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