Skip to content

Commit 360bd23

Browse files
committed
Fix error with CREATE PUBLICATION, wal_level=minimal, and new tables.
CREATE PUBLICATION has failed spuriously when applied to a permanent relation created or rewritten in the current transaction. Make the same change to another site having the same semantic intent; the second instance has no user-visible consequences. Back-patch to v13, where commit c6b9204 broke this. Kyotaro Horiguchi Discussion: https://postgr.es/m/20210113.160705.2225256954956139776.horikyota.ntt@gmail.com
1 parent 8a54e12 commit 360bd23

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/backend/catalog/pg_publication.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
6767
errdetail("System tables cannot be added to publications.")));
6868

6969
/* UNLOGGED and TEMP relations cannot be part of publication. */
70-
if (!RelationNeedsWAL(targetrel))
70+
if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
7171
ereport(ERROR,
7272
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7373
errmsg("table \"%s\" cannot be replicated",

src/backend/optimizer/util/plancat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
126126
relation = table_open(relationObjectId, NoLock);
127127

128128
/* Temporary and unlogged relations are inaccessible during recovery. */
129-
if (!RelationNeedsWAL(relation) && RecoveryInProgress())
129+
if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
130+
RecoveryInProgress())
130131
ereport(ERROR,
131132
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
132133
errmsg("cannot access temporary or unlogged relations during recovery")));

src/test/subscription/t/001_rep_changes.pl

Lines changed: 19 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::More tests => 27;
6+
use Test::More tests => 28;
77

88
# Initialize publisher node
99
my $node_publisher = get_new_node('publisher');
@@ -451,3 +451,21 @@
451451

452452
$node_subscriber->stop('fast');
453453
$node_publisher->stop('fast');
454+
455+
# CREATE PUBLICATION while wal_level=minimal should succeed, with a WARNING
456+
$node_publisher->append_conf(
457+
'postgresql.conf', qq(
458+
wal_level=minimal
459+
max_wal_senders=0
460+
));
461+
$node_publisher->start;
462+
($result, my $retout, my $reterr) = $node_publisher->psql(
463+
'postgres', qq{
464+
BEGIN;
465+
CREATE TABLE skip_wal();
466+
CREATE PUBLICATION tap_pub2 FOR TABLE skip_wal;
467+
ROLLBACK;
468+
});
469+
ok( $reterr =~
470+
m/WARNING: wal_level is insufficient to publish logical changes/,
471+
'CREATE PUBLICATION while wal_level=minimal');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy