diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2022-03-03 13:00:49 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2022-03-27 17:03:33 -0400 |
commit | f79b803dcc98d707450e158db3638dc67ff8380b (patch) | |
tree | a9c33df51b967eeb99b86af92008f7f0bc1e3d6e /src/backend/nodes/readfuncs.c | |
parent | b64c3bd62ea7064a1a36fbd921e8955fa76faa3e (diff) | |
download | postgresql-f79b803dcc98d707450e158db3638dc67ff8380b.tar.gz postgresql-f79b803dcc98d707450e158db3638dc67ff8380b.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,
Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby.
Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Diffstat (limited to 'src/backend/nodes/readfuncs.c')
-rw-r--r-- | src/backend/nodes/readfuncs.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 3f68f7c18d9..6f398cdc15b 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -1390,6 +1390,51 @@ _readOnConflictExpr(void) } /* + * _readJsonFormat + */ +static JsonFormat * +_readJsonFormat(void) +{ + READ_LOCALS(JsonFormat); + + READ_ENUM_FIELD(format_type, JsonFormatType); + READ_ENUM_FIELD(encoding, JsonEncoding); + READ_LOCATION_FIELD(location); + + READ_DONE(); +} + +/* + * _readJsonReturning + */ +static JsonReturning * +_readJsonReturning(void) +{ + READ_LOCALS(JsonReturning); + + READ_NODE_FIELD(format); + READ_OID_FIELD(typid); + READ_INT_FIELD(typmod); + + READ_DONE(); +} + +/* + * _readJsonValueExpr + */ +static JsonValueExpr * +_readJsonValueExpr(void) +{ + READ_LOCALS(JsonValueExpr); + + READ_NODE_FIELD(raw_expr); + READ_NODE_FIELD(formatted_expr); + READ_NODE_FIELD(format); + + READ_DONE(); +} + +/* * Stuff from pathnodes.h. * * Mostly we don't need to read planner nodes back in again, but some @@ -2974,6 +3019,12 @@ parseNodeString(void) return_value = _readPartitionBoundSpec(); else if (MATCH("PARTITIONRANGEDATUM", 19)) return_value = _readPartitionRangeDatum(); + else if (MATCH("JSONFORMAT", 10)) + return_value = _readJsonFormat(); + else if (MATCH("JSONRETURNING", 13)) + return_value = _readJsonReturning(); + else if (MATCH("JSONVALUEEXPR", 13)) + return_value = _readJsonValueExpr(); else { elog(ERROR, "badly formatted node string \"%.32s\"...", token); |