51 Node *contextItemExpr,
56 int colMin,
int colMax,
94 errmsg(
"invalid %s behavior",
"ON ERROR"),
95 errdetail(
"Only EMPTY [ ARRAY ] or ERROR is allowed in the top-level ON ERROR clause."),
99 if (rootPathSpec->
name == NULL)
153 tf->ordinalitycol = -1;
165 tf, jt->
alias, is_lateral,
true);
178 foreach(lc1, columns)
188 errcode(ERRCODE_DUPLICATE_ALIAS),
189 errmsg(
"duplicate JSON_TABLE column or path name: %s",
202 errcode(ERRCODE_DUPLICATE_ALIAS),
203 errmsg(
"duplicate JSON_TABLE column or path name: %s",
222 if (strcmp(
name, (
const char *)
lfirst(lc)) == 0)
234 char *
name = namebuf;
236 snprintf(namebuf,
sizeof(namebuf),
"json_table_path_%d",
259 bool ordinality_found =
false;
270 foreach(col, columns)
281 tf->colnames =
lappend(tf->colnames,
292 if (ordinality_found)
294 (
errcode(ERRCODE_SYNTAX_ERROR),
295 errmsg(
"only one FOR ORDINALITY column is allowed"),
297 ordinality_found =
true;
325 param->
typeId = contextItemTypid;
350 tf->coltypmods =
lappend_int(tf->coltypmods, typmod);
351 tf->colcollations =
lappend_oid(tf->colcollations, typcoll);
352 tf->colvalexprs =
lappend(tf->colvalexprs, colexpr);
359 colMax = colMin = -1;
381 return typid == JSONOID ||
383 typid == RECORDOID ||
385 typtype == TYPTYPE_COMPOSITE ||
387 (typtype == TYPTYPE_DOMAIN &&
434 jfexpr->pathspec = pathspec;
435 jfexpr->passing = passingArgs;
437 jfexpr->output->typeName = jtc->typeName;
439 jfexpr->output->returning->format = jtc->format;
440 jfexpr->on_empty = jtc->on_empty;
441 jfexpr->on_error = jtc->on_error;
442 jfexpr->quotes = jtc->quotes;
443 jfexpr->wrapper = jtc->wrapper;
444 jfexpr->location = jtc->location;
500 int colMin,
int colMax,
514 scan->
plan.type = T_JsonTablePathScan;
518 scan->
child = childplan;
538 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)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Node * makeStringConst(char *str, int location)
JsonFormat * makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
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
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)
ParseNamespaceItem * transformJsonTable(ParseState *pstate, JsonTable *jt)
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)