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

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

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

1630{
1631 List *result = NIL;
1632 int attno;
1633 Var *var;
1634 TargetEntry *te;
1635
1636 /*
1637 * Note that resnos of the tlist must correspond to attnos of the
1638 * underlying relation, hence we need entries for dropped columns too.
1639 */
1640 for (attno = 0; attno < RelationGetNumberOfAttributes(targetrel); attno++)
1641 {
1642 Form_pg_attribute attr = TupleDescAttr(targetrel->rd_att, attno);
1643 char *name;
1644
1645 if (attr->attisdropped)
1646 {
1647 /*
1648 * can't use atttypid here, but it doesn't really matter what type
1649 * the Const claims to be.
1650 */
1651 var = (Var *) makeNullConst(INT4OID, -1, InvalidOid);
1652 name = NULL;
1653 }
1654 else
1655 {
1656 var = makeVar(exclRelIndex, attno + 1,
1657 attr->atttypid, attr->atttypmod,
1658 attr->attcollation,
1659 0);
1660 name = pstrdup(NameStr(attr->attname));
1661 }
1662
1663 te = makeTargetEntry((Expr *) var,
1664 attno + 1,
1665 name,
1666 false);
1667
1668 result = lappend(result, te);
1669 }
1670
1671 /*
1672 * Add a whole-row-Var entry to support references to "EXCLUDED.*". Like
1673 * the other entries in the EXCLUDED tlist, its resno must match the Var's
1674 * varattno, else the wrong things happen while resolving references in
1675 * setrefs.c. This is against normal conventions for targetlists, but
1676 * it's okay since we don't use this as a real tlist.
1677 */
1678 var = makeVar(exclRelIndex, InvalidAttrNumber,
1679 targetrel->rd_rel->reltype,
1680 -1, InvalidOid, 0);
1681 te = makeTargetEntry((Expr *) var, InvalidAttrNumber, NULL, true);
1682 result = lappend(result, te);
1683
1684 return result;
1685}
#define InvalidAttrNumber
Definition attnum.h:23
#define NameStr(name)
Definition c.h:835
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:1781
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 3745 of file analyze.c.

3746{
3747 Assert(strength != LCS_NONE); /* else caller error */
3748
3749 if (qry->setOperations)
3750 ereport(ERROR,
3752 /*------
3753 translator: %s is a SQL row locking clause such as FOR UPDATE */
3754 errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
3755 LCS_asString(strength))));
3756 if (qry->distinctClause != NIL)
3757 ereport(ERROR,
3759 /*------
3760 translator: %s is a SQL row locking clause such as FOR UPDATE */
3761 errmsg("%s is not allowed with DISTINCT clause",
3762 LCS_asString(strength))));
3763 if (qry->groupClause != NIL || qry->groupingSets != NIL)
3764 ereport(ERROR,
3766 /*------
3767 translator: %s is a SQL row locking clause such as FOR UPDATE */
3768 errmsg("%s is not allowed with GROUP BY clause",
3769 LCS_asString(strength))));
3770 if (qry->havingQual != NULL)
3771 ereport(ERROR,
3773 /*------
3774 translator: %s is a SQL row locking clause such as FOR UPDATE */
3775 errmsg("%s is not allowed with HAVING clause",
3776 LCS_asString(strength))));
3777 if (qry->hasAggs)
3778 ereport(ERROR,
3780 /*------
3781 translator: %s is a SQL row locking clause such as FOR UPDATE */
3782 errmsg("%s is not allowed with aggregate functions",
3783 LCS_asString(strength))));
3784 if (qry->hasWindowFuncs)
3785 ereport(ERROR,
3787 /*------
3788 translator: %s is a SQL row locking clause such as FOR UPDATE */
3789 errmsg("%s is not allowed with window functions",
3790 LCS_asString(strength))));
3791 if (qry->hasTargetSRFs)
3792 ereport(ERROR,
3794 /*------
3795 translator: %s is a SQL row locking clause such as FOR UPDATE */
3796 errmsg("%s is not allowed with set-returning functions in the target list",
3797 LCS_asString(strength))));
3798}
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:3720
Node * setOperations
Definition parsenodes.h:239
List * groupClause
Definition parsenodes.h:219
Node * havingQual
Definition parsenodes.h:225
List * groupingSets
Definition parsenodes.h:223
List * distinctClause
Definition parsenodes.h:229

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

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

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

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

130{
132 Query *query;
134
135 Assert(sourceText != NULL); /* required as of 8.4 */
136
137 pstate->p_sourcetext = sourceText;
138
139 if (numParams > 0)
140 setup_parse_fixed_parameters(pstate, paramTypes, numParams);
141
142 pstate->p_queryEnv = queryEnv;
143
144 query = transformTopLevelStmt(pstate, parseTree);
145
146 if (IsQueryIdEnabled())
147 jstate = JumbleQuery(query);
148
150 (*post_parse_analyze_hook) (pstate, query, jstate);
151
152 free_parsestate(pstate);
153
154 pgstat_report_query_id(query->queryId, false);
155
156 return query;
157}
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:271
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 167 of file analyze.c.

170{
172 Query *query;
174
175 Assert(sourceText != NULL); /* required as of 8.4 */
176
177 pstate->p_sourcetext = sourceText;
178
179 setup_parse_variable_parameters(pstate, paramTypes, numParams);
180
181 pstate->p_queryEnv = queryEnv;
182
183 query = transformTopLevelStmt(pstate, parseTree);
184
185 /* make sure all is well with parameter types */
186 check_variable_parameters(pstate, query);
187
188 if (IsQueryIdEnabled())
189 jstate = JumbleQuery(query);
190
192 (*post_parse_analyze_hook) (pstate, query, jstate);
193
194 free_parsestate(pstate);
195
196 pgstat_report_query_id(query->queryId, false);
197
198 return query;
199}
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 208 of file analyze.c.

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

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

248{
249 ParseState *pstate = make_parsestate(parentParseState);
250 Query *query;
251
252 pstate->p_parent_cte = parentCTE;
255
256 query = transformStmt(pstate, parseTree);
257
258 free_parsestate(pstate);
259
260 return query;
261}
Query * transformStmt(ParseState *pstate, Node *parseTree)
Definition analyze.c:334
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 542 of file analyze.c.

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

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

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

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

1105{
1106 List *result;
1107 ListCell *lc;
1108 ListCell *icols;
1110
1111 /*
1112 * Check length of expr list. It must not have more expressions than
1113 * there are target columns. We allow fewer, but only if no explicit
1114 * columns list was given (the remaining columns are implicitly
1115 * defaulted). Note we must check this *after* transformation because
1116 * that could expand '*' into multiple items.
1117 */
1119 ereport(ERROR,
1121 errmsg("INSERT has more expressions than target columns"),
1122 parser_errposition(pstate,
1124 list_length(icolumns))))));
1125 if (stmtcols != NIL &&
1127 {
1128 /*
1129 * We can get here for cases like INSERT ... SELECT (a,b,c) FROM ...
1130 * where the user accidentally created a RowExpr instead of separate
1131 * columns. Add a suitable hint if that seems to be the problem,
1132 * because the main error message is quite misleading for this case.
1133 * (If there's no stmtcols, you'll get something about data type
1134 * mismatch, which is less misleading so we don't worry about giving a
1135 * hint in that case.)
1136 */
1137 ereport(ERROR,
1139 errmsg("INSERT has more target columns than expressions"),
1140 ((list_length(exprlist) == 1 &&
1143 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),
1144 parser_errposition(pstate,
1146 list_length(exprlist))))));
1147 }
1148
1149 /*
1150 * Prepare columns for assignment to target table.
1151 */
1152 result = NIL;
1154 {
1155 Expr *expr = (Expr *) lfirst(lc);
1157 int attno = lfirst_int(attnos);
1158
1159 expr = transformAssignedExpr(pstate, expr,
1161 col->name,
1162 attno,
1163 col->indirection,
1164 col->location);
1165
1167 {
1168 /*
1169 * We need to remove top-level FieldStores and SubscriptingRefs,
1170 * as well as any CoerceToDomain appearing above one of those ---
1171 * but not a CoerceToDomain that isn't above one of those.
1172 */
1173 while (expr)
1174 {
1175 Expr *subexpr = expr;
1176
1177 while (IsA(subexpr, CoerceToDomain))
1178 {
1179 subexpr = ((CoerceToDomain *) subexpr)->arg;
1180 }
1181 if (IsA(subexpr, FieldStore))
1182 {
1183 FieldStore *fstore = (FieldStore *) subexpr;
1184
1185 expr = (Expr *) linitial(fstore->newvals);
1186 }
1187 else if (IsA(subexpr, SubscriptingRef))
1188 {
1189 SubscriptingRef *sbsref = (SubscriptingRef *) subexpr;
1190
1191 if (sbsref->refassgnexpr == NULL)
1192 break;
1193
1194 expr = sbsref->refassgnexpr;
1195 }
1196 else
1197 break;
1198 }
1199 }
1200
1201 result = lappend(result, expr);
1202 }
1203
1204 return result;
1205}
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:1698
#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:1195
Expr * refassgnexpr
Definition primnodes.h:736

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

