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

Commit7ccb2f5

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 parent474e7da commit7ccb2f5

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
@@ -57,7 +57,8 @@ build_replindex_scan_key(ScanKey skey, Relation rel, Relation idxrel,
5757
int2vector*indkey=&idxrel->rd_index->indkey;
5858
boolhasnulls= false;
5959

60-
Assert(RelationGetReplicaIndex(rel)==RelationGetRelid(idxrel));
60+
Assert(RelationGetReplicaIndex(rel)==RelationGetRelid(idxrel)||
61+
RelationGetPrimaryKeyIndex(rel)==RelationGetRelid(idxrel));
6162

6263
indclassDatum=SysCacheGetAttr(INDEXRELID,idxrel->rd_indextuple,
6364
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
@@ -34,6 +34,10 @@
3434
$node_publisher->safe_psql('postgres',
3535
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
3636
);
37+
$node_publisher->safe_psql('postgres',
38+
"CREATE TABLE tab_full_pk (a int primary key, b text)");
39+
$node_publisher->safe_psql('postgres',
40+
"ALTER TABLE tab_full_pk REPLICA IDENTITY FULL");
3741
# Let this table with REPLICA IDENTITY NOTHING, allowing only INSERT changes.
3842
$node_publisher->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
3943
$node_publisher->safe_psql('postgres',
@@ -46,6 +50,10 @@
4650
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_full2 (x text)");
4751
$node_subscriber->safe_psql('postgres',
4852
"CREATE TABLE tab_rep (a int primary key)");
53+
$node_subscriber->safe_psql('postgres',
54+
"CREATE TABLE tab_full_pk (a int primary key, b text)");
55+
$node_subscriber->safe_psql('postgres',
56+
"ALTER TABLE tab_full_pk REPLICA IDENTITY FULL");
4957
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
5058

5159
# different column count and order than on publisher
@@ -64,7 +72,7 @@
6472
$node_publisher->safe_psql('postgres',
6573
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
6674
$node_publisher->safe_psql('postgres',
67-
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing"
75+
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing, tab_full_pk"
6876
);
6977
$node_publisher->safe_psql('postgres',
7078
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
@@ -102,6 +110,9 @@
102110
$node_publisher->safe_psql('postgres',
103111
"INSERT INTO tab_mixed VALUES (2, 'bar', 2.2)");
104112

113+
$node_publisher->safe_psql('postgres',
114+
"INSERT INTO tab_full_pk VALUES (1, 'foo')");
115+
105116
$node_publisher->safe_psql('postgres',
106117
"INSERT INTO tab_nothing VALUES (generate_series(1,20))");
107118

@@ -159,6 +170,8 @@
159170
"UPDATE tab_full2 SET x = 'bb' WHERE x = 'b'");
160171
$node_publisher->safe_psql('postgres',
161172
"UPDATE tab_mixed SET b = 'baz' WHERE a = 1");
173+
$node_publisher->safe_psql('postgres',
174+
"UPDATE tab_full_pk SET b = 'bar' WHERE a = 1");
162175

163176
$node_publisher->wait_for_catchup('tap_sub');
164177

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp