| 220 | |
| 221 | |
| 222 | static bool |
| 223 | assert_equals_base(FunctionCallInfo fcinfo) |
| 224 | { |
| 225 | Datum value1 = PG_GETARG_DATUM(0); |
| 226 | Datum value2 = PG_GETARG_DATUM(1); |
| 227 | Oid *ptr; |
| 228 | |
| 229 | ptr = (Oid *) fcinfo->flinfo->fn_extra; |
| 230 | if (ptr == NULL) |
| 231 | { |
| 232 | Oid valtype = get_fn_expr_argtype(fcinfo->flinfo, 0); |
| 233 | Oid eqopfcid; |
| 234 | |
| 235 | if (!OidIsValid(valtype)) |
| 236 | elog(ERROR, "could not determine data type of input"); |
| 237 | |
| 238 | eqopfcid = equality_oper_funcid(valtype); |
| 239 | |
| 240 | if (!OidIsValid(eqopfcid)) |
| 241 | ereport(ERROR, |
| 242 | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 243 | errmsg("unknown equal operand for datatype"))); |
| 244 | |
| 245 | /* First time calling for current query: allocate storage */ |
| 246 | fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, |
| 247 | sizeof(Oid)); |
| 248 | ptr = (Oid *) fcinfo->flinfo->fn_extra; |
| 249 | *ptr = eqopfcid; |
| 250 | } |
| 251 | |
| 252 | return DatumGetBool(OidFunctionCall2Coll(*ptr, DEFAULT_COLLATION_OID, value1, value2)); |
| 253 | } |
| 254 | |
| 255 | Datum |
| 256 | plunit_assert_equals(PG_FUNCTION_ARGS) |
no test coverage detected