mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
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 c6b92041d38512a4176ed76ad06f713d2e6c01a8 broke this. Kyotaro Horiguchi Discussion: https://postgr.es/m/20210113.160705.2225256954956139776.horikyota.ntt@gmail.com
This commit is contained in:
parent
8a54e12a38
commit
360bd2321b
@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
|
|||||||
errdetail("System tables cannot be added to publications.")));
|
errdetail("System tables cannot be added to publications.")));
|
||||||
|
|
||||||
/* UNLOGGED and TEMP relations cannot be part of publication. */
|
/* UNLOGGED and TEMP relations cannot be part of publication. */
|
||||||
if (!RelationNeedsWAL(targetrel))
|
if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("table \"%s\" cannot be replicated",
|
errmsg("table \"%s\" cannot be replicated",
|
||||||
|
@ -126,7 +126,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
|
|||||||
relation = table_open(relationObjectId, NoLock);
|
relation = table_open(relationObjectId, NoLock);
|
||||||
|
|
||||||
/* Temporary and unlogged relations are inaccessible during recovery. */
|
/* Temporary and unlogged relations are inaccessible during recovery. */
|
||||||
if (!RelationNeedsWAL(relation) && RecoveryInProgress())
|
if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
|
||||||
|
RecoveryInProgress())
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("cannot access temporary or unlogged relations during recovery")));
|
errmsg("cannot access temporary or unlogged relations during recovery")));
|
||||||
|
@ -3,7 +3,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use PostgresNode;
|
use PostgresNode;
|
||||||
use TestLib;
|
use TestLib;
|
||||||
use Test::More tests => 27;
|
use Test::More tests => 28;
|
||||||
|
|
||||||
# Initialize publisher node
|
# Initialize publisher node
|
||||||
my $node_publisher = get_new_node('publisher');
|
my $node_publisher = get_new_node('publisher');
|
||||||
@ -451,3 +451,21 @@ is($result, qq(0), 'check replication origin was dropped on subscriber');
|
|||||||
|
|
||||||
$node_subscriber->stop('fast');
|
$node_subscriber->stop('fast');
|
||||||
$node_publisher->stop('fast');
|
$node_publisher->stop('fast');
|
||||||
|
|
||||||
|
# CREATE PUBLICATION while wal_level=minimal should succeed, with a WARNING
|
||||||
|
$node_publisher->append_conf(
|
||||||
|
'postgresql.conf', qq(
|
||||||
|
wal_level=minimal
|
||||||
|
max_wal_senders=0
|
||||||
|
));
|
||||||
|
$node_publisher->start;
|
||||||
|
($result, my $retout, my $reterr) = $node_publisher->psql(
|
||||||
|
'postgres', qq{
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE skip_wal();
|
||||||
|
CREATE PUBLICATION tap_pub2 FOR TABLE skip_wal;
|
||||||
|
ROLLBACK;
|
||||||
|
});
|
||||||
|
ok( $reterr =~
|
||||||
|
m/WARNING: wal_level is insufficient to publish logical changes/,
|
||||||
|
'CREATE PUBLICATION while wal_level=minimal');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user