@@ -64,12 +64,14 @@ static void
6464parse_subscription_options (List * options , bool * connect , bool * enabled_given ,
6565 bool * enabled , bool * create_slot ,
6666 bool * slot_name_given , char * * slot_name ,
67- bool * copy_data , char * * synchronous_commit )
67+ bool * copy_data , char * * synchronous_commit ,
68+ bool * refresh )
6869{
6970 ListCell * lc ;
7071 bool connect_given = false;
7172 bool create_slot_given = false;
7273 bool copy_data_given = false;
74+ bool refresh_given = false;
7375
7476 /* If connect is specified, the others also need to be. */
7577 Assert (!connect || (enabled && create_slot && copy_data ));
@@ -92,6 +94,8 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
9294 * copy_data = true;
9395 if (synchronous_commit )
9496 * synchronous_commit = NULL ;
97+ if (refresh )
98+ * refresh = true;
9599
96100 /* Parse options */
97101 foreach (lc , options )
@@ -167,6 +171,16 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
167171 PGC_BACKEND , PGC_S_TEST , GUC_ACTION_SET ,
168172 false, 0 , false);
169173 }
174+ else if (strcmp (defel -> defname , "refresh" ) == 0 && refresh )
175+ {
176+ if (refresh_given )
177+ ereport (ERROR ,
178+ (errcode (ERRCODE_SYNTAX_ERROR ),
179+ errmsg ("conflicting or redundant options" )));
180+
181+ refresh_given = true;
182+ * refresh = defGetBoolean (defel );
183+ }
170184 else
171185 ereport (ERROR ,
172186 (errcode (ERRCODE_SYNTAX_ERROR ),
@@ -315,7 +329,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
315329 */
316330 parse_subscription_options (stmt -> options , & connect , & enabled_given ,
317331 & enabled , & create_slot , & slotname_given ,
318- & slotname , & copy_data , & synchronous_commit );
332+ & slotname , & copy_data , & synchronous_commit ,
333+ NULL );
319334
320335 /*
321336 * Since creating a replication slot is not transactional, rolling back
@@ -645,7 +660,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
645660
646661 parse_subscription_options (stmt -> options , NULL , NULL , NULL ,
647662 NULL , & slotname_given , & slotname ,
648- NULL , & synchronous_commit );
663+ NULL , & synchronous_commit , NULL );
649664
650665 if (slotname_given )
651666 {
@@ -680,7 +695,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
680695
681696 parse_subscription_options (stmt -> options , NULL ,
682697 & enabled_given , & enabled , NULL ,
683- NULL , NULL , NULL , NULL );
698+ NULL , NULL , NULL , NULL , NULL );
684699 Assert (enabled_given );
685700
686701 if (!sub -> slotname && enabled )
@@ -712,13 +727,13 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
712727 break ;
713728
714729 case ALTER_SUBSCRIPTION_PUBLICATION :
715- case ALTER_SUBSCRIPTION_PUBLICATION_REFRESH :
716730 {
717731 bool copy_data ;
732+ bool refresh ;
718733
719734 parse_subscription_options (stmt -> options , NULL , NULL , NULL ,
720735 NULL , NULL , NULL , & copy_data ,
721- NULL );
736+ NULL , & refresh );
722737
723738 values [Anum_pg_subscription_subpublications - 1 ] =
724739 publicationListToArray (stmt -> publication );
@@ -727,12 +742,13 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
727742 update_tuple = true;
728743
729744 /* Refresh if user asked us to. */
730- if (stmt -> kind == ALTER_SUBSCRIPTION_PUBLICATION_REFRESH )
745+ if (refresh )
731746 {
732747 if (!sub -> enabled )
733748 ereport (ERROR ,
734749 (errcode (ERRCODE_SYNTAX_ERROR ),
735- errmsg ("ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled subscriptions" )));
750+ errmsg ("ALTER SUBSCRIPTION with refresh is not allowed for disabled subscriptions" ),
751+ errhint ("Use ALTER SUBSCRIPTION ... SET PUBLICATION ... WITH (refresh = false)." )));
736752
737753 /* Make sure refresh sees the new list of publications. */
738754 sub -> publications = stmt -> publication ;
@@ -754,7 +770,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
754770
755771 parse_subscription_options (stmt -> options , NULL , NULL , NULL ,
756772 NULL , NULL , NULL , & copy_data ,
757- NULL );
773+ NULL , NULL );
758774
759775 AlterSubscription_refresh (sub , copy_data );
760776
0 commit comments