PostgreSQL Source Code  git master
analyze.h File Reference
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)
 

Functions

Queryparse_analyze (RawStmt *parseTree, const char *sourceText, Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
 
Queryparse_analyze_varparams (RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams)
 
Queryparse_sub_analyze (Node *parseTree, ParseState *parentParseState, CommonTableExpr *parentCTE, bool locked_from_parent, bool resolve_unknowns)
 
QuerytransformTopLevelStmt (ParseState *pstate, RawStmt *parseTree)
 
QuerytransformStmt (ParseState *pstate, Node *parseTree)
 
bool analyze_requires_snapshot (RawStmt *parseTree)
 
const char * LCS_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)
 

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)

Definition at line 20 of file analyze.h.

Function Documentation

◆ analyze_requires_snapshot()

bool analyze_requires_snapshot ( RawStmt parseTree)

Definition at line 366 of file analyze.c.

References nodeTag, RawStmt::stmt, T_CreateTableAsStmt, T_DeclareCursorStmt, T_DeleteStmt, T_ExplainStmt, T_InsertStmt, T_PLAssignStmt, T_SelectStmt, and T_UpdateStmt.

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

367 {
368  bool result;
369 
370  switch (nodeTag(parseTree->stmt))
371  {
372  /*
373  * Optimizable statements
374  */
375  case T_InsertStmt:
376  case T_DeleteStmt:
377  case T_UpdateStmt:
378  case T_SelectStmt:
379  case T_PLAssignStmt:
380  result = true;
381  break;
382 
383  /*
384  * Special cases
385  */
386  case T_DeclareCursorStmt:
387  case T_ExplainStmt:
388  case T_CreateTableAsStmt:
389  /* yes, because we must analyze the contained statement */
390  result = true;
391  break;
392 
393  default:
394  /* other utility statements don't have any real parse analysis */
395  result = false;
396  break;
397  }
398 
399  return result;
400 }
Node * stmt
Definition: parsenodes.h:1539
#define nodeTag(nodeptr)
Definition: nodes.h:538

◆ applyLockingClause()

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

Definition at line 3166 of file analyze.c.

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

Referenced by markQueryForLocking(), and transformLockingClause().

3169 {
3170  RowMarkClause *rc;
3171 
3172  Assert(strength != LCS_NONE); /* else caller error */
3173 
3174  /* If it's an explicit clause, make sure hasForUpdate gets set */
3175  if (!pushedDown)
3176  qry->hasForUpdate = true;
3177 
3178  /* Check for pre-existing entry for same rtindex */
3179  if ((rc = get_parse_rowmark(qry, rtindex)) != NULL)
3180  {
3181  /*
3182  * If the same RTE is specified with more than one locking strength,
3183  * use the strongest. (Reasonable, since you can't take both a shared
3184  * and exclusive lock at the same time; it'll end up being exclusive
3185  * anyway.)
3186  *
3187  * Similarly, if the same RTE is specified with more than one lock
3188  * wait policy, consider that NOWAIT wins over SKIP LOCKED, which in
3189  * turn wins over waiting for the lock (the default). This is a bit
3190  * more debatable but raising an error doesn't seem helpful. (Consider
3191  * for instance SELECT FOR UPDATE NOWAIT from a view that internally
3192  * contains a plain FOR UPDATE spec.) Having NOWAIT win over SKIP
3193  * LOCKED is reasonable since the former throws an error in case of
3194  * coming across a locked tuple, which may be undesirable in some
3195  * cases but it seems better than silently returning inconsistent
3196  * results.
3197  *
3198  * And of course pushedDown becomes false if any clause is explicit.
3199  */
3200  rc->strength = Max(rc->strength, strength);
3201  rc->waitPolicy = Max(rc->waitPolicy, waitPolicy);
3202  rc->pushedDown &= pushedDown;
3203  return;
3204  }
3205 
3206  /* Make a new RowMarkClause */
3207  rc = makeNode(RowMarkClause);
3208  rc->rti = rtindex;
3209  rc->strength = strength;
3210  rc->waitPolicy = waitPolicy;
3211  rc->pushedDown = pushedDown;
3212  qry->rowMarks = lappend(qry->rowMarks, rc);
3213 }
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
List * rowMarks
Definition: parsenodes.h:164
LockClauseStrength strength
Definition: parsenodes.h:1388
List * lappend(List *list, void *datum)
Definition: list.c:336
#define Max(x, y)
Definition: c.h:980
#define makeNode(_type_)
Definition: nodes.h:581
#define Assert(condition)
Definition: c.h:804
LockWaitPolicy waitPolicy
Definition: parsenodes.h:1389
bool hasForUpdate
Definition: parsenodes.h:132

◆ BuildOnConflictExcludedTargetlist()

List* BuildOnConflictExcludedTargetlist ( Relation  targetrel,
Index  exclRelIndex 
)

Definition at line 1088 of file analyze.c.

References InvalidAttrNumber, InvalidOid, lappend(), makeNullConst(), makeTargetEntry(), makeVar(), name, NameStr, NIL, pstrdup(), RelationData::rd_att, RelationData::rd_rel, RelationGetNumberOfAttributes, and TupleDescAttr.

Referenced by rewriteTargetView(), and transformOnConflictClause().

1090 {
1091  List *result = NIL;
1092  int attno;
1093  Var *var;
1094  TargetEntry *te;
1095 
1096  /*
1097  * Note that resnos of the tlist must correspond to attnos of the
1098  * underlying relation, hence we need entries for dropped columns too.
1099  */
1100  for (attno = 0; attno < RelationGetNumberOfAttributes(targetrel); attno++)
1101  {
1102  Form_pg_attribute attr = TupleDescAttr(targetrel->rd_att, attno);
1103  char *name;
1104 
1105  if (attr->attisdropped)
1106  {
1107  /*
1108  * can't use atttypid here, but it doesn't really matter what type
1109  * the Const claims to be.
1110  */
1111  var = (Var *) makeNullConst(INT4OID, -1, InvalidOid);
1112  name = NULL;
1113  }
1114  else
1115  {
1116  var = makeVar(exclRelIndex, attno + 1,
1117  attr->atttypid, attr->atttypmod,
1118  attr->attcollation,
1119  0);
1120  name = pstrdup(NameStr(attr->attname));
1121  }
1122 
1123  te = makeTargetEntry((Expr *) var,
1124  attno + 1,
1125  name,
1126  false);
1127 
1128  result = lappend(result, te);
1129  }
1130 
1131  /*
1132  * Add a whole-row-Var entry to support references to "EXCLUDED.*". Like
1133  * the other entries in the EXCLUDED tlist, its resno must match the Var's
1134  * varattno, else the wrong things happen while resolving references in
1135  * setrefs.c. This is against normal conventions for targetlists, but
1136  * it's okay since we don't use this as a real tlist.
1137  */
1138  var = makeVar(exclRelIndex, InvalidAttrNumber,
1139  targetrel->rd_rel->reltype,
1140  -1, InvalidOid, 0);
1141  te = makeTargetEntry((Expr *) var, InvalidAttrNumber, NULL, true);
1142  result = lappend(result, te);
1143 
1144  return result;
1145 }
#define NIL
Definition: pg_list.h:65
#define RelationGetNumberOfAttributes(relation)
Definition: rel.h:463
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
char * pstrdup(const char *in)
Definition: mcxt.c:1187
Form_pg_class rd_rel
Definition: rel.h:110
Definition: primnodes.h:181
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Definition: makefuncs.c:337
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:197
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Definition: makefuncs.c:238
Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:66
List * lappend(List *list, void *datum)
Definition: list.c:336
TupleDesc rd_att
Definition: rel.h:111
#define InvalidOid
Definition: postgres_ext.h:36
const char * name
Definition: encode.c:515
#define InvalidAttrNumber
Definition: attnum.h:23
#define NameStr(name)
Definition: c.h:681
Definition: pg_list.h:50

◆ CheckSelectLocking()

void CheckSelectLocking ( Query qry,
LockClauseStrength  strength 
)

Definition at line 2928 of file analyze.c.

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

Referenced by preprocess_rowmarks(), and transformLockingClause().

2929 {
2930  Assert(strength != LCS_NONE); /* else caller error */
2931 
2932  if (qry->setOperations)
2933  ereport(ERROR,
2934  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2935  /*------
2936  translator: %s is a SQL row locking clause such as FOR UPDATE */
2937  errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
2938  LCS_asString(strength))));
2939  if (qry->distinctClause != NIL)
2940  ereport(ERROR,
2941  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2942  /*------
2943  translator: %s is a SQL row locking clause such as FOR UPDATE */
2944  errmsg("%s is not allowed with DISTINCT clause",
2945  LCS_asString(strength))));
2946  if (qry->groupClause != NIL)
2947  ereport(ERROR,
2948  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2949  /*------
2950  translator: %s is a SQL row locking clause such as FOR UPDATE */
2951  errmsg("%s is not allowed with GROUP BY clause",
2952  LCS_asString(strength))));
2953  if (qry->havingQual != NULL)
2954  ereport(ERROR,
2955  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2956  /*------
2957  translator: %s is a SQL row locking clause such as FOR UPDATE */
2958  errmsg("%s is not allowed with HAVING clause",
2959  LCS_asString(strength))));
2960  if (qry->hasAggs)
2961  ereport(ERROR,
2962  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2963  /*------
2964  translator: %s is a SQL row locking clause such as FOR UPDATE */
2965  errmsg("%s is not allowed with aggregate functions",
2966  LCS_asString(strength))));
2967  if (qry->hasWindowFuncs)
2968  ereport(ERROR,
2969  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2970  /*------
2971  translator: %s is a SQL row locking clause such as FOR UPDATE */
2972  errmsg("%s is not allowed with window functions",
2973  LCS_asString(strength))));
2974  if (qry->hasTargetSRFs)
2975  ereport(ERROR,
2976  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2977  /*------
2978  translator: %s is a SQL row locking clause such as FOR UPDATE */
2979  errmsg("%s is not allowed with set-returning functions in the target list",
2980  LCS_asString(strength))));
2981 }
#define NIL
Definition: pg_list.h:65
const char * LCS_asString(LockClauseStrength strength)
Definition: analyze.c:2903
bool hasAggs
Definition: parsenodes.h:125
int errcode(int sqlerrcode)
Definition: elog.c:694
List * distinctClause
Definition: parsenodes.h:156
#define ERROR
Definition: elog.h:45
#define ereport(elevel,...)
Definition: elog.h:155
bool hasTargetSRFs
Definition: parsenodes.h:127
#define Assert(condition)
Definition: c.h:804
bool hasWindowFuncs
Definition: parsenodes.h:126
Node * setOperations
Definition: parsenodes.h:166
List * groupClause
Definition: parsenodes.h:148
int errmsg(const char *fmt,...)
Definition: elog.c:905
Node * havingQual
Definition: parsenodes.h:152

◆ LCS_asString()

const char* LCS_asString ( LockClauseStrength  strength)

Definition at line 2903 of file analyze.c.

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().

2904 {
2905  switch (strength)
2906  {
2907  case LCS_NONE:
2908  Assert(false);
2909  break;
2910  case LCS_FORKEYSHARE:
2911  return "FOR KEY SHARE";
2912  case LCS_FORSHARE:
2913  return "FOR SHARE";
2914  case LCS_FORNOKEYUPDATE:
2915  return "FOR NO KEY UPDATE";
2916  case LCS_FORUPDATE:
2917  return "FOR UPDATE";
2918  }
2919  return "FOR some"; /* shouldn't happen */
2920 }
#define Assert(condition)
Definition: c.h:804

◆ makeSortGroupClauseForSetOp()

SortGroupClause* makeSortGroupClauseForSetOp ( Oid  rescoltype)

Definition at line 1816 of file analyze.c.

References SortGroupClause::eqop, get_sort_group_operators(), SortGroupClause::hashable, makeNode, SortGroupClause::nulls_first, SortGroupClause::sortop, and SortGroupClause::tleSortGroupRef.

Referenced by rewriteSearchAndCycle(), and transformSetOperationTree().

1817 {
1819  Oid sortop;
1820  Oid eqop;
1821  bool hashable;
1822 
1823  /* determine the eqop and optional sortop */
1824  get_sort_group_operators(rescoltype,
1825  false, true, false,
1826  &sortop, &eqop, NULL,
1827  &hashable);
1828 
1829  /* we don't have a tlist yet, so can't assign sortgrouprefs */
1830  grpcl->tleSortGroupRef = 0;
1831  grpcl->eqop = eqop;
1832  grpcl->sortop = sortop;
1833  grpcl->nulls_first = false; /* OK with or without sortop */
1834  grpcl->hashable = hashable;
1835 
1836  return grpcl;
1837 }
Index tleSortGroupRef
Definition: parsenodes.h:1262
unsigned int Oid
Definition: postgres_ext.h:31
#define makeNode(_type_)
Definition: nodes.h:581
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:192

◆ parse_analyze()

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

Definition at line 104 of file analyze.c.

References Assert, free_parsestate(), make_parsestate(), ParseState::p_queryEnv, ParseState::p_sourcetext, parse_fixed_parameters(), post_parse_analyze_hook, and transformTopLevelStmt().

Referenced by DefineView(), and pg_analyze_and_rewrite().

107 {
108  ParseState *pstate = make_parsestate(NULL);
109  Query *query;
110 
111  Assert(sourceText != NULL); /* required as of 8.4 */
112 
113  pstate->p_sourcetext = sourceText;
114 
115  if (numParams > 0)
116  parse_fixed_parameters(pstate, paramTypes, numParams);
117 
118  pstate->p_queryEnv = queryEnv;
119 
120  query = transformTopLevelStmt(pstate, parseTree);
121 
123  (*post_parse_analyze_hook) (pstate, query);
124 
125  free_parsestate(pstate);
126 
127  return query;
128 }
QueryEnvironment * p_queryEnv
Definition: parse_node.h:204
ParseState * make_parsestate(ParseState *parentParseState)
Definition: parse_node.c:44
const char * p_sourcetext
Definition: parse_node.h:180
#define Assert(condition)
Definition: c.h:804
void parse_fixed_parameters(ParseState *pstate, Oid *paramTypes, int numParams)
Definition: parse_param.c:67
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
Definition: analyze.c:195
void free_parsestate(ParseState *pstate)
Definition: parse_node.c:77
post_parse_analyze_hook_type post_parse_analyze_hook
Definition: analyze.c:53

◆ parse_analyze_varparams()

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

Definition at line 138 of file analyze.c.

References Assert, check_variable_parameters(), free_parsestate(), make_parsestate(), ParseState::p_sourcetext, parse_variable_parameters(), post_parse_analyze_hook, and transformTopLevelStmt().

Referenced by exec_parse_message(), and PrepareQuery().

140 {
141  ParseState *pstate = make_parsestate(NULL);
142  Query *query;
143 
144  Assert(sourceText != NULL); /* required as of 8.4 */
145 
146  pstate->p_sourcetext = sourceText;
147 
148  parse_variable_parameters(pstate, paramTypes, numParams);
149 
150  query = transformTopLevelStmt(pstate, parseTree);
151 
152  /* make sure all is well with parameter types */
153  check_variable_parameters(pstate, query);
154 
156  (*post_parse_analyze_hook) (pstate, query);
157 
158  free_parsestate(pstate);
159 
160  return query;
161 }
void parse_variable_parameters(ParseState *pstate, Oid **paramTypes, int *numParams)
Definition: parse_param.c:83
ParseState * make_parsestate(ParseState *parentParseState)
Definition: parse_node.c:44
const char * p_sourcetext
Definition: parse_node.h:180
#define Assert(condition)
Definition: c.h:804
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
Definition: analyze.c:195
void check_variable_parameters(ParseState *pstate, Query *query)
Definition: parse_param.c:272
void free_parsestate(ParseState *pstate)
Definition: parse_node.c:77
post_parse_analyze_hook_type post_parse_analyze_hook
Definition: analyze.c:53

◆ parse_sub_analyze()

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

Definition at line 168 of file analyze.c.

References 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().

172 {
173  ParseState *pstate = make_parsestate(parentParseState);
174  Query *query;
175 
176  pstate->p_parent_cte = parentCTE;
177  pstate->p_locked_from_parent = locked_from_parent;
178  pstate->p_resolve_unknowns = resolve_unknowns;
179 
180  query = transformStmt(pstate, parseTree);
181 
182  free_parsestate(pstate);
183 
184  return query;
185 }
CommonTableExpr * p_parent_cte
Definition: parse_node.h:190
bool p_locked_from_parent
Definition: parse_node.h:199
ParseState * make_parsestate(ParseState *parentParseState)
Definition: parse_node.c:44
bool p_resolve_unknowns
Definition: parse_node.h:201
Query * transformStmt(ParseState *pstate, Node *parseTree)
Definition: analyze.c:258
void free_parsestate(ParseState *pstate)
Definition: parse_node.c:77

◆ transformStmt()

Query* transformStmt ( ParseState pstate,
Node parseTree 
)

Definition at line 258 of file analyze.c.

References Query::canSetTag, CMD_UTILITY, Query::commandType, makeNode, nodeTag, SelectStmt::op, QSRC_ORIGINAL, Query::querySource, SETOP_NONE, T_CallStmt, T_CreateTableAsStmt, T_DeclareCursorStmt, T_DeleteStmt, T_ExplainStmt, T_InsertStmt, T_PLAssignStmt, T_SelectStmt, T_UpdateStmt, transformCallStmt(), transformCreateTableAsStmt(), transformDeclareCursorStmt(), transformDeleteStmt(), transformExplainStmt(), transformInsertStmt(), transformPLAssignStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), transformValuesClause(), Query::utilityStmt, and SelectStmt::valuesLists.

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

259 {
260  Query *result;
261 
262  /*
263  * We apply RAW_EXPRESSION_COVERAGE_TEST testing to basic DML statements;
264  * we can't just run it on everything because raw_expression_tree_walker()
265  * doesn't claim to handle utility statements.
266  */
267 #ifdef RAW_EXPRESSION_COVERAGE_TEST
268  switch (nodeTag(parseTree))
269  {
270  case T_SelectStmt:
271  case T_InsertStmt:
272  case T_UpdateStmt:
273  case T_DeleteStmt:
274  (void) test_raw_expression_coverage(parseTree, NULL);
275  break;
276  default:
277  break;
278  }
279 #endif /* RAW_EXPRESSION_COVERAGE_TEST */
280 
281  switch (nodeTag(parseTree))
282  {
283  /*
284  * Optimizable statements
285  */
286  case T_InsertStmt:
287  result = transformInsertStmt(pstate, (InsertStmt *) parseTree);
288  break;
289 
290  case T_DeleteStmt:
291  result = transformDeleteStmt(pstate, (DeleteStmt *) parseTree);
292  break;
293 
294  case T_UpdateStmt:
295  result = transformUpdateStmt(pstate, (UpdateStmt *) parseTree);
296  break;
297 
298  case T_SelectStmt:
299  {
300  SelectStmt *n = (SelectStmt *) parseTree;
301 
302  if (n->valuesLists)
303  result = transformValuesClause(pstate, n);
304  else if (n->op == SETOP_NONE)
305  result = transformSelectStmt(pstate, n);
306  else
307  result = transformSetOperationStmt(pstate, n);
308  }
309  break;
310 
311  case T_PLAssignStmt:
312  result = transformPLAssignStmt(pstate,
313  (PLAssignStmt *) parseTree);
314  break;
315 
316  /*
317  * Special cases
318  */
319  case T_DeclareCursorStmt:
320  result = transformDeclareCursorStmt(pstate,
321  (DeclareCursorStmt *) parseTree);
322  break;
323 
324  case T_ExplainStmt:
325  result = transformExplainStmt(pstate,
326  (ExplainStmt *) parseTree);
327  break;
328 
329  case T_CreateTableAsStmt:
330  result = transformCreateTableAsStmt(pstate,
331  (CreateTableAsStmt *) parseTree);
332  break;
333 
334  case T_CallStmt:
335  result = transformCallStmt(pstate,
336  (CallStmt *) parseTree);
337  break;
338 
339  default:
340 
341  /*
342  * other statements don't require any transformation; just return
343  * the original parsetree with a Query node plastered on top.
344  */
345  result = makeNode(Query);
346  result->commandType = CMD_UTILITY;
347  result->utilityStmt = (Node *) parseTree;
348  break;
349  }
350 
351  /* Mark as original query until we learn differently */
352  result->querySource = QSRC_ORIGINAL;
353  result->canSetTag = true;
354 
355  return result;
356 }
static Query * transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
Definition: analyze.c:2787
static Query * transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
Definition: analyze.c:2677
static Query * transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
Definition: analyze.c:2235
static Query * transformValuesClause(ParseState *pstate, SelectStmt *stmt)
Definition: analyze.c:1341
Definition: nodes.h:533
Node * utilityStmt
Definition: parsenodes.h:120
static Query * transformExplainStmt(ParseState *pstate, ExplainStmt *stmt)
Definition: analyze.c:2763
static Query * transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
Definition: analyze.c:1200
List * valuesLists
Definition: parsenodes.h:1643
static Query * transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
Definition: analyze.c:2429
static Query * transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
Definition: analyze.c:477
SetOperation op
Definition: parsenodes.h:1659
CmdType commandType
Definition: parsenodes.h:112
#define makeNode(_type_)
Definition: nodes.h:581
QuerySource querySource
Definition: parsenodes.h:114
bool canSetTag
Definition: parsenodes.h:118
static Query * transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
Definition: analyze.c:407
static Query * transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
Definition: analyze.c:1565
#define nodeTag(nodeptr)
Definition: nodes.h:538
static Query * transformCallStmt(ParseState *pstate, CallStmt *stmt)
Definition: analyze.c:2864

◆ transformTopLevelStmt()

Query* transformTopLevelStmt ( ParseState pstate,
RawStmt parseTree 
)

Definition at line 195 of file analyze.c.

References RawStmt::stmt, Query::stmt_len, RawStmt::stmt_len, Query::stmt_location, RawStmt::stmt_location, and transformOptionalSelectInto().

Referenced by inline_function(), parse_analyze(), parse_analyze_varparams(), and pg_analyze_and_rewrite_params().

196 {
197  Query *result;
198 
199  /* We're at top level, so allow SELECT INTO */
200  result = transformOptionalSelectInto(pstate, parseTree->stmt);
201 
202  result->stmt_location = parseTree->stmt_location;
203  result->stmt_len = parseTree->stmt_len;
204 
205  return result;
206 }
int stmt_location
Definition: parsenodes.h:181
Node * stmt
Definition: parsenodes.h:1539
int stmt_len
Definition: parsenodes.h:1541
int stmt_location
Definition: parsenodes.h:1540
static Query * transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
Definition: analyze.c:219
int stmt_len
Definition: parsenodes.h:182

Variable Documentation

◆ post_parse_analyze_hook