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 4040 of file analyze.c.

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

3741{
3742 Assert(strength != LCS_NONE); /* else caller error */
3743
3744 if (qry->setOperations)
3745 ereport(ERROR,
3747 /*------
3748 translator: %s is a SQL row locking clause such as FOR UPDATE */
3749 errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
3750 LCS_asString(strength))));
3751 if (qry->distinctClause != NIL)
3752 ereport(ERROR,
3754 /*------
3755 translator: %s is a SQL row locking clause such as FOR UPDATE */
3756 errmsg("%s is not allowed with DISTINCT clause",
3757 LCS_asString(strength))));
3758 if (qry->groupClause != NIL || qry->groupingSets != NIL)
3759 ereport(ERROR,
3761 /*------
3762 translator: %s is a SQL row locking clause such as FOR UPDATE */
3763 errmsg("%s is not allowed with GROUP BY clause",
3764 LCS_asString(strength))));
3765 if (qry->havingQual != NULL)
3766 ereport(ERROR,
3768 /*------
3769 translator: %s is a SQL row locking clause such as FOR UPDATE */
3770 errmsg("%s is not allowed with HAVING clause",
3771 LCS_asString(strength))));
3772 if (qry->hasAggs)
3773 ereport(ERROR,
3775 /*------
3776 translator: %s is a SQL row locking clause such as FOR UPDATE */
3777 errmsg("%s is not allowed with aggregate functions",
3778 LCS_asString(strength))));
3779 if (qry->hasWindowFuncs)
3780 ereport(ERROR,
3782 /*------
3783 translator: %s is a SQL row locking clause such as FOR UPDATE */
3784 errmsg("%s is not allowed with window functions",
3785 LCS_asString(strength))));
3786 if (qry->hasTargetSRFs)
3787 ereport(ERROR,
3789 /*------
3790 translator: %s is a SQL row locking clause such as FOR UPDATE */
3791 errmsg("%s is not allowed with set-returning functions in the target list",
3792 LCS_asString(strength))));
3793}
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:3715
Node * setOperations
Definition parsenodes.h:240
List * groupClause
Definition parsenodes.h:221
Node * havingQual
Definition parsenodes.h:226
List * groupingSets
Definition parsenodes.h:224
List * distinctClause
Definition parsenodes.h:230

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 2603 of file analyze.c.

2606{
2607 ListCell *ltl;
2608 ListCell *rtl;
2609
2610 /*
2611 * Verify that the two children have the same number of non-junk columns,
2612 * and determine the types of the merged output columns.
2613 */
2615 ereport(ERROR,
2617 errmsg("each %s query must have the same number of columns",
2618 context),
2619 parser_errposition(pstate,
2620 exprLocation((const Node *) rtargetlist))));
2621
2622 if (targetlist)
2623 *targetlist = NIL;
2624 op->colTypes = NIL;
2625 op->colTypmods = NIL;
2626 op->colCollations = NIL;
2627 op->groupClauses = NIL;
2628
2630 {
2633 Node *lcolnode = (Node *) ltle->expr;
2634 Node *rcolnode = (Node *) rtle->expr;
2637 Node *bestexpr;
2638 int bestlocation;
2642
2643 /* select common type, same as CASE et al */
2646 context,
2647 &bestexpr);
2649
2650 /*
2651 * Verify the coercions are actually possible. If not, we'd fail
2652 * later anyway, but we want to fail now while we have sufficient
2653 * context to produce an error cursor position.
2654 *
2655 * For all non-UNKNOWN-type cases, we verify coercibility but we don't
2656 * modify the child's expression, for fear of changing the child
2657 * query's semantics.
2658 *
2659 * If a child expression is an UNKNOWN-type Const or Param, we want to
2660 * replace it with the coerced expression. This can only happen when
2661 * the child is a leaf set-op node. It's safe to replace the
2662 * expression because if the child query's semantics depended on the
2663 * type of this output column, it'd have already coerced the UNKNOWN
2664 * to something else. We want to do this because (a) we want to
2665 * verify that a Const is valid for the target type, or resolve the
2666 * actual type of an UNKNOWN Param, and (b) we want to avoid
2667 * unnecessary discrepancies between the output type of the child
2668 * query and the resolved target type. Such a discrepancy would
2669 * disable optimization in the planner.
2670 *
2671 * If it's some other UNKNOWN-type node, eg a Var, we do nothing
2672 * (knowing that coerce_to_common_type would fail). The planner is
2673 * sometimes able to fold an UNKNOWN Var to a constant before it has
2674 * to coerce the type, so failing now would just break cases that
2675 * might work.
2676 */
2677 if (lcoltype != UNKNOWNOID)
2679 rescoltype, context);
2680 else if (IsA(lcolnode, Const) ||
2681 IsA(lcolnode, Param))
2682 {
2684 rescoltype, context);
2685 ltle->expr = (Expr *) lcolnode;
2686 }
2687
2688 if (rcoltype != UNKNOWNOID)
2690 rescoltype, context);
2691 else if (IsA(rcolnode, Const) ||
2692 IsA(rcolnode, Param))
2693 {
2695 rescoltype, context);
2696 rtle->expr = (Expr *) rcolnode;
2697 }
2698
2701 rescoltype);
2702
2703 /*
2704 * Select common collation. A common collation is required for all
2705 * set operators except UNION ALL; see SQL:2008 7.13 <query
2706 * expression> Syntax Rule 15c. (If we fail to identify a common
2707 * collation for a UNION ALL column, the colCollations element will be
2708 * set to InvalidOid, which may result in a runtime error if something
2709 * at a higher query level wants to use the column's collation.)
2710 */
2713 (op->op == SETOP_UNION && op->all));
2714
2715 /* emit results */
2716 op->colTypes = lappend_oid(op->colTypes, rescoltype);
2717 op->colTypmods = lappend_int(op->colTypmods, rescoltypmod);
2718 op->colCollations = lappend_oid(op->colCollations, rescolcoll);
2719
2720 /*
2721 * For all cases except UNION ALL, identify the grouping operators
2722 * (and, if available, sorting operators) that will be used to
2723 * eliminate duplicates.
2724 */
2725 if (op->op != SETOP_UNION || !op->all)
2726 {
2728
2730 bestlocation);
2731
2732 /* If it's a recursive union, we need to require hashing support. */
2733 op->groupClauses = lappend(op->groupClauses,
2735
2737 }
2738
2739 /*
2740 * Construct a dummy tlist entry to return. We use a SetToDefault
2741 * node for the expression, since it carries exactly the fields
2742 * needed, but any other expression node type would do as well.
2743 */
2744 if (targetlist)
2745 {
2748
2749 rescolnode->typeId = rescoltype;
2750 rescolnode->typeMod = rescoltypmod;
2751 rescolnode->collation = rescolcoll;
2752 rescolnode->location = bestlocation;
2754 0, /* no need to set resno */
2755 NULL,
2756 false);
2757 *targetlist = lappend(*targetlist, restle);
2758 }
2759 }
2760}
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:2371
#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 3715 of file analyze.c.

3716{
3717 switch (strength)
3718 {
3719 case LCS_NONE:
3720 Assert(false);
3721 break;
3722 case LCS_FORKEYSHARE:
3723 return "FOR KEY SHARE";
3724 case LCS_FORSHARE:
3725 return "FOR SHARE";
3726 case LCS_FORNOKEYUPDATE:
3727 return "FOR NO KEY UPDATE";
3728 case LCS_FORUPDATE:
3729 return "FOR UPDATE";
3730 }
3731 return "FOR some"; /* shouldn't happen */
3732}
@ 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 2371 of file analyze.c.

2372{
2374 Oid sortop;
2375 Oid eqop;
2376 bool hashable;
2377
2378 /* determine the eqop and optional sortop */
2380 false, true, false,
2381 &sortop, &eqop, NULL,
2382 &hashable);
2383
2384 /*
2385 * The type cache doesn't believe that record is hashable (see
2386 * cache_record_field_properties()), but if the caller really needs hash
2387 * support, we can assume it does. Worst case, if any components of the
2388 * record don't support hashing, we will fail at execution.
2389 */
2391 hashable = true;
2392
2393 /* we don't have a tlist yet, so can't assign sortgrouprefs */
2394 grpcl->tleSortGroupRef = 0;
2395 grpcl->eqop = eqop;
2396 grpcl->sortop = sortop;
2397 grpcl->reverse_sort = false; /* Sort-op is "less than", or InvalidOid */
2398 grpcl->nulls_first = false; /* OK with or without sortop */
2399 grpcl->hashable = hashable;
2400
2401 return grpcl;
2402}
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 3062 of file analyze.c.

