Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d5bd3a

Browse files
author
Amit Kapila
committed
Fix replica identity check for a partitioned table.
The current publisher code checks if UPDATE or DELETE can be executed withthe replica identity of the table even if it's a partitioned table. We canskip checking the replica identity for partitioned tables because theoperations are actually performed on the leaf partitions (not thepartitioned table).Reported-by: Brad NicholsonAuthor: Hou ZhijieReviewed-by: Peter Smith, Amit KapilaBackpatch-through: 13Discussion:https://postgr.es/m/CAMMnM%3D8i5DohH%3DYKzV0_wYuYSYvuOJoL9F5nzXTc%2ByzsG1f6rg%40mail.gmail.com
1 parentf4c32cd commit0d5bd3a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
569569
{
570570
PublicationDescpubdesc;
571571

572+
/*
573+
* Skip checking the replica identity for partitioned tables, because the
574+
* operations are actually performed on the leaf partitions.
575+
*/
576+
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
577+
return;
578+
572579
/* We only need to do checks for UPDATE and DELETE. */
573580
if (cmd!=CMD_UPDATE&&cmd!=CMD_DELETE)
574581
return;

‎src/test/regress/expected/publication.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
214214
Tables:
215215
"public.testpub_parted"
216216

217+
-- works despite missing REPLICA IDENTITY, because no actual update happened
218+
UPDATE testpub_parted SET a = 1 WHERE false;
217219
-- should now fail, because parent's publication replicates updates
218220
UPDATE testpub_parted1 SET a = 1;
219221
ERROR: cannot update table "testpub_parted1" because it does not have a replica identity and publishes updates

‎src/test/regress/sql/publication.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ UPDATE testpub_parted1 SET a = 1;
119119
-- only parent is listed as being in publication, not the partition
120120
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
121121
\dRp+ testpub_forparted
122+
-- works despite missing REPLICA IDENTITY, because no actual update happened
123+
UPDATE testpub_partedSET a=1WHERE false;
122124
-- should now fail, because parent's publication replicates updates
123125
UPDATE testpub_parted1SET a=1;
124126
ALTERTABLE testpub_parted DETACH PARTITION testpub_parted1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp