Disappearing comments after undistributing table
Hi, we have a problem with disappearing comments during development, if distributed table is undistributed.
CREATE SCHEMA test;
CREATE TABLE test.table_1
(
id bigserial,
code varchar(200) not null,
name varchar(200),
date_created timestamp with time zone default NOW() not null,
active boolean default true,
CONSTRAINT table_1_pkey PRIMARY KEY (id)
)
WITH (autovacuum_enabled = TRUE);
comment on table test.table_1 is 'Table 1';
comment on column test.table_1.id is 'table id';
comment on column test.table_1.code is 'table code';
comment on column test.table_1.name is 'table name';
comment on column test.table_1.date_created is 'table date_created';
comment on column test.table_1.active is 'table active';
SELECT create_distributed_table('test.table_1', 'id');
select obj_description('test.table_1'::regclass); -- has comment
select undistribute_table('test.table_1');
SELECT create_distributed_table('test.table_1', 'id');
select obj_description('test.table_1'::regclass); -- has no comment
We would like to contribute a fix for this issue. Would you accept such fix?
If so, any hints on which place the fix should go to. We are currently looking to modify blob/main/src/backend/distributed/commands/alter_table.c file.
Thank you.
Yeah, we'd definitely accept a fix (assuming it has some tests, and makes the change in the correct place in the codebase).
Regarding pointers on this. I think you'd either need to join ConvertTableInternal or the GetPreLoadTableCreationCommands function that it calls.
I feel like GetPreLoadTableCreationCommands would probably be the actually "correct" place, but that function is used all over the codebase so we might need to fix stuff in other places if you change that. So maybe adding some extra lines to ConvertTableToInternal would be the most pragmatic way to fix this issue.
@JelteF could you please check if the PR is ok?