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