@@ -6252,14 +6252,16 @@ flatten_set_variable_args(const char *name, List *args)
6252
6252
* SET command
6253
6253
*/
6254
6254
void
6255
- ExecSetVariableStmt (VariableSetStmt * stmt )
6255
+ ExecSetVariableStmt (VariableSetStmt * stmt , bool isTopLevel )
6256
6256
{
6257
6257
GucAction action = stmt -> is_local ?GUC_ACTION_LOCAL :GUC_ACTION_SET ;
6258
6258
6259
6259
switch (stmt -> kind )
6260
6260
{
6261
6261
case VAR_SET_VALUE :
6262
6262
case VAR_SET_CURRENT :
6263
+ if (stmt -> is_local )
6264
+ RequireTransactionChain (isTopLevel ,"SET LOCAL" );
6263
6265
(void )set_config_option (stmt -> name ,
6264
6266
ExtractSetVariableArgs (stmt ),
6265
6267
(superuser () ?PGC_SUSET :PGC_USERSET ),
@@ -6269,7 +6271,6 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
6269
6271
0 );
6270
6272
break ;
6271
6273
case VAR_SET_MULTI :
6272
-
6273
6274
/*
6274
6275
* Special-case SQL syntaxes. The TRANSACTION and SESSION
6275
6276
* CHARACTERISTICS cases effectively set more than one variable
@@ -6281,6 +6282,8 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
6281
6282
{
6282
6283
ListCell * head ;
6283
6284
6285
+ RequireTransactionChain (isTopLevel ,"SET TRANSACTION" );
6286
+
6284
6287
foreach (head ,stmt -> args )
6285
6288
{
6286
6289
DefElem * item = (DefElem * )lfirst (head );
@@ -6329,6 +6332,8 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
6329
6332
ereport (ERROR ,
6330
6333
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
6331
6334
errmsg ("SET LOCAL TRANSACTION SNAPSHOT is not implemented" )));
6335
+
6336
+ RequireTransactionChain (isTopLevel ,"SET TRANSACTION" );
6332
6337
Assert (IsA (con ,A_Const ));
6333
6338
Assert (nodeTag (& con -> val )== T_String );
6334
6339
ImportSnapshot (strVal (& con -> val ));
@@ -6338,7 +6343,13 @@ ExecSetVariableStmt(VariableSetStmt *stmt)
6338
6343
stmt -> name );
6339
6344
break ;
6340
6345
case VAR_SET_DEFAULT :
6346
+ if (stmt -> is_local )
6347
+ RequireTransactionChain (isTopLevel ,"SET LOCAL" );
6348
+ /* fall through */
6341
6349
case VAR_RESET :
6350
+ if (strcmp (stmt -> name ,"transaction_isolation" )== 0 )
6351
+ RequireTransactionChain (isTopLevel ,"RESET TRANSACTION" );
6352
+
6342
6353
(void )set_config_option (stmt -> name ,
6343
6354
NULL ,
6344
6355
(superuser () ?PGC_SUSET :PGC_USERSET ),