46 gettext_noop(
"recursive reference to query \"%s\" must not appear within its non-recursive term"),
48 gettext_noop(
"recursive reference to query \"%s\" must not appear within a subquery"),
50 gettext_noop(
"recursive reference to query \"%s\" must not appear within an outer join"),
52 gettext_noop(
"recursive reference to query \"%s\" must not appear within INTERSECT"),
54 gettext_noop(
"recursive reference to query \"%s\" must not appear within EXCEPT")
124 foreach(lc, withClause->
ctes)
135 (
errcode(ERRCODE_DUPLICATE_ALIAS),
136 errmsg(
"WITH query name \"%s\" specified more than once",
169 foreach(lc, withClause->
ctes)
221 foreach(lc, withClause->
ctes)
256 elog(
ERROR,
"unexpected non-Query statement in WITH");
258 elog(
ERROR,
"unexpected utility statement in WITH");
267 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
268 errmsg(
"WITH clause containing a data-modifying statement must be at the top level"),
310 if (lctyp == NULL || lctypmod == NULL || lccoll == NULL)
311 elog(
ERROR,
"wrong number of output columns in WITH");
316 (
errcode(ERRCODE_DATATYPE_MISMATCH),
317 errmsg(
"recursive query \"%s\" column %d has type %s in non-recursive term but type %s overall",
323 errhint(
"Cast the output of the non-recursive term to the correct type."),
327 (
errcode(ERRCODE_COLLATION_MISMATCH),
328 errmsg(
"recursive query \"%s\" column %d has collation \"%s\" in non-recursive term but collation \"%s\" overall",
332 errhint(
"Use the COLLATE clause to set the collation of the non-recursive term."),
338 if (lctyp != NULL || lctypmod != NULL || lccoll != NULL)
339 elog(
ERROR,
"wrong number of output columns in WITH");
349 (
errcode(ERRCODE_SYNTAX_ERROR),
350 errmsg(
"WITH query is not recursive"),
380 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
381 errmsg(
"with a SEARCH or CYCLE clause, the left side of the UNION must be a SELECT")));
385 (
errcode(ERRCODE_SYNTAX_ERROR),
386 errmsg(
"with a SEARCH or CYCLE clause, the right side of the UNION must be a SELECT")));
400 (
errcode(ERRCODE_SYNTAX_ERROR),
401 errmsg(
"search column \"%s\" not in WITH query column list",
407 (
errcode(ERRCODE_DUPLICATE_COLUMN),
408 errmsg(
"search column \"%s\" specified more than once",
417 errmsg(
"search sequence column name \"%s\" already used in WITH query column list",
435 (
errcode(ERRCODE_SYNTAX_ERROR),
436 errmsg(
"cycle column \"%s\" not in WITH query column list",
442 (
errcode(ERRCODE_DUPLICATE_COLUMN),
443 errmsg(
"cycle column \"%s\" specified more than once",
452 errmsg(
"cycle mark column name \"%s\" already used in WITH query column list",
464 errmsg(
"cycle path column name \"%s\" already used in WITH query column list",
472 errmsg(
"cycle mark column name and cycle path column name are the same"),
486 "CYCLE/SET/DEFAULT");
501 errcode(ERRCODE_UNDEFINED_FUNCTION),
502 errmsg(
"could not identify an equality operator for type %s",
507 errcode(ERRCODE_UNDEFINED_FUNCTION),
508 errmsg(
"could not identify an inequality operator for type %s",
520 errmsg(
"search sequence column name and cycle mark column name are the same"),
527 errmsg(
"search sequence column name and cycle path column name are the same"),
565 foreach(tlistitem, tlist)
576 if (varattno > numaliases)
602 colcoll = DEFAULT_COLLATION_OID;
608 if (varattno < numaliases)
610 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
611 errmsg(
"WITH query \"%s\" has %d columns available but %d columns specified",
612 cte->
ctename, varattno, numaliases),
664 foreach(lc2, withlist)
778 for (
i = 0;
i < numitems;
i++)
781 for (
j =
i;
j < numitems;
j++)
790 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
791 errmsg(
"mutual recursion between WITH items is not implemented"),
811 for (
j =
i + 1;
j < numitems;
j++)
842 (
errcode(ERRCODE_INVALID_RECURSION),
843 errmsg(
"recursive query \"%s\" must not contain data-modifying statements",
850 (
errcode(ERRCODE_INVALID_RECURSION),
851 errmsg(
"recursive query \"%s\" does not have the form non-recursive-term UNION [ALL] recursive-term",
871 elog(
ERROR,
"missing recursive reference");
894 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
895 errmsg(
"ORDER BY in a recursive query is not implemented"),
900 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
901 errmsg(
"OFFSET in a recursive query is not implemented"),
906 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
907 errmsg(
"LIMIT in a recursive query is not implemented"),
912 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
913 errmsg(
"FOR UPDATE/SHARE in a recursive query is not implemented"),
945 foreach(lc2, withlist)
961 (
errcode(ERRCODE_INVALID_RECURSION),
969 (
errcode(ERRCODE_INVALID_RECURSION),
970 errmsg(
"recursive reference to query \"%s\" must not appear more than once",
1042 switch (
j->jointype)
1054 cstate->
context = save_context;
1062 cstate->
context = save_context;
1069 cstate->
context = save_context;
1074 elog(
ERROR,
"unrecognized join type: %d",
1089 cstate->
context = save_context;
1131 cstate->context = save_context;
1150 cstate->context = save_context;
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_empty(const Bitmapset *a)
#define OidIsValid(objectId)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
List * list_delete_first(List *list)
bool list_member(const List *list, const void *datum)
List * lcons(void *datum, List *list)
char * get_collation_name(Oid colloid)
Oid get_negator(Oid opno)
char * pstrdup(const char *in)
void * palloc0(Size size)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
int exprLocation(const Node *expr)
bool raw_expression_tree_walker(Node *node, bool(*walker)(), void *context)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
Node * coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
Oid select_common_collation(ParseState *pstate, List *exprs, bool none_ok)
static void checkWellFormedSelectStmt(SelectStmt *stmt, CteState *cstate)
@ RECURSION_NONRECURSIVETERM
static void makeDependencyGraph(CteState *cstate)
void analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
static void checkWellFormedRecursion(CteState *cstate)
static void TopologicalSort(ParseState *pstate, CteItem *items, int numitems)
List * transformWithClause(ParseState *pstate, WithClause *withClause)
static bool makeDependencyGraphWalker(Node *node, CteState *cstate)
static bool checkWellFormedRecursionWalker(Node *node, CteState *cstate)
static const char *const recursion_errormsgs[]
static void analyzeCTE(ParseState *pstate, CommonTableExpr *cte)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
int parser_errposition(ParseState *pstate, int location)
#define GetCTETargetList(cte)
Query * parse_sub_analyze(Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
Node * cycle_mark_default
CTECycleClause * cycle_clause
CTESearchClause * search_clause
ParseState * parentParseState
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
String * makeString(char *str)