27#include "utils/fmgrprotos.h"
49 Node *contextItemExpr,
54 int colMin,
int colMax,
92 errmsg(
"invalid %s behavior",
"ON ERROR"),
93 errdetail(
"Only EMPTY [ ARRAY ] or ERROR is allowed in the top-level ON ERROR clause."),
97 if (rootPathSpec->
name == NULL)
151 tf->ordinalitycol = -1;
163 tf, jt->
alias, is_lateral,
true);
176 foreach(lc1, columns)
186 errcode(ERRCODE_DUPLICATE_ALIAS),
187 errmsg(
"duplicate JSON_TABLE column or path name: %s",
200 errcode(ERRCODE_DUPLICATE_ALIAS),
201 errmsg(
"duplicate JSON_TABLE column or path name: %s",
220 if (strcmp(
name, (
const char *)
lfirst(lc)) == 0)
232 char *
name = namebuf;
234 snprintf(namebuf,
sizeof(namebuf),
"json_table_path_%d",
257 bool ordinality_found =
false;
268 foreach(col, columns)
279 tf->colnames =
lappend(tf->colnames,
290 if (ordinality_found)
292 (
errcode(ERRCODE_SYNTAX_ERROR),
293 errmsg(
"only one FOR ORDINALITY column is allowed"),
295 ordinality_found =
true;
323 param->
typeId = contextItemTypid;
348 tf->coltypmods =
lappend_int(tf->coltypmods, typmod);
349 tf->colcollations =
lappend_oid(tf->colcollations, typcoll);
350 tf->colvalexprs =
lappend(tf->colvalexprs, colexpr);
357 colMax = colMin = -1;
379 return typid == JSONOID ||
381 typid == RECORDOID ||
383 typtype == TYPTYPE_COMPOSITE ||
385 (typtype == TYPTYPE_DOMAIN &&
432 jfexpr->pathspec = pathspec;
433 jfexpr->passing = passingArgs;
435 jfexpr->output->typeName = jtc->typeName;
437 jfexpr->output->returning->format = jtc->format;
438 jfexpr->on_empty = jtc->on_empty;
439 jfexpr->on_error = jtc->on_error;
440 jfexpr->quotes = jtc->quotes;
441 jfexpr->wrapper = jtc->wrapper;
442 jfexpr->location = jtc->location;
498 int colMin,
int colMax,
512 scan->
plan.type = T_JsonTablePathScan;
516 scan->
child = childplan;
536 join->
plan.type = T_JsonTableSiblingJoin;
#define Assert(condition)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define DirectFunctionCall1(func, arg1)
void escape_json(StringInfo buf, const char *str)
Datum jsonpath_in(PG_FUNCTION_ARGS)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
char get_typtype(Oid typid)
Oid getBaseType(Oid typid)
#define type_is_array(typid)
JsonTablePath * makeJsonTablePath(Const *pathvalue, char *pathname)
Node * makeStringConst(char *str, int location)
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
JsonFormat * makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
char * pstrdup(const char *in)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
static JsonTablePlan * makeJsonTableSiblingJoin(JsonTablePlan *lplan, JsonTablePlan *rplan)
static char * generateJsonTablePathName(JsonTableParseContext *cxt)
struct JsonTableParseContext JsonTableParseContext
ParseNamespaceItem * transformJsonTable(ParseState *pstate, JsonTable *jt)
static bool LookupPathOrColumnName(JsonTableParseContext *cxt, char *name)
static JsonFuncExpr * transformJsonTableColumn(JsonTableColumn *jtc, Node *contextItemExpr, List *passingArgs)
static JsonTablePlan * makeJsonTablePathScan(JsonTablePathSpec *pathspec, bool errorOnError, int colMin, int colMax, JsonTablePlan *childplan)
static JsonTablePlan * transformJsonTableColumns(JsonTableParseContext *cxt, List *columns, List *passingArgs, JsonTablePathSpec *pathspec)
static bool isCompositeType(Oid typid)
static void CheckDuplicateColumnOrPathNames(JsonTableParseContext *cxt, List *columns)
static JsonTablePlan * transformJsonTableNestedColumns(JsonTableParseContext *cxt, List *passingArgs, List *columns)
int parser_errposition(ParseState *pstate, int location)
@ EXPR_KIND_FROM_FUNCTION
ParseNamespaceItem * addRangeTableEntryForTableFunc(ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl)
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
static int list_length(const List *l)
static Datum CStringGetDatum(const char *X)
@ JSON_BEHAVIOR_EMPTY_ARRAY
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
JsonValueExpr * context_item
JsonTableColumnType coltype
JsonTablePathSpec * pathspec
JsonTablePathSpec * pathspec
JsonValueExpr * context_item
String * makeString(char *str)
bool contain_vars_of_level(Node *node, int levelsup)