mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
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.
This commit is contained in:
53
src/backend/utils/cache/lsyscache.c
vendored
53
src/backend/utils/cache/lsyscache.c
vendored
@ -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 ---------- */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user