--------------------- * lookupProcCallback() - Find a specified callback for a specified function * * Parameters: * profnoid - oid of the function that has a callback * promethod - which callback to find * --------------------- */
| 125 | * --------------------- |
| 126 | */ |
| 127 | Oid |
| 128 | lookupProcCallback(Oid profnoid, char promethod) |
| 129 | { |
| 130 | Relation rel; |
| 131 | ScanKeyData skey[2]; |
| 132 | SysScanDesc scan; |
| 133 | HeapTuple tup; |
| 134 | Oid result; |
| 135 | |
| 136 | Assert(OidIsValid(profnoid)); |
| 137 | |
| 138 | /* open pg_proc_callback */ |
| 139 | rel = heap_open(ProcCallbackRelationId, AccessShareLock); |
| 140 | |
| 141 | /* Lookup (profnoid, promethod) from index */ |
| 142 | /* (profnoid, promethod) is guaranteed unique by the index */ |
| 143 | ScanKeyInit(&skey[0], |
| 144 | Anum_pg_proc_callback_profnoid, |
| 145 | BTEqualStrategyNumber, F_OIDEQ, |
| 146 | ObjectIdGetDatum(profnoid)); |
| 147 | ScanKeyInit(&skey[1], |
| 148 | Anum_pg_proc_callback_promethod, |
| 149 | BTEqualStrategyNumber, F_CHAREQ, |
| 150 | CharGetDatum(promethod)); |
| 151 | scan = systable_beginscan(rel, ProcCallbackProfnoidPromethodIndexId, true, |
| 152 | NULL, 2, skey); |
| 153 | tup = systable_getnext(scan); |
| 154 | if (HeapTupleIsValid(tup)) |
| 155 | { |
| 156 | Datum d; |
| 157 | bool isnull; |
| 158 | |
| 159 | d = heap_getattr(tup, Anum_pg_proc_callback_procallback, |
| 160 | RelationGetDescr(rel), &isnull); |
| 161 | Assert(!isnull); |
| 162 | |
| 163 | result = DatumGetObjectId(d); |
| 164 | } |
| 165 | else |
| 166 | result = InvalidOid; |
| 167 | |
| 168 | systable_endscan(scan); |
| 169 | heap_close(rel, AccessShareLock); |
| 170 | |
| 171 | return result; |
| 172 | } |
no test coverage detected