mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Fix a WARNING for data origin discrepancies.
Previously, a WARNING was issued at the time of defining a subscription with origin=NONE only when the publisher subscribed to the same table from other publishers, indicating potential data origination from different origins. However, the publisher can subscribe to the partition ancestors or partition children of the table from other publishers, which could also result in mixed-origin data inclusion. So, give a WARNING in those cases as well. Reported-by: Sergey Tatarintsev <s.tatarintsev@postgrespro.ru> Author: Hou Zhijie <houzj.fnst@fujitsu.com> Author: Shlok Kyal <shlok.kyal.oss@gmail.com> Reviewed-by: Vignesh C <vignesh21@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Backpatch-through: 16, where it was introduced Discussion: https://postgr.es/m/5eda6a9c-63cf-404d-8a49-8dcb116a29f3@postgrespro.ru
This commit is contained in:
@@ -2083,11 +2083,12 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check and log a warning if the publisher has subscribed to the same table
|
||||
* from some other publisher. This check is required only if "copy_data = true"
|
||||
* and "origin = none" for CREATE SUBSCRIPTION and
|
||||
* ALTER SUBSCRIPTION ... REFRESH statements to notify the user that data
|
||||
* having origin might have been copied.
|
||||
* Check and log a warning if the publisher has subscribed to the same table,
|
||||
* its partition ancestors (if it's a partition), or its partition children (if
|
||||
* it's a partitioned table), from some other publishers. This check is
|
||||
* required only if "copy_data = true" and "origin = none" for CREATE
|
||||
* SUBSCRIPTION and ALTER SUBSCRIPTION ... REFRESH statements to notify the
|
||||
* user that data having origin might have been copied.
|
||||
*
|
||||
* This check need not be performed on the tables that are already added
|
||||
* because incremental sync for those tables will happen through WAL and the
|
||||
@@ -2117,7 +2118,9 @@ check_publications_origin(WalReceiverConn *wrconn, List *publications,
|
||||
"SELECT DISTINCT P.pubname AS pubname\n"
|
||||
"FROM pg_publication P,\n"
|
||||
" LATERAL pg_get_publication_tables(P.pubname) GPT\n"
|
||||
" JOIN pg_subscription_rel PS ON (GPT.relid = PS.srrelid),\n"
|
||||
" JOIN pg_subscription_rel PS ON (GPT.relid = PS.srrelid OR"
|
||||
" GPT.relid IN (SELECT relid FROM pg_partition_ancestors(PS.srrelid) UNION"
|
||||
" SELECT relid FROM pg_partition_tree(PS.srrelid))),\n"
|
||||
" pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)\n"
|
||||
"WHERE C.oid = GPT.relid AND P.pubname IN (");
|
||||
GetPublicationsStr(publications, &cmd, true);
|
||||
|
||||
Reference in New Issue
Block a user