diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2022-04-05 14:09:04 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2022-04-05 14:17:08 -0400 |
commit | fadb48b00e02ccfd152baa80942de30205ab3c4f (patch) | |
tree | 67664217c57aff2d9006738fd538cba887b8beb7 /src/backend/nodes/copyfuncs.c | |
parent | e83ebfe6d767dafcefe00bc5f11392a3d6976c1b (diff) |
PLAN clauses for JSON_TABLE
These clauses allow the user to specify how data from nested paths are
joined, allowing considerable freedom in shaping the tabular output of
JSON_TABLE.
PLAN DEFAULT allows the user to specify the global strategies when
dealing with sibling or child nested paths. The is often sufficient to
achieve the necessary goal, and is considerably simpler than the full
PLAN clause, which allows the user to specify the strategy to be used
for each named nested path.
Nikita Glukhov
Reviewers have included (in no particular order) Andres Freund, Alexander
Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers, Zhihong Yu,
Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby.
Discussion: https://postgr.es/m/7e2cb85d-24cf-4abb-30a5-1a33715959bd@postgrespro.ru
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 1a74122f139..d5760b10067 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -2696,6 +2696,7 @@ _copyJsonTable(const JsonTable *from) COPY_NODE_FIELD(common); COPY_NODE_FIELD(columns); + COPY_NODE_FIELD(plan); COPY_NODE_FIELD(on_error); COPY_NODE_FIELD(alias); COPY_SCALAR_FIELD(location); @@ -2715,6 +2716,7 @@ _copyJsonTableColumn(const JsonTableColumn *from) COPY_STRING_FIELD(name); COPY_NODE_FIELD(typeName); COPY_STRING_FIELD(pathspec); + COPY_STRING_FIELD(pathname); COPY_SCALAR_FIELD(format); COPY_SCALAR_FIELD(wrapper); COPY_SCALAR_FIELD(omit_quotes); @@ -2727,6 +2729,24 @@ _copyJsonTableColumn(const JsonTableColumn *from) } /* + * _copyJsonTablePlan + */ +static JsonTablePlan * +_copyJsonTablePlan(const JsonTablePlan *from) +{ + JsonTablePlan *newnode = makeNode(JsonTablePlan); + + COPY_SCALAR_FIELD(plan_type); + COPY_SCALAR_FIELD(join_type); + COPY_STRING_FIELD(pathname); + COPY_NODE_FIELD(plan1); + COPY_NODE_FIELD(plan2); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +/* * _copyJsonTableParent */ static JsonTableParent * @@ -2735,7 +2755,9 @@ _copyJsonTableParent(const JsonTableParent *from) JsonTableParent *newnode = makeNode(JsonTableParent); COPY_NODE_FIELD(path); + COPY_STRING_FIELD(name); COPY_NODE_FIELD(child); + COPY_SCALAR_FIELD(outerJoin); COPY_SCALAR_FIELD(colMin); COPY_SCALAR_FIELD(colMax); @@ -2752,6 +2774,7 @@ _copyJsonTableSibling(const JsonTableSibling *from) COPY_NODE_FIELD(larg); COPY_NODE_FIELD(rarg); + COPY_SCALAR_FIELD(cross); return newnode; } @@ -5929,6 +5952,9 @@ copyObjectImpl(const void *from) case T_JsonTableColumn: retval = _copyJsonTableColumn(from); break; + case T_JsonTablePlan: + retval = _copyJsonTablePlan(from); + break; case T_JsonTableParent: retval = _copyJsonTableParent(from); break; |