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

Commit05d151e

Browse files
committed
Fix handling of temp and unlogged tables in FOR ALL TABLES publications
If a FOR ALL TABLES publication exists, temporary and unlogged tablesare ignored for publishing changes. But CheckCmdReplicaIdentity()would still check in that case that such a table has a replicaidentity set before accepting updates. To fix, haveGetRelationPublicationActions() return that such a table publishes noactions.Discussion:https://www.postgresql.org/message-id/f3f151f7-c4dd-1646-b998-f60bd6217dd3@2ndquadrant.com
1 parentfea2cab commit05d151e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

‎src/backend/utils/cache/relcache.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5236,6 +5236,13 @@ GetRelationPublicationActions(Relation relation)
52365236
MemoryContextoldcxt;
52375237
PublicationActions*pubactions=palloc0(sizeof(PublicationActions));
52385238

5239+
/*
5240+
* If not publishable, it publishes no actions. (pgoutput_change() will
5241+
* ignore it.)
5242+
*/
5243+
if (!is_publishable_relation(relation))
5244+
returnpubactions;
5245+
52395246
if (relation->rd_pubactions)
52405247
returnmemcpy(pubactions,relation->rd_pubactions,
52415248
sizeof(PublicationActions));

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

Lines changed: 36 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=>1;
6+
use Test::Moretests=>3;
77

88
subwait_for_caught_up
99
{
@@ -72,3 +72,38 @@ sub wait_for_caught_up
7272
wait_for_caught_up($node_publisher,'sub1');
7373

7474
pass('index predicates do not cause crash');
75+
76+
$node_publisher->stop('fast');
77+
$node_subscriber->stop('fast');
78+
79+
80+
# Handling of temporary and unlogged tables with FOR ALL TABLES publications
81+
82+
# If a FOR ALL TABLES publication exists, temporary and unlogged
83+
# tables are ignored for publishing changes. The bug was that we
84+
# would still check in that case that such a table has a replica
85+
# identity set before accepting updates. If it did not it would cause
86+
# an error when an update was attempted.
87+
88+
$node_publisher = get_new_node('publisher2');
89+
$node_publisher->init(allows_streaming=>'logical');
90+
$node_publisher->start;
91+
92+
$node_publisher->safe_psql('postgres',
93+
"CREATE PUBLICATION pub FOR ALL TABLES");
94+
95+
is($node_publisher->psql(
96+
'postgres',
97+
"CREATE TEMPORARY TABLE tt1 AS SELECT 1 AS a; UPDATE tt1 SET a = 2;"),
98+
0,
99+
'update to temporary table without replica identity with FOR ALL TABLES publication'
100+
);
101+
102+
is($node_publisher->psql(
103+
'postgres',
104+
"CREATE UNLOGGED TABLE tu1 AS SELECT 1 AS a; UPDATE tu1 SET a = 2;"),
105+
0,
106+
'update to unlogged table without replica identity with FOR ALL TABLES publication'
107+
);
108+
109+
$node_publisher->stop('fast');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp