Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce 'pg_catalog.pg_type' #4332

Merged
merged 16 commits into from
Jul 15, 2024
Merged

Conversation

J0HN50N133
Copy link
Contributor

@J0HN50N133 J0HN50N133 commented Jul 10, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#3560

What's changed and what's your intention?

Refactor the structure of src/catalog adapting to both pg_catalog and information_schema. Add one of the most simple pg_catalog table: pg_type support

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • New Features
    • Introduced pg_catalog schema support, adding PostgreSQL catalog functionality and enhancing schema management capabilities.
  • Bug Fixes
    • Updated SQL query results to include pg_catalog, ensuring consistent database visibility and schema reporting.
  • Refactor
    • Reorganized module structures for improved code maintainability and legacy compatibility.
  • Tests
    • Added test cases to verify the inclusion of pg_catalog in database listings and schema queries.

@J0HN50N133 J0HN50N133 requested a review from a team as a code owner July 10, 2024 08:38
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes introduce a new PGCatalogProvider to manage the pg_catalog schema alongside the information_schema schema within the SystemCatalog struct. The update reorganizes module structures, enhances schema and table management functionalities, and updates constants. Test cases are modified to reflect the inclusion of pg_catalog, and new functionalities for handling PostgreSQL catalog tables are added.

Changes

File(s) Change Summary
src/catalog/src/kvbackend/manager.rs Introduced PGCatalogProvider, modified SystemCatalog to include pg_catalog, and updated schema and table methods.
src/catalog/src/lib.rs Renamed information_schema to system_schema and created a new information_schema module for legacy compatibility.
src/catalog/src/memory/manager.rs Added PG_CATALOG_NAME constant and registered schema with PG_CATALOG_NAME.
src/catalog/src/system_schema.rs Added modules and traits for system schema management, including pg_catalog.
src/catalog/src/system_schema/information_schema.rs Restructured InformationSchemaProvider and related imports and methods.
src/catalog/src/system_schema/information_schema/information_memory_table.rs Refactored imports and modified function visibility to pub(super).
src/catalog/src/system_schema/information_schema/views.rs Moved imports to reflect new code organization.
src/catalog/src/system_schema/memory_table.rs Updated module imports, visibility, and added SystemTable implementation.
src/catalog/src/system_schema/pg_catalog.rs Introduced PGCatalogProvider, memory tables, and methods for pg_catalog.
src/common/catalog/src/consts.rs Added constants related to PG_CATALOG_NAME and pg_catalog tables.
tests/cases/standalone/common/create/create_database.result Added pg_catalog to the list of databases.
tests/cases/standalone/common/create/create_database_opts.result Added pg_catalog to the databases listed in SQL queries.
tests/cases/standalone/common/information_schema/tables.result Added pg_type under pg_catalog in query results.
tests/cases/standalone/common/show/show_databases_tables.result Updated SHOW DATABASES output to include pg_catalog.
tests/cases/standalone/common/system/information_schema.result Added and modified entries for pg_type in pg_catalog within information_schema.
tests-integration/src/tests/instance_test.rs Updated test functions to reflect the inclusion of pg_catalog.
src/catalog/src/system_schema/memory_table/tables.rs Added functions to create column schemas for memory tables.
src/catalog/src/system_schema/memory_table/table_columns.rs Added macro memory_table_cols for table column processing.
src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs Added functions for defining schema columns for PostgreSQL catalog tables.

Poem

In the fields of code, rabbits hop with glee,
New schemas bloom, pg_catalog set free.
With tables and columns, a structure so neat,
Information flows, a rhythmic beat.
Tests now reflect a broadened sky,
pg_catalog joins, reaching high.
Hopping through data, a joyful spree,
Code and rabbit, in harmony.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
src/catalog/src/kvbackend/manager.rs (1)

305-305: Documentation update for system tables

The documentation update reflects the addition of pg_catalog tables, ensuring that the documentation is consistent with the new functionality.

- /// - public.numbers
- /// - information_schema.{tables}
+ /// - public.numbers
+ /// - information_schema.{tables}
+ /// - pg_catalog.{tables}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da0c840 and e2693bd.

