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

Commit1df86aa

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 parentdc9ed21 commit1df86aa

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
@@ -565,6 +565,13 @@ CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
565565
{
566566
PublicationActions*pubactions;
567567

568+
/*
569+
* Skip checking the replica identity for partitioned tables, because the
570+
* operations are actually performed on the leaf partitions.
571+
*/
572+
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
573+
return;
574+
568575
/* We only need to do checks for UPDATE and DELETE. */
569576
if (cmd!=CMD_UPDATE&&cmd!=CMD_DELETE)
570577
return;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
140140
Tables:
141141
"public.testpub_parted"
142142

143+
-- works despite missing REPLICA IDENTITY, because no actual update happened
144+
UPDATE testpub_parted SET a = 1 WHERE false;
143145
-- should now fail, because parent's publication replicates updates
144146
UPDATE testpub_parted1 SET a = 1;
145147
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
@@ -85,6 +85,8 @@ UPDATE testpub_parted1 SET a = 1;
8585
-- only parent is listed as being in publication, not the partition
8686
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
8787
\dRp+ testpub_forparted
88+
-- works despite missing REPLICA IDENTITY, because no actual update happened
89+
UPDATE testpub_partedSET a=1WHERE false;
8890
-- should now fail, because parent's publication replicates updates
8991
UPDATE testpub_parted1SET a=1;
9092
ALTERTABLE testpub_parted DETACH PARTITION testpub_parted1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp