diff options
Diffstat (limited to 'src/backend/utils/adt/arrayfuncs.c')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 122 |
1 files changed, 60 insertions, 62 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index e457d81f23c..a785361fd07 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -3571,6 +3571,7 @@ array_contains_nulls(ArrayType *array) Datum array_eq(PG_FUNCTION_ARGS) { + LOCAL_FCINFO(locfcinfo, 2); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1); Oid collation = PG_GET_COLLATION(); @@ -3590,7 +3591,6 @@ array_eq(PG_FUNCTION_ARGS) array_iter it1; array_iter it2; int i; - FunctionCallInfoData locfcinfo; if (element_type != AARR_ELEMTYPE(array2)) ereport(ERROR, @@ -3630,7 +3630,7 @@ array_eq(PG_FUNCTION_ARGS) /* * apply the operator to each pair of array elements. */ - InitFunctionCallInfoData(locfcinfo, &typentry->eq_opr_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->eq_opr_finfo, 2, collation, NULL, NULL); /* Loop over source data */ @@ -3666,12 +3666,12 @@ array_eq(PG_FUNCTION_ARGS) /* * Apply the operator to the element pair */ - locfcinfo.arg[0] = elt1; - locfcinfo.arg[1] = elt2; - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; - oprresult = DatumGetBool(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt1; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = elt2; + locfcinfo->args[1].isnull = false; + locfcinfo->isnull = false; + oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo)); if (!oprresult) { result = false; @@ -3742,6 +3742,7 @@ btarraycmp(PG_FUNCTION_ARGS) static int array_cmp(FunctionCallInfo fcinfo) { + LOCAL_FCINFO(locfcinfo, 2); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1); Oid collation = PG_GET_COLLATION(); @@ -3761,7 +3762,6 @@ array_cmp(FunctionCallInfo fcinfo) array_iter it1; array_iter it2; int i; - FunctionCallInfoData locfcinfo; if (element_type != AARR_ELEMTYPE(array2)) ereport(ERROR, @@ -3794,7 +3794,7 @@ array_cmp(FunctionCallInfo fcinfo) /* * apply the operator to each pair of array elements. */ - InitFunctionCallInfoData(locfcinfo, &typentry->cmp_proc_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->cmp_proc_finfo, 2, collation, NULL, NULL); /* Loop over source data */ @@ -3833,12 +3833,12 @@ array_cmp(FunctionCallInfo fcinfo) } /* Compare the pair of elements */ - locfcinfo.arg[0] = elt1; - locfcinfo.arg[1] = elt2; - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; - cmpresult = DatumGetInt32(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt1; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = elt2; + locfcinfo->args[1].isnull = false; + locfcinfo->isnull = false; + cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo)); if (cmpresult == 0) continue; /* equal */ @@ -3913,6 +3913,7 @@ array_cmp(FunctionCallInfo fcinfo) Datum hash_array(PG_FUNCTION_ARGS) { + LOCAL_FCINFO(locfcinfo, 1); AnyArrayType *array = PG_GETARG_ANY_ARRAY_P(0); int ndims = AARR_NDIM(array); int *dims = AARR_DIMS(array); @@ -3925,7 +3926,6 @@ hash_array(PG_FUNCTION_ARGS) char typalign; int i; array_iter iter; - FunctionCallInfoData locfcinfo; /* * We arrange to look up the hash function only once per series of calls, @@ -3953,7 +3953,7 @@ hash_array(PG_FUNCTION_ARGS) /* * apply the hash function to each array element. */ - InitFunctionCallInfoData(locfcinfo, &typentry->hash_proc_finfo, 1, + InitFunctionCallInfoData(*locfcinfo, &typentry->hash_proc_finfo, 1, InvalidOid, NULL, NULL); /* Loop over source data */ @@ -3977,10 +3977,10 @@ hash_array(PG_FUNCTION_ARGS) else { /* Apply the hash function */ - locfcinfo.arg[0] = elt; - locfcinfo.argnull[0] = false; - locfcinfo.isnull = false; - elthash = DatumGetUInt32(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt; + locfcinfo->args[0].isnull = false; + locfcinfo->isnull = false; + elthash = DatumGetUInt32(FunctionCallInvoke(locfcinfo)); } /* @@ -4010,6 +4010,7 @@ hash_array(PG_FUNCTION_ARGS) Datum hash_array_extended(PG_FUNCTION_ARGS) { + LOCAL_FCINFO(locfcinfo, 2); AnyArrayType *array = PG_GETARG_ANY_ARRAY_P(0); uint64 seed = PG_GETARG_INT64(1); int ndims = AARR_NDIM(array); @@ -4023,7 +4024,6 @@ hash_array_extended(PG_FUNCTION_ARGS) char typalign; int i; array_iter iter; - FunctionCallInfoData locfcinfo; typentry = (TypeCacheEntry *) fcinfo->flinfo->fn_extra; if (typentry == NULL || @@ -4042,7 +4042,7 @@ hash_array_extended(PG_FUNCTION_ARGS) typbyval = typentry->typbyval; typalign = typentry->typalign; - InitFunctionCallInfoData(locfcinfo, &typentry->hash_extended_proc_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->hash_extended_proc_finfo, 2, InvalidOid, NULL, NULL); /* Loop over source data */ @@ -4065,12 +4065,11 @@ hash_array_extended(PG_FUNCTION_ARGS) else { /* Apply the hash function */ - locfcinfo.arg[0] = elt; - locfcinfo.arg[1] = Int64GetDatum(seed); - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; - elthash = DatumGetUInt64(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = Int64GetDatum(seed); + locfcinfo->args[1].isnull = false; + elthash = DatumGetUInt64(FunctionCallInvoke(locfcinfo)); } result = (result << 5) - result + elthash; @@ -4100,6 +4099,7 @@ static bool array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, bool matchall, void **fn_extra) { + LOCAL_FCINFO(locfcinfo, 2); bool result = matchall; Oid element_type = AARR_ELEMTYPE(array1); TypeCacheEntry *typentry; @@ -4113,7 +4113,6 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, int i; int j; array_iter it1; - FunctionCallInfoData locfcinfo; if (element_type != AARR_ELEMTYPE(array2)) ereport(ERROR, @@ -4164,7 +4163,7 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, /* * Apply the comparison operator to each pair of array elements. */ - InitFunctionCallInfoData(locfcinfo, &typentry->eq_opr_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->eq_opr_finfo, 2, collation, NULL, NULL); /* Loop over source data */ @@ -4206,12 +4205,12 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, /* * Apply the operator to the element pair */ - locfcinfo.arg[0] = elt1; - locfcinfo.arg[1] = elt2; - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; - oprresult = DatumGetBool(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt1; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = elt2; + locfcinfo->args[1].isnull = false; + locfcinfo->isnull = false; + oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo)); if (oprresult) break; } @@ -6042,6 +6041,7 @@ array_replace_internal(ArrayType *array, bool remove, Oid collation, FunctionCallInfo fcinfo) { + LOCAL_FCINFO(locfcinfo, 2); ArrayType *result; Oid element_type; Datum *values; @@ -6062,7 +6062,6 @@ array_replace_internal(ArrayType *array, int bitmask; bool changed = false; TypeCacheEntry *typentry; - FunctionCallInfoData locfcinfo; element_type = ARR_ELEMTYPE(array); ndim = ARR_NDIM(array); @@ -6117,7 +6116,7 @@ array_replace_internal(ArrayType *array, } /* Prepare to apply the comparison operator */ - InitFunctionCallInfoData(locfcinfo, &typentry->eq_opr_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->eq_opr_finfo, 2, collation, NULL, NULL); /* Allocate temporary arrays for new values */ @@ -6175,12 +6174,12 @@ array_replace_internal(ArrayType *array, /* * Apply the operator to the element pair */ - locfcinfo.arg[0] = elt; - locfcinfo.arg[1] = search; - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; - oprresult = DatumGetBool(FunctionCallInvoke(&locfcinfo)); + locfcinfo->args[0].value = elt; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = search; + locfcinfo->args[1].isnull = false; + locfcinfo->isnull = false; + oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo)); if (!oprresult) { /* no match, keep element */ @@ -6457,10 +6456,10 @@ width_bucket_array_fixed(Datum operand, Oid collation, TypeCacheEntry *typentry) { + LOCAL_FCINFO(locfcinfo, 2); char *thresholds_data; int typlen = typentry->typlen; bool typbyval = typentry->typbyval; - FunctionCallInfoData locfcinfo; int left; int right; @@ -6470,7 +6469,7 @@ width_bucket_array_fixed(Datum operand, */ thresholds_data = (char *) ARR_DATA_PTR(thresholds); - InitFunctionCallInfoData(locfcinfo, &typentry->cmp_proc_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->cmp_proc_finfo, 2, collation, NULL, NULL); /* Find the bucket */ @@ -6484,13 +6483,13 @@ width_bucket_array_fixed(Datum operand, ptr = thresholds_data + mid * typlen; - locfcinfo.arg[0] = operand; - locfcinfo.arg[1] = fetch_att(ptr, typbyval, typlen); - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; + locfcinfo->args[0].value = operand; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = fetch_att(ptr, typbyval, typlen); + locfcinfo->args[1].isnull = false; + locfcinfo->isnull = false; - cmpresult = DatumGetInt32(FunctionCallInvoke(&locfcinfo)); + cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo)); if (cmpresult < 0) right = mid; @@ -6510,17 +6509,17 @@ width_bucket_array_variable(Datum operand, Oid collation, TypeCacheEntry *typentry) { + LOCAL_FCINFO(locfcinfo, 2); char *thresholds_data; int typlen = typentry->typlen; bool typbyval = typentry->typbyval; char typalign = typentry->typalign; - FunctionCallInfoData locfcinfo; int left; int right; thresholds_data = (char *) ARR_DATA_PTR(thresholds); - InitFunctionCallInfoData(locfcinfo, &typentry->cmp_proc_finfo, 2, + InitFunctionCallInfoData(*locfcinfo, &typentry->cmp_proc_finfo, 2, collation, NULL, NULL); /* Find the bucket */ @@ -6541,13 +6540,12 @@ width_bucket_array_variable(Datum operand, ptr = (char *) att_align_nominal(ptr, typalign); } - locfcinfo.arg[0] = operand; - locfcinfo.arg[1] = fetch_att(ptr, typbyval, typlen); - locfcinfo.argnull[0] = false; - locfcinfo.argnull[1] = false; - locfcinfo.isnull = false; + locfcinfo->args[0].value = operand; + locfcinfo->args[0].isnull = false; + locfcinfo->args[1].value = fetch_att(ptr, typbyval, typlen); + locfcinfo->args[1].isnull = false; - cmpresult = DatumGetInt32(FunctionCallInvoke(&locfcinfo)); + cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo)); if (cmpresult < 0) right = mid; |