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, 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)
 
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, 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 503 of file analyze.c.

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

3672{
3673 RowMarkClause *rc;
3674
3675 Assert(strength != LCS_NONE); /* else caller error */
3676
3677 /* If it's an explicit clause, make sure hasForUpdate gets set */
3678 if (!pushedDown)
3679 qry->hasForUpdate = true;
3680
3681 /* Check for pre-existing entry for same rtindex */
3682 if ((rc = get_parse_rowmark(qry, rtindex)) != NULL)
3683 {
3684 /*
3685 * If the same RTE is specified with more than one locking strength,
3686 * use the strongest. (Reasonable, since you can't take both a shared
3687 * and exclusive lock at the same time; it'll end up being exclusive
3688 * anyway.)
3689 *
3690 * Similarly, if the same RTE is specified with more than one lock
3691 * wait policy, consider that NOWAIT wins over SKIP LOCKED, which in
3692 * turn wins over waiting for the lock (the default). This is a bit
3693 * more debatable but raising an error doesn't seem helpful. (Consider
3694 * for instance SELECT FOR UPDATE NOWAIT from a view that internally
3695 * contains a plain FOR UPDATE spec.) Having NOWAIT win over SKIP
3696 * LOCKED is reasonable since the former throws an error in case of
3697 * coming across a locked tuple, which may be undesirable in some
3698 * cases but it seems better than silently returning inconsistent
3699 * results.
3700 *
3701 * And of course pushedDown becomes false if any clause is explicit.
3702 */
3703 rc->strength = Max(rc->strength, strength);
3704 rc->waitPolicy = Max(rc->waitPolicy, waitPolicy);
3705 rc->pushedDown &= pushedDown;
3706 return;
3707 }
3708
3709 /* Make a new RowMarkClause */
3710 rc = makeNode(RowMarkClause);
3711 rc->rti = rtindex;
3712 rc->strength = strength;
3713 rc->waitPolicy = waitPolicy;
3714 rc->pushedDown = pushedDown;
3715 qry->rowMarks = lappend(qry->rowMarks, rc);
3716}
#define Max(x, y)
Definition c.h:1087
#define Assert(condition)
Definition c.h:945
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:234
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 1291 of file analyze.c.

1293{
1294 List *result = NIL;
1295 int attno;
1296 Var *var;
1297 TargetEntry *te;
1298
1299 /*
1300 * Note that resnos of the tlist must correspond to attnos of the
1301 * underlying relation, hence we need entries for dropped columns too.
1302 */
1303 for (attno = 0; attno < RelationGetNumberOfAttributes(targetrel); attno++)
1304 {
1305 Form_pg_attribute attr = TupleDescAttr(targetrel->rd_att, attno);
1306 char *name;
1307
1308 if (attr->attisdropped)
1309 {
1310 /*
1311 * can't use atttypid here, but it doesn't really matter what type
1312 * the Const claims to be.
1313 */
1314 var = (Var *) makeNullConst(INT4OID, -1, InvalidOid);
1315 name = NULL;
1316 }
1317 else
1318 {
1319 var = makeVar(exclRelIndex, attno + 1,
1320 attr->atttypid, attr->atttypmod,
1321 attr->attcollation,
1322 0);
1323 name = pstrdup(NameStr(attr->attname));
1324 }
1325
1326 te = makeTargetEntry((Expr *) var,
1327 attno + 1,
1328 name,
1329 false);
1330
1331 result = lappend(result, te);
1332 }
1333
1334 /*
1335 * Add a whole-row-Var entry to support references to "EXCLUDED.*". Like
1336 * the other entries in the EXCLUDED tlist, its resno must match the Var's
1337 * varattno, else the wrong things happen while resolving references in
1338 * setrefs.c. This is against normal conventions for targetlists, but
1339 * it's okay since we don't use this as a real tlist.
1340 */
1341 var = makeVar(exclRelIndex, InvalidAttrNumber,
1342 targetrel->rd_rel->reltype,
1343 -1, InvalidOid, 0);
1344 te = makeTargetEntry((Expr *) var, InvalidAttrNumber, NULL, true);
1345 result = lappend(result, te);
1346
1347 return result;
1348}
#define InvalidAttrNumber
Definition attnum.h:23
#define NameStr(name)
Definition c.h:837
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:520
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, and TupleDescAttr().

