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