+ExecSetVariableStmt(VariableSetStmt *stmt)
+{
+ GucAction action = stmt->is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET;
+
+ switch (stmt->kind)
+ {
+ case VAR_SET_VALUE:
+ case VAR_SET_CURRENT:
+ set_config_option(stmt->name,
+ ExtractSetVariableArgs(stmt),
+ (superuser() ? PGC_SUSET : PGC_USERSET),
+ PGC_S_SESSION,
+ action,
+ true);
+ break;
+ case VAR_SET_MULTI:
+
+ /*
+ * Special case for special SQL syntax that effectively sets more
+ * than one variable per statement.
+ */
+ if (strcmp(stmt->name, "TRANSACTION") == 0)
+ {
+ ListCell *head;
+
+ foreach(head, stmt->args)
+ {
+ DefElem *item = (DefElem *) lfirst(head);
+
+ if (strcmp(item->defname, "transaction_isolation") == 0)
+ SetPGVariable("transaction_isolation",
+ list_make1(item->arg), stmt->is_local);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
+ SetPGVariable("transaction_read_only",
+ list_make1(item->arg), stmt->is_local);
+ else
+ elog(ERROR, "unexpected SET TRANSACTION element: %s",
+ item->defname);
+ }
+ }
+ else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
+ {
+ ListCell *head;
+
+ foreach(head, stmt->args)
+ {
+ DefElem *item = (DefElem *) lfirst(head);
+
+ if (strcmp(item->defname, "transaction_isolation") == 0)
+ SetPGVariable("default_transaction_isolation",
+ list_make1(item->arg), stmt->is_local);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
+ SetPGVariable("default_transaction_read_only",
+ list_make1(item->arg), stmt->is_local);
+ else
+ elog(ERROR, "unexpected SET SESSION element: %s",
+ item->defname);
+ }
+ }
+ else
+ elog(ERROR, "unexpected SET MULTI element: %s",
+ stmt->name);
+ break;
+ case VAR_SET_DEFAULT:
+ case VAR_RESET:
+ set_config_option(stmt->name,
+ NULL,
+ (superuser() ? PGC_SUSET : PGC_USERSET),
+ PGC_S_SESSION,
+ action,
+ true);
+ break;
+ case VAR_RESET_ALL:
+ ResetAllOptions();
+ break;
+ }
+}
+
+/*
+ * Get the value to assign for a VariableSetStmt, or NULL if it's RESET.
+ * The result is palloc'd.
+ *
+ * This is exported for use by actions such as ALTER ROLE SET.
+ */
+char *
+ExtractSetVariableArgs(VariableSetStmt *stmt)
+{
+ switch (stmt->kind)
+ {
+ case VAR_SET_VALUE:
+ return flatten_set_variable_args(stmt->name, stmt->args);
+ case VAR_SET_CURRENT:
+ return GetConfigOptionByName(stmt->name, NULL);
+ default:
+ return NULL;
+ }
+}
+
+/*
+ * SetPGVariable - SET command exported as an easily-C-callable function.
+ *
+ * This provides access to SET TO value, as well as SET TO DEFAULT (expressed
+ * by passing args == NIL), but not SET FROM CURRENT functionality.
+ */
+void