/* * LookupOperWithArgs * Like LookupOperName, but the argument types are specified by * a ObjectWithArg node. */ Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError) { TypeName *oprleft, *oprright; Oid leftoid, rightoid; Assert(list_length(oper->objargs) == 2); oprleft = linitial(oper->objargs); oprright = lsecond(oper->objargs); if (oprleft == NULL) leftoid = InvalidOid; else leftoid = LookupTypeNameOid(NULL, oprleft, noError); if (oprright == NULL) rightoid = InvalidOid; else rightoid = LookupTypeNameOid(NULL, oprright, noError); return LookupOperName(NULL, oper->objname, leftoid, rightoid, noError, -1); }
static BloomFilter * bloom_operation(FunctionCallInfo fcinfo, bool intersection) { Oid bf_type = LookupTypeNameOid(NULL, SystemTypeName("bloom"), false); BloomFilter *result = NULL; int i; for (i = 0; i < PG_NARGS(); i++) { BloomFilter *bf; if (PG_ARGISNULL(i)) continue; if (get_fn_expr_argtype(fcinfo->flinfo, i) != bf_type) elog(ERROR, "argument %d is not of type \"bloom\"", i + 1); bf = (BloomFilter *) PG_GETARG_VARLENA_P(i); if (result) { if (bf->m != result->m) elog(ERROR, "bloom filters must have the same p"); else if (bf->k != result->k) elog(ERROR, "bloom filters must have the same n"); } if (result == NULL) result = bf; else if (intersection) result = BloomFilterIntersection(result, bf); else result = BloomFilterUnion(result, bf); } return result; }
/* * LookupOperNameTypeNames * Like LookupOperName, but the argument types are specified by * TypeName nodes. * * Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op. */ Oid LookupOperNameTypeNames(ParseState *pstate, List *opername, TypeName *oprleft, TypeName *oprright, bool noError, int location) { Oid leftoid, rightoid; if (oprleft == NULL) leftoid = InvalidOid; else leftoid = LookupTypeNameOid(pstate, oprleft, noError); if (oprright == NULL) rightoid = InvalidOid; else rightoid = LookupTypeNameOid(pstate, oprright, noError); return LookupOperName(pstate, opername, leftoid, rightoid, noError, location); }