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

Commitb6bf90e

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 parent560bb56 commitb6bf90e

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
@@ -246,9 +246,10 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
246246
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
247247

248248
/*
249-
* Ignore dropped columns as the publisher doesn't send those
249+
* Ignore dropped and generated columns as the publisher doesn't send
250+
* those
250251
*/
251-
if (att->attisdropped)
252+
if (att->attisdropped||att->attgenerated)
252253
continue;
253254

254255
/*

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@
299299
$node_publisher->stop('fast');
300300
$node_subscriber->stop('fast');
301301

302-
# The bug was that when the REPLICA IDENTITY FULL is used with droppedcolumns,
303-
# we fail to apply updates and deletes
302+
# The bug was that when the REPLICA IDENTITY FULL is used with droppedor
303+
#generated columns,we fail to apply updates and deletes
304304
my$node_publisher_d_cols =
305305
PostgreSQL::Test::Cluster->new('node_publisher_d_cols');
306306
$node_publisher_d_cols->init(allows_streaming=>'logical');
@@ -315,14 +315,18 @@
315315
'postgres',qq(
316316
CREATE TABLE dropped_cols (a int, b_drop int, c int);
317317
ALTER TABLE dropped_cols REPLICA IDENTITY FULL;
318-
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols;
318+
CREATE TABLE generated_cols (a int, b_gen int GENERATED ALWAYS AS (5 * a) STORED, c int);
319+
ALTER TABLE generated_cols REPLICA IDENTITY FULL;
320+
CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols, generated_cols;
319321
-- some initial data
320322
INSERT INTO dropped_cols VALUES (1, 1, 1);
323+
INSERT INTO generated_cols (a, c) VALUES (1, 1);
321324
));
322325

323326
$node_subscriber_d_cols->safe_psql(
324327
'postgres',qq(
325328
CREATE TABLE dropped_cols (a int, b_drop int, c int);
329+
CREATE TABLE generated_cols (a int, b_gen int GENERATED ALWAYS AS (5 * a) STORED, c int);
326330
));
327331

328332
my$publisher_connstr_d_cols =
@@ -344,6 +348,7 @@
344348
$node_publisher_d_cols->safe_psql(
345349
'postgres',qq(
346350
UPDATE dropped_cols SET a = 100;
351+
UPDATE generated_cols SET a = 100;
347352
));
348353
$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols');
349354

@@ -352,6 +357,11 @@
352357
qq(1),
353358
'replication with RI FULL and dropped columns');
354359

360+
is($node_subscriber_d_cols->safe_psql(
361+
'postgres',"SELECT count(*) FROM generated_cols WHERE a = 100"),
362+
qq(1),
363+
'replication with RI FULL and generated columns');
364+
355365
$node_publisher_d_cols->stop('fast');
356366
$node_subscriber_d_cols->stop('fast');
357367

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp