@@ -6252,14 +6252,16 @@ flatten_set_variable_args(const char *name, List *args)
62526252 * SET command
62536253 */
62546254void
6255- ExecSetVariableStmt (VariableSetStmt * stmt )
6255+ ExecSetVariableStmt (VariableSetStmt * stmt , bool isTopLevel )
62566256{
62576257 GucAction action = stmt -> is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET ;
62586258
62596259 switch (stmt -> kind )
62606260 {
62616261 case VAR_SET_VALUE :
62626262 case VAR_SET_CURRENT :
6263+ if (stmt -> is_local )
6264+ RequireTransactionChain (isTopLevel , "SET LOCAL" );
62636265 (void ) set_config_option (stmt -> name ,
62646266 ExtractSetVariableArgs (stmt ),
62656267 (superuser () ? PGC_SUSET : PGC_USERSET ),
@@ -6269,7 +6271,6 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
62696271 0 );
62706272 break ;
62716273 case VAR_SET_MULTI :
6272-
62736274 /*
62746275 * Special-case SQL syntaxes. The TRANSACTION and SESSION
62756276 * CHARACTERISTICS cases effectively set more than one variable
@@ -6281,6 +6282,8 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
62816282 {
62826283 ListCell * head ;
62836284
6285+ RequireTransactionChain (isTopLevel , "SET TRANSACTION" );
6286+
62846287 foreach (head , stmt -> args )
62856288 {
62866289 DefElem * item = (DefElem * ) lfirst (head );
@@ -6329,6 +6332,8 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
63296332 ereport (ERROR ,
63306333 (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
63316334 errmsg ("SET LOCAL TRANSACTION SNAPSHOT is not implemented" )));
6335+
6336+ RequireTransactionChain (isTopLevel , "SET TRANSACTION" );
63326337 Assert (IsA (con , A_Const ));
63336338 Assert (nodeTag (& con -> val ) == T_String );
63346339 ImportSnapshot (strVal (& con -> val ));
@@ -6338,7 +6343,13 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
63386343 stmt -> name );
63396344 break ;
63406345 case VAR_SET_DEFAULT :
6346+ if (stmt -> is_local )
6347+ RequireTransactionChain (isTopLevel , "SET LOCAL" );
6348+ /* fall through */
63416349 case VAR_RESET :
6350+ if (strcmp (stmt -> name , "transaction_isolation" ) == 0 )
6351+ RequireTransactionChain (isTopLevel , "RESET TRANSACTION" );
6352+
63426353 (void ) set_config_option (stmt -> name ,
63436354 NULL ,
63446355 (superuser () ? PGC_SUSET : PGC_USERSET ),
0 commit comments