mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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
This commit is contained in:
@ -1751,6 +1751,36 @@ _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
|
||||
WRITE_NODE_FIELD(exclRelTlist);
|
||||
}
|
||||
|
||||
static void
|
||||
_outJsonFormat(StringInfo str, const JsonFormat *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("JSONFORMAT");
|
||||
|
||||
WRITE_ENUM_FIELD(format_type, JsonFormatType);
|
||||
WRITE_ENUM_FIELD(encoding, JsonEncoding);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
_outJsonReturning(StringInfo str, const JsonReturning *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("JSONRETURNING");
|
||||
|
||||
WRITE_NODE_FIELD(format);
|
||||
WRITE_OID_FIELD(typid);
|
||||
WRITE_INT_FIELD(typmod);
|
||||
}
|
||||
|
||||
static void
|
||||
_outJsonValueExpr(StringInfo str, const JsonValueExpr *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("JSONVALUEEXPR");
|
||||
|
||||
WRITE_NODE_FIELD(raw_expr);
|
||||
WRITE_NODE_FIELD(formatted_expr);
|
||||
WRITE_NODE_FIELD(format);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Stuff from pathnodes.h.
|
||||
@ -4537,6 +4567,15 @@ outNode(StringInfo str, const void *obj)
|
||||
case T_PartitionRangeDatum:
|
||||
_outPartitionRangeDatum(str, obj);
|
||||
break;
|
||||
case T_JsonFormat:
|
||||
_outJsonFormat(str, obj);
|
||||
break;
|
||||
case T_JsonReturning:
|
||||
_outJsonReturning(str, obj);
|
||||
break;
|
||||
case T_JsonValueExpr:
|
||||
_outJsonValueExpr(str, obj);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
|
Reference in New Issue
Block a user