Re: [PATCH v1] Fix initial sync of zero-column published tables

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: mingjiegao <mingjie(dot)gmj(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH v1] Fix initial sync of zero-column published tables
Date: 2026-11-04 00:52:32
Message-ID: CAHut+PsnxcPa3g_e3ZtPiDJVMTU6wXf_b0o+=9nNg+KUtfgD9w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi mingjiegao.

I was able to reproduce your reported tablesync bug for a table with zero cols.

Using:
test_pub=# CREATE TABLE t_nocols();
test_pub=# INSERT INTO T_NOCOLS DEFAULT VALUES;

and:
test_sub=# create table t_nocols(local_col text default
'subscriber-col-default');

~~~

Also confirmed the issue was fixed after applying the v1 patch.

~~~

Here are some minor review comments:

1.
Now that BeginCopyFrom is just a thin "wrapper" should all that
commentary describing each of the function parameters be moved to
BeginCopyFromExtended function-comment where all the work is done?

2.
The TAP test code for this patch seems more elaborate than usual.
AFAIK it is normal to accept that regressions show up as a timeout.

My LLM suggested simpler, more typical-looking test code, like below:

--------------------
# Zero-column publisher table; a subscriber-only column must get its
# default during initial sync in both text and binary mode.
$node_publisher->safe_psql('postgres', q{
CREATE TABLE tab_nocols_text ();
CREATE TABLE tab_nocols_bin ();
INSERT INTO tab_nocols_text DEFAULT VALUES;
INSERT INTO tab_nocols_bin DEFAULT VALUES;
CREATE PUBLICATION pub_nocols_text FOR TABLE tab_nocols_text;
CREATE PUBLICATION pub_nocols_bin FOR TABLE tab_nocols_bin;
});
$node_subscriber->safe_psql('postgres', q{
CREATE TABLE tab_nocols_text (c text DEFAULT 'sub-default');
CREATE TABLE tab_nocols_bin (c text DEFAULT 'sub-default');
});
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub_nocols_text CONNECTION
'$publisher_connstr' PUBLICATION pub_nocols_text WITH (binary =
false)");
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub_nocols_bin CONNECTION
'$publisher_connstr' PUBLICATION pub_nocols_bin WITH (binary =
true)");
$node_subscriber->wait_for_subscription_sync($node_publisher,
'sub_nocols_text');
$node_subscriber->wait_for_subscription_sync($node_publisher, 'sub_nocols_bin');

is($node_subscriber->safe_psql('postgres',
"SELECT c FROM tab_nocols_text"), 'sub-default',
'zero-column initial sync uses subscriber default (text)');
is($node_subscriber->safe_psql('postgres',
"SELECT c FROM tab_nocols_bin"), 'sub-default',
'zero-column initial sync uses subscriber default (binary)');
--------------------

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message David Rowley 2026-11-04 00:46:46 Re: [PG19] Wrong results from Memoize with a nondeterministic collation