Files selected for processing (28)
  • src/catalog/src/kvbackend/manager.rs (5 hunks)
  • src/catalog/src/lib.rs (1 hunks)
  • src/catalog/src/memory/manager.rs (3 hunks)
  • src/catalog/src/system_schema.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema.rs (5 hunks)
  • src/catalog/src/system_schema/information_schema/cluster_info.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema/information_memory_table.rs (2 hunks)
  • src/catalog/src/system_schema/information_schema/key_column_usage.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema/partitions.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema/region_peers.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema/schemata.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema/tables.rs (1 hunks)
  • src/catalog/src/system_schema/memory_table.rs (8 hunks)
  • src/catalog/src/system_schema/memory_table/table_columns.rs (1 hunks)
  • src/catalog/src/system_schema/memory_table/tables.rs (1 hunks)
  • src/catalog/src/system_schema/pg_catalog.rs (1 hunks)
  • src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs (1 hunks)
  • src/catalog/src/system_schema/pg_catalog/table_names.rs (1 hunks)
  • src/common/catalog/src/consts.rs (2 hunks)
  • tests/cases/standalone/common/create/create_database.result (1 hunks)
  • tests/cases/standalone/common/create/create_database_opts.result (3 hunks)
  • tests/cases/standalone/common/information_schema/tables.result (1 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.result (2 hunks)
  • tests/cases/standalone/common/system/information_schema.result (6 hunks)
  • tests/cases/standalone/common/system/information_schema.sql (1 hunks)
  • tests/cases/standalone/common/system/pg_catalog.result (1 hunks)
  • tests/cases/standalone/common/system/pg_catalog.sql (1 hunks)
  • tests/cases/standalone/common/view/create.result (1 hunks)
Files skipped from review due to trivial changes (10)
  • src/catalog/src/system_schema/information_schema/key_column_usage.rs
  • src/catalog/src/system_schema/information_schema/partitions.rs
  • src/catalog/src/system_schema/information_schema/schemata.rs
  • src/catalog/src/system_schema/information_schema/tables.rs
  • src/catalog/src/system_schema/pg_catalog/table_names.rs
  • tests/cases/standalone/common/create/create_database.result
  • tests/cases/standalone/common/create/create_database_opts.result
  • tests/cases/standalone/common/information_schema/tables.result
  • tests/cases/standalone/common/show/show_databases_tables.result
  • tests/cases/standalone/common/system/information_schema.sql
Additional comments not posted (46)
tests/cases/standalone/common/system/pg_catalog.sql (1)

1-4: SQL commands are correct.

The commands correctly test the creation and selection from the pg_catalog schema.

tests/cases/standalone/common/system/pg_catalog.result (1)

1-31: Expected results are correct.

The results correctly reflect the error and the contents of the pg_type table.

src/catalog/src/system_schema/memory_table/table_columns.rs (1)

1-50: Macro and test are correct.

The memory_table_cols macro correctly initializes and populates columns. The test verifies its correctness.

src/catalog/src/system_schema/memory_table/tables.rs (1)

1-79: Functions and tests are correct.

The functions correctly create column schemas for various data types. The tests verify their correctness.

src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs (1)

24-59: LGTM! Verify the usage of the macro memory_table_cols!.

The function pg_type_schema_columns correctly defines columns and their types for the pg_type table in the pg_catalog schema.

However, ensure the macro memory_table_cols! is used correctly and consistently throughout the codebase.

Verification successful

LGTM!

The macro memory_table_cols! is correctly defined and consistently used in the codebase.

  • Definition in src/catalog/src/system_schema/memory_table/table_columns.rs
  • Usage in src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs
  • Usage in src/catalog/src/system_schema/memory_table/table_columns.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the macro `memory_table_cols!`.

# Test: Search for the macro usage. Expect: Consistent usage throughout the codebase.
rg --type rust --word memory_table_cols

Length of output: 479


Script:

#!/bin/bash
# Description: Verify the usage of the macro `memory_table_cols!`.

# Test: Search for the macro usage. Expect: Consistent usage throughout the codebase.
rg --type rust --word-regexp memory_table_cols

Length of output: 418


Script:

#!/bin/bash
# Extract the definition of the macro `memory_table_cols!` and its usages in the specified files.

# Extract the macro definition
echo "Macro Definition in table_columns.rs:"
rg --type rust --context 10 --word-regexp "macro_rules! memory_table_cols" src/catalog/src/system_schema/memory_table/table_columns.rs

# Extract the macro usage in pg_catalog_memory_table.rs
echo -e "\nMacro Usage in pg_catalog_memory_table.rs:"
rg --type rust --context 10 --word-regexp "memory_table_cols" src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs

# Extract the macro usage in table_columns.rs
echo -e "\nMacro Usage in table_columns.rs:"
rg --type rust --context 10 --word-regexp "memory_table_cols" src/catalog/src/system_schema/memory_table/table_columns.rs

Length of output: 3410

src/catalog/src/lib.rs (2)

34-37: LGTM!

The module declaration for system_schema and the re-export of information_schema for legacy compatibility are correct.


Line range hint 40-89:
LGTM!

The trait CatalogManager defines various async methods for managing catalogs, schemas, and tables. The return types and method signatures are appropriate.

src/catalog/src/system_schema/pg_catalog.rs (4)

47-51: LGTM!

The struct PGCatalogProvider correctly includes fields for catalog name, catalog manager, and tables. The use of Weak for the catalog manager is appropriate.


79-87: LGTM!

The new function correctly initializes a new PGCatalogProvider instance and calls build_tables to initialize the tables.


89-97: LGTM!

The build_tables function correctly initializes the tables for the PGCatalogProvider by iterating over MEMORY_TABLES. The note regarding security rules is a good practice.


62-76: LGTM!

The setup_memory_table macro correctly sets up memory tables for the pg_catalog schema. The use of the paste crate is appropriate.

src/common/catalog/src/consts.rs (1)

99-104: LGTM!

The constants related to the pg_catalog schema are correctly defined. The use of a mask for table IDs ensures uniqueness.

src/catalog/src/system_schema.rs (4)

15-18: Module declarations align with the new structure.

The new module declarations for information_schema, memory_table, and pg_catalog align with the reorganization and new additions mentioned in the PR summary.


37-61: Introduction of SystemSchemaProvider trait is well-defined.

The methods within the SystemSchemaProvider trait for managing system tables are well-defined and align with the overall goal of managing system tables.


63-94: Introduction of SystemSchemaProviderInner trait is clear and necessary.

The methods within the SystemSchemaProviderInner trait provide necessary internal operations for managing system schemas.


97-164: Introduction of SystemTable trait and its implementations is well-structured.

The SystemTable trait, associated types, and implementations are well-structured and necessary for defining and managing system tables.

src/catalog/src/system_schema/memory_table.rs (3)

15-17: Module declarations align with the new structure.

The new module declarations for table_columns and tables align with the reorganization and new additions mentioned in the PR summary.


Line range hint 37-60:
Introduction of MemoryTable struct and its methods is well-structured.

The MemoryTable struct and its methods provide necessary functionality for managing in-memory tables.


107-138: Implementation of SystemTable for MemoryTable is well-structured.

The implementation of SystemTable for MemoryTable aligns with the SystemTable trait and provides necessary functionality for in-memory tables.

src/catalog/src/system_schema/information_schema.rs (4)

17-18: Module declarations align with the new structure.

The new module declarations for information_memory_table and key_column_usage align with the reorganization and new additions mentioned in the PR summary.


108-114: Implementation of SystemSchemaProvider for InformationSchemaProvider is well-structured.

The implementation of SystemSchemaProvider for InformationSchemaProvider aligns with the SystemSchemaProvider trait and provides necessary functionality for managing information schema tables.


Line range hint 115-182:
Implementation of SystemSchemaProviderInner for InformationSchemaProvider is well-structured.

The implementation of SystemSchemaProviderInner for InformationSchemaProvider aligns with the SystemSchemaProviderInner trait and provides necessary internal operations for managing information schema tables.


258-280: Compatibility implementation for legacy information_schema code is well-structured.

The compatibility implementation ensures backward compatibility with legacy information_schema code.

src/catalog/src/system_schema/information_schema/region_peers.rs (1)

43-43: Implementation of InformationSchemaRegionPeers is well-structured.

The implementation of InformationSchemaRegionPeers and related traits for managing region peers information is detailed and aligns with the overall goal of managing region peers information.

src/catalog/src/system_schema/information_schema/cluster_info.rs (1)

44-44: Importing new modules from information_schema

The import of utils, InformationTable, and Predicates from information_schema is necessary to support the new functionality introduced for managing cluster info.

src/catalog/src/kvbackend/manager.rs (9)

22-22: Addition of PG_CATALOG_NAME constant

The addition of the PG_CATALOG_NAME constant is necessary for the new pg_catalog schema.


50-51: Importing PGCatalogProvider

The import of PGCatalogProvider from system_schema::pg_catalog is necessary for managing the new pg_catalog schema.


96-99: Initialization of pg_catalog_provider in KvBackendCatalogManager

The initialization of pg_catalog_provider in the KvBackendCatalogManager constructor is essential for supporting the new pg_catalog schema.


311-311: Addition of pg_catalog_provider to SystemCatalog struct

The addition of pg_catalog_provider to the SystemCatalog struct is necessary for managing the new pg_catalog schema.


315-320: Schema names method update

The schema_names method now includes PG_CATALOG_NAME, allowing the system to recognize the pg_catalog schema.


324-330: Table names method update

The table_names method now includes handling for PG_CATALOG_NAME, enabling the system to manage tables within the pg_catalog schema.


335-335: Schema exists method update

The schema_exists method now checks for the pg_catalog schema, ensuring the system can verify the existence of this schema.


343-344: Table exists method update

The table_exists method now includes a check for tables within the pg_catalog schema, ensuring proper management of these tables.


360-362: Table method update

The table method now includes handling for the pg_catalog schema, ensuring that the system can retrieve tables from this schema.

src/catalog/src/memory/manager.rs (4)

23-24: Addition of PG_CATALOG_NAME constant

The addition of the PG_CATALOG_NAME constant is necessary for the new pg_catalog schema.


32-32: Importing SystemSchemaProvider

The import of SystemSchemaProvider is necessary to support the new system schema changes.


178-183: Registering pg_catalog schema

The registration of the pg_catalog schema in the with_default_setup method ensures that the memory catalog manager recognizes and can manage this new schema.


207-207: Update to catalog_exist_sync method

The update to the catalog_exist_sync method is necessary to ensure that the pg_catalog schema is recognized by the system.

src/catalog/src/system_schema/information_schema/information_memory_table.rs (3)

18-24: Importing necessary modules

The import of Schema, SchemaRef, and VectorRef from datatypes::schema and datatypes::vectors is necessary for defining the schemas and columns for the new tables.


21-24: Importing table names and memory table utilities

The import of table_names and memory table utilities is necessary for defining the schemas and columns for the new tables.


30-30: Defining schemas and columns for new tables

The function get_schema_columns defines the schemas and columns for various new tables in the information_schema. This change is necessary to support the new functionality.

tests/cases/standalone/common/view/create.result (1)

97-97: Addition of pg_type table in pg_catalog schema looks good.

The new entry for the pg_type table in the pg_catalog schema is consistent with the existing entries.

tests/cases/standalone/common/system/information_schema.result (4)

45-45: Addition of pg_type table entry in pg_catalog schema is appropriate.

The addition of this entry aligns with the objective of supporting pg_catalog.


391-393: Addition of columns for pg_type table in pg_catalog schema is appropriate.

The columns oid, typlen, and typname are standard for the pg_type table and their inclusion aligns with the PR objective.


449-449: Addition of filter to exclude pg_catalog schema is appropriate.

This change ensures that the query does not return tables from the pg_catalog schema, aligning with the PR objective.


463-463: Addition of filter to exclude pg_catalog schema is appropriate.

This change ensures that the query does not return tables from the pg_catalog schema, aligning with the PR objective.

@J0HN50N133 J0HN50N133 changed the title feat: support of 'pg_catalog.pg_type' feat: introduce 'pg_catalog.pg_type' Jul 10, 2024
@J0HN50N133
Copy link
Contributor Author

@tisonkun can you review on this?

@tisonkun
Copy link
Contributor

These cases failed:

  TRY 4 FAIL [   0.670s] tests-integration tests::instance_test::test_execute_show_databases_tables::case_1_test_with_standalone
  TRY 4 FAIL [   0.747s] tests-integration tests::instance_test::test_execute_show_databases_tables::case_2_test_with_distributed
  TRY 3 FAIL [   0.689s] tests-integration tests::instance_test::test_show_databases::case_1_test_with_standalone
  TRY 3 FAIL [   0.755s] tests-integration tests::instance_test::test_show_databases::case_2_test_with_distributed

I think it's mainly we add a new table. Please update them correspondingly.

@killme2008
Copy link
Contributor

@waynexia @evenyag Are you aware of PG? If yes, please have a look.

@github-actions github-actions bot added docs-required This change requires docs update. docs-not-required This change does not impact docs. and removed docs-not-required This change does not impact docs. docs-required This change requires docs update. labels Jul 11, 2024
@J0HN50N133
Copy link
Contributor Author

These cases failed:

  TRY 4 FAIL [   0.670s] tests-integration tests::instance_test::test_execute_show_databases_tables::case_1_test_with_standalone
  TRY 4 FAIL [   0.747s] tests-integration tests::instance_test::test_execute_show_databases_tables::case_2_test_with_distributed
  TRY 3 FAIL [   0.689s] tests-integration tests::instance_test::test_show_databases::case_1_test_with_standalone
  TRY 3 FAIL [   0.755s] tests-integration tests::instance_test::test_show_databases::case_2_test_with_distributed

I think it's mainly we add a new table. Please update them correspondingly.

Fixed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e2693bd and eca7744.

Files selected for processing (2)
  • src/catalog/src/kvbackend/manager.rs (5 hunks)
  • tests-integration/src/tests/instance_test.rs (3 hunks)
Additional comments not posted (10)
src/catalog/src/kvbackend/manager.rs (8)

22-22: Import change looks good.

The addition of PG_CATALOG_NAME is necessary to support the new pg_catalog schema.


50-50: Import change looks good.

The addition of PGCatalogProvider is necessary to support the new pg_catalog schema.


51-51: Import change looks good.

The addition of SystemSchemaProvider is necessary to support the new system schema handling.


92-100: Changes to KvBackendCatalogManager::new look good.

Adding pg_catalog_cache and initializing pg_catalog_provider are necessary to support the new pg_catalog schema.


311-311: Changes to SystemCatalog look good.

Adding pg_catalog_cache is necessary to support caching for the new pg_catalog schema.


315-315: Changes to SystemCatalog look good.

Adding pg_catalog_provider is necessary to support the new pg_catalog schema.


319-324: Changes to SystemCatalog::schema_names look good.

Adding PG_CATALOG_NAME to the list of schema names is necessary to support the new pg_catalog schema.


328-331: Changes to SystemCatalog::table_names look good.

Adding support for pg_catalog in the table_names method is necessary to support the new pg_catalog schema.

tests-integration/src/tests/instance_test.rs (2)

465-465: Verify the inclusion of pg_catalog in the database listings.

Ensure that the pg_catalog schema is correctly included in the output of the "show databases" command.

Verification successful

Verify that pg_catalog is included in the test assertions for "show databases" command.

Check the test assertions to ensure that pg_catalog is included in the expected output.


Verified inclusion of pg_catalog in the database listings.

The integration test correctly includes pg_catalog in the expected output of the "show databases" command.

  • tests-integration/src/tests/instance_test.rs
    • Line 465: The expected output includes pg_catalog.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `pg_catalog` is included in the output of the "show databases" command.

# Test: Execute the command and check the output. Expect: `pg_catalog` should be listed.
rg --type rust 'show databases' -A 5

Length of output: 2056


Script:

#!/bin/bash
# Description: Search for test assertions that check the output of the "show databases" command in the `instance_test.rs` file.

# We will look for patterns that define expected output to include `pg_catalog`.
rg --type rust 'expected' tests-integration/src/tests/instance_test.rs -A 5

Length of output: 14982


1903-1903: Verify the inclusion of pg_catalog in the database listings.

Ensure that the pg_catalog schema is correctly included in the output of the "show databases" command in a different context.

Verification successful

The pg_catalog schema is correctly included in the expected output of the "show databases" command.

The test case in tests-integration/src/tests/instance_test.rs confirms that pg_catalog is part of the expected output.

  • Location in the codebase:
    • tests-integration/src/tests/instance_test.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `pg_catalog` is included in the output of the "show databases" command in a different context.

# Test: Execute the command and check the output. Expect: `pg_catalog` should be listed.
rg --type rust 'show databases' -A 5

Length of output: 2056


Script:

#!/bin/bash
# Description: Verify that `pg_catalog` is included in the expected output of the "show databases" command in the test cases.

# Search for the expected output in the test cases.
rg 'execute_sql\(&instance, "show databases"\)' -A 5 tests-integration/src/tests/instance_test.rs

Length of output: 336


Script:

#!/bin/bash
# Description: Verify that `pg_catalog` is included in the expected output of the "show databases" command in the test cases.

# Search for the complete expected output in the test cases.
rg 'let expected =' -A 10 tests-integration/src/tests/instance_test.rs

Length of output: 16591

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 97.93510% with 7 lines in your changes missing coverage. Please review.

Project coverage is 84.96%. Comparing base (04ac0c8) to head (f0e8e79).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4332      +/-   ##
==========================================
- Coverage   85.24%   84.96%   -0.28%     
==========================================
  Files        1068     1073       +5     
  Lines      191277   191406     +129     
==========================================
- Hits       163046   162629     -417     
- Misses      28231    28777     +546     

src/catalog/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

This is generally in a good direction and I believe we can almost merge it first and improve details later, since it won't introduce regressions.

A few comments inline to avoid unnecessary back and forth changes.

@tisonkun
Copy link
Contributor

@J0HN50N133 @killme2008 @evenyag

Let's try to push forward this PR together. It's the first step for pg_catalog and changing the system table file structure.

If we keep it open for a long time, it will conflict with every following changes to information_schema, which introduces unnecessary burden to keep track on.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eca7744 and f0e8e79.

Files selected for processing (11)
  • src/catalog/src/lib.rs (1 hunks)
  • src/catalog/src/system_schema/information_schema.rs (5 hunks)
  • src/catalog/src/system_schema/information_schema/information_memory_table.rs (2 hunks)
  • src/catalog/src/system_schema/information_schema/views.rs (1 hunks)
  • src/catalog/src/system_schema/memory_table.rs (8 hunks)
  • src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs (1 hunks)
  • src/common/catalog/src/consts.rs (2 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.result (2 hunks)
  • tests/cases/standalone/common/system/information_schema.result (6 hunks)
  • tests/cases/standalone/common/system/information_schema.sql (1 hunks)
  • tests/cases/standalone/common/view/create.result (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/catalog/src/system_schema/information_schema/views.rs
Files skipped from review as they are similar to previous changes (9)
  • src/catalog/src/system_schema/information_schema.rs
  • src/catalog/src/system_schema/information_schema/information_memory_table.rs
  • src/catalog/src/system_schema/memory_table.rs
  • src/catalog/src/system_schema/pg_catalog/pg_catalog_memory_table.rs
  • src/common/catalog/src/consts.rs
  • tests/cases/standalone/common/show/show_databases_tables.result
  • tests/cases/standalone/common/system/information_schema.result
  • tests/cases/standalone/common/system/information_schema.sql
  • tests/cases/standalone/common/view/create.result
Additional comments not posted (2)
src/catalog/src/lib.rs (2)

34-34: Module system_schema added.

The system_schema module is correctly defined and integrated.


35-37: Re-export information_schema for legacy compatibility.

The information_schema module is correctly re-exported from system_schema. The TODO comment suggests migrating to the new path later.

Copy link
Member

@sunng87 sunng87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sunng87
Copy link
Member

sunng87 commented Jul 15, 2024

This looks awesome from my side. It's great as a start of introducing postgres metatables. It also contains some refactoring to make system schema API more friendly.

There are some non-blocking issues we can think about next:

  • I hope we can hold this until 0.9 release
  • Can we add a restriction to show this pg_catalog only when user connects from postgresql protocol? It's not a big issue but seeing pg_catalog from mysql client can a little weird.
  • Also I found this SystemCatalog naming is becoming a little confusing after some time when we won't have a real catalog called system. WDYT @evenyag

@tisonkun tisonkun added this pull request to the merge queue Jul 15, 2024
@tisonkun
Copy link
Contributor

Thanks for your contribution! Please go ahead :D

Merged via the queue into GreptimeTeam:main with commit 072d7c2 Jul 15, 2024
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants