index 11987c8f3ba5245b9586afba2565b7f85fb78f08..800107d4e72648fe4e54cd96fcc1288e8d88a94e 100644 (file)
}
/*
- * Apply the operator to the element pair
+ * Apply the operator to the element pair; treat NULL as false
*/
locfcinfo->args[0].value = elt1;
locfcinfo->args[0].isnull = false;
locfcinfo->args[1].isnull = false;
locfcinfo->isnull = false;
oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo));
- if (!oprresult)
+ if (locfcinfo->isnull || !oprresult)
{
result = false;
break;
locfcinfo->args[0].isnull = false;
locfcinfo->args[1].value = elt2;
locfcinfo->args[1].isnull = false;
- locfcinfo->isnull = false;
cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo));
+ /* We don't expect comparison support functions to return null */
+ Assert(!locfcinfo->isnull);
+
if (cmpresult == 0)
continue; /* equal */
/* Apply the hash function */
locfcinfo->args[0].value = elt;
locfcinfo->args[0].isnull = false;
- locfcinfo->isnull = false;
elthash = DatumGetUInt32(FunctionCallInvoke(locfcinfo));
+ /* We don't expect hash functions to return null */
+ Assert(!locfcinfo->isnull);
}
/*
locfcinfo->args[1].value = Int64GetDatum(seed);
locfcinfo->args[1].isnull = false;
elthash = DatumGetUInt64(FunctionCallInvoke(locfcinfo));
+ /* We don't expect hash functions to return null */
+ Assert(!locfcinfo->isnull);
}
result = (result << 5) - result + elthash;
@@ -4207,7 +4212,7 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
continue; /* can't match */
/*
- * Apply the operator to the element pair
+ * Apply the operator to the element pair; treat NULL as false
*/
locfcinfo->args[0].value = elt1;
locfcinfo->args[0].isnull = false;
@@ -4215,7 +4220,7 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
locfcinfo->args[1].isnull = false;
locfcinfo->isnull = false;
oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo));
- if (oprresult)
+ if (!locfcinfo->isnull && oprresult)
break;
}
else
{
/*
- * Apply the operator to the element pair
+ * Apply the operator to the element pair; treat NULL as false
*/
locfcinfo->args[0].value = elt;
locfcinfo->args[0].isnull = false;
locfcinfo->args[1].isnull = false;
locfcinfo->isnull = false;
oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo));
- if (!oprresult)
+ if (locfcinfo->isnull || !oprresult)
{
/* no match, keep element */
values[nresult] = elt;
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));
+ /* We don't expect comparison support functions to return null */
+ Assert(!locfcinfo->isnull);
+
if (cmpresult < 0)
right = mid;
else
cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo));
+ /* We don't expect comparison support functions to return null */
+ Assert(!locfcinfo->isnull);
+
if (cmpresult < 0)
right = mid;
else
index 06ad83d7cae150afc540aaa4cac1e2b6c01a2e18..80cba2f4c261e308f05036583dd25a87b15bd05b 100644 (file)
locfcinfo->args[0].isnull = false;
locfcinfo->args[1].value = values2[i2];
locfcinfo->args[1].isnull = false;
- locfcinfo->isnull = false;
cmpresult = DatumGetInt32(FunctionCallInvoke(locfcinfo));
+ /* We don't expect comparison support functions to return null */
+ Assert(!locfcinfo->isnull);
+
if (cmpresult < 0)
{
/* arg1 is less than arg2 */
locfcinfo->args[0].isnull = false;
locfcinfo->args[1].value = values2[i2];
locfcinfo->args[1].isnull = false;
- locfcinfo->isnull = false;
oprresult = DatumGetBool(FunctionCallInvoke(locfcinfo));
- if (!oprresult)
+ if (locfcinfo->isnull || !oprresult)
{
result = false;
break;
index a4249994b9219d636516afcf431d73d31dabc43a..d349510b7c76cb95cabb0623a01182929d556003 100644 (file)
@@ -163,6 +163,11 @@ extern void fmgr_symbol(Oid functionId, char **mod, char **fn);
* caller must still check fcinfo->isnull! Also, if function is strict,
* it is caller's responsibility to verify that no null arguments are present
* before calling.
+ *
+ * Some code performs multiple calls without redoing InitFunctionCallInfoData,
+ * possibly altering the argument values. This is okay, but be sure to reset
+ * the fcinfo->isnull flag before each call, since callees are permitted to
+ * assume that starts out false.
*/
#define FunctionCallInvoke(fcinfo) ((* (fcinfo)->flinfo->fn_addr) (fcinfo))