PostgreSQL Source Code: src/backend/parser/parse_func.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
36
37
38
39typedef enum
40{
44
46 List *fargs, int numAggregatedArgs,
47 Oid *actual_arg_types, Oid *declared_arg_types);
50 Node *first_arg, int location);
52 int nargs, const Oid *argtypes,
53 bool include_out_arguments, bool missing_ok,
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
91 Node *last_srf, FuncCall *fn, bool proc_call, int location)
92{
93 bool is_column = (fn == NULL);
94 List *agg_order = (fn ? fn->agg_order : NIL);
95 Expr *agg_filter = NULL;
97 bool agg_within_group = (fn ? fn->agg_within_group : false);
98 bool agg_star = (fn ? fn->agg_star : false);
99 bool agg_distinct = (fn ? fn->agg_distinct : false);
100 bool func_variadic = (fn ? fn->func_variadic : false);
102 bool could_be_projection;
103 Oid rettype;
104 Oid funcid;
106 Node *first_arg = NULL;
107 int nargs;
108 int nargsplusdefs;
110 Oid *declared_arg_types;
111 List *argnames;
112 List *argdefaults;
113 Node *retval;
114 bool retset;
115 int nvargs;
116 Oid vatype;
118 char aggkind = 0;
120
121
122
123
124 if (fn && fn->agg_filter != NULL)
127 "FILTER");
128
129
130
131
132
133
134
137 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
138 errmsg_plural("cannot pass more than %d argument to a function",
139 "cannot pass more than %d arguments to a function",
143
144
145
146
147
148
149
150
151
152
153
154 nargs = 0;
155 foreach(l, fargs)
156 {
159
160 if (argtype == VOIDOID && IsA(arg, Param) &&
161 !is_column && !agg_within_group)
162 {
164 continue;
165 }
166
167 actual_arg_types[nargs++] = argtype;
168 }
169
170
171
172
173
174
175
176
177
178 argnames = NIL;
179 foreach(l, fargs)
180 {
182
184 {
187
188
189 foreach(lc, argnames)
190 {
191 if (strcmp(na->name, (char *) lfirst(lc)) == 0)
193 (errcode(ERRCODE_SYNTAX_ERROR),
194 errmsg("argument name \"%s\" used more than once",
195 na->name),
197 }
198 argnames = lappend(argnames, na->name);
199 }
200 else
201 {
202 if (argnames != NIL)
204 (errcode(ERRCODE_SYNTAX_ERROR),
205 errmsg("positional argument cannot follow named argument"),
207 }
208 }
209
210 if (fargs)
211 {
213 Assert(first_arg != NULL);
214 }
215
216
217
218
219
220
221
222
223 could_be_projection = (nargs == 1 && !proc_call &&
224 agg_order == NIL && agg_filter == NULL &&
225 !agg_star && !agg_distinct && over == NULL &&
226 !func_variadic && argnames == NIL &&
228 (actual_arg_types[0] == RECORDOID ||
229 ISCOMPLEX(actual_arg_types[0])));
230
231
232
233
234 if (could_be_projection && is_column)
235 {
238 first_arg,
239 location);
240 if (retval)
241 return retval;
242
243
244
245
246
247 }
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
265
267 actual_arg_types,
268 !func_variadic, true, proc_call,
269 &funcid, &rettype, &retset,
270 &nvargs, &vatype,
271 &declared_arg_types, &argdefaults);
272
274
275
276
277
278
279
280 if (proc_call &&
286 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
287 errmsg("%s is not a procedure",
289 argnames,
290 actual_arg_types)),
291 errhint("To call a function, use SELECT."),
293
296 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
297 errmsg("%s is a procedure",
299 argnames,
300 actual_arg_types)),
301 errhint("To call a procedure, use CALL."),
303
307 {
308
309
310
311
312 if (agg_star)
314 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
315 errmsg("%s(*) specified, but %s is not an aggregate function",
319 if (agg_distinct)
321 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
322 errmsg("DISTINCT specified, but %s is not an aggregate function",
325 if (agg_within_group)
327 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
328 errmsg("WITHIN GROUP specified, but %s is not an aggregate function",
331 if (agg_order != NIL)
333 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
334 errmsg("ORDER BY specified, but %s is not an aggregate function",
337 if (agg_filter)
339 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
340 errmsg("FILTER specified, but %s is not an aggregate function",
343 if (over)
345 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
346 errmsg("OVER specified, but %s is not a window function nor an aggregate function",
349 }
350
351
352
353
355 {
356
357 }
359 {
360
361
362
365 int catDirectArgs;
366
369 elog(ERROR, "cache lookup failed for aggregate %u", funcid);
371 aggkind = classForm->aggkind;
372 catDirectArgs = classForm->aggnumdirectargs;
374
375
376 if (AGGKIND_IS_ORDERED_SET(aggkind))
377 {
378 int numAggregatedArgs;
379 int numDirectArgs;
380
381 if (!agg_within_group)
383 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
384 errmsg("WITHIN GROUP is required for ordered-set aggregate %s",
387 if (over)
389 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
390 errmsg("OVER is not supported for ordered-set aggregate %s",
393
394 Assert(!agg_distinct);
395
396 Assert(!func_variadic);
397
398
399
400
401
402
403
404
405
406
407 numAggregatedArgs = list_length(agg_order);
408 numDirectArgs = nargs - numAggregatedArgs;
409 Assert(numDirectArgs >= 0);
410
412 {
413
414 if (numDirectArgs != catDirectArgs)
416 (errcode(ERRCODE_UNDEFINED_FUNCTION),
417 errmsg("function %s does not exist",
419 argnames,
420 actual_arg_types)),
421 errhint_plural("There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
422 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
423 catDirectArgs,
425 catDirectArgs, numDirectArgs),
427 }
428 else
429 {
430
431
432
433
434
435
436
438
440 if (nvargs > 1)
442 if (catDirectArgs < pronargs)
443 {
444
445 if (numDirectArgs != catDirectArgs)
447 (errcode(ERRCODE_UNDEFINED_FUNCTION),
448 errmsg("function %s does not exist",
450 argnames,
451 actual_arg_types)),
452 errhint_plural("There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
453 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
454 catDirectArgs,
456 catDirectArgs, numDirectArgs),
458 }
459 else
460 {
461
462
463
464
465
466
467
468
469
470 if (aggkind == AGGKIND_HYPOTHETICAL)
471 {
472 if (nvargs != 2 * numAggregatedArgs)
474 (errcode(ERRCODE_UNDEFINED_FUNCTION),
475 errmsg("function %s does not exist",
477 argnames,
478 actual_arg_types)),
479 errhint("To use the hypothetical-set aggregate %s, the number of hypothetical direct arguments (here %d) must match the number of ordering columns (here %d).",
481 nvargs - numAggregatedArgs, numAggregatedArgs),
483 }
484 else
485 {
486 if (nvargs <= numAggregatedArgs)
488 (errcode(ERRCODE_UNDEFINED_FUNCTION),
489 errmsg("function %s does not exist",
491 argnames,
492 actual_arg_types)),
493 errhint_plural("There is an ordered-set aggregate %s, but it requires at least %d direct argument.",
494 "There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
495 catDirectArgs,
497 catDirectArgs),
499 }
500 }
501 }
502
503
504 if (aggkind == AGGKIND_HYPOTHETICAL)
506 actual_arg_types, declared_arg_types);
507 }
508 else
509 {
510
511 if (agg_within_group)
513 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
514 errmsg("%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
517 }
518 }
520 {
521
522
523
524 if (!over)
526 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
527 errmsg("window function %s requires an OVER clause",
530
531 if (agg_within_group)
533 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
534 errmsg("window function %s cannot have WITHIN GROUP",
537 }
539 {
540
541
542
543
545 actual_arg_types[0], rettype, -1,
547 }
549 {
550
551
552
553
554
555
556
557 if (is_column)
558 return NULL;
559
560 if (proc_call)
562 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
563 errmsg("procedure %s is not unique",
565 actual_arg_types)),
566 errhint("Could not choose a best candidate procedure. "
567 "You might need to add explicit type casts."),
569 else
571 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
572 errmsg("function %s is not unique",
574 actual_arg_types)),
575 errhint("Could not choose a best candidate function. "
576 "You might need to add explicit type casts."),
578 }
579 else
580 {
581
582
583
584
585
586 if (is_column)
587 return NULL;
588
589
590
591
592 if (could_be_projection)
593 {
596 first_arg,
597 location);
598 if (retval)
599 return retval;
600 }
601
602
603
604
605
606 if (list_length(agg_order) > 1 && !agg_within_group)
607 {
608
610 (errcode(ERRCODE_UNDEFINED_FUNCTION),
611 errmsg("function %s does not exist",
613 actual_arg_types)),
614 errhint("No aggregate function matches the given name and argument types. "
615 "Perhaps you misplaced ORDER BY; ORDER BY must appear "
616 "after all regular arguments of the aggregate."),
618 }
619 else if (proc_call)
621 (errcode(ERRCODE_UNDEFINED_FUNCTION),
622 errmsg("procedure %s does not exist",
624 actual_arg_types)),
625 errhint("No procedure matches the given name and argument types. "
626 "You might need to add explicit type casts."),
628 else
630 (errcode(ERRCODE_UNDEFINED_FUNCTION),
631 errmsg("function %s does not exist",
633 actual_arg_types)),
634 errhint("No function matches the given name and argument types. "
635 "You might need to add explicit type casts."),
637 }
638
639
640
641
642
643
644
645
646 nargsplusdefs = nargs;
647 foreach(l, argdefaults)
648 {
650
651
654 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
655 errmsg_plural("cannot pass more than %d argument to a function",
656 "cannot pass more than %d arguments to a function",
660
661 actual_arg_types[nargsplusdefs++] = exprType(expr);
662 }
663
664
665
666
667
668
670 declared_arg_types,
671 nargsplusdefs,
672 rettype,
673 false);
674
675
676 make_fn_arguments(pstate, fargs, actual_arg_types, declared_arg_types);
677
678
679
680
681
682
684 {
686 func_variadic = false;
687 }
688
689
690
691
692
693 if (nvargs > 0 && vatype != ANYOID)
694 {
696 int non_var_args = nargs - nvargs;
698
699 Assert(non_var_args >= 0);
702
703 newa->elements = vargs;
704
706 newa->array_typeid = get_array_type(newa->element_typeid);
709 (errcode(ERRCODE_UNDEFINED_OBJECT),
710 errmsg("could not find array type for data type %s",
713
714 newa->multidims = false;
716
717 fargs = lappend(fargs, newa);
718
719
720 Assert(!func_variadic);
721
722 func_variadic = true;
723 }
724
725
726
727
728
729 if (nargs > 0 && vatype == ANYOID && func_variadic)
730 {
731 Oid va_arr_typid = actual_arg_types[nargs - 1];
732
735 (errcode(ERRCODE_DATATYPE_MISMATCH),
736 errmsg("VARIADIC argument must be an array"),
739 }
740
741
742 if (retset)
744
745
747 {
749
750 funcexpr->funcid = funcid;
751 funcexpr->funcresulttype = rettype;
752 funcexpr->funcretset = retset;
753 funcexpr->funcvariadic = func_variadic;
754 funcexpr->funcformat = funcformat;
755
756 funcexpr->args = fargs;
757 funcexpr->location = location;
758
759 retval = (Node *) funcexpr;
760 }
762 {
763
765
767 aggref->aggtype = rettype;
768
769 aggref->aggtranstype = InvalidOid;
770
771
772
774 aggref->aggstar = agg_star;
775 aggref->aggvariadic = func_variadic;
776 aggref->aggkind = aggkind;
777 aggref->aggpresorted = false;
778
779 aggref->aggsplit = AGGSPLIT_SIMPLE;
780 aggref->aggno = -1;
781 aggref->aggtransno = -1;
783
784
785
786
787
788 if (fargs == NIL && !agg_star && !agg_within_group)
790 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
791 errmsg("%s(*) must be used to call a parameterless aggregate function",
794
795 if (retset)
797 (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
798 errmsg("aggregates cannot return sets"),
800
801
802
803
804
805
806
807
808
809
810 if (argnames != NIL)
812 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
813 errmsg("aggregates cannot use named arguments"),
815
816
818
819 retval = (Node *) aggref;
820 }
821 else
822 {
823
825
826 Assert(over);
827 Assert(!agg_within_group);
828
830 wfunc->wintype = rettype;
831
832 wfunc->args = fargs;
833
834 wfunc->winstar = agg_star;
837 wfunc->runCondition = NIL;
839
840
841
842
843 if (agg_distinct)
845 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
846 errmsg("DISTINCT is not implemented for window functions"),
848
849
850
851
852
853 if (wfunc->winagg && fargs == NIL && !agg_star)
855 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
856 errmsg("%s(*) must be used to call a parameterless aggregate function",
859
860
861
862
863 if (agg_order != NIL)
865 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
866 errmsg("aggregate ORDER BY is not implemented for window functions"),
868
869
870
871
872 if (!wfunc->winagg && agg_filter)
874 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
875 errmsg("FILTER is not implemented for non-aggregate window functions"),
877
878
879
880
883 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
884 errmsg("window function calls cannot contain set-returning function calls"),
885 errhint("You might be able to move the set-returning function into a LATERAL FROM item."),
888
889 if (retset)
891 (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
892 errmsg("window functions cannot return sets"),
894
895
897
898 retval = (Node *) wfunc;
899 }
900
901
902 if (retset)
904
905 return retval;
906}
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922int
924 Oid *input_typeids,
927{
930 int ncandidates = 0;
931
932 *candidates = NULL;
933
934 for (current_candidate = raw_candidates;
935 current_candidate != NULL;
936 current_candidate = next_candidate)
937 {
938 next_candidate = current_candidate->next;
941 {
942 current_candidate->next = *candidates;
943 *candidates = current_candidate;
944 ncandidates++;
945 }
946 }
947
948 return ncandidates;
949}
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1009 Oid *input_typeids,
1011{
1013 first_candidate,
1014 last_candidate;
1015 Oid *current_typeids;
1016 Oid current_type;
1017 int i;
1018 int ncandidates;
1019 int nbestMatch,
1020 nmatch,
1021 nunknowns;
1024 current_category;
1025 bool current_is_preferred;
1027 bool resolved_unknowns;
1028
1029
1032 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1033 errmsg_plural("cannot pass more than %d argument to a function",
1034 "cannot pass more than %d arguments to a function",
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051 nunknowns = 0;
1052 for (i = 0; i < nargs; i++)
1053 {
1054 if (input_typeids[i] != UNKNOWNOID)
1055 input_base_typeids[i] = getBaseType(input_typeids[i]);
1056 else
1057 {
1058
1059 input_base_typeids[i] = UNKNOWNOID;
1060 nunknowns++;
1061 }
1062 }
1063
1064
1065
1066
1067
1068 ncandidates = 0;
1069 nbestMatch = 0;
1070 last_candidate = NULL;
1071 for (current_candidate = candidates;
1072 current_candidate != NULL;
1073 current_candidate = current_candidate->next)
1074 {
1075 current_typeids = current_candidate->args;
1076 nmatch = 0;
1077 for (i = 0; i < nargs; i++)
1078 {
1079 if (input_base_typeids[i] != UNKNOWNOID &&
1080 current_typeids[i] == input_base_typeids[i])
1081 nmatch++;
1082 }
1083
1084
1085 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1086 {
1087 nbestMatch = nmatch;
1088 candidates = current_candidate;
1089 last_candidate = current_candidate;
1090 ncandidates = 1;
1091 }
1092
1093 else if (nmatch == nbestMatch)
1094 {
1095 last_candidate->next = current_candidate;
1096 last_candidate = current_candidate;
1097 ncandidates++;
1098 }
1099
1100 }
1101
1102 if (last_candidate)
1103 last_candidate->next = NULL;
1104
1105 if (ncandidates == 1)
1106 return candidates;
1107
1108
1109
1110
1111
1112
1113
1114
1115 for (i = 0; i < nargs; i++)
1116 slot_category[i] = TypeCategory(input_base_typeids[i]);
1117 ncandidates = 0;
1118 nbestMatch = 0;
1119 last_candidate = NULL;
1120 for (current_candidate = candidates;
1121 current_candidate != NULL;
1122 current_candidate = current_candidate->next)
1123 {
1124 current_typeids = current_candidate->args;
1125 nmatch = 0;
1126 for (i = 0; i < nargs; i++)
1127 {
1128 if (input_base_typeids[i] != UNKNOWNOID)
1129 {
1130 if (current_typeids[i] == input_base_typeids[i] ||
1132 nmatch++;
1133 }
1134 }
1135
1136 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1137 {
1138 nbestMatch = nmatch;
1139 candidates = current_candidate;
1140 last_candidate = current_candidate;
1141 ncandidates = 1;
1142 }
1143 else if (nmatch == nbestMatch)
1144 {
1145 last_candidate->next = current_candidate;
1146 last_candidate = current_candidate;
1147 ncandidates++;
1148 }
1149 }
1150
1151 if (last_candidate)
1152 last_candidate->next = NULL;
1153
1154 if (ncandidates == 1)
1155 return candidates;
1156
1157
1158
1159
1160
1161
1162
1163 if (nunknowns == 0)
1164 return NULL;
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185 resolved_unknowns = false;
1186 for (i = 0; i < nargs; i++)
1187 {
1188 bool have_conflict;
1189
1190 if (input_base_typeids[i] != UNKNOWNOID)
1191 continue;
1192 resolved_unknowns = true;
1193 slot_category[i] = TYPCATEGORY_INVALID;
1194 slot_has_preferred_type[i] = false;
1195 have_conflict = false;
1196 for (current_candidate = candidates;
1197 current_candidate != NULL;
1198 current_candidate = current_candidate->next)
1199 {
1200 current_typeids = current_candidate->args;
1201 current_type = current_typeids[i];
1203 ¤t_category,
1204 ¤t_is_preferred);
1205 if (slot_category[i] == TYPCATEGORY_INVALID)
1206 {
1207
1208 slot_category[i] = current_category;
1209 slot_has_preferred_type[i] = current_is_preferred;
1210 }
1211 else if (current_category == slot_category[i])
1212 {
1213
1214 slot_has_preferred_type[i] |= current_is_preferred;
1215 }
1216 else
1217 {
1218
1219 if (current_category == TYPCATEGORY_STRING)
1220 {
1221
1222 slot_category[i] = current_category;
1223 slot_has_preferred_type[i] = current_is_preferred;
1224 }
1225 else
1226 {
1227
1228
1229
1230 have_conflict = true;
1231 }
1232 }
1233 }
1234 if (have_conflict && slot_category[i] != TYPCATEGORY_STRING)
1235 {
1236
1237 resolved_unknowns = false;
1238 break;
1239 }
1240 }
1241
1242 if (resolved_unknowns)
1243 {
1244
1245 ncandidates = 0;
1246 first_candidate = candidates;
1247 last_candidate = NULL;
1248 for (current_candidate = candidates;
1249 current_candidate != NULL;
1250 current_candidate = current_candidate->next)
1251 {
1252 bool keepit = true;
1253
1254 current_typeids = current_candidate->args;
1255 for (i = 0; i < nargs; i++)
1256 {
1257 if (input_base_typeids[i] != UNKNOWNOID)
1258 continue;
1259 current_type = current_typeids[i];
1261 ¤t_category,
1262 ¤t_is_preferred);
1263 if (current_category != slot_category[i])
1264 {
1265 keepit = false;
1266 break;
1267 }
1268 if (slot_has_preferred_type[i] && !current_is_preferred)
1269 {
1270 keepit = false;
1271 break;
1272 }
1273 }
1274 if (keepit)
1275 {
1276
1277 last_candidate = current_candidate;
1278 ncandidates++;
1279 }
1280 else
1281 {
1282
1283 if (last_candidate)
1284 last_candidate->next = current_candidate->next;
1285 else
1286 first_candidate = current_candidate->next;
1287 }
1288 }
1289
1290
1291 if (last_candidate)
1292 {
1293 candidates = first_candidate;
1294
1295 last_candidate->next = NULL;
1296 }
1297
1298 if (ncandidates == 1)
1299 return candidates;
1300 }
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312 if (nunknowns < nargs)
1313 {
1314 Oid known_type = UNKNOWNOID;
1315
1316 for (i = 0; i < nargs; i++)
1317 {
1318 if (input_base_typeids[i] == UNKNOWNOID)
1319 continue;
1320 if (known_type == UNKNOWNOID)
1321 known_type = input_base_typeids[i];
1322 else if (known_type != input_base_typeids[i])
1323 {
1324
1325 known_type = UNKNOWNOID;
1326 break;
1327 }
1328 }
1329
1330 if (known_type != UNKNOWNOID)
1331 {
1332
1333 for (i = 0; i < nargs; i++)
1334 input_base_typeids[i] = known_type;
1335 ncandidates = 0;
1336 last_candidate = NULL;
1337 for (current_candidate = candidates;
1338 current_candidate != NULL;
1339 current_candidate = current_candidate->next)
1340 {
1341 current_typeids = current_candidate->args;
1342 if (can_coerce_type(nargs, input_base_typeids, current_typeids,
1344 {
1345 if (++ncandidates > 1)
1346 break;
1347 last_candidate = current_candidate;
1348 }
1349 }
1350 if (ncandidates == 1)
1351 {
1352
1353 last_candidate->next = NULL;
1354 return last_candidate;
1355 }
1356 }
1357 }
1358
1359 return NULL;
1360}
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1396 List *fargs,
1397 List *fargnames,
1398 int nargs,
1399 Oid *argtypes,
1400 bool expand_variadic,
1401 bool expand_defaults,
1402 bool include_out_arguments,
1403 Oid *funcid,
1404 Oid *rettype,
1405 bool *retset,
1406 int *nvargs,
1407 Oid *vatype,
1408 Oid **true_typeids,
1409 List **argdefaults)
1410{
1413
1414
1417 *retset = false;
1418 *nvargs = 0;
1420 *true_typeids = NULL;
1421 if (argdefaults)
1422 *argdefaults = NIL;
1423
1424
1426 expand_variadic, expand_defaults,
1427 include_out_arguments, false);
1428
1429
1430
1431
1432
1433 for (best_candidate = raw_candidates;
1434 best_candidate != NULL;
1435 best_candidate = best_candidate->next)
1436 {
1437
1438 if (nargs == 0 ||
1439 memcmp(argtypes, best_candidate->args, nargs * sizeof(Oid)) == 0)
1440 break;
1441 }
1442
1443 if (best_candidate == NULL)
1444 {
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484 if (nargs == 1 && fargs != NIL && fargnames == NIL)
1485 {
1487
1489 {
1490 Oid sourceType = argtypes[0];
1492 bool iscoercion;
1493
1494 if (sourceType == UNKNOWNOID && IsA(arg1, Const))
1495 {
1496
1497 iscoercion = true;
1498 }
1499 else
1500 {
1502 Oid cfuncid;
1503
1506 &cfuncid);
1507 switch (cpathtype)
1508 {
1510 iscoercion = true;
1511 break;
1513 if ((sourceType == RECORDOID ||
1515 TypeCategory(targetType) == TYPCATEGORY_STRING)
1516 iscoercion = false;
1517 else
1518 iscoercion = true;
1519 break;
1520 default:
1521 iscoercion = false;
1522 break;
1523 }
1524 }
1525
1526 if (iscoercion)
1527 {
1528
1530 *rettype = targetType;
1531 *retset = false;
1532 *nvargs = 0;
1534 *true_typeids = argtypes;
1536 }
1537 }
1538 }
1539
1540
1541
1542
1543 if (raw_candidates != NULL)
1544 {
1546 int ncandidates;
1547
1549 argtypes,
1550 raw_candidates,
1551 ¤t_candidates);
1552
1553
1554 if (ncandidates == 1)
1555 best_candidate = current_candidates;
1556
1557
1558
1559
1560 else if (ncandidates > 1)
1561 {
1563 argtypes,
1564 current_candidates);
1565
1566
1567
1568
1569
1570 if (!best_candidate)
1572 }
1573 }
1574 }
1575
1576 if (best_candidate)
1577 {
1581
1582
1583
1584
1585
1586
1589
1590
1591
1592
1593
1594
1595 if (fargnames != NIL && !expand_variadic && nargs > 0 &&
1596 best_candidate->argnumbers[nargs - 1] != nargs - 1)
1598
1599 *funcid = best_candidate->oid;
1600 *nvargs = best_candidate->nvargs;
1601 *true_typeids = best_candidate->args;
1602
1603
1604
1605
1606
1607
1608 if (best_candidate->argnumbers != NULL)
1609 {
1610 int i = 0;
1612
1613 foreach(lc, fargs)
1614 {
1616
1619 i++;
1620 }
1621 }
1622
1626 elog(ERROR, "cache lookup failed for function %u",
1627 best_candidate->oid);
1629 *rettype = pform->prorettype;
1630 *retset = pform->proretset;
1631 *vatype = pform->provariadic;
1632
1633 if (argdefaults && best_candidate->ndargs > 0)
1634 {
1635 Datum proargdefaults;
1636 char *str;
1637 List *defaults;
1638
1639
1640 if (best_candidate->ndargs > pform->pronargdefaults)
1641 elog(ERROR, "not enough default arguments");
1642
1644 Anum_pg_proc_proargdefaults);
1648
1649
1650 if (best_candidate->argnumbers != NULL)
1651 {
1652
1653
1654
1655
1656
1657
1658
1659
1661 int *firstdefarg;
1662 List *newdefaults;
1664 int i;
1665
1666 defargnumbers = NULL;
1667 firstdefarg = &best_candidate->argnumbers[best_candidate->nargs - best_candidate->ndargs];
1668 for (i = 0; i < best_candidate->ndargs; i++)
1670 firstdefarg[i]);
1671 newdefaults = NIL;
1672 i = best_candidate->nominalnargs - pform->pronargdefaults;
1673 foreach(lc, defaults)
1674 {
1677 i++;
1678 }
1681 *argdefaults = newdefaults;
1682 }
1683 else
1684 {
1685
1686
1687
1688
1689 int ndelete;
1690
1692 if (ndelete > 0)
1694 *argdefaults = defaults;
1695 }
1696 }
1697
1698 switch (pform->prokind)
1699 {
1700 case PROKIND_AGGREGATE:
1702 break;
1703 case PROKIND_FUNCTION:
1705 break;
1706 case PROKIND_PROCEDURE:
1708 break;
1709 case PROKIND_WINDOW:
1711 break;
1712 default:
1713 elog(ERROR, "unrecognized prokind: %c", pform->prokind);
1715 break;
1716 }
1717
1719 return result;
1720 }
1721
1723}
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740static void
1742 List *fargs,
1743 int numAggregatedArgs,
1744 Oid *actual_arg_types,
1745 Oid *declared_arg_types)
1746{
1747 int numDirectArgs,
1748 numNonHypotheticalArgs;
1749 int hargpos;
1750
1751 numDirectArgs = list_length(fargs) - numAggregatedArgs;
1752 numNonHypotheticalArgs = numDirectArgs - numAggregatedArgs;
1753
1754 if (numNonHypotheticalArgs < 0)
1755 elog(ERROR, "incorrect number of arguments to hypothetical-set aggregate");
1756
1757
1758 for (hargpos = numNonHypotheticalArgs; hargpos < numDirectArgs; hargpos++)
1759 {
1760 int aargpos = numDirectArgs + (hargpos - numNonHypotheticalArgs);
1763 Oid commontype;
1764 int32 commontypmod;
1765
1766
1767 if (declared_arg_types[hargpos] != declared_arg_types[aargpos])
1768 elog(ERROR, "hypothetical-set aggregate has inconsistent declared argument types");
1769
1770
1771 if (declared_arg_types[hargpos] != ANYOID)
1772 continue;
1773
1774
1775
1776
1777
1778
1781 "WITHIN GROUP",
1782 NULL);
1785 commontype);
1786
1787
1788
1789
1790
1793 actual_arg_types[hargpos],
1794 commontype, commontypmod,
1797 -1);
1798 actual_arg_types[hargpos] = commontype;
1801 actual_arg_types[aargpos],
1802 commontype, commontypmod,
1805 -1);
1806 actual_arg_types[aargpos] = commontype;
1807 }
1808}
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824void
1826 List *fargs,
1827 Oid *actual_arg_types,
1828 Oid *declared_arg_types)
1829{
1831 int i = 0;
1832
1833 foreach(current_fargs, fargs)
1834 {
1835
1836 if (actual_arg_types[i] != declared_arg_types[i])
1837 {
1839
1840
1841
1842
1843
1845 {
1847
1850 actual_arg_types[i],
1851 declared_arg_types[i], -1,
1854 -1);
1856 }
1857 else
1858 {
1860 node,
1861 actual_arg_types[i],
1862 declared_arg_types[i], -1,
1865 -1);
1866 lfirst(current_fargs) = node;
1867 }
1868 }
1869 i++;
1870 }
1871}
1872
1873
1874
1875
1876
1877
1878
1879
1880static Oid
1882{
1883 Oid result;
1884 Type typtup;
1885
1886
1887
1888
1889
1891 NULL, false, false);
1892 if (typtup == NULL)
1894
1898 else
1900
1902 return result;
1903}
1904
1905
1906
1907
1908
1909
1910
1911static Node *
1913 int location)
1914{
1916 int i;
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928 if (IsA(first_arg, Var) &&
1930 {
1932
1934 ((Var *) first_arg)->varno,
1935 ((Var *) first_arg)->varlevelsup);
1936
1938 ((Var *) first_arg)->varlevelsup,
1940 }
1941
1942
1943
1944
1945
1946
1947
1948
1949 if (IsA(first_arg, Var) &&
1950 ((Var *) first_arg)->vartype == RECORDOID)
1952 else
1954 if (!tupdesc)
1955 return NULL;
1956
1957 for (i = 0; i < tupdesc->natts; i++)
1958 {
1960
1962 !att->attisdropped)
1963 {
1964
1966
1967 fselect->arg = (Expr *) first_arg;
1969 fselect->resulttype = att->atttypid;
1970 fselect->resulttypmod = att->atttypmod;
1971
1972 fselect->resultcollid = att->attcollation;
1973 return (Node *) fselect;
1974 }
1975 }
1976
1977 return NULL;
1978}
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992const char *
1994 List *argnames, const Oid *argtypes)
1995{
1997 int numposargs;
1999 int i;
2000
2002
2004
2005 numposargs = nargs - list_length(argnames);
2007
2008 for (i = 0; i < nargs; i++)
2009 {
2010 if (i)
2012 if (i >= numposargs)
2013 {
2015 lc = lnext(argnames, lc);
2016 }
2018 }
2019
2021
2022 return argbuf.data;
2023}
2024
2025
2026
2027
2028
2029const char *
2031 List *argnames, const Oid *argtypes)
2032{
2034 nargs, argnames, argtypes);
2035}
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048static Oid
2050 int nargs, const Oid *argtypes,
2051 bool include_out_arguments, bool missing_ok,
2053{
2056
2057
2058 Assert(argtypes != NULL || nargs == 0);
2059
2060
2062
2063
2065 include_out_arguments, missing_ok);
2066
2067
2068 for (; clist != NULL; clist = clist->next)
2069 {
2070
2071 if (nargs >= 0)
2072 {
2073
2074 if (nargs > 0 &&
2075 memcmp(argtypes, clist->args, nargs * sizeof(Oid)) != 0)
2076 continue;
2077 }
2078
2079
2081 {
2084 }
2085
2086
2087 switch (objtype)
2088 {
2091
2093 continue;
2094 break;
2096
2098 continue;
2099 break;
2101
2102 break;
2103 default:
2105 }
2106
2107
2109 {
2112 }
2113
2114
2115 result = clist->oid;
2116 }
2117
2118 return result;
2119}
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2145{
2146 Oid funcoid;
2148
2151 false, missing_ok,
2152 &lookupError);
2153
2155 return funcoid;
2156
2157 switch (lookupError)
2158 {
2160
2161 if (missing_ok)
2163
2164 if (nargs < 0)
2166 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2167 errmsg("could not find a function named \"%s\"",
2169 else
2171 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2172 errmsg("function %s does not exist",
2174 NIL, argtypes))));
2175 break;
2176
2178
2180 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2181 errmsg("function name \"%s\" is not unique",
2183 errhint("Specify the argument list to select the function unambiguously.")));
2184 break;
2185 }
2186
2187 return InvalidOid;
2188}
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2207{
2209 int argcount;
2210 int nargs;
2211 int i;
2213 Oid oid;
2215
2220
2223 {
2226 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2227 errmsg_plural("procedures cannot have more than %d argument",
2228 "procedures cannot have more than %d arguments",
2231 else
2233 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2234 errmsg_plural("functions cannot have more than %d argument",
2235 "functions cannot have more than %d arguments",
2238 }
2239
2240
2241
2242
2243
2244 i = 0;
2245 foreach(args_item, func->objargs)
2246 {
2248
2251 return InvalidOid;
2252 i++;
2253 }
2254
2255
2256
2257
2258
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2271 func->objname, nargs, argoids,
2272 false, missing_ok,
2273 &lookupError);
2274
2275
2276
2277
2278
2279
2280
2281
2282
2286 {
2287 bool have_param_mode = false;
2288
2289
2290
2291
2292
2293
2294
2295
2296
2298 {
2300
2302 {
2303 have_param_mode = true;
2304 break;
2305 }
2306 }
2307
2308 if (!have_param_mode)
2309 {
2310 Oid poid;
2311
2312
2314
2315
2317 argcount, argoids,
2318 true, missing_ok,
2319 &lookupError);
2320
2321
2323 {
2325 {
2326
2329 }
2330 else
2331 oid = poid;
2332 }
2335 }
2336 }
2337
2339 {
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351 switch (objtype)
2352 {
2354
2357 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
2358 errmsg("%s is not a function",
2360 NIL, argoids))));
2361 break;
2362
2364
2367 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
2368 errmsg("%s is not a procedure",
2370 NIL, argoids))));
2371 break;
2372
2374
2377 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
2378 errmsg("function %s is not an aggregate",
2380 NIL, argoids))));
2381 break;
2382
2383 default:
2384
2385 break;
2386 }
2387
2388 return oid;
2389 }
2390 else
2391 {
2392
2393 switch (lookupError)
2394 {
2396
2397 if (missing_ok)
2398 break;
2399
2400 switch (objtype)
2401 {
2405 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2406 errmsg("could not find a procedure named \"%s\"",
2408 else
2410 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2411 errmsg("procedure %s does not exist",
2413 NIL, argoids))));
2414 break;
2415
2419 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2420 errmsg("could not find an aggregate named \"%s\"",
2422 else if (argcount == 0)
2424 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2425 errmsg("aggregate %s(*) does not exist",
2427 else
2429 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2430 errmsg("aggregate %s does not exist",
2432 NIL, argoids))));
2433 break;
2434
2435 default:
2436
2439 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2440 errmsg("could not find a function named \"%s\"",
2442 else
2444 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2445 errmsg("function %s does not exist",
2447 NIL, argoids))));
2448 break;
2449 }
2450 break;
2451
2453 switch (objtype)
2454 {
2457 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2458 errmsg("function name \"%s\" is not unique",
2461 errhint("Specify the argument list to select the function unambiguously.") : 0));
2462 break;
2465 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2466 errmsg("procedure name \"%s\" is not unique",
2469 errhint("Specify the argument list to select the procedure unambiguously.") : 0));
2470 break;
2473 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2474 errmsg("aggregate name \"%s\" is not unique",
2477 errhint("Specify the argument list to select the aggregate unambiguously.") : 0));
2478 break;
2481 (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2482 errmsg("routine name \"%s\" is not unique",
2485 errhint("Specify the argument list to select the routine unambiguously.") : 0));
2486 break;
2487
2488 default:
2489 Assert(false);
2490 break;
2491 }
2492 break;
2493 }
2494
2496 }
2497}
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510void
2512{
2513 const char *err;
2514 bool errkind;
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528 err = NULL;
2529 errkind = false;
2531 {
2533 Assert(false);
2534 break;
2536
2537 break;
2540 err = _("set-returning functions are not allowed in JOIN conditions");
2541 break;
2543
2544 errkind = true;
2545 break;
2547
2548
2549
2552 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2553 errmsg("set-returning functions must appear at top level of FROM"),
2556 break;
2558 errkind = true;
2559 break;
2561 err = _("set-returning functions are not allowed in policy expressions");
2562 break;
2564 errkind = true;
2565 break;
2567 errkind = true;
2568 break;
2571
2573 break;
2577 err = _("set-returning functions are not allowed in window definitions");
2578 break;
2581
2583 break;
2586
2587 errkind = true;
2588 break;
2591
2593 break;
2595
2597 break;
2600 errkind = true;
2601 break;
2604 errkind = true;
2605 break;
2607
2608 errkind = true;
2609 break;
2611
2613 break;
2615 err = _("set-returning functions are not allowed in MERGE WHEN conditions");
2616 break;
2619 err = _("set-returning functions are not allowed in check constraints");
2620 break;
2623 err = _("set-returning functions are not allowed in DEFAULT expressions");
2624 break;
2626 err = _("set-returning functions are not allowed in index expressions");
2627 break;
2629 err = _("set-returning functions are not allowed in index predicates");
2630 break;
2632 err = _("set-returning functions are not allowed in statistics expressions");
2633 break;
2635 err = _("set-returning functions are not allowed in transform expressions");
2636 break;
2638 err = _("set-returning functions are not allowed in EXECUTE parameters");
2639 break;
2641 err = _("set-returning functions are not allowed in trigger WHEN conditions");
2642 break;
2644 err = _("set-returning functions are not allowed in partition bound");
2645 break;
2647 err = _("set-returning functions are not allowed in partition key expressions");
2648 break;
2650 err = _("set-returning functions are not allowed in CALL arguments");
2651 break;
2653 err = _("set-returning functions are not allowed in COPY FROM WHERE conditions");
2654 break;
2656 err = _("set-returning functions are not allowed in column generation expressions");
2657 break;
2659 errkind = true;
2660 break;
2661
2662
2663
2664
2665
2666
2667
2668
2669 }
2670 if (err)
2672 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2675 if (errkind)
2677 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2678
2679 errmsg("set-returning functions are not allowed in %s",
2682}
#define InvalidAttrNumber
void bms_free(Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define TextDatumGetCString(d)
#define OidIsValid(objectId)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errmsg_internal(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errhint_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
char * format_type_be(Oid type_oid)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
Assert(PointerIsAligned(start, uint64))
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_delete_first_n(List *list, int n)
List * list_truncate(List *list, int new_size)
char get_func_prokind(Oid funcid)
Oid get_base_element_type(Oid typid)
Oid getBaseType(Oid typid)
Oid get_array_type(Oid typid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
TypeName * makeTypeNameFromNameList(List *names)
void pfree(void *pointer)
char * NameListToString(const List *names)
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Oid exprType(const Node *expr)
int exprLocation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
void transformWindowFuncCall(ParseState *pstate, WindowFunc *wfunc, WindowDef *windef)
void transformAggregateCall(ParseState *pstate, Aggref *agg, List *args, List *aggorder, bool agg_distinct)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
TYPCATEGORY TypeCategory(Oid type)
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
bool IsPreferredType(TYPCATEGORY category, Oid type)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
@ COERCION_PATH_COERCEVIAIO
@ COERCION_PATH_RELABELTYPE
const char * ParseExprKindName(ParseExprKind exprKind)
const char * funcname_signature_string(const char *funcname, int nargs, List *argnames, const Oid *argtypes)
static Node * ParseComplexProjection(ParseState *pstate, const char *funcname, Node *first_arg, int location)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
static Oid LookupFuncNameInternal(ObjectType objtype, List *funcname, int nargs, const Oid *argtypes, bool include_out_arguments, bool missing_ok, FuncLookupError *lookupError)
FuncCandidateList func_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates)
static void unify_hypothetical_args(ParseState *pstate, List *fargs, int numAggregatedArgs, Oid *actual_arg_types, Oid *declared_arg_types)
Node * ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, Node *last_srf, FuncCall *fn, bool proc_call, int location)
const char * func_signature_string(List *funcname, int nargs, List *argnames, const Oid *argtypes)
FuncDetailCode func_get_detail(List *funcname, List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, bool include_out_arguments, Oid *funcid, Oid *rettype, bool *retset, int *nvargs, Oid *vatype, Oid **true_typeids, List **argdefaults)
void check_srf_call_placement(ParseState *pstate, Node *last_srf, int location)
static Oid FuncNameAsType(List *funcname)
Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
int func_match_argtypes(int nargs, Oid *input_typeids, FuncCandidateList raw_candidates, FuncCandidateList *candidates)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
@ EXPR_KIND_EXECUTE_PARAMETER
@ EXPR_KIND_COLUMN_DEFAULT
@ EXPR_KIND_STATS_EXPRESSION
@ EXPR_KIND_INDEX_EXPRESSION
@ EXPR_KIND_MERGE_RETURNING
@ EXPR_KIND_PARTITION_BOUND
@ EXPR_KIND_FUNCTION_DEFAULT
@ EXPR_KIND_WINDOW_FRAME_RANGE
@ EXPR_KIND_FROM_SUBSELECT
@ EXPR_KIND_WINDOW_FRAME_GROUPS
@ EXPR_KIND_PARTITION_EXPRESSION
@ EXPR_KIND_INDEX_PREDICATE
@ EXPR_KIND_INSERT_TARGET
@ EXPR_KIND_ALTER_COL_TRANSFORM
@ EXPR_KIND_UPDATE_TARGET
@ EXPR_KIND_SELECT_TARGET
@ EXPR_KIND_GENERATED_COLUMN
@ EXPR_KIND_CALL_ARGUMENT
@ EXPR_KIND_FROM_FUNCTION
@ EXPR_KIND_UPDATE_SOURCE
@ EXPR_KIND_CHECK_CONSTRAINT
@ EXPR_KIND_WINDOW_PARTITION
@ EXPR_KIND_WINDOW_FRAME_ROWS
@ EXPR_KIND_VALUES_SINGLE
ParseNamespaceItem * GetNSItemByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
Node * scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, const char *colname, int location)
TupleDesc expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
Oid typeTypeRelid(Type typ)
Type LookupTypeNameExtended(ParseState *pstate, const TypeName *typeName, int32 *typmod_p, bool temp_ok, bool missing_ok)
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
#define ISCOMPLEX(typeid)
FormData_pg_aggregate * Form_pg_aggregate
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define foreach_delete_current(lst, var_or_cell)
static ListCell * list_nth_cell(const List *list, int n)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
FormData_pg_proc * Form_pg_proc
FormData_pg_type * Form_pg_type
static Datum ObjectIdGetDatum(Oid X)
void * stringToNode(const char *str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
FunctionParameterMode mode
ParseExprKind p_expr_kind
struct _FuncCandidateList * next
Oid args[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
static void * fn(void *arg)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)