From 46cdfe82c405b94d98dfeb9ece205f89ef3ab235 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Sat, 23 Jul 2022 15:43:45 +0800 Subject: [PATCH] create table/comment support --- src/common/backend/nodes/copyfuncs.cpp | 3 + src/common/backend/nodes/equalfuncs.cpp | 3 + src/common/backend/nodes/outfuncs.cpp | 9 ++ src/common/backend/nodes/readfuncs.cpp | 6 + src/common/backend/parser/gram.y | 140 ++++++++++++++++++++-- src/common/backend/utils/init/globals.cpp | 4 +- src/gausskernel/process/tcop/utility.cpp | 45 +++++++ src/include/miscadmin.h | 1 + src/include/nodes/parsenodes.h | 1 + src/include/nodes/parsenodes_common.h | 2 + src/test/regress/expected/b_comments.out | 81 +++++++++++++ src/test/regress/parallel_schedule0 | 2 +- src/test/regress/sql/b_comments.sql | 62 ++++++++++ 13 files changed, 346 insertions(+), 13 deletions(-) create mode 100644 src/test/regress/expected/b_comments.out create mode 100644 src/test/regress/sql/b_comments.sql diff --git a/src/common/backend/nodes/copyfuncs.cpp b/src/common/backend/nodes/copyfuncs.cpp index ccd6ac137..064ca29df 100644 --- a/src/common/backend/nodes/copyfuncs.cpp +++ b/src/common/backend/nodes/copyfuncs.cpp @@ -4100,6 +4100,7 @@ static ColumnDef* _copyColumnDef(const ColumnDef* from) COPY_SCALAR_FIELD(collOid); COPY_NODE_FIELD(constraints); COPY_NODE_FIELD(fdwoptions); + COPY_NODE_FIELD(columnOptions); COPY_NODE_FIELD(clientLogicColumnRef); COPY_NODE_FIELD(position); @@ -4965,6 +4966,7 @@ static void CopyCreateStmtFields(const CreateStmt* from, CreateStmt* newnode) COPY_NODE_FIELD(distributeby); COPY_NODE_FIELD(subcluster); #endif + COPY_NODE_FIELD(tableOptions); COPY_STRING_FIELD(internalData); COPY_NODE_FIELD(uuids); COPY_SCALAR_FIELD(relkind); @@ -5109,6 +5111,7 @@ static IndexStmt* _copyIndexStmt(const IndexStmt* from) COPY_SCALAR_FIELD(oldNode); COPY_NODE_FIELD(partClause); COPY_SCALAR_FIELD(partIndexUsable); + COPY_NODE_FIELD(indexOptions); COPY_SCALAR_FIELD(isPartitioned); COPY_SCALAR_FIELD(unique); COPY_SCALAR_FIELD(primary); diff --git a/src/common/backend/nodes/equalfuncs.cpp b/src/common/backend/nodes/equalfuncs.cpp index c4bcfa364..2f2e6d896 100644 --- a/src/common/backend/nodes/equalfuncs.cpp +++ b/src/common/backend/nodes/equalfuncs.cpp @@ -1155,6 +1155,7 @@ static bool _equalCreateStmt(const CreateStmt* a, const CreateStmt* b) COMPARE_NODE_FIELD(distributeby); COMPARE_NODE_FIELD(subcluster); #endif + COMPARE_NODE_FIELD(tableOptions); COMPARE_STRING_FIELD(internalData); COMPARE_NODE_FIELD(uuids); COMPARE_SCALAR_FIELD(relkind); @@ -1395,6 +1396,7 @@ static bool _equalIndexStmt(const IndexStmt* a, const IndexStmt* b) COMPARE_SCALAR_FIELD(indexOid); COMPARE_SCALAR_FIELD(oldNode); COMPARE_NODE_FIELD(partClause); + COMPARE_NODE_FIELD(indexOptions); COMPARE_SCALAR_FIELD(isPartitioned); COMPARE_SCALAR_FIELD(unique); COMPARE_SCALAR_FIELD(primary); @@ -2562,6 +2564,7 @@ static bool _equalColumnDef(const ColumnDef* a, const ColumnDef* b) COMPARE_SCALAR_FIELD(collOid); COMPARE_NODE_FIELD(constraints); COMPARE_NODE_FIELD(fdwoptions); + COMPARE_NODE_FIELD(columnOptions); return true; } diff --git a/src/common/backend/nodes/outfuncs.cpp b/src/common/backend/nodes/outfuncs.cpp index 08b7e9a01..d69e4ea5a 100755 --- a/src/common/backend/nodes/outfuncs.cpp +++ b/src/common/backend/nodes/outfuncs.cpp @@ -3472,6 +3472,9 @@ static void _outCreateStmtInfo(StringInfo str, const CreateStmt* node) WRITE_BOOL_FIELD(ivm); } WRITE_NODE_FIELD(partTableState); + if (t_thrd.proc->workingVersionNum >= COMMENT_SUPPORT_VERSION_NUM) { + WRITE_NODE_FIELD(tableOptions); + } WRITE_NODE_FIELD(uuids); if (t_thrd.proc->workingVersionNum >= MATVIEW_VERSION_NUM) { WRITE_CHAR_FIELD(relkind); @@ -3608,6 +3611,9 @@ static void _outIndexStmt(StringInfo str, IndexStmt* node) WRITE_OID_FIELD(indexOid); WRITE_OID_FIELD(oldNode); WRITE_NODE_FIELD(partClause); + if (t_thrd.proc->workingVersionNum >= COMMENT_SUPPORT_VERSION_NUM) { + WRITE_NODE_FIELD(indexOptions); + } WRITE_BOOL_FIELD(isPartitioned); WRITE_BOOL_FIELD(unique); WRITE_BOOL_FIELD(primary); @@ -3804,6 +3810,9 @@ static void _outColumnDef(StringInfo str, ColumnDef* node) WRITE_OID_FIELD(collOid); WRITE_NODE_FIELD(constraints); WRITE_NODE_FIELD(fdwoptions); + if (t_thrd.proc->workingVersionNum >= COMMENT_SUPPORT_VERSION_NUM) { + WRITE_NODE_FIELD(columnOptions); + } WRITE_NODE_FIELD(clientLogicColumnRef); if (t_thrd.proc->workingVersionNum >= GENERATED_COL_VERSION_NUM) { if (node->generatedCol) diff --git a/src/common/backend/nodes/readfuncs.cpp b/src/common/backend/nodes/readfuncs.cpp index 232fefb3f..60f50d46e 100755 --- a/src/common/backend/nodes/readfuncs.cpp +++ b/src/common/backend/nodes/readfuncs.cpp @@ -5274,6 +5274,9 @@ static ColumnDef* _readColumnDef() READ_OID_FIELD(collOid); READ_NODE_FIELD(constraints); READ_NODE_FIELD(fdwoptions); + IF_EXIST(columnOptions) { + READ_NODE_FIELD(columnOptions); + } READ_NODE_FIELD(clientLogicColumnRef); if (local_node->storage == '0') { local_node->storage = 0; @@ -5383,6 +5386,9 @@ static IndexStmt* _readIndexStmt() READ_OID_FIELD(indexOid); READ_OID_FIELD(oldNode); READ_NODE_FIELD(partClause); + IF_EXIST(columnOptions) { + READ_NODE_FIELD(indexOptions); + } READ_BOOL_FIELD(isPartitioned); READ_BOOL_FIELD(unique); READ_BOOL_FIELD(primary); diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index c353719df..0227edb69 100644 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -246,6 +246,9 @@ static char* MakeConnectByRootColName(char* tabname, char* colname); static void FilterStartWithUseCases(SelectStmt* stmt, List* locking_clause, core_yyscan_t yyscanner, int location); static FuncCall* MakePriorAsFunc(); +/* B Compatibility Check */ +static void BCompatibilityOptionSupportCheck(); + #ifndef ENABLE_MULTIPLE_NODES static bool CheckWhetherInColList(char *colname, List *col_list); #endif @@ -486,6 +489,11 @@ static int errstate; relation_expr_list dostmt_opt_list merge_values_clause publication_name_list +/* b compatibility: comment start */ +%type opt_index_options index_options opt_table_options table_options opt_column_options column_options +%type index_option table_option column_option +/* b compatibility: comment end */ + %type group_by_list %type group_by_item empty_grouping_set rollup_clause cube_clause %type grouping_sets_clause @@ -901,6 +909,7 @@ static int errstate; START_WITH CONNECT_BY /* Precedence: lowest to highest */ +%nonassoc COMMENT %nonassoc PARTIAL_EMPTY_PREC %nonassoc CLUSTER %nonassoc SET /* see relation_expr_opt_alias */ @@ -4045,6 +4054,92 @@ opt_reloptions: WITH reloptions { $$ = $2; } | /* EMPTY */ { $$ = NIL; } ; +opt_index_options: + /* EMPTY */ { $$ = NIL; } + | index_options { $$ = $1; } + ; +index_options: + index_option + { + BCompatibilityOptionSupportCheck(); + $$ = list_make1($1); + } + | index_options index_option + { + $$ = lcons($2, $1); + } + ; +index_option: + COMMENT opt_equal Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_INDEX; + n->objname = NIL; + n->objargs = NIL; + n->comment = $3; + $$ = (Node*)n; + } + ; + +opt_table_options: + /* EMPTY */ { $$ = NIL; } + | table_options { $$ = $1; } + ; +table_options: + table_option + { + BCompatibilityOptionSupportCheck(); + $$ = list_make1($1); + } + | table_options opt_comma table_option + { + $$ = lcons($3, $1); + } + ; +table_option: + COMMENT opt_equal Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TABLE; + n->objname = NIL; + n->objargs = NIL; + n->comment = $3; + $$ = (Node*)n; + } + ; + +opt_comma: + /* empty */ + | ',' + ; + +opt_column_options: + /* EMPTY */ { $$ = NIL; } + | column_options { $$ = $1; } + ; +column_options: + column_option + { + BCompatibilityOptionSupportCheck(); + $$ = list_make1($1); + } + | column_options column_option + { + $$ = lcons($2, $1); + } + ; +column_option: + COMMENT Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_COLUMN; + n->objname = NIL; + n->objargs = NIL; + n->comment = $2; + $$ = (Node*)n; + } + ; + reloption_list: reloption_elem { $$ = list_make1($1); } | reloption_list ',' reloption_elem { $$ = lappend($1, $3); } @@ -4912,12 +5007,13 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' /* PGXC_BEGIN */ OptDistributeBy OptSubCluster /* PGXC_END */ + opt_table_options opt_table_partitioning_clause opt_internal_data OptKind { CreateStmt *n = makeNode(CreateStmt); $4->relpersistence = $2; - n->relkind = $17; + n->relkind = $18; n->relation = $4; n->tableElts = $6; n->inhRelations = $8; @@ -4931,8 +5027,9 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->distributeby = $13; n->subcluster = $14; /* PGXC_END */ - n->partTableState = (PartitionState *)$15; - n->internalData = $16; + n->tableOptions = $15; + n->partTableState = (PartitionState *)$16; + n->internalData = $17; $$ = (Node *)n; } | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' @@ -4941,6 +5038,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' /* PGXC_BEGIN */ OptDistributeBy OptSubCluster /* PGXC_END */ + opt_table_options opt_table_partitioning_clause opt_internal_data { @@ -4959,8 +5057,9 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->distributeby = $16; n->subcluster = $17; /* PGXC_END */ - n->partTableState = (PartitionState *)$18; - n->internalData = $19; + n->tableOptions = $18; + n->partTableState = (PartitionState *)$19; + n->internalData = $20; $$ = (Node *)n; } | CREATE OptTemp TABLE qualified_name OF any_name @@ -4968,6 +5067,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' /* PGXC_BEGIN */ OptDistributeBy OptSubCluster /* PGXC_END */ + opt_table_options { CreateStmt *n = makeNode(CreateStmt); $4->relpersistence = $2; @@ -4985,6 +5085,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->distributeby = $12; n->subcluster = $13; /* PGXC_END */ + n->tableOptions = $14; n->partTableState = NULL; n->internalData = NULL; $$ = (Node *)n; @@ -4994,6 +5095,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' /* PGXC_BEGIN */ OptDistributeBy OptSubCluster /* PGXC_END */ + opt_table_options { CreateStmt *n = makeNode(CreateStmt); $7->relpersistence = $2; @@ -5011,6 +5113,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->distributeby = $15; n->subcluster = $16; /* PGXC_END */ + n->tableOptions = $17; n->partTableState = NULL; n->internalData = NULL; $$ = (Node *)n; @@ -5752,7 +5855,7 @@ TypedTableElement: | TableConstraint { $$ = $1; } ; -columnDef: ColId Typename KVType ColCmprsMode create_generic_options ColQualList +columnDef: ColId Typename KVType ColCmprsMode create_generic_options ColQualList opt_column_options { ColumnDef *n = makeNode(ColumnDef); n->colname = $1; @@ -5775,6 +5878,7 @@ columnDef: ColId Typename KVType ColCmprsMode create_generic_options ColQualList SplitColQualList($6, &n->constraints, &n->collClause, yyscanner); } + n->columnOptions = $7; $$ = (Node *)n; } ; @@ -5846,7 +5950,7 @@ ColConstraint: $$ = (Node *) n; } | ENCRYPTED with_algorithm - { + { $$=$2; } ; @@ -11683,7 +11787,7 @@ defacl_privilege_target: IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name ON qualified_name access_method_clause '(' index_params ')' - opt_include opt_reloptions OptPartitionElement where_clause + opt_include opt_reloptions OptPartitionElement opt_index_options where_clause { IndexStmt *n = makeNode(IndexStmt); n->unique = $2; @@ -11696,7 +11800,8 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name n->indexIncludingParams = $12; n->options = $13; n->tableSpace = $14; - n->whereClause = $15; + n->indexOptions = $15; + n->whereClause = $16; n->excludeOpNames = NIL; n->idxcomment = NULL; n->indexOid = InvalidOid; @@ -11712,7 +11817,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name } | CREATE opt_unique INDEX opt_concurrently opt_index_name ON qualified_name access_method_clause '(' index_params ')' - LOCAL opt_partition_index_def opt_include opt_reloptions OptTableSpace + LOCAL opt_partition_index_def opt_include opt_reloptions OptTableSpace opt_index_options { IndexStmt *n = makeNode(IndexStmt); @@ -11727,6 +11832,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name n->indexIncludingParams = $14; n->options = $15; n->tableSpace = $16; + n->indexOptions = $17; n->isPartitioned = true; n->isGlobal = false; n->excludeOpNames = NIL; @@ -11742,7 +11848,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name } | CREATE opt_unique INDEX opt_concurrently opt_index_name ON qualified_name access_method_clause '(' index_params ')' - GLOBAL opt_include opt_reloptions OptTableSpace + GLOBAL opt_include opt_reloptions OptTableSpace opt_index_options { IndexStmt *n = makeNode(IndexStmt); @@ -11757,6 +11863,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name n->indexIncludingParams = $13; n->options = $14; n->tableSpace = $15; + n->indexOptions = $16; n->isPartitioned = true; n->isGlobal = true; n->excludeOpNames = NIL; @@ -26424,6 +26531,17 @@ static bool CheckWhetherInColList(char *colname, List *col_list) } #endif +static void BCompatibilityOptionSupportCheck() +{ +#ifdef ENABLE_MULTIPLE_NODES + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Comment is not yet supported."))); +#endif + if (DB_IS_CMPT(B_FORMAT)) { + return; + } + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Comment is supported only in B compatible database."))); +} + static int GetFillerColIndex(char *filler_col_name, List *col_list) { ListCell* lc = NULL; diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index ffa9499bb..3c47f83c5 100644 --- a/src/common/backend/utils/init/globals.cpp +++ b/src/common/backend/utils/init/globals.cpp @@ -59,7 +59,7 @@ bool open_join_children = true; bool will_shutdown = false; /* hard-wired binary version number */ -const uint32 GRAND_VERSION_NUM = 92611; +const uint32 GRAND_VERSION_NUM = 92612; const uint32 PREDPUSH_SAME_LEVEL_VERSION_NUM = 92522; const uint32 UPSERT_WHERE_VERSION_NUM = 92514; @@ -139,6 +139,8 @@ const uint32 DISASTER_READ_VERSION_NUM = 92592; const uint32 PITR_INIT_VERSION_NUM = 92599; +const uint32 COMMENT_SUPPORT_VERSION_NUM = 92612; + #ifdef PGXC bool useLocalXid = false; #endif diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index 737a410d9..113f79ead 100755 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -196,6 +196,8 @@ static bool IsAllTempObjectsInVacuumStmt(Node* parsetree); static int64 getCopySequenceMaxval(const char *nspname, const char *relname, const char *colname); static int64 getCopySequenceCountval(const char *nspname, const char *relname); +void BCompatibilityCreateTableOptions(CreateStmt* stmt, Oid relOid); +static inline void RelOrIndexOrColumnCreateComment(List* list, Oid oid, char *columnName = NULL); /* the hash value of extension script */ #define POSTGIS_VERSION_NUM 2 @@ -2160,6 +2162,9 @@ void CreateCommand(CreateStmt *parse_tree, const char *query_string, ParamListIn AlterCStoreCreateTables(rel_oid, toast_options, (CreateStmt*)stmt); AlterDfsCreateTables(rel_oid, toast_options, (CreateStmt*)stmt); AlterCreateChainTables(rel_oid, toast_options, (CreateStmt *)stmt); + + BCompatibilityCreateTableOptions((CreateStmt*)stmt, rel_oid); + #ifdef ENABLE_MULTIPLE_NODES Datum reloptions = transformRelOptions( (Datum)0, ((CreateStmt*)stmt)->options, NULL, validnsps, true, false); @@ -4907,6 +4912,9 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi DefineDeltaUniqueIndex(rel_id, stmt, indexRelOid); } #endif + /* index options */ + RelOrIndexOrColumnCreateComment(((IndexStmt *)stmt)->indexOptions, indexRelOid); + pgstat_report_waitstatus(oldStatus); #ifdef PGXC if (IS_PGXC_COORDINATOR && !stmt->isconstraint && !IsConnFromCoord()) { @@ -13404,3 +13412,40 @@ static int64 getCopySequenceMaxval(const char *nspname, const char *relname, con SPI_finish(); return DatumGetInt64(attval); } + + /** + * b stmt create index. Only the last one of comments takes effect. + * @param list table or index or column option + * @param oid oid of table or index + */ + static inline void RelOrIndexOrColumnCreateComment(List* list, Oid oid, char *columnName) +{ + ListCell *cell = NULL; + foreach (cell, list) { + void *pointer = lfirst(cell); + if (IsA(pointer, CommentStmt)) { + CommentStmt *commentStmt = (CommentStmt *)pointer; + CreateComments(oid, RelationRelationId, columnName == NULL ? 0 : get_attnum(oid, columnName), + commentStmt->comment); + return; + } + } +} + +/** + * B Compatibility Create Table Options + * @params: stmt createStmt + * @params: relOid oid of table created + */ +void BCompatibilityCreateTableOptions(CreateStmt *stmt, Oid relOid) +{ + /* table Options */ + RelOrIndexOrColumnCreateComment(stmt->tableOptions, relOid); + + /* column Options */ + ListCell *cell = NULL; + foreach (cell, stmt->tableElts) { + ColumnDef *columnDef = (ColumnDef *)lfirst(cell); + RelOrIndexOrColumnCreateComment(columnDef->columnOptions, relOid, columnDef->colname); + } +} \ No newline at end of file diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 6af84726a..e7e2ce1fc 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -99,6 +99,7 @@ extern const uint32 PITR_INIT_VERSION_NUM; extern const uint32 PUBLICATION_INITIAL_DATA_VERSION_NAME; extern const uint32 CREATE_FUNCTION_DEFINER_VERSION; extern const uint32 KEYWORD_IGNORE_COMPART_VERSION_NUM; +extern const uint32 COMMENT_SUPPORT_VERSION_NUM; extern void register_backend_version(uint32 backend_version); extern bool contain_backend_version(uint32 version_number); diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 1e588ea59..7cbda2254 100755 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1277,6 +1277,7 @@ typedef struct IndexStmt { List* partIndexOldPSortOid; /* partition psort oid, if any */ Node* partClause; /* partition index define */ bool* partIndexUsable; /* is partition index usable */ + List* indexOptions; /* b compatiblity options */ /* @hdfs * is a partitioned index? The foreign table dose not index. The isPartitioned * value is false when relation is a foreign table. diff --git a/src/include/nodes/parsenodes_common.h b/src/include/nodes/parsenodes_common.h index a62819bb1..deb840aa2 100644 --- a/src/include/nodes/parsenodes_common.h +++ b/src/include/nodes/parsenodes_common.h @@ -1006,6 +1006,7 @@ typedef struct ColumnDef { Oid collOid; /* collation OID (InvalidOid if not set) */ List *constraints; /* other constraints on column */ List *fdwoptions; /* per-column FDW options */ + List *columnOptions; /* b compatiblity options */ ClientLogicColumnRef *clientLogicColumnRef; Position *position; Form_pg_attribute dropped_attr; /* strcuture for dropped attribute during create table like OE */ @@ -1170,6 +1171,7 @@ typedef struct CreateStmt { List *uuids; /* list of uuid, used for create sequence(like 'create table t(a serial))' */ Oid oldBucket; /* bucketoid of resizing table */ List *oldNode; /* relfilenode of resizing table */ + List *tableOptions; /* b compatiblity options */ List *oldToastNode; /* toastnode of resizing table */ char relkind; /* type of object */ } CreateStmt; diff --git a/src/test/regress/expected/b_comments.out b/src/test/regress/expected/b_comments.out new file mode 100644 index 000000000..d42dd65e2 --- /dev/null +++ b/src/test/regress/expected/b_comments.out @@ -0,0 +1,81 @@ +/* unsupport */ +create schema b_comments; +set search_path to 'b_comments'; +create table test_row(a int not null comment 'test_row.a'); +ERROR: Comment is supported only in B compatible database. +create table test_row(a int not null) comment 'test_row'; +ERROR: Comment is supported only in B compatible database. +create index on test_row(a,b) comment 'test_row_index'; +ERROR: Comment is supported only in B compatible database. +create table partition_test(c1 int, c2 int, logdate date not null) comment 'partition_test' partition by range (logdate) INTERVAL ('1 month') +( + PARTITION partition_test_p0 VALUES LESS THAN ('2020-03-01'), + PARTITION partition_test_p1 VALUES LESS THAN ('2020-04-01'), + PARTITION partition_test_p2 VALUES LESS THAN ('2020-05-01') +); +ERROR: Comment is supported only in B compatible database. +create index partition_test_index on partition_test (logdate) local +( + partition sip1_index_local, + partition sip2_index_local tablespace PG_DEFAULT, + partition sip3_index_local tablespace PG_DEFAULT +) comment 'partition_test_index'; +ERROR: Comment is supported only in B compatible database. +drop schema b_comments cascade; +create database b_comments dbcompatibility 'B'; +\c b_comments +create schema b_comments; +set search_path to 'b_comments'; +/* sanity check */ +create table test_row(a int not null comment 'test_row.a', b int not null comment 'test_row.b') comment 'test_row'; +create index on test_row(a,b) comment 'test_row_index'; +/* column orientation check */ +create table test_column(a int comment 'test_column.a', b int comment 'test_column.b') with (orientation='column') comment 'test_column'; +/* comment position check */ +create tablespace b_comments relative location 'b_comments'; +create table test(id int) tablespace b_comments comment 'test'; +create index on test(id) tablespace b_comments comment 'test_index' where id > 10 ; +/* partition position check*/ +create table partition_test(c1 int, c2 int, logdate date not null) comment 'partition_test' partition by range (logdate) INTERVAL ('1 month') +( + PARTITION partition_test_p0 VALUES LESS THAN ('2020-03-01'), + PARTITION partition_test_p1 VALUES LESS THAN ('2020-04-01'), + PARTITION partition_test_p2 VALUES LESS THAN ('2020-05-01') +); +create index partition_test_index on partition_test (logdate) local +( + partition sip1_index_local, + partition sip2_index_local tablespace PG_DEFAULT, + partition sip3_index_local tablespace PG_DEFAULT +) comment 'partition_test_index'; +/* result */ +select description +from pg_description +where objoid in (select relfilenode + from pg_class + where relnamespace in (select oid from pg_catalog.pg_namespace where nspname = 'b_comments')) +order by description; + description +---------------------- + partition_test + partition_test_index + test + test_column + test_column.a + test_column.b + test_index + test_row + test_row.a + test_row.b + test_row_index +(11 rows) + +drop schema b_comments cascade; +NOTICE: drop cascades to 4 other objects +DETAIL: drop cascades to table test_row +drop cascades to table test_column +drop cascades to table test +drop cascades to table partition_test +reset search_path; +\c postgres +drop database b_comments; diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 854f32bc2..3243a63cd 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -917,7 +917,7 @@ test: fdw_audit test: gs_global_config_audit test: detail declare_multiple_variable test: gs_dump_encrypt substr -test: composite_datum_record mysql_function +test: composite_datum_record mysql_function b_comments test: join_test_alias test: ignore/ignore_type_transform ignore/ignore_not_null_constraints ignore/ignore_unique_constraints ignore/ignore_no_matched_partition \ No newline at end of file diff --git a/src/test/regress/sql/b_comments.sql b/src/test/regress/sql/b_comments.sql new file mode 100644 index 000000000..6323ff0d9 --- /dev/null +++ b/src/test/regress/sql/b_comments.sql @@ -0,0 +1,62 @@ +/* unsupport */ +create schema b_comments; +set search_path to 'b_comments'; +create table test_row(a int not null comment 'test_row.a'); +create table test_row(a int not null) comment 'test_row'; +create index on test_row(a,b) comment 'test_row_index'; +create table partition_test(c1 int, c2 int, logdate date not null) comment 'partition_test' partition by range (logdate) INTERVAL ('1 month') +( + PARTITION partition_test_p0 VALUES LESS THAN ('2020-03-01'), + PARTITION partition_test_p1 VALUES LESS THAN ('2020-04-01'), + PARTITION partition_test_p2 VALUES LESS THAN ('2020-05-01') +); +create index partition_test_index on partition_test (logdate) local +( + partition sip1_index_local, + partition sip2_index_local tablespace PG_DEFAULT, + partition sip3_index_local tablespace PG_DEFAULT +) comment 'partition_test_index'; +drop schema b_comments cascade; + + +create database b_comments dbcompatibility 'B'; +\c b_comments +create schema b_comments; +set search_path to 'b_comments'; +/* sanity check */ +create table test_row(a int not null comment 'test_row.a', b int not null comment 'test_row.b') comment 'test_row'; +create index on test_row(a,b) comment 'test_row_index'; + +/* column orientation check */ +create table test_column(a int comment 'test_column.a', b int comment 'test_column.b') with (orientation='column') comment 'test_column'; + +/* comment position check */ +create tablespace b_comments relative location 'b_comments'; +create table test(id int) tablespace b_comments comment 'test'; +create index on test(id) tablespace b_comments comment 'test_index' where id > 10 ; + +/* partition position check*/ +create table partition_test(c1 int, c2 int, logdate date not null) comment 'partition_test' partition by range (logdate) INTERVAL ('1 month') +( + PARTITION partition_test_p0 VALUES LESS THAN ('2020-03-01'), + PARTITION partition_test_p1 VALUES LESS THAN ('2020-04-01'), + PARTITION partition_test_p2 VALUES LESS THAN ('2020-05-01') +); +create index partition_test_index on partition_test (logdate) local +( + partition sip1_index_local, + partition sip2_index_local tablespace PG_DEFAULT, + partition sip3_index_local tablespace PG_DEFAULT +) comment 'partition_test_index'; + +/* result */ +select description +from pg_description +where objoid in (select relfilenode + from pg_class + where relnamespace in (select oid from pg_catalog.pg_namespace where nspname = 'b_comments')) +order by description; +drop schema b_comments cascade; +reset search_path; +\c postgres +drop database b_comments; \ No newline at end of file