71 bool isTopLevel,
List **targetlist);
88#ifdef DEBUG_NODE_TESTS_ENABLED
89static bool test_raw_expression_coverage(
Node *node,
void *
context);
106 const Oid *paramTypes,
int numParams,
113 Assert(sourceText != NULL);
128 (*post_parse_analyze_hook) (pstate, query, jstate);
146 Oid **paramTypes,
int *numParams,
153 Assert(sourceText != NULL);
170 (*post_parse_analyze_hook) (pstate, query, jstate);
188 void *parserSetupArg,
195 Assert(sourceText != NULL);
199 (*parserSetup) (pstate, parserSetupArg);
207 (*post_parse_analyze_hook) (pstate, query, jstate);
224 bool locked_from_parent,
225 bool resolve_unknowns)
274 stmt_len = ((
InsertStmt *) parseTree)->stmt_len;
279 stmt_len = ((
DeleteStmt *) parseTree)->stmt_len;
284 stmt_len = ((
UpdateStmt *) parseTree)->stmt_len;
289 stmt_len = ((
MergeStmt *) parseTree)->stmt_len;
294 stmt_len = ((
SelectStmt *) parseTree)->stmt_len;
309 qry->stmt_len = stmt_len;
321 Assert(qry->stmt_len >= 0);
368 if (
stmt->intoClause)
372 ctas->
query = parseTree;
382 stmt->intoClause = NULL;
384 parseTree = (
Node *) ctas;
400#ifdef DEBUG_NODE_TESTS_ENABLED
408 if (Debug_raw_expression_coverage_test)
417 (void) test_raw_expression_coverage(parseTree, NULL);
476 case T_DeclareCursorStmt:
486 case T_CreateTableAsStmt:
510 result->canSetTag =
true;
554 case T_DeclareCursorStmt:
556 case T_CreateTableAsStmt:
608 if (
stmt->withClause)
610 qry->hasRecursive =
stmt->withClause->recursive;
676 bool isGeneralSelect;
678 List *sub_rteperminfos;
687 bool isOnConflictUpdate;
697 if (
stmt->withClause)
699 qry->hasRecursive =
stmt->withClause->recursive;
704 qry->override =
stmt->override;
706 isOnConflictUpdate = (
stmt->onConflictClause &&
718 isGeneralSelect = (selectStmt && (selectStmt->
valuesLists ==
NIL ||
746 sub_rteperminfos =
NIL;
757 if (isOnConflictUpdate)
760 false,
false, targetPerms);
769 if (selectStmt == NULL)
778 else if (isGeneralSelect)
818 elog(
ERROR,
"unexpected non-SELECT command in INSERT ... SELECT");
864 exprList =
lappend(exprList, expr);
885 int sublist_length = -1;
886 bool lateral =
false;
888 Assert(selectStmt->intoClause == NULL);
890 foreach(lc, selectStmt->valuesLists)
906 if (sublist_length < 0)
914 (
errcode(ERRCODE_SYNTAX_ERROR),
915 errmsg(
"VALUES lists must all be the same length"),
949 exprsLists =
lappend(exprsLists, sublist);
982 coltypes, coltypmods, colcollations,
983 NULL, lateral,
true);
1007 List *valuesLists = selectStmt->valuesLists;
1010 Assert(selectStmt->intoClause == NULL);
1032 perminfo = pstate->p_target_nsitem->p_perminfo;
1033 qry->targetList =
NIL;
1035 forthree(lc, exprList, icols, icolumns, attnos, attrnos)
1046 qry->targetList =
lappend(qry->targetList, tle);
1057 if (
stmt->onConflictClause ||
stmt->returningList)
1059 pstate->p_namespace =
NIL;
1065 if (
stmt->onConflictClause)
1067 stmt->onConflictClause);
1070 if (
stmt->returningList)
1072 stmt->returningList,
1076 qry->rtable = pstate->p_rtable;
1077 qry->rteperminfos = pstate->p_rteperminfos;
1078 qry->jointree =
makeFromExpr(pstate->p_joinlist, NULL);
1080 qry->hasTargetSRFs = pstate->p_hasTargetSRFs;
1081 qry->hasSubLinks = pstate->p_hasSubLinks;
1101 bool strip_indirection)
1117 (
errcode(ERRCODE_SYNTAX_ERROR),
1118 errmsg(
"INSERT has more expressions than target columns"),
1122 if (stmtcols !=
NIL &&
1135 (
errcode(ERRCODE_SYNTAX_ERROR),
1136 errmsg(
"INSERT has more target columns than expressions"),
1140 errhint(
"The insertion source is a row expression containing the same number of columns expected by the INSERT. Did you accidentally use extra parentheses?") : 0),
1150 forthree(lc, exprlist, icols, icolumns, attnos, attrnos)
1163 if (strip_indirection)
1172 Expr *subexpr = expr;
1198 result =
lappend(result, expr);
1215 Oid arbiterConstraint;
1217 Node *onConflictWhere = NULL;
1218 int exclRelIndex = 0;
1238 exclRte = exclNSItem->
p_rte;
1246 exclRte->relkind = RELKIND_COMPOSITE_TYPE;
1255 &arbiterWhere, &arbiterConstraint);
1333 if (attr->attisdropped)
1344 var =
makeVar(exclRelIndex, attno + 1,
1345 attr->atttypid, attr->atttypmod,
1367 targetrel->
rd_rel->reltype,
1397 if (
attnum > 0 && var->vartype == RECORDOID)
1408 if (ste == NULL || ste->resjunk)
1437 if (
stmt->withClause)
1439 qry->hasRecursive =
stmt->withClause->recursive;
1445 if (
stmt->intoClause)
1447 (
errcode(ERRCODE_SYNTAX_ERROR),
1448 errmsg(
"SELECT ... INTO is not allowed here"),
1497 if (
stmt->distinctClause ==
NIL)
1500 qry->hasDistinctOn =
false;
1509 qry->hasDistinctOn =
false;
1515 stmt->distinctClause,
1518 qry->hasDistinctOn =
true;
1548 foreach(l,
stmt->lockingClause)
1578 List **colexprs = NULL;
1579 int sublist_length = -1;
1580 bool lateral =
false;
1600 if (
stmt->withClause)
1602 qry->hasRecursive =
stmt->withClause->recursive;
1614 foreach(lc,
stmt->valuesLists)
1630 if (sublist_length < 0)
1640 (
errcode(ERRCODE_SYNTAX_ERROR),
1641 errmsg(
"VALUES lists must all be the same length"),
1648 foreach(lc2, sublist)
1652 colexprs[
i] =
lappend(colexprs[
i], col);
1677 for (
i = 0;
i < sublist_length;
i++)
1685 foreach(lc, colexprs[
i])
1698 colcollations =
lappend_oid(colcollations, colcoll);
1704 for (
i = 0;
i < sublist_length;
i++)
1706 forboth(lc, colexprs[
i], lc2, exprsLists)
1711 sublist =
lappend(sublist, col);
1731 coltypes, coltypmods, colcollations,
1732 NULL, lateral,
true);
1759 if (
stmt->lockingClause)
1761 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1764 errmsg(
"%s cannot be applied to VALUES",
1795 Query *leftmostQuery;
1800 List *lockingClause;
1811 int sv_rtable_length;
1827 leftmostSelect =
stmt->larg;
1828 while (leftmostSelect && leftmostSelect->
op !=
SETOP_NONE)
1829 leftmostSelect = leftmostSelect->
larg;
1831 leftmostSelect->
larg == NULL);
1834 (
errcode(ERRCODE_SYNTAX_ERROR),
1835 errmsg(
"SELECT ... INTO is not allowed here"),
1844 sortClause =
stmt->sortClause;
1845 limitOffset =
stmt->limitOffset;
1846 limitCount =
stmt->limitCount;
1847 lockingClause =
stmt->lockingClause;
1848 withClause =
stmt->withClause;
1851 stmt->limitOffset = NULL;
1852 stmt->limitCount = NULL;
1854 stmt->withClause = NULL;
1859 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1862 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
1864 linitial(lockingClause))->strength))));
1869 qry->hasRecursive = withClause->
recursive;
1885 node = sostmt->
larg;
1891 Assert(leftmostQuery != NULL);
1911 forfour(lct, sostmt->colTypes,
1912 lcm, sostmt->colTypmods,
1913 lcc, sostmt->colCollations,
1924 Assert(!lefttle->resjunk);
1925 colName =
pstrdup(lefttle->resname);
1938 targetvars =
lappend(targetvars, var);
1940 sortnscolumns[sortcolindex].
p_varno = leftmostRTI;
1942 sortnscolumns[sortcolindex].
p_vartype = colType;
1943 sortnscolumns[sortcolindex].
p_vartypmod = colTypmod;
1944 sortnscolumns[sortcolindex].
p_varcollid = colCollation;
1945 sortnscolumns[sortcolindex].
p_varnosyn = leftmostRTI;
2001 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2002 errmsg(
"invalid UNION/INTERSECT/EXCEPT ORDER BY clause"),
2003 errdetail(
"Only result column names can be used, not expressions or functions."),
2004 errhint(
"Add the expression/function to every SELECT, or move the UNION into a FROM clause."),
2025 foreach(l, lockingClause)
2057 &sortop, &eqop, NULL,
2066 if (require_hash && (rescoltype == RECORDOID || rescoltype == RECORDARRAYOID))
2075 grpcl->hashable = hashable;
2096 bool isTopLevel,
List **targetlist)
2108 if (
stmt->intoClause)
2110 (
errcode(ERRCODE_SYNTAX_ERROR),
2111 errmsg(
"INTO is only allowed on first SELECT of UNION/INTERSECT/EXCEPT"),
2116 if (
stmt->lockingClause)
2118 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2121 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
2139 if (
stmt->sortClause ||
stmt->limitOffset ||
stmt->limitCount ||
2140 stmt->lockingClause ||
stmt->withClause)
2150 char selectName[32];
2170 NULL,
false,
false);
2182 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2183 errmsg(
"UNION/INTERSECT/EXCEPT member statement cannot refer to other relations of same query level"),
2199 *targetlist =
lappend(*targetlist, tle);
2206 snprintf(selectName,
sizeof(selectName),
"*SELECT* %d",
2219 return (
Node *) rtr;
2253 if (isTopLevel && recursive)
2269 (
errcode(ERRCODE_SYNTAX_ERROR),
2270 errmsg(
"each %s query must have the same number of columns",
2278 op->colTypmods =
NIL;
2279 op->colCollations =
NIL;
2280 op->groupClauses =
NIL;
2281 forboth(ltl, ltargetlist, rtl, rtargetlist)
2329 if (lcoltype != UNKNOWNOID)
2340 if (rcoltype != UNKNOWNOID)
2369 op->colTypes =
lappend_oid(op->colTypes, rescoltype);
2370 op->colTypmods =
lappend_int(op->colTypmods, rescoltypmod);
2371 op->colCollations =
lappend_oid(op->colCollations, rescolcoll);
2389 op->groupClauses =
lappend(op->groupClauses,
2405 rescolnode->
typeId = rescoltype;
2406 rescolnode->typeMod = rescoltypmod;
2407 rescolnode->collation = rescolcoll;
2408 rescolnode->
location = bestlocation;
2413 *targetlist =
lappend(*targetlist, restle);
2430 Query *leftmostQuery;
2445 Assert(leftmostQuery != NULL);
2461 Assert(!lefttle->resjunk);
2462 colName =
pstrdup(lefttle->resname);
2467 targetList =
lappend(targetList, tle);
2485 qry->isReturn =
true;
2521 if (
stmt->withClause)
2523 qry->hasRecursive =
stmt->withClause->recursive;
2529 stmt->relation->inh,
2610 tle->resname = NULL;
2613 if (orig_tl == NULL)
2614 elog(
ERROR,
"UPDATE target count mismatch --- internal error");
2618 origTarget->
name,
true);
2621 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2622 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2627 errhint(
"SET target columns cannot be qualified with the relation name.") : 0,
2639 orig_tl =
lnext(origTlist, orig_tl);
2641 if (orig_tl != NULL)
2642 elog(
ERROR,
"UPDATE target count mismatch --- internal error");
2656 int save_next_resno;
2658 if (returningList ==
NIL)
2680 (
errcode(ERRCODE_SYNTAX_ERROR),
2681 errmsg(
"RETURNING must have at least one column"),
2715 List *indirection =
stmt->indirection;
2716 int nnames =
stmt->nnames;
2721 Oid targetcollation;
2739 while (--nnames > 0 && indirection !=
NIL)
2744 elog(
ERROR,
"invalid name count in PLAssignStmt");
2783 (
errcode(ERRCODE_SYNTAX_ERROR),
2785 "assignment source returned %d columns",
2815 else if (targettype != type_id &&
2816 (targettype == RECORDOID ||
ISCOMPLEX(targettype)) &&
2817 (type_id == RECORDOID ||
ISCOMPLEX(type_id)))
2837 targettype, targettypmod,
2842 if (tle->
expr == NULL)
2844 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2845 errmsg(
"variable \"%s\" is of type %s"
2846 " but expression is of type %s",
2850 errhint(
"You will need to rewrite or cast the expression."),
2889 qry->hasDistinctOn =
false;
2898 qry->hasDistinctOn =
false;
2907 qry->hasDistinctOn =
true;
2968 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
2970 errmsg(
"cannot specify both %s and %s",
2971 "SCROLL",
"NO SCROLL")));
2976 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
2978 errmsg(
"cannot specify both %s and %s",
2979 "ASENSITIVE",
"INSENSITIVE")));
2988 elog(
ERROR,
"unexpected non-SELECT command in DECLARE CURSOR");
2995 if (query->hasModifyingCTE)
2997 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2998 errmsg(
"DECLARE CURSOR must not contain data-modifying statements in WITH")));
3003 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3006 errmsg(
"DECLARE CURSOR WITH HOLD ... %s is not supported",
3009 errdetail(
"Holdable cursors must be READ ONLY.")));
3014 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3017 errmsg(
"DECLARE SCROLL CURSOR ... %s is not supported",
3020 errdetail(
"Scrollable cursors must be READ ONLY.")));
3025 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
3028 errmsg(
"DECLARE INSENSITIVE CURSOR ... %s is not valid",
3031 errdetail(
"Insensitive cursors must be READ ONLY.")));
3056 bool generic_plan =
false;
3057 Oid *paramTypes = NULL;
3069 foreach(lc,
stmt->options)
3073 if (strcmp(opt->
defname,
"generic_plan") == 0)
3122 if (query->hasModifyingCTE)
3124 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3125 errmsg(
"materialized views must not use data-modifying statements in WITH")));
3134 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3135 errmsg(
"materialized views must not use temporary tables or views")));
3144 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3145 errmsg(
"materialized views may not be defined using bound parameters")));
3154 if (
stmt->into->rel->relpersistence == RELPERSISTENCE_UNLOGGED)
3156 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3157 errmsg(
"materialized views cannot be unlogged")));
3197 foreach(lc,
stmt->funccall->args)
3205 stmt->funccall->funcname,
3210 stmt->funccall->location);
3228 fexpr->funcresulttype,
3233 Anum_pg_proc_proargmodes,
3253 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
3259 foreach(lc, fexpr->
args)
3263 switch (argmodes[
i])
3266 case PROARGMODE_VARIADIC:
3269 case PROARGMODE_OUT:
3270 outargs =
lappend(outargs, n);
3272 case PROARGMODE_INOUT:
3278 elog(
ERROR,
"invalid argmode %c for procedure",
3284 fexpr->
args = inargs;
3287 stmt->funcexpr = fexpr;
3288 stmt->outargs = outargs;
3313 return "FOR KEY SHARE";
3317 return "FOR NO KEY UPDATE";
3319 return "FOR UPDATE";
3336 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3339 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
3343 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3346 errmsg(
"%s is not allowed with DISTINCT clause",
3350 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3353 errmsg(
"%s is not allowed with GROUP BY clause",
3357 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3360 errmsg(
"%s is not allowed with HAVING clause",
3364 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3367 errmsg(
"%s is not allowed with aggregate functions",
3369 if (qry->hasWindowFuncs)
3371 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3374 errmsg(
"%s is not allowed with window functions",
3376 if (qry->hasTargetSRFs)
3378 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3381 errmsg(
"%s is not allowed with set-returning functions in the target list",
3411 if (lockedRels ==
NIL)
3470 foreach(l, lockedRels)
3477 (
errcode(ERRCODE_SYNTAX_ERROR),
3480 errmsg(
"%s must specify unqualified relation names",
3488 char *rtename = rte->eref->aliasname;
3503 if (rte->alias == NULL)
3507 if (rte->join_using_alias == NULL)
3509 rtename = rte->join_using_alias->aliasname;
3516 if (strcmp(rtename, thisrel->
relname) == 0)
3541 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3544 errmsg(
"%s cannot be applied to a join",
3550 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3553 errmsg(
"%s cannot be applied to a function",
3559 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3562 errmsg(
"%s cannot be applied to a table function",
3568 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3571 errmsg(
"%s cannot be applied to VALUES",
3577 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3580 errmsg(
"%s cannot be applied to a WITH query",
3586 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3589 errmsg(
"%s cannot be applied to a named tuplestore",
3597 elog(
ERROR,
"unrecognized RTE type: %d",
3609 errmsg(
"relation \"%s\" in %s clause not found in FROM clause",
3631 qry->hasForUpdate =
true;
3670#ifdef DEBUG_NODE_TESTS_ENABLED
3680test_raw_expression_coverage(
Node *node,
void *
context)
3685 test_raw_expression_coverage,
void(* post_parse_analyze_hook_type)(ParseState *pstate, Query *query, JumbleState *jstate)
#define DatumGetArrayTypeP(X)
#define InvalidAttrNumber
void pgstat_report_query_id(uint64 query_id, bool force)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define Assert(condition)
List * expand_function_arguments(List *args, bool include_out_arguments, Oid result_type, HeapTuple func_tuple)
bool defGetBoolean(DefElem *def)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define HeapTupleIsValid(tuple)
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
List * list_copy(const List *oldlist)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * list_delete_last(List *list)
void list_free(List *list)
List * list_truncate(List *list, int new_size)
Alias * makeAlias(const char *aliasname, List *colnames)
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
FromExpr * makeFromExpr(List *fromlist, Node *quals)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
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)
#define raw_expression_tree_walker(n, w, c)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
void(* ParserSetupHook)(struct ParseState *pstate, void *arg)
void parseCheckAggregates(ParseState *pstate, Query *qry)
List * transformGroupClause(ParseState *pstate, List *grouplist, List **groupingSets, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
List * transformSortClause(ParseState *pstate, List *orderlist, List **targetlist, ParseExprKind exprKind, bool useSQL99)
List * transformDistinctOnClause(ParseState *pstate, List *distinctlist, List **targetlist, List *sortClause)
List * transformWindowDefinitions(ParseState *pstate, List *windowdefs, List **targetlist)
void transformFromClause(ParseState *pstate, List *frmList)
List * transformDistinctClause(ParseState *pstate, List **targetlist, List *sortClause, bool is_agg)
Node * transformLimitClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName, LimitOption limitOption)
void transformOnConflictArbiter(ParseState *pstate, OnConflictClause *onConflictClause, List **arbiterExpr, Node **arbiterWhere, Oid *constraint)
int setTargetTable(ParseState *pstate, RangeVar *relation, bool inh, bool alsoSource, AclMode requiredPerms)
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)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
void assign_list_collations(ParseState *pstate, List *exprs)
Oid select_common_collation(ParseState *pstate, List *exprs, bool none_ok)
void assign_query_collations(ParseState *pstate, Query *query)
void assign_expr_collations(ParseState *pstate, Node *expr)
void analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
List * transformWithClause(ParseState *pstate, WithClause *withClause)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
Node * ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, Node *last_srf, FuncCall *fn, bool proc_call, int location)
Query * transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
void free_parsestate(ParseState *pstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
@ EXPR_KIND_INSERT_TARGET
@ EXPR_KIND_UPDATE_TARGET
@ EXPR_KIND_SELECT_TARGET
@ EXPR_KIND_CALL_ARGUMENT
@ EXPR_KIND_UPDATE_SOURCE
@ EXPR_KIND_VALUES_SINGLE
struct ParseNamespaceColumn ParseNamespaceColumn
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
void check_variable_parameters(ParseState *pstate, Query *query)
bool query_contains_extern_params(Query *query)
void setup_parse_variable_parameters(ParseState *pstate, Oid **paramTypes, int *numParams)
void setup_parse_fixed_parameters(ParseState *pstate, const Oid *paramTypes, int numParams)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
List * expandNSItemVars(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location, List **colnames)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
ParseNamespaceItem * addRangeTableEntryForSubquery(ParseState *pstate, Query *subquery, Alias *alias, bool lateral, 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)
List * expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, bool require_col_privs, int location)
bool isQueryUsingTempRelation(Query *query)
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
ParseNamespaceItem * addRangeTableEntryForValues(ParseState *pstate, List *exprs, List *coltypes, List *coltypmods, List *colcollations, Alias *alias, bool lateral, bool inFromCl)
Expr * transformAssignedExpr(ParseState *pstate, Expr *expr, ParseExprKind exprKind, const char *colname, int attrno, List *indirection, int location)
List * transformExpressionList(ParseState *pstate, List *exprlist, ParseExprKind exprKind, bool allowDefault)
Node * transformAssignmentIndirection(ParseState *pstate, Node *basenode, const char *targetName, bool targetIsSubscripting, Oid targetTypeId, int32 targetTypMod, Oid targetCollation, List *indirection, ListCell *indirection_cell, Node *rhs, CoercionContext ccontext, int location)
void updateTargetListEntry(ParseState *pstate, TargetEntry *tle, char *colname, int attrno, List *indirection, int location)
List * transformTargetList(ParseState *pstate, List *targetlist, ParseExprKind exprKind)
void resolveTargetListUnknowns(ParseState *pstate, List *targetlist)
void markTargetListOrigins(ParseState *pstate, List *targetlist)
List * checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
#define ISCOMPLEX(typeid)
#define CURSOR_OPT_INSENSITIVE
#define CURSOR_OPT_SCROLL
#define ACL_SELECT_FOR_UPDATE
#define CURSOR_OPT_ASENSITIVE
#define CURSOR_OPT_NO_SCROLL
static OnConflictExpr * transformOnConflictClause(ParseState *pstate, OnConflictClause *onConflictClause)
static Query * transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
static void transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc, bool pushedDown)
static void setQueryLocationAndLength(ParseState *pstate, Query *qry, Node *parseTree)
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
void CheckSelectLocking(Query *qry, LockClauseStrength strength)
SortGroupClause * makeSortGroupClauseForSetOp(Oid rescoltype, bool require_hash)
static Node * transformSetOperationTree(ParseState *pstate, SelectStmt *stmt, bool isTopLevel, List **targetlist)
Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
bool analyze_requires_snapshot(RawStmt *parseTree)
List * transformInsertRow(ParseState *pstate, List *exprlist, List *stmtcols, List *icolumns, List *attrnos, bool strip_indirection)
void applyLockingClause(Query *qry, Index rtindex, LockClauseStrength strength, LockWaitPolicy waitPolicy, bool pushedDown)
static void determineRecursiveColTypes(ParseState *pstate, Node *larg, List *nrtargetlist)
static Query * transformReturnStmt(ParseState *pstate, ReturnStmt *stmt)
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
post_parse_analyze_hook_type post_parse_analyze_hook
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
List * transformUpdateTargetList(ParseState *pstate, List *origTlist)
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
List * transformReturningList(ParseState *pstate, List *returningList, ParseExprKind exprKind)
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
const char * LCS_asString(LockClauseStrength strength)
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
Query * parse_sub_analyze(Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
List * BuildOnConflictExcludedTargetlist(Relation targetrel, Index exclRelIndex)
static int count_rowexpr_columns(ParseState *pstate, Node *expr)
Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
bool stmt_requires_parse_analysis(RawStmt *parseTree)
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Query * transformStmt(ParseState *pstate, Node *parseTree)
#define rt_fetch(rangetable_index, rangetable)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define forboth(cell1, list1, cell2, list2)
#define forthree(cell1, list1, cell2, list2, cell3, list3)
static void * list_nth(const List *list, int n)
#define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
#define ERRCODE_UNDEFINED_TABLE
static Datum ObjectIdGetDatum(Oid X)
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
void check_stack_depth(void)
LockClauseStrength strength
LockWaitPolicy waitPolicy
RTEPermissionInfo * p_perminfo
ParseNamespaceItem * p_target_nsitem
ParseExprKind p_expr_kind
bool p_locked_from_parent
ParseParamRefHook p_paramref_hook
QueryEnvironment * p_queryEnv
const char * p_sourcetext
Relation p_target_relation
CommonTableExpr * p_parent_cte
LockClauseStrength strength
LockWaitPolicy waitPolicy
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
String * makeString(char *str)
bool contain_vars_of_level(Node *node, int levelsup)
int locate_var_of_level(Node *node, int levelsup)