diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2022-04-04 15:36:03 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2022-04-04 16:03:47 -0400 |
commit | 4e34747c88a03ede6e9d731727815e37273d4bc9 (patch) | |
tree | c7318a224b908c5dbaba3198324c90ec5429c3a5 /src/backend/nodes/readfuncs.c | |
parent | c42a6fc41dc22b42e5417224440c02893996afb4 (diff) | |
download | postgresql-4e34747c88a03ede6e9d731727815e37273d4bc9.tar.gz postgresql-4e34747c88a03ede6e9d731727815e37273d4bc9.zip |
JSON_TABLE
This feature allows jsonb data to be treated as a table and thus used in
a FROM clause like other tabular data. Data can be selected from the
jsonb using jsonpath expressions, and hoisted out of nested structures
in the jsonb to form multiple rows, more or less like an outer join.
Nikita Glukhov
Reviewers have included (in no particular order) Andres Freund, Alexander
Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers, Zhihong Yu (whose
name I previously misspelled), Himanshu Upadhyaya, Daniel Gustafsson,
Justin Pryzby.
Discussion: https://postgr.es/m/7e2cb85d-24cf-4abb-30a5-1a33715959bd@postgrespro.ru
Diffstat (limited to 'src/backend/nodes/readfuncs.c')
-rw-r--r-- | src/backend/nodes/readfuncs.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index c94b2561f05..19e257684cd 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -571,6 +571,7 @@ _readTableFunc(void) { READ_LOCALS(TableFunc); + READ_ENUM_FIELD(functype, TableFuncType); READ_NODE_FIELD(ns_uris); READ_NODE_FIELD(ns_names); READ_NODE_FIELD(docexpr); @@ -581,7 +582,9 @@ _readTableFunc(void) READ_NODE_FIELD(colcollations); READ_NODE_FIELD(colexprs); READ_NODE_FIELD(coldefexprs); + READ_NODE_FIELD(colvalexprs); READ_BITMAPSET_FIELD(notnulls); + READ_NODE_FIELD(plan); READ_INT_FIELD(ordinalitycol); READ_LOCATION_FIELD(location); @@ -1532,6 +1535,30 @@ _readJsonExpr(void) READ_DONE(); } +static JsonTableParent * +_readJsonTableParent(void) +{ + READ_LOCALS(JsonTableParent); + + READ_NODE_FIELD(path); + READ_NODE_FIELD(child); + READ_INT_FIELD(colMin); + READ_INT_FIELD(colMax); + + READ_DONE(); +} + +static JsonTableSibling * +_readJsonTableSibling(void) +{ + READ_LOCALS(JsonTableSibling); + + READ_NODE_FIELD(larg); + READ_NODE_FIELD(rarg); + + READ_DONE(); +} + /* * _readJsonCoercion */ @@ -3194,6 +3221,10 @@ parseNodeString(void) return_value = _readJsonCoercion(); else if (MATCH("JSONITEMCOERCIONS", 17)) return_value = _readJsonItemCoercions(); + else if (MATCH("JSONTABPNODE", 12)) + return_value = _readJsonTableParent(); + else if (MATCH("JSONTABSNODE", 12)) + return_value = _readJsonTableSibling(); else { elog(ERROR, "badly formatted node string \"%.32s\"...", token); |