- MemSet(typeId, 0, 8 * sizeof(Oid));
- typeId[0] = OIDOID; /* operator OID */
- typeId[1] = OIDOID; /* relation OID */
- typeId[2] = INT2OID; /* attribute number */
- typeId[3] = 0; /* value - can be any type */
- typeId[4] = INT4OID; /* flags - left or right selectivity */
- tup = SearchSysCacheTuple(PRONAME,
- PointerGetDatum(restrictionName),
- Int32GetDatum(5),
- PointerGetDatum(typeId),
- 0);
- if (!HeapTupleIsValid(tup))
- func_error("OperatorDef", restrictionName, 5, typeId, NULL);
-
- values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
+ Oid restOid;
+
+ MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
+ typeId[0] = 0; /* Query (opaque type) */
+ typeId[1] = OIDOID; /* operator OID */
+ typeId[2] = 0; /* args list (opaque type) */
+ typeId[3] = INT4OID; /* varRelid */
+
+ restOid = GetSysCacheOid(PROCNAME,
+ PointerGetDatum(restrictionName),
+ Int32GetDatum(4),
+ PointerGetDatum(typeId),
+ 0);
+ if (!OidIsValid(restOid))
+ func_error("OperatorDef", restrictionName, 4, typeId, NULL);
+
+ values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(restOid);