Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 05843b1

Browse files
committed
Minor improvements in sequence decoding code and docs
A couple minor comment improvements and code cleanups, based on post-commit feedback to the sequence decoding patch. Author: Amit Kapila, vignesh C Discussion: https://postgr.es/m/aeb2ba8d-e6f4-5486-cc4c-0d4982c291cb@enterprisedb.com
1 parent 174877f commit 05843b1

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7141,7 +7141,7 @@ Sequence
71417141
</term>
71427142
<listitem>
71437143
<para>
7144-
1 if the sequence update is transactions, 0 otherwise.
7144+
1 if the sequence update is transactional, 0 otherwise.
71457145
</para>
71467146
</listitem>
71477147
</varlistentry>

src/backend/catalog/pg_publication.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ AssertObjectTypeValid(char objectType)
193193
}
194194

195195
/*
196-
* Determine object type given the object type set for a schema.
196+
* Determine object type matching a given a relkind value.
197197
*/
198198
char
199199
pub_get_object_type_for_relkind(char relkind)

src/backend/commands/publicationcmds.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ parse_publication_options(ParseState *pstate,
175175
static void
176176
ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
177177
List **tables, List **sequences,
178-
List **tables_schemas, List **sequences_schemas,
179-
List **schemas)
178+
List **tables_schemas, List **sequences_schemas)
180179
{
181180
ListCell *cell;
182181
PublicationObjSpec *pubobj;
@@ -204,14 +203,12 @@ ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
204203

205204
/* Filter out duplicates if user specifies "sch1, sch1" */
206205
*tables_schemas = list_append_unique_oid(*tables_schemas, schemaid);
207-
*schemas = list_append_unique_oid(*schemas, schemaid);
208206
break;
209207
case PUBLICATIONOBJ_SEQUENCES_IN_SCHEMA:
210208
schemaid = get_namespace_oid(pubobj->name, false);
211209

212210
/* Filter out duplicates if user specifies "sch1, sch1" */
213211
*sequences_schemas = list_append_unique_oid(*sequences_schemas, schemaid);
214-
*schemas = list_append_unique_oid(*schemas, schemaid);
215212
break;
216213
case PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA:
217214
search_path = fetch_search_path(false);
@@ -225,7 +222,6 @@ ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
225222

226223
/* Filter out duplicates if user specifies "sch1, sch1" */
227224
*tables_schemas = list_append_unique_oid(*tables_schemas, schemaid);
228-
*schemas = list_append_unique_oid(*schemas, schemaid);
229225
break;
230226
case PUBLICATIONOBJ_SEQUENCES_IN_CUR_SCHEMA:
231227
search_path = fetch_search_path(false);
@@ -239,7 +235,6 @@ ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
239235

240236
/* Filter out duplicates if user specifies "sch1, sch1" */
241237
*sequences_schemas = list_append_unique_oid(*sequences_schemas, schemaid);
242-
*schemas = list_append_unique_oid(*schemas, schemaid);
243238
break;
244239
default:
245240
/* shouldn't happen */
@@ -679,7 +674,6 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
679674
List *sequences = NIL;
680675
List *tables_schemaidlist = NIL;
681676
List *sequences_schemaidlist = NIL;
682-
List *schemaidlist = NIL;
683677

684678
bool for_all_tables = false;
685679
bool for_all_sequences = false;
@@ -706,6 +700,12 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
706700
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
707701
errmsg("must be superuser to create FOR ALL TABLES publication")));
708702

703+
/* FOR ALL SEQUENCES requires superuser */
704+
if (for_all_sequences && !superuser())
705+
ereport(ERROR,
706+
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
707+
errmsg("must be superuser to create FOR ALL SEQUENCES publication")));
708+
709709
rel = table_open(PublicationRelationId, RowExclusiveLock);
710710

711711
/* Check if name is used */
@@ -782,8 +782,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
782782
ObjectsInPublicationToOids(stmt->pubobjects, pstate,
783783
&tables, &sequences,
784784
&tables_schemaidlist,
785-
&sequences_schemaidlist,
786-
&schemaidlist);
785+
&sequences_schemaidlist);
787786

788787
/* FOR ALL TABLES IN SCHEMA requires superuser */
789788
if (list_length(tables_schemaidlist) > 0 && !superuser())
@@ -1321,7 +1320,7 @@ CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
13211320
NameStr(pubform->pubname)),
13221321
errdetail("Tables cannot be added to or dropped from FOR ALL TABLES publications.")));
13231322

1324-
/* Check that user is allowed to manipulate the publication tables. */
1323+
/* Check that user is allowed to manipulate the publication sequences. */
13251324
if (sequences && pubform->puballsequences)
13261325
ereport(ERROR,
13271326
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -1462,14 +1461,12 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
14621461
List *sequences = NIL;
14631462
List *tables_schemaidlist = NIL;
14641463
List *sequences_schemaidlist = NIL;
1465-
List *schemaidlist = NIL;
14661464
Oid pubid = pubform->oid;
14671465

14681466
ObjectsInPublicationToOids(stmt->pubobjects, pstate,
14691467
&tables, &sequences,
14701468
&tables_schemaidlist,
1471-
&sequences_schemaidlist,
1472-
&schemaidlist);
1469+
&sequences_schemaidlist);
14731470

14741471
CheckAlterPublication(stmt, tup,
14751472
tables, tables_schemaidlist,

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,8 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
18041804
{
18051805
Oid schemaId = get_rel_namespace(relid);
18061806
List *pubids = GetRelationPublications(relid);
1807-
char objectType = pub_get_object_type_for_relkind(get_rel_relkind(relid));
1807+
char relkind = get_rel_relkind(relid);
1808+
char objectType = pub_get_object_type_for_relkind(relkind);
18081809
/*
18091810
* We don't acquire a lock on the namespace system table as we build
18101811
* the cache entry using a historic snapshot and all the later changes
@@ -1815,7 +1816,6 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
18151816
Oid publish_as_relid = relid;
18161817
int publish_ancestor_level = 0;
18171818
bool am_partition = get_rel_relispartition(relid);
1818-
char relkind = get_rel_relkind(relid);
18191819
List *rel_publications = NIL;
18201820

18211821
/* Reload publications if needed before use. */

0 commit comments

Comments
 (0)