From 1ee264e02b073bc324156d85ac2985d873e5a55b Mon Sep 17 00:00:00 2001 From: Sami Imseih Date: Sat, 29 Aug 2026 19:39:05 +0000 Subject: [PATCH v2 1/4] Track DefElem argument locations to allow query normalization This records DefElem argument locations so utility statements that use DefElem for options can normalize the supplied argument values. DefElem now carries an arg_location field, initialized to -1 when unset, and gram.y is taught to record the location of the element value. Future patches will use this in custom query jumbling for specific utility statements. --- src/backend/nodes/makefuncs.c | 2 ++ src/backend/parser/gram.y | 1 + src/include/nodes/parsenodes.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index cdc02b274ff..628f4bb0a48 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -643,6 +643,7 @@ makeDefElem(char *name, Node *arg, int location) res->arg = arg; res->defaction = DEFELEM_UNSPEC; res->location = location; + res->arg_location = -1; return res; } @@ -662,6 +663,7 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg, res->arg = arg; res->defaction = defaction; res->location = location; + res->arg_location = -1; return res; } diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 2df39a48fc6..65b2b4384f8 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -1225,6 +1225,7 @@ utility_option_elem: utility_option_name utility_option_arg { $$ = makeDefElem($1, $2, @1); + $$->arg_location = @2; } ; diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index d3835af8f9e..afe09b1f7a9 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -864,6 +864,8 @@ typedef struct DefElem * TypeName */ DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */ ParseLoc location; /* token location, or -1 if unknown */ + /* argument location, or -1 if unknown */ + ParseLoc arg_location; } DefElem; /* -- 2.47.3