~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/utils/typcache.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * typcache.h
 
4
 *        Type cache definitions.
 
5
 *
 
6
 * The type cache exists to speed lookup of certain information about data
 
7
 * types that is not directly available from a type's pg_type row.
 
8
 *
 
9
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
10
 * Portions Copyright (c) 1994, Regents of the University of California
 
11
 *
 
12
 * $PostgreSQL$
 
13
 *
 
14
 *-------------------------------------------------------------------------
 
15
 */
 
16
#ifndef TYPCACHE_H
 
17
#define TYPCACHE_H
 
18
 
 
19
#include "access/tupdesc.h"
 
20
#include "fmgr.h"
 
21
 
 
22
 
 
23
typedef struct TypeCacheEntry
 
24
{
 
25
        /* typeId is the hash lookup key and MUST BE FIRST */
 
26
        Oid                     type_id;                /* OID of the data type */
 
27
 
 
28
        /* some subsidiary information copied from the pg_type row */
 
29
        int16           typlen;
 
30
        bool            typbyval;
 
31
        char            typalign;
 
32
        char            typtype;
 
33
        Oid                     typrelid;
 
34
 
 
35
        /*
 
36
         * Information obtained from opfamily entries
 
37
         *
 
38
         * These will be InvalidOid if no match could be found, or if the
 
39
         * information hasn't yet been requested.
 
40
         */
 
41
        Oid                     btree_opf;              /* the default btree opclass' family */
 
42
        Oid                     btree_opintype; /* the default btree opclass' opcintype */
 
43
        Oid                     hash_opf;               /* the default hash opclass' family */
 
44
        Oid                     hash_opintype;  /* the default hash opclass' opcintype */
 
45
        Oid                     eq_opr;                 /* the equality operator */
 
46
        Oid                     lt_opr;                 /* the less-than operator */
 
47
        Oid                     gt_opr;                 /* the greater-than operator */
 
48
        Oid                     cmp_proc;               /* the btree comparison function */
 
49
 
 
50
        /*
 
51
         * Pre-set-up fmgr call info for the equality operator and the btree
 
52
         * comparison function.  These are kept in the type cache to avoid
 
53
         * problems with memory leaks in repeated calls to array_eq and array_cmp.
 
54
         * There is not currently a need to maintain call info for the lt_opr or
 
55
         * gt_opr.
 
56
         */
 
57
        FmgrInfo        eq_opr_finfo;
 
58
        FmgrInfo        cmp_proc_finfo;
 
59
 
 
60
        /*
 
61
         * Tuple descriptor if it's a composite type (row type).  NULL if not
 
62
         * composite or information hasn't yet been requested.  (NOTE: this is a
 
63
         * reference-counted tupledesc.)
 
64
         */
 
65
        TupleDesc       tupDesc;
 
66
} TypeCacheEntry;
 
67
 
 
68
/* Bit flags to indicate which fields a given caller needs to have set */
 
69
#define TYPECACHE_EQ_OPR                        0x0001
 
70
#define TYPECACHE_LT_OPR                        0x0002
 
71
#define TYPECACHE_GT_OPR                        0x0004
 
72
#define TYPECACHE_CMP_PROC                      0x0008
 
73
#define TYPECACHE_EQ_OPR_FINFO          0x0010
 
74
#define TYPECACHE_CMP_PROC_FINFO        0x0020
 
75
#define TYPECACHE_TUPDESC                       0x0040
 
76
#define TYPECACHE_BTREE_OPFAMILY        0x0080
 
77
 
 
78
extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags);
 
79
 
 
80
extern TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod);
 
81
 
 
82
extern TupleDesc lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod,
 
83
                                                           bool noError);
 
84
 
 
85
extern TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod);
 
86
 
 
87
extern void assign_record_type_typmod(TupleDesc tupDesc);
 
88
 
 
89
extern void flush_rowtype_cache(Oid type_id);
 
90
 
 
91
#endif   /* TYPCACHE_H */