Re: Data is copied twice when specifying both child and parent table in publication
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>
Cc: "osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com>, "shiy.fnst@fujitsu.com" <shiy.fnst@fujitsu.com>,
"houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>, Amit Langote <amitlangote09@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>,
Dilip Kumar <dilipbalaut@gmail.com>, Greg Nancarrow <gregn4422@gmail.com>, vignesh C <vignesh21@gmail.com>
Date: 2022-05-13T05:58:31Z
Lists: pgsql-hackers
On Fri, May 13, 2022 at 7:32 AM wangw.fnst@fujitsu.com <wangw.fnst@fujitsu.com> wrote: > > Attach the patches.(Only changed the patch for HEAD.). > Few comments: ============= 1. @@ -1135,6 +1172,15 @@ pg_get_publication_tables(PG_FUNCTION_ARGS) if (publication->pubviaroot) tables = filter_partitions(tables); } + pfree(elems); + + /* + * We need an additional filter for this case : A partition table is + * published in a publication with viaroot, and its parent or child + * table is published in another publication without viaroot. In this + * case, we should publish only parent table. + */ + tables = filter_partitions(tables); Do we need to filter partitions twice? Can't we check if any of the publications has 'pubviaroot' option set, if so, call filter_partitions at the end? 2. " FROM pg_class c JOIN pg_namespace n" + " ON n.oid = c.relnamespace," + " LATERAL pg_get_publication_tables(array[ %s ]) gst" Here, it is better to have an alias name as gpt. 3. } + pfree(elems); + An extra line between these two lines makes it looks slightly better. 4. Not able to apply patch cleanly. patching file src/test/subscription/t/013_partition.pl Hunk #1 FAILED at 477. Hunk #2 FAILED at 556. Hunk #3 FAILED at 584. 3 out of 3 hunks FAILED -- saving rejects to file src/test/subscription/t/013_partition.pl.rej patching file src/test/subscription/t/028_row_filter.pl Hunk #1 succeeded at 394 (offset 1 line). Hunk #2 FAILED at 722. 1 out of 2 hunks FAILED -- saving rejects to file src/test/subscription/t/028_row_filter.pl.rej patching file src/test/subscription/t/031_column_list.pl Hunk #1 succeeded at 948 (offset -92 lines). Hunk #2 FAILED at 1050. 1 out of 2 hunks FAILED -- saving rejects to file src/test/subscription/t/031_column_list.pl.rej -- With Regards, Amit Kapila.
Commits
-
Avoid syncing data twice for the 'publish_via_partition_root' option.
- 062a84442424 16.0 landed
-
Fix partition table's REPLICA IDENTITY checking on the subscriber.
- 52d5ea9adb01 14.5 cited
-
Prohibit combining publications with different column lists.
- fd0b9dcebda7 15.0 cited
-
Fix double publish of child table's data.
- 3f06c00cf6dc 13.6 landed
- 614b77d65a38 14.2 landed
- 5e97905a2c76 15.0 landed
-
Support adding partitioned tables to publication
- 17b9e7f9fe23 13.0 cited