3070{
3071 int save_nslen = list_length(pstate->p_namespace);
3072 int save_next_resno;
3073
3074 if (returningClause == NULL)
3075 return; /* nothing to do */
3076
3077 /*
3078 * Scan RETURNING WITH(...) options for OLD/NEW alias names. Complain if
3079 * there is any conflict with existing relations.
3080 */
3081 foreach_node(ReturningOption, option, returningClause->options)
3082 {
3083 switch (option->option)
3084 {
3086 if (qry->returningOldAlias != NULL)
3087 ereport(ERROR,
3089 /* translator: %s is OLD or NEW */
3090 errmsg("%s cannot be specified multiple times", "OLD"),
3091 parser_errposition(pstate, option->location));
3092 qry->returningOldAlias = option->value;
3093 break;
3094
3096 if (qry->returningNewAlias != NULL)
3097 ereport(ERROR,
3099 /* translator: %s is OLD or NEW */
3100 errmsg("%s cannot be specified multiple times", "NEW"),
3101 parser_errposition(pstate, option->location));
3102 qry->returningNewAlias = option->value;
3103 break;
3104
3105 default:
3106 elog(ERROR, "unrecognized returning option: %d", option->option);
3107 }
3108
3109 if (refnameNamespaceItem(pstate, NULL, option->value, -1, NULL) != NULL)
3110 ereport(ERROR,
3112 errmsg("table name \"%s\" specified more than once",
3113 option->value),
3114 parser_errposition(pstate, option->location));
3115
3116 addNSItemForReturning(pstate, option->value,
3117 option->option == RETURNING_OPTION_OLD ?
3119 }
3120
3121 /*
3122 * If OLD/NEW alias names weren't explicitly specified, use "old"/"new"
3123 * unless masked by existing relations.
3124 */
3125 if (qry->returningOldAlias == NULL &&
3126 refnameNamespaceItem(pstate, NULL, "old", -1, NULL) == NULL)
3127 {
3128 qry->returningOldAlias = "old";
3130 }
3131 if (qry->returningNewAlias == NULL &&
3132 refnameNamespaceItem(pstate, NULL, "new", -1, NULL) == NULL)
3133 {
3134 qry->returningNewAlias = "new";
3136 }
3137
3138 /*
3139 * We need to assign resnos starting at one in the RETURNING list. Save
3140 * and restore the main tlist's value of p_next_resno, just in case
3141 * someone looks at it later (probably won't happen).
3142 */
3143 save_next_resno = pstate->p_next_resno;
3144 pstate->p_next_resno = 1;
3145
3146 /* transform RETURNING expressions identically to a SELECT targetlist */
3147 qry->returningList = transformTargetList(pstate,
3148 returningClause->exprs,
3149 exprKind);
3150
3151 /*
3152 * Complain if the nonempty tlist expanded to nothing (which is possible
3153 * if it contains only a star-expansion of a zero-column table). If we
3154 * allow this, the parsed Query will look like it didn't have RETURNING,
3155 * with results that would probably surprise the user.
3156 */
3157 if (qry->returningList == NIL)
3158 ereport(ERROR,
3160 errmsg("RETURNING must have at least one column"),
3161 parser_errposition(pstate,
3162 exprLocation(linitial(returningClause->exprs)))));
3163
3164 /* mark column origins */
3166
3167 /* resolve any still-unresolved output columns as being type text */
3168 if (pstate->p_resolve_unknowns)
3170
3171 /* restore state */
3172 pstate->p_namespace = list_truncate(pstate->p_namespace, save_nslen);
3173 pstate->p_next_resno = save_next_resno;
3174}
#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:3028
#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:217

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

335{
336 Query *result;
337
338#ifdef DEBUG_NODE_TESTS_ENABLED
339
340 /*
341 * We apply debug_raw_expression_coverage_test testing to basic DML
342 * statements; we can't just run it on everything because
343 * raw_expression_tree_walker() doesn't claim to handle utility
344 * statements.
345 */
347 {
348 switch (nodeTag(parseTree))
349 {
350 case T_SelectStmt:
351 case T_InsertStmt:
352 case T_UpdateStmt:
353 case T_DeleteStmt:
354 case T_MergeStmt:
356 break;
357 default:
358 break;
359 }
360 }
361#endif /* DEBUG_NODE_TESTS_ENABLED */
362
363 /*
364 * Caution: when changing the set of statement types that have non-default
365 * processing here, see also stmt_requires_parse_analysis() and
366 * analyze_requires_snapshot().
367 */
368 switch (nodeTag(parseTree))
369 {
370 /*
371 * Optimizable statements
372 */
373 case T_InsertStmt:
375 break;
376
377 case T_DeleteStmt:
379 break;
380
381 case T_UpdateStmt:
383 break;
384
385 case T_MergeStmt:
387 break;
388
389 case T_SelectStmt:
390 {
392
393 if (n->valuesLists)
394 result = transformValuesClause(pstate, n);
395 else if (n->op == SETOP_NONE)
396 result = transformSelectStmt(pstate, n, NULL);
397 else
399 }
400 break;
401
402 case T_ReturnStmt:
404 break;
405
406 case T_PLAssignStmt:
409 break;
410
411 /*
412 * Special cases
413 */
417 break;
418
419 case T_ExplainStmt:
422 break;
423
427 break;
428
429 case T_CallStmt:
430 result = transformCallStmt(pstate,
431 (CallStmt *) parseTree);
432 break;
433
434 default:
435
436 /*
437 * other statements don't require any transformation; just return
438 * the original parsetree with a Query node plastered on top.
439 */
441 result->commandType = CMD_UTILITY;
442 result->utilityStmt = parseTree;
443 break;
444 }
445
446 /* Mark as original query until we learn differently */
447 result->querySource = QSRC_ORIGINAL;
448 result->canSetTag = true;
449
450 return result;
451}
Query * transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
@ SETOP_NONE
@ QSRC_ORIGINAL
Definition parsenodes.h:36
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
Definition analyze.c:575
static Query * transformReturnStmt(ParseState *pstate, ReturnStmt *stmt)
Definition analyze.c:2827
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
Definition analyze.c:3189
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
Definition analyze.c:3516
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
Definition analyze.c:3595
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:2120
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt, SelectStmtPassthrough *passthru)
Definition analyze.c:1747
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
Definition analyze.c:2858
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Definition analyze.c:3464
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
Definition analyze.c:3371
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
Definition analyze.c:661
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:1901
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 271 of file analyze.c.

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

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

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