mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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
This commit is contained in:
@ -1394,6 +1394,7 @@ _copyTableFunc(const TableFunc *from)
|
||||
{
|
||||
TableFunc *newnode = makeNode(TableFunc);
|
||||
|
||||
COPY_SCALAR_FIELD(functype);
|
||||
COPY_NODE_FIELD(ns_uris);
|
||||
COPY_NODE_FIELD(ns_names);
|
||||
COPY_NODE_FIELD(docexpr);
|
||||
@ -1404,7 +1405,9 @@ _copyTableFunc(const TableFunc *from)
|
||||
COPY_NODE_FIELD(colcollations);
|
||||
COPY_NODE_FIELD(colexprs);
|
||||
COPY_NODE_FIELD(coldefexprs);
|
||||
COPY_NODE_FIELD(colvalexprs);
|
||||
COPY_BITMAPSET_FIELD(notnulls);
|
||||
COPY_NODE_FIELD(plan);
|
||||
COPY_SCALAR_FIELD(ordinalitycol);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
@ -2683,6 +2686,76 @@ _copyJsonArgument(const JsonArgument *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyJsonTable
|
||||
*/
|
||||
static JsonTable *
|
||||
_copyJsonTable(const JsonTable *from)
|
||||
{
|
||||
JsonTable *newnode = makeNode(JsonTable);
|
||||
|
||||
COPY_NODE_FIELD(common);
|
||||
COPY_NODE_FIELD(columns);
|
||||
COPY_NODE_FIELD(on_error);
|
||||
COPY_NODE_FIELD(alias);
|
||||
COPY_SCALAR_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyJsonTableColumn
|
||||
*/
|
||||
static JsonTableColumn *
|
||||
_copyJsonTableColumn(const JsonTableColumn *from)
|
||||
{
|
||||
JsonTableColumn *newnode = makeNode(JsonTableColumn);
|
||||
|
||||
COPY_SCALAR_FIELD(coltype);
|
||||
COPY_STRING_FIELD(name);
|
||||
COPY_NODE_FIELD(typeName);
|
||||
COPY_STRING_FIELD(pathspec);
|
||||
COPY_SCALAR_FIELD(format);
|
||||
COPY_SCALAR_FIELD(wrapper);
|
||||
COPY_SCALAR_FIELD(omit_quotes);
|
||||
COPY_NODE_FIELD(columns);
|
||||
COPY_NODE_FIELD(on_empty);
|
||||
COPY_NODE_FIELD(on_error);
|
||||
COPY_SCALAR_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyJsonTableParent
|
||||
*/
|
||||
static JsonTableParent *
|
||||
_copyJsonTableParent(const JsonTableParent *from)
|
||||
{
|
||||
JsonTableParent *newnode = makeNode(JsonTableParent);
|
||||
|
||||
COPY_NODE_FIELD(path);
|
||||
COPY_NODE_FIELD(child);
|
||||
COPY_SCALAR_FIELD(colMin);
|
||||
COPY_SCALAR_FIELD(colMax);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyJsonTableSibling
|
||||
*/
|
||||
static JsonTableSibling *
|
||||
_copyJsonTableSibling(const JsonTableSibling *from)
|
||||
{
|
||||
JsonTableSibling *newnode = makeNode(JsonTableSibling);
|
||||
|
||||
COPY_NODE_FIELD(larg);
|
||||
COPY_NODE_FIELD(rarg);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/* ****************************************************************
|
||||
* pathnodes.h copy functions
|
||||
*
|
||||
@ -5850,6 +5923,18 @@ copyObjectImpl(const void *from)
|
||||
case T_JsonItemCoercions:
|
||||
retval = _copyJsonItemCoercions(from);
|
||||
break;
|
||||
case T_JsonTable:
|
||||
retval = _copyJsonTable(from);
|
||||
break;
|
||||
case T_JsonTableColumn:
|
||||
retval = _copyJsonTableColumn(from);
|
||||
break;
|
||||
case T_JsonTableParent:
|
||||
retval = _copyJsonTableParent(from);
|
||||
break;
|
||||
case T_JsonTableSibling:
|
||||
retval = _copyJsonTableSibling(from);
|
||||
break;
|
||||
|
||||
/*
|
||||
* RELATION NODES
|
||||
|
Reference in New Issue
Block a user