PostgreSQL Source Code: src/backend/nodes/makefuncs.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
17
23
24
25
26
27
28
31 Node *lexpr, Node *rexpr, int location)
32{
34
35 a->kind = kind;
37 a->lexpr = lexpr;
38 a->rexpr = rexpr;
39 a->location = location;
40 return a;
41}
42
43
44
45
46
49 Node *lexpr, Node *rexpr, int location)
50{
52
53 a->kind = kind;
55 a->lexpr = lexpr;
56 a->rexpr = rexpr;
57 a->location = location;
58 return a;
59}
60
61
62
63
64
68 Oid vartype,
70 Oid varcollid,
71 Index varlevelsup)
72{
74
75 var->varno = varno;
77 var->vartype = vartype;
78 var->vartypmod = vartypmod;
79 var->varcollid = varcollid;
81
82
83
84
85
86
87
88
89
91 var->varnullingrels = NULL;
92 var->varnosyn = (Index) varno;
93 var->varattnosyn = varattno;
94
95
97
98 return var;
99}
100
101
102
103
104
105
109{
115 0);
116}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
138 int varno,
139 Index varlevelsup,
140 bool allowScalar)
141{
142 Var *result;
143 Oid toid;
145
147 {
149
153 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
154 errmsg("relation \"%s\" does not have a composite type",
158 toid,
159 -1,
161 varlevelsup);
162 break;
163
165
166
167
168
169
170
171
172
174 {
175
179 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
180 errmsg("relation \"%s\" does not have a composite type",
182 }
184 {
185
186
187
188
189
190
191
192 Assert(!allowScalar);
196 toid = RECORDOID;
197 }
198 else
199 {
200
201 toid = RECORDOID;
202 }
205 toid,
206 -1,
208 varlevelsup);
209 break;
210
212
213
214
215
216
217
219 {
220
223 RECORDOID,
224 -1,
226 varlevelsup);
227 break;
228 }
229
233 {
234
237 toid,
238 -1,
240 varlevelsup);
241 }
242 else if (allowScalar)
243 {
244
246 1,
247 toid,
248 -1,
250 varlevelsup);
251 }
252 else
253 {
254
257 RECORDOID,
258 -1,
260 varlevelsup);
261 }
262 break;
263
264 default:
265
266
267
268
269
270
271
274 RECORDOID,
275 -1,
277 varlevelsup);
278 break;
279 }
280
281 return result;
282}
283
284
285
286
287
291 char *resname,
292 bool resjunk)
293{
295
296 tle->expr = expr;
297 tle->resno = resno;
298 tle->resname = resname;
299
300
301
302
303
304
307 tle->resorigcol = 0;
308
309 tle->resjunk = resjunk;
310
311 return tle;
312}
313
314
315
316
317
318
319
320
323{
325
327 memcpy(tle, src_tle, sizeof(TargetEntry));
328 return tle;
329}
330
331
332
333
334
337{
339
341 f->quals = quals;
342 return f;
343}
344
345
346
347
348
351 int32 consttypmod,
352 Oid constcollid,
353 int constlen,
354 Datum constvalue,
355 bool constisnull,
356 bool constbyval)
357{
359
360
361
362
363
364
365 if (!constisnull && constlen == -1)
367
369 cnst->consttypmod = consttypmod;
370 cnst->constcollid = constcollid;
371 cnst->constlen = constlen;
372 cnst->constvalue = constvalue;
373 cnst->constisnull = constisnull;
374 cnst->constbyval = constbyval;
375 cnst->location = -1;
376
377 return cnst;
378}
379
380
381
382
383
384
385
386
389{
391 bool typByVal;
392
395 consttypmod,
396 constcollid,
397 (int) typLen,
399 true,
400 typByVal);
401}
402
403
404
405
406
409{
410
413}
414
415
416
417
418
421{
423
426 b->location = location;
427
429}
430
431
432
433
434
435
436
439{
441
442 a->aliasname = pstrdup(aliasname);
443 a->colnames = colnames;
444
445 return a;
446}
447
448
449
450
451
455{
457
460 r->resulttypmod = rtypmod;
461 r->resultcollid = rcollid;
462 r->relabelformat = rformat;
464
465 return r;
466}
467
468
469
470
471
474{
476
480 r->inh = true;
484
485 return r;
486}
487
488
489
490
491
494{
496
508
509 return notnull;
510}
511
512
513
514
515
516
517
520{
522}
523
524
525
526
527
528
529
532{
534
535 n->names = names;
539 return n;
540}
541
542
543
544
545
548{
550
554 return n;
555}
556
557
558
559
560
561
562
563
566{
568
583
584 return n;
585}
586
587
588
589
590
591
592
596{
598
600 funcexpr->funcid = funcid;
601 funcexpr->funcresulttype = rettype;
602 funcexpr->funcretset = false;
603 funcexpr->funcvariadic = false;
604 funcexpr->funcformat = fformat;
605 funcexpr->funccollid = funccollid;
606 funcexpr->inputcollid = inputcollid;
609
610 return funcexpr;
611}
612
613
614
615
616
619{
621
622 n->val.sval.type = T_String;
625
626 return (Node *) n;
627}
628
629
630
631
632
633
634
635
638{
640
646
647 return res;
648}
649
650
651
652
653
657{
659
665
666 return res;
667}
668
669
670
671
672
673
674
677{
679
684 n->over = NULL;
691 return n;
692}
693
694
695
696
697
698
699
703 Oid opcollid, Oid inputcollid)
704{
706
707 expr->opno = opno;
709 expr->opresulttype = opresulttype;
710 expr->opretset = opretset;
711 expr->opcollid = opcollid;
712 expr->inputcollid = inputcollid;
713 if (rightop)
715 else
718 return (Expr *) expr;
719}
720
721
722
723
724
725
728{
730
732 expr->args = andclauses;
734 return (Expr *) expr;
735}
736
737
738
739
740
741
744{
746
748 expr->args = orclauses;
750 return (Expr *) expr;
751}
752
753
754
755
756
757
760{
762
766 return (Expr *) expr;
767}
768
769
770
771
772
773
774
775
776
777
778
781{
782 if (qual1 == NULL)
783 return qual2;
784 if (qual2 == NULL)
785 return qual1;
787}
788
789
790
791
792
793
794
795
796
797
800{
801 if (andclauses == NIL)
805 else
807}
808
811{
812
813
814
815
816
817 if (clause == NULL)
818 return NIL;
820 return ((BoolExpr *) clause)->args;
821 else if (IsA(clause, Const) &&
822 !((Const *) clause)->constisnull &&
824 return NIL;
825 else
827}
828
829
830
831
832
835 List *predicates, bool unique, bool nulls_not_distinct,
836 bool isready, bool concurrent, bool summarizing,
837 bool withoutoverlaps)
838{
840
853
854
855 Assert(!summarizing || (numkeyattrs == numattrs));
856
857
860
861
864
865
869
870
874
875
878
879
880 n->ii_Am = amoid;
883
884 return n;
885}
886
887
888
889
890
893{
895
896 n->kind = kind;
899 return n;
900}
901
902
903
904
905
908{
910
912 v->oid = oid;
914 return v;
915}
916
917
918
919
920
923{
925
929
930 return jf;
931}
932
933
934
935
936
940{
942
946
947 return jve;
948}
949
950
951
952
953
956{
958
959 behavior->btype = btype;
960 behavior->expr = expr;
961 behavior->location = location;
962
963 return behavior;
964}
965
966
967
968
969
972{
974
977
978 return (Node *) n;
979}
980
981
982
983
984
987 bool unique_keys, int location)
988{
990
991 n->expr = expr;
996
997 return (Node *) n;
998}
999
1000
1001
1002
1003
1006 int name_location)
1007{
1009
1010 Assert(string != NULL);
1012 if (name != NULL)
1014
1016 pathspec->location = string_location;
1017
1018 return pathspec;
1019}
1020
1021
1022
1023
1024
1027{
1029
1031 path->value = pathvalue;
1032 path->name = pathname;
1033
1034 return path;
1035}
Datum boolop(PG_FUNCTION_ARGS)
#define InvalidAttrNumber
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_DETOAST_DATUM(datum)
Assert(PointerIsAligned(start, uint64))
char * get_rel_name(Oid relid)
bool type_is_rowtype(Oid typid)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Oid get_rel_type_id(Oid relid)
Alias * makeAlias(const char *aliasname, List *colnames)
Expr * make_orclause(List *orclauses)
Expr * make_ands_explicit(List *andclauses)
Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)
VacuumRelation * makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
DefElem * makeDefElem(char *name, Node *arg, int location)
A_Expr * makeA_Expr(A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr, int location)
TypeName * makeTypeNameFromNameList(List *names)
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
FromExpr * makeFromExpr(List *fromlist, Node *quals)
JsonBehavior * makeJsonBehavior(JsonBehaviorType btype, Node *expr, int location)
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)
JsonTablePath * makeJsonTablePath(Const *pathvalue, char *pathname)
DefElem * makeDefElemExtended(char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
A_Expr * makeSimpleA_Expr(A_Expr_Kind kind, char *name, Node *lexpr, Node *rexpr, int location)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Node * makeJsonKeyValue(Node *key, Node *value)
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Var * makeWholeRowVar(RangeTblEntry *rte, int varno, Index varlevelsup, bool allowScalar)
Node * makeBoolConst(bool value, bool isnull)
RelabelType * makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat)
Node * makeStringConst(char *str, int location)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
TypeName * makeTypeName(char *typnam)
Expr * make_andclause(List *andclauses)
FuncCall * makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
JsonTablePathSpec * makeJsonTablePathSpec(char *string, char *name, int string_location, int name_location)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
FuncExpr * makeFuncExpr(Oid funcid, Oid rettype, List *args, Oid funccollid, Oid inputcollid, CoercionForm fformat)
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Constraint * makeNotNullConstraint(String *colname)
Expr * make_notclause(Expr *notclause)
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
Node * make_and_qual(Node *qual1, Node *qual2)
JsonFormat * makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
GroupingSet * makeGroupingSet(GroupingSetKind kind, List *content, int location)
List * make_ands_implicit(Expr *clause)
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
TargetEntry * flatCopyTargetEntry(TargetEntry *src_tle)
Node * makeJsonIsPredicate(Node *expr, JsonFormat *format, JsonValueType item_type, bool unique_keys, int location)
char * pstrdup(const char *in)
MemoryContext CurrentMemoryContext
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
static bool is_andclause(const void *clause)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
#define list_make2(x1, x2)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
CollateClause * collClause
uint16 * ii_ExclusionStrats
ExprState * ii_PredicateState
List * ii_ExpressionsState
JsonFormatType format_type
VarReturningType varreturningtype
String * makeString(char *str)