191 errmsg(
"relation \"%s\" cannot be the target of a modifying statement",
213 relation->
alias, inh,
false);
446 elog(
ERROR,
"unexpected non-SELECT command in subquery in FROM");
537 fc->agg_order ==
NIL &&
542 !
fc->func_variadic &&
547 foreach(
lc2,
fc->args)
567 errmsg(
"set-returning functions must appear at top level of FROM"),
595 errmsg(
"set-returning functions must appear at top level of FROM"),
607 errmsg(
"multiple column definition lists are not allowed for the same function"),
640 errmsg(
"ROWS FROM() with multiple functions cannot have a column definition list"),
641 errhint(
"Put a separate column definition list for each function inside ROWS FROM()."),
647 errmsg(
"UNNEST() with multiple arguments cannot have a column definition list"),
648 errhint(
"Use separate UNNEST() calls inside ROWS FROM(), and attach a column definition list to each one."),
655 errmsg(
"WITH ORDINALITY cannot be used with a column definition list"),
656 errhint(
"Put the column definition list inside ROWS FROM()."),
733 tf->ordinalitycol = -1;
739 foreach(
col,
rtf->columns)
748 tf->colnames =
lappend(tf->colnames,
755 if (
rawc->for_ordinality)
757 if (tf->ordinalitycol != -1)
760 errmsg(
"only one FOR ORDINALITY column is allowed"),
765 tf->ordinalitycol = colno;
769 if (
rawc->typeName->setof)
772 errmsg(
"column \"%s\" cannot be declared SETOF",
781 tf->coltypmods =
lappend_int(tf->coltypmods, typmod);
798 if (
rawc->coldefexpr)
811 tf->coldefexprs =
lappend(tf->coldefexprs, coldefexpr);
813 if (
rawc->is_not_null)
817 for (
j = 0;
j < colno;
j++)
821 errmsg(
"column name \"%s\" is not unique",
824 names[colno] =
rawc->colname;
831 if (
rtf->namespaces !=
NIL)
839 foreach(ns,
rtf->namespaces)
854 foreach(
lc2, ns_names)
863 errmsg(
"namespace name \"%s\" is not unique",
873 errmsg(
"only one default namespace is allowed"),
883 tf->ns_uris = ns_uris;
884 tf->ns_names = ns_names;
933 errmsg(
"tablesample method %s does not exist",
941 errmsg(
"function %s must return type %s",
955 errmsg_plural(
"tablesample method %s requires %d argument, not %d",
956 "tablesample method %s requires %d arguments, not %d",
986 if (!
tsm->repeatable_across_queries)
989 errmsg(
"tablesample method %s does not support REPEATABLE",
1134 rte = (*top_nsitem)->p_rte;
1142 errmsg(
"TABLESAMPLE clause can only be applied to tables and materialized views"),
1279 if (
j->join_using_alias)
1280 j->join_using_alias->colnames =
j->usingClause;
1329 errmsg(
"column name \"%s\" appears more than once in USING clause",
1344 errmsg(
"common column name \"%s\" appears more than once in left table",
1353 errmsg(
"column \"%s\" specified in USING clause does not exist in left table",
1368 errmsg(
"common column name \"%s\" appears more than once in right table",
1377 errmsg(
"column \"%s\" specified in USING clause does not exist in right table",
1430 switch (
j->jointype)
1446 elog(
ERROR,
"unrecognized join type: %d",
1534 nscol->p_varattnosyn = k + 1;
1549 j->join_using_alias,
1572 if (
j->join_using_alias)
1577 jnsitem->p_names =
j->join_using_alias;
1584 jnsitem->p_rel_visible =
true;
1585 jnsitem->p_cols_visible =
true;
1586 jnsitem->p_lateral_only =
false;
1605 if (
j->alias !=
NULL)
1615 nsitem->p_cols_visible =
true;
1616 nsitem->p_lateral_only =
false;
1617 nsitem->p_lateral_ok =
true;
1652 var->varnosyn =
nscol->p_varnosyn;
1653 var->varattnosyn =
nscol->p_varattnosyn;
1754 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
1819 foreach(
lc,
namespace)
1836 foreach(
lc,
namespace)
1907 errmsg(
"row count cannot be null in FETCH FIRST ... WITH TIES clause")));
1932 errmsg(
"argument of %s must not contain variables",
1962 errmsg(
"aggregate functions are not allowed in %s",
1971 errmsg(
"window functions are not allowed in %s",
1983 elog(
ERROR,
"unexpected exprKind in checkTargetlistEntrySQL92");
2054 int location = ((
ColumnRef *) node)->location;
2086 if (!
tle->resjunk &&
2097 errmsg(
"%s \"%s\" is ambiguous",
2125 errmsg(
"non-integer constant in %s",
2147 errmsg(
"%s position %d is not in select list",
2295 foreach(l2,
gset->content)
2325 foreach(l, (
List *) expr)
2338 return (
Node *) result;
2369 List **targetlist,
List *sortClause,
2382 if (
tle->ressortgroupref > 0)
2403 return tle->ressortgroupref;
2424 foreach(
sl, sortClause)
2428 if (
sc->tleSortGroupRef ==
tle->ressortgroupref)
2433 grpc->nulls_first =
false;
2454 return tle->ressortgroupref;
2477 List **targetlist,
List *sortClause,
2530 List **targetlist,
List *sortClause,
2538 foreach(
gl,
gset->content)
2546 targetlist, sortClause,
2559 targetlist, sortClause,
2586 errmsg(
"CUBE is limited to 12 elements"),
2637 List **groupingSets,
2638 List **targetlist,
List *sortClause,
2689 result, *targetlist,
2750 targetlist, sortClause,
2759 targetlist, sortClause,
2778 *groupingSets = gsets;
2839 List *partitionClause;
2854 errmsg(
"window \"%s\" is already defined",
windef->name),
2866 errmsg(
"window \"%s\" does not exist",
2895 wc->refname =
windef->refname;
2913 if (partitionClause)
2916 errmsg(
"cannot override PARTITION BY clause of window \"%s\"",
2925 if (orderClause &&
refwc->orderClause)
2928 errmsg(
"cannot override ORDER BY clause of window \"%s\"",
2934 wc->copiedOrder =
false;
2939 wc->copiedOrder =
true;
2945 wc->copiedOrder =
false;
2958 errmsg(
"cannot copy window \"%s\" because it has a frame clause",
2964 errmsg(
"cannot copy window \"%s\" because it has a frame clause",
2966 errhint(
"Omit the parentheses in this OVER clause."),
2986 errmsg(
"RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column"),
2995 elog(
ERROR,
"operator %u is not a valid ordering operator",
2999 wc->inRangeAsc = !
sortcl->reverse_sort;
3000 wc->inRangeNullsFirst =
sortcl->nulls_first;
3009 errmsg(
"GROUPS mode requires an ORDER BY clause"),
3016 &wc->startInRangeFunc,
3020 &wc->endInRangeFunc,
3070 foreach(
slitem, sortClause)
3079 errmsg(
"in an aggregate with DISTINCT, ORDER BY expressions must appear in argument list") :
3080 errmsg(
"for SELECT DISTINCT, ORDER BY expressions must appear in select list"),
3090 foreach(
tlitem, *targetlist)
3097 result, *targetlist,
3112 errmsg(
"an aggregate with DISTINCT must have at least one argument") :
3113 errmsg(
"SELECT DISTINCT must have at least one column")));
3133 List **targetlist,
List *sortClause)
3170 foreach(
lc, sortClause)
3179 errmsg(
"SELECT DISTINCT ON expressions must match initial ORDER BY expressions"),
3211 errmsg(
"SELECT DISTINCT ON expressions must match initial ORDER BY expressions"),
3214 result, *targetlist,
3250 elog(
ERROR,
"get_matching_location: no matching sortgroupref");
3289 errmsg(
"%s is not allowed in ON CONFLICT clause",
3295 errmsg(
"%s is not allowed in ON CONFLICT clause",
3296 "NULLS FIRST/LAST"),
3298 if (
ielem->opclassopts)
3301 errmsg(
"operator class options are not allowed in ON CONFLICT clause"),
3338 if (!
ielem->collation)
3344 if (!
ielem->opclass)
3348 ielem->opclass,
false);
3373 *arbiterWhere =
NULL;
3379 errmsg(
"ON CONFLICT DO UPDATE requires inference specification or constraint name"),
3380 errhint(
"For example, ON CONFLICT (column_name)."),
3391 errmsg(
"ON CONFLICT is not supported with system catalog tables"),
3399 errmsg(
"ON CONFLICT is not supported on table \"%s\" used as a catalog table",
3491 location =
sortby->location;
3497 switch (
sortby->sortby_dir)
3503 &sortop, &eqop,
NULL,
3510 NULL, &eqop, &sortop,
3530 errmsg(
"operator %s is not a valid ordering operator",
3532 errhint(
"Ordering operators must be \"<\" or \">\" members of btree operator families.")));
3559 sortcl->hashable = hashable;
3560 sortcl->reverse_sort = reverse;
3562 switch (
sortby->sortby_nulls)
3566 sortcl->nulls_first = reverse;
3569 sortcl->nulls_first =
true;
3572 sortcl->nulls_first =
false;
3575 elog(
ERROR,
"unrecognized sortby_nulls: %d",
3635 &sortop, &eqop,
NULL,
3642 grpcl->sortop = sortop;
3643 grpcl->reverse_sort =
false;
3645 grpcl->nulls_first =
false;
3646 grpcl->hashable = hashable;
3667 if (
tle->ressortgroupref)
3668 return tle->ressortgroupref;
3680 return tle->ressortgroupref;
3716 if (
scl->tleSortGroupRef ==
ref &&
3718 sortop ==
scl->sortop ||
3846 errmsg(
"RANGE with offset PRECEDING/FOLLOWING is not supported for column type %s",
3852 errmsg(
"RANGE with offset PRECEDING/FOLLOWING is not supported for column type %s and offset type %s",
3855 errhint(
"Cast the offset value to an appropriate type."),
3860 errmsg(
"RANGE with offset PRECEDING/FOLLOWING has multiple interpretations for column type %s and offset type %s",
3863 errhint(
"Cast the offset value to the exact intended type."),
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
#define Assert(condition)
#define OidIsValid(objectId)
bool IsCatalogRelation(Relation relation)
void ReleaseCatCacheList(CatCList *list)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
#define palloc_object(type)
#define palloc_array(type, count)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
bool list_member_int(const List *list, int datum)
List * list_truncate(List *list, int new_size)
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, CompareType *cmptype)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
bool op_hashjoinable(Oid opno, Oid inputtype)
Oid get_typcollation(Oid typid)
Oid get_func_rettype(Oid funcid)
Oid get_commutator(Oid opno)
Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)
A_Expr * makeSimpleA_Expr(A_Expr_Kind kind, char *name, Node *lexpr, Node *rexpr, int location)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
RelabelType * makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat)
FuncCall * makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
GroupingSet * makeGroupingSet(GroupingSetKind kind, List *content, int location)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
char * NameListToString(const List *names)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
Node * strip_implicit_coercions(Node *node)
int exprLocation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
Index assignSortGroupRef(TargetEntry *tle, List *tlist)
static List * transformGroupClauseList(List **flatresult, ParseState *pstate, List *list, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99, bool toplevel)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
static Node * transformJoinOnClause(ParseState *pstate, JoinExpr *j, List *namespace)
static int extractRemainingColumns(ParseState *pstate, ParseNamespaceColumn *src_nscolumns, List *src_colnames, List **src_colnos, List **res_colnames, List **res_colvars, ParseNamespaceColumn *res_nscolumns)
static void setNamespaceLateralState(List *namespace, bool lateral_only, bool lateral_ok)
static Node * flatten_grouping_sets(Node *expr, bool toplevel, bool *hasGroupingSets)
static void markRelsAsNulledBy(ParseState *pstate, Node *n, int jindex)
List * transformGroupClause(ParseState *pstate, List *grouplist, bool groupByAll, List **groupingSets, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99)
static void checkExprIsVarFree(ParseState *pstate, Node *n, const char *constructName)
static ParseNamespaceItem * transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
List * transformSortClause(ParseState *pstate, List *orderlist, List **targetlist, ParseExprKind exprKind, bool useSQL99)
List * transformDistinctOnClause(ParseState *pstate, List *distinctlist, List **targetlist, List *sortClause)
static Var * buildVarFromNSColumn(ParseState *pstate, ParseNamespaceColumn *nscol)
static ParseNamespaceItem * transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
List * transformWindowDefinitions(ParseState *pstate, List *windowdefs, List **targetlist)
static void setNamespaceColumnVisibility(List *namespace, bool cols_visible)
static int get_matching_location(int sortgroupref, List *sortgrouprefs, List *exprs)
void transformFromClause(ParseState *pstate, List *frmList)
static ParseNamespaceItem * getNSItemForSpecialRelationTypes(ParseState *pstate, RangeVar *rv)
static void checkTargetlistEntrySQL92(ParseState *pstate, TargetEntry *tle, ParseExprKind exprKind)
static Index transformGroupClauseExpr(List **flatresult, Bitmapset *seen_local, ParseState *pstate, Node *gexpr, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99, bool toplevel)
static TableSampleClause * transformRangeTableSample(ParseState *pstate, RangeTableSample *rts)
static TargetEntry * findTargetlistEntrySQL99(ParseState *pstate, Node *node, List **tlist, ParseExprKind exprKind)
List * transformDistinctClause(ParseState *pstate, List **targetlist, List *sortClause, bool is_agg)
bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList)
Node * transformLimitClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName, LimitOption limitOption)
static List * addTargetToGroupList(ParseState *pstate, TargetEntry *tle, List *grouplist, List *targetlist, int location)
static Node * transformFrameOffset(ParseState *pstate, int frameOptions, Oid rangeopfamily, Oid rangeopcintype, Oid *inRangeFunc, Node *clause)
static Node * transformGroupingSet(List **flatresult, ParseState *pstate, GroupingSet *gset, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99, bool toplevel)
static List * resolve_unique_index_expr(ParseState *pstate, InferClause *infer, Relation heapRel)
void transformOnConflictArbiter(ParseState *pstate, OnConflictClause *onConflictClause, List **arbiterExpr, Node **arbiterWhere, Oid *constraint)
static Node * transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars)
int setTargetTable(ParseState *pstate, RangeVar *relation, bool inh, bool alsoSource, AclMode requiredPerms)
static Node * buildMergedJoinVar(ParseState *pstate, JoinType jointype, Var *l_colvar, Var *r_colvar)
static Node * transformFromClauseItem(ParseState *pstate, Node *n, ParseNamespaceItem **top_nsitem, List **namespace)
static ParseNamespaceItem * transformTableEntry(ParseState *pstate, RangeVar *r)
static TargetEntry * findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist, ParseExprKind exprKind)
static WindowClause * findWindowClause(List *wclist, const char *name)
List * addTargetToSortList(ParseState *pstate, TargetEntry *tle, List *sortlist, List *targetlist, SortBy *sortby)
static ParseNamespaceItem * transformRangeFunction(ParseState *pstate, RangeFunction *r)
Node * coerce_to_specific_type_typmod(ParseState *pstate, Node *node, Oid targetTypeId, int32 targetTypmod, const char *constructName)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
Node * coerce_to_specific_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
void assign_list_collations(ParseState *pstate, List *exprs)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
const char * ParseExprKindName(ParseExprKind exprKind)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
ParseNamespaceItem * transformJsonTable(ParseState *pstate, JsonTable *jt)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
@ EXPR_KIND_INDEX_EXPRESSION
@ EXPR_KIND_WINDOW_FRAME_RANGE
@ EXPR_KIND_FROM_SUBSELECT
@ EXPR_KIND_WINDOW_FRAME_GROUPS
@ EXPR_KIND_INDEX_PREDICATE
@ EXPR_KIND_FROM_FUNCTION
@ EXPR_KIND_WINDOW_PARTITION
@ EXPR_KIND_WINDOW_FRAME_ROWS
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError)
void markNullableIfNeeded(ParseState *pstate, Var *var)
CommonTableExpr * scanNameSpaceForCTE(ParseState *pstate, const char *refname, Index *ctelevelsup)
Node * colNameToVar(ParseState *pstate, const char *colname, bool localonly, int location)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
ParseNamespaceItem * addRangeTableEntryForENR(ParseState *pstate, RangeVar *rv, bool inFromCl)
void markVarForSelectPriv(ParseState *pstate, Var *var)
ParseNamespaceItem * addRangeTableEntry(ParseState *pstate, RangeVar *relation, Alias *alias, bool inh, bool inFromCl)
ParseNamespaceItem * addRangeTableEntryForTableFunc(ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl)
Relation parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
bool scanNameSpaceForENR(ParseState *pstate, const char *refname)
ParseNamespaceItem * addRangeTableEntryForFunction(ParseState *pstate, List *funcnames, List *funcexprs, List *coldeflists, RangeFunction *rangefunc, bool lateral, bool inFromCl)
bool isLockedRefname(ParseState *pstate, const char *refname)
ParseNamespaceItem * addRangeTableEntryForSubquery(ParseState *pstate, Query *subquery, Alias *alias, bool lateral, bool inFromCl)
ParseNamespaceItem * addRangeTableEntryForCTE(ParseState *pstate, CommonTableExpr *cte, Index levelsup, RangeVar *rv, bool inFromCl)
ParseNamespaceItem * addRangeTableEntryForJoin(ParseState *pstate, List *colnames, ParseNamespaceColumn *nscolumns, JoinType jointype, int nummergedcols, List *aliasvars, List *leftcols, List *rightcols, Alias *join_using_alias, Alias *alias, bool inFromCl)
void checkNameSpaceConflicts(ParseState *pstate, List *namespace1, List *namespace2)
TargetEntry * transformTargetEntry(ParseState *pstate, Node *node, Node *expr, ParseExprKind exprKind, char *colname, bool resjunk)
char * FigureColname(Node *node)
Oid LookupCollation(ParseState *pstate, List *collnames, int location)
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
#define FRAMEOPTION_END_OFFSET
#define FRAMEOPTION_START_OFFSET
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_DEFAULTS
Query * parse_sub_analyze(Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
List * SystemFuncName(char *name)
FormData_pg_amproc * Form_pg_amproc
Bitmapset * get_relation_constraint_attnos(Oid relid, const char *conname, bool missing_ok, Oid *constraintOid)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_ptr(type, var, lst)
static ListCell * list_nth_cell(const List *list, int n)
#define list_make1_int(x1)
#define list_make2(x1, x2)
static Datum ObjectIdGetDatum(Oid X)
static int fc(const char *x)
#define RelationGetRelid(relation)
#define RelationIsUsedAsCatalogTable(relation)
#define RelationGetRelationName(relation)
bool contain_windowfuncs(Node *node)
int locate_agg_of_level(Node *node, int levelsup)
bool contain_aggs_of_level(Node *node, int levelsup)
int locate_windowfunc(Node *node)
void check_stack_depth(void)
RTEPermissionInfo * p_perminfo
ParseNamespaceItem * p_target_nsitem
ParseExprKind p_expr_kind
Relation p_target_relation
VarReturningType varreturningtype
#define SearchSysCacheList2(cacheId, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
Node * get_sortgroupclause_expr(SortGroupClause *sgClause, List *targetList)
String * makeString(char *str)
bool contain_vars_of_level(Node *node, int levelsup)
int locate_var_of_level(Node *node, int levelsup)