@@ -175,8 +175,7 @@ parse_publication_options(ParseState *pstate,
175175static void
176176ObjectsInPublicationToOids (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 ,
0 commit comments