On Thu, Nov 5, 2026 at 1:48 PM Mingjie Gao <[email protected]> wrote:
...
> Please find the updated v2 patch attached.
>
Some minor comments for the v2 test code.
======
src/test/subscription/t/008_diff_schema.pl
1.
+ CREATE PUBLICATION pub_nocols FOR TABLE tab_nocols
+ WITH (publish = 'insert');
Saying publish = 'insert' seems overkill.
~~~
2.
+ $node_subscriber->safe_psql('postgres', 'DROP SUBSCRIPTION sub_nocols');
+ $node_publisher->safe_psql('postgres',
+ 'DROP PUBLICATION pub_nocols; DROP TABLE tab_nocols');
+ $node_subscriber->safe_psql('postgres', 'DROP TABLE tab_nocols');
Those could be combined a bit...
~~~
3. Other misc refactoring
some spaces
some comments
some more consistent use of terminating ';'
etc.
~~~
I've made a few tmp changes (only cosmetic -- nothing functional).
e.g., see my attached version of the 008_diff_schema.pl changes for reference.
======
Kind Regards,
Peter Smith.
Fujitsu Australia
diff --git a/src/test/subscription/t/008_diff_schema.pl
b/src/test/subscription/t/008_diff_schema.pl
index 96e3d6f5888..fbdfcda3f51 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -31,6 +31,63 @@ $node_subscriber->safe_psql('postgres',
# Setup logical replication
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
+
+# A zero-column publisher still sends rows. Subscriber-only columns must
+# get their defaults during initial COPY as well as incremental replication.
+foreach my $binary ('false', 'true')
+{
+ $node_publisher->safe_psql(
+ 'postgres', q{
+ CREATE TABLE tab_nocols ();
+ INSERT INTO tab_nocols DEFAULT VALUES;
+ INSERT INTO tab_nocols DEFAULT VALUES;
+ CREATE PUBLICATION pub_nocols FOR TABLE tab_nocols;
+ });
+ $node_subscriber->safe_psql('postgres',
+ "CREATE TABLE tab_nocols (local_value text DEFAULT
'subscriber-default')"
+ );
+ $node_subscriber->safe_psql('postgres',
+ "CREATE SUBSCRIPTION sub_nocols CONNECTION '$publisher_connstr'
PUBLICATION pub_nocols WITH (binary = $binary)"
+ );
+
+ # test initial sync
+ $node_subscriber->wait_for_subscription_sync($node_publisher,
'sub_nocols');
+
+ is( $node_subscriber->safe_psql(
+ 'postgres', q{
+ SELECT count(*) FROM tab_nocols
+ WHERE local_value = 'subscriber-default';
+ }),
+ '2',
+ "initial zero-column rows use local defaults (binary =
$binary)");
+
+ # test incremental replication
+ $node_publisher->safe_psql('postgres',
+ "INSERT INTO tab_nocols DEFAULT VALUES");
+
+ $node_publisher->wait_for_catchup('sub_nocols');
+
+ is( $node_subscriber->safe_psql(
+ 'postgres', q{
+ SELECT count(*) FROM tab_nocols
+ WHERE local_value = 'subscriber-default';
+ }),
+ '3',
+ "incremental zero-column rows use local defaults (binary =
$binary)");
+
+ # cleanup
+ $node_subscriber->safe_psql(
+ 'postgres', q{
+ DROP SUBSCRIPTION sub_nocols;
+ DROP TABLE tab_nocols;
+ });
+ $node_publisher->safe_psql(
+ 'postgres', q{
+ DROP PUBLICATION pub_nocols;
+ DROP TABLE tab_nocols;
+ });
+}
+
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION tap_pub FOR ALL TABLES");