70 bool isTopLevel,
List **targetlist);
87 #ifdef RAW_EXPRESSION_COVERAGE_TEST
88 static bool test_raw_expression_coverage(
Node *node,
void *
context);
105 const Oid *paramTypes,
int numParams,
112 Assert(sourceText != NULL);
127 (*post_parse_analyze_hook) (pstate, query, jstate);
145 Oid **paramTypes,
int *numParams,
152 Assert(sourceText != NULL);
169 (*post_parse_analyze_hook) (pstate, query, jstate);
187 void *parserSetupArg,
194 Assert(sourceText != NULL);
198 (*parserSetup) (pstate, parserSetupArg);
206 (*post_parse_analyze_hook) (pstate, query, jstate);
223 bool locked_from_parent,
224 bool resolve_unknowns)
256 result->stmt_len = parseTree->
stmt_len;
283 if (
stmt->intoClause)
287 ctas->
query = parseTree;
297 stmt->intoClause = NULL;
299 parseTree = (
Node *) ctas;
320 #ifdef RAW_EXPRESSION_COVERAGE_TEST
328 (void) test_raw_expression_coverage(parseTree, NULL);
386 case T_DeclareCursorStmt:
396 case T_CreateTableAsStmt:
420 result->canSetTag =
true;
463 case T_DeclareCursorStmt:
465 case T_CreateTableAsStmt:
517 if (
stmt->withClause)
519 qry->hasRecursive =
stmt->withClause->recursive;
585 bool isGeneralSelect;
587 List *sub_rteperminfos;
596 bool isOnConflictUpdate;
606 if (
stmt->withClause)
608 qry->hasRecursive =
stmt->withClause->recursive;
613 qry->override =
stmt->override;
615 isOnConflictUpdate = (
stmt->onConflictClause &&
627 isGeneralSelect = (selectStmt && (selectStmt->
valuesLists ==
NIL ||
655 sub_rteperminfos =
NIL;
666 if (isOnConflictUpdate)
669 false,
false, targetPerms);
678 if (selectStmt == NULL)
687 else if (isGeneralSelect)
727 elog(
ERROR,
"unexpected non-SELECT command in INSERT ... SELECT");
773 exprList =
lappend(exprList, expr);
794 int sublist_length = -1;
795 bool lateral =
false;
797 Assert(selectStmt->intoClause == NULL);
799 foreach(lc, selectStmt->valuesLists)
815 if (sublist_length < 0)
823 (
errcode(ERRCODE_SYNTAX_ERROR),
824 errmsg(
"VALUES lists must all be the same length"),
858 exprsLists =
lappend(exprsLists, sublist);
891 coltypes, coltypmods, colcollations,
892 NULL, lateral,
true);
916 List *valuesLists = selectStmt->valuesLists;
919 Assert(selectStmt->intoClause == NULL);
941 perminfo = pstate->p_target_nsitem->p_perminfo;
942 qry->targetList =
NIL;
944 forthree(lc, exprList, icols, icolumns, attnos, attrnos)
955 qry->targetList =
lappend(qry->targetList, tle);
966 if (
stmt->onConflictClause ||
stmt->returningList)
968 pstate->p_namespace =
NIL;
974 if (
stmt->onConflictClause)
976 stmt->onConflictClause);
979 if (
stmt->returningList)
985 qry->rtable = pstate->p_rtable;
986 qry->rteperminfos = pstate->p_rteperminfos;
989 qry->hasTargetSRFs = pstate->p_hasTargetSRFs;
990 qry->hasSubLinks = pstate->p_hasSubLinks;
1010 bool strip_indirection)
1026 (
errcode(ERRCODE_SYNTAX_ERROR),
1027 errmsg(
"INSERT has more expressions than target columns"),
1031 if (stmtcols !=
NIL &&
1044 (
errcode(ERRCODE_SYNTAX_ERROR),
1045 errmsg(
"INSERT has more target columns than expressions"),
1049 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),
1059 forthree(lc, exprlist, icols, icolumns, attnos, attrnos)
1072 if (strip_indirection)
1081 Expr *subexpr = expr;
1107 result =
lappend(result, expr);
1124 Oid arbiterConstraint;
1126 Node *onConflictWhere = NULL;
1127 int exclRelIndex = 0;
1147 exclRte = exclNSItem->
p_rte;
1155 exclRte->relkind = RELKIND_COMPOSITE_TYPE;
1164 &arbiterWhere, &arbiterConstraint);
1242 if (attr->attisdropped)
1253 var =
makeVar(exclRelIndex, attno + 1,
1254 attr->atttypid, attr->atttypmod,
1276 targetrel->
rd_rel->reltype,
1306 if (
attnum > 0 && var->vartype == RECORDOID)
1317 if (ste == NULL || ste->resjunk)
1346 if (
stmt->withClause)
1348 qry->hasRecursive =
stmt->withClause->recursive;
1354 if (
stmt->intoClause)
1356 (
errcode(ERRCODE_SYNTAX_ERROR),
1357 errmsg(
"SELECT ... INTO is not allowed here"),
1406 if (
stmt->distinctClause ==
NIL)
1409 qry->hasDistinctOn =
false;
1418 qry->hasDistinctOn =
false;
1424 stmt->distinctClause,
1427 qry->hasDistinctOn =
true;
1457 foreach(l,
stmt->lockingClause)
1487 List **colexprs = NULL;
1488 int sublist_length = -1;
1489 bool lateral =
false;
1509 if (
stmt->withClause)
1511 qry->hasRecursive =
stmt->withClause->recursive;
1523 foreach(lc,
stmt->valuesLists)
1539 if (sublist_length < 0)
1549 (
errcode(ERRCODE_SYNTAX_ERROR),
1550 errmsg(
"VALUES lists must all be the same length"),
1557 foreach(lc2, sublist)
1561 colexprs[
i] =
lappend(colexprs[
i], col);
1586 for (
i = 0;
i < sublist_length;
i++)
1594 foreach(lc, colexprs[
i])
1599 lfirst(lc) = (
void *) col;
1607 colcollations =
lappend_oid(colcollations, colcoll);
1613 for (
i = 0;
i < sublist_length;
i++)
1615 forboth(lc, colexprs[
i], lc2, exprsLists)
1620 sublist =
lappend(sublist, col);
1640 coltypes, coltypmods, colcollations,
1641 NULL, lateral,
true);
1668 if (
stmt->lockingClause)
1670 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1673 errmsg(
"%s cannot be applied to VALUES",
1704 Query *leftmostQuery;
1709 List *lockingClause;
1720 int sv_rtable_length;
1736 leftmostSelect =
stmt->larg;
1737 while (leftmostSelect && leftmostSelect->
op !=
SETOP_NONE)
1738 leftmostSelect = leftmostSelect->
larg;
1740 leftmostSelect->
larg == NULL);
1743 (
errcode(ERRCODE_SYNTAX_ERROR),
1744 errmsg(
"SELECT ... INTO is not allowed here"),
1753 sortClause =
stmt->sortClause;
1754 limitOffset =
stmt->limitOffset;
1755 limitCount =
stmt->limitCount;
1756 lockingClause =
stmt->lockingClause;
1757 withClause =
stmt->withClause;
1760 stmt->limitOffset = NULL;
1761 stmt->limitCount = NULL;
1763 stmt->withClause = NULL;
1768 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1771 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
1773 linitial(lockingClause))->strength))));
1778 qry->hasRecursive = withClause->
recursive;
1794 node = sostmt->
larg;
1800 Assert(leftmostQuery != NULL);
1820 forfour(lct, sostmt->colTypes,
1821 lcm, sostmt->colTypmods,
1822 lcc, sostmt->colCollations,
1833 Assert(!lefttle->resjunk);
1834 colName =
pstrdup(lefttle->resname);
1847 targetvars =
lappend(targetvars, var);
1849 sortnscolumns[sortcolindex].
p_varno = leftmostRTI;
1851 sortnscolumns[sortcolindex].
p_vartype = colType;
1852 sortnscolumns[sortcolindex].
p_vartypmod = colTypmod;
1853 sortnscolumns[sortcolindex].
p_varcollid = colCollation;
1854 sortnscolumns[sortcolindex].
p_varnosyn = leftmostRTI;
1910 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1911 errmsg(
"invalid UNION/INTERSECT/EXCEPT ORDER BY clause"),
1912 errdetail(
"Only result column names can be used, not expressions or functions."),
1913 errhint(
"Add the expression/function to every SELECT, or move the UNION into a FROM clause."),
1934 foreach(l, lockingClause)
1966 &sortop, &eqop, NULL,
1975 if (require_hash && (rescoltype == RECORDOID || rescoltype == RECORDARRAYOID))
1983 grpcl->hashable = hashable;
2004 bool isTopLevel,
List **targetlist)
2016 if (
stmt->intoClause)
2018 (
errcode(ERRCODE_SYNTAX_ERROR),
2019 errmsg(
"INTO is only allowed on first SELECT of UNION/INTERSECT/EXCEPT"),
2024 if (
stmt->lockingClause)
2026 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2029 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
2047 if (
stmt->sortClause ||
stmt->limitOffset ||
stmt->limitCount ||
2048 stmt->lockingClause ||
stmt->withClause)
2058 char selectName[32];
2078 NULL,
false,
false);
2090 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2091 errmsg(
"UNION/INTERSECT/EXCEPT member statement cannot refer to other relations of same query level"),
2107 *targetlist =
lappend(*targetlist, tle);
2114 snprintf(selectName,
sizeof(selectName),
"*SELECT* %d",
2127 return (
Node *) rtr;
2161 if (isTopLevel && recursive)
2177 (
errcode(ERRCODE_SYNTAX_ERROR),
2178 errmsg(
"each %s query must have the same number of columns",
2186 op->colTypmods =
NIL;
2187 op->colCollations =
NIL;
2188 op->groupClauses =
NIL;
2189 forboth(ltl, ltargetlist, rtl, rtargetlist)
2237 if (lcoltype != UNKNOWNOID)
2248 if (rcoltype != UNKNOWNOID)
2277 op->colTypes =
lappend_oid(op->colTypes, rescoltype);
2278 op->colTypmods =
lappend_int(op->colTypmods, rescoltypmod);
2279 op->colCollations =
lappend_oid(op->colCollations, rescolcoll);
2297 op->groupClauses =
lappend(op->groupClauses,
2313 rescolnode->
typeId = rescoltype;
2314 rescolnode->typeMod = rescoltypmod;
2315 rescolnode->collation = rescolcoll;
2316 rescolnode->
location = bestlocation;
2321 *targetlist =
lappend(*targetlist, restle);
2338 Query *leftmostQuery;
2353 Assert(leftmostQuery != NULL);
2369 Assert(!lefttle->resjunk);
2370 colName =
pstrdup(lefttle->resname);
2375 targetList =
lappend(targetList, tle);
2393 qry->isReturn =
true;
2429 if (
stmt->withClause)
2431 qry->hasRecursive =
stmt->withClause->recursive;
2437 stmt->relation->inh,
2518 tle->resname = NULL;
2521 if (orig_tl == NULL)
2522 elog(
ERROR,
"UPDATE target count mismatch --- internal error");
2526 origTarget->
name,
true);
2529 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2530 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2535 errhint(
"SET target columns cannot be qualified with the relation name.") : 0,
2547 orig_tl =
lnext(origTlist, orig_tl);
2549 if (orig_tl != NULL)
2550 elog(
ERROR,
"UPDATE target count mismatch --- internal error");
2564 int save_next_resno;
2566 if (returningList ==
NIL)
2588 (
errcode(ERRCODE_SYNTAX_ERROR),
2589 errmsg(
"RETURNING must have at least one column"),
2623 List *indirection =
stmt->indirection;
2624 int nnames =
stmt->nnames;
2629 Oid targetcollation;
2647 while (--nnames > 0 && indirection !=
NIL)
2652 elog(
ERROR,
"invalid name count in PLAssignStmt");
2691 (
errcode(ERRCODE_SYNTAX_ERROR),
2693 "assignment source returned %d columns",
2723 else if (targettype != type_id &&
2724 (targettype == RECORDOID ||
ISCOMPLEX(targettype)) &&
2725 (type_id == RECORDOID ||
ISCOMPLEX(type_id)))
2745 targettype, targettypmod,
2750 if (tle->
expr == NULL)
2752 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2753 errmsg(
"variable \"%s\" is of type %s"
2754 " but expression is of type %s",
2758 errhint(
"You will need to rewrite or cast the expression."),
2797 qry->hasDistinctOn =
false;
2806 qry->hasDistinctOn =
false;
2815 qry->hasDistinctOn =
true;
2876 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
2878 errmsg(
"cannot specify both %s and %s",
2879 "SCROLL",
"NO SCROLL")));
2884 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
2886 errmsg(
"cannot specify both %s and %s",
2887 "ASENSITIVE",
"INSENSITIVE")));
2896 elog(
ERROR,
"unexpected non-SELECT command in DECLARE CURSOR");
2903 if (query->hasModifyingCTE)
2905 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2906 errmsg(
"DECLARE CURSOR must not contain data-modifying statements in WITH")));
2911 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2914 errmsg(
"DECLARE CURSOR WITH HOLD ... %s is not supported",
2917 errdetail(
"Holdable cursors must be READ ONLY.")));
2922 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2925 errmsg(
"DECLARE SCROLL CURSOR ... %s is not supported",
2928 errdetail(
"Scrollable cursors must be READ ONLY.")));
2933 (
errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
2936 errmsg(
"DECLARE INSENSITIVE CURSOR ... %s is not valid",
2939 errdetail(
"Insensitive cursors must be READ ONLY.")));
2964 bool generic_plan =
false;
2965 Oid *paramTypes = NULL;
2977 foreach(lc,
stmt->options)
2981 if (strcmp(opt->
defname,
"generic_plan") == 0)
3030 if (query->hasModifyingCTE)
3032 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3033 errmsg(
"materialized views must not use data-modifying statements in WITH")));
3042 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3043 errmsg(
"materialized views must not use temporary tables or views")));
3052 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3053 errmsg(
"materialized views may not be defined using bound parameters")));
3062 if (
stmt->into->rel->relpersistence == RELPERSISTENCE_UNLOGGED)
3064 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3065 errmsg(
"materialized views cannot be unlogged")));
3105 foreach(lc,
stmt->funccall->args)
3113 stmt->funccall->funcname,
3118 stmt->funccall->location);
3136 fexpr->funcresulttype,
3141 Anum_pg_proc_proargmodes,
3161 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
3167 foreach(lc, fexpr->
args)
3171 switch (argmodes[
i])
3174 case PROARGMODE_VARIADIC:
3177 case PROARGMODE_OUT:
3178 outargs =
lappend(outargs, n);
3180 case PROARGMODE_INOUT:
3186 elog(
ERROR,
"invalid argmode %c for procedure",
3192 fexpr->
args = inargs;
3195 stmt->funcexpr = fexpr;
3196 stmt->outargs = outargs;
3221 return "FOR KEY SHARE";
3225 return "FOR NO KEY UPDATE";
3227 return "FOR UPDATE";
3244 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3247 errmsg(
"%s is not allowed with UNION/INTERSECT/EXCEPT",
3251 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3254 errmsg(
"%s is not allowed with DISTINCT clause",
3258 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3261 errmsg(
"%s is not allowed with GROUP BY clause",
3265 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3268 errmsg(
"%s is not allowed with HAVING clause",
3272 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3275 errmsg(
"%s is not allowed with aggregate functions",
3277 if (qry->hasWindowFuncs)
3279 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3282 errmsg(
"%s is not allowed with window functions",
3284 if (qry->hasTargetSRFs)
3286 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3289 errmsg(
"%s is not allowed with set-returning functions in the target list",
3319 if (lockedRels ==
NIL)
3378 foreach(l, lockedRels)
3385 (
errcode(ERRCODE_SYNTAX_ERROR),
3388 errmsg(
"%s must specify unqualified relation names",
3396 char *rtename = rte->eref->aliasname;
3411 if (rte->alias == NULL)
3415 if (rte->join_using_alias == NULL)
3417 rtename = rte->join_using_alias->aliasname;
3424 if (strcmp(rtename, thisrel->
relname) == 0)
3449 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3452 errmsg(
"%s cannot be applied to a join",
3458 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3461 errmsg(
"%s cannot be applied to a function",
3467 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3470 errmsg(
"%s cannot be applied to a table function",
3476 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3479 errmsg(
"%s cannot be applied to VALUES",
3485 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3488 errmsg(
"%s cannot be applied to a WITH query",
3494 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3497 errmsg(
"%s cannot be applied to a named tuplestore",
3505 elog(
ERROR,
"unrecognized RTE type: %d",
3517 errmsg(
"relation \"%s\" in %s clause not found in FROM clause",
3539 qry->hasForUpdate =
true;
3586 #ifdef RAW_EXPRESSION_COVERAGE_TEST
3589 test_raw_expression_coverage(
Node *node,
void *
context)
3594 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)
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)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * list_truncate(List *list, int new_size)
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)
void list_free(List *list)
List * list_delete_last(List *list)
Alias * makeAlias(const char *aliasname, List *colnames)
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
FromExpr * makeFromExpr(List *fromlist, Node *quals)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
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 * transformWindowDefinitions(ParseState *pstate, List *windowdefs, List **targetlist)
List * transformDistinctOnClause(ParseState *pstate, List *distinctlist, List **targetlist, List *sortClause)
Node * transformLimitClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName, LimitOption limitOption)
List * transformSortClause(ParseState *pstate, List *orderlist, List **targetlist, ParseExprKind exprKind, bool useSQL99)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
void transformFromClause(ParseState *pstate, List *frmList)
List * transformGroupClause(ParseState *pstate, List *grouplist, List **groupingSets, List **targetlist, List *sortClause, ParseExprKind exprKind, bool useSQL99)
List * transformDistinctClause(ParseState *pstate, List **targetlist, List *sortClause, bool is_agg)
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)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
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)
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)
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
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)
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
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 * addRangeTableEntryForValues(ParseState *pstate, List *exprs, List *coltypes, List *coltypmods, List *colcollations, Alias *alias, bool lateral, bool inFromCl)
List * expandNSItemVars(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location, List **colnames)
List * expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, bool require_col_privs, int location)
bool isQueryUsingTempRelation(Query *query)
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
List * transformTargetList(ParseState *pstate, List *targetlist, ParseExprKind exprKind)
Expr * transformAssignedExpr(ParseState *pstate, Expr *expr, ParseExprKind exprKind, const char *colname, int attrno, List *indirection, int location)
void updateTargetListEntry(ParseState *pstate, TargetEntry *tle, char *colname, int attrno, List *indirection, int location)
void resolveTargetListUnknowns(ParseState *pstate, List *targetlist)
void markTargetListOrigins(ParseState *pstate, List *targetlist)
List * checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
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)
List * transformExpressionList(ParseState *pstate, List *exprlist, ParseExprKind exprKind, bool allowDefault)
#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)
Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
List * transformUpdateTargetList(ParseState *pstate, List *origTlist)
Query * parse_sub_analyze(Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
static Query * transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
static void transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc, bool pushedDown)
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
List * transformInsertRow(ParseState *pstate, List *exprlist, List *stmtcols, List *icolumns, List *attrnos, bool strip_indirection)
void CheckSelectLocking(Query *qry, LockClauseStrength strength)
static Node * transformSetOperationTree(ParseState *pstate, SelectStmt *stmt, bool isTopLevel, List **targetlist)
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
bool analyze_requires_snapshot(RawStmt *parseTree)
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)
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
List * BuildOnConflictExcludedTargetlist(Relation targetrel, Index exclRelIndex)
SortGroupClause * makeSortGroupClauseForSetOp(Oid rescoltype, bool require_hash)
const char * LCS_asString(LockClauseStrength strength)
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Query * transformStmt(ParseState *pstate, Node *parseTree)
Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
static int count_rowexpr_columns(ParseState *pstate, Node *expr)
List * transformReturningList(ParseState *pstate, List *returningList, ParseExprKind exprKind)
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const 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)
#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 ListCell * list_head(const List *l)
#define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4)
static void * list_nth(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
#define ERRCODE_UNDEFINED_TABLE
void check_stack_depth(void)
static Datum ObjectIdGetDatum(Oid X)
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
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)
#define TupleDescAttr(tupdesc, i)
String * makeString(char *str)
bool contain_vars_of_level(Node *node, int levelsup)
int locate_var_of_level(Node *node, int levelsup)