Referenced by rewriteTargetView(), and transformOnConflictClause().

◆ CheckSelectLocking()

void CheckSelectLocking ( Query qry,
LockClauseStrength  strength 
)
extern

Definition at line 3378 of file analyze.c.

3379{
3380 Assert(strength != LCS_NONE); /* else caller error */
3381
3382 if (qry->setOperations)
3383 ereport(ERROR,
3385 /*------
3386 translator: %s is a SQL row locking clause such as FOR UPDATE */
3387 errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
3388 LCS_asString(strength))));
3389 if (qry->distinctClause != NIL)
3390 ereport(ERROR,
3392 /*------
3393 translator: %s is a SQL row locking clause such as FOR UPDATE */
3394 errmsg("%s is not allowed with DISTINCT clause",
3395 LCS_asString(strength))));
3396 if (qry->groupClause != NIL || qry->groupingSets != NIL)
3397 ereport(ERROR,
3399 /*------
3400 translator: %s is a SQL row locking clause such as FOR UPDATE */
3401 errmsg("%s is not allowed with GROUP BY clause",
3402 LCS_asString(strength))));
3403 if (qry->havingQual != NULL)
3404 ereport(ERROR,
3406 /*------
3407 translator: %s is a SQL row locking clause such as FOR UPDATE */
3408 errmsg("%s is not allowed with HAVING clause",
3409 LCS_asString(strength))));
3410 if (qry->hasAggs)
3411 ereport(ERROR,
3413 /*------
3414 translator: %s is a SQL row locking clause such as FOR UPDATE */
3415 errmsg("%s is not allowed with aggregate functions",
3416 LCS_asString(strength))));
3417 if (qry->hasWindowFuncs)
3418 ereport(ERROR,
3420 /*------
3421 translator: %s is a SQL row locking clause such as FOR UPDATE */
3422 errmsg("%s is not allowed with window functions",
3423 LCS_asString(strength))));
3424 if (qry->hasTargetSRFs)
3425 ereport(ERROR,
3427 /*------
3428 translator: %s is a SQL row locking clause such as FOR UPDATE */
3429 errmsg("%s is not allowed with set-returning functions in the target list",
3430 LCS_asString(strength))));
3431}
int errcode(int sqlerrcode)
Definition elog.c:874
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
static char * errmsg
const char * LCS_asString(LockClauseStrength strength)
Definition analyze.c:3353
Node * setOperations
Definition parsenodes.h:236
List * groupClause
Definition parsenodes.h:216
Node * havingQual
Definition parsenodes.h:222
List * groupingSets
Definition parsenodes.h:220
List * distinctClause
Definition parsenodes.h:226

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

2275{
2276 ListCell *ltl;
2277 ListCell *rtl;
2278
2279 /*
2280 * Verify that the two children have the same number of non-junk columns,
2281 * and determine the types of the merged output columns.
2282 */
2284 ereport(ERROR,
2286 errmsg("each %s query must have the same number of columns",
2287 context),
2288 parser_errposition(pstate,
2289 exprLocation((const Node *) rtargetlist))));
2290
2291 if (targetlist)
2292 *targetlist = NIL;
2293 op->colTypes = NIL;
2294 op->colTypmods = NIL;
2295 op->colCollations = NIL;
2296 op->groupClauses = NIL;
2297
2299 {
2302 Node *lcolnode = (Node *) ltle->expr;
2303 Node *rcolnode = (Node *) rtle->expr;
2306 Node *bestexpr;
2307 int bestlocation;
2311
2312 /* select common type, same as CASE et al */
2315 context,
2316 &bestexpr);
2318
2319 /*
2320 * Verify the coercions are actually possible. If not, we'd fail
2321 * later anyway, but we want to fail now while we have sufficient
2322 * context to produce an error cursor position.
2323 *
2324 * For all non-UNKNOWN-type cases, we verify coercibility but we don't
2325 * modify the child's expression, for fear of changing the child
2326 * query's semantics.
2327 *
2328 * If a child expression is an UNKNOWN-type Const or Param, we want to
2329 * replace it with the coerced expression. This can only happen when
2330 * the child is a leaf set-op node. It's safe to replace the
2331 * expression because if the child query's semantics depended on the
2332 * type of this output column, it'd have already coerced the UNKNOWN
2333 * to something else. We want to do this because (a) we want to
2334 * verify that a Const is valid for the target type, or resolve the
2335 * actual type of an UNKNOWN Param, and (b) we want to avoid
2336 * unnecessary discrepancies between the output type of the child
2337 * query and the resolved target type. Such a discrepancy would
2338 * disable optimization in the planner.
2339 *
2340 * If it's some other UNKNOWN-type node, eg a Var, we do nothing
2341 * (knowing that coerce_to_common_type would fail). The planner is
2342 * sometimes able to fold an UNKNOWN Var to a constant before it has
2343 * to coerce the type, so failing now would just break cases that
2344 * might work.
2345 */
2346 if (lcoltype != UNKNOWNOID)
2348 rescoltype, context);
2349 else if (IsA(lcolnode, Const) ||
2350 IsA(lcolnode, Param))
2351 {
2353 rescoltype, context);
2354 ltle->expr = (Expr *) lcolnode;
2355 }
2356
2357 if (rcoltype != UNKNOWNOID)
2359 rescoltype, context);
2360 else if (IsA(rcolnode, Const) ||
2361 IsA(rcolnode, Param))
2362 {
2364 rescoltype, context);
2365 rtle->expr = (Expr *) rcolnode;
2366 }
2367
2370 rescoltype);
2371
2372 /*
2373 * Select common collation. A common collation is required for all
2374 * set operators except UNION ALL; see SQL:2008 7.13 <query
2375 * expression> Syntax Rule 15c. (If we fail to identify a common
2376 * collation for a UNION ALL column, the colCollations element will be
2377 * set to InvalidOid, which may result in a runtime error if something
2378 * at a higher query level wants to use the column's collation.)
2379 */
2382 (op->op == SETOP_UNION && op->all));
2383
2384 /* emit results */
2385 op->colTypes = lappend_oid(op->colTypes, rescoltype);
2386 op->colTypmods = lappend_int(op->colTypmods, rescoltypmod);
2387 op->colCollations = lappend_oid(op->colCollations, rescolcoll);
2388
2389 /*
2390 * For all cases except UNION ALL, identify the grouping operators
2391 * (and, if available, sorting operators) that will be used to
2392 * eliminate duplicates.
2393 */
2394 if (op->op != SETOP_UNION || !op->all)
2395 {
2397
2399 bestlocation);
2400
2401 /* If it's a recursive union, we need to require hashing support. */
2402 op->groupClauses = lappend(op->groupClauses,
2404
2406 }
2407
2408 /*
2409 * Construct a dummy tlist entry to return. We use a SetToDefault
2410 * node for the expression, since it carries exactly the fields
2411 * needed, but any other expression node type would do as well.
2412 */
2413 if (targetlist)
2414 {
2417
2418 rescolnode->typeId = rescoltype;
2419 rescolnode->typeMod = rescoltypmod;
2420 rescolnode->collation = rescolcoll;
2421 rescolnode->location = bestlocation;
2423 0, /* no need to set resno */
2424 NULL,
2425 false);
2426 *targetlist = lappend(*targetlist, restle);
2427 }
2428 }
2429}
int32_t int32
Definition c.h:614
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:2040
#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 3353 of file analyze.c.

3354{
3355 switch (strength)
3356 {
3357 case LCS_NONE:
3358 Assert(false);
3359 break;
3360 case LCS_FORKEYSHARE:
3361 return "FOR KEY SHARE";
3362 case LCS_FORSHARE:
3363 return "FOR SHARE";
3364 case LCS_FORNOKEYUPDATE:
3365 return "FOR NO KEY UPDATE";
3366 case LCS_FORUPDATE:
3367 return "FOR UPDATE";
3368 }
3369 return "FOR some"; /* shouldn't happen */
3370}
@ 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 2040 of file analyze.c.

2041{
2043 Oid sortop;
2044 Oid eqop;
2045 bool hashable;
2046
2047 /* determine the eqop and optional sortop */
2049 false, true, false,
2050 &sortop, &eqop, NULL,
2051 &hashable);
2052
2053 /*
2054 * The type cache doesn't believe that record is hashable (see
2055 * cache_record_field_properties()), but if the caller really needs hash
2056 * support, we can assume it does. Worst case, if any components of the
2057 * record don't support hashing, we will fail at execution.
2058 */
2060 hashable = true;
2061
2062 /* we don't have a tlist yet, so can't assign sortgrouprefs */
2063 grpcl->tleSortGroupRef = 0;
2064 grpcl->eqop = eqop;
2065 grpcl->sortop = sortop;
2066 grpcl->reverse_sort = false; /* Sort-op is "less than", or InvalidOid */
2067 grpcl->nulls_first = false; /* OK with or without sortop */
2068 grpcl->hashable = hashable;
2069
2070 return grpcl;
2071}
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 117 of file analyze.c.

120{
122 Query *query;
124
125 Assert(sourceText != NULL); /* required as of 8.4 */
126
127 pstate->p_sourcetext = sourceText;
128
129 if (numParams > 0)
130 setup_parse_fixed_parameters(pstate, paramTypes, numParams);
131
132 pstate->p_queryEnv = queryEnv;
133
134 query = transformTopLevelStmt(pstate, parseTree);
135
136 if (IsQueryIdEnabled())
137 jstate = JumbleQuery(query);
138
140 (*post_parse_analyze_hook) (pstate, query, jstate);
141
142 free_parsestate(pstate);
143
144 pgstat_report_query_id(query->queryId, false);
145
146 return query;
147}
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:68
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
Definition analyze.c:261
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
QueryEnvironment * p_queryEnv
Definition parse_node.h:237
const char * p_sourcetext
Definition parse_node.h:210

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

160{
162 Query *query;
164
165 Assert(sourceText != NULL); /* required as of 8.4 */
166
167 pstate->p_sourcetext = sourceText;
168
169 setup_parse_variable_parameters(pstate, paramTypes, numParams);
170
171 pstate->p_queryEnv = queryEnv;
172
173 query = transformTopLevelStmt(pstate, parseTree);
174
175 /* make sure all is well with parameter types */
176 check_variable_parameters(pstate, query);
177
178 if (IsQueryIdEnabled())
179 jstate = JumbleQuery(query);
180
182 (*post_parse_analyze_hook) (pstate, query, jstate);
183
184 free_parsestate(pstate);
185
186 pgstat_report_query_id(query->queryId, false);
187
188 return query;
189}
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 198 of file analyze.c.

202{
204 Query *query;
206
207 Assert(sourceText != NULL); /* required as of 8.4 */
208
209 pstate->p_sourcetext = sourceText;
210 pstate->p_queryEnv = queryEnv;
211 (*parserSetup) (pstate, parserSetupArg);
212
213 query = transformTopLevelStmt(pstate, parseTree);
214
215 if (IsQueryIdEnabled())
216 jstate = JumbleQuery(query);
217
219 (*post_parse_analyze_hook) (pstate, query, jstate);
220
221 free_parsestate(pstate);
222
223 pgstat_report_query_id(query->queryId, false);
224
225 return query;
226}

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

