diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-05 00:31:36 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-05 00:31:36 +0000 |
commit | 4bdb4be62e652ee3220dae21a4fa340832c93429 (patch) | |
tree | f1b39eb4cbcc1a8fca748304770a72aec96cd472 /src/backend/utils/adt/regproc.c | |
parent | 0e11aea246a462e503a73908c9fc143b9f2da16a (diff) | |
download | postgresql-4bdb4be62e652ee3220dae21a4fa340832c93429.tar.gz postgresql-4bdb4be62e652ee3220dae21a4fa340832c93429.zip |
Divide functions into three volatility classes (immutable, stable, and
volatile), rather than the old cachable/noncachable distinction. This
allows indexscan optimizations in many places where we formerly didn't.
Also, add a pronamespace column to pg_proc (it doesn't do anything yet,
however).
Diffstat (limited to 'src/backend/utils/adt/regproc.c')
-rw-r--r-- | src/backend/utils/adt/regproc.c | 64 |
1 files changed, 15 insertions, 49 deletions
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index b06001af3da..fd28c8fae77 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.64 2001/10/25 05:49:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.65 2002/04/05 00:31:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -42,13 +42,13 @@ regprocin(PG_FUNCTION_ARGS) char *pro_name_or_oid = PG_GETARG_CSTRING(0); RegProcedure result = InvalidOid; int matches = 0; - ScanKeyData skey[1]; if (pro_name_or_oid[0] == '-' && pro_name_or_oid[1] == '\0') PG_RETURN_OID(InvalidOid); if (pro_name_or_oid[0] >= '0' && - pro_name_or_oid[0] <= '9') + pro_name_or_oid[0] <= '9' && + strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { Oid searchOid; @@ -61,67 +61,33 @@ regprocin(PG_FUNCTION_ARGS) elog(ERROR, "No procedure with oid %s", pro_name_or_oid); matches = 1; } - else if (!IsIgnoringSystemIndexes()) + else { Relation hdesc; - Relation idesc; - IndexScanDesc sd; - RetrieveIndexResult indexRes; - HeapTupleData tuple; - Buffer buffer; + ScanKeyData skey[1]; + SysScanDesc funcscan; + HeapTuple tuple; ScanKeyEntryInitialize(&skey[0], 0x0, - (AttrNumber) 1, + (AttrNumber) Anum_pg_proc_proname, (RegProcedure) F_NAMEEQ, CStringGetDatum(pro_name_or_oid)); hdesc = heap_openr(ProcedureRelationName, AccessShareLock); - idesc = index_openr(ProcedureNameIndex); - sd = index_beginscan(idesc, false, 1, skey); - - while ((indexRes = index_getnext(sd, ForwardScanDirection))) - { - tuple.t_datamcxt = NULL; - tuple.t_data = NULL; - tuple.t_self = indexRes->heap_iptr; - heap_fetch(hdesc, SnapshotNow, &tuple, &buffer, sd); - pfree(indexRes); - if (tuple.t_data != NULL) - { - result = (RegProcedure) tuple.t_data->t_oid; - ReleaseBuffer(buffer); - if (++matches > 1) - break; - } - } - index_endscan(sd); - index_close(idesc); - heap_close(hdesc, AccessShareLock); - } - else - { - Relation proc; - HeapScanDesc procscan; - HeapTuple proctup; + funcscan = systable_beginscan(hdesc, ProcedureNameNspIndex, true, + SnapshotNow, 1, skey); - ScanKeyEntryInitialize(&skey[0], 0x0, - (AttrNumber) Anum_pg_proc_proname, - (RegProcedure) F_NAMEEQ, - CStringGetDatum(pro_name_or_oid)); - - proc = heap_openr(ProcedureRelationName, AccessShareLock); - procscan = heap_beginscan(proc, 0, SnapshotNow, 1, skey); - - while (HeapTupleIsValid(proctup = heap_getnext(procscan, 0))) + while (HeapTupleIsValid(tuple = systable_getnext(funcscan))) { - result = proctup->t_data->t_oid; + result = (RegProcedure) tuple->t_data->t_oid; if (++matches > 1) break; } - heap_endscan(procscan); - heap_close(proc, AccessShareLock); + systable_endscan(funcscan); + + heap_close(hdesc, AccessShareLock); } if (matches > 1) |