aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/nodes/queryjumblefuncs.c19
-rw-r--r--src/backend/parser/gram.y24
-rw-r--r--src/include/nodes/parsenodes.h21
3 files changed, 61 insertions, 3 deletions
diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index 129fb447099..5e43fd92294 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -57,6 +57,7 @@ static void RecordConstLocation(JumbleState *jstate, int location);
static void _jumbleNode(JumbleState *jstate, Node *node);
static void _jumbleA_Const(JumbleState *jstate, Node *node);
static void _jumbleList(JumbleState *jstate, Node *node);
+static void _jumbleVariableSetStmt(JumbleState *jstate, Node *node);
/*
* Given a possibly multi-statement source string, confine our attention to the
@@ -352,3 +353,21 @@ _jumbleA_Const(JumbleState *jstate, Node *node)
}
}
}
+
+static void
+_jumbleVariableSetStmt(JumbleState *jstate, Node *node)
+{
+ VariableSetStmt *expr = (VariableSetStmt *) node;
+
+ JUMBLE_FIELD(kind);
+ JUMBLE_STRING(name);
+
+ /*
+ * Account for the list of arguments in query jumbling only if told by the
+ * parser.
+ */
+ if (expr->jumble_args)
+ JUMBLE_NODE(args);
+ JUMBLE_FIELD(is_local);
+ JUMBLE_LOCATION(location);
+}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index b1d4642c59b..4aa8646af7b 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -1647,6 +1647,8 @@ set_rest:
n->kind = VAR_SET_MULTI;
n->name = "TRANSACTION";
n->args = $2;
+ n->jumble_args = true;
+ n->location = -1;
$$ = n;
}
| SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
@@ -1656,6 +1658,8 @@ set_rest:
n->kind = VAR_SET_MULTI;
n->name = "SESSION CHARACTERISTICS";
n->args = $5;
+ n->jumble_args = true;
+ n->location = -1;
$$ = n;
}
| set_rest_more
@@ -1669,6 +1673,7 @@ generic_set:
n->kind = VAR_SET_VALUE;
n->name = $1;
n->args = $3;
+ n->location = @3;
$$ = n;
}
| var_name '=' var_list
@@ -1678,6 +1683,7 @@ generic_set:
n->kind = VAR_SET_VALUE;
n->name = $1;
n->args = $3;
+ n->location = @3;
$$ = n;
}
| var_name TO DEFAULT
@@ -1686,6 +1692,7 @@ generic_set:
n->kind = VAR_SET_DEFAULT;
n->name = $1;
+ n->location = -1;
$$ = n;
}
| var_name '=' DEFAULT
@@ -1694,6 +1701,7 @@ generic_set:
n->kind = VAR_SET_DEFAULT;
n->name = $1;
+ n->location = -1;
$$ = n;
}
;
@@ -1706,6 +1714,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_CURRENT;
n->name = $1;
+ n->location = -1;
$$ = n;
}
/* Special syntaxes mandated by SQL standard: */
@@ -1715,6 +1724,8 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "timezone";
+ n->location = -1;
+ n->jumble_args = true;
if ($3 != NULL)
n->args = list_make1($3);
else
@@ -1736,6 +1747,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "search_path";
n->args = list_make1(makeStringConst($2, @2));
+ n->location = @2;
$$ = n;
}
| NAMES opt_encoding
@@ -1744,6 +1756,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "client_encoding";
+ n->location = @2;
if ($2 != NULL)
n->args = list_make1(makeStringConst($2, @2));
else
@@ -1757,6 +1770,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "role";
n->args = list_make1(makeStringConst($2, @2));
+ n->location = @2;
$$ = n;
}
| SESSION AUTHORIZATION NonReservedWord_or_Sconst
@@ -1766,6 +1780,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "session_authorization";
n->args = list_make1(makeStringConst($3, @3));
+ n->location = @3;
$$ = n;
}
| SESSION AUTHORIZATION DEFAULT
@@ -1774,6 +1789,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_DEFAULT;
n->name = "session_authorization";
+ n->location = -1;
$$ = n;
}
| XML_P OPTION document_or_content
@@ -1783,6 +1799,8 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->name = "xmloption";
n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", @3));
+ n->jumble_args = true;
+ n->location = -1;
$$ = n;
}
/* Special syntaxes invented by PostgreSQL: */
@@ -1793,6 +1811,7 @@ set_rest_more: /* Generic SET syntaxes: */
n->kind = VAR_SET_MULTI;
n->name = "TRANSACTION SNAPSHOT";
n->args = list_make1(makeStringConst($3, @3));
+ n->location = @3;
$$ = n;
}
;
@@ -1900,6 +1919,7 @@ reset_rest:
n->kind = VAR_RESET;
n->name = "timezone";
+ n->location = -1;
$$ = n;
}
| TRANSACTION ISOLATION LEVEL
@@ -1908,6 +1928,7 @@ reset_rest:
n->kind = VAR_RESET;
n->name = "transaction_isolation";
+ n->location = -1;
$$ = n;
}
| SESSION AUTHORIZATION
@@ -1916,6 +1937,7 @@ reset_rest:
n->kind = VAR_RESET;
n->name = "session_authorization";
+ n->location = -1;
$$ = n;
}
;
@@ -1927,6 +1949,7 @@ generic_reset:
n->kind = VAR_RESET;
n->name = $1;
+ n->location = -1;
$$ = n;
}
| ALL
@@ -1934,6 +1957,7 @@ generic_reset:
VariableSetStmt *n = makeNode(VariableSetStmt);
n->kind = VAR_RESET_ALL;
+ n->location = -1;
$$ = n;
}
;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index e62ce1b7536..1c314cd9074 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2616,11 +2616,26 @@ typedef enum VariableSetKind
typedef struct VariableSetStmt
{
+ pg_node_attr(custom_query_jumble)
+
NodeTag type;
VariableSetKind kind;
- char *name; /* variable to be set */
- List *args; /* List of A_Const nodes */
- bool is_local; /* SET LOCAL? */
+ /* variable to be set */
+ char *name;
+ /* List of A_Const nodes */
+ List *args;
+
+ /*
+ * True if arguments should be accounted for in query jumbling. We use a
+ * separate flag rather than query_jumble_ignore on "args" as several
+ * grammar flavors of SET rely on a list of values that are parsed
+ * directly from the grammar's keywords.
+ */
+ bool jumble_args;
+ /* SET LOCAL? */
+ bool is_local;
+ /* token location, or -1 if unknown */
+ ParseLoc location pg_node_attr(query_jumble_location);
} VariableSetStmt;
/* ----------------------