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  * makeStringConst -
542  * build a A_Const node of type T_String for given string
543  */
544 Node *
545 makeStringConst(char *str, int location)
546 {
547  A_Const *n = makeNode(A_Const);
548 
549  n->val.sval.type = T_String;
550  n->val.sval.sval = str;
551  n->location = location;
552 
553  return (Node *) n;
554 }
555 
556 /*
557  * makeDefElem -
558  * build a DefElem node
559  *
560  * This is sufficient for the "typical" case with an unqualified option name
561  * and no special action.
562  */
563 DefElem *
564 makeDefElem(char *name, Node *arg, int location)
565 {
567 
568  res->defnamespace = NULL;
569  res->defname = name;
570  res->arg = arg;
571  res->defaction = DEFELEM_UNSPEC;
572  res->location = location;
573 
574  return res;
575 }
576 
577 /*
578  * makeDefElemExtended -
579  * build a DefElem node with all fields available to be specified
580  */
581 DefElem *
582 makeDefElemExtended(char *nameSpace, char *name, Node *arg,
583  DefElemAction defaction, int location)
584 {
586 
587  res->defnamespace = nameSpace;
588  res->defname = name;
589  res->arg = arg;
590  res->defaction = defaction;
591  res->location = location;
592 
593  return res;
594 }
595 
596 /*
597  * makeFuncCall -
598  *
599  * Initialize a FuncCall struct with the information every caller must
600  * supply. Any non-default parameters have to be inserted by the caller.
601  */
602 FuncCall *
603 makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
604 {
605  FuncCall *n = makeNode(FuncCall);
606 
607  n->funcname = name;
608  n->args = args;
609  n->agg_order = NIL;
610  n->agg_filter = NULL;
611  n->over = NULL;
612  n->agg_within_group = false;
613  n->agg_star = false;
614  n->agg_distinct = false;
615  n->func_variadic = false;
616  n->funcformat = funcformat;
617  n->location = location;
618  return n;
619 }
620 
621 /*
622  * make_opclause
623  * Creates an operator clause given its operator info, left operand
624  * and right operand (pass NULL to create single-operand clause),
625  * and collation info.
626  */
627 Expr *
628 make_opclause(Oid opno, Oid opresulttype, bool opretset,
629  Expr *leftop, Expr *rightop,
630  Oid opcollid, Oid inputcollid)
631 {
632  OpExpr *expr = makeNode(OpExpr);
633 
634  expr->opno = opno;
635  expr->opfuncid = InvalidOid;
636  expr->opresulttype = opresulttype;
637  expr->opretset = opretset;
638  expr->opcollid = opcollid;
639  expr->inputcollid = inputcollid;
640  if (rightop)
641  expr->args = list_make2(leftop, rightop);
642  else
643  expr->args = list_make1(leftop);
644  expr->location = -1;
645  return (Expr *) expr;
646 }
647 
648 /*
649  * make_andclause
650  *
651  * Creates an 'and' clause given a list of its subclauses.
652  */
653 Expr *
654 make_andclause(List *andclauses)
655 {
656  BoolExpr *expr = makeNode(BoolExpr);
657 
658  expr->boolop = AND_EXPR;
659  expr->args = andclauses;
660  expr->location = -1;
661  return (Expr *) expr;
662 }
663 
664 /*
665  * make_orclause
666  *
667  * Creates an 'or' clause given a list of its subclauses.
668  */
669 Expr *
670 make_orclause(List *orclauses)
671 {
672  BoolExpr *expr = makeNode(BoolExpr);
673 
674  expr->boolop = OR_EXPR;
675  expr->args = orclauses;
676  expr->location = -1;
677  return (Expr *) expr;
678 }
679 
680 /*
681  * make_notclause
682  *
683  * Create a 'not' clause given the expression to be negated.
684  */
685 Expr *
686 make_notclause(Expr *notclause)
687 {
688  BoolExpr *expr = makeNode(BoolExpr);
689 
690  expr->boolop = NOT_EXPR;
691  expr->args = list_make1(notclause);
692  expr->location = -1;
693  return (Expr *) expr;
694 }
695 
696 /*
697  * make_and_qual
698  *
699  * Variant of make_andclause for ANDing two qual conditions together.
700  * Qual conditions have the property that a NULL nodetree is interpreted
701  * as 'true'.
702  *
703  * NB: this makes no attempt to preserve AND/OR flatness; so it should not
704  * be used on a qual that has already been run through prepqual.c.
705  */
706 Node *
707 make_and_qual(Node *qual1, Node *qual2)
708 {
709  if (qual1 == NULL)
710  return qual2;
711  if (qual2 == NULL)
712  return qual1;
713  return (Node *) make_andclause(list_make2(qual1, qual2));
714 }
715 
716 /*
717  * The planner and executor usually represent qualification expressions
718  * as lists of boolean expressions with implicit AND semantics.
719  *
720  * These functions convert between an AND-semantics expression list and the
721  * ordinary representation of a boolean expression.
722  *
723  * Note that an empty list is considered equivalent to TRUE.
724  */
725 Expr *
727 {
728  if (andclauses == NIL)
729  return (Expr *) makeBoolConst(true, false);
730  else if (list_length(andclauses) == 1)
731  return (Expr *) linitial(andclauses);
732  else
733  return make_andclause(andclauses);
734 }
735 
736 List *
738 {
739  /*
740  * NB: because the parser sets the qual field to NULL in a query that has
741  * no WHERE clause, we must consider a NULL input clause as TRUE, even
742  * though one might more reasonably think it FALSE.
743  */
744  if (clause == NULL)
745  return NIL; /* NULL -> NIL list == TRUE */
746  else if (is_andclause(clause))
747  return ((BoolExpr *) clause)->args;
748  else if (IsA(clause, Const) &&
749  !((Const *) clause)->constisnull &&
750  DatumGetBool(((Const *) clause)->constvalue))
751  return NIL; /* constant TRUE input -> NIL list */
752  else
753  return list_make1(clause);
754 }
755 
756 /*
757  * makeIndexInfo
758  * create an IndexInfo node
759  */
760 IndexInfo *
761 makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions,
762  List *predicates, bool unique, bool nulls_not_distinct,
763  bool isready, bool concurrent, bool summarizing)
764 {
766 
767  n->ii_NumIndexAttrs = numattrs;
768  n->ii_NumIndexKeyAttrs = numkeyattrs;
769  Assert(n->ii_NumIndexKeyAttrs != 0);
771  n->ii_Unique = unique;
772  n->ii_NullsNotDistinct = nulls_not_distinct;
773  n->ii_ReadyForInserts = isready;
774  n->ii_CheckedUnchanged = false;
775  n->ii_IndexUnchanged = false;
776  n->ii_Concurrent = concurrent;
777  n->ii_Summarizing = summarizing;
778 
779  /* summarizing indexes cannot contain non-key attributes */
780  Assert(!summarizing || (numkeyattrs == numattrs));
781 
782  /* expressions */
783  n->ii_Expressions = expressions;
785 
786  /* predicates */
787  n->ii_Predicate = predicates;
788  n->ii_PredicateState = NULL;
789 
790  /* exclusion constraints */
791  n->ii_ExclusionOps = NULL;
792  n->ii_ExclusionProcs = NULL;
793  n->ii_ExclusionStrats = NULL;
794 
795  /* speculative inserts */
796  n->ii_UniqueOps = NULL;
797  n->ii_UniqueProcs = NULL;
798  n->ii_UniqueStrats = NULL;
799 
800  /* initialize index-build state to default */
801  n->ii_BrokenHotChain = false;
802  n->ii_ParallelWorkers = 0;
803 
804  /* set up for possible use by index AM */
805  n->ii_Am = amoid;
806  n->ii_AmCache = NULL;
808 
809  return n;
810 }
811 
812 /*
813  * makeGroupingSet
814  *
815  */
816 GroupingSet *
817 makeGroupingSet(GroupingSetKind kind, List *content, int location)
818 {
820 
821  n->kind = kind;
822  n->content = content;
823  n->location = location;
824  return n;
825 }
826 
827 /*
828  * makeVacuumRelation -
829  * create a VacuumRelation node
830  */
832 makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
833 {
835 
836  v->relation = relation;
837  v->oid = oid;
838  v->va_cols = va_cols;
839  return v;
840 }
841 
842 /*
843  * makeJsonFormat -
844  * creates a JsonFormat node
845  */
846 JsonFormat *
848 {
850 
851  jf->format_type = type;
852  jf->encoding = encoding;
853  jf->location = location;
854 
855  return jf;
856 }
857 
858 /*
859  * makeJsonValueExpr -
860  * creates a JsonValueExpr node
861  */
863 makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr,
865 {
867 
868  jve->raw_expr = raw_expr;
869  jve->formatted_expr = formatted_expr;
870  jve->format = format;
871 
872  return jve;
873 }
874 
875 /*
876  * makeJsonBehavior -
877  * creates a JsonBehavior node
878  */
879 JsonBehavior *
880 makeJsonBehavior(JsonBehaviorType btype, Node *expr, int location)
881 {
882  JsonBehavior *behavior = makeNode(JsonBehavior);
883 
884  behavior->btype = btype;
885  behavior->expr = expr;
886  behavior->location = location;
887 
888  return behavior;
889 }
890 
891 /*
892  * makeJsonKeyValue -
893  * creates a JsonKeyValue node
894  */
895 Node *
897 {
899 
900  n->key = (Expr *) key;
902 
903  return (Node *) n;
904 }
905 
906 /*
907  * makeJsonIsPredicate -
908  * creates a JsonIsPredicate node
909  */
910 Node *
912  bool unique_keys, int location)
913 {
915 
916  n->expr = expr;
917  n->format = format;
918  n->item_type = item_type;
919  n->unique_keys = unique_keys;
920  n->location = location;
921 
922  return (Node *) n;
923 }
924 
925 /*
926  * makeJsonTablePathSpec -
927  * Make JsonTablePathSpec node from given path string and name (if any)
928  */
930 makeJsonTablePathSpec(char *string, char *name, int string_location,
931  int name_location)
932 {
934 
935  Assert(string != NULL);
936  pathspec->string = makeStringConst(string, string_location);
937  if (name != NULL)
938  pathspec->name = pstrdup(name);
939 
940  pathspec->name_location = name_location;
941  pathspec->location = string_location;
942 
943  return pathspec;
944 }
945 
946 /*
947  * makeJsonTablePath -
948  * Make JsonTablePath node for given path string and name
949  */
951 makeJsonTablePath(Const *pathvalue, char *pathname)
952 {
954 
955  Assert(IsA(pathvalue, Const));
956  path->value = pathvalue;
957  path->name = pathname;
958 
959  return path;
960 }
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:493
signed int int32
Definition: c.h:494
#define Assert(condition)
Definition: c.h:858
unsigned int Index
Definition: c.h:614
#define OidIsValid(objectId)
Definition: c.h:775
int errcode(int sqlerrcode)
Definition: elog.c:855
int errmsg(const char *fmt,...)
Definition: elog.c:1068
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
const char * str
static struct @155 value
int b
Definition: isn.c:70
int a
Definition: isn.c:69
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2655
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2251
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1979
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1928
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Definition: makefuncs.c:628
JsonTablePathSpec * makeJsonTablePathSpec(char *string, char *name, int string_location, int name_location)
Definition: makefuncs.c:930
JsonTablePath * makeJsonTablePath(Const *pathvalue, char *pathname)
Definition: makefuncs.c:951
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
JsonBehavior * makeJsonBehavior(JsonBehaviorType btype, Node *expr, int location)
Definition: makefuncs.c:880
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
Definition: makefuncs.c:105
Node * makeJsonKeyValue(Node *key, Node *value)
Definition: makefuncs.c:896
GroupingSet * makeGroupingSet(GroupingSetKind kind, List *content, int location)
Definition: makefuncs.c:817
Expr * make_notclause(Expr *notclause)
Definition: makefuncs.c:686
List * make_ands_implicit(Expr *clause)
Definition: makefuncs.c:737
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
Node * makeStringConst(char *str, int location)
Definition: makefuncs.c:545
VacuumRelation * makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
Definition: makefuncs.c:832
Node * make_and_qual(Node *qual1, Node *qual2)
Definition: makefuncs.c:707
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:654
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:564
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:726
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
Definition: makefuncs.c:474
JsonFormat * makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
Definition: makefuncs.c:847
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:603
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
Definition: makefuncs.c:863
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:761
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:911
Expr * make_orclause(List *orclauses)
Definition: makefuncs.c:670
DefElem * makeDefElemExtended(char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
Definition: makefuncs.c:582
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:1696
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:298
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:816
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:1501
A_Expr_Kind
Definition: parsenodes.h:312
@ RTE_FUNCTION
Definition: parsenodes.h:1031
@ RTE_RELATION
Definition: parsenodes.h:1028
DefElemAction
Definition: parsenodes.h:804
@ DEFELEM_UNSPEC
Definition: parsenodes.h:805
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:1637
BoolExprType
Definition: primnodes.h:930
@ AND_EXPR
Definition: primnodes.h:931
@ OR_EXPR
Definition: primnodes.h:931
@ NOT_EXPR
Definition: primnodes.h:931
JsonEncoding
Definition: primnodes.h:1625
JsonBehaviorType
Definition: primnodes.h:1760
CoercionForm
Definition: primnodes.h:733
JsonValueType
Definition: primnodes.h:1717
union ValUnion val
Definition: parsenodes.h:362
ParseLoc location
Definition: parsenodes.h:364
BoolExprType boolop
Definition: primnodes.h:939
List * args
Definition: primnodes.h:940
ParseLoc location
Definition: primnodes.h:941
bool is_not_null
Definition: parsenodes.h:731
CollateClause * collClause
Definition: parsenodes.h:741
List * constraints
Definition: parsenodes.h:743
Node * cooked_default
Definition: parsenodes.h:736
int inhcount
Definition: parsenodes.h:729
char * colname
Definition: parsenodes.h:726
TypeName * typeName
Definition: parsenodes.h:727
bool is_from_type
Definition: parsenodes.h:732
List * fdwoptions
Definition: parsenodes.h:744
Node * raw_default
Definition: parsenodes.h:735
char storage
Definition: parsenodes.h:733
Oid collOid
Definition: parsenodes.h:742
bool is_local
Definition: parsenodes.h:730
ParseLoc location
Definition: parsenodes.h:745
Oid consttype
Definition: primnodes.h:312
Node * quals
Definition: primnodes.h:2305
List * fromlist
Definition: primnodes.h:2304
bool agg_within_group
Definition: parsenodes.h:431
CoercionForm funcformat
Definition: parsenodes.h:435
Node * agg_filter
Definition: parsenodes.h:429
List * agg_order
Definition: parsenodes.h:428
List * funcname
Definition: parsenodes.h:426
List * args
Definition: parsenodes.h:427
bool agg_star
Definition: parsenodes.h:432
bool agg_distinct
Definition: parsenodes.h:433
ParseLoc location
Definition: parsenodes.h:436
bool func_variadic
Definition: parsenodes.h:434
struct WindowDef * over
Definition: parsenodes.h:430
ParseLoc location
Definition: primnodes.h:770
Oid funcid
Definition: primnodes.h:750
List * args
Definition: primnodes.h:768
List * content
Definition: parsenodes.h:1513
ParseLoc location
Definition: parsenodes.h:1514
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
Node * expr
Definition: primnodes.h:1787
ParseLoc location
Definition: primnodes.h:1789
JsonBehaviorType btype
Definition: primnodes.h:1786
ParseLoc location
Definition: primnodes.h:1653
JsonEncoding encoding
Definition: primnodes.h:1652
JsonFormatType format_type
Definition: primnodes.h:1651
JsonFormat * format
Definition: primnodes.h:1732
JsonValueType item_type
Definition: primnodes.h:1733
ParseLoc location
Definition: primnodes.h:1735
JsonValueExpr * value
Definition: parsenodes.h:1879
ParseLoc name_location
Definition: parsenodes.h:1816
Const * value
Definition: primnodes.h:1867
Expr * formatted_expr
Definition: primnodes.h:1680
JsonFormat * format
Definition: primnodes.h:1681
Expr * raw_expr
Definition: primnodes.h:1679
Definition: pg_list.h:54
Definition: nodes.h:129
Oid opno
Definition: primnodes.h:818
List * args
Definition: primnodes.h:836
ParseLoc location
Definition: primnodes.h:839
bool funcordinality
Definition: parsenodes.h:1189
List * functions
Definition: parsenodes.h:1187
RTEKind rtekind
Definition: parsenodes.h:1057
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
ParseLoc location
Definition: primnodes.h:94
char * schemaname
Definition: primnodes.h:79
Oid resulttype
Definition: primnodes.h:1185
ParseLoc location
Definition: primnodes.h:1192
Expr * arg
Definition: primnodes.h:1184
char * sval
Definition: value.h:68
Expr * expr
Definition: primnodes.h:2186
AttrNumber resno
Definition: primnodes.h:2188
Index ressortgroupref
Definition: primnodes.h:2192
Oid typeOid
Definition: parsenodes.h:269
List * names
Definition: parsenodes.h:268
int32 typemod
Definition: parsenodes.h:273
ParseLoc location
Definition: parsenodes.h:275
List * typmods
Definition: parsenodes.h:272
RangeVar * relation
Definition: parsenodes.h:3860
Definition: primnodes.h:248
ParseLoc location
Definition: primnodes.h:293
AttrNumber varattno
Definition: primnodes.h:260
int varno
Definition: primnodes.h:255
Index varlevelsup
Definition: primnodes.h:280
String sval
Definition: parsenodes.h:353
String * makeString(char *str)
Definition: value.c:63
const char * type
const char * name