3065{
3066 int save_nslen = list_length(pstate->p_namespace);
3067 int save_next_resno;
3068
3069 if (returningClause == NULL)
3070 return; /* nothing to do */
3071
3072 /*
3073 * Scan RETURNING WITH(...) options for OLD/NEW alias names. Complain if
3074 * there is any conflict with existing relations.
3075 */
3076 foreach_node(ReturningOption, option, returningClause->options)
3077 {
3078 switch (option->option)
3079 {
3081 if (qry->returningOldAlias != NULL)
3082 ereport(ERROR,
3084 /* translator: %s is OLD or NEW */
3085 errmsg("%s cannot be specified multiple times", "OLD"),
3086 parser_errposition(pstate, option->location));
3087 qry->returningOldAlias = option->value;
3088 break;
3089
3091 if (qry->returningNewAlias != NULL)
3092 ereport(ERROR,
3094 /* translator: %s is OLD or NEW */
3095 errmsg("%s cannot be specified multiple times", "NEW"),
3096 parser_errposition(pstate, option->location));
3097 qry->returningNewAlias = option->value;
3098 break;
3099
3100 default:
3101 elog(ERROR, "unrecognized returning option: %d", option->option);
3102 }
3103
3104 if (refnameNamespaceItem(pstate, NULL, option->value, -1, NULL) != NULL)
3105 ereport(ERROR,
3107 errmsg("table name \"%s\" specified more than once",
3108 option->value),
3109 parser_errposition(pstate, option->location));
3110
3111 addNSItemForReturning(pstate, option->value,
3112 option->option == RETURNING_OPTION_OLD ?
3114 }
3115
3116 /*
3117 * If OLD/NEW alias names weren't explicitly specified, use "old"/"new"
3118 * unless masked by existing relations.
3119 */
3120 if (qry->returningOldAlias == NULL &&
3121 refnameNamespaceItem(pstate, NULL, "old", -1, NULL) == NULL)
3122 {
3123 qry->returningOldAlias = "old";
3125 }
3126 if (qry->returningNewAlias == NULL &&
3127 refnameNamespaceItem(pstate, NULL, "new", -1, NULL) == NULL)
3128 {
3129 qry->returningNewAlias = "new";
3131 }
3132
3133 /*
3134 * We need to assign resnos starting at one in the RETURNING list. Save
3135 * and restore the main tlist's value of p_next_resno, just in case
3136 * someone looks at it later (probably won't happen).
3137 */
3138 save_next_resno = pstate->p_next_resno;
3139 pstate->p_next_resno = 1;
3140
3141 /* transform RETURNING expressions identically to a SELECT targetlist */
3142 qry->returningList = transformTargetList(pstate,
3143 returningClause->exprs,
3144 exprKind);
3145
3146 /*
3147 * Complain if the nonempty tlist expanded to nothing (which is possible
3148 * if it contains only a star-expansion of a zero-column table). If we
3149 * allow this, the parsed Query will look like it didn't have RETURNING,
3150 * with results that would probably surprise the user.
3151 */
3152 if (qry->returningList == NIL)
3153 ereport(ERROR,
3155 errmsg("RETURNING must have at least one column"),
3156 parser_errposition(pstate,
3157 exprLocation(linitial(returningClause->exprs)))));
3158
3159 /* mark column origins */
3161
3162 /* resolve any still-unresolved output columns as being type text */
3163 if (pstate->p_resolve_unknowns)
3165
3166 /* restore state */
3167 pstate->p_namespace = list_truncate(pstate->p_namespace, save_nslen);
3168 pstate->p_next_resno = save_next_resno;
3169}
#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:3023
#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:2821
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
Definition analyze.c:3184
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
Definition analyze.c:3511
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
Definition analyze.c:3590
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:2114
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt, SelectStmtPassthrough *passthru)
Definition analyze.c:1743
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
Definition analyze.c:2852
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Definition analyze.c:3459
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
Definition analyze.c:3366
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
Definition analyze.c:663
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:1895
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 2934 of file analyze.c.

2935{
2936 List *tlist = NIL;
2939 ListCell *tl;
2940
2941 tlist = transformTargetList(pstate, origTlist,
2943
2944 /* Prepare to assign non-conflicting resnos to resjunk attributes */
2947
2948 /* Prepare non-junk columns for assignment to target table */
2951
2952 foreach(tl, tlist)
2953 {
2956 int attrno;
2957
2958 if (tle->resjunk)
2959 {
2960 /*
2961 * Resjunk nodes need no additional processing, but be sure they
2962 * have resnos that do not match any target columns; else rewriter
2963 * or planner might get confused. They don't need a resname
2964 * either.
2965 */
2966 tle->resno = (AttrNumber) pstate->p_next_resno++;
2967 tle->resname = NULL;
2968 continue;
2969 }
2970 if (orig_tl == NULL)
2971 elog(ERROR, "UPDATE target count mismatch --- internal error");
2973
2975 origTarget->name, true);
2977 ereport(ERROR,
2979 errmsg("column \"%s\" of relation \"%s\" does not exist",
2980 origTarget->name,
2982 (origTarget->indirection != NIL &&
2983 strcmp(origTarget->name, pstate->p_target_nsitem->p_names->aliasname) == 0) ?
2984 errhint("SET target columns cannot be qualified with the relation name.") : 0,
2985 parser_errposition(pstate, origTarget->location)));
2986
2987 /*
2988 * If this is a FOR PORTION OF update, forbid directly setting the
2989 * range column, since that would conflict with the implicit updates.
2990 */
2991 if (forPortionOf != NULL)
2992 {
2993 if (attrno == forPortionOf->rangeVar->varattno)
2994 ereport(ERROR,
2996 errmsg("cannot update column \"%s\" because it is used in FOR PORTION OF",
2997 origTarget->name),
2998 parser_errposition(pstate, origTarget->location)));
2999 }
3000
3001 updateTargetListEntry(pstate, tle, origTarget->name,
3002 attrno,
3003 origTarget->indirection,
3004 origTarget->location);
3005
3006 /* Mark the target column as requiring update permissions */
3007 target_perminfo->updatedCols = bms_add_member(target_perminfo->updatedCols,
3009
3011 }
3012 if (orig_tl != NULL)
3013 elog(ERROR, "UPDATE target count mismatch --- internal error");
3014
3015 return tlist;
3016}
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