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

Commit3acb30b

Browse files
committed
Fix assertion with relation using REPLICA IDENTITY FULL in subscriber
In a logical replication subscriber, a table using REPLICA IDENTITY FULLwhich has a primary key would try to use the primary key's indexavailable to scan for a tuple, but an assertion only assumed as correctthe case of an index associated to REPLICA IDENTITY USING INDEX. Thiscommit corrects the assertion so as the use of a primary key index is avalid case.Reported-by: Dilip KumarAnalyzed-by: Dilip KumarAuthor: Euler TaveiraReviewed-by: Michael Paquier, Masahiko SawadaDiscussion:https://postgr.es/m/CAFiTN-u64S5bUiPL1q5kwpHNd0hRnf1OE-bzxNiOs5zo84i51w@mail.gmail.comBackpatch-through: 10
1 parent9d66ea5 commit3acb30b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ build_replindex_scan_key(ScanKey skey, Relation rel, Relation idxrel,
5555
int2vector*indkey=&idxrel->rd_index->indkey;
5656
boolhasnulls= false;
5757

58-
Assert(RelationGetReplicaIndex(rel)==RelationGetRelid(idxrel));
58+
Assert(RelationGetReplicaIndex(rel)==RelationGetRelid(idxrel)||
59+
RelationGetPrimaryKeyIndex(rel)==RelationGetRelid(idxrel));
5960

6061
indclassDatum=SysCacheGetAttr(INDEXRELID,idxrel->rd_indextuple,
6162
Anum_pg_index_indclass,&isnull);

‎src/test/subscription/t/001_rep_changes.pl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
"CREATE TABLE tab_mixed (a int primary key, b text, c numeric)");
3232
$node_publisher->safe_psql('postgres',
3333
"INSERT INTO tab_mixed (a, b, c) VALUES (1, 'foo', 1.1)");
34+
$node_publisher->safe_psql('postgres',
35+
"CREATE TABLE tab_full_pk (a int primary key, b text)");
36+
$node_publisher->safe_psql('postgres',
37+
"ALTER TABLE tab_full_pk REPLICA IDENTITY FULL");
3438
# Let this table with REPLICA IDENTITY NOTHING, allowing only INSERT changes.
3539
$node_publisher->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
3640
$node_publisher->safe_psql('postgres',
@@ -43,6 +47,10 @@
4347
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_full2 (x text)");
4448
$node_subscriber->safe_psql('postgres',
4549
"CREATE TABLE tab_rep (a int primary key)");
50+
$node_subscriber->safe_psql('postgres',
51+
"CREATE TABLE tab_full_pk (a int primary key, b text)");
52+
$node_subscriber->safe_psql('postgres',
53+
"ALTER TABLE tab_full_pk REPLICA IDENTITY FULL");
4654
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
4755

4856
# different column count and order than on publisher
@@ -56,7 +64,7 @@
5664
$node_publisher->safe_psql('postgres',
5765
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
5866
$node_publisher->safe_psql('postgres',
59-
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_nothing"
67+
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_nothing, tab_full_pk"
6068
);
6169
$node_publisher->safe_psql('postgres',
6270
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
@@ -99,6 +107,9 @@
99107
$node_publisher->safe_psql('postgres',
100108
"INSERT INTO tab_mixed VALUES (2, 'bar', 2.2)");
101109

110+
$node_publisher->safe_psql('postgres',
111+
"INSERT INTO tab_full_pk VALUES (1, 'foo')");
112+
102113
$node_publisher->safe_psql('postgres',
103114
"INSERT INTO tab_nothing VALUES (generate_series(1,20))");
104115

@@ -146,6 +157,8 @@
146157
"UPDATE tab_full2 SET x = 'bb' WHERE x = 'b'");
147158
$node_publisher->safe_psql('postgres',
148159
"UPDATE tab_mixed SET b = 'baz' WHERE a = 1");
160+
$node_publisher->safe_psql('postgres',
161+
"UPDATE tab_full_pk SET b = 'bar' WHERE a = 1");
149162

150163
# Wait for subscription to catch up
151164
$node_publisher->poll_query_until('postgres',$caughtup_query)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp