diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-17 19:58:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-17 19:58:06 +0000 |
commit | ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8 (patch) | |
tree | bd256cf157c4636382d59938162326fccc70b62c /src/backend/utils/cache/lsyscache.c | |
parent | d89578ccbefb83aa9f9d1c00269cd866be2cc857 (diff) | |
download | postgresql-ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8.tar.gz postgresql-ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8.zip |
Create a 'type cache' that keeps track of the data needed for any particular
datatype by array_eq and array_cmp; use this to solve problems with memory
leaks in array indexing support. The parser's equality_oper and ordering_oper
routines also use the cache. Change the operator search algorithms to look
for appropriate btree or hash index opclasses, instead of assuming operators
named '<' or '=' have the right semantics. (ORDER BY ASC/DESC now also look
at opclasses, instead of assuming '<' and '>' are the right things.) Add
several more index opclasses so that there is no regression in functionality
for base datatypes. initdb forced due to catalog additions.
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 0faa097f349..3864a2fa52b 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.106 2003/08/11 23:04:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.107 2003/08/17 19:58:06 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -122,7 +122,6 @@ get_op_hash_function(Oid opno) { CatCList *catlist; int i; - HeapTuple tuple; Oid opclass = InvalidOid; /* @@ -137,10 +136,8 @@ get_op_hash_function(Oid opno) for (i = 0; i < catlist->n_members; i++) { - Form_pg_amop aform; - - tuple = &catlist->members[i]->tuple; - aform = (Form_pg_amop) GETSTRUCT(tuple); + HeapTuple tuple = &catlist->members[i]->tuple; + Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); if (aform->amopstrategy == HTEqualStrategyNumber && opclass_is_hash(aform->amopclaid)) @@ -155,20 +152,7 @@ get_op_hash_function(Oid opno) if (OidIsValid(opclass)) { /* Found a suitable opclass, get its hash support function */ - tuple = SearchSysCache(AMPROCNUM, - ObjectIdGetDatum(opclass), - Int16GetDatum(HASHPROC), - 0, 0); - if (HeapTupleIsValid(tuple)) - { - Form_pg_amproc aform = (Form_pg_amproc) GETSTRUCT(tuple); - RegProcedure result; - - result = aform->amproc; - ReleaseSysCache(tuple); - Assert(RegProcedureIsValid(result)); - return result; - } + return get_opclass_proc(opclass, HASHPROC); } /* Didn't find a match... */ @@ -176,6 +160,35 @@ get_op_hash_function(Oid opno) } +/* ---------- AMPROC CACHES ---------- */ + +/* + * get_opclass_proc + * Get the OID of the specified support function + * for the specified opclass. + * + * Returns InvalidOid if there is no pg_amproc entry for the given keys. + */ +Oid +get_opclass_proc(Oid opclass, int16 procnum) +{ + HeapTuple tp; + Form_pg_amproc amproc_tup; + RegProcedure result; + + tp = SearchSysCache(AMPROCNUM, + ObjectIdGetDatum(opclass), + Int16GetDatum(procnum), + 0, 0); + if (!HeapTupleIsValid(tp)) + return InvalidOid; + amproc_tup = (Form_pg_amproc) GETSTRUCT(tp); + result = amproc_tup->amproc; + ReleaseSysCache(tp); + return result; +} + + /* ---------- ATTRIBUTE CACHES ---------- */ /* |