PostgreSQL Source Code  git master
makefuncs.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * makefuncs.c
4  * creator functions for various nodes. The functions here are for the
5  * most frequently created nodes.
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  * src/backend/nodes/makefuncs.c
13  *
14  *-------------------------------------------------------------------------
15  */
16 #include "postgres.h"
17 
18 #include "catalog/pg_class.h"
19 #include "catalog/pg_type.h"
20 #include "nodes/makefuncs.h"
21 #include "nodes/nodeFuncs.h"
22 #include "utils/lsyscache.h"
23 
24 
25 /*
26  * makeA_Expr -
27  * makes an A_Expr node
28  */
29 A_Expr *
31  Node *lexpr, Node *rexpr, int location)
32 {
33  A_Expr *a = makeNode(A_Expr);
34 
35  a->kind = kind;
36  a->name = name;
37  a->lexpr = lexpr;
38  a->rexpr = rexpr;
39  a->location = location;
40  return a;
41 }
42 
43 /*
44  * makeSimpleA_Expr -
45  * As above, given a simple (unqualified) operator name
46  */
47 A_Expr *
49  Node *lexpr, Node *rexpr, int location)
50 {
51  A_Expr *a = makeNode(A_Expr);
52 
53  a->kind = kind;
54  a->name = list_make1(makeString((char *) name));
55  a->lexpr = lexpr;
56  a->rexpr = rexpr;
57  a->location = location;
58  return a;
59 }
60 
61 /*
62  * makeVar -
63  * creates a Var node
64  */
65 Var *
66 makeVar(int varno,
67  AttrNumber varattno,
68  Oid vartype,
69  int32 vartypmod,
70  Oid varcollid,
71  Index varlevelsup)
72 {
73  Var *var = makeNode(Var);
74 
75  var->varno = varno;
76  var->varattno = varattno;
77  var->vartype = vartype;
78  var->vartypmod = vartypmod;
79  var->varcollid = varcollid;
80  var->varlevelsup = varlevelsup;
81 
82  /*
83  * Only a few callers need to make Var nodes with non-null varnullingrels,
84  * or with varnosyn/varattnosyn different from varno/varattno. We don't
85  * provide separate arguments for them, but just initialize them to NULL
86  * and the given varno/varattno. This reduces code clutter and chance of
87  * error for most callers.
88  */
89  var->varnullingrels = NULL;
90  var->varnosyn = (Index) varno;
91  var->varattnosyn = varattno;
92 
93  /* Likewise, we just set location to "unknown" here */
94  var->location = -1;
95 
96  return var;
97 }
98 
99 /*
100  * makeVarFromTargetEntry -
101  * convenience function to create a same-level Var node from a
102  * TargetEntry
103  */
104 Var *
106  TargetEntry *tle)
107 {
108  return makeVar(varno,
109  tle->resno,
110  exprType((Node *) tle->expr),
111  exprTypmod((Node *) tle->expr),
112  exprCollation((Node *) tle->expr),
113  0);
114 }
115 
116 /*
117  * makeWholeRowVar -
118  * creates a Var node representing a whole row of the specified RTE
119  *
120  * A whole-row reference is a Var with varno set to the correct range
121  * table entry, and varattno == 0 to signal that it references the whole
122  * tuple. (Use of zero here is unclean, since it could easily be confused
123  * with error cases, but it's not worth changing now.) The vartype indicates
124  * a rowtype; either a named composite type, or a domain over a named
125  * composite type (only possible if the RTE is a function returning that),
126  * or RECORD. This function encapsulates the logic for determining the
127  * correct rowtype OID to use.
128  *
129  * If allowScalar is true, then for the case where the RTE is a single function
130  * returning a non-composite result type, we produce a normal Var referencing
131  * the function's result directly, instead of the single-column composite
132  * value that the whole-row notation might otherwise suggest.
133  */
134 Var *
136  int varno,
137  Index varlevelsup,
138  bool allowScalar)
139 {
140  Var *result;
141  Oid toid;
142  Node *fexpr;
143 
144  switch (rte->rtekind)
145  {
146  case RTE_RELATION:
147  /* relation: the rowtype is a named composite type */
148  toid = get_rel_type_id(rte->relid);
149  if (!OidIsValid(toid))
150  ereport(ERROR,
151  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
152  errmsg("relation \"%s\" does not have a composite type",
153  get_rel_name(rte->relid))));
154  result = makeVar(varno,
156  toid,
157  -1,
158  InvalidOid,
159  varlevelsup);
160  break;
161 
162  case RTE_FUNCTION:
163 
164  /*
165  * If there's more than one function, or ordinality is requested,
166  * force a RECORD result, since there's certainly more than one
167  * column involved and it can't be a known named type.
168  */
169  if (rte->funcordinality || list_length(rte->functions) != 1)
170  {
171  /* always produces an anonymous RECORD result */
172  result = makeVar(varno,
174  RECORDOID,
175  -1,
176  InvalidOid,
177  varlevelsup);
178  break;
179  }
180 
181  fexpr = ((RangeTblFunction *) linitial(rte->functions))->funcexpr;
182  toid = exprType(fexpr);
183  if (type_is_rowtype(toid))
184  {
185  /* func returns composite; same as relation case */
186  result = makeVar(varno,
188  toid,
189  -1,
190  InvalidOid,
191  varlevelsup);
192  }
193  else if (allowScalar)
194  {
195  /* func returns scalar; just return its output as-is */
196  result = makeVar(varno,
197  1,
198  toid,
199  -1,
200  exprCollation(fexpr),
201  varlevelsup);
202  }
203  else
204  {
205  /* func returns scalar, but we want a composite result */
206  result = makeVar(varno,
208  RECORDOID,
209  -1,
210  InvalidOid,
211  varlevelsup);
212  }
213  break;
214 
215  default:
216 
217  /*
218  * RTE is a join, subselect, tablefunc, or VALUES. We represent
219  * this as a whole-row Var of RECORD type. (Note that in most
220  * cases the Var will be expanded to a RowExpr during planning,
221  * but that is not our concern here.)
222  */
223  result = makeVar(varno,
225  RECORDOID,
226  -1,
227  InvalidOid,
228  varlevelsup);
229  break;
230  }
231 
232  return result;
233 }
234 
235 /*
236  * makeTargetEntry -
237  * creates a TargetEntry node
238  */
239 TargetEntry *
241  AttrNumber resno,
242  char *resname,
243  bool resjunk)
244 {
246 
247  tle->expr = expr;
248  tle->resno = resno;
249  tle->resname = resname;
250 
251  /*
252  * We always set these fields to 0. If the caller wants to change them he
253  * must do so explicitly. Few callers do that, so omitting these
254  * arguments reduces the chance of error.
255  */
256  tle->ressortgroupref = 0;
257  tle->resorigtbl = InvalidOid;
258  tle->resorigcol = 0;
259 
260  tle->resjunk = resjunk;
261 
262  return tle;
263 }
264 
265 /*
266  * flatCopyTargetEntry -
267  * duplicate a TargetEntry, but don't copy substructure
268  *
269  * This is commonly used when we just want to modify the resno or substitute
270  * a new expression.
271  */
272 TargetEntry *
274 {
276 
277  Assert(IsA(src_tle, TargetEntry));
278  memcpy(tle, src_tle, sizeof(TargetEntry));
279  return tle;
280 }
281 
282 /*
283  * makeFromExpr -
284  * creates a FromExpr node
285  */
286 FromExpr *
287 makeFromExpr(List *fromlist, Node *quals)
288 {
289  FromExpr *f = makeNode(FromExpr);
290 
291  f->fromlist = fromlist;
292  f->quals = quals;
293  return f;
294 }
295 
296 /*
297  * makeConst -
298  * creates a Const node
299  */
300 Const *
301 makeConst(Oid consttype,
302  int32 consttypmod,
303  Oid constcollid,
304  int constlen,
305  Datum constvalue,
306  bool constisnull,
307  bool constbyval)
308 {
309  Const *cnst = makeNode(Const);
310 
311  /*
312  * If it's a varlena value, force it to be in non-expanded (non-toasted)
313  * format; this avoids any possible dependency on external values and
314  * improves consistency of representation, which is important for equal().
315  */
316  if (!constisnull && constlen == -1)
317  constvalue = PointerGetDatum(PG_DETOAST_DATUM(constvalue));
318 
319  cnst->consttype = consttype;
320  cnst->consttypmod = consttypmod;
321  cnst->constcollid = constcollid;
322  cnst->constlen = constlen;
323  cnst->constvalue = constvalue;
324  cnst->constisnull = constisnull;
325  cnst->constbyval = constbyval;
326  cnst->location = -1; /* "unknown" */
327 
328  return cnst;
329 }
330 
331 /*
332  * makeNullConst -
333  * creates a Const node representing a NULL of the specified type/typmod
334  *
335  * This is a convenience routine that just saves a lookup of the type's
336  * storage properties.
337  */
338 Const *
339 makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
340 {
341  int16 typLen;
342  bool typByVal;
343 
344  get_typlenbyval(consttype, &typLen, &typByVal);
345  return makeConst(consttype,
346  consttypmod,
347  constcollid,
348  (int) typLen,
349  (Datum) 0,
350  true,
351  typByVal);
352 }
353 
354 /*
355  * makeBoolConst -
356  * creates a Const node representing a boolean value (can be NULL too)
357  */
358 Node *
359 makeBoolConst(bool value, bool isnull)
360 {
361  /* note that pg_type.h hardwires size of bool as 1 ... duplicate it */
362  return (Node *) makeConst(BOOLOID, -1, InvalidOid, 1,
363  BoolGetDatum(value), isnull, true);
364 }
365 
366 /*
367  * makeBoolExpr -
368  * creates a BoolExpr node
369  */
370 Expr *
372 {
374 
375  b->boolop = boolop;
376  b->args = args;
377  b->location = location;
378 
379  return (Expr *) b;
380 }
381 
382 /*
383  * makeAlias -
384  * creates an Alias node
385  *
386  * NOTE: the given name is copied, but the colnames list (if any) isn't.
387  */
388 Alias *
389 makeAlias(const char *aliasname, List *colnames)
390 {
391  Alias *a = makeNode(Alias);
392 
393  a->aliasname = pstrdup(aliasname);
394  a->colnames = colnames;
395 
396  return a;
397 }
398 
399 /*
400  * makeRelabelType -
401  * creates a RelabelType node
402  */
403 RelabelType *
404 makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid,
405  CoercionForm rformat)
406 {
408 
409  r->arg = arg;
410  r->resulttype = rtype;
411  r->resulttypmod = rtypmod;
412  r->resultcollid = rcollid;
413  r->relabelformat = rformat;
414  r->location = -1;
415 
416  return r;
417 }
418 
419 /*
420  * makeRangeVar -
421  * creates a RangeVar node (rather oversimplified case)
422  */
423 RangeVar *
424 makeRangeVar(char *schemaname, char *relname, int location)
425 {
426  RangeVar *r = makeNode(RangeVar);
427 
428  r->catalogname = NULL;
429  r->schemaname = schemaname;
430  r->relname = relname;
431  r->inh = true;
432  r->relpersistence = RELPERSISTENCE_PERMANENT;
433  r->alias = NULL;
434  r->location = location;
435 
436  return r;
437 }
438 
439 /*
440  * makeTypeName -
441  * build a TypeName node for an unqualified name.
442  *
443  * typmod is defaulted, but can be changed later by caller.
444  */
445 TypeName *
446 makeTypeName(char *typnam)
447 {
449 }
450 
451 /*
452  * makeTypeNameFromNameList -
453  * build a TypeName node for a String list representing a qualified name.
454  *
455  * typmod is defaulted, but can be changed later by caller.
456  */
457 TypeName *
459 {
460  TypeName *n = makeNode(TypeName);
461 
462  n->names = names;
463  n->typmods = NIL;
464  n->typemod = -1;
465  n->location = -1;
466  return n;
467 }
468 
469 /*
470  * makeTypeNameFromOid -
471  * build a TypeName node to represent a type already known by OID/typmod.
472  */
473 TypeName *
474 makeTypeNameFromOid(Oid typeOid, int32 typmod)
475 {
476  TypeName *n = makeNode(TypeName);
477 
478  n->typeOid = typeOid;
479  n->typemod = typmod;
480  n->location = -1;
481  return n;
482 }
483 
484 /*
485  * makeColumnDef -
486  * build a ColumnDef node to represent a simple column definition.
487  *
488  * Type and collation are specified by OID.
489  * Other properties are all basic to start with.
490  */
491 ColumnDef *
492 makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
493 {
495 
496  n->colname = pstrdup(colname);
497  n->typeName = makeTypeNameFromOid(typeOid, typmod);
498  n->inhcount = 0;
499  n->is_local = true;
500  n->is_not_null = false;
501  n->is_from_type = false;
502  n->storage = 0;
503  n->raw_default = NULL;
504  n->cooked_default = NULL;
505  n->collClause = NULL;
506  n->collOid = collOid;
507  n->constraints = NIL;
508  n->fdwoptions = NIL;
509  n->location = -1;
510 
511  return n;
512 }
513 
514 /*
515  * makeFuncExpr -
516  * build an expression tree representing a function call.
517  *
518  * The argument expressions must have been transformed already.
519  */
520 FuncExpr *
521 makeFuncExpr(Oid funcid, Oid rettype, List *args,
522  Oid funccollid, Oid inputcollid, CoercionForm fformat)
523 {
524  FuncExpr *funcexpr;
525 
526  funcexpr = makeNode(FuncExpr);
527  funcexpr->funcid = funcid;
528  funcexpr->funcresulttype = rettype;
529  funcexpr->funcretset = false; /* only allowed case here */
530  funcexpr->funcvariadic = false; /* only allowed case here */
531  funcexpr->funcformat = fformat;
532  funcexpr->funccollid = funccollid;
533  funcexpr->inputcollid = inputcollid;
534  funcexpr->args = args;
535  funcexpr->location = -1;
536 
537  return funcexpr;
538 }
539 
540 /*
541  * makeDefElem -
542  * build a DefElem node
543  *
544  * This is sufficient for the "typical" case with an unqualified option name
545  * and no special action.
546  */
547 DefElem *
548 makeDefElem(char *name, Node *arg, int location)
549 {
551 
552  res->defnamespace = NULL;
553  res->defname = name;
554  res->arg = arg;
555  res->defaction = DEFELEM_UNSPEC;
556  res->location = location;
557 
558  return res;
559 }
560 
561 /*
562  * makeDefElemExtended -
563  * build a DefElem node with all fields available to be specified
564  */
565 DefElem *
566 makeDefElemExtended(char *nameSpace, char *name, Node *arg,
567  DefElemAction defaction, int location)
568 {
570 
571  res->defnamespace = nameSpace;
572  res->defname = name;
573  res->arg = arg;
574  res->defaction = defaction;
575  res->location = location;
576 
577  return res;
578 }
579 
580 /*
581  * makeFuncCall -
582  *
583  * Initialize a FuncCall struct with the information every caller must
584  * supply. Any non-default parameters have to be inserted by the caller.
585  */
586 FuncCall *
587 makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
588 {
589  FuncCall *n = makeNode(FuncCall);
590 
591  n->funcname = name;
592  n->args = args;
593  n->agg_order = NIL;
594  n->agg_filter = NULL;
595  n->over = NULL;
596  n->agg_within_group = false;
597  n->agg_star = false;
598  n->agg_distinct = false;
599  n->func_variadic = false;
600  n->funcformat = funcformat;
601  n->location = location;
602  return n;
603 }
604 
605 /*
606  * make_opclause
607  * Creates an operator clause given its operator info, left operand
608  * and right operand (pass NULL to create single-operand clause),
609  * and collation info.
610  */
611 Expr *
612 make_opclause(Oid opno, Oid opresulttype, bool opretset,
613  Expr *leftop, Expr *rightop,
614  Oid opcollid, Oid inputcollid)
615 {
616  OpExpr *expr = makeNode(OpExpr);
617 
618  expr->opno = opno;
619  expr->opfuncid = InvalidOid;
620  expr->opresulttype = opresulttype;
621  expr->opretset = opretset;
622  expr->opcollid = opcollid;
623  expr->inputcollid = inputcollid;
624  if (rightop)
625  expr->args = list_make2(leftop, rightop);
626  else
627  expr->args = list_make1(leftop);
628  expr->location = -1;
629  return (Expr *) expr;
630 }
631 
632 /*
633  * make_andclause
634  *
635  * Creates an 'and' clause given a list of its subclauses.
636  */
637 Expr *
638 make_andclause(List *andclauses)
639 {
640  BoolExpr *expr = makeNode(BoolExpr);
641 
642  expr->boolop = AND_EXPR;
643  expr->args = andclauses;
644  expr->location = -1;
645  return (Expr *) expr;
646 }
647 
648 /*
649  * make_orclause
650  *
651  * Creates an 'or' clause given a list of its subclauses.
652  */
653 Expr *
654 make_orclause(List *orclauses)
655 {
656  BoolExpr *expr = makeNode(BoolExpr);
657 
658  expr->boolop = OR_EXPR;
659  expr->args = orclauses;
660  expr->location = -1;
661  return (Expr *) expr;
662 }
663 
664 /*
665  * make_notclause
666  *
667  * Create a 'not' clause given the expression to be negated.
668  */
669 Expr *
670 make_notclause(Expr *notclause)
671 {
672  BoolExpr *expr = makeNode(BoolExpr);
673 
674  expr->boolop = NOT_EXPR;
675  expr->args = list_make1(notclause);
676  expr->location = -1;
677  return (Expr *) expr;
678 }
679 
680 /*
681  * make_and_qual
682  *
683  * Variant of make_andclause for ANDing two qual conditions together.
684  * Qual conditions have the property that a NULL nodetree is interpreted
685  * as 'true'.
686  *
687  * NB: this makes no attempt to preserve AND/OR flatness; so it should not
688  * be used on a qual that has already been run through prepqual.c.
689  */
690 Node *
691 make_and_qual(Node *qual1, Node *qual2)
692 {
693  if (qual1 == NULL)
694  return qual2;
695  if (qual2 == NULL)
696  return qual1;
697  return (Node *) make_andclause(list_make2(qual1, qual2));
698 }
699 
700 /*
701  * The planner and executor usually represent qualification expressions
702  * as lists of boolean expressions with implicit AND semantics.
703  *
704  * These functions convert between an AND-semantics expression list and the
705  * ordinary representation of a boolean expression.
706  *
707  * Note that an empty list is considered equivalent to TRUE.
708  */
709 Expr *
711 {
712  if (andclauses == NIL)
713  return (Expr *) makeBoolConst(true, false);
714  else if (list_length(andclauses) == 1)
715  return (Expr *) linitial(andclauses);
716  else
717  return make_andclause(andclauses);
718 }
719 
720 List *
722 {
723  /*
724  * NB: because the parser sets the qual field to NULL in a query that has
725  * no WHERE clause, we must consider a NULL input clause as TRUE, even
726  * though one might more reasonably think it FALSE.
727  */
728  if (clause == NULL)
729  return NIL; /* NULL -> NIL list == TRUE */
730  else if (is_andclause(clause))
731  return ((BoolExpr *) clause)->args;
732  else if (IsA(clause, Const) &&
733  !((Const *) clause)->constisnull &&
734  DatumGetBool(((Const *) clause)->constvalue))
735  return NIL; /* constant TRUE input -> NIL list */
736  else
737  return list_make1(clause);
738 }
739 
740 /*
741  * makeIndexInfo
742  * create an IndexInfo node
743  */
744 IndexInfo *
745 makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions,
746  List *predicates, bool unique, bool nulls_not_distinct,
747  bool isready, bool concurrent, bool summarizing)
748 {
750 
751  n->ii_NumIndexAttrs = numattrs;
752  n->ii_NumIndexKeyAttrs = numkeyattrs;
753  Assert(n->ii_NumIndexKeyAttrs != 0);
755  n->ii_Unique = unique;
756  n->ii_NullsNotDistinct = nulls_not_distinct;
757  n->ii_ReadyForInserts = isready;
758  n->ii_CheckedUnchanged = false;
759  n->ii_IndexUnchanged = false;
760  n->ii_Concurrent = concurrent;
761  n->ii_Summarizing = summarizing;
762 
763  /* summarizing indexes cannot contain non-key attributes */
764  Assert(!summarizing || (numkeyattrs == numattrs));
765 
766  /* expressions */
767  n->ii_Expressions = expressions;
769 
770  /* predicates */
771  n->ii_Predicate = predicates;
772  n->ii_PredicateState = NULL;
773 
774  /* exclusion constraints */
775  n->ii_ExclusionOps = NULL;
776  n->ii_ExclusionProcs = NULL;
777  n->ii_ExclusionStrats = NULL;
778 
779  /* speculative inserts */
780  n->ii_UniqueOps = NULL;
781  n->ii_UniqueProcs = NULL;
782  n->ii_UniqueStrats = NULL;
783 
784  /* initialize index-build state to default */
785  n->ii_BrokenHotChain = false;
786  n->ii_ParallelWorkers = 0;
787 
788  /* set up for possible use by index AM */
789  n->ii_Am = amoid;
790  n->ii_AmCache = NULL;
792 
793  return n;
794 }
795 
796 /*
797  * makeGroupingSet
798  *
799  */
800 GroupingSet *
801 makeGroupingSet(GroupingSetKind kind, List *content, int location)
802 {
804 
805  n->kind = kind;
806  n->content = content;
807  n->location = location;
808  return n;
809 }
810 
811 /*
812  * makeVacuumRelation -
813  * create a VacuumRelation node
814  */
816 makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
817 {
819 
820  v->relation = relation;
821  v->oid = oid;
822  v->va_cols = va_cols;
823  return v;
824 }
825 
826 /*
827  * makeJsonFormat -
828  * creates a JsonFormat node
829  */
830 JsonFormat *
832 {
834 
835  jf->format_type = type;
836  jf->encoding = encoding;
837  jf->location = location;
838 
839  return jf;
840 }
841 
842 /*
843  * makeJsonValueExpr -
844  * creates a JsonValueExpr node
845  */
847 makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr,
849 {
851 
852  jve->raw_expr = raw_expr;
853  jve->formatted_expr = formatted_expr;
854  jve->format = format;
855 
856  return jve;
857 }
858 
859 /*
860  * makeJsonKeyValue -
861  * creates a JsonKeyValue node
862  */
863 Node *
865 {
867 
868  n->key = (Expr *) key;
870 
871  return (Node *) n;
872 }
873 
874 /*
875  * makeJsonIsPredicate -
876  * creates a JsonIsPredicate node
877  */
878 Node *
880  bool unique_keys, int location)
881 {
883 
884  n->expr = expr;
885  n->format = format;
886  n->item_type = item_type;
887  n->unique_keys = unique_keys;
888  n->location = location;
889 
890  return (Node *) n;
891 }
Datum boolop(PG_FUNCTION_ARGS)
Definition: _int_bool.c:418
int16 AttrNumber
Definition: attnum.h:21
#define InvalidAttrNumber
Definition: attnum.h:23
signed short int16
Definition: c.h:480
signed int int32
Definition: c.h:481
unsigned int Index
Definition: c.h:601
#define OidIsValid(objectId)
Definition: c.h:762
int errcode(int sqlerrcode)
Definition: elog.c:859
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
static struct @150 value
int b
Definition: isn.c:70
int a
Definition: isn.c:69
Assert(fmt[strlen(fmt) - 1] !='\n')
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2611
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2207
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1957
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1906
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Definition: makefuncs.c:612
Alias * makeAlias(const char *aliasname, List *colnames)
Definition: makefuncs.c:389
Var * makeWholeRowVar(RangeTblEntry *rte, int varno, Index varlevelsup, bool allowScalar)
Definition: makefuncs.c:135
FuncExpr * makeFuncExpr(Oid funcid, Oid rettype, List *args, Oid funccollid, Oid inputcollid, CoercionForm fformat)
Definition: makefuncs.c:521
TypeName * makeTypeName(char *typnam)
Definition: makefuncs.c:446
RelabelType * makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat)
Definition: makefuncs.c:404
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
Definition: makefuncs.c:105
Node * makeJsonKeyValue(Node *key, Node *value)
Definition: makefuncs.c:864
GroupingSet * makeGroupingSet(GroupingSetKind kind, List *content, int location)
Definition: makefuncs.c:801
Expr * make_notclause(Expr *notclause)
Definition: makefuncs.c:670
List * make_ands_implicit(Expr *clause)
Definition: makefuncs.c:721
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Definition: makefuncs.c:240
TypeName * makeTypeNameFromNameList(List *names)
Definition: makefuncs.c:458
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Definition: makefuncs.c:339
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:301
VacuumRelation * makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
Definition: makefuncs.c:816
Node * make_and_qual(Node *qual1, Node *qual2)
Definition: makefuncs.c:691
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:638
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Definition: makefuncs.c:424
FromExpr * makeFromExpr(List *fromlist, Node *quals)
Definition: makefuncs.c:287
DefElem * makeDefElem(char *name, Node *arg, int location)
Definition: makefuncs.c:548
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
Definition: makefuncs.c:492
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:66
Expr * make_ands_explicit(List *andclauses)
Definition: makefuncs.c:710
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
Definition: makefuncs.c:474
JsonFormat * makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
Definition: makefuncs.c:831
Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)
Definition: makefuncs.c:371
Node * makeBoolConst(bool value, bool isnull)
Definition: makefuncs.c:359
FuncCall * makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
Definition: makefuncs.c:587
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
Definition: makefuncs.c:847
TargetEntry * flatCopyTargetEntry(TargetEntry *src_tle)
Definition: makefuncs.c:273
IndexInfo * makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions, List *predicates, bool unique, bool nulls_not_distinct, bool isready, bool concurrent, bool summarizing)
Definition: makefuncs.c:745
A_Expr * makeA_Expr(A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr, int location)
Definition: makefuncs.c:30
Node * makeJsonIsPredicate(Node *expr, JsonFormat *format, JsonValueType item_type, bool unique_keys, int location)
Definition: makefuncs.c:879
Expr * make_orclause(List *orclauses)
Definition: makefuncs.c:654
DefElem * makeDefElemExtended(char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
Definition: makefuncs.c:566
A_Expr * makeSimpleA_Expr(A_Expr_Kind kind, char *name, Node *lexpr, Node *rexpr, int location)
Definition: makefuncs.c:48
char * pstrdup(const char *in)
Definition: mcxt.c:1683
MemoryContext CurrentMemoryContext
Definition: mcxt.c:131
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:284
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:788
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:105
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
#define makeNode(_type_)
Definition: nodes.h:155
#define castNode(_type_, nodeptr)
Definition: nodes.h:176
GroupingSetKind
Definition: parsenodes.h:1456
A_Expr_Kind
Definition: parsenodes.h:311
@ RTE_FUNCTION
Definition: parsenodes.h:1014
@ RTE_RELATION
Definition: parsenodes.h:1011
DefElemAction
Definition: parsenodes.h:800
@ DEFELEM_UNSPEC
Definition: parsenodes.h:801
void * arg
static char format
NameData relname
Definition: pg_class.h:38
int32 encoding
Definition: pg_database.h:41
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
#define list_make1(x1)
Definition: pg_list.h:212
#define linitial(l)
Definition: pg_list.h:178
#define list_make2(x1, x2)
Definition: pg_list.h:214
static bool DatumGetBool(Datum X)
Definition: postgres.h:90
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Datum BoolGetDatum(bool X)
Definition: postgres.h:102
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
JsonFormatType
Definition: primnodes.h:1593
BoolExprType
Definition: primnodes.h:886
@ AND_EXPR
Definition: primnodes.h:887
@ OR_EXPR
Definition: primnodes.h:887
@ NOT_EXPR
Definition: primnodes.h:887
JsonEncoding
Definition: primnodes.h:1581
CoercionForm
Definition: primnodes.h:689
JsonValueType
Definition: primnodes.h:1673
int location
Definition: primnodes.h:897
BoolExprType boolop
Definition: primnodes.h:895
List * args
Definition: primnodes.h:896
bool is_not_null
Definition: parsenodes.h:727
CollateClause * collClause
Definition: parsenodes.h:737
int location
Definition: parsenodes.h:741
List * constraints
Definition: parsenodes.h:739
Node * cooked_default
Definition: parsenodes.h:732
int inhcount
Definition: parsenodes.h:725
char * colname
Definition: parsenodes.h:722
TypeName * typeName
Definition: parsenodes.h:723
bool is_from_type
Definition: parsenodes.h:728
List * fdwoptions
Definition: parsenodes.h:740
Node * raw_default
Definition: parsenodes.h:731
char storage
Definition: parsenodes.h:729
Oid collOid
Definition: parsenodes.h:738
bool is_local
Definition: parsenodes.h:726
Oid consttype
Definition: primnodes.h:298
Node * quals
Definition: primnodes.h:2062
List * fromlist
Definition: primnodes.h:2061
bool agg_within_group
Definition: parsenodes.h:430
int location
Definition: parsenodes.h:435
CoercionForm funcformat
Definition: parsenodes.h:434
Node * agg_filter
Definition: parsenodes.h:428
List * agg_order
Definition: parsenodes.h:427
List * funcname
Definition: parsenodes.h:425
List * args
Definition: parsenodes.h:426
bool agg_star
Definition: parsenodes.h:431
bool agg_distinct
Definition: parsenodes.h:432
bool func_variadic
Definition: parsenodes.h:433
struct WindowDef * over
Definition: parsenodes.h:429
Oid funcid
Definition: primnodes.h:706
List * args
Definition: primnodes.h:724
int location
Definition: primnodes.h:726
List * content
Definition: parsenodes.h:1468
bool ii_Unique
Definition: execnodes.h:197
uint16 * ii_ExclusionStrats
Definition: execnodes.h:193
bool ii_BrokenHotChain
Definition: execnodes.h:203
int ii_NumIndexAttrs
Definition: execnodes.h:184
void * ii_AmCache
Definition: execnodes.h:207
bool ii_CheckedUnchanged
Definition: execnodes.h:200
Oid * ii_UniqueOps
Definition: execnodes.h:194
ExprState * ii_PredicateState
Definition: execnodes.h:190
Oid * ii_ExclusionOps
Definition: execnodes.h:191
bool ii_NullsNotDistinct
Definition: execnodes.h:198
int ii_ParallelWorkers
Definition: execnodes.h:205
bool ii_Concurrent
Definition: execnodes.h:202
uint16 * ii_UniqueStrats
Definition: execnodes.h:196
int ii_NumIndexKeyAttrs
Definition: execnodes.h:185
List * ii_ExpressionsState
Definition: execnodes.h:188
List * ii_Expressions
Definition: execnodes.h:187
bool ii_IndexUnchanged
Definition: execnodes.h:201
Oid * ii_ExclusionProcs
Definition: execnodes.h:192
Oid ii_Am
Definition: execnodes.h:206
bool ii_Summarizing
Definition: execnodes.h:204
Oid * ii_UniqueProcs
Definition: execnodes.h:195
MemoryContext ii_Context
Definition: execnodes.h:208
bool ii_ReadyForInserts
Definition: execnodes.h:199
List * ii_Predicate
Definition: execnodes.h:189
int location
Definition: primnodes.h:1609
JsonEncoding encoding
Definition: primnodes.h:1608
JsonFormatType format_type
Definition: primnodes.h:1607
JsonFormat * format
Definition: primnodes.h:1688
JsonValueType item_type
Definition: primnodes.h:1689
JsonValueExpr * value
Definition: parsenodes.h:1727
Expr * formatted_expr
Definition: primnodes.h:1636
JsonFormat * format
Definition: primnodes.h:1637
Expr * raw_expr
Definition: primnodes.h:1635
Definition: pg_list.h:54
Definition: nodes.h:129
int location
Definition: primnodes.h:795
Oid opno
Definition: primnodes.h:774
List * args
Definition: primnodes.h:792
bool funcordinality
Definition: parsenodes.h:1154
List * functions
Definition: parsenodes.h:1153
RTEKind rtekind
Definition: parsenodes.h:1030
int location
Definition: primnodes.h:94
char * relname
Definition: primnodes.h:82
bool inh
Definition: primnodes.h:85
Alias * alias
Definition: primnodes.h:91
char relpersistence
Definition: primnodes.h:88
char * catalogname
Definition: primnodes.h:76
char * schemaname
Definition: primnodes.h:79
Oid resulttype
Definition: primnodes.h:1141
Expr * arg
Definition: primnodes.h:1140
Expr * expr
Definition: primnodes.h:1943
AttrNumber resno
Definition: primnodes.h:1945
Index ressortgroupref
Definition: primnodes.h:1949
Oid typeOid
Definition: parsenodes.h:268
List * names
Definition: parsenodes.h:267
int32 typemod
Definition: parsenodes.h:272
int location
Definition: parsenodes.h:274
List * typmods
Definition: parsenodes.h:271
RangeVar * relation
Definition: parsenodes.h:3709
Definition: primnodes.h:234
AttrNumber varattno
Definition: primnodes.h:246
int varno
Definition: primnodes.h:241
Index varlevelsup
Definition: primnodes.h:266
int location
Definition: primnodes.h:279
String * makeString(char *str)
Definition: value.c:63
const char * type
const char * name