diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-13 02:50:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-13 02:50:35 +0000 |
commit | 37168b8da43d9a6f7471cf757119ece6c96fb2b9 (patch) | |
tree | ce7059e77ac05a045f9de7c6272c7e1c8210d96a /src/backend/utils/cache | |
parent | 766fb7f707f9527be219353f5f970aab3d786554 (diff) | |
download | postgresql-37168b8da43d9a6f7471cf757119ece6c96fb2b9.tar.gz postgresql-37168b8da43d9a6f7471cf757119ece6c96fb2b9.zip |
Clean up handling of variable-free qual clauses. System now does the
right thing with variable-free clauses that contain noncachable functions,
such as 'WHERE random() < 0.5' --- these are evaluated once per
potential output tuple. Expressions that contain only Params are
now candidates to be indexscan quals --- for example, 'var = ($1 + 1)'
can now be indexed. Cope with RelabelType nodes atop potential indexscan
variables --- this oversight prevents 7.0.* from recognizing some
potentially indexscanable situations.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 5c80a5179a4..28910dae892 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.44 2000/07/23 03:50:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.45 2000/08/13 02:50:16 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -26,15 +26,15 @@ /* * op_class * - * Return t iff operator 'opid' is in operator class 'opclass' for + * Return t iff operator 'opno' is in operator class 'opclass' for * access method 'amopid'. */ bool -op_class(Oid opid, Oid opclass, Oid amopid) +op_class(Oid opno, Oid opclass, Oid amopid) { if (HeapTupleIsValid(SearchSysCacheTuple(AMOPOPID, ObjectIdGetDatum(opclass), - ObjectIdGetDatum(opid), + ObjectIdGetDatum(opno), ObjectIdGetDatum(amopid), 0))) return true; @@ -287,7 +287,7 @@ get_opcode(Oid opno) return optup->oprcode; } else - return (RegProcedure) NULL; + return (RegProcedure) InvalidOid; } /* @@ -371,17 +371,28 @@ op_hashjoinable(Oid opno, Oid ltype, Oid rtype) return InvalidOid; } +/* + * op_iscachable + * + * Get the proiscachable flag for the operator's underlying function. + */ +bool +op_iscachable(Oid opno) +{ + RegProcedure funcid = get_opcode(opno); + + if (funcid == (RegProcedure) InvalidOid) + elog(ERROR, "Operator OID %u does not exist", opno); + + return func_iscachable((Oid) funcid); +} + HeapTuple get_operator_tuple(Oid opno) { - HeapTuple optup; - - if ((optup = SearchSysCacheTuple(OPEROID, - ObjectIdGetDatum(opno), - 0, 0, 0))) - return optup; - else - return (HeapTuple) NULL; + return SearchSysCacheTuple(OPEROID, + ObjectIdGetDatum(opno), + 0, 0, 0); } /* @@ -450,7 +461,7 @@ get_oprrest(Oid opno) return optup->oprrest; } else - return (RegProcedure) NULL; + return (RegProcedure) InvalidOid; } /* @@ -473,7 +484,7 @@ get_oprjoin(Oid opno) return optup->oprjoin; } else - return (RegProcedure) NULL; + return (RegProcedure) InvalidOid; } /* ---------- FUNCTION CACHE ---------- */ @@ -496,6 +507,24 @@ get_func_rettype(Oid funcid) return ((Form_pg_proc) GETSTRUCT(func_tuple))->prorettype; } +/* + * func_iscachable + * Given procedure id, return the function's proiscachable flag. + */ +bool +func_iscachable(Oid funcid) +{ + HeapTuple func_tuple; + + func_tuple = SearchSysCacheTuple(PROCOID, + ObjectIdGetDatum(funcid), + 0, 0, 0); + if (!HeapTupleIsValid(func_tuple)) + elog(ERROR, "Function OID %u does not exist", funcid); + + return ((Form_pg_proc) GETSTRUCT(func_tuple))->proiscachable; +} + /* ---------- RELATION CACHE ---------- */ #ifdef NOT_USED |