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

Commit7eb6217

Browse files
committed
Remove incorrect assertion for INSERT in logical replication's publisher
On the publisher, it was assumed that an INSERT change cannot happen fora relation with no replica identity. However this is true only for achange that needs references to old rows, aka UPDATE or DELETE, sotrying to use logical replication with a relation that has no replicaidentity led to an assertion failure in the publisher when issuing anINSERT. This commit removes the incorrect assertion, and adds moreregression tests to provide coverage for relations without replicaidentity.Reported-by: Neha SharmaAuthor: Dilip Kumar, Michael PaquierReviewed-by: Andres FreundDiscussion:https://postgr.es/m/CANiYTQsL1Hb8_Km08qd32svrqNumXLJeoGo014O7VZymgOhZEA@mail.gmail.comBackpatch-through: 10
1 parent2e86e15 commit7eb6217

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

‎src/backend/replication/logical/proto.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
143143
{
144144
pq_sendbyte(out,'I');/* action INSERT */
145145

146-
Assert(rel->rd_rel->relreplident==REPLICA_IDENTITY_DEFAULT||
147-
rel->rd_rel->relreplident==REPLICA_IDENTITY_FULL||
148-
rel->rd_rel->relreplident==REPLICA_IDENTITY_INDEX);
149-
150146
/* use Oid as relation identifier */
151147
pq_sendint32(out,RelationGetRelid(rel));
152148

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use warnings;
44
use PostgresNode;
55
use TestLib;
6-
use Test::Moretests=>22;
6+
use Test::Moretests=>23;
77

88
# Initialize publisher node
99
my$node_publisher = get_new_node('publisher');
@@ -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+
# Let this table with REPLICA IDENTITY NOTHING, allowing only INSERT changes.
38+
$node_publisher->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
39+
$node_publisher->safe_psql('postgres',
40+
"ALTER TABLE tab_nothing REPLICA IDENTITY NOTHING");
3741

3842
# Setup structure on subscriber
3943
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_notrep (a int)");
@@ -42,6 +46,7 @@
4246
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_full2 (x text)");
4347
$node_subscriber->safe_psql('postgres',
4448
"CREATE TABLE tab_rep (a int primary key)");
49+
$node_subscriber->safe_psql('postgres',"CREATE TABLE tab_nothing (a int)");
4550

4651
# different column count and order than on publisher
4752
$node_subscriber->safe_psql('postgres',
@@ -59,7 +64,7 @@
5964
$node_publisher->safe_psql('postgres',
6065
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
6166
$node_publisher->safe_psql('postgres',
62-
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include"
67+
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing"
6368
);
6469
$node_publisher->safe_psql('postgres',
6570
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
@@ -98,6 +103,9 @@
98103
$node_publisher->safe_psql('postgres',
99104
"INSERT INTO tab_mixed VALUES (2, 'bar', 2.2)");
100105

106+
$node_publisher->safe_psql('postgres',
107+
"INSERT INTO tab_nothing VALUES (generate_series(1,20))");
108+
101109
$node_publisher->safe_psql('postgres',
102110
"INSERT INTO tab_include SELECT generate_series(1,50)");
103111
$node_publisher->safe_psql('postgres',
@@ -118,6 +126,10 @@
118126
is($result,qq(local|1.1|foo|1
119127
local|2.2|bar|2),'check replicated changes with different column order');
120128

129+
$result =
130+
$node_subscriber->safe_psql('postgres',"SELECT count(*) FROM tab_nothing");
131+
is($result,qq(20),'check replicated changes with REPLICA IDENTITY NOTHING');
132+
121133
$result =$node_subscriber->safe_psql('postgres',
122134
"SELECT count(*), min(a), max(a) FROM tab_include");
123135
is($result,qq(20|-20|-1),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp