mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Fix few issues in commit 5509055d69.
Test failure on buildfarm member prion: The test failed due to an unexpected LOCATION: line appearing between the WARNING and ERROR messages. This occurred because the prion machine uses log_error_verbosity = verbose, which includes additional context in error messages. The test was originally checking for both WARNING and ERROR messages in sequence sync, but the extra LOCATION: line disrupted this pattern. To make the test robust across different verbosity settings, it now only checks for the presence of the WARNING message after the test, which is sufficient to validate the intended behavior. Failure to sync sequences with quoted names: The previous implementation did not correctly quote sequence names when querying remote information, leading to failures when quoted sequence names were used. This fix ensures that sequence names are properly quoted during remote queries, allowing sequences with quoted identifiers to be synced correctly. Author: Vignesh C <vignesh21@gmail.com> Author: Shinya Kato <shinya11.kato@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CALDaNm0WcdSCoNPiE-5ek4J2dMJ5o111GPTzKCYj9G5i=ONYtQ@mail.gmail.com Discussion: https://postgr.es/m/CAOzEurQOSN=Zcp9uVnatNbAy=2WgMTJn_DYszYjv0KUeQX_e_A@mail.gmail.com
This commit is contained in:
@@ -60,6 +60,7 @@
|
|||||||
#include "replication/logicalworker.h"
|
#include "replication/logicalworker.h"
|
||||||
#include "replication/worker_internal.h"
|
#include "replication/worker_internal.h"
|
||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/fmgroids.h"
|
#include "utils/fmgroids.h"
|
||||||
#include "utils/guc.h"
|
#include "utils/guc.h"
|
||||||
#include "utils/inval.h"
|
#include "utils/inval.h"
|
||||||
@@ -407,14 +408,20 @@ copy_sequences(WalReceiverConn *conn)
|
|||||||
|
|
||||||
for (int idx = cur_batch_base_index; idx < n_seqinfos; idx++)
|
for (int idx = cur_batch_base_index; idx < n_seqinfos; idx++)
|
||||||
{
|
{
|
||||||
|
char *nspname_literal;
|
||||||
|
char *seqname_literal;
|
||||||
|
|
||||||
LogicalRepSequenceInfo *seqinfo =
|
LogicalRepSequenceInfo *seqinfo =
|
||||||
(LogicalRepSequenceInfo *) list_nth(seqinfos, idx);
|
(LogicalRepSequenceInfo *) list_nth(seqinfos, idx);
|
||||||
|
|
||||||
if (seqstr->len > 0)
|
if (seqstr->len > 0)
|
||||||
appendStringInfoString(seqstr, ", ");
|
appendStringInfoString(seqstr, ", ");
|
||||||
|
|
||||||
appendStringInfo(seqstr, "(\'%s\', \'%s\', %d)",
|
nspname_literal = quote_literal_cstr(seqinfo->nspname);
|
||||||
seqinfo->nspname, seqinfo->seqname, idx);
|
seqname_literal = quote_literal_cstr(seqinfo->seqname);
|
||||||
|
|
||||||
|
appendStringInfo(seqstr, "(%s, %s, %d)",
|
||||||
|
nspname_literal, seqname_literal, idx);
|
||||||
|
|
||||||
if (++batch_size == MAX_SEQUENCES_SYNC_PER_BATCH)
|
if (++batch_size == MAX_SEQUENCES_SYNC_PER_BATCH)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ $node_subscriber->start;
|
|||||||
my $ddl = qq(
|
my $ddl = qq(
|
||||||
CREATE TABLE regress_seq_test (v BIGINT);
|
CREATE TABLE regress_seq_test (v BIGINT);
|
||||||
CREATE SEQUENCE regress_s1;
|
CREATE SEQUENCE regress_s1;
|
||||||
|
CREATE SEQUENCE "regress'quote";
|
||||||
);
|
);
|
||||||
$node_publisher->safe_psql('postgres', $ddl);
|
$node_publisher->safe_psql('postgres', $ddl);
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ $ddl = qq(
|
|||||||
CREATE SEQUENCE regress_s1;
|
CREATE SEQUENCE regress_s1;
|
||||||
CREATE SEQUENCE regress_s2;
|
CREATE SEQUENCE regress_s2;
|
||||||
CREATE SEQUENCE regress_s3;
|
CREATE SEQUENCE regress_s3;
|
||||||
|
CREATE SEQUENCE "regress'quote";
|
||||||
);
|
);
|
||||||
$node_subscriber->safe_psql('postgres', $ddl);
|
$node_subscriber->safe_psql('postgres', $ddl);
|
||||||
|
|
||||||
@@ -40,6 +42,7 @@ $node_publisher->safe_psql(
|
|||||||
'postgres', qq(
|
'postgres', qq(
|
||||||
-- generate a number of values using the sequence
|
-- generate a number of values using the sequence
|
||||||
INSERT INTO regress_seq_test SELECT nextval('regress_s1') FROM generate_series(1,100);
|
INSERT INTO regress_seq_test SELECT nextval('regress_s1') FROM generate_series(1,100);
|
||||||
|
INSERT INTO regress_seq_test SELECT nextval('"regress''quote"') FROM generate_series(1,100);
|
||||||
));
|
));
|
||||||
|
|
||||||
# Setup logical replication pub/sub
|
# Setup logical replication pub/sub
|
||||||
@@ -63,6 +66,13 @@ my $result = $node_subscriber->safe_psql(
|
|||||||
));
|
));
|
||||||
is($result, '100|t', 'initial test data replicated');
|
is($result, '100|t', 'initial test data replicated');
|
||||||
|
|
||||||
|
$result = $node_subscriber->safe_psql(
|
||||||
|
'postgres', qq(
|
||||||
|
SELECT last_value, is_called FROM "regress'quote";
|
||||||
|
));
|
||||||
|
is($result, '100|t',
|
||||||
|
'initial test data replicated for sequence name having quotes');
|
||||||
|
|
||||||
##########
|
##########
|
||||||
## ALTER SUBSCRIPTION ... REFRESH PUBLICATION should cause sync of new
|
## ALTER SUBSCRIPTION ... REFRESH PUBLICATION should cause sync of new
|
||||||
# sequences of the publisher, but changes to existing sequences should
|
# sequences of the publisher, but changes to existing sequences should
|
||||||
@@ -201,14 +211,14 @@ $node_subscriber->safe_psql('postgres',
|
|||||||
# Verify that an error is logged for parameter differences on sequence
|
# Verify that an error is logged for parameter differences on sequence
|
||||||
# ('regress_s4').
|
# ('regress_s4').
|
||||||
$node_subscriber->wait_for_log(
|
$node_subscriber->wait_for_log(
|
||||||
qr/WARNING: ( [A-Z0-9]+:)? mismatched or renamed sequence on subscriber \("public.regress_s4"\)\n.*ERROR: ( [A-Z0-9]+:)? logical replication sequence synchronization failed for subscription "regress_seq_sub"/,
|
qr/WARNING: ( [A-Z0-9]+:)? mismatched or renamed sequence on subscriber \("public.regress_s4"\)/,
|
||||||
$log_offset);
|
$log_offset);
|
||||||
|
|
||||||
# Verify that an error is logged for the missing sequence ('regress_s4').
|
# Verify that an error is logged for the missing sequence ('regress_s4').
|
||||||
$node_publisher->safe_psql('postgres', qq(DROP SEQUENCE regress_s4;));
|
$node_publisher->safe_psql('postgres', qq(DROP SEQUENCE regress_s4;));
|
||||||
|
|
||||||
$node_subscriber->wait_for_log(
|
$node_subscriber->wait_for_log(
|
||||||
qr/WARNING: ( [A-Z0-9]+:)? missing sequence on publisher \("public.regress_s4"\)\n.*ERROR: ( [A-Z0-9]+:)? logical replication sequence synchronization failed for subscription "regress_seq_sub"/,
|
qr/WARNING: ( [A-Z0-9]+:)? missing sequence on publisher \("public.regress_s4"\)/,
|
||||||
$log_offset);
|
$log_offset);
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|||||||
Reference in New Issue
Block a user