diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2022-03-03 13:00:49 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2022-03-22 17:32:54 -0400 |
commit | 865fe4d5df560a6f5353da652018ff876978ad2d (patch) | |
tree | 47d3609a7b5fbf1fb60a1559a1af40b0df961de6 /src/backend/nodes/copyfuncs.c | |
parent | a3b071bbe050252b35c589a7f1a2ee2f7ee3e9d4 (diff) | |
download | postgresql-865fe4d5df560a6f5353da652018ff876978ad2d.tar.gz postgresql-865fe4d5df560a6f5353da652018ff876978ad2d.zip |
Common SQL/JSON clauses
This introduces some of the building blocks used by the SQL/JSON
constructor and query functions. Specifically, it provides node
executor and grammar support for the FORMAT JSON [ENCODING foo]
clause, and values decorated with it, and for the RETURNING clause.
The following SQL/JSON patches will leverage these.
Nikita Glukhov (who probably deserves an award for perseverance).
Reviewers have included (in no particular order) Andres Freund, Alexander
Korotkov, Pavel Stehule, Andrew Alsup. Erik Rijkers, Zihong Yu and
Himanshu Upadhyaya.
Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index d4f8455a2bd..55c36b46a88 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -2298,6 +2298,52 @@ _copyOnConflictExpr(const OnConflictExpr *from) return newnode; } + +/* + * _copyJsonFormat + */ +static JsonFormat * +_copyJsonFormat(const JsonFormat *from) +{ + JsonFormat *newnode = makeNode(JsonFormat); + + COPY_SCALAR_FIELD(format_type); + COPY_SCALAR_FIELD(encoding); + COPY_LOCATION_FIELD(location); + + return newnode; +} + +/* + * _copyJsonReturning + */ +static JsonReturning * +_copyJsonReturning(const JsonReturning *from) +{ + JsonReturning *newnode = makeNode(JsonReturning); + + COPY_NODE_FIELD(format); + COPY_SCALAR_FIELD(typid); + COPY_SCALAR_FIELD(typmod); + + return newnode; +} + +/* + * _copyJsonValueExpr + */ +static JsonValueExpr * +_copyJsonValueExpr(const JsonValueExpr *from) +{ + JsonValueExpr *newnode = makeNode(JsonValueExpr); + + COPY_NODE_FIELD(raw_expr); + COPY_NODE_FIELD(formatted_expr); + COPY_NODE_FIELD(format); + + return newnode; +} + /* **************************************************************** * pathnodes.h copy functions * @@ -5350,6 +5396,15 @@ copyObjectImpl(const void *from) case T_OnConflictExpr: retval = _copyOnConflictExpr(from); break; + case T_JsonFormat: + retval = _copyJsonFormat(from); + break; + case T_JsonReturning: + retval = _copyJsonReturning(from); + break; + case T_JsonValueExpr: + retval = _copyJsonValueExpr(from); + break; /* * RELATION NODES |