88 #ifdef HAVE_COMPUTED_GOTO
89 #define EEO_USE_COMPUTED_GOTO
102 #if defined(EEO_USE_COMPUTED_GOTO)
105 typedef struct ExprEvalOpLookup
112 static const void **dispatch_table = NULL;
115 static ExprEvalOpLookup reverse_dispatch_table[
EEOP_LAST];
118 #define EEO_CASE(name) CASE_##name:
119 #define EEO_DISPATCH() goto *((void *) op->opcode)
120 #define EEO_OPCODE(opcode) ((intptr_t) dispatch_table[opcode])
124 #define EEO_SWITCH() starteval: switch ((ExprEvalOp) op->opcode)
125 #define EEO_CASE(name) case name:
126 #define EEO_DISPATCH() goto starteval
127 #define EEO_OPCODE(opcode) (opcode)
137 #define EEO_JUMP(stepno) \
139 op = &state->steps[stepno]; \
195 #define SH_PREFIX saophash
196 #define SH_ELEMENT_TYPE ScalarArrayOpExprHashEntry
197 #define SH_KEY_TYPE Datum
198 #define SH_SCOPE static inline
219 #define SH_PREFIX saophash
220 #define SH_ELEMENT_TYPE ScalarArrayOpExprHashEntry
221 #define SH_KEY_TYPE Datum
223 #define SH_HASH_KEY(tb, key) saop_element_hash(tb, key)
224 #define SH_EQUAL(tb, a, b) saop_hash_element_match(tb, a, b)
225 #define SH_SCOPE static inline
226 #define SH_STORE_HASH
227 #define SH_GET_HASH(tb, a) a->hash
275 if (
state->steps_len == 3)
318 state->steps[0].d.casetest.value)
324 else if (
state->steps_len == 2)
365 #if defined(EEO_USE_COMPUTED_GOTO)
371 for (
int off = 0; off <
state->steps_len; off++)
406 #if defined(EEO_USE_COMPUTED_GOTO)
407 static const void *
const dispatch_table[] = {
409 &&CASE_EEOP_INNER_FETCHSOME,
410 &&CASE_EEOP_OUTER_FETCHSOME,
411 &&CASE_EEOP_SCAN_FETCHSOME,
412 &&CASE_EEOP_INNER_VAR,
413 &&CASE_EEOP_OUTER_VAR,
414 &&CASE_EEOP_SCAN_VAR,
415 &&CASE_EEOP_INNER_SYSVAR,
416 &&CASE_EEOP_OUTER_SYSVAR,
417 &&CASE_EEOP_SCAN_SYSVAR,
418 &&CASE_EEOP_WHOLEROW,
419 &&CASE_EEOP_ASSIGN_INNER_VAR,
420 &&CASE_EEOP_ASSIGN_OUTER_VAR,
421 &&CASE_EEOP_ASSIGN_SCAN_VAR,
422 &&CASE_EEOP_ASSIGN_TMP,
423 &&CASE_EEOP_ASSIGN_TMP_MAKE_RO,
425 &&CASE_EEOP_FUNCEXPR,
426 &&CASE_EEOP_FUNCEXPR_STRICT,
427 &&CASE_EEOP_FUNCEXPR_FUSAGE,
428 &&CASE_EEOP_FUNCEXPR_STRICT_FUSAGE,
429 &&CASE_EEOP_BOOL_AND_STEP_FIRST,
430 &&CASE_EEOP_BOOL_AND_STEP,
431 &&CASE_EEOP_BOOL_AND_STEP_LAST,
432 &&CASE_EEOP_BOOL_OR_STEP_FIRST,
433 &&CASE_EEOP_BOOL_OR_STEP,
434 &&CASE_EEOP_BOOL_OR_STEP_LAST,
435 &&CASE_EEOP_BOOL_NOT_STEP,
438 &&CASE_EEOP_JUMP_IF_NULL,
439 &&CASE_EEOP_JUMP_IF_NOT_NULL,
440 &&CASE_EEOP_JUMP_IF_NOT_TRUE,
441 &&CASE_EEOP_NULLTEST_ISNULL,
442 &&CASE_EEOP_NULLTEST_ISNOTNULL,
443 &&CASE_EEOP_NULLTEST_ROWISNULL,
444 &&CASE_EEOP_NULLTEST_ROWISNOTNULL,
445 &&CASE_EEOP_BOOLTEST_IS_TRUE,
446 &&CASE_EEOP_BOOLTEST_IS_NOT_TRUE,
447 &&CASE_EEOP_BOOLTEST_IS_FALSE,
448 &&CASE_EEOP_BOOLTEST_IS_NOT_FALSE,
449 &&CASE_EEOP_PARAM_EXEC,
450 &&CASE_EEOP_PARAM_EXTERN,
451 &&CASE_EEOP_PARAM_CALLBACK,
452 &&CASE_EEOP_CASE_TESTVAL,
453 &&CASE_EEOP_MAKE_READONLY,
454 &&CASE_EEOP_IOCOERCE,
455 &&CASE_EEOP_DISTINCT,
456 &&CASE_EEOP_NOT_DISTINCT,
458 &&CASE_EEOP_SQLVALUEFUNCTION,
459 &&CASE_EEOP_CURRENTOFEXPR,
460 &&CASE_EEOP_NEXTVALUEEXPR,
461 &&CASE_EEOP_ARRAYEXPR,
462 &&CASE_EEOP_ARRAYCOERCE,
464 &&CASE_EEOP_ROWCOMPARE_STEP,
465 &&CASE_EEOP_ROWCOMPARE_FINAL,
467 &&CASE_EEOP_FIELDSELECT,
468 &&CASE_EEOP_FIELDSTORE_DEFORM,
469 &&CASE_EEOP_FIELDSTORE_FORM,
470 &&CASE_EEOP_SBSREF_SUBSCRIPTS,
471 &&CASE_EEOP_SBSREF_OLD,
472 &&CASE_EEOP_SBSREF_ASSIGN,
473 &&CASE_EEOP_SBSREF_FETCH,
474 &&CASE_EEOP_DOMAIN_TESTVAL,
475 &&CASE_EEOP_DOMAIN_NOTNULL,
476 &&CASE_EEOP_DOMAIN_CHECK,
477 &&CASE_EEOP_CONVERT_ROWTYPE,
478 &&CASE_EEOP_SCALARARRAYOP,
479 &&CASE_EEOP_HASHED_SCALARARRAYOP,
481 &&CASE_EEOP_JSON_CONSTRUCTOR,
484 &&CASE_EEOP_GROUPING_FUNC,
485 &&CASE_EEOP_WINDOW_FUNC,
487 &&CASE_EEOP_AGG_STRICT_DESERIALIZE,
488 &&CASE_EEOP_AGG_DESERIALIZE,
489 &&CASE_EEOP_AGG_STRICT_INPUT_CHECK_ARGS,
490 &&CASE_EEOP_AGG_STRICT_INPUT_CHECK_NULLS,
491 &&CASE_EEOP_AGG_PLAIN_PERGROUP_NULLCHECK,
492 &&CASE_EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYVAL,
493 &&CASE_EEOP_AGG_PLAIN_TRANS_STRICT_BYVAL,
494 &&CASE_EEOP_AGG_PLAIN_TRANS_BYVAL,
495 &&CASE_EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYREF,
496 &&CASE_EEOP_AGG_PLAIN_TRANS_STRICT_BYREF,
497 &&CASE_EEOP_AGG_PLAIN_TRANS_BYREF,
498 &&CASE_EEOP_AGG_PRESORTED_DISTINCT_SINGLE,
499 &&CASE_EEOP_AGG_PRESORTED_DISTINCT_MULTI,
500 &&CASE_EEOP_AGG_ORDERED_TRANS_DATUM,
501 &&CASE_EEOP_AGG_ORDERED_TRANS_TUPLE,
506 "dispatch_table out of whack with ExprEvalOp");
516 resultslot =
state->resultslot;
521 #if defined(EEO_USE_COMPUTED_GOTO)
631 int attnum =
op->d.assign_var.attnum;
638 Assert(
resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
648 int attnum =
op->d.assign_var.attnum;
655 Assert(
resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
665 int attnum =
op->d.assign_var.attnum;
672 Assert(
resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
683 Assert(
resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
694 Assert(
resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts);
707 *
op->resnull =
op->d.constval.isnull;
708 *
op->resvalue =
op->d.constval.value;
734 d =
op->d.func.fn_addr(fcinfo);
749 for (
int argno = 0; argno <
nargs; argno++)
758 d =
op->d.func.fn_addr(fcinfo);
794 *
op->d.boolexpr.anynull =
false;
808 *
op->d.boolexpr.anynull =
true;
836 else if (*
op->d.boolexpr.anynull)
861 *
op->d.boolexpr.anynull =
false;
875 *
op->d.boolexpr.anynull =
true;
903 else if (*
op->d.boolexpr.anynull)
938 *
op->resnull =
false;
987 *
op->resnull =
false;
995 *
op->resnull =
false;
1023 *
op->resnull =
false;
1035 *
op->resnull =
false;
1048 *
op->resnull =
false;
1061 *
op->resnull =
false;
1086 op->d.cparam.paramfunc(
state,
op, econtext);
1101 if (
op->d.casetest.value)
1103 *
op->resvalue = *
op->d.casetest.value;
1104 *
op->resnull = *
op->d.casetest.isnull;
1120 if (
op->d.casetest.value)
1122 *
op->resvalue = *
op->d.casetest.value;
1123 *
op->resnull = *
op->d.casetest.isnull;
1139 if (!*
op->d.make_readonly.isnull)
1142 *
op->resnull = *
op->d.make_readonly.isnull;
1166 fcinfo_out =
op->d.iocoerce.fcinfo_data_out;
1170 fcinfo_out->
isnull =
false;
1178 if (!
op->d.iocoerce.finfo_in->fn_strict ||
str != NULL)
1183 fcinfo_in =
op->d.iocoerce.fcinfo_data_in;
1188 fcinfo_in->
isnull =
false;
1226 *
op->resnull =
false;
1232 *
op->resnull =
false;
1240 eqresult =
op->d.func.fn_addr(fcinfo);
1257 *
op->resnull =
false;
1262 *
op->resnull =
false;
1269 eqresult =
op->d.func.fn_addr(fcinfo);
1270 *
op->resvalue = eqresult;
1290 result =
op->d.func.fn_addr(fcinfo);
1296 *
op->resnull =
true;
1369 if (
op->d.rowcompare_step.finfo->fn_strict &&
1372 *
op->resnull =
true;
1378 d =
op->d.rowcompare_step.fn_addr(fcinfo);
1384 *
op->resnull =
true;
1387 *
op->resnull =
false;
1403 *
op->resnull =
false;
1462 if (
op->d.sbsref_subscript.subscriptfunc(
state,
op, econtext))
1478 op->d.sbsref.subscriptfunc(
state,
op, econtext);
1552 int aggno =
op->d.aggref.aggno;
1597 if (
op->d.agg_deserialize.fcinfo_data->args[0].isnull)
1631 int nargs =
op->d.agg_strict_input_check.nargs;
1633 for (
int argno = 0; argno <
nargs; argno++)
1636 EEO_JUMP(
op->d.agg_strict_input_check.jumpnull);
1643 bool *
nulls =
op->d.agg_strict_input_check.nulls;
1644 int nargs =
op->d.agg_strict_input_check.nargs;
1646 for (
int argno = 0; argno <
nargs; argno++)
1649 EEO_JUMP(
op->d.agg_strict_input_check.jumpnull);
1664 if (pergroup_allaggs == NULL)
1665 EEO_JUMP(
op->d.agg_plain_pergroup_nullcheck.jumpnull);
1695 op->d.agg_trans.aggcontext);
1702 op->d.agg_trans.aggcontext,
1703 op->d.agg_trans.setno);
1721 op->d.agg_trans.aggcontext,
1722 op->d.agg_trans.setno);
1738 op->d.agg_trans.aggcontext,
1739 op->d.agg_trans.setno);
1756 op->d.agg_trans.aggcontext);
1759 op->d.agg_trans.aggcontext,
1760 op->d.agg_trans.setno);
1777 op->d.agg_trans.aggcontext,
1778 op->d.agg_trans.setno);
1793 op->d.agg_trans.aggcontext,
1794 op->d.agg_trans.setno);
1807 EEO_JUMP(
op->d.agg_presorted_distinctcheck.jumpdistinct);
1818 EEO_JUMP(
op->d.agg_presorted_distinctcheck.jumpdistinct);
1849 return state->resvalue;
1870 return state->evalfunc(
state, econtext, isNull);
1888 for (
int i = 0;
i <
state->steps_len;
i++)
1954 elog(
ERROR,
"attribute number %d exceeds number of columns %d",
1959 if (attr->attisdropped)
1961 (
errcode(ERRCODE_UNDEFINED_COLUMN),
1962 errmsg(
"attribute %d of type %s has been dropped",
1965 if (
vartype != attr->atttypid)
1967 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1968 errmsg(
"attribute %d of type %s has wrong type",
1970 errdetail(
"Table has type %s, but query expects %s.",
1982 #ifdef USE_ASSERT_CHECKING
1984 if (!
op->d.fetch.fixed)
2031 if (type_id != RECORDOID)
2047 if (typentry->
tupDesc == NULL)
2049 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2050 errmsg(
"type %s is not composite",
2134 int attnum =
op->d.assign_var.attnum + 1;
2149 Assert(
resultnum >= 0 && resultnum < outslot->tts_tupleDescriptor->natts);
2190 *
op->resvalue = *
op->d.casetest.value;
2191 *
op->resnull = *
op->d.casetest.isnull;
2196 fcinfo =
op->d.func.fcinfo_data;
2200 for (
int argno = 0; argno <
nargs; argno++)
2209 d =
op->d.func.fn_addr(fcinfo);
2221 return op->d.constval.value;
2272 int attnum =
op->d.assign_var.attnum;
2281 Assert(
resultnum >= 0 && resultnum < outslot->tts_tupleDescriptor->natts);
2310 #if defined(EEO_USE_COMPUTED_GOTO)
2316 dispatch_compare_ptr(
const void *
a,
const void *
b)
2318 const ExprEvalOpLookup *la = (
const ExprEvalOpLookup *)
a;
2319 const ExprEvalOpLookup *lb = (
const ExprEvalOpLookup *)
b;
2321 if (la->opcode < lb->opcode)
2323 else if (la->opcode > lb->opcode)
2335 #if defined(EEO_USE_COMPUTED_GOTO)
2337 if (dispatch_table == NULL)
2339 dispatch_table = (
const void **)
2345 reverse_dispatch_table[
i].opcode = dispatch_table[
i];
2350 qsort(reverse_dispatch_table,
2352 sizeof(ExprEvalOpLookup),
2353 dispatch_compare_ptr);
2367 #if defined(EEO_USE_COMPUTED_GOTO)
2370 ExprEvalOpLookup
key;
2371 ExprEvalOpLookup *
res;
2373 key.opcode = (
void *)
op->opcode;
2375 reverse_dispatch_table,
2377 sizeof(ExprEvalOpLookup),
2378 dispatch_compare_ptr);
2405 d =
op->d.func.fn_addr(fcinfo);
2427 for (
int argno = 0; argno <
nargs; argno++)
2431 *
op->resnull =
true;
2439 d =
op->d.func.fn_addr(fcinfo);
2478 int paramId =
op->d.param.paramid;
2481 paramId > 0 && paramId <= paramInfo->numParams))
2488 prm = paramInfo->
paramFetch(paramInfo, paramId,
false, &prmdata);
2490 prm = ¶mInfo->
params[paramId - 1];
2497 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2498 errmsg(
"type of parameter %d (%s) does not match that when preparing the plan (%s)",
2509 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2510 errmsg(
"no value found for parameter %d", paramId)));
2522 *
op->resnull =
false;
2554 *
op->resnull = fcinfo->isnull;
2559 *
op->resnull = fcinfo->isnull;
2564 *
op->resnull = fcinfo->isnull;
2569 *
op->resnull = fcinfo->isnull;
2587 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2588 errmsg(
"WHERE CURRENT OF is not supported for this table type")));
2599 switch (
op->d.nextvalueexpr.seqtypid)
2611 elog(
ERROR,
"unsupported sequence type %u",
2612 op->d.nextvalueexpr.seqtypid);
2614 *
op->resnull =
false;
2648 *
op->resnull =
false;
2680 &
op->d.nulltest_row.rowcache, NULL);
2688 for (
int att = 1; att <= tupDesc->
natts; att++)
2727 int nelems =
op->d.arrayexpr.nelems;
2733 *
op->resnull =
false;
2735 if (!
op->d.arrayexpr.multidims)
2738 Datum *dvalues =
op->d.arrayexpr.elemvalues;
2739 bool *dnulls =
op->d.arrayexpr.elemnulls;
2748 op->d.arrayexpr.elemlength,
2749 op->d.arrayexpr.elembyval,
2750 op->d.arrayexpr.elemalign);
2757 int outer_nelems = 0;
2759 int *elem_dims = NULL;
2760 int *elem_lbs = NULL;
2761 bool firstone =
true;
2762 bool havenulls =
false;
2763 bool haveempty =
false;
2778 for (
int elemoff = 0; elemoff <
nelems; elemoff++)
2785 arraydatum =
op->d.arrayexpr.elemvalues[elemoff];
2786 eisnull =
op->d.arrayexpr.elemnulls[elemoff];
2800 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2801 errmsg(
"cannot merge incompatible arrays"),
2802 errdetail(
"Array with element type %s cannot be "
2803 "included in ARRAY construct with element type %s.",
2809 if (this_ndims <= 0)
2818 elem_ndims = this_ndims;
2819 ndims = elem_ndims + 1;
2820 if (ndims <= 0 || ndims >
MAXDIM)
2822 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2823 errmsg(
"number of array dimensions (%d) exceeds the maximum allowed (%d)",
2826 elem_dims = (
int *)
palloc(elem_ndims *
sizeof(
int));
2827 memcpy(elem_dims,
ARR_DIMS(array), elem_ndims *
sizeof(
int));
2828 elem_lbs = (
int *)
palloc(elem_ndims *
sizeof(
int));
2829 memcpy(elem_lbs,
ARR_LBOUND(array), elem_ndims *
sizeof(
int));
2836 if (elem_ndims != this_ndims ||
2838 elem_ndims *
sizeof(
int)) != 0 ||
2840 elem_ndims *
sizeof(
int)) != 0)
2842 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
2843 errmsg(
"multidimensional arrays must have array "
2844 "expressions with matching dimensions")));
2850 nbytes += subbytes[outer_nelems];
2854 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2855 errmsg(
"array size exceeds the maximum allowed (%d)",
2877 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
2878 errmsg(
"multidimensional arrays must have array "
2879 "expressions with matching dimensions")));
2883 dims[0] = outer_nelems;
2885 for (
int i = 1;
i < ndims;
i++)
2887 dims[
i] = elem_dims[
i - 1];
2888 lbs[
i] = elem_lbs[
i - 1];
2898 nbytes += dataoffset;
2908 result->
ndim = ndims;
2911 memcpy(
ARR_DIMS(result), dims, ndims *
sizeof(
int));
2912 memcpy(
ARR_LBOUND(result), lbs, ndims *
sizeof(
int));
2916 for (
int i = 0;
i < outer_nelems;
i++)
2918 memcpy(dat, subdata[
i], subbytes[
i]);
2924 iitem += subnitems[
i];
2945 arraydatum = *
op->resvalue;
2951 if (
op->d.arraycoerce.elemexprstate == NULL)
2965 op->d.arraycoerce.elemexprstate,
2967 op->d.arraycoerce.resultelemtype,
2968 op->d.arraycoerce.amstate);
2984 op->d.row.elemvalues,
2985 op->d.row.elemnulls);
2988 *
op->resnull =
false;
3001 bool *
nulls =
op->d.minmax.nulls;
3010 *
op->resnull =
true;
3012 for (
int off = 0; off <
op->d.minmax.nelems; off++)
3022 *
op->resnull =
false;
3037 if (cmpresult > 0 &&
operator ==
IS_LEAST)
3039 else if (cmpresult < 0 &&
operator ==
IS_GREATEST)
3066 tupDatum = *
op->resvalue;
3084 elog(
ERROR,
"unsupported reference to system column %d in FieldSelect",
3087 elog(
ERROR,
"attribute number %d exceeds number of columns %d",
3092 if (attr->attisdropped)
3094 *
op->resnull =
true;
3100 if (
op->d.fieldselect.resulttype != attr->atttypid)
3102 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3104 errdetail(
"Table has type %s, but query expects %s.",
3122 &
op->d.fieldselect.rowcache, NULL);
3130 elog(
ERROR,
"unsupported reference to system column %d in FieldSelect",
3133 elog(
ERROR,
"attribute number %d exceeds number of columns %d",
3138 if (attr->attisdropped)
3140 *
op->resnull =
true;
3146 if (
op->d.fieldselect.resulttype != attr->atttypid)
3148 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3150 errdetail(
"Table has type %s, but query expects %s.",
3181 memset(
op->d.fieldstore.nulls,
true,
3182 op->d.fieldstore.ncolumns *
sizeof(
bool));
3190 Datum tupDatum = *
op->resvalue;
3208 op->d.fieldstore.rowcache, NULL);
3212 elog(
ERROR,
"too many columns in composite type %u",
3213 op->d.fieldstore.fstore->resulttype);
3216 op->d.fieldstore.values,
3217 op->d.fieldstore.nulls);
3233 op->d.fieldstore.rowcache, NULL);
3236 op->d.fieldstore.values,
3237 op->d.fieldstore.nulls);
3240 *
op->resnull =
false;
3258 bool changed =
false;
3264 tupDatum = *
op->resvalue;
3273 op->d.convert_rowtype.incache,
3277 op->d.convert_rowtype.outcache,
3308 if (
op->d.convert_rowtype.map != NULL)
3348 bool useOr =
op->d.scalararrayop.useOr;
3349 bool strictfunc =
op->d.scalararrayop.finfo->fn_strict;
3381 *
op->resnull =
false;
3391 *
op->resnull =
true;
3402 &
op->d.scalararrayop.typlen,
3403 &
op->d.scalararrayop.typbyval,
3404 &
op->d.scalararrayop.typalign);
3408 typlen =
op->d.scalararrayop.typlen;
3427 if (bitmap && (*bitmap & bitmask) == 0)
3445 thisresult = (
Datum) 0;
3450 thisresult =
op->d.scalararrayop.fn_addr(fcinfo);
3479 if (bitmask == 0x100)
3487 *
op->resvalue = result;
3488 *
op->resnull = resultnull;
3504 fcinfo->args[0].value =
key;
3505 fcinfo->args[0].isnull =
false;
3524 fcinfo->args[0].value = key1;
3525 fcinfo->args[0].isnull =
false;
3526 fcinfo->args[1].value = key2;
3527 fcinfo->args[1].isnull =
false;
3552 bool inclause =
op->d.hashedscalararrayop.inclause;
3553 bool strictfunc =
op->d.hashedscalararrayop.finfo->fn_strict;
3569 *
op->resnull =
true;
3588 saop =
op->d.hashedscalararrayop.saop;
3633 if (bitmap && (*bitmap & bitmask) == 0)
3652 if (bitmask == 0x100)
3684 if (!hashfound &&
op->d.hashedscalararrayop.has_nulls)
3710 result =
op->d.hashedscalararrayop.finfo->fn_addr(fcinfo);
3711 resultnull = fcinfo->
isnull;
3722 *
op->resvalue = result;
3723 *
op->resnull = resultnull;
3734 (
errcode(ERRCODE_NOT_NULL_VIOLATION),
3735 errmsg(
"domain %s does not allow null values",
3746 if (!*
op->d.domaincheck.checknull &&
3749 (
errcode(ERRCODE_CHECK_VIOLATION),
3750 errmsg(
"value for domain %s violates check constraint \"%s\"",
3752 op->d.domaincheck.constraintname),
3754 op->d.domaincheck.constraintname)));
3769 *
op->resnull =
true;
3789 *
op->resnull =
false;
3797 bool *
argnull =
op->d.xmlexpr.named_argnull;
3819 *
op->resnull =
false;
3838 op->d.xmlexpr.named_argvalue,
3839 op->d.xmlexpr.named_argnull,
3840 op->d.xmlexpr.argvalue,
3841 op->d.xmlexpr.argnull));
3842 *
op->resnull =
false;
3850 bool preserve_whitespace;
3867 preserve_whitespace));
3868 *
op->resnull =
false;
3927 *
op->resnull =
false;
3947 *
op->resnull =
false;
3965 *
op->resnull =
false;
3970 elog(
ERROR,
"unrecognized XML operation");
4047 elog(
ERROR,
"invalid JsonConstructorExpr type %d", ctor->
type);
4049 *
op->resvalue =
res;
4072 if (exprtype == TEXTOID || exprtype == JSONOID)
4108 else if (exprtype == JSONBOID)
4159 foreach(lc,
op->d.grouping_func.clauses)
4170 *
op->resnull =
false;
4228 if (
op->d.wholerow.junkFilter != NULL)
4238 if (
op->d.wholerow.first)
4241 op->d.wholerow.slow =
false;
4247 if (
variable->vartype != RECORDOID)
4272 if (var_tupdesc->
natts != slot_tupdesc->
natts)
4274 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4275 errmsg(
"table row type and query-specified row type do not match"),
4277 "Table row contains %d attributes, but query expects %d.",
4278 slot_tupdesc->
natts,
4279 slot_tupdesc->
natts,
4280 var_tupdesc->
natts)));
4282 for (
int i = 0;
i < var_tupdesc->
natts;
i++)
4287 if (vattr->atttypid == sattr->atttypid)
4289 if (!vattr->attisdropped)
4291 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4292 errmsg(
"table row type and query-specified row type do not match"),
4293 errdetail(
"Table has type %s at ordinal position %d, but query expects %s.",
4298 if (vattr->attlen != sattr->attlen ||
4299 vattr->attalign != sattr->attalign)
4300 op->d.wholerow.slow =
true;
4330 output_tupdesc->
tdtypeid = RECORDOID;
4361 op->d.wholerow.first =
false;
4370 if (
op->d.wholerow.slow)
4378 for (
int i = 0;
i < var_tupdesc->
natts;
i++)
4383 if (!vattr->attisdropped)
4387 if (vattr->attlen != sattr->attlen ||
4388 vattr->attalign != sattr->attalign)
4390 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4391 errmsg(
"table row type and query-specified row type do not match"),
4392 errdetail(
"Physical storage mismatch on dropped attribute at ordinal position %d.",
4417 *
op->resnull =
false;
4433 elog(
ERROR,
"failed to fetch attribute from slot");
4495 Datum newValue,
bool newValueIsNull,
4496 Datum oldValue,
bool oldValueIsNull)
4498 Assert(newValue != oldValue);
4500 if (!newValueIsNull)
4520 newValue = (
Datum) 0;
4523 if (!oldValueIsNull)
4623 int setno =
op->d.agg_trans.setno;
4626 *
op->resvalue, *
op->resnull);
4637 int setno =
op->d.agg_trans.setno;
#define DatumGetArrayTypePCopy(X)
#define ARR_NULLBITMAP(a)
#define ARR_OVERHEAD_WITHNULLS(ndims, nitems)
#define DatumGetArrayTypeP(X)
#define ARR_OVERHEAD_NONULLS(ndims)
#define ARR_DATA_OFFSET(a)
Datum array_map(Datum arrayd, ExprState *exprstate, ExprContext *econtext, Oid retType, ArrayMapState *amstate)
ArrayType * construct_empty_array(Oid elmtype)
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
void array_bitmap_copy(bits8 *destbitmap, int destoffset, const bits8 *srcbitmap, int srcoffset, int nitems)
int ArrayGetNItems(int ndim, const int *dims)
void ArrayCheckBounds(int ndim, const int *dims, const int *lb)
#define InvalidAttrNumber
Datum current_database(PG_FUNCTION_ARGS)
Timestamp GetSQLLocalTimestamp(int32 typmod)
TimestampTz GetSQLCurrentTimestamp(int32 typmod)
bool bms_is_member(int x, const Bitmapset *a)
static Datum values[MAXATTR]
#define pg_attribute_always_inline
#define StaticAssertDecl(condition, errmessage)
#define OidIsValid(objectId)
TimeTzADT * GetSQLCurrentTime(int32 typmod)
TimeADT GetSQLLocalTime(int32 typmod)
DateADT GetSQLCurrentDate(void)
static Datum DateADTGetDatum(DateADT X)
static Datum TimeTzADTPGetDatum(const TimeTzADT *X)
static Datum TimeADTGetDatum(TimeADT X)
Datum datumCopy(Datum value, bool typByVal, int typLen)
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
int errdatatype(Oid datatypeOid)
int errdomainconstraint(Oid datatypeOid, const char *conname)
int errdetail(const char *fmt,...)
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecEvalParamExtern(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalFieldStoreForm(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op)
static void CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype)
void ExecEvalRow(ExprState *state, ExprEvalStep *op)
static pg_attribute_always_inline Datum ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
static pg_attribute_always_inline Datum ExecJustAssignVarImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
void ExecEvalFieldStoreDeForm(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalCurrentOfExpr(ExprState *state, ExprEvalStep *op)
void ExecEvalSQLValueFunction(ExprState *state, ExprEvalStep *op)
void ExecEvalRowNull(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op)
static Datum ExecJustAssignInnerVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecJustScanVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecJustApplyFuncToCase(ExprState *state, ExprContext *econtext, bool *isnull)
Datum ExecInterpExprStillValid(ExprState *state, ExprContext *econtext, bool *isNull)
static pg_attribute_always_inline void ExecAggPlainTransByVal(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup, ExprContext *aggcontext, int setno)
struct ScalarArrayOpExprHashEntry ScalarArrayOpExprHashEntry
static Datum ExecJustAssignScanVar(ExprState *state, ExprContext *econtext, bool *isnull)
void ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
bool ExecEvalPreOrderedDistinctMulti(AggState *aggstate, AggStatePerTrans pertrans)
void ExecEvalFieldSelect(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
struct ScalarArrayOpExprHashTable ScalarArrayOpExprHashTable
static Datum ExecJustInnerVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
void ExecEvalConstraintNotNull(ExprState *state, ExprEvalStep *op)
static void ExecInitInterpreter(void)
void ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
void ExecEvalAggOrderedTransDatum(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
static Datum ExecJustConst(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecJustOuterVar(ExprState *state, ExprContext *econtext, bool *isnull)
void ExecEvalParamExec(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecAggInitGroup(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup, ExprContext *aggcontext)
static pg_attribute_always_inline Datum ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
void ExecEvalNextValueExpr(ExprState *state, ExprEvalStep *op)
void ExecEvalSysVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext, TupleTableSlot *slot)
static bool saop_hash_element_match(struct saophash_hash *tb, Datum key1, Datum key2)
void ExecEvalMinMax(ExprState *state, ExprEvalStep *op)
void ExecEvalSubPlan(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalJsonIsPredicate(ExprState *state, ExprEvalStep *op)
static uint32 saop_element_hash(struct saophash_hash *tb, Datum key)
static Datum ExecJustInnerVar(ExprState *state, ExprContext *econtext, bool *isnull)
Datum ExecAggCopyTransValue(AggState *aggstate, AggStatePerTrans pertrans, Datum newValue, bool newValueIsNull, Datum oldValue, bool oldValueIsNull)
static Datum ExecJustAssignInnerVar(ExprState *state, ExprContext *econtext, bool *isnull)
void CheckExprStillValid(ExprState *state, ExprContext *econtext)
void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecReadyInterpretedExpr(ExprState *state)
static Datum ExecJustAssignScanVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
static void ExecEvalRowNullInt(ExprState *state, ExprEvalStep *op, ExprContext *econtext, bool checkisnull)
void ExecEvalRowNotNull(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
ExprEvalOp ExecEvalStepOp(ExprState *state, ExprEvalStep *op)
static Datum ExecJustAssignOuterVar(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecJustAssignOuterVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
void ExecEvalConstraintCheck(ExprState *state, ExprEvalStep *op)
void ExecEvalArrayCoerce(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
static void CheckOpSlotCompatibility(ExprEvalStep *op, TupleTableSlot *slot)
void ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
static Datum ExecJustOuterVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecJustScanVar(ExprState *state, ExprContext *econtext, bool *isnull)
static Datum ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
static pg_attribute_always_inline Datum ExecJustVarImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
void ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
bool ExecEvalPreOrderedDistinctSingle(AggState *aggstate, AggStatePerTrans pertrans)
#define EEO_OPCODE(opcode)
static pg_attribute_always_inline void ExecAggPlainTransByRef(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup, ExprContext *aggcontext, int setno)
void ExecEvalAggOrderedTransTuple(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
static TupleDesc get_cached_rowtype(Oid type_id, int32 typmod, ExprEvalRowtypeCache *rowcache, bool *changed)
#define EEO_FLAG_INTERPRETER_INITIALIZED
#define EEO_FLAG_DIRECT_THREADED
@ EEOP_FUNCEXPR_STRICT_FUSAGE
@ EEOP_AGG_PLAIN_PERGROUP_NULLCHECK
@ EEOP_AGG_STRICT_DESERIALIZE
@ EEOP_BOOLTEST_IS_NOT_FALSE
@ EEOP_AGG_PLAIN_TRANS_BYREF
@ EEOP_AGG_PRESORTED_DISTINCT_MULTI
@ EEOP_AGG_PLAIN_TRANS_BYVAL
@ EEOP_NULLTEST_ROWISNOTNULL
@ EEOP_ASSIGN_TMP_MAKE_RO
@ EEOP_BOOL_OR_STEP_FIRST
@ EEOP_AGG_STRICT_INPUT_CHECK_NULLS
@ EEOP_AGG_STRICT_INPUT_CHECK_ARGS
@ EEOP_NULLTEST_ROWISNULL
@ EEOP_NULLTEST_ISNOTNULL
@ EEOP_AGG_PRESORTED_DISTINCT_SINGLE
@ EEOP_BOOL_AND_STEP_FIRST
@ EEOP_BOOL_AND_STEP_LAST
@ EEOP_AGG_ORDERED_TRANS_DATUM
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYREF
@ EEOP_BOOLTEST_IS_NOT_TRUE
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYREF
@ EEOP_HASHED_SCALARARRAYOP
@ EEOP_AGG_ORDERED_TRANS_TUPLE
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
const TupleTableSlotOps TTSOpsBufferHeapTuple
const TupleTableSlotOps TTSOpsHeapTuple
Datum(* ExprStateEvalFunc)(struct ExprState *expression, struct ExprContext *econtext, bool *isNull)
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
static bool ExecQual(ExprState *state, ExprContext *econtext)
ExpandedObjectHeader * DatumGetEOHP(Datum d)
void DeleteExpandedObject(Datum d)
Datum MakeExpandedObjectReadOnlyInternal(Datum d)
#define DatumIsReadWriteExpandedObject(d, isnull, typlen)
static Datum expanded_record_get_field(ExpandedRecordHeader *erh, int fnumber, bool *isnull)
static TupleDesc expanded_record_get_tupdesc(ExpandedRecordHeader *erh)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum Int64GetDatum(int64 X)
#define DatumGetHeapTupleHeader(X)
#define DatumGetTextPP(X)
#define SizeForFunctionCallInfo(nargs)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define LOCAL_FCINFO(name, nargs)
#define FunctionCallInvoke(fcinfo)
#define fmgr_info_set_expr(expr, finfo)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
HeapTuple toast_build_flattened_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
#define HeapTupleHeaderSetTypMod(tup, typmod)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
#define HeapTupleHeaderGetTypMod(tup)
#define HeapTupleHeaderGetTypeId(tup)
#define HeapTupleHeaderGetDatumLength(tup)
#define HeapTupleHeaderSetTypeId(tup, typeid)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Datum json_build_array_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null)
Datum json_build_object_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null, bool unique_keys)
Datum datum_to_json(Datum val, JsonTypeCategory tcategory, Oid outfuncoid)
bool json_validate(text *json, bool check_unique_keys, bool throw_error)
@ JSON_TOKEN_OBJECT_START
Datum jsonb_from_text(text *js, bool unique_keys)
Datum jsonb_build_array_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null)
Datum jsonb_build_object_worker(int nargs, Datum *args, bool *nulls, Oid *types, bool absent_on_null, bool unique_keys)
Datum datum_to_jsonb(Datum val, JsonTypeCategory tcategory, Oid outfuncoid)
static Jsonb * DatumGetJsonbP(Datum d)
#define JB_ROOT_IS_OBJECT(jbp_)
#define JB_ROOT_IS_ARRAY(jbp_)
#define JB_ROOT_IS_SCALAR(jbp_)
JsonTokenType json_get_first_token(text *json, bool throw_error)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
MemoryContext MemoryContextGetParent(MemoryContext context)
#define AllocSizeIsValid(size)
Datum current_user(PG_FUNCTION_ARGS)
Datum session_user(PG_FUNCTION_ARGS)
Datum current_schema(PG_FUNCTION_ARGS)
Oid exprType(const Node *expr)
void ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
Datum ExecSubPlan(SubPlanState *node, ExprContext *econtext, bool *isNull)
#define castNode(_type_, nodeptr)