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

Commitadedf54

Browse files
author
Amit Kapila
committed
Ignore generated columns during apply of update/delete.
We fail to apply updates and deletes when the REPLICA IDENTITY FULL isused for the table having generated columns. We didn't use to ignoregenerated columns while doing tuple comparison among the tuples fromthe publisher and subscriber during apply of updates and deletes.Author: Onder KalaciReviewed-by: Shi yu, Amit KapilaBackpatch-through: 12Discussion:https://postgr.es/m/CACawEhVQC9WoofunvXg12aXtbqKnEgWxoRx3+v8q32AWYsdpGg@mail.gmail.com
1 parentecb6965 commitadedf54

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,10 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
292292
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
293293

294294
/*
295-
* Ignore dropped columns as the publisher doesn't send those
295+
* Ignore dropped and generated columns as the publisher doesn't send
296+
* those
296297
*/
297-
if (att->attisdropped)
298+
if (att->attisdropped||att->attgenerated)
298299
continue;
299300

300301
/*

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@
377377
$node_publisher->stop('fast');
378378
$node_subscriber->stop('fast');
379379

380-
# The bug was that when the REPLICA IDENTITY FULL is used with droppedcolumns,
381-
# we fail to apply updates and deletes
380+
# The bug was that when the REPLICA IDENTITY FULL is used with droppedor
381+
#generated columns,we fail to apply updates and deletes
382382
$node_publisher->rotate_logfile();
383383
$node_publisher->start();
384384

@@ -389,14 +389,18 @@
389389
'postgres',qq(
390390
CREATE TABLE dropped_cols (a int, b_drop int, c int);
391391
ALTER TABLE dropped_cols REPLICA IDENTITY FULL;
392-
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols;
392+
CREATE TABLE generated_cols (a int, b_gen int GENERATED ALWAYS AS (5 * a) STORED, c int);
393+
ALTER TABLE generated_cols REPLICA IDENTITY FULL;
394+
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols, generated_cols;
393395
-- some initial data
394396
INSERT INTO dropped_cols VALUES (1, 1, 1);
397+
INSERT INTO generated_cols (a, c) VALUES (1, 1);
395398
));
396399

397400
$node_subscriber->safe_psql(
398401
'postgres',qq(
399402
CREATE TABLE dropped_cols (a int, b_drop int, c int);
403+
CREATE TABLE generated_cols (a int, b_gen int GENERATED ALWAYS AS (5 * a) STORED, c int);
400404
));
401405

402406
$publisher_connstr =$node_publisher->connstr .' dbname=postgres';
@@ -417,6 +421,7 @@
417421
$node_publisher->safe_psql(
418422
'postgres',qq(
419423
UPDATE dropped_cols SET a = 100;
424+
UPDATE generated_cols SET a = 100;
420425
));
421426
$node_publisher->wait_for_catchup('sub_dropped_cols');
422427

@@ -425,6 +430,11 @@
425430
qq(1),
426431
'replication with RI FULL and dropped columns');
427432

433+
is($node_subscriber->safe_psql(
434+
'postgres',"SELECT count(*) FROM generated_cols WHERE a = 100"),
435+
qq(1),
436+
'replication with RI FULL and generated columns');
437+
428438
$node_publisher->stop('fast');
429439
$node_subscriber->stop('fast');
430440

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp