Fix assorted issues in conflict log table handling.

DROP SUBSCRIPTION and ALTER SUBSCRIPTION ... SET
(conflict_log_destination = 'log') dropped the conflict log table with
DROP_CASCADE since a5918fddf1, so user objects depending on the table or
its row type, such as views or functions, were dropped silently. Those
objects need not be owned by the subscription owner, and for ALTER the
effect is surprising because it looks like a mere logging setting change.

Now DROP SUBSCRIPTION passes its CASCADE | RESTRICT behavior down to the
deletion of the table, and ALTER SUBSCRIPTION always uses RESTRICT, so
both fail when other objects depend on the table, as DROP TABLE does. In
DROP SUBSCRIPTION the table is now dropped after the workers are stopped
and the prepared-transaction check, but before the tablesync origins are
dropped, because dropping an origin resets its progress in shared memory
and that is not undone on rollback.

Also document the pg_subscription columns subconflictlogrelid and
subconflictlogdest in catalogs.sgml, and explain once, above
IsConflictLogTableNamespace(), why operations on conflict log tables are
restricted, instead of repeating it at each call site.

Author: Zsolt Parragi <[email protected]>
Author: Nisha Moond <[email protected]>
Author: Dilip Kumar <[email protected]>
Reviewed-by: shveta malik <[email protected]>
Reviewed-by: vignesh C <[email protected]>
Reviewed-by: Hayato Kuroda <[email protected]>
Reviewed-by: Zhijie Hou <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Discussion: 
https://postgr.es/m/CAFiTN-sHeA%3DA%2B054KcOGue_q4tiT65rRvKxfdmJL3xjMwa2Kow%40mail.gmail.com
Discussion: 
https://postgr.es/m/CAN4CZFOqiZtHOHAgd1mA325XQrsShj0C%3DvK2SBboUTFEmdoPZg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b8bf28800559a9ad71360fb2384d4b9981d24fa8

Modified Files
--------------
doc/src/sgml/catalogs.sgml                 | 26 +++++++++++
doc/src/sgml/ddl.sgml                      |  2 +-
doc/src/sgml/ref/alter_subscription.sgml   |  3 +-
doc/src/sgml/ref/drop_subscription.sgml    | 15 +++++--
src/backend/catalog/catalog.c              | 13 +++++-
src/backend/commands/policy.c              |  5 ---
src/backend/commands/subscriptioncmds.c    | 72 +++++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 20 ---------
src/backend/commands/trigger.c             | 10 -----
src/backend/replication/logical/conflict.c |  8 +++-
src/backend/rewrite/rewriteDefine.c        | 10 -----
src/test/regress/expected/subscription.out | 18 +++++++-
src/test/regress/sql/subscription.sql      | 11 ++++-
13 files changed, 141 insertions(+), 72 deletions(-)

Reply via email to