238{
239 ParseState *pstate = make_parsestate(parentParseState);
240 Query *query;
241
242 pstate->p_parent_cte = parentCTE;
245
246 query = transformStmt(pstate, parseTree);
247
248 free_parsestate(pstate);
249
250 return query;
251}
Query * transformStmt(ParseState *pstate, Node *parseTree)
Definition analyze.c:324
bool p_locked_from_parent
Definition parse_node.h:232
bool p_resolve_unknowns
Definition parse_node.h:234
CommonTableExpr * p_parent_cte
Definition parse_node.h:223

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

533{
534 bool result;
535
536 if (query->commandType != CMD_UTILITY)
537 {
538 /* All optimizable statements require rewriting/planning */
539 result = true;
540 }
541 else
542 {
543 /* This list should match stmt_requires_parse_analysis() */
544 switch (nodeTag(query->utilityStmt))
545 {
547 case T_ExplainStmt:
549 case T_CallStmt:
550 result = true;
551 break;
552 default:
553 result = false;
554 break;
555 }
556 }
557 return result;
558}
#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, and Query::utilityStmt.

Referenced by BuildingPlanRequiresSnapshot(), and StmtPlanRequiresRevalidation().

◆ stmt_requires_parse_analysis()

bool stmt_requires_parse_analysis ( RawStmt parseTree)
extern

Definition at line 459 of file analyze.c.

460{
461 bool result;
462
463 switch (nodeTag(parseTree->stmt))
464 {
465 /*
466 * Optimizable statements
467 */
468 case T_InsertStmt:
469 case T_DeleteStmt:
470 case T_UpdateStmt:
471 case T_MergeStmt:
472 case T_SelectStmt:
473 case T_ReturnStmt:
474 case T_PLAssignStmt:
475 result = true;
476 break;
477
478 /*
479 * Special cases
480 */
482 case T_ExplainStmt:
484 case T_CallStmt:
485 result = true;
486 break;
487
488 default:
489 /* all other statements just get wrapped in a CMD_UTILITY Query */
490 result = false;
491 break;
492 }
493
494 return result;
495}

References fb(), and nodeTag.

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

1081{
1082 List *result;
1083 ListCell *lc;
1084 ListCell *icols;
1086
1087 /*
1088 * Check length of expr list. It must not have more expressions than
1089 * there are target columns. We allow fewer, but only if no explicit
1090 * columns list was given (the remaining columns are implicitly
1091 * defaulted). Note we must check this *after* transformation because
1092 * that could expand '*' into multiple items.
1093 */
1095 ereport(ERROR,
1097 errmsg("INSERT has more expressions than target columns"),
1098 parser_errposition(pstate,
1100 list_length(icolumns))))));
1101 if (stmtcols != NIL &&
1103 {
1104 /*
1105 * We can get here for cases like INSERT ... SELECT (a,b,c) FROM ...
1106 * where the user accidentally created a RowExpr instead of separate
1107 * columns. Add a suitable hint if that seems to be the problem,
1108 * because the main error message is quite misleading for this case.
1109 * (If there's no stmtcols, you'll get something about data type
1110 * mismatch, which is less misleading so we don't worry about giving a
1111 * hint in that case.)
1112 */
1113 ereport(ERROR,
1115 errmsg("INSERT has more target columns than expressions"),
1116 ((list_length(exprlist) == 1 &&
1119 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),
1120 parser_errposition(pstate,
1122 list_length(exprlist))))));
1123 }
1124
1125 /*
1126 * Prepare columns for assignment to target table.
1127 */
1128 result = NIL;
1130 {
1131 Expr *expr = (Expr *) lfirst(lc);
1133 int attno = lfirst_int(attnos);
1134
1135 expr = transformAssignedExpr(pstate, expr,
1137 col->name,
1138 attno,
1139 col->indirection,
1140 col->location);
1141
1143 {
1144 /*
1145 * We need to remove top-level FieldStores and SubscriptingRefs,
1146 * as well as any CoerceToDomain appearing above one of those ---
1147 * but not a CoerceToDomain that isn't above one of those.
1148 */
1149 while (expr)
1150 {
1151 Expr *subexpr = expr;
1152
1153 while (IsA(subexpr, CoerceToDomain))
1154 {
1155 subexpr = ((CoerceToDomain *) subexpr)->arg;
1156 }
1157 if (IsA(subexpr, FieldStore))
1158 {
1159 FieldStore *fstore = (FieldStore *) subexpr;
1160
1161 expr = (Expr *) linitial(fstore->newvals);
1162 }
1163 else if (IsA(subexpr, SubscriptingRef))
1164 {
1165 SubscriptingRef *sbsref = (SubscriptingRef *) subexpr;
1166
1167 if (sbsref->refassgnexpr == NULL)
1168 break;
1169
1170 expr = sbsref->refassgnexpr;
1171 }
1172 else
1173 break;
1174 }
1175 }
1176
1177 result = lappend(result, expr);
1178 }
1179
1180 return result;
1181}
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:1361
#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, and transformAssignedExpr().

Referenced by transformInsertStmt(), and transformMergeStmt().

◆ transformReturningClause()

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

Definition at line 2700 of file analyze.c.

2703{
2704 int save_nslen = list_length(pstate->p_namespace);
2705 int save_next_resno;
2706
2707 if (returningClause == NULL)
2708 return; /* nothing to do */
2709
2710 /*
2711 * Scan RETURNING WITH(...) options for OLD/NEW alias names. Complain if
2712 * there is any conflict with existing relations.
2713 */
2714 foreach_node(ReturningOption, option, returningClause->options)
2715 {
2716 switch (option->option)
2717 {
2719 if (qry->returningOldAlias != NULL)
2720 ereport(ERROR,
2722 /* translator: %s is OLD or NEW */
2723 errmsg("%s cannot be specified multiple times", "OLD"),
2724 parser_errposition(pstate, option->location));
2725 qry->returningOldAlias = option->value;
2726 break;
2727
2729 if (qry->returningNewAlias != NULL)
2730 ereport(ERROR,
2732 /* translator: %s is OLD or NEW */
2733 errmsg("%s cannot be specified multiple times", "NEW"),
2734 parser_errposition(pstate, option->location));
2735 qry->returningNewAlias = option->value;
2736 break;
2737
2738 default:
2739 elog(ERROR, "unrecognized returning option: %d", option->option);
2740 }
2741
2742 if (refnameNamespaceItem(pstate, NULL, option->value, -1, NULL) != NULL)
2743 ereport(ERROR,
2745 errmsg("table name \"%s\" specified more than once",
2746 option->value),
2747 parser_errposition(pstate, option->location));
2748
2749 addNSItemForReturning(pstate, option->value,
2750 option->option == RETURNING_OPTION_OLD ?
2752 }
2753
2754 /*
2755 * If OLD/NEW alias names weren't explicitly specified, use "old"/"new"
2756 * unless masked by existing relations.
2757 */
2758 if (qry->returningOldAlias == NULL &&
2759 refnameNamespaceItem(pstate, NULL, "old", -1, NULL) == NULL)
2760 {
2761 qry->returningOldAlias = "old";
2763 }
2764 if (qry->returningNewAlias == NULL &&
2765 refnameNamespaceItem(pstate, NULL, "new", -1, NULL) == NULL)
2766 {
2767 qry->returningNewAlias = "new";
2769 }
2770
2771 /*
2772 * We need to assign resnos starting at one in the RETURNING list. Save
2773 * and restore the main tlist's value of p_next_resno, just in case
2774 * someone looks at it later (probably won't happen).
2775 */
2776 save_next_resno = pstate->p_next_resno;
2777 pstate->p_next_resno = 1;
2778
2779 /* transform RETURNING expressions identically to a SELECT targetlist */
2780 qry->returningList = transformTargetList(pstate,
2781 returningClause->exprs,
2782 exprKind);
2783
2784 /*
2785 * Complain if the nonempty tlist expanded to nothing (which is possible
2786 * if it contains only a star-expansion of a zero-column table). If we
2787 * allow this, the parsed Query will look like it didn't have RETURNING,
2788 * with results that would probably surprise the user.
2789 */
2790 if (qry->returningList == NIL)
2791 ereport(ERROR,
2793 errmsg("RETURNING must have at least one column"),
2794 parser_errposition(pstate,
2795 exprLocation(linitial(returningClause->exprs)))));
2796
2797 /* mark column origins */
2799
2800 /* resolve any still-unresolved output columns as being type text */
2801 if (pstate->p_resolve_unknowns)
2803
2804 /* restore state */
2805 pstate->p_namespace = list_truncate(pstate->p_namespace, save_nslen);
2806 pstate->p_next_resno = save_next_resno;
2807}
#define elog(elevel,...)
Definition elog.h:226
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:2661
#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:218
int p_next_resno
Definition parse_node.h:229
List * returningList
Definition parsenodes.h:214

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

325{
326 Query *result;
327
328#ifdef DEBUG_NODE_TESTS_ENABLED
329
330 /*
331 * We apply debug_raw_expression_coverage_test testing to basic DML
332 * statements; we can't just run it on everything because
333 * raw_expression_tree_walker() doesn't claim to handle utility
334 * statements.
335 */
337 {
338 switch (nodeTag(parseTree))
339 {
340 case T_SelectStmt:
341 case T_InsertStmt:
342 case T_UpdateStmt:
343 case T_DeleteStmt:
344 case T_MergeStmt:
346 break;
347 default:
348 break;
349 }
350 }
351#endif /* DEBUG_NODE_TESTS_ENABLED */
352
353 /*
354 * Caution: when changing the set of statement types that have non-default
355 * processing here, see also stmt_requires_parse_analysis() and
356 * analyze_requires_snapshot().
357 */
358 switch (nodeTag(parseTree))
359 {
360 /*
361 * Optimizable statements
362 */
363 case T_InsertStmt:
364 result = transformInsertStmt(pstate, (InsertStmt *) parseTree);
365 break;
366
367 case T_DeleteStmt:
368 result = transformDeleteStmt(pstate, (DeleteStmt *) parseTree);
369 break;
370
371 case T_UpdateStmt:
372 result = transformUpdateStmt(pstate, (UpdateStmt *) parseTree);
373 break;
374
375 case T_MergeStmt:
376 result = transformMergeStmt(pstate, (MergeStmt *) parseTree);
377 break;
378
379 case T_SelectStmt:
380 {
382
383 if (n->valuesLists)
384 result = transformValuesClause(pstate, n);
385 else if (n->op == SETOP_NONE)
386 result = transformSelectStmt(pstate, n, NULL);
387 else
388 result = transformSetOperationStmt(pstate, n);
389 }
390 break;
391
392 case T_ReturnStmt:
393 result = transformReturnStmt(pstate, (ReturnStmt *) parseTree);
394 break;
395
396 case T_PLAssignStmt:
397 result = transformPLAssignStmt(pstate,
399 break;
400
401 /*
402 * Special cases
403 */
405 result = transformDeclareCursorStmt(pstate,
407 break;
408
409 case T_ExplainStmt:
410 result = transformExplainStmt(pstate,
412 break;
413
415 result = transformCreateTableAsStmt(pstate,
417 break;
418
419 case T_CallStmt:
420 result = transformCallStmt(pstate,
421 (CallStmt *) parseTree);
422 break;
423
424 default:
425
426 /*
427 * other statements don't require any transformation; just return
428 * the original parsetree with a Query node plastered on top.
429 */
430 result = makeNode(Query);
431 result->commandType = CMD_UTILITY;
432 result->utilityStmt = parseTree;
433 break;
434 }
435
436 /* Mark as original query until we learn differently */
437 result->querySource = QSRC_ORIGINAL;
438 result->canSetTag = true;
439
440 return result;
441}
Query * transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
@ SETOP_NONE
@ QSRC_ORIGINAL
Definition parsenodes.h:36
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
Definition analyze.c:565
static Query * transformReturnStmt(ParseState *pstate, ReturnStmt *stmt)
Definition analyze.c:2490
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
Definition analyze.c:2822
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
Definition analyze.c:3149
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
Definition analyze.c:3228
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:1783
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt, SelectStmtPassthrough *passthru)
Definition analyze.c:1410
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
Definition analyze.c:2521
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Definition analyze.c:3097
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
Definition analyze.c:3004
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
Definition analyze.c:637
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Definition analyze.c:1564
List * valuesLists
SetOperation op

References CMD_UTILITY, Query::commandType, fb(), makeNode, nodeTag, SelectStmt::op, QSRC_ORIGINAL, SETOP_NONE, transformCallStmt(), transformCreateTableAsStmt(), transformDeclareCursorStmt(), transformDeleteStmt(), transformExplainStmt(), transformInsertStmt(), transformMergeStmt(), transformPLAssignStmt(), transformReturnStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), transformValuesClause(), Query::utilityStmt, 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 261 of file analyze.c.

262{
263 Query *result;
264
265 /* We're at top level, so allow SELECT INTO */
266 result = transformOptionalSelectInto(pstate, parseTree->stmt);
267
268 result->stmt_location = parseTree->stmt_location;
269 result->stmt_len = parseTree->stmt_len;
270
271 return result;
272}
static Query * transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
Definition analyze.c:285
ParseLoc stmt_location
Definition parsenodes.h:255

References fb(), Query::stmt_location, and transformOptionalSelectInto().

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

◆ transformUpdateTargetList()

List * transformUpdateTargetList ( ParseState pstate,
List origTlist 
)
extern

Definition at line 2586 of file analyze.c.

2587{
2588 List *tlist = NIL;
2591 ListCell *tl;
2592
2593 tlist = transformTargetList(pstate, origTlist,
2595
2596 /* Prepare to assign non-conflicting resnos to resjunk attributes */
2599
2600 /* Prepare non-junk columns for assignment to target table */
2603
2604 foreach(tl, tlist)
2605 {
2608 int attrno;
2609
2610 if (tle->resjunk)
2611 {
2612 /*
2613 * Resjunk nodes need no additional processing, but be sure they
2614 * have resnos that do not match any target columns; else rewriter
2615 * or planner might get confused. They don't need a resname
2616 * either.
2617 */
2618 tle->resno = (AttrNumber) pstate->p_next_resno++;
2619 tle->resname = NULL;
2620 continue;
2621 }
2622 if (orig_tl == NULL)
2623 elog(ERROR, "UPDATE target count mismatch --- internal error");
2625
2627 origTarget->name, true);
2629 ereport(ERROR,
2631 errmsg("column \"%s\" of relation \"%s\" does not exist",
2632 origTarget->name,
2634 (origTarget->indirection != NIL &&
2635 strcmp(origTarget->name, pstate->p_target_nsitem->p_names->aliasname) == 0) ?
2636 errhint("SET target columns cannot be qualified with the relation name.") : 0,
2637 parser_errposition(pstate, origTarget->location)));
2638
2639 updateTargetListEntry(pstate, tle, origTarget->name,
2640 attrno,
2641 origTarget->indirection,
2642 origTarget->location);
2643
2644 /* Mark the target column as requiring update permissions */
2645 target_perminfo->updatedCols = bms_add_member(target_perminfo->updatedCols,
2647
2649 }
2650 if (orig_tl != NULL)
2651 elog(ERROR, "UPDATE target count mismatch --- internal error");
2652
2653 return tlist;
2654}
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:548
char * aliasname
Definition primnodes.h:52
RTEPermissionInfo * p_perminfo
Definition parse_node.h:313
ParseNamespaceItem * p_target_nsitem
Definition parse_node.h:225
Relation p_target_relation
Definition parse_node.h:224
#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(), RelationGetNumberOfAttributes, RelationGetRelationName, transformTargetList(), and updateTargetListEntry().

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

Variable Documentation

◆ post_parse_analyze_hook