PostgreSQL Source Code  git master
rewriteSearchCycle.c File Reference
#include "postgres.h"
#include "catalog/pg_operator_d.h"
#include "catalog/pg_type_d.h"
#include "nodes/makefuncs.h"
#include "nodes/pg_list.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "parser/analyze.h"
#include "parser/parsetree.h"
#include "rewrite/rewriteManip.h"
#include "rewrite/rewriteSearchCycle.h"
#include "utils/fmgroids.h"
Include dependency graph for rewriteSearchCycle.c:

Go to the source code of this file.

Functions

static RowExprmake_path_rowexpr (const CommonTableExpr *cte, const List *col_list)
 
static Exprmake_path_initial_array (RowExpr *rowexpr)
 
static Exprmake_path_cat_expr (RowExpr *rowexpr, AttrNumber path_varattno)
 
CommonTableExprrewriteSearchAndCycle (CommonTableExpr *cte)
 

Function Documentation

◆ make_path_cat_expr()

static Expr* make_path_cat_expr ( RowExpr rowexpr,
AttrNumber  path_varattno 
)
static

Definition at line 180 of file rewriteSearchCycle.c.

References ArrayExpr::array_typeid, COERCE_EXPLICIT_CALL, ArrayExpr::element_typeid, ArrayExpr::elements, InvalidOid, list_make1, list_make2, ArrayExpr::location, makeFuncExpr(), makeNode, and makeVar().

Referenced by rewriteSearchAndCycle().

181 {
182  ArrayExpr *arr;
183  FuncExpr *fexpr;
184 
185  arr = makeNode(ArrayExpr);
186  arr->array_typeid = RECORDARRAYOID;
187  arr->element_typeid = RECORDOID;
188  arr->location = -1;
189  arr->elements = list_make1(rowexpr);
190 
191  fexpr = makeFuncExpr(F_ARRAY_CAT, RECORDARRAYOID,
192  list_make2(makeVar(1, path_varattno, RECORDARRAYOID, -1, 0, 0),
193  arr),
195 
196  return (Expr *) fexpr;
197 }
#define list_make2(x1, x2)
Definition: pg_list.h:208
Oid array_typeid
Definition: primnodes.h:1024
#define list_make1(x1)
Definition: pg_list.h:206
List * elements
Definition: primnodes.h:1027
Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:66
int location
Definition: primnodes.h:1029
#define InvalidOid
Definition: postgres_ext.h:36
#define makeNode(_type_)
Definition: nodes.h:587
Oid element_typeid
Definition: primnodes.h:1026
FuncExpr * makeFuncExpr(Oid funcid, Oid rettype, List *args, Oid funccollid, Oid inputcollid, CoercionForm fformat)
Definition: makefuncs.c:519

◆ make_path_initial_array()

static Expr* make_path_initial_array ( RowExpr rowexpr)
static

Definition at line 159 of file rewriteSearchCycle.c.

References ArrayExpr::array_typeid, ArrayExpr::element_typeid, ArrayExpr::elements, list_make1, ArrayExpr::location, and makeNode.

Referenced by rewriteSearchAndCycle().

160 {
161  ArrayExpr *arr;
162 
163  arr = makeNode(ArrayExpr);
164  arr->array_typeid = RECORDARRAYOID;
165  arr->element_typeid = RECORDOID;
166  arr->location = -1;
167  arr->elements = list_make1(rowexpr);
168 
169  return (Expr *) arr;
170 }
Oid array_typeid
Definition: primnodes.h:1024
#define list_make1(x1)
Definition: pg_list.h:206
List * elements
Definition: primnodes.h:1027
int location
Definition: primnodes.h:1029
#define makeNode(_type_)
Definition: nodes.h:587
Oid element_typeid
Definition: primnodes.h:1026

◆ make_path_rowexpr()

static RowExpr* make_path_rowexpr ( const CommonTableExpr cte,
const List col_list 
)
static

Definition at line 117 of file rewriteSearchCycle.c.

References RowExpr::args, COERCE_IMPLICIT_CAST, RowExpr::colnames, CommonTableExpr::ctecolcollations, CommonTableExpr::ctecolnames, CommonTableExpr::ctecoltypes, CommonTableExpr::ctecoltypmods, i, lappend(), lfirst, list_length(), list_nth(), list_nth_int(), list_nth_oid(), RowExpr::location, makeNode, makeString(), makeVar(), RowExpr::row_format, RowExpr::row_typeid, and strVal.

Referenced by rewriteSearchAndCycle().

118 {
119  RowExpr *rowexpr;
120  ListCell *lc;
121 
122  rowexpr = makeNode(RowExpr);
123  rowexpr->row_typeid = RECORDOID;
124  rowexpr->row_format = COERCE_IMPLICIT_CAST;
125  rowexpr->location = -1;
126 
127  foreach(lc, col_list)
128  {
129  char *colname = strVal(lfirst(lc));
130 
131  for (int i = 0; i < list_length(cte->ctecolnames); i++)
132  {
133  char *colname2 = strVal(list_nth(cte->ctecolnames, i));
134 
135  if (strcmp(colname, colname2) == 0)
136  {
137  Var *var;
138 
139  var = makeVar(1, i + 1,
140  list_nth_oid(cte->ctecoltypes, i),
143  0);
144  rowexpr->args = lappend(rowexpr->args, var);
145  rowexpr->colnames = lappend(rowexpr->colnames, makeString(colname));
146  break;
147  }
148  }
149  }
150 
151  return rowexpr;
152 }
Value * makeString(char *str)
Definition: value.c:53
List * args
Definition: primnodes.h:1058
#define strVal(v)
Definition: value.h:54
Definition: primnodes.h:186
static int list_nth_int(const List *list, int n)
Definition: pg_list.h:289
static Oid list_nth_oid(const List *list, int n)
Definition: pg_list.h:300
List * colnames
Definition: primnodes.h:1074
static void * list_nth(const List *list, int n)
Definition: pg_list.h:278
int location
Definition: primnodes.h:1075
List * ctecoltypmods
Definition: parsenodes.h:1514
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
List * ctecolnames
Definition: parsenodes.h:1512
#define makeNode(_type_)
Definition: nodes.h:587
#define lfirst(lc)
Definition: pg_list.h:169
Oid row_typeid
Definition: primnodes.h:1059
static int list_length(const List *l)
Definition: pg_list.h:149
List * ctecoltypes
Definition: parsenodes.h:1513
int i
List * ctecolcollations
Definition: parsenodes.h:1515
CoercionForm row_format
Definition: primnodes.h:1073

◆ rewriteSearchAndCycle()

CommonTableExpr* rewriteSearchAndCycle ( CommonTableExpr cte)

Definition at line 203 of file rewriteSearchCycle.c.

References RangeTblEntry::alias, SetOperationStmt::all, FieldSelect::arg, ScalarArrayOpExpr::args, CaseExpr::args, RowExpr::args, Assert, Query::canSetTag, CaseExpr::casecollid, CaseExpr::casetype, castNode, CMD_SELECT, COERCE_EXPLICIT_CALL, SetOperationStmt::colCollations, Alias::colnames, RowExpr::colnames, SetOperationStmt::colTypes, SetOperationStmt::colTypmods, Query::commandType, copyObject, CommonTableExpr::ctecolcollations, CommonTableExpr::ctecolnames, CommonTableExpr::ctecoltypes, CommonTableExpr::ctecoltypmods, RangeTblEntry::ctename, CommonTableExpr::ctename, CommonTableExpr::ctequery, CommonTableExpr::cycle_clause, CTECycleClause::cycle_col_list, CTECycleClause::cycle_mark_collation, CTECycleClause::cycle_mark_column, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_neop, CTECycleClause::cycle_mark_type, CTECycleClause::cycle_mark_typmod, CTECycleClause::cycle_mark_value, CTECycleClause::cycle_path_column, CaseExpr::defresult, RangeTblEntry::eref, CaseWhen::expr, FieldSelect::fieldnum, FLOAT8PASSBYVAL, SetOperationStmt::groupClauses, i, IncrementVarSublevelsUp(), RangeTblEntry::inFromCl, Int64GetDatum(), InvalidAttrNumber, InvalidOid, Query::jointree, lappend(), lappend_int(), lappend_oid(), SetOperationStmt::larg, lcons(), lfirst, list_head(), list_length(), list_make1, list_make2, list_nth(), list_nth_int(), list_nth_oid(), ScalarArrayOpExpr::location, CaseExpr::location, CaseWhen::location, make_opclause(), make_path_cat_expr(), make_path_initial_array(), make_path_rowexpr(), makeAlias(), makeConst(), makeFromExpr(), makeFuncExpr(), makeNode, makeSortGroupClauseForSetOp(), makeString(), makeTargetEntry(), makeVar(), SetOperationStmt::op, ScalarArrayOpExpr::opno, SetOperationStmt::rarg, TargetEntry::resorigcol, TargetEntry::resorigtbl, CaseWhen::result, FieldSelect::resulttype, FieldSelect::resulttypmod, rt_fetch, Query::rtable, RTE_CTE, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblRef::rtindex, CTESearchClause::search_breadth_first, CommonTableExpr::search_clause, CTESearchClause::search_col_list, CTESearchClause::search_seq_column, SETOP_UNION, Query::setOperations, strVal, RangeTblEntry::subquery, Query::targetList, and ScalarArrayOpExpr::useOr.

Referenced by fireRIRrules().

204 {
205  Query *ctequery;
206  SetOperationStmt *sos;
207  int rti1,
208  rti2;
209  RangeTblEntry *rte1,
210  *rte2,
211  *newrte;
212  Query *newq1,
213  *newq2;
214  Query *newsubquery;
215  RangeTblRef *rtr;
216  Oid search_seq_type = InvalidOid;
217  AttrNumber sqc_attno = InvalidAttrNumber;
218  AttrNumber cmc_attno = InvalidAttrNumber;
219  AttrNumber cpa_attno = InvalidAttrNumber;
220  TargetEntry *tle;
221  RowExpr *cycle_col_rowexpr = NULL;
222  RowExpr *search_col_rowexpr = NULL;
223  List *ewcl;
224  int cte_rtindex = -1;
225 
226  Assert(cte->search_clause || cte->cycle_clause);
227 
228  cte = copyObject(cte);
229 
230  ctequery = castNode(Query, cte->ctequery);
231 
232  /*
233  * The top level of the CTE's query should be a UNION. Find the two
234  * subqueries.
235  */
236  Assert(ctequery->setOperations);
237  sos = castNode(SetOperationStmt, ctequery->setOperations);
238  Assert(sos->op == SETOP_UNION);
239 
240  rti1 = castNode(RangeTblRef, sos->larg)->rtindex;
241  rti2 = castNode(RangeTblRef, sos->rarg)->rtindex;
242 
243  rte1 = rt_fetch(rti1, ctequery->rtable);
244  rte2 = rt_fetch(rti2, ctequery->rtable);
245 
246  Assert(rte1->rtekind == RTE_SUBQUERY);
247  Assert(rte2->rtekind == RTE_SUBQUERY);
248 
249  /*
250  * We'll need this a few times later.
251  */
252  if (cte->search_clause)
253  {
255  search_seq_type = RECORDOID;
256  else
257  search_seq_type = RECORDARRAYOID;
258  }
259 
260  /*
261  * Attribute numbers of the added columns in the CTE's column list
262  */
263  if (cte->search_clause)
264  sqc_attno = list_length(cte->ctecolnames) + 1;
265  if (cte->cycle_clause)
266  {
267  cmc_attno = list_length(cte->ctecolnames) + 1;
268  cpa_attno = list_length(cte->ctecolnames) + 2;
269  if (cte->search_clause)
270  {
271  cmc_attno++;
272  cpa_attno++;
273  }
274  }
275 
276  /*
277  * Make new left subquery
278  */
279  newq1 = makeNode(Query);
280  newq1->commandType = CMD_SELECT;
281  newq1->canSetTag = true;
282 
283  newrte = makeNode(RangeTblEntry);
284  newrte->rtekind = RTE_SUBQUERY;
285  newrte->alias = makeAlias("*TLOCRN*", cte->ctecolnames);
286  newrte->eref = newrte->alias;
287  newsubquery = copyObject(rte1->subquery);
288  IncrementVarSublevelsUp((Node *) newsubquery, 1, 1);
289  newrte->subquery = newsubquery;
290  newrte->inFromCl = true;
291  newq1->rtable = list_make1(newrte);
292 
293  rtr = makeNode(RangeTblRef);
294  rtr->rtindex = 1;
295  newq1->jointree = makeFromExpr(list_make1(rtr), NULL);
296 
297  /*
298  * Make target list
299  */
300  for (int i = 0; i < list_length(cte->ctecolnames); i++)
301  {
302  Var *var;
303 
304  var = makeVar(1, i + 1,
305  list_nth_oid(cte->ctecoltypes, i),
308  0);
309  tle = makeTargetEntry((Expr *) var, i + 1, strVal(list_nth(cte->ctecolnames, i)), false);
310  tle->resorigtbl = castNode(TargetEntry, list_nth(rte1->subquery->targetList, i))->resorigtbl;
311  tle->resorigcol = castNode(TargetEntry, list_nth(rte1->subquery->targetList, i))->resorigcol;
312  newq1->targetList = lappend(newq1->targetList, tle);
313  }
314 
315  if (cte->search_clause)
316  {
317  Expr *texpr;
318 
319  search_col_rowexpr = make_path_rowexpr(cte, cte->search_clause->search_col_list);
321  {
322  search_col_rowexpr->args = lcons(makeConst(INT8OID, -1, InvalidOid, sizeof(int64),
323  Int64GetDatum(0), false, FLOAT8PASSBYVAL),
324  search_col_rowexpr->args);
325  search_col_rowexpr->colnames = lcons(makeString("*DEPTH*"), search_col_rowexpr->colnames);
326  texpr = (Expr *) search_col_rowexpr;
327  }
328  else
329  texpr = make_path_initial_array(search_col_rowexpr);
330  tle = makeTargetEntry(texpr,
331  list_length(newq1->targetList) + 1,
333  false);
334  newq1->targetList = lappend(newq1->targetList, tle);
335  }
336  if (cte->cycle_clause)
337  {
339  list_length(newq1->targetList) + 1,
341  false);
342  newq1->targetList = lappend(newq1->targetList, tle);
343  cycle_col_rowexpr = make_path_rowexpr(cte, cte->cycle_clause->cycle_col_list);
344  tle = makeTargetEntry(make_path_initial_array(cycle_col_rowexpr),
345  list_length(newq1->targetList) + 1,
347  false);
348  newq1->targetList = lappend(newq1->targetList, tle);
349  }
350 
351  rte1->subquery = newq1;
352 
353  if (cte->search_clause)
354  {
356  }
357  if (cte->cycle_clause)
358  {
361  }
362 
363  /*
364  * Make new right subquery
365  */
366  newq2 = makeNode(Query);
367  newq2->commandType = CMD_SELECT;
368  newq2->canSetTag = true;
369 
370  newrte = makeNode(RangeTblEntry);
371  newrte->rtekind = RTE_SUBQUERY;
372  ewcl = copyObject(cte->ctecolnames);
373  if (cte->search_clause)
374  {
375  ewcl = lappend(ewcl, makeString(cte->search_clause->search_seq_column));
376  }
377  if (cte->cycle_clause)
378  {
379  ewcl = lappend(ewcl, makeString(cte->cycle_clause->cycle_mark_column));
380  ewcl = lappend(ewcl, makeString(cte->cycle_clause->cycle_path_column));
381  }
382  newrte->alias = makeAlias("*TROCRN*", ewcl);
383  newrte->eref = newrte->alias;
384 
385  /*
386  * Find the reference to our CTE in the range table
387  */
388  for (int rti = 1; rti <= list_length(rte2->subquery->rtable); rti++)
389  {
390  RangeTblEntry *e = rt_fetch(rti, rte2->subquery->rtable);
391 
392  if (e->rtekind == RTE_CTE && strcmp(cte->ctename, e->ctename) == 0)
393  {
394  cte_rtindex = rti;
395  break;
396  }
397  }
398  Assert(cte_rtindex > 0);
399 
400  newsubquery = copyObject(rte2->subquery);
401  IncrementVarSublevelsUp((Node *) newsubquery, 1, 1);
402 
403  /*
404  * Add extra columns to target list of subquery of right subquery
405  */
406  if (cte->search_clause)
407  {
408  Var *var;
409 
410  /* ctename.sqc */
411  var = makeVar(cte_rtindex, sqc_attno,
412  search_seq_type, -1, InvalidOid, 0);
413  tle = makeTargetEntry((Expr *) var,
414  list_length(newsubquery->targetList) + 1,
416  false);
417  newsubquery->targetList = lappend(newsubquery->targetList, tle);
418  }
419  if (cte->cycle_clause)
420  {
421  Var *var;
422 
423  /* ctename.cmc */
424  var = makeVar(cte_rtindex, cmc_attno,
428  tle = makeTargetEntry((Expr *) var,
429  list_length(newsubquery->targetList) + 1,
431  false);
432  newsubquery->targetList = lappend(newsubquery->targetList, tle);
433 
434  /* ctename.cpa */
435  var = makeVar(cte_rtindex, cpa_attno,
436  RECORDARRAYOID, -1, InvalidOid, 0);
437  tle = makeTargetEntry((Expr *) var,
438  list_length(newsubquery->targetList) + 1,
440  false);
441  newsubquery->targetList = lappend(newsubquery->targetList, tle);
442  }
443 
444  newrte->subquery = newsubquery;
445  newrte->inFromCl = true;
446  newq2->rtable = list_make1(newrte);
447 
448  rtr = makeNode(RangeTblRef);
449  rtr->rtindex = 1;
450 
451  if (cte->cycle_clause)
452  {
453  Expr *expr;
454 
455  /*
456  * Add cmc <> cmv condition
457  */
458  expr = make_opclause(cte->cycle_clause->cycle_mark_neop, BOOLOID, false,
459  (Expr *) makeVar(1, cmc_attno,
464  InvalidOid,
466 
467  newq2->jointree = makeFromExpr(list_make1(rtr), (Node *) expr);
468  }
469  else
470  newq2->jointree = makeFromExpr(list_make1(rtr), NULL);
471 
472  /*
473  * Make target list
474  */
475  for (int i = 0; i < list_length(cte->ctecolnames); i++)
476  {
477  Var *var;
478 
479  var = makeVar(1, i + 1,
480  list_nth_oid(cte->ctecoltypes, i),
483  0);
484  tle = makeTargetEntry((Expr *) var, i + 1, strVal(list_nth(cte->ctecolnames, i)), false);
485  tle->resorigtbl = castNode(TargetEntry, list_nth(rte2->subquery->targetList, i))->resorigtbl;
486  tle->resorigcol = castNode(TargetEntry, list_nth(rte2->subquery->targetList, i))->resorigcol;
487  newq2->targetList = lappend(newq2->targetList, tle);
488  }
489 
490  if (cte->search_clause)
491  {
492  Expr *texpr;
493 
495  {
496  FieldSelect *fs;
497  FuncExpr *fexpr;
498 
499  /*
500  * ROW(sqc.depth + 1, cols)
501  */
502 
503  search_col_rowexpr = copyObject(search_col_rowexpr);
504 
505  fs = makeNode(FieldSelect);
506  fs->arg = (Expr *) makeVar(1, sqc_attno, RECORDOID, -1, 0, 0);
507  fs->fieldnum = 1;
508  fs->resulttype = INT8OID;
509  fs->resulttypmod = -1;
510 
511  fexpr = makeFuncExpr(F_INT8INC, INT8OID, list_make1(fs), InvalidOid, InvalidOid, COERCE_EXPLICIT_CALL);
512 
513  lfirst(list_head(search_col_rowexpr->args)) = fexpr;
514 
515  texpr = (Expr *) search_col_rowexpr;
516  }
517  else
518  {
519  /*
520  * sqc || ARRAY[ROW(cols)]
521  */
522  texpr = make_path_cat_expr(search_col_rowexpr, sqc_attno);
523  }
524  tle = makeTargetEntry(texpr,
525  list_length(newq2->targetList) + 1,
527  false);
528  newq2->targetList = lappend(newq2->targetList, tle);
529  }
530 
531  if (cte->cycle_clause)
532  {
533  ScalarArrayOpExpr *saoe;
534  CaseExpr *caseexpr;
535  CaseWhen *casewhen;
536 
537  /*
538  * CASE WHEN ROW(cols) = ANY (ARRAY[cpa]) THEN cmv ELSE cmd END
539  */
540 
541  saoe = makeNode(ScalarArrayOpExpr);
542  saoe->location = -1;
543  saoe->opno = RECORD_EQ_OP;
544  saoe->useOr = true;
545  saoe->args = list_make2(cycle_col_rowexpr,
546  makeVar(1, cpa_attno, RECORDARRAYOID, -1, 0, 0));
547 
548  caseexpr = makeNode(CaseExpr);
549  caseexpr->location = -1;
550  caseexpr->casetype = cte->cycle_clause->cycle_mark_type;
551  caseexpr->casecollid = cte->cycle_clause->cycle_mark_collation;
552  casewhen = makeNode(CaseWhen);
553  casewhen->location = -1;
554  casewhen->expr = (Expr *) saoe;
555  casewhen->result = (Expr *) cte->cycle_clause->cycle_mark_value;
556  caseexpr->args = list_make1(casewhen);
557  caseexpr->defresult = (Expr *) cte->cycle_clause->cycle_mark_default;
558 
559  tle = makeTargetEntry((Expr *) caseexpr,
560  list_length(newq2->targetList) + 1,
562  false);
563  newq2->targetList = lappend(newq2->targetList, tle);
564 
565  /*
566  * cpa || ARRAY[ROW(cols)]
567  */
568  tle = makeTargetEntry(make_path_cat_expr(cycle_col_rowexpr, cpa_attno),
569  list_length(newq2->targetList) + 1,
571  false);
572  newq2->targetList = lappend(newq2->targetList, tle);
573  }
574 
575  rte2->subquery = newq2;
576 
577  if (cte->search_clause)
578  {
580  }
581  if (cte->cycle_clause)
582  {
585  }
586 
587  /*
588  * Add the additional columns to the SetOperationStmt
589  */
590  if (cte->search_clause)
591  {
592  sos->colTypes = lappend_oid(sos->colTypes, search_seq_type);
593  sos->colTypmods = lappend_int(sos->colTypmods, -1);
595  if (!sos->all)
596  sos->groupClauses = lappend(sos->groupClauses,
597  makeSortGroupClauseForSetOp(search_seq_type));
598  }
599  if (cte->cycle_clause)
600  {
604  if (!sos->all)
605  sos->groupClauses = lappend(sos->groupClauses,
607 
608  sos->colTypes = lappend_oid(sos->colTypes, RECORDARRAYOID);
609  sos->colTypmods = lappend_int(sos->colTypmods, -1);
611  if (!sos->all)
612  sos->groupClauses = lappend(sos->groupClauses,
613  makeSortGroupClauseForSetOp(RECORDARRAYOID));
614  }
615 
616  /*
617  * Add the additional columns to the CTE query's target list
618  */
619  if (cte->search_clause)
620  {
621  ctequery->targetList = lappend(ctequery->targetList,
622  makeTargetEntry((Expr *) makeVar(1, sqc_attno,
623  search_seq_type, -1, InvalidOid, 0),
624  list_length(ctequery->targetList) + 1,
626  false));
627  }
628  if (cte->cycle_clause)
629  {
630  ctequery->targetList = lappend(ctequery->targetList,
631  makeTargetEntry((Expr *) makeVar(1, cmc_attno,
635  list_length(ctequery->targetList) + 1,
637  false));
638  ctequery->targetList = lappend(ctequery->targetList,
639  makeTargetEntry((Expr *) makeVar(1, cpa_attno,
640  RECORDARRAYOID, -1, InvalidOid, 0),
641  list_length(ctequery->targetList) + 1,
643  false));
644  }
645 
646  /*
647  * Add the additional columns to the CTE's output columns
648  */
649  cte->ctecolnames = ewcl;
650  if (cte->search_clause)
651  {
652  cte->ctecoltypes = lappend_oid(cte->ctecoltypes, search_seq_type);
653  cte->ctecoltypmods = lappend_int(cte->ctecoltypmods, -1);
655  }
656  if (cte->cycle_clause)
657  {
661 
662  cte->ctecoltypes = lappend_oid(cte->ctecoltypes, RECORDARRAYOID);
663  cte->ctecoltypmods = lappend_int(cte->ctecoltypmods, -1);
665  }
666 
667  return cte;
668 }
#define list_make2(x1, x2)
Definition: pg_list.h:208
Value * makeString(char *str)
Definition: value.c:53
List * args
Definition: primnodes.h:1058
bool search_breadth_first
Definition: parsenodes.h:1476
FromExpr * makeFromExpr(List *fromlist, Node *quals)
Definition: makefuncs.c:285
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:776
Alias * alias
Definition: parsenodes.h:1140
List * colnames
Definition: primnodes.h:43
FromExpr * jointree
Definition: parsenodes.h:148
Oid resulttype
Definition: primnodes.h:800
#define castNode(_type_, nodeptr)
Definition: nodes.h:608
char * search_seq_column
Definition: parsenodes.h:1477
SortGroupClause * makeSortGroupClauseForSetOp(Oid rescoltype)
Definition: analyze.c:1855
Oid casecollid
Definition: primnodes.h:967
Definition: nodes.h:539
#define strVal(v)
Definition: value.h:54
Oid resorigtbl
Definition: primnodes.h:1449
Expr * arg
Definition: primnodes.h:798
Oid casetype
Definition: primnodes.h:966
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:186
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:299
static Expr * make_path_initial_array(RowExpr *rowexpr)
List * lappend_oid(List *list, Oid datum)
Definition: list.c:372
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Definition: makefuncs.c:610
static int list_nth_int(const List *list, int n)
Definition: pg_list.h:289
int location
Definition: primnodes.h:982
List * targetList
Definition: parsenodes.h:150
static Oid list_nth_oid(const List *list, int n)
Definition: pg_list.h:300
#define list_make1(x1)
Definition: pg_list.h:206
Alias * makeAlias(const char *aliasname, List *colnames)
Definition: makefuncs.c:387
static Expr * make_path_cat_expr(RowExpr *rowexpr, AttrNumber path_varattno)
List * rtable
Definition: parsenodes.h:147
List * colnames
Definition: primnodes.h:1074
CTESearchClause * search_clause
Definition: parsenodes.h:1505
static void * list_nth(const List *list, int n)
Definition: pg_list.h:278
List * cycle_col_list
Definition: parsenodes.h:1484
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
List * ctecoltypmods
Definition: parsenodes.h:1514
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1697
#define rt_fetch(rangetable_index, rangetable)
Definition: parsetree.h:31
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_int(List *list, int datum)
Definition: list.c:354
List * lappend(List *list, void *datum)
Definition: list.c:336
List * search_col_list
Definition: parsenodes.h:1475
List * ctecolnames
Definition: parsenodes.h:1512
List * args
Definition: primnodes.h:969
List * colCollations
Definition: parsenodes.h:1720
Oid cycle_mark_collation
Definition: parsenodes.h:1493
#define InvalidOid
Definition: postgres_ext.h:36
CmdType commandType
Definition: parsenodes.h:120
List * lcons(void *datum, List *list)
Definition: list.c:468
#define makeNode(_type_)
Definition: nodes.h:587
#define FLOAT8PASSBYVAL
Definition: c.h:570
#define Assert(condition)
Definition: c.h:804
#define lfirst(lc)
Definition: pg_list.h:169
bool canSetTag
Definition: parsenodes.h:126
static int list_length(const List *l)
Definition: pg_list.h:149
Node * cycle_mark_value
Definition: parsenodes.h:1486
SetOperation op
Definition: parsenodes.h:1711
int location
Definition: primnodes.h:971
Node * cycle_mark_default
Definition: parsenodes.h:1487
#define InvalidAttrNumber
Definition: attnum.h:23
List * ctecoltypes
Definition: parsenodes.h:1513
RTEKind rtekind
Definition: parsenodes.h:995
char * cycle_path_column
Definition: parsenodes.h:1488
char * ctename
Definition: parsenodes.h:1105
CTECycleClause * cycle_clause
Definition: parsenodes.h:1506
Node * setOperations
Definition: parsenodes.h:177
e
Definition: preproc-init.c:82
AttrNumber resorigcol
Definition: primnodes.h:1450
Query * subquery
Definition: parsenodes.h:1030
char * cycle_mark_column
Definition: parsenodes.h:1485
int i
Alias * eref
Definition: parsenodes.h:1141
Expr * result
Definition: primnodes.h:981
List * ctecolcollations
Definition: parsenodes.h:1515
#define copyObject(obj)
Definition: nodes.h:655
Expr * defresult
Definition: primnodes.h:970
Expr * expr
Definition: primnodes.h:980
Definition: pg_list.h:50
int16 AttrNumber
Definition: attnum.h:21
static RowExpr * make_path_rowexpr(const CommonTableExpr *cte, const List *col_list)
FuncExpr * makeFuncExpr(Oid funcid, Oid rettype, List *args, Oid funccollid, Oid inputcollid, CoercionForm fformat)
Definition: makefuncs.c:519
int32 resulttypmod
Definition: primnodes.h:802
AttrNumber fieldnum
Definition: primnodes.h:799