Code formatting cleanup

pull/7635/head
EriksP 2024-06-21 13:56:43 +03:00
parent 4e525fc170
commit 45fca50598
9 changed files with 27 additions and 21 deletions

View File

@ -34,8 +34,8 @@
#include "catalog/pg_am.h" #include "catalog/pg_am.h"
#include "catalog/pg_depend.h" #include "catalog/pg_depend.h"
#include "catalog/pg_rewrite_d.h" #include "catalog/pg_rewrite_d.h"
#include "commands/defrem.h"
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/defrem.h"
#include "executor/spi.h" #include "executor/spi.h"
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "utils/builtins.h" #include "utils/builtins.h"
@ -1779,11 +1779,13 @@ CreateMaterializedViewDDLCommand(Oid matViewOid)
return query->data; 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 static void
MigrateColumnComments(Oid sourceId, Oid targetId){ MigrateColumnComments(Oid sourceId, Oid targetId)
{
Relation relation = relation_open(sourceId, AccessShareLock); Relation relation = relation_open(sourceId, AccessShareLock);
TupleDesc tupleDesc = RelationGetDescr(relation); TupleDesc tupleDesc = RelationGetDescr(relation);
for (int attrNum = 0; attrNum < tupleDesc->natts; attrNum++) for (int attrNum = 0; attrNum < tupleDesc->natts; attrNum++)
@ -1791,24 +1793,28 @@ MigrateColumnComments(Oid sourceId, Oid targetId){
Form_pg_attribute attr = TupleDescAttr(tupleDesc, attrNum); Form_pg_attribute attr = TupleDescAttr(tupleDesc, attrNum);
if (!attr->attisdropped) if (!attr->attisdropped)
{ {
char *columnComment = GetComment(sourceId, RelationRelationId ,attrNum + 1); char *columnComment = GetComment(sourceId, RelationRelationId, attrNum + 1);
CreateComments(targetId, RelationRelationId, attrNum + 1, columnComment); CreateComments(targetId, RelationRelationId, attrNum + 1, columnComment);
} }
} }
relation_close(relation, AccessShareLock); relation_close(relation, AccessShareLock);
} }
/* /*
* MigrateTableComment migrates the comment of the source distributed table to the target undistributed table. * MigrateTableComment migrates the comment of the source distributed table to the target undistributed table.
*/ */
static void static void
MigrateTableComment(Oid sourceId, Oid targetId){ MigrateTableComment(Oid sourceId, Oid targetId)
{
char *comment = GetComment(sourceId, RelationRelationId, 0); char *comment = GetComment(sourceId, RelationRelationId, 0);
if(comment != NULL) { if (comment != NULL)
{
CreateComments(targetId, RelationRelationId, 0, comment); CreateComments(targetId, RelationRelationId, 0, comment);
} }
} }
/* /*
* ReplaceTable replaces the source table with the target table. * ReplaceTable replaces the source table with the target table.
* It moves all the rows of the source table to target table with INSERT SELECT. * 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 (!PartitionedTable(sourceId) && !IsForeignTable(sourceId))
{ {
if (!suppressNoticeMessages) if (!suppressNoticeMessages)
{ {
ereport(NOTICE, (errmsg("moving the data of %s", qualifiedSourceName))); 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); ExecuteQueryViaSPI(query->data, SPI_OK_UTILITY);
} }
/* /*
* HasAnyGeneratedStoredColumns decides if relation has any columns that we * HasAnyGeneratedStoredColumns decides if relation has any columns that we
* might need to copy the data of when replacing table. * might need to copy the data of when replacing table.

View File

@ -4,4 +4,4 @@ test: comment_migration_table_joined_tables
test: comment_migration_table_joined_tables_FK test: comment_migration_table_joined_tables_FK
test: comment_migration_column test: comment_migration_column
test: comment_migration_column_joined_tables test: comment_migration_column_joined_tables
test: comment_migration_column_joined_tables_FK test: comment_migration_column_joined_tables_FK

View File

@ -144,4 +144,4 @@ test: comment_migration_table_joined_tables
test: comment_migration_table_joined_tables_FK test: comment_migration_table_joined_tables_FK
test: comment_migration_column test: comment_migration_column
test: comment_migration_column_joined_tables test: comment_migration_column_joined_tables
test: comment_migration_column_joined_tables_FK test: comment_migration_column_joined_tables_FK

View File

@ -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); 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 TABLE comment_migration_column.table_1;
DROP SCHEMA comment_migration_column; DROP SCHEMA comment_migration_column;

View File

@ -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_2;
DROP TABLE comment_migration_column.table_1; DROP TABLE comment_migration_column.table_1;
DROP SCHEMA comment_migration_column; DROP SCHEMA comment_migration_column;

View File

@ -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_2;
DROP TABLE comment_migration_column.table_1; DROP TABLE comment_migration_column.table_1;
DROP SCHEMA comment_migration_column; DROP SCHEMA comment_migration_column;

View File

@ -14,16 +14,16 @@ CREATE TABLE comment_migration_table.table_1
SET citus.shard_replication_factor = 1; SET citus.shard_replication_factor = 1;
comment on table comment_migration_table.table_1 is 'Table 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 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 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 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 TABLE comment_migration_table.table_1;
DROP SCHEMA comment_migration_table; DROP SCHEMA comment_migration_table;

View File

@ -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_2;
DROP TABLE comment_migration_table.table_1; DROP TABLE comment_migration_table.table_1;
DROP SCHEMA comment_migration_table; DROP SCHEMA comment_migration_table;

View File

@ -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_2;
DROP TABLE comment_migration_table.table_1; DROP TABLE comment_migration_table.table_1;
DROP SCHEMA comment_migration_table; DROP SCHEMA comment_migration_table;