postgresql/src/backend/commands
Tomas Vondra c91f71b9dc Fix publish_as_relid with multiple publications
Commit 83fd4532a7 allowed publishing of changes via ancestors, for
publications defined with publish_via_partition_root. But the way
the ancestor was determined in get_rel_sync_entry() was incorrect,
simply updating the same variable. So with multiple publications,
replicating different ancestors, the outcome depended on the order
of publications in the list - the value from the last loop was used,
even if it wasn't the top-most ancestor.

This is a probably rare situation, as in most cases publications do
not overlap, so each partition has exactly one candidate ancestor
to replicate as and there's no ambiguity.

Fixed by tracking the "ancestor level" for each publication, and
picking the top-most ancestor. Adds a test case, verifying the
correct ancestor is used for publishing the changes and that this
does not depend on order of publications in the list.

Older releases have another bug in this loop - once all actions are
replicated, the loop is terminated, on the assumption that inspecting
additional publications is unecessary. But that misses the fact that
those additional applications may replicate different ancestors.

Fixed by removal of this break condition. We might still terminate the
loop in some cases (e.g. when replicating all actions and the ancestor
is the partition root).

Backpatch to 13, where publish_via_partition_root was introduced.

Initial report and fix by me, test added by Hou zj. Reviews and
improvements by Amit Kapila.

Author: Tomas Vondra, Hou zj, Amit Kapila
Reviewed-by: Amit Kapila, Hou zj
Discussion: https://postgr.es/m/d26d24dd-2fab-3c48-0162-2b7f84a9c893%40enterprisedb.com
2022-03-16 18:05:58 +01:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c Add VACUUM instrumentation for scanned pages, relfrozenxid. 2022-02-11 16:48:40 -08:00
async.c Reduce more the number of calls to GetMaxBackends() 2022-02-10 10:27:29 +09:00
cluster.c Consolidate VACUUM xid cutoff logic. 2022-02-11 18:26:15 -08:00
collationcmds.c DefineCollation() code cleanup 2022-03-11 08:32:52 +01:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Add HEADER support to COPY text format 2022-01-28 09:44:47 +01:00
copyfrom.c Remove redundant memory context switches in BeginCopyFrom(). 2022-01-19 12:31:15 -05:00
copyfromparse.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copyto.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
createas.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dbcommands.c Database-level collation version tracking 2022-02-14 08:27:26 +01:00
define.c Add Boolean node 2022-01-17 10:38:23 +01:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
event_trigger.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
explain.c Fix collection of typos in the code and the documentation 2022-03-15 11:29:35 +09:00
extension.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
foreigncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
functioncmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
indexcmds.c Fix comment in CheckIndexCompatible(). 2022-02-18 12:19:10 +09:00
lockcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
matview.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
opclasscmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Add pg_analyze_and_rewrite_varparams() 2022-03-07 08:13:30 +01:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Fix publish_as_relid with multiple publications 2022-03-16 18:05:58 +01:00
schemacmds.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
seclabel.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
sequence.c Logical decoding of sequences 2022-02-10 18:43:51 +01:00
statscmds.c Check syscache result in AlterStatistics 2022-01-23 03:16:31 +01:00
subscriptioncmds.c Optionally disable subscriptions on error. 2022-03-14 09:32:40 +05:30
tablecmds.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
tablespace.c Fix DROP {DATABASE,TABLESPACE} on Windows. 2022-02-12 10:21:23 +13:00
trigger.c Add API of sorts for transition table handling in trigger.c 2022-03-11 20:40:03 -03:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Add missing TYPEALIGN macros 2022-02-16 19:33:28 +07:00
user.c Add Boolean node 2022-01-17 10:38:23 +01:00
vacuum.c Avoid VACUUM reltuples distortion. 2022-02-16 17:15:50 -08:00
vacuumparallel.c Unify VACUUM VERBOSE and autovacuum logging. 2022-01-14 16:50:34 -08:00
variable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
view.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00