Skip to content

Spr 929 add table comment#580

Merged
garthgoodson merged 8 commits into
mainfrom
SPR-929-add-table-comment
Aug 15, 2025
Merged

Spr 929 add table comment#580
garthgoodson merged 8 commits into
mainfrom
SPR-929-add-table-comment

Conversation

@ella-springtail

Copy link
Copy Markdown
Contributor

Added support for table comment for partitioned tables.

@linear

linear Bot commented Aug 11, 2025

Copy link
Copy Markdown
SPR-929 Use COMMENT sql to tag FDW tables with table ID

For foreign tables on the FDW/DDL mgr we use the foreign table options to store the primary table ID (oid). This is used by the policy code to validate that a table exists when applying a policy. However, we don't have a similar way to do it for partitioned tables that are created as regular, not foreign tables.

The proposal is to use the COMMENT sql call to add a comment tid:<oid> to the regular tables. The DDL mgr should be modified when it creates a regular (non-foreign) table. This code may be in the fdw common file.

As well, on startup import schema is called to create the tables. I'm not sure if we iterate through the partition tables in another way on startup, if so we can add the COMMENT sql calls there (COMMENT can not be added directly to the import schema call), if not we will need something to iterate the non-foreign tables, and applying the COMMENT after looking them up in the tablename system table; the system table indicates if the table is a regular table by the presence of a partition_key, if no partition_key exists the table is not a regular table. Then one can extract the TID, namespace name and table name and add the COMMENT. It is not expected that there are a lot of these tables.

Lastly, in the policy branch, there is a check for table existence, currently it checks the foreign table options for the TID, a check must be added to check the comments for the TID as well.

@garthgoodson garthgoodson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couple of improvements suggested.

Comment thread include/pg_fdw/pg_fdw_ddl_common.hh Outdated
Comment thread src/pg_fdw/pg_ddl_mgr.cc
Comment thread src/pg_fdw/pg_ddl_mgr.cc Outdated
@sonarqubecloud

Copy link
Copy Markdown

@garthgoodson garthgoodson merged commit db696f2 into main Aug 15, 2025
7 checks passed
@garthgoodson garthgoodson deleted the SPR-929-add-table-comment branch August 15, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants