DigitalChinaOpenSource / TiDB-for-PostgreSQL

PgSQL compatible on distributed database TiDB
Apache License 2.0
387 stars 21 forks source link

Implement the compatibility of PostgreSQL system tables #33

Open Orion7r opened 3 years ago

Orion7r commented 3 years ago

Development Task

Description

The system library of PostgreSQL is information schema and pg catalog, which is different from TiDB. These two databases are implemented in TiDB for PostgreSQL, but the implementation of system tables and system views in these two databases is not perfect and needs to be supplemented.

The implementation of system tables and system views is mainly to be compatible with query requests connected from clients, such as PgAdmin and Navicat, so that these clients can connect to TiDB for PostgreSQL using PostgreSQL protocol.

Detailed information about information_schema and pg_catalog can be found in the following two links. information_schema pg_catalog

This section mainly covers the InfoSchema and Executor directories. System tables and views are defined in InfoSchema. System table structures can be defined in the tables.go file, and infoschema_reader.go file in Executor, which involves initialization of related system table data.

Currently, we only implement the related system tables for information_schema, but there is no initialization for the data that exists in the system tables, which means that most of the tables are empty, which is definitely not normal. For pg_catalog, instead of implementing information_schema, we use the session module to execute SQL statements to initialize system tables, system views and data in pg_catalog before starting TiDB. This needs to be changed later to the same implementation as information_schema.

Task List

  1. The initial data for the system table in information_schema
  2. Tables and corresponding data in the pg_catalog system library

Methods or modules that need to be implemented: