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

Commitfc63e6b

Browse files
author
Amit Kapila
committed
Ignore dropped columns during apply of update/delete.
We fail to apply updates and deletes when the REPLICA IDENTITY FULL isused for the table having dropped columns. We didn't use to ignore droppedcolumns while doing tuple comparison among the tuples from the publisherand subscriber during apply of updates and deletes.Author: Onder Kalaci, Shi yuReviewed-by: Amit KapilaDiscussion:https://postgr.es/m/CACawEhVQC9WoofunvXg12aXtbqKnEgWxoRx3+v8q32AWYsdpGg@mail.gmail.com
1 parent44d44aa commitfc63e6b

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2)
242242
Form_pg_attributeatt;
243243
TypeCacheEntry*typentry;
244244

245+
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
246+
247+
/*
248+
* Ignore dropped columns as the publisher doesn't send those
249+
*/
250+
if (att->attisdropped)
251+
continue;
252+
245253
/*
246254
* If one value is NULL and other is not, then they are certainly not
247255
* equal
@@ -255,8 +263,6 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2)
255263
if (slot1->tts_isnull[attrnum]||slot2->tts_isnull[attrnum])
256264
continue;
257265

258-
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
259-
260266
typentry=lookup_type_cache(att->atttypid,TYPECACHE_EQ_OPR_FINFO);
261267
if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
262268
ereport(ERROR,

‎src/test/subscription/t/100_bugs.pl

Lines changed: 56 additions & 1 deletion
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=>5;
6+
use Test::Moretests=>6;
77

88
# Bug #15114
99

@@ -179,3 +179,58 @@
179179

180180
$node_publisher->stop('fast');
181181
$node_subscriber->stop('fast');
182+
183+
# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns,
184+
# we fail to apply updates and deletes
185+
my$node_publisher_d_cols = get_new_node('node_publisher_d_cols');
186+
$node_publisher_d_cols->init(allows_streaming=>'logical');
187+
$node_publisher_d_cols->start;
188+
189+
my$node_subscriber_d_cols = get_new_node('node_subscriber_d_cols');
190+
$node_subscriber_d_cols->init(allows_streaming=>'logical');
191+
$node_subscriber_d_cols->start;
192+
193+
$node_publisher_d_cols->safe_psql(
194+
'postgres',qq(
195+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
196+
ALTER TABLE dropped_cols REPLICA IDENTITY FULL;
197+
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols;
198+
-- some initial data
199+
INSERT INTO dropped_cols VALUES (1, 1, 1);
200+
));
201+
202+
$node_subscriber_d_cols->safe_psql(
203+
'postgres',qq(
204+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
205+
));
206+
207+
my$publisher_connstr_d_cols =
208+
$node_publisher_d_cols->connstr .' dbname=postgres';
209+
$node_subscriber_d_cols->safe_psql('postgres',
210+
"CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr_d_cols application_name=sub_dropped_cols' PUBLICATION pub_dropped_cols"
211+
);
212+
$node_subscriber_d_cols->wait_for_subscription_sync($node_publisher_d_cols,
213+
'sub_dropped_cols');
214+
215+
$node_publisher_d_cols->safe_psql(
216+
'postgres',qq(
217+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
218+
));
219+
$node_subscriber_d_cols->safe_psql(
220+
'postgres',qq(
221+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
222+
));
223+
224+
$node_publisher_d_cols->safe_psql(
225+
'postgres',qq(
226+
UPDATE dropped_cols SET a = 100;
227+
));
228+
$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols');
229+
230+
is($node_subscriber_d_cols->safe_psql(
231+
'postgres',"SELECT count(*) FROM dropped_cols WHERE a = 100"),
232+
qq(1),
233+
'replication with RI FULL and dropped columns');
234+
235+
$node_publisher_d_cols->stop('fast');
236+
$node_subscriber_d_cols->stop('fast');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp