73 int sublevels_up,
int location);
78 List *largs,
List *rargs,
int location);
286 (
errcode(ERRCODE_SYNTAX_ERROR),
287 errmsg(
"DEFAULT is not allowed in this context"),
305 result = (
Node *) expr;
336 ((
Var *) relref)->varno,
337 ((
Var *) relref)->varlevelsup);
339 (
errcode(ERRCODE_UNDEFINED_COLUMN),
340 errmsg(
"column %s.%s does not exist",
351 (
errcode(ERRCODE_UNDEFINED_COLUMN),
352 errmsg(
"column \"%s\" not found in data type %s",
355 else if (relTypeId == RECORDOID)
357 (
errcode(ERRCODE_UNDEFINED_COLUMN),
358 errmsg(
"could not identify column \"%s\" in record data type",
363 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
364 errmsg(
"column notation .%s applied to type %s, " 365 "which is not a composite type",
390 subscripts =
lappend(subscripts, n);
394 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
395 errmsg(
"row expansion via \"*\" is not supported here"),
421 if (newresult == NULL)
447 char *nspname = NULL;
449 char *colname = NULL;
458 } crerr = CRERR_NO_COLUMN;
515 err =
_(
"cannot use column reference in DEFAULT expression");
518 err =
_(
"cannot use column reference in partition bound expression");
531 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
617 crerr = CRERR_NO_RTE;
667 crerr = CRERR_NO_RTE;
720 crerr = CRERR_WRONG_DB;
730 crerr = CRERR_NO_RTE;
764 crerr = CRERR_TOO_MANY;
784 else if (hookresult != NULL)
786 (
errcode(ERRCODE_AMBIGUOUS_COLUMN),
787 errmsg(
"column reference \"%s\" is ambiguous",
799 case CRERR_NO_COLUMN:
808 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
809 errmsg(
"cross-database references are not implemented: %s",
815 (
errcode(ERRCODE_SYNTAX_ERROR),
816 errmsg(
"improper qualified name (too many dotted names): %s",
842 (
errcode(ERRCODE_UNDEFINED_PARAMETER),
1042 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1043 errmsg(
"NULLIF requires = operator to yield boolean"),
1047 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1049 errmsg(
"%s must not return a set",
"NULLIF"),
1062 return (
Node *) result;
1068 Node *result = NULL;
1096 rexprs = rvars = rnonvars =
NIL;
1101 rexprs =
lappend(rexprs, rexpr);
1103 rvars =
lappend(rvars, rexpr);
1105 rnonvars =
lappend(rnonvars, rexpr);
1134 if (
OidIsValid(scalar_type) && scalar_type != RECORDOID)
1148 foreach(l, rnonvars)
1155 aexprs =
lappend(aexprs, rexpr);
1336 foreach(lc, a->
args)
1357 foreach(args, fn->
args)
1405 if (maref->
colno == 1)
1428 (
errcode(ERRCODE_SYNTAX_ERROR),
1429 errmsg(
"number of columns does not match number of values"),
1460 (
errcode(ERRCODE_SYNTAX_ERROR),
1461 errmsg(
"number of columns does not match number of values"),
1474 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1475 errmsg(
"source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"),
1512 return (
Node *) param;
1537 elog(
ERROR,
"unexpected expr type in multiassign list");
1602 (
Node *) placeholder,
1616 newargs =
lappend(newargs, neww);
1620 newc->
args = newargs;
1624 if (defresult == NULL)
1630 defresult = (
Node *) n;
1654 foreach(l, newc->
args)
1668 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1670 errmsg(
"set-returning functions are not allowed in %s",
1672 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
1678 return (
Node *) newc;
1732 err =
_(
"cannot use subquery in check constraint");
1736 err =
_(
"cannot use subquery in DEFAULT expression");
1739 err =
_(
"cannot use subquery in index expression");
1742 err =
_(
"cannot use subquery in index predicate");
1745 err =
_(
"cannot use subquery in transform expression");
1748 err =
_(
"cannot use subquery in EXECUTE parameter");
1751 err =
_(
"cannot use subquery in trigger WHEN condition");
1754 err =
_(
"cannot use subquery in partition bound");
1757 err =
_(
"cannot use subquery in partition key expression");
1760 err =
_(
"cannot use subquery in CALL argument");
1763 err =
_(
"cannot use subquery in COPY FROM WHERE condition");
1766 err =
_(
"cannot use subquery in column generation expression");
1779 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1796 elog(
ERROR,
"unexpected non-SELECT command in SubLink");
1818 (
errcode(ERRCODE_SYNTAX_ERROR),
1819 errmsg(
"subquery must return only one column"),
1854 left_list = ((
RowExpr *) lefthand)->args;
1879 right_list =
lappend(right_list, param);
1889 (
errcode(ERRCODE_SYNTAX_ERROR),
1890 errmsg(
"subquery has too many columns"),
1894 (
errcode(ERRCODE_SYNTAX_ERROR),
1895 errmsg(
"subquery has too few columns"),
1969 newelems =
lappend(newelems, newe);
1982 coerce_type = (newa->
multidims ? array_type : element_type);
1988 if (newelems ==
NIL)
1990 (
errcode(ERRCODE_INDETERMINATE_DATATYPE),
1991 errmsg(
"cannot determine type of empty array"),
1992 errhint(
"Explicitly cast to the desired type, " 1993 "for example ARRAY[]::integer[]."),
2005 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2006 errmsg(
"could not find element type for data type %s",
2016 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2017 errmsg(
"could not find array type for data type %s",
2021 coerce_hard =
false;
2034 foreach(element, newelems)
2050 (
errcode(ERRCODE_CANNOT_COERCE),
2051 errmsg(
"cannot cast type %s to %s",
2060 newcoercedelems =
lappend(newcoercedelems, newe);
2069 return (
Node *) newa;
2093 snprintf(fname,
sizeof(fname),
"f%d", fnum);
2099 return (
Node *) newr;
2111 foreach(args, c->
args)
2117 newargs =
lappend(newargs, newe);
2124 foreach(args, newargs)
2132 newcoercedargs =
lappend(newcoercedargs, newe);
2138 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2140 errmsg(
"set-returning functions are not allowed in %s",
2142 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
2146 newc->
args = newcoercedargs;
2148 return (
Node *) newc;
2157 const char *funcname = (m->
op ==
IS_GREATEST) ?
"GREATEST" :
"LEAST";
2161 foreach(args, m->
args)
2167 newargs =
lappend(newargs, newe);
2174 foreach(args, newargs)
2182 newcoercedargs =
lappend(newcoercedargs, newe);
2185 newm->
args = newcoercedargs;
2187 return (
Node *) newm;
2200 svf->
type = DATEOID;
2203 svf->
type = TIMETZOID;
2206 svf->
type = TIMETZOID;
2210 svf->
type = TIMESTAMPTZOID;
2213 svf->
type = TIMESTAMPTZOID;
2217 svf->
type = TIMEOID;
2220 svf->
type = TIMEOID;
2224 svf->
type = TIMESTAMPOID;
2227 svf->
type = TIMESTAMPOID;
2236 svf->
type = NAMEOID;
2240 return (
Node *) svf;
2257 newx->
type = XMLOID;
2284 (
errcode(ERRCODE_SYNTAX_ERROR),
2286 ?
errmsg(
"unnamed XML attribute value must be a column reference")
2287 :
errmsg(
"unnamed XML element value must be a column reference"),
2301 (
errcode(ERRCODE_SYNTAX_ERROR),
2302 errmsg(
"XML attribute name \"%s\" appears more than once",
2315 foreach(lc, x->
args)
2369 return (
Node *) newx;
2392 xexpr->
type = targetType;
2393 xexpr->
typmod = targetTypmod;
2402 TEXTOID, targetType, targetTypmod,
2408 (
errcode(ERRCODE_CANNOT_COERCE),
2409 errmsg(
"cannot cast XMLSERIALIZE result to %s",
2418 const char *clausename;
2423 clausename =
"IS TRUE";
2426 clausename =
"IS NOT TRUE";
2429 clausename =
"IS FALSE";
2432 clausename =
"IS NOT FALSE";
2435 clausename =
"IS UNKNOWN";
2438 clausename =
"IS NOT UNKNOWN";
2441 elog(
ERROR,
"unrecognized booltesttype: %d",
2487 if (node != NULL &&
IsA(node,
Param))
2501 return (
Node *) cexpr;
2509 int sublevels_up,
int location)
2522 sublevels_up,
true);
2530 return (
Node *) result;
2563 int32 targetBaseTypmod;
2572 targetBaseTypmod = targetTypmod;
2603 targetType, targetTypmod,
2609 (
errcode(ERRCODE_CANNOT_COERCE),
2610 errmsg(
"cannot cast type %s to %s",
2640 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2641 errmsg(
"collations are not supported by type %s",
2648 return (
Node *) newc;
2665 List *largs,
List *rargs,
int location)
2674 List **opinfo_lists;
2682 (
errcode(ERRCODE_SYNTAX_ERROR),
2683 errmsg(
"unequal number of entries in row expressions"),
2692 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2693 errmsg(
"cannot compare rows of zero length"),
2717 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2718 errmsg(
"row comparison operator must yield type boolean, " 2724 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2725 errmsg(
"row comparison operator must not return a set"),
2727 opexprs =
lappend(opexprs, cmp);
2760 foreach(j, opinfo_lists[i])
2767 strats = this_strats;
2783 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2784 errmsg(
"could not determine interpretation of row comparison operator %s",
2786 errhint(
"Row comparison operators must be associated with btree operator families."),
2805 for (i = 0; i < nopers; i++)
2810 foreach(j, opinfo_lists[i])
2824 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2825 errmsg(
"could not determine interpretation of row comparison operator %s",
2827 errdetail(
"There are multiple equally-plausible candidates."),
2851 rcexpr->
opnos = opnos;
2854 rcexpr->
largs = largs;
2855 rcexpr->
rargs = rargs;
2857 return (
Node *) rcexpr;
2870 Node *result = NULL;
2878 (
errcode(ERRCODE_SYNTAX_ERROR),
2879 errmsg(
"unequal number of entries in row expressions"),
2915 result =
make_op(pstate, opname, ltree, rtree,
2917 if (((
OpExpr *) result)->opresulttype != BOOLOID)
2919 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2920 errmsg(
"IS DISTINCT FROM requires = operator to yield boolean"),
2922 if (((
OpExpr *) result)->opretset)
2924 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2926 errmsg(
"%s must not return a set",
"IS DISTINCT FROM"),
2972 return "invalid expression context";
2974 return "extension expression";
2978 return "JOIN/USING";
2980 return "sub-SELECT in FROM";
2982 return "function in FROM";
2992 return "window PARTITION BY";
2994 return "window ORDER BY";
2996 return "window RANGE";
2998 return "window ROWS";
3000 return "window GROUPS";
3013 return "DISTINCT ON";
3030 return "index expression";
3032 return "index predicate";
3040 return "partition bound";
3042 return "PARTITION BY";
3048 return "GENERATED AS";
3059 return "unrecognized expression kind";
#define list_make2(x1, x2)
Value * makeString(char *str)
Expr * make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, Node *last_srf, int location)
static Node * transformAExprDistinct(ParseState *pstate, A_Expr *a)
static Node * transformRowExpr(ParseState *pstate, RowExpr *r, bool allowDefault)
static bool exprIsNullConstant(Node *arg)
static Node * transformExprRecurse(ParseState *pstate, Node *expr)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
static void unknown_attribute(ParseState *pstate, Node *relref, const char *attname, int location)
int bms_first_member(Bitmapset *a)
#define IsA(nodeptr, _type_)
static Node * transformIndirection(ParseState *pstate, A_Indirection *ind)
int errhint(const char *fmt,...)
static Node * transformCurrentOfExpr(ParseState *pstate, CurrentOfExpr *cexpr)
Expr * make_scalar_array_op(ParseState *pstate, List *opname, bool useOr, Node *ltree, Node *rtree, int location)
#define forboth(cell1, list1, cell2, list2)
static Node * transformAExprOpAny(ParseState *pstate, A_Expr *a)
int exprLocation(const Node *expr)
void markVarForSelectPriv(ParseState *pstate, Var *var)
static Node * transformMinMaxExpr(ParseState *pstate, MinMaxExpr *m)
int32 anytime_typmod_check(bool istz, int32 typmod)
#define castNode(_type_, nodeptr)
int32 exprTypmod(const Node *expr)
Oid get_element_type(Oid typid)
#define NodeSetTag(nodeptr, t)
Oid get_array_type(Oid typid)
char * pstrdup(const char *in)
static Node * transformAExprNullIf(ParseState *pstate, A_Expr *a)
bool expression_returns_set(Node *clause)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
static Node * transformSubLink(ParseState *pstate, SubLink *sublink)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
Node * scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, const char *colname, int location)
Var * makeWholeRowVar(RangeTblEntry *rte, Index varno, Index varlevelsup, bool allowScalar)
List * list_concat(List *list1, const List *list2)
int errcode(int sqlerrcode)
void errorMissingColumn(ParseState *pstate, const char *relname, const char *colname, int location)
List * p_multiassign_exprs
static Expr * make_distinct_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, int location)
ParseNamespaceItem * p_target_nsitem
A_Expr * makeSimpleA_Expr(A_Expr_Kind kind, char *name, Node *lexpr, Node *rexpr, int location)
Const * make_const(ParseState *pstate, Value *value, int location)
static Node * transformBooleanTest(ParseState *pstate, BooleanTest *b)
static Node * transformXmlExpr(ParseState *pstate, XmlExpr *x)
List * lappend_oid(List *list, Oid datum)
#define OidIsValid(objectId)
static Node * transformCoalesceExpr(ParseState *pstate, CoalesceExpr *c)
static Node * make_row_comparison_op(ParseState *pstate, List *opname, List *largs, List *rargs, int location)
const char * ParseExprKindName(ParseExprKind exprKind)
PostParseColumnRefHook p_post_columnref_hook
Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, Node *last_srf, FuncCall *fn, bool proc_call, int location)
static void * list_nth(const List *list, int n)
static Node * transformBoolExpr(ParseState *pstate, BoolExpr *a)
char * FigureColname(Node *node)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
Node * makeBoolConst(bool value, bool isnull)
static Node * transformArrayExpr(ParseState *pstate, A_ArrayExpr *a, Oid array_type, Oid element_type, int32 typmod)
#define lfirst_node(type, lc)
static Node * transformAExprOpAll(ParseState *pstate, A_Expr *a)
char * get_database_name(Oid dbid)
static Node * transformFuncCall(ParseState *pstate, FuncCall *fn)
ParseParamRefHook p_paramref_hook
char * map_sql_identifier_to_xml_name(const char *ident, bool fully_escaped, bool escape_period)
void check_stack_depth(void)
SubscriptingRef * transformContainerSubscripts(ParseState *pstate, Node *containerBase, Oid containerType, int32 containerTypMod, List *indirection, bool isAssignment)
int errdetail(const char *fmt,...)
static Node * transformWholeRowRef(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location)
static Node * transformParamRef(ParseState *pstate, ParamRef *pref)
void errorMissingRTE(ParseState *pstate, RangeVar *relation)
List * list_delete_last(List *list)
bool type_is_rowtype(Oid typid)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
static Node * transformAExprOp(ParseState *pstate, A_Expr *a)
Node * coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context)
List * lappend(List *list, void *datum)
static chr element(struct vars *v, const chr *startp, const chr *endp)
char * NameListToString(List *names)
static Node * transformMultiAssignRef(ParseState *pstate, MultiAssignRef *maref)
static Node * transformCollateClause(ParseState *pstate, CollateClause *c)
bool Transform_null_equals
List * get_op_btree_interpretation(Oid opno)
BoolTestType booltesttype
List * transformExpressionList(ParseState *pstate, List *exprlist, ParseExprKind exprKind, bool allowDefault)
Node * transformGroupingFunc(ParseState *pstate, GroupingFunc *p)
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
static Node * make_row_distinct_op(ParseState *pstate, List *opname, RowExpr *lrow, RowExpr *rrow, int location)
ParseExprKind p_expr_kind
NullTestType nulltesttype
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
Oid LookupCollation(ParseState *pstate, List *collnames, int location)
Query * parse_sub_analyze(Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
#define ereport(elevel,...)
ParseNamespaceItem * refnameNamespaceItem(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
static void * fn(void *arg)
List * lcons(void *datum, List *list)
int errmsg_internal(const char *fmt,...)
#define Assert(condition)
int32 anytimestamp_typmod_check(bool istz, int32 typmod)
bool contain_vars_of_level(Node *node, int levelsup)
#define ISCOMPLEX(typeid)
Oid exprType(const Node *expr)
static int list_length(const List *l)
int parser_errposition(ParseState *pstate, int location)
Oid exprCollation(const Node *expr)
#define type_is_array(typid)
static Node * make_nulltest_from_distinct(ParseState *pstate, A_Expr *distincta, Node *arg)
Bitmapset * bms_add_member(Bitmapset *a, int x)
static Node * transformCaseExpr(ParseState *pstate, CaseExpr *c)
#define InvalidAttrNumber
static Node * transformTypeCast(ParseState *pstate, TypeCast *tc)
static Node * transformColumnRef(ParseState *pstate, ColumnRef *cref)
int errmsg(const char *fmt,...)
static Node * transformXmlSerialize(ParseState *pstate, XmlSerialize *xs)
int parser_coercion_errposition(ParseState *pstate, int coerce_location, Node *input_expr)
int count_nonjunk_tlist_entries(List *tlist)
static Node * transformSQLValueFunction(ParseState *pstate, SQLValueFunction *svf)
Node * coerce_to_specific_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
PreParseColumnRefHook p_pre_columnref_hook
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
bool type_is_collatable(Oid typid)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
static Node * transformAExprBetween(ParseState *pstate, A_Expr *a)
Node * colNameToVar(ParseState *pstate, const char *colname, bool localonly, int location)
static int cmp(const chr *x, const chr *y, size_t len)
static Node * transformAExprIn(ParseState *pstate, A_Expr *a)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)