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

Commitb797def

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 parent8d578b9 commitb797def

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
289289
Form_pg_attributeatt;
290290
TypeCacheEntry*typentry;
291291

292+
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
293+
294+
/*
295+
* Ignore dropped columns as the publisher doesn't send those
296+
*/
297+
if (att->attisdropped)
298+
continue;
299+
292300
/*
293301
* If one value is NULL and other is not, then they are certainly not
294302
* equal
@@ -302,8 +310,6 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
302310
if (slot1->tts_isnull[attrnum]||slot2->tts_isnull[attrnum])
303311
continue;
304312

305-
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
306-
307313
typentry=eq[attrnum];
308314
if (typentry==NULL)
309315
{

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,61 @@
370370
is($result,qq(1
371371
3),'check data in subscriber sch2.t1 after schema rename');
372372

373+
# Again, drop replication state but not tables.
374+
$node_subscriber->safe_psql('postgres',"DROP SUBSCRIPTION tap_sub_sch");
375+
$node_publisher->safe_psql('postgres',"DROP PUBLICATION tap_pub_sch");
376+
377+
$node_publisher->stop('fast');
378+
$node_subscriber->stop('fast');
379+
380+
# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns,
381+
# we fail to apply updates and deletes
382+
$node_publisher->rotate_logfile();
383+
$node_publisher->start();
384+
385+
$node_subscriber->rotate_logfile();
386+
$node_subscriber->start();
387+
388+
$node_publisher->safe_psql(
389+
'postgres',qq(
390+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
391+
ALTER TABLE dropped_cols REPLICA IDENTITY FULL;
392+
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols;
393+
-- some initial data
394+
INSERT INTO dropped_cols VALUES (1, 1, 1);
395+
));
396+
397+
$node_subscriber->safe_psql(
398+
'postgres',qq(
399+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
400+
));
401+
402+
$publisher_connstr =$node_publisher->connstr .' dbname=postgres';
403+
$node_subscriber->safe_psql('postgres',
404+
"CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr' PUBLICATION pub_dropped_cols"
405+
);
406+
$node_subscriber->wait_for_subscription_sync;
407+
408+
$node_publisher->safe_psql(
409+
'postgres',qq(
410+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
411+
));
412+
$node_subscriber->safe_psql(
413+
'postgres',qq(
414+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
415+
));
416+
417+
$node_publisher->safe_psql(
418+
'postgres',qq(
419+
UPDATE dropped_cols SET a = 100;
420+
));
421+
$node_publisher->wait_for_catchup('sub_dropped_cols');
422+
423+
is($node_subscriber->safe_psql(
424+
'postgres',"SELECT count(*) FROM dropped_cols WHERE a = 100"),
425+
qq(1),
426+
'replication with RI FULL and dropped columns');
427+
373428
$node_publisher->stop('fast');
374429
$node_subscriber->stop('fast');
375430

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp