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

Commit65ead76

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 parent1b9e42e commit65ead76

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

‎src/backend/executor/execReplication.c

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

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

259-
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
260-
261267
typentry=eq[attrnum];
262268
if (typentry==NULL)
263269
{

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

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use warnings;
77
use PostgresNode;
88
use TestLib;
9-
use Test::Moretests=>7;
9+
use Test::Moretests=>8;
1010

1111
# Bug #15114
1212

@@ -298,3 +298,57 @@
298298

299299
$node_publisher->stop('fast');
300300
$node_subscriber->stop('fast');
301+
302+
# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns,
303+
# we fail to apply updates and deletes
304+
my$node_publisher_d_cols = get_new_node('node_publisher_d_cols');
305+
$node_publisher_d_cols->init(allows_streaming=>'logical');
306+
$node_publisher_d_cols->start;
307+
308+
my$node_subscriber_d_cols = get_new_node('node_subscriber_d_cols');
309+
$node_subscriber_d_cols->init(allows_streaming=>'logical');
310+
$node_subscriber_d_cols->start;
311+
312+
$node_publisher_d_cols->safe_psql(
313+
'postgres',qq(
314+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
315+
ALTER TABLE dropped_cols REPLICA IDENTITY FULL;
316+
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols;
317+
-- some initial data
318+
INSERT INTO dropped_cols VALUES (1, 1, 1);
319+
));
320+
321+
$node_subscriber_d_cols->safe_psql(
322+
'postgres',qq(
323+
CREATE TABLE dropped_cols (a int, b_drop int, c int);
324+
));
325+
326+
my$publisher_connstr_d_cols =
327+
$node_publisher_d_cols->connstr .' dbname=postgres';
328+
$node_subscriber_d_cols->safe_psql('postgres',
329+
"CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr_d_cols' PUBLICATION pub_dropped_cols"
330+
);
331+
$node_subscriber_d_cols->wait_for_subscription_sync;
332+
333+
$node_publisher_d_cols->safe_psql(
334+
'postgres',qq(
335+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
336+
));
337+
$node_subscriber_d_cols->safe_psql(
338+
'postgres',qq(
339+
ALTER TABLE dropped_cols DROP COLUMN b_drop;
340+
));
341+
342+
$node_publisher_d_cols->safe_psql(
343+
'postgres',qq(
344+
UPDATE dropped_cols SET a = 100;
345+
));
346+
$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols');
347+
348+
is($node_subscriber_d_cols->safe_psql(
349+
'postgres',"SELECT count(*) FROM dropped_cols WHERE a = 100"),
350+
qq(1),
351+
'replication with RI FULL and dropped columns');
352+
353+
$node_publisher_d_cols->stop('fast');
354+
$node_subscriber_d_cols->stop('fast');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp