PostgreSQL Source Code git master
Loading...
Searching...
No Matches
analyze.h File Reference
#include "nodes/params.h"
#include "nodes/queryjumble.h"
#include "parser/parse_node.h"
Include dependency graph for analyze.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* post_parse_analyze_hook_type) (ParseState *pstate, Query *query, const JumbleState *jstate)
 

Functions

Queryparse_analyze_fixedparams (RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
 
Queryparse_analyze_varparams (RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
 
Queryparse_analyze_withcb (RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
 
Queryparse_sub_analyze (Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
 
ListtransformInsertRow (ParseState *pstate, List *exprlist, List *stmtcols, List *icolumns, List *attrnos, bool strip_indirection)
 
ListtransformUpdateTargetList (ParseState *pstate, List *origTlist, ForPortionOfExpr *forPortionOf)
 
void transformReturningClause (ParseState *pstate, Query *qry, ReturningClause *returningClause, ParseExprKind exprKind)
 
QuerytransformTopLevelStmt (ParseState *pstate, RawStmt *parseTree)
 
QuerytransformStmt (ParseState *pstate, Node *parseTree)
 
bool stmt_requires_parse_analysis (RawStmt *parseTree)
 
bool analyze_requires_snapshot (RawStmt *parseTree)
 
bool query_requires_rewrite_plan (Query *query)
 
const charLCS_asString (LockClauseStrength strength)
 
void CheckSelectLocking (Query *qry, LockClauseStrength strength)
 
void applyLockingClause (Query *qry, Index rtindex, LockClauseStrength strength, LockWaitPolicy waitPolicy, bool pushedDown)
 
ListBuildOnConflictExcludedTargetlist (Relation targetrel, Index exclRelIndex)
 
SortGroupClausemakeSortGroupClauseForSetOp (Oid rescoltype, bool require_hash)
 
void constructSetOpTargetlist (ParseState *pstate, SetOperationStmt *op, const List *ltargetlist, const List *rtargetlist, List **targetlist, const char *context, bool recursive)
 

Variables

PGDLLIMPORT post_parse_analyze_hook_type post_parse_analyze_hook
 

Typedef Documentation

◆ post_parse_analyze_hook_type

typedef void(* post_parse_analyze_hook_type) (ParseState *pstate, Query *query, const JumbleState *jstate)

Definition at line 22 of file analyze.h.

Function Documentation

◆ analyze_requires_snapshot()

bool analyze_requires_snapshot ( RawStmt parseTree)
extern

Definition at line 514 of file analyze.c.

515{
516 /*
517 * Currently, this should return true in exactly the same cases that
518 * stmt_requires_parse_analysis() does, so we just invoke that function
519 * rather than duplicating it. We keep the two entry points separate for
520 * clarity of callers, since from the callers' standpoint these are
521 * different conditions.
522 *
523 * While there may someday be a statement type for which transformStmt()
524 * does something nontrivial and yet no snapshot is needed for that
525 * processing, it seems likely that making such a choice would be fragile.
526 * If you want to install an exception, document the reasoning for it in a
527 * comment.
528 */
530}
bool stmt_requires_parse_analysis(RawStmt *parseTree)
Definition analyze.c:470
static int fb(int x)

References fb(), and stmt_requires_parse_analysis().

Referenced by BuildingPlanRequiresSnapshot(), exec_bind_message(), exec_parse_message(), and exec_simple_query().

◆ applyLockingClause()

void applyLockingClause ( Query qry,
Index  rtindex,
LockClauseStrength  strength,
LockWaitPolicy  waitPolicy,
bool  pushedDown 
)
extern

Definition at line 4042 of file analyze.c.

4045{
4046 RowMarkClause *rc;
4047
4048 Assert(strength != LCS_NONE); /* else caller error */
4049
4050 /* If it's an explicit clause, make sure hasForUpdate gets set */
4051 if (!pushedDown)
4052 qry->hasForUpdate = true;
4053
4054 /* Check for pre-existing entry for same rtindex */
4055 if ((rc = get_parse_rowmark(qry, rtindex)) != NULL)
4056 {
4057 /*
4058 * If the same RTE is specified with more than one locking strength,
4059 * use the strongest. (Reasonable, since you can't take both a shared
4060 * and exclusive lock at the same time; it'll end up being exclusive
4061 * anyway.)
4062 *
4063 * Similarly, if the same RTE is specified with more than one lock
4064 * wait policy, consider that NOWAIT wins over SKIP LOCKED, which in
4065 * turn wins over waiting for the lock (the default). This is a bit
4066 * more debatable but raising an error doesn't seem helpful. (Consider
4067 * for instance SELECT FOR UPDATE NOWAIT from a view that internally
4068 * contains a plain FOR UPDATE spec.) Having NOWAIT win over SKIP
4069 * LOCKED is reasonable since the former throws an error in case of
4070 * coming across a locked tuple, which may be undesirable in some
4071 * cases but it seems better than silently returning inconsistent
4072 * results.
4073 *
4074 * And of course pushedDown becomes false if any clause is explicit.
4075 */
4076 rc->strength = Max(rc->strength, strength);
4077 rc->waitPolicy = Max(rc->waitPolicy, waitPolicy);
4078 rc->pushedDown &= pushedDown;
4079 return;
4080 }
4081
4082 /* Make a new RowMarkClause */
4083 rc = makeNode(RowMarkClause);
4084 rc->rti = rtindex;
4085 rc->strength = strength;
4086 rc->waitPolicy = waitPolicy;
4087 rc->pushedDown = pushedDown;
4088 qry->rowMarks = lappend(qry->rowMarks, rc);
4089}
#define Max(x, y)
Definition c.h:1144
#define Assert(condition)
Definition c.h:1002
List * lappend(List *list, void *datum)
Definition list.c:339
@ LCS_NONE
Definition lockoptions.h:23
#define makeNode(_type_)
Definition nodes.h:159
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
List * rowMarks
Definition parsenodes.h:239
LockClauseStrength strength
LockWaitPolicy waitPolicy

References Assert, fb(), get_parse_rowmark(), lappend(), LCS_NONE, makeNode, Max, RowMarkClause::pushedDown, Query::rowMarks, RowMarkClause::rti, RowMarkClause::strength, and RowMarkClause::waitPolicy.

Referenced by markQueryForLocking(), and transformLockingClause().

◆ BuildOnConflictExcludedTargetlist()

List * BuildOnConflictExcludedTargetlist ( Relation  targetrel,
Index  exclRelIndex 
)
extern

Definition at line 1624 of file analyze.c.

1626{
1627 List *result = NIL;
1628 int attno;
1629 Var *var;
1630 TargetEntry *te;
1631
1632 /*
1633 * Note that resnos of the tlist must correspond to attnos of the
1634 * underlying relation, hence we need entries for dropped columns too.
1635 */
1636 for (attno = 0; attno < RelationGetNumberOfAttributes(targetrel); attno++)
1637 {
1638 Form_pg_attribute attr = TupleDescAttr(targetrel->rd_att, attno);
1639 char *name;
1640
1641 if (attr->attisdropped)
1642 {
1643 /*
1644 * can't use atttypid here, but it doesn't really matter what type
1645 * the Const claims to be.
1646 */
1647 var = (Var *) makeNullConst(INT4OID, -1, InvalidOid);
1648 name = NULL;
1649 }
1650 else
1651 {
1652 var = makeVar(exclRelIndex, attno + 1,
1653 attr->atttypid, attr->atttypmod,
1654 attr->attcollation,
1655 0);
1656 name = pstrdup(NameStr(attr->attname));
1657 }
1658
1659 te = makeTargetEntry((Expr *) var,
1660 attno + 1,
1661 name,
1662 false);
1663
1664 result = lappend(result, te);
1665 }
1666
1667 /*
1668 * Add a whole-row-Var entry to support references to "EXCLUDED.*". Like
1669 * the other entries in the EXCLUDED tlist, its resno must match the Var's
1670 * varattno, else the wrong things happen while resolving references in
1671 * setrefs.c. This is against normal conventions for targetlists, but
1672 * it's okay since we don't use this as a real tlist.
1673 */
1674 var = makeVar(exclRelIndex, InvalidAttrNumber,
1675 targetrel->rd_rel->reltype,
1676 -1, InvalidOid, 0);
1677 te = makeTargetEntry((Expr *) var, InvalidAttrNumber, NULL, true);
1678 result = lappend(result, te);
1679
1680 return result;
1681}
#define InvalidAttrNumber
Definition attnum.h:23
#define NameStr(name)
Definition c.h:894
uint32 result
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition makefuncs.c:66
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Definition makefuncs.c:388
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Definition makefuncs.c:289
char * pstrdup(const char *in)
Definition mcxt.c:1910
FormData_pg_attribute * Form_pg_attribute
#define NIL
Definition pg_list.h:68
#define InvalidOid
#define RelationGetNumberOfAttributes(relation)
Definition rel.h:522
Definition pg_list.h:54
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178
const char * name

References fb(), InvalidAttrNumber, InvalidOid, lappend(), makeNullConst(), makeTargetEntry(), makeVar(), name, NameStr, NIL, pstrdup(), RelationGetNumberOfAttributes, result, and TupleDescAttr().

Referenced by rewriteTargetView(), and transformOnConflictClause().

◆ CheckSelectLocking()

void CheckSelectLocking ( Query qry,
LockClauseStrength  strength 
)
extern

Definition at line 3742 of file analyze.c.

3743{
3744 Assert(strength != LCS_NONE); /* else caller error */
3745
3746 if (qry->setOperations)
3747 ereport(ERROR,
3749 /*------
3750 translator: %s is a SQL row locking clause such as FOR UPDATE */
3751 errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
3752 LCS_asString(strength))));
3753 if (qry->distinctClause != NIL)
3754 ereport(ERROR,
3756 /*------
3757 translator: %s is a SQL row locking clause such as FOR UPDATE */
3758 errmsg("%s is not allowed with DISTINCT clause",
3759 LCS_asString(strength))));
3760 if (qry->groupClause != NIL || qry->groupingSets != NIL)
3761 ereport(ERROR,
3763 /*------
3764 translator: %s is a SQL row locking clause such as FOR UPDATE */
3765 errmsg("%s is not allowed with GROUP BY clause",
3766 LCS_asString(strength))));
3767 if (qry->havingQual != NULL)
3768 ereport(ERROR,
3770 /*------
3771 translator: %s is a SQL row locking clause such as FOR UPDATE */
3772 errmsg("%s is not allowed with HAVING clause",
3773 LCS_asString(strength))));
3774 if (qry->hasAggs)
3775 ereport(ERROR,
3777 /*------
3778 translator: %s is a SQL row locking clause such as FOR UPDATE */
3779 errmsg("%s is not allowed with aggregate functions",
3780 LCS_asString(strength))));
3781 if (qry->hasWindowFuncs)
3782 ereport(ERROR,
3784 /*------
3785 translator: %s is a SQL row locking clause such as FOR UPDATE */
3786 errmsg("%s is not allowed with window functions",
3787 LCS_asString(strength))));
3788 if (qry->hasTargetSRFs)
3789 ereport(ERROR,
3791 /*------
3792 translator: %s is a SQL row locking clause such as FOR UPDATE */
3793 errmsg("%s is not allowed with set-returning functions in the target list",
3794 LCS_asString(strength))));
3795}
int errcode(int sqlerrcode)
Definition elog.c:875
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
static char * errmsg
const char * LCS_asString(LockClauseStrength strength)
Definition analyze.c:3717
Node * setOperations
Definition parsenodes.h:241
List * groupClause
Definition parsenodes.h:221
Node * havingQual
Definition parsenodes.h:227
List * groupingSets
Definition parsenodes.h:225
List * distinctClause
Definition parsenodes.h:231

References Assert, Query::distinctClause, ereport, errcode(), errmsg, ERROR, fb(), Query::groupClause, Query::groupingSets, Query::havingQual, LCS_asString(), LCS_NONE, NIL, and Query::setOperations.

Referenced by preprocess_rowmarks(), and transformLockingClause().

◆ constructSetOpTargetlist()

void constructSetOpTargetlist ( ParseState pstate,
SetOperationStmt op,
const List ltargetlist,
const List rtargetlist,
List **  targetlist,
const char context,
bool  recursive 
)
extern

Definition at line 2605 of file analyze.c.

2608{
2609 ListCell *ltl;
2610 ListCell *rtl;
2611
2612 /*
2613 * Verify that the two children have the same number of non-junk columns,
2614 * and determine the types of the merged output columns.
2615 */
2617 ereport(ERROR,
2619 errmsg("each %s query must have the same number of columns",
2620 context),
2621 parser_errposition(pstate,
2622 exprLocation((const Node *) rtargetlist))));
2623
2624 if (targetlist)
2625 *targetlist = NIL;
2626 op->colTypes = NIL;
2627 op->colTypmods = NIL;
2628 op->colCollations = NIL;
2629 op->groupClauses = NIL;
2630
2632 {
2635 Node *lcolnode = (Node *) ltle->expr;
2636 Node *rcolnode = (Node *) rtle->expr;
2639 Node *bestexpr;
2640 int bestlocation;
2644
2645 /* select common type, same as CASE et al */
2648 context,
2649 &bestexpr);
2651
2652 /*
2653 * Verify the coercions are actually possible. If not, we'd fail
2654 * later anyway, but we want to fail now while we have sufficient
2655 * context to produce an error cursor position.
2656 *
2657 * For all non-UNKNOWN-type cases, we verify coercibility but we don't
2658 * modify the child's expression, for fear of changing the child
2659 * query's semantics.
2660 *
2661 * If a child expression is an UNKNOWN-type Const or Param, we want to
2662 * replace it with the coerced expression. This can only happen when
2663 * the child is a leaf set-op node. It's safe to replace the
2664 * expression because if the child query's semantics depended on the
2665 * type of this output column, it'd have already coerced the UNKNOWN
2666 * to something else. We want to do this because (a) we want to
2667 * verify that a Const is valid for the target type, or resolve the
2668 * actual type of an UNKNOWN Param, and (b) we want to avoid
2669 * unnecessary discrepancies between the output type of the child
2670 * query and the resolved target type. Such a discrepancy would
2671 * disable optimization in the planner.
2672 *
2673 * If it's some other UNKNOWN-type node, eg a Var, we do nothing
2674 * (knowing that coerce_to_common_type would fail). The planner is
2675 * sometimes able to fold an UNKNOWN Var to a constant before it has
2676 * to coerce the type, so failing now would just break cases that
2677 * might work.
2678 */
2679 if (lcoltype != UNKNOWNOID)
2681 rescoltype, context);
2682 else if (IsA(lcolnode, Const) ||
2683 IsA(lcolnode, Param))
2684 {
2686 rescoltype, context);
2687 ltle->expr = (Expr *) lcolnode;
2688 }
2689
2690 if (rcoltype != UNKNOWNOID)
2692 rescoltype, context);
2693 else if (IsA(rcolnode, Const) ||
2694 IsA(rcolnode, Param))
2695 {
2697 rescoltype, context);
2698 rtle->expr = (Expr *) rcolnode;
2699 }
2700
2703 rescoltype);
2704
2705 /*
2706 * Select common collation. A common collation is required for all
2707 * set operators except UNION ALL; see SQL:2008 7.13 <query
2708 * expression> Syntax Rule 15c. (If we fail to identify a common
2709 * collation for a UNION ALL column, the colCollations element will be
2710 * set to InvalidOid, which may result in a runtime error if something
2711 * at a higher query level wants to use the column's collation.)
2712 */
2715 (op->op == SETOP_UNION && op->all));
2716
2717 /* emit results */
2718 op->colTypes = lappend_oid(op->colTypes, rescoltype);
2719 op->colTypmods = lappend_int(op->colTypmods, rescoltypmod);
2720 op->colCollations = lappend_oid(op->colCollations, rescolcoll);
2721
2722 /*
2723 * For all cases except UNION ALL, identify the grouping operators
2724 * (and, if available, sorting operators) that will be used to
2725 * eliminate duplicates.
2726 */
2727 if (op->op != SETOP_UNION || !op->all)
2728 {
2730
2732 bestlocation);
2733
2734 /* If it's a recursive union, we need to require hashing support. */
2735 op->groupClauses = lappend(op->groupClauses,
2737
2739 }
2740
2741 /*
2742 * Construct a dummy tlist entry to return. We use a SetToDefault
2743 * node for the expression, since it carries exactly the fields
2744 * needed, but any other expression node type would do as well.
2745 */
2746 if (targetlist)
2747 {
2750
2751 rescolnode->typeId = rescoltype;
2752 rescolnode->typeMod = rescoltypmod;
2753 rescolnode->collation = rescolcoll;
2754 rescolnode->location = bestlocation;
2756 0, /* no need to set resno */
2757 NULL,
2758 false);
2759 *targetlist = lappend(*targetlist, restle);
2760 }
2761 }
2762}
int32_t int32
Definition c.h:679
List * lappend_int(List *list, int datum)
Definition list.c:357
List * lappend_oid(List *list, Oid datum)
Definition list.c:375
Oid exprType(const Node *expr)
Definition nodeFuncs.c:42
int exprLocation(const Node *expr)
Definition nodeFuncs.c:1403
#define IsA(nodeptr, _type_)
Definition nodes.h:162
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)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
Definition parse_node.c:156
int parser_errposition(ParseState *pstate, int location)
Definition parse_node.c:106
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
Definition parse_node.c:140
@ SETOP_UNION
SortGroupClause * makeSortGroupClauseForSetOp(Oid rescoltype, bool require_hash)
Definition analyze.c:2373
#define lfirst(lc)
Definition pg_list.h:172
static int list_length(const List *l)
Definition pg_list.h:152
#define forboth(cell1, list1, cell2, list2)
Definition pg_list.h:550
#define list_make2(x1, x2)
Definition pg_list.h:246
unsigned int Oid
Definition nodes.h:133
SetOperation op

References SetOperationStmt::all, cancel_parser_errposition_callback(), coerce_to_common_type(), ereport, errcode(), errmsg, ERROR, exprLocation(), exprType(), fb(), forboth, IsA, lappend(), lappend_int(), lappend_oid(), lfirst, list_length(), list_make2, makeNode, makeSortGroupClauseForSetOp(), makeTargetEntry(), NIL, SetOperationStmt::op, parser_errposition(), select_common_collation(), select_common_type(), select_common_typmod(), SETOP_UNION, and setup_parser_errposition_callback().

Referenced by generate_setop_from_pathqueries(), and transformSetOperationTree().

◆ LCS_asString()

const char * LCS_asString ( LockClauseStrength  strength)
extern

Definition at line 3717 of file analyze.c.

3718{
3719 switch (strength)
3720 {
3721 case LCS_NONE:
3722 Assert(false);
3723 break;
3724 case LCS_FORKEYSHARE:
3725 return "FOR KEY SHARE";
3726 case LCS_FORSHARE:
3727 return "FOR SHARE";
3728 case LCS_FORNOKEYUPDATE:
3729 return "FOR NO KEY UPDATE";
3730 case LCS_FORUPDATE:
3731 return "FOR UPDATE";
3732 }
3733 return "FOR some"; /* shouldn't happen */
3734}
@ LCS_FORUPDATE
Definition lockoptions.h:28
@ LCS_FORSHARE
Definition lockoptions.h:26
@ LCS_FORKEYSHARE
Definition lockoptions.h:25
@ LCS_FORNOKEYUPDATE
Definition lockoptions.h:27

References Assert, LCS_FORKEYSHARE, LCS_FORNOKEYUPDATE, LCS_FORSHARE, LCS_FORUPDATE, and LCS_NONE.

Referenced by CheckSelectLocking(), grouping_planner(), make_outerjoininfo(), transformDeclareCursorStmt(), transformLockingClause(), transformSetOperationStmt(), transformSetOperationTree(), and transformValuesClause().

◆ makeSortGroupClauseForSetOp()

SortGroupClause * makeSortGroupClauseForSetOp ( Oid  rescoltype,
bool  require_hash 
)
extern

Definition at line 2373 of file analyze.c.

2374{
2376 Oid sortop;
2377 Oid eqop;
2378 bool hashable;
2379
2380 /* determine the eqop and optional sortop */
2382 false, true, false,
2383 &sortop, &eqop, NULL,
2384 &hashable);
2385
2386 /*
2387 * The type cache doesn't believe that record is hashable (see
2388 * cache_record_field_properties()), but if the caller really needs hash
2389 * support, we can assume it does. Worst case, if any components of the
2390 * record don't support hashing, we will fail at execution.
2391 */
2393 hashable = true;
2394
2395 /* we don't have a tlist yet, so can't assign sortgrouprefs */
2396 grpcl->tleSortGroupRef = 0;
2397 grpcl->eqop = eqop;
2398 grpcl->sortop = sortop;
2399 grpcl->reverse_sort = false; /* Sort-op is "less than", or InvalidOid */
2400 grpcl->nulls_first = false; /* OK with or without sortop */
2401 grpcl->hashable = hashable;
2402
2403 return grpcl;
2404}
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
Definition parse_oper.c:183

References fb(), get_sort_group_operators(), and makeNode.

Referenced by constructSetOpTargetlist(), and rewriteSearchAndCycle().

◆ parse_analyze_fixedparams()

Query * parse_analyze_fixedparams ( RawStmt parseTree,
const char sourceText,
const Oid paramTypes,
int  numParams,
QueryEnvironment queryEnv 
)
extern

Definition at line 128 of file analyze.c.

131{
133 Query *query;
135
136 Assert(sourceText != NULL); /* required as of 8.4 */
137
138 pstate->p_sourcetext = sourceText;
139
140 if (numParams > 0)
141 setup_parse_fixed_parameters(pstate, paramTypes, numParams);
142
143 pstate->p_queryEnv = queryEnv;
144
145 query = transformTopLevelStmt(pstate, parseTree);
146
147 if (IsQueryIdEnabled())
148 jstate = JumbleQuery(query);
149
151 (*post_parse_analyze_hook) (pstate, query, jstate);
152
153 free_parsestate(pstate);
154
155 pgstat_report_query_id(query->queryId, false);
156
157 return query;
158}
void pgstat_report_query_id(int64 query_id, bool force)
void free_parsestate(ParseState *pstate)
Definition parse_node.c:72
ParseState * make_parsestate(ParseState *parentParseState)
Definition parse_node.c:39
void setup_parse_fixed_parameters(ParseState *pstate, const Oid *paramTypes, int numParams)
Definition parse_param.c:68
post_parse_analyze_hook_type post_parse_analyze_hook
Definition analyze.c:74
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
Definition analyze.c:272
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
QueryEnvironment * p_queryEnv
Definition parse_node.h:241
const char * p_sourcetext
Definition parse_node.h:214

References Assert, fb(), free_parsestate(), IsQueryIdEnabled(), JumbleQuery(), make_parsestate(), ParseState::p_queryEnv, ParseState::p_sourcetext, pgstat_report_query_id(), post_parse_analyze_hook, setup_parse_fixed_parameters(), and transformTopLevelStmt().

Referenced by DefineView(), and pg_analyze_and_rewrite_fixedparams().

◆ parse_analyze_varparams()

Query * parse_analyze_varparams ( RawStmt parseTree,
const char sourceText,
Oid **  paramTypes,
int numParams,
QueryEnvironment queryEnv 
)
extern

Definition at line 168 of file analyze.c.

171{
173 Query *query;
175
176 Assert(sourceText != NULL); /* required as of 8.4 */
177
178 pstate->p_sourcetext = sourceText;
179
180 setup_parse_variable_parameters(pstate, paramTypes, numParams);
181
182 pstate->p_queryEnv = queryEnv;
183
184 query = transformTopLevelStmt(pstate, parseTree);
185
186 /* make sure all is well with parameter types */
187 check_variable_parameters(pstate, query);
188
189 if (IsQueryIdEnabled())
190 jstate = JumbleQuery(query);
191
193 (*post_parse_analyze_hook) (pstate, query, jstate);
194
195 free_parsestate(pstate);
196
197 pgstat_report_query_id(query->queryId, false);
198
199 return query;
200}
void check_variable_parameters(ParseState *pstate, Query *query)
void setup_parse_variable_parameters(ParseState *pstate, Oid **paramTypes, int *numParams)
Definition parse_param.c:84

References Assert, check_variable_parameters(), fb(), free_parsestate(), IsQueryIdEnabled(), JumbleQuery(), make_parsestate(), ParseState::p_queryEnv, ParseState::p_sourcetext, pgstat_report_query_id(), post_parse_analyze_hook, setup_parse_variable_parameters(), and transformTopLevelStmt().

Referenced by pg_analyze_and_rewrite_varparams().

◆ parse_analyze_withcb()

Query * parse_analyze_withcb ( RawStmt parseTree,
const char sourceText,
ParserSetupHook  parserSetup,
void parserSetupArg,
QueryEnvironment queryEnv 
)
extern

Definition at line 209 of file analyze.c.

213{
215 Query *query;
217
218 Assert(sourceText != NULL); /* required as of 8.4 */
219
220 pstate->p_sourcetext = sourceText;
221 pstate->p_queryEnv = queryEnv;
222 (*parserSetup) (pstate, parserSetupArg);
223
224 query = transformTopLevelStmt(pstate, parseTree);
225
226 if (IsQueryIdEnabled())
227 jstate = JumbleQuery(query);
228
230 (*post_parse_analyze_hook) (pstate, query, jstate);
231
232 free_parsestate(pstate);
233
234 pgstat_report_query_id(query->queryId, false);
235
236 return query;
237}

References Assert, fb(), free_parsestate(), IsQueryIdEnabled(), JumbleQuery(), make_parsestate(), ParseState::p_queryEnv, ParseState::p_sourcetext, pgstat_report_query_id(), post_parse_analyze_hook, and transformTopLevelStmt().

Referenced by pg_analyze_and_rewrite_withcb().

◆ parse_sub_analyze()

Query * parse_sub_analyze ( Node parseTree,
ParseState parentParseState,
CommonTableExpr parentCTE,
bool  locked_from_parent,
bool  resolve_unknowns 
)
extern

Definition at line 245 of file analyze.c.

249{
250 ParseState *pstate = make_parsestate(parentParseState);
251 Query *query;
252
253 pstate->p_parent_cte = parentCTE;
256
257 query = transformStmt(pstate, parseTree);
258
259 free_parsestate(pstate);
260
261 return query;
262}
Query * transformStmt(ParseState *pstate, Node *parseTree)
Definition analyze.c:335
bool p_locked_from_parent
Definition parse_node.h:236
bool p_resolve_unknowns
Definition parse_node.h:238
CommonTableExpr * p_parent_cte
Definition parse_node.h:227

References fb(), free_parsestate(), make_parsestate(), ParseState::p_locked_from_parent, ParseState::p_parent_cte, ParseState::p_resolve_unknowns, and transformStmt().

Referenced by analyzeCTE(), transformRangeSubselect(), transformSetOperationTree(), and transformSubLink().

◆ query_requires_rewrite_plan()

bool query_requires_rewrite_plan ( Query query)
extern

Definition at line 543 of file analyze.c.

544{
545 bool result;
546
547 if (query->commandType != CMD_UTILITY)
548 {
549 /* All optimizable statements require rewriting/planning */
550 result = true;
551 }
552 else
553 {
554 /* This list should match stmt_requires_parse_analysis() */
555 switch (nodeTag(query->utilityStmt))
556 {
558 case T_ExplainStmt:
560 case T_CallStmt:
561 result = true;
562 break;
563 default:
564 result = false;
565 break;
566 }
567 }
568 return result;
569}
#define nodeTag(nodeptr)
Definition nodes.h:137
@ CMD_UTILITY
Definition nodes.h:278
CmdType commandType
Definition parsenodes.h:124
Node * utilityStmt
Definition parsenodes.h:144

References CMD_UTILITY, Query::commandType, fb(), nodeTag, result, and Query::utilityStmt.

Referenced by BuildingPlanRequiresSnapshot(), and StmtPlanRequiresRevalidation().

◆ stmt_requires_parse_analysis()

bool stmt_requires_parse_analysis ( RawStmt parseTree)
extern

Definition at line 470 of file analyze.c.

471{
472 bool result;
473
474 switch (nodeTag(parseTree->stmt))
475 {
476 /*
477 * Optimizable statements
478 */
479 case T_InsertStmt:
480 case T_DeleteStmt:
481 case T_UpdateStmt:
482 case T_MergeStmt:
483 case T_SelectStmt:
484 case T_ReturnStmt:
485 case T_PLAssignStmt:
486 result = true;
487 break;
488
489 /*
490 * Special cases
491 */
493 case T_ExplainStmt:
495 case T_CallStmt:
496 result = true;
497 break;
498
499 default:
500 /* all other statements just get wrapped in a CMD_UTILITY Query */
501 result = false;
502 break;
503 }
504
505 return result;
506}

References fb(), nodeTag, and result.

Referenced by analyze_requires_snapshot(), and StmtPlanRequiresRevalidation().

◆ transformInsertRow()

List * transformInsertRow ( ParseState pstate,
List exprlist,
List stmtcols,
List icolumns,
List attrnos,
bool  strip_indirection 
)
extern

Definition at line 1104 of file analyze.c.

1107{
1108 List *result;
1109 ListCell *lc;
1110 ListCell *icols;
1112
1113 /*
1114 * Check length of expr list. It must not have more expressions than
1115 * there are target columns. We allow fewer, but only if no explicit
1116 * columns list was given (the remaining columns are implicitly
1117 * defaulted). Note we must check this *after* transformation because
1118 * that could expand '*' into multiple items.
1119 */
1121 ereport(ERROR,
1123 errmsg("INSERT has more expressions than target columns"),
1124 parser_errposition(pstate,
1126 list_length(icolumns))))));
1127 if (stmtcols != NIL &&
1129 {
1130 /*
1131 * We can get here for cases like INSERT ... SELECT (a,b,c) FROM ...
1132 * where the user accidentally created a RowExpr instead of separate
1133 * columns. Add a suitable hint if that seems to be the problem,
1134 * because the main error message is quite misleading for this case.
1135 * (If there's no stmtcols, you'll get something about data type
1136 * mismatch, which is less misleading so we don't worry about giving a
1137 * hint in that case.)
1138 */
1139 ereport(ERROR,
1141 errmsg("INSERT has more target columns than expressions"),
1142 ((list_length(exprlist) == 1 &&
1145 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),
1146 parser_errposition(pstate,
1148 list_length(exprlist))))));
1149 }
1150
1151 /*
1152 * Prepare columns for assignment to target table.
1153 */
1154 result = NIL;
1156 {
1157 Expr *expr = (Expr *) lfirst(lc);
1159 int attno = lfirst_int(attnos);
1160
1161 expr = transformAssignedExpr(pstate, expr,
1163 col->name,
1164 attno,
1165 col->indirection,
1166 col->location);
1167
1169 {
1170 /*
1171 * We need to remove top-level FieldStores and SubscriptingRefs,
1172 * as well as any CoerceToDomain appearing above one of those ---
1173 * but not a CoerceToDomain that isn't above one of those.
1174 */
1175 while (expr)
1176 {
1177 Expr *subexpr = expr;
1178
1179 while (IsA(subexpr, CoerceToDomain))
1180 {
1181 subexpr = ((CoerceToDomain *) subexpr)->arg;
1182 }
1183 if (IsA(subexpr, FieldStore))
1184 {
1185 FieldStore *fstore = (FieldStore *) subexpr;
1186
1187 expr = (Expr *) linitial(fstore->newvals);
1188 }
1189 else if (IsA(subexpr, SubscriptingRef))
1190 {
1191 SubscriptingRef *sbsref = (SubscriptingRef *) subexpr;
1192
1193 if (sbsref->refassgnexpr == NULL)
1194 break;
1195
1196 expr = sbsref->refassgnexpr;
1197 }
1198 else
1199 break;
1200 }
1201 }
1202
1203 result = lappend(result, expr);
1204 }
1205
1206 return result;
1207}
int errhint(const char *fmt,...) pg_attribute_printf(1
@ EXPR_KIND_INSERT_TARGET
Definition parse_node.h:55
Expr * transformAssignedExpr(ParseState *pstate, Expr *expr, ParseExprKind exprKind, const char *colname, int attrno, List *indirection, int location)
static int count_rowexpr_columns(ParseState *pstate, Node *expr)
Definition analyze.c:1694
#define lfirst_node(type, lc)
Definition pg_list.h:176
#define lfirst_int(lc)
Definition pg_list.h:173
#define forthree(cell1, list1, cell2, list2, cell3, list3)
Definition pg_list.h:595
static void * list_nth(const List *list, int n)
Definition pg_list.h:331
#define linitial(l)
Definition pg_list.h:178
List * newvals
Definition primnodes.h:1176
Expr * refassgnexpr
Definition primnodes.h:726

References count_rowexpr_columns(), ereport, errcode(), errhint(), errmsg, ERROR, EXPR_KIND_INSERT_TARGET, exprLocation(), fb(), forthree, IsA, lappend(), lfirst, lfirst_int, lfirst_node, linitial, list_length(), list_nth(), FieldStore::newvals, NIL, parser_errposition(), SubscriptingRef::refassgnexpr, result, and transformAssignedExpr().

Referenced by transformInsertStmt(), and transformMergeStmt().

◆ transformReturningClause()

void transformReturningClause ( ParseState pstate,
Query qry,
ReturningClause returningClause,
ParseExprKind  exprKind 
)
extern

Definition at line 3064 of file analyze.c.

3067{
3068 int save_nslen = list_length(pstate->p_namespace);
3069 int save_next_resno;
3070
3071 if (returningClause == NULL)
3072 return; /* nothing to do */
3073
3074 /*
3075 * Scan RETURNING WITH(...) options for OLD/NEW alias names. Complain if
3076 * there is any conflict with existing relations.
3077 */
3078 foreach_node(ReturningOption, option, returningClause->options)
3079 {
3080 switch (option->option)
3081 {
3083 if (qry->returningOldAlias != NULL)
3084 ereport(ERROR,
3086 /* translator: %s is OLD or NEW */
3087 errmsg("%s cannot be specified multiple times", "OLD"),
3088 parser_errposition(pstate, option->location));
3089 qry->returningOldAlias = option->value;
3090 break;
3091
3093 if (qry->returningNewAlias != NULL)
3094 ereport(ERROR,
3096 /* translator: %s is OLD or NEW */
3097 errmsg("%s cannot be specified multiple times", "NEW"),
3098 parser_errposition(pstate, option->location));
3099 qry->returningNewAlias = option->value;
3100 break;
3101
3102 default:
3103 elog(ERROR, "unrecognized returning option: %d", option->option);
3104 }
3105
3106 if (refnameNamespaceItem(pstate, NULL, option->value, -1, NULL) != NULL)
3107 ereport(ERROR,
3109 errmsg("table name \"%s\" specified more than once",
3110 option->value),
3111 parser_errposition(pstate, option->location));
3112
3113 addNSItemForReturning(pstate, option->value,
3114 option->option == RETURNING_OPTION_OLD ?
3116 }
3117
3118 /*
3119 * If OLD/NEW alias names weren't explicitly specified, use "old"/"new"
3120 * unless masked by existing relations.
3121 */
3122 if (qry->returningOldAlias == NULL &&
3123 refnameNamespaceItem(pstate, NULL, "old", -1, NULL) == NULL)
3124 {
3125 qry->returningOldAlias = "old";
3127 }
3128 if (qry->returningNewAlias == NULL &&
3129 refnameNamespaceItem(pstate, NULL, "new", -1, NULL) == NULL)
3130 {
3131 qry->returningNewAlias = "new";
3133 }
3134
3135 /*
3136 * We need to assign resnos starting at one in the RETURNING list. Save
3137 * and restore the main tlist's value of p_next_resno, just in case
3138 * someone looks at it later (probably won't happen).
3139 */
3140 save_next_resno = pstate->p_next_resno;
3141 pstate->p_next_resno = 1;
3142
3143 /* transform RETURNING expressions identically to a SELECT targetlist */
3144 qry->returningList = transformTargetList(pstate,
3145 returningClause->exprs,
3146 exprKind);
3147
3148 /*
3149 * Complain if the nonempty tlist expanded to nothing (which is possible
3150 * if it contains only a star-expansion of a zero-column table). If we
3151 * allow this, the parsed Query will look like it didn't have RETURNING,
3152 * with results that would probably surprise the user.
3153 */
3154 if (qry->returningList == NIL)
3155 ereport(ERROR,
3157 errmsg("RETURNING must have at least one column"),
3158 parser_errposition(pstate,
3159 exprLocation(linitial(returningClause->exprs)))));
3160
3161 /* mark column origins */
3163
3164 /* resolve any still-unresolved output columns as being type text */
3165 if (pstate->p_resolve_unknowns)
3167
3168 /* restore state */
3169 pstate->p_namespace = list_truncate(pstate->p_namespace, save_nslen);
3170 pstate->p_next_resno = save_next_resno;
3171}
#define elog(elevel,...)
Definition elog.h:228
List * list_truncate(List *list, int new_size)
Definition list.c:631
ParseNamespaceItem * refnameNamespaceItem(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
List * transformTargetList(ParseState *pstate, List *targetlist, ParseExprKind exprKind)
void resolveTargetListUnknowns(ParseState *pstate, List *targetlist)
void markTargetListOrigins(ParseState *pstate, List *targetlist)
@ RETURNING_OPTION_NEW
@ RETURNING_OPTION_OLD
static void addNSItemForReturning(ParseState *pstate, const char *aliasname, VarReturningType returning_type)
Definition analyze.c:3025
#define foreach_node(type, var, lst)
Definition pg_list.h:528
@ VAR_RETURNING_OLD
Definition primnodes.h:258
@ VAR_RETURNING_NEW
Definition primnodes.h:259
List * p_namespace
Definition parse_node.h:222
int p_next_resno
Definition parse_node.h:233
List * returningList
Definition parsenodes.h:219

References addNSItemForReturning(), elog, ereport, errcode(), errmsg, ERROR, exprLocation(), ReturningClause::exprs, fb(), foreach_node, linitial, list_length(), list_truncate(), markTargetListOrigins(), NIL, ReturningClause::options, ParseState::p_namespace, ParseState::p_next_resno, ParseState::p_resolve_unknowns, parser_errposition(), refnameNamespaceItem(), resolveTargetListUnknowns(), RETURNING_OPTION_NEW, RETURNING_OPTION_OLD, Query::returningList, transformTargetList(), VAR_RETURNING_NEW, and VAR_RETURNING_OLD.

Referenced by transformDeleteStmt(), transformInsertStmt(), transformMergeStmt(), and transformUpdateStmt().

◆ transformStmt()

Query * transformStmt ( ParseState pstate,
Node parseTree 
)
extern

Definition at line 335 of file analyze.c.

336{
337 Query *result;
338
339#ifdef DEBUG_NODE_TESTS_ENABLED
340
341 /*
342 * We apply debug_raw_expression_coverage_test testing to basic DML
343 * statements; we can't just run it on everything because
344 * raw_expression_tree_walker() doesn't claim to handle utility
345 * statements.
346 */
348 {
349 switch (nodeTag(parseTree))
350 {
351 case T_SelectStmt:
352 case T_InsertStmt:
353 case T_UpdateStmt:
354 case T_DeleteStmt:
355 case T_MergeStmt:
357 break;
358 default:
359 break;
360 }
361 }
362#endif /* DEBUG_NODE_TESTS_ENABLED */
363
364 /*
365 * Caution: when changing the set of statement types that have non-default
366 * processing here, see also stmt_requires_parse_analysis() and
367 * analyze_requires_snapshot().
368 */
369 switch (nodeTag(parseTree))
370 {
371 /*
372 * Optimizable statements
373 */
374 case T_InsertStmt:
376 break;
377
378 case T_DeleteStmt:
380 break;
381
382 case T_UpdateStmt:
384 break;
385
386 case T_MergeStmt:
388 break;
389
390 case T_SelectStmt:
391 {
393
394 if (n->valuesLists)
395 result = transformValuesClause(pstate, n);
396 else if (n->op == SETOP_NONE)
397 result = transformSelectStmt(pstate, n, NULL);
398 else
400 }
401 break;
402
403 case T_ReturnStmt:
405 break;
406
407 case T_PLAssignStmt:
410 break;
411
412 /*
413 * Special cases
414 */
418 break;
419
420 case T_ExplainStmt:
423 break;
424
428 break;
429
430 case T_CallStmt:
431 result = transformCallStmt(pstate,
432 (CallStmt *) parseTree);
433 break;
434
435 default:
436
437 /*
438 * other statements don't require any transformation; just return
439 * the original parsetree with a Query node plastered on top.
440 */
442 result->commandType = CMD_UTILITY;
443 result->utilityStmt = parseTree;
444 break;
445 }
446
447 /* Mark as original query until we learn differently */
448 result->querySource = QSRC_ORIGINAL;
449 result->canSetTag = true;
450
451 return result;
452}
Query * transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
@ SETOP_NONE
@ QSRC_ORIGINAL
Definition parsenodes.h:36
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
Definition analyze.c:576
static Query * transformReturnStmt(ParseState *pstate, ReturnStmt *stmt)
Definition analyze.c:2823
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
Definition analyze.c:3186
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
Definition analyze.c:3513
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
Definition analyze.c:3592
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:2116
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt, SelectStmtPassthrough *passthru)
Definition analyze.c:1743
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
Definition analyze.c:2854
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Definition analyze.c:3461
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
Definition analyze.c:3368
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
Definition analyze.c:663
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:1897
List * valuesLists
SetOperation op

References CMD_UTILITY, fb(), makeNode, nodeTag, SelectStmt::op, QSRC_ORIGINAL, result, SETOP_NONE, transformCallStmt(), transformCreateTableAsStmt(), transformDeclareCursorStmt(), transformDeleteStmt(), transformExplainStmt(), transformInsertStmt(), transformMergeStmt(), transformPLAssignStmt(), transformReturnStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), transformValuesClause(), and SelectStmt::valuesLists.

Referenced by interpret_AS_clause(), parse_sub_analyze(), transformCreateTableAsStmt(), transformDeclareCursorStmt(), transformInsertStmt(), transformJsonArrayQueryConstructor(), transformOptionalSelectInto(), and transformRuleStmt().

◆ transformTopLevelStmt()

Query * transformTopLevelStmt ( ParseState pstate,
RawStmt parseTree 
)
extern

Definition at line 272 of file analyze.c.

273{
274 Query *result;
275
276 /* We're at top level, so allow SELECT INTO */
278
279 result->stmt_location = parseTree->stmt_location;
280 result->stmt_len = parseTree->stmt_len;
281
282 return result;
283}
static Query * transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
Definition analyze.c:296

References fb(), result, and transformOptionalSelectInto().

Referenced by inline_function(), parse_analyze_fixedparams(), parse_analyze_varparams(), and parse_analyze_withcb().

◆ transformUpdateTargetList()

List * transformUpdateTargetList ( ParseState pstate,
List origTlist,
ForPortionOfExpr forPortionOf 
)
extern

Definition at line 2936 of file analyze.c.

2937{
2938 List *tlist = NIL;
2941 ListCell *tl;
2942
2943 tlist = transformTargetList(pstate, origTlist,
2945
2946 /* Prepare to assign non-conflicting resnos to resjunk attributes */
2949
2950 /* Prepare non-junk columns for assignment to target table */
2953
2954 foreach(tl, tlist)
2955 {
2958 int attrno;
2959
2960 if (tle->resjunk)
2961 {
2962 /*
2963 * Resjunk nodes need no additional processing, but be sure they
2964 * have resnos that do not match any target columns; else rewriter
2965 * or planner might get confused. They don't need a resname
2966 * either.
2967 */
2968 tle->resno = (AttrNumber) pstate->p_next_resno++;
2969 tle->resname = NULL;
2970 continue;
2971 }
2972 if (orig_tl == NULL)
2973 elog(ERROR, "UPDATE target count mismatch --- internal error");
2975
2977 origTarget->name, true);
2979 ereport(ERROR,
2981 errmsg("column \"%s\" of relation \"%s\" does not exist",
2982 origTarget->name,
2984 (origTarget->indirection != NIL &&
2985 strcmp(origTarget->name, pstate->p_target_nsitem->p_names->aliasname) == 0) ?
2986 errhint("SET target columns cannot be qualified with the relation name.") : 0,
2987 parser_errposition(pstate, origTarget->location)));
2988
2989 /*
2990 * If this is a FOR PORTION OF update, forbid directly setting the
2991 * range column, since that would conflict with the implicit updates.
2992 */
2993 if (forPortionOf != NULL)
2994 {
2995 if (attrno == forPortionOf->rangeVar->varattno)
2996 ereport(ERROR,
2998 errmsg("cannot update column \"%s\" because it is used in FOR PORTION OF",
2999 origTarget->name),
3000 parser_errposition(pstate, origTarget->location)));
3001 }
3002
3003 updateTargetListEntry(pstate, tle, origTarget->name,
3004 attrno,
3005 origTarget->indirection,
3006 origTarget->location);
3007
3008 /* Mark the target column as requiring update permissions */
3009 target_perminfo->updatedCols = bms_add_member(target_perminfo->updatedCols,
3011
3013 }
3014 if (orig_tl != NULL)
3015 elog(ERROR, "UPDATE target count mismatch --- internal error");
3016
3017 return tlist;
3018}
int16 AttrNumber
Definition attnum.h:21
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition bitmapset.c:934
@ EXPR_KIND_UPDATE_SOURCE
Definition parse_node.h:56
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
void updateTargetListEntry(ParseState *pstate, TargetEntry *tle, char *colname, int attrno, List *indirection, int location)
static ListCell * list_head(const List *l)
Definition pg_list.h:128
static ListCell * lnext(const List *l, const ListCell *c)
Definition pg_list.h:375
#define RelationGetRelationName(relation)
Definition rel.h:550
char * aliasname
Definition primnodes.h:52
RTEPermissionInfo * p_perminfo
Definition parse_node.h:317
ParseNamespaceItem * p_target_nsitem
Definition parse_node.h:229
Relation p_target_relation
Definition parse_node.h:228
AttrNumber varattno
Definition primnodes.h:275
#define FirstLowInvalidHeapAttributeNumber
Definition sysattr.h:27

References Alias::aliasname, attnameAttNum(), bms_add_member(), elog, ereport, errcode(), errhint(), errmsg, ERROR, EXPR_KIND_UPDATE_SOURCE, fb(), FirstLowInvalidHeapAttributeNumber, InvalidAttrNumber, lfirst, lfirst_node, list_head(), lnext(), NIL, ParseNamespaceItem::p_names, ParseState::p_next_resno, ParseNamespaceItem::p_perminfo, ParseState::p_target_nsitem, ParseState::p_target_relation, parser_errposition(), ForPortionOfExpr::rangeVar, RelationGetNumberOfAttributes, RelationGetRelationName, transformTargetList(), updateTargetListEntry(), and Var::varattno.

Referenced by transformMergeStmt(), transformOnConflictClause(), and transformUpdateStmt().

Variable Documentation

◆ post_parse_analyze_hook