aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/typcache.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-11-15 13:05:45 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-11-15 13:05:45 -0500
commit37ee4b75db8f979da6d67ba153d068b012394b46 (patch)
treeb888127287d4f1b06d34cd57ec9dba8cf40a62b1 /src/include/utils/typcache.h
parentad50934eaadb626de682defe0ad270bbf31e92a2 (diff)
downloadpostgresql-37ee4b75db8f979da6d67ba153d068b012394b46.tar.gz
postgresql-37ee4b75db8f979da6d67ba153d068b012394b46.zip
Restructure function-internal caching in the range type code.
Move the responsibility for caching specialized information about range types into the type cache, so that the catalog lookups only have to occur once per session. Rearrange APIs a bit so that fn_extra caching is actually effective in the GiST support code. (Use of OidFunctionCallN is bad enough for performance in itself, but it also prevents the function from exploiting fn_extra caching.) The range I/O functions are still not very bright about caching repeated lookups, but that seems like material for a separate patch. Also, avoid unnecessary use of memcpy to fetch/store the range type OID and flags, and don't use the full range_deserialize machinery when all we need to see is the flags value. Also fix API error in range_gist_penalty --- it was failing to set *penalty for any case involving an empty range.
Diffstat (limited to 'src/include/utils/typcache.h')
-rw-r--r--src/include/utils/typcache.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h
index eb93c1d3b54..823b6ae576a 100644
--- a/src/include/utils/typcache.h
+++ b/src/include/utils/typcache.h
@@ -32,6 +32,7 @@ typedef struct TypeCacheEntry
int16 typlen;
bool typbyval;
char typalign;
+ char typstorage;
char typtype;
Oid typrelid;
@@ -71,6 +72,18 @@ typedef struct TypeCacheEntry
*/
TupleDesc tupDesc;
+ /*
+ * Fields computed when TYPECACHE_RANGE_INFO is requested. Zeroes if
+ * not a range type or information hasn't yet been requested. Note that
+ * rng_cmp_proc_finfo could be different from the element type's default
+ * btree comparison function.
+ */
+ struct TypeCacheEntry *rngelemtype; /* range's element type */
+ Oid rng_collation; /* collation for comparisons, if any */
+ FmgrInfo rng_cmp_proc_finfo; /* comparison function */
+ FmgrInfo rng_canonical_finfo; /* canonicalization function, if any */
+ FmgrInfo rng_subdiff_finfo; /* difference function, if any */
+
/* Private data, for internal use of typcache.c only */
int flags; /* flags about what we've computed */
@@ -93,6 +106,7 @@ typedef struct TypeCacheEntry
#define TYPECACHE_TUPDESC 0x0100
#define TYPECACHE_BTREE_OPFAMILY 0x0200
#define TYPECACHE_HASH_OPFAMILY 0x0400
+#define TYPECACHE_RANGE_INFO 0x0800
extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags);