From 45fca5059833dd8307922ae07eb609e1092f34e9 Mon Sep 17 00:00:00 2001 From: EriksP Date: Fri, 21 Jun 2024 13:56:43 +0300 Subject: [PATCH] Code formatting cleanup --- .../distributed/commands/alter_table.c | 24 ++++++++++++------- src/test/regress/comment_migration_schedule | 2 +- src/test/regress/multi_schedule | 2 +- .../regress/sql/comment_migration_column.sql | 2 +- ...comment_migration_column_joined_tables.sql | 2 +- ...ment_migration_column_joined_tables_FK.sql | 2 +- .../regress/sql/comment_migration_table.sql | 10 ++++---- .../comment_migration_table_joined_tables.sql | 2 +- ...mment_migration_table_joined_tables_FK.sql | 2 +- 9 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/backend/distributed/commands/alter_table.c b/src/backend/distributed/commands/alter_table.c index c62a02b71..62764945c 100644 --- a/src/backend/distributed/commands/alter_table.c +++ b/src/backend/distributed/commands/alter_table.c @@ -34,8 +34,8 @@ #include "catalog/pg_am.h" #include "catalog/pg_depend.h" #include "catalog/pg_rewrite_d.h" -#include "commands/defrem.h" #include "commands/comment.h" +#include "commands/defrem.h" #include "executor/spi.h" #include "nodes/pg_list.h" #include "utils/builtins.h" @@ -1779,11 +1779,13 @@ CreateMaterializedViewDDLCommand(Oid matViewOid) return query->data; } + /* -* MigrateColumnComments migrates distributed table column comments to the target undistributed table columns. -*/ + * MigrateColumnComments migrates distributed table column comments to the target undistributed table columns. + */ static void -MigrateColumnComments(Oid sourceId, Oid targetId){ +MigrateColumnComments(Oid sourceId, Oid targetId) +{ Relation relation = relation_open(sourceId, AccessShareLock); TupleDesc tupleDesc = RelationGetDescr(relation); for (int attrNum = 0; attrNum < tupleDesc->natts; attrNum++) @@ -1791,24 +1793,28 @@ MigrateColumnComments(Oid sourceId, Oid targetId){ Form_pg_attribute attr = TupleDescAttr(tupleDesc, attrNum); if (!attr->attisdropped) { - char *columnComment = GetComment(sourceId, RelationRelationId ,attrNum + 1); + char *columnComment = GetComment(sourceId, RelationRelationId, attrNum + 1); CreateComments(targetId, RelationRelationId, attrNum + 1, columnComment); } } relation_close(relation, AccessShareLock); } + /* * MigrateTableComment migrates the comment of the source distributed table to the target undistributed table. -*/ + */ static void -MigrateTableComment(Oid sourceId, Oid targetId){ +MigrateTableComment(Oid sourceId, Oid targetId) +{ char *comment = GetComment(sourceId, RelationRelationId, 0); - if(comment != NULL) { + if (comment != NULL) + { CreateComments(targetId, RelationRelationId, 0, comment); } } + /* * ReplaceTable replaces the source table with the target table. * It moves all the rows of the source table to target table with INSERT SELECT. @@ -1828,7 +1834,6 @@ ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands, if (!PartitionedTable(sourceId) && !IsForeignTable(sourceId)) { - if (!suppressNoticeMessages) { ereport(NOTICE, (errmsg("moving the data of %s", qualifiedSourceName))); @@ -1933,6 +1938,7 @@ ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands, ExecuteQueryViaSPI(query->data, SPI_OK_UTILITY); } + /* * HasAnyGeneratedStoredColumns decides if relation has any columns that we * might need to copy the data of when replacing table. diff --git a/src/test/regress/comment_migration_schedule b/src/test/regress/comment_migration_schedule index 2c11f1458..50146af0e 100644 --- a/src/test/regress/comment_migration_schedule +++ b/src/test/regress/comment_migration_schedule @@ -4,4 +4,4 @@ test: comment_migration_table_joined_tables test: comment_migration_table_joined_tables_FK test: comment_migration_column test: comment_migration_column_joined_tables -test: comment_migration_column_joined_tables_FK \ No newline at end of file +test: comment_migration_column_joined_tables_FK diff --git a/src/test/regress/multi_schedule b/src/test/regress/multi_schedule index 4ed8e135a..bb0c53e09 100644 --- a/src/test/regress/multi_schedule +++ b/src/test/regress/multi_schedule @@ -144,4 +144,4 @@ test: comment_migration_table_joined_tables test: comment_migration_table_joined_tables_FK test: comment_migration_column test: comment_migration_column_joined_tables -test: comment_migration_column_joined_tables_FK \ No newline at end of file +test: comment_migration_column_joined_tables_FK diff --git a/src/test/regress/sql/comment_migration_column.sql b/src/test/regress/sql/comment_migration_column.sql index 3f9753894..f5f5b453c 100644 --- a/src/test/regress/sql/comment_migration_column.sql +++ b/src/test/regress/sql/comment_migration_column.sql @@ -30,4 +30,4 @@ SELECT create_distributed_table('comment_migration_column.table_1', 'id'); select col_description('comment_migration_column.table_1'::regclass,1), col_description('comment_migration_column.table_1'::regclass,2), col_description('comment_migration_column.table_1'::regclass,3), col_description('comment_migration_column.table_1'::regclass,4), col_description('comment_migration_column.table_1'::regclass,5); DROP TABLE comment_migration_column.table_1; -DROP SCHEMA comment_migration_column; \ No newline at end of file +DROP SCHEMA comment_migration_column; diff --git a/src/test/regress/sql/comment_migration_column_joined_tables.sql b/src/test/regress/sql/comment_migration_column_joined_tables.sql index f3220e9b2..10e0b1cca 100644 --- a/src/test/regress/sql/comment_migration_column_joined_tables.sql +++ b/src/test/regress/sql/comment_migration_column_joined_tables.sql @@ -51,4 +51,4 @@ select col_description('comment_migration_column.table_2'::regclass,1), col_desc DROP TABLE comment_migration_column.table_2; DROP TABLE comment_migration_column.table_1; -DROP SCHEMA comment_migration_column; \ No newline at end of file +DROP SCHEMA comment_migration_column; diff --git a/src/test/regress/sql/comment_migration_column_joined_tables_FK.sql b/src/test/regress/sql/comment_migration_column_joined_tables_FK.sql index 67e3c5cc4..3fcc8c8f2 100644 --- a/src/test/regress/sql/comment_migration_column_joined_tables_FK.sql +++ b/src/test/regress/sql/comment_migration_column_joined_tables_FK.sql @@ -53,4 +53,4 @@ select col_description('comment_migration_column.table_2'::regclass,1), col_desc DROP TABLE comment_migration_column.table_2; DROP TABLE comment_migration_column.table_1; -DROP SCHEMA comment_migration_column; \ No newline at end of file +DROP SCHEMA comment_migration_column; diff --git a/src/test/regress/sql/comment_migration_table.sql b/src/test/regress/sql/comment_migration_table.sql index 2049e0706..638bddba9 100644 --- a/src/test/regress/sql/comment_migration_table.sql +++ b/src/test/regress/sql/comment_migration_table.sql @@ -14,16 +14,16 @@ CREATE TABLE comment_migration_table.table_1 SET citus.shard_replication_factor = 1; comment on table comment_migration_table.table_1 is 'Table 1'; -select obj_description('comment_migration_table.table_1'::regclass); +select obj_description('comment_migration_table.table_1'::regclass); SELECT create_distributed_table('comment_migration_table.table_1', 'id'); -select obj_description('comment_migration_table.table_1'::regclass); +select obj_description('comment_migration_table.table_1'::regclass); select undistribute_table('comment_migration_table.table_1'); -select obj_description('comment_migration_table.table_1'::regclass); +select obj_description('comment_migration_table.table_1'::regclass); SELECT create_distributed_table('comment_migration_table.table_1', 'id'); -select obj_description('comment_migration_table.table_1'::regclass); +select obj_description('comment_migration_table.table_1'::regclass); DROP TABLE comment_migration_table.table_1; -DROP SCHEMA comment_migration_table; \ No newline at end of file +DROP SCHEMA comment_migration_table; diff --git a/src/test/regress/sql/comment_migration_table_joined_tables.sql b/src/test/regress/sql/comment_migration_table_joined_tables.sql index 63f898847..4c7f962e5 100644 --- a/src/test/regress/sql/comment_migration_table_joined_tables.sql +++ b/src/test/regress/sql/comment_migration_table_joined_tables.sql @@ -46,4 +46,4 @@ select obj_description('comment_migration_table.table_2'::regclass); DROP TABLE comment_migration_table.table_2; DROP TABLE comment_migration_table.table_1; -DROP SCHEMA comment_migration_table; \ No newline at end of file +DROP SCHEMA comment_migration_table; diff --git a/src/test/regress/sql/comment_migration_table_joined_tables_FK.sql b/src/test/regress/sql/comment_migration_table_joined_tables_FK.sql index 05427e94f..093177f93 100644 --- a/src/test/regress/sql/comment_migration_table_joined_tables_FK.sql +++ b/src/test/regress/sql/comment_migration_table_joined_tables_FK.sql @@ -48,4 +48,4 @@ select obj_description('comment_migration_table.table_2'::regclass); DROP TABLE comment_migration_table.table_2; DROP TABLE comment_migration_table.table_1; -DROP SCHEMA comment_migration_table; \ No newline at end of file +DROP SCHEMA comment_migration_table;