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

Commit002c9dd

Browse files
committed
Handle sequences in preprocess_pubobj_list
Commit75b1521 added support for logical replication of sequences,including grammar changes, but it did not update preprocess_pubobj_listaccordingly. This can cause segfaults with "continuations", i.e. whencommand specifies a list of objects: CREATE PUBLICATION p FOR SEQUENCE s1, s2;Reported by Amit Kapila, patch by me.Reported-by: Amit KapilaDiscussion:https://postgr.es/m/CAA4eK1JxDNKGBSNTyN-Xj2JRjzFo+ziSqJbjH==vuO0YF_CQrg@mail.gmail.com
1 parent2d22329 commit002c9dd

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

‎src/backend/parser/gram.y

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17493,7 +17493,8 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
1749317493
if (pubobj->pubobjtype == PUBLICATIONOBJ_CONTINUATION)
1749417494
pubobj->pubobjtype = prevobjtype;
1749517495

17496-
if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLE)
17496+
if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLE ||
17497+
pubobj->pubobjtype == PUBLICATIONOBJ_SEQUENCE)
1749717498
{
1749817499
/* relation name or pubtable must be set for this type of object*/
1749917500
if (!pubobj->name && !pubobj->pubtable)
@@ -17537,6 +17538,30 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
1753717538
errmsg("invalid schema name at or near"),
1753817539
parser_errposition(pubobj->location));
1753917540
}
17541+
else if (pubobj->pubobjtype == PUBLICATIONOBJ_SEQUENCES_IN_SCHEMA ||
17542+
pubobj->pubobjtype == PUBLICATIONOBJ_SEQUENCES_IN_CUR_SCHEMA)
17543+
{
17544+
/* WHERE clause is not allowed on a schema object*/
17545+
if (pubobj->pubtable && pubobj->pubtable->whereClause)
17546+
ereport(ERROR,
17547+
errcode(ERRCODE_SYNTAX_ERROR),
17548+
errmsg("WHERE clause not allowed for schema"),
17549+
parser_errposition(pubobj->location));
17550+
17551+
/*
17552+
* We can distinguish between the different type of schema
17553+
* objects based on whether name and pubtable is set.
17554+
*/
17555+
if (pubobj->name)
17556+
pubobj->pubobjtype = PUBLICATIONOBJ_SEQUENCES_IN_SCHEMA;
17557+
else if (!pubobj->name && !pubobj->pubtable)
17558+
pubobj->pubobjtype = PUBLICATIONOBJ_SEQUENCES_IN_CUR_SCHEMA;
17559+
else
17560+
ereport(ERROR,
17561+
errcode(ERRCODE_SYNTAX_ERROR),
17562+
errmsg("invalid schema name at or near"),
17563+
parser_errposition(pubobj->location));
17564+
}
1754017565

1754117566
prevobjtype = pubobj->pubobjtype;
1754217567
}

‎src/test/regress/expected/publication.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,24 @@ Publications:
319319

320320
DROP SEQUENCE testpub_seq0, pub_test.testpub_seq1, testpub_seq2;
321321
DROP PUBLICATION testpub_forallsequences, testpub_forsequence, testpub_forschema;
322+
-- publication testing multiple sequences at the same time
323+
CREATE SEQUENCE testpub_seq1;
324+
CREATE SEQUENCE testpub_seq2;
325+
SET client_min_messages = 'ERROR';
326+
CREATE PUBLICATION testpub_multi FOR SEQUENCE testpub_seq1, testpub_seq2;
327+
RESET client_min_messages;
328+
\dRp+ testpub_multi
329+
Publication testpub_multi
330+
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Sequences | Via root
331+
--------------------------+------------+---------------+---------+---------+---------+-----------+-----------+----------
332+
regress_publication_user | f | f | t | t | t | t | t | f
333+
Sequences:
334+
"public.testpub_seq1"
335+
"public.testpub_seq2"
336+
337+
DROP PUBLICATION testpub_multi;
338+
DROP SEQUENCE testpub_seq1;
339+
DROP SEQUENCE testpub_seq2;
322340
-- Publication mixing tables and sequences
323341
SET client_min_messages = 'ERROR';
324342
CREATE PUBLICATION testpub_mix;

‎src/test/regress/sql/publication.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname
167167
DROPSEQUENCE testpub_seq0,pub_test.testpub_seq1, testpub_seq2;
168168
DROP PUBLICATION testpub_forallsequences, testpub_forsequence, testpub_forschema;
169169

170+
171+
-- publication testing multiple sequences at the same time
172+
CREATESEQUENCEtestpub_seq1;
173+
CREATESEQUENCEtestpub_seq2;
174+
175+
SET client_min_messages='ERROR';
176+
CREATE PUBLICATION testpub_multi FOR SEQUENCE testpub_seq1, testpub_seq2;
177+
RESET client_min_messages;
178+
179+
\dRp+ testpub_multi
180+
181+
DROP PUBLICATION testpub_multi;
182+
DROPSEQUENCE testpub_seq1;
183+
DROPSEQUENCE testpub_seq2;
184+
185+
170186
-- Publication mixing tables and sequences
171187
SET client_min_messages='ERROR';
172188
CREATE PUBLICATION testpub_mix;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp