summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2003-08-17 19:58:06 +0000
committerTom Lane2003-08-17 19:58:06 +0000
commitec646dbc65afc8c55118cb3fb75cb6fd18d78dd8 (patch)
treebd256cf157c4636382d59938162326fccc70b62c /src/include
parentd89578ccbefb83aa9f9d1c00269cd866be2cc857 (diff)
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/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_amop.h34
-rw-r--r--src/include/catalog/pg_amproc.h6
-rw-r--r--src/include/catalog/pg_opclass.h6
-rw-r--r--src/include/catalog/pg_operator.h5
-rw-r--r--src/include/catalog/pg_proc.h10
-rw-r--r--src/include/nodes/nodes.h4
-rw-r--r--src/include/nodes/parsenodes.h19
-rw-r--r--src/include/parser/parse_clause.h5
-rw-r--r--src/include/parser/parse_oper.h7
-rw-r--r--src/include/utils/acl.h3
-rw-r--r--src/include/utils/builtins.h4
-rw-r--r--src/include/utils/cash.h1
-rw-r--r--src/include/utils/lsyscache.h3
-rw-r--r--src/include/utils/typcache.h66
15 files changed, 152 insertions, 25 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 48723471a26..9d4f80b727b 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.206 2003/08/04 02:40:10 momjian Exp $
+ * $Id: catversion.h,v 1.207 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200307301
+#define CATALOG_VERSION_NO 200308171
#endif
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index fcf162eb98f..bff4b217003 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -16,7 +16,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_amop.h,v 1.54 2003/08/04 02:40:10 momjian Exp $
+ * $Id: pg_amop.h,v 1.55 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -419,6 +419,36 @@ DATA(insert ( 2098 4 f 2335 ));
DATA(insert ( 2098 5 f 2336 ));
/*
+ * btree money_ops
+ */
+
+DATA(insert ( 2099 1 f 902 ));
+DATA(insert ( 2099 2 f 904 ));
+DATA(insert ( 2099 3 f 900 ));
+DATA(insert ( 2099 4 f 905 ));
+DATA(insert ( 2099 5 f 903 ));
+
+/*
+ * btree reltime_ops
+ */
+
+DATA(insert ( 2233 1 f 568 ));
+DATA(insert ( 2233 2 f 570 ));
+DATA(insert ( 2233 3 f 566 ));
+DATA(insert ( 2233 4 f 569 ));
+DATA(insert ( 2233 5 f 571 ));
+
+/*
+ * btree tinterval_ops
+ */
+
+DATA(insert ( 2234 1 f 813 ));
+DATA(insert ( 2234 2 f 815 ));
+DATA(insert ( 2234 3 f 811 ));
+DATA(insert ( 2234 4 f 814 ));
+DATA(insert ( 2234 5 f 816 ));
+
+/*
* btree array_ops
*/
@@ -496,5 +526,7 @@ DATA(insert ( 2230 1 f 2316 ));
DATA(insert ( 2231 1 f 2328 ));
/* name_pattern_ops */
DATA(insert ( 2232 1 f 2334 ));
+/* aclitem_ops */
+DATA(insert ( 2235 1 f 974 ));
#endif /* PG_AMOP_H */
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index 24c1fa416fe..a2607db5eb8 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -14,7 +14,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_amproc.h,v 1.43 2003/08/04 02:40:11 momjian Exp $
+ * $Id: pg_amproc.h,v 1.44 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -110,6 +110,9 @@ DATA(insert ( 2095 1 2166 ));
DATA(insert ( 2096 1 2166 ));
DATA(insert ( 2097 1 2180 ));
DATA(insert ( 2098 1 2187 ));
+DATA(insert ( 2099 1 377 ));
+DATA(insert ( 2233 1 380 ));
+DATA(insert ( 2234 1 381 ));
/* hash */
@@ -145,5 +148,6 @@ DATA(insert ( 2229 1 456 ));
DATA(insert ( 2230 1 456 ));
DATA(insert ( 2231 1 456 ));
DATA(insert ( 2232 1 455 ));
+DATA(insert ( 2235 1 329 ));
#endif /* PG_AMPROC_H */
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index bbd69dca5b6..af277ad687a 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -26,7 +26,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_opclass.h,v 1.56 2003/08/04 02:40:12 momjian Exp $
+ * $Id: pg_opclass.h,v 1.57 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -157,6 +157,7 @@ DATA(insert OID = 2097 ( 403 bpchar_pattern_ops PGNSP PGUID 1042 f 0 ));
#define BPCHAR_PATTERN_BTREE_OPS_OID 2097
DATA(insert OID = 2098 ( 403 name_pattern_ops PGNSP PGUID 19 f 0 ));
#define NAME_PATTERN_BTREE_OPS_OID 2098
+DATA(insert OID = 2099 ( 403 money_ops PGNSP PGUID 790 t 0 ));
DATA(insert OID = 2222 ( 405 bool_ops PGNSP PGUID 16 t 0 ));
DATA(insert OID = 2223 ( 405 bytea_ops PGNSP PGUID 17 t 0 ));
DATA(insert OID = 2224 ( 405 int2vector_ops PGNSP PGUID 22 t 0 ));
@@ -168,5 +169,8 @@ DATA(insert OID = 2229 ( 405 text_pattern_ops PGNSP PGUID 25 f 0 ));
DATA(insert OID = 2230 ( 405 varchar_pattern_ops PGNSP PGUID 1043 f 0 ));
DATA(insert OID = 2231 ( 405 bpchar_pattern_ops PGNSP PGUID 1042 f 0 ));
DATA(insert OID = 2232 ( 405 name_pattern_ops PGNSP PGUID 19 f 0 ));
+DATA(insert OID = 2233 ( 403 reltime_ops PGNSP PGUID 703 t 0 ));
+DATA(insert OID = 2234 ( 403 tinterval_ops PGNSP PGUID 704 t 0 ));
+DATA(insert OID = 2235 ( 405 aclitem_ops PGNSP PGUID 1033 t 0 ));
#endif /* PG_OPCLASS_H */
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 176cd1eaaf6..991e9429d37 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_operator.h,v 1.120 2003/08/04 02:40:12 momjian Exp $
+ * $Id: pg_operator.h,v 1.121 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -424,7 +424,7 @@ DATA(insert OID = 965 ( "^" PGNSP PGUID b f 701 701 701 0 0 0 0 0 0 dpow -
DATA(insert OID = 966 ( "+" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclinsert - - ));
DATA(insert OID = 967 ( "-" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclremove - - ));
DATA(insert OID = 968 ( "~" PGNSP PGUID b f 1034 1033 16 0 0 0 0 0 0 aclcontains - - ));
-DATA(insert OID = 974 ( "=" PGNSP PGUID b f 1033 1033 16 974 0 0 0 0 0 aclitemeq eqsel eqjoinsel ));
+DATA(insert OID = 974 ( "=" PGNSP PGUID b t 1033 1033 16 974 0 0 0 0 0 aclitemeq eqsel eqjoinsel ));
/* additional geometric operators - thomas 1997-07-09 */
DATA(insert OID = 969 ( "@@" PGNSP PGUID l f 0 601 600 0 0 0 0 0 0 lseg_center - - ));
@@ -448,6 +448,7 @@ DATA(insert OID = 1071 ( "<>" PGNSP PGUID b f 2277 2277 16 1071 1070 0 0 0
DATA(insert OID = 1072 ( "<" PGNSP PGUID b f 2277 2277 16 1073 1075 0 0 0 0 array_lt scalarltsel scalarltjoinsel ));
#define ARRAY_LT_OP 1072
DATA(insert OID = 1073 ( ">" PGNSP PGUID b f 2277 2277 16 1072 1074 0 0 0 0 array_gt scalargtsel scalargtjoinsel ));
+#define ARRAY_GT_OP 1073
DATA(insert OID = 1074 ( "<=" PGNSP PGUID b f 2277 2277 16 1075 1073 0 0 0 0 array_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1075 ( ">=" PGNSP PGUID b f 2277 2277 16 1074 1072 0 0 0 0 array_ge scalargtsel scalargtjoinsel ));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 1fe3812d709..59b957ddd0d 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.312 2003/08/04 02:40:12 momjian Exp $
+ * $Id: pg_proc.h,v 1.313 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -758,6 +758,12 @@ DATA(insert OID = 359 ( btnamecmp PGNSP PGUID 12 f f t f i 2 23 "19 19" btn
DESCR("btree less-equal-greater");
DATA(insert OID = 360 ( bttextcmp PGNSP PGUID 12 f f t f i 2 23 "25 25" bttextcmp - _null_ ));
DESCR("btree less-equal-greater");
+DATA(insert OID = 377 ( cash_cmp PGNSP PGUID 12 f f t f i 2 23 "790 790" cash_cmp - _null_ ));
+DESCR("btree less-equal-greater");
+DATA(insert OID = 380 ( btreltimecmp PGNSP PGUID 12 f f t f i 2 23 "703 703" btreltimecmp - _null_ ));
+DESCR("btree less-equal-greater");
+DATA(insert OID = 381 ( bttintervalcmp PGNSP PGUID 12 f f t f i 2 23 "704 704" bttintervalcmp - _null_ ));
+DESCR("btree less-equal-greater");
DATA(insert OID = 382 ( btarraycmp PGNSP PGUID 12 f f t f i 2 23 "2277 2277" btarraycmp - _null_ ));
DESCR("btree less-equal-greater");
@@ -844,6 +850,8 @@ DATA(insert OID = 456 ( hashvarlena PGNSP PGUID 12 f f t f i 1 23 "2281" has
DESCR("hash any varlena type");
DATA(insert OID = 457 ( hashoidvector PGNSP PGUID 12 f f t f i 1 23 "30" hashoidvector - _null_ ));
DESCR("hash");
+DATA(insert OID = 329 ( hash_aclitem PGNSP PGUID 12 f f t f i 1 23 "1033" hash_aclitem - _null_ ));
+DESCR("hash");
DATA(insert OID = 398 ( hashint2vector PGNSP PGUID 12 f f t f i 1 23 "22" hashint2vector - _null_ ));
DESCR("hash");
DATA(insert OID = 399 ( hashmacaddr PGNSP PGUID 12 f f t f i 1 23 "829" hashmacaddr - _null_ ));
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 9c80a9ebc74..6e3254dc67a 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.146 2003/08/04 02:40:13 momjian Exp $
+ * $Id: nodes.h,v 1.147 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -265,7 +265,7 @@ typedef enum NodeTag
T_ExprFieldSelect,
T_ResTarget,
T_TypeCast,
- T_SortGroupBy,
+ T_SortBy,
T_RangeSubselect,
T_RangeFunction,
T_TypeName,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 497ba3b6247..cbaaee49cf9 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.246 2003/08/08 21:42:48 momjian Exp $
+ * $Id: parsenodes.h,v 1.247 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -279,14 +279,19 @@ typedef struct ResTarget
} ResTarget;
/*
- * SortGroupBy - for ORDER BY clause
+ * SortBy - for ORDER BY clause
*/
-typedef struct SortGroupBy
+#define SORTBY_ASC 1
+#define SORTBY_DESC 2
+#define SORTBY_USING 3
+
+typedef struct SortBy
{
NodeTag type;
- List *useOp; /* operator to use */
- Node *node; /* Expression */
-} SortGroupBy;
+ int sortby_kind; /* see codes above */
+ List *useOp; /* name of op to use, if SORTBY_USING */
+ Node *node; /* expression to sort on */
+} SortBy;
/*
* RangeSubselect - subquery appearing in a FROM clause
@@ -614,7 +619,7 @@ typedef struct SelectStmt
* These fields are used in both "leaf" SelectStmts and upper-level
* SelectStmts.
*/
- List *sortClause; /* sort clause (a list of SortGroupBy's) */
+ List *sortClause; /* sort clause (a list of SortBy's) */
Node *limitOffset; /* # of result tuples to skip */
Node *limitCount; /* # of result tuples to return */
List *forUpdate; /* FOR UPDATE clause */
diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h
index 670b72cfbac..8439c19804c 100644
--- a/src/include/parser/parse_clause.h
+++ b/src/include/parser/parse_clause.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_clause.h,v 1.36 2003/08/07 19:20:23 tgl Exp $
+ * $Id: parse_clause.h,v 1.37 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,7 +37,8 @@ extern List *addAllTargetsToSortList(ParseState *pstate,
bool resolveUnknown);
extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle,
List *sortlist, List *targetlist,
- List *opname, bool resolveUnknown);
+ int sortby_kind, List *sortby_opname,
+ bool resolveUnknown);
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
extern bool targetIsInSortList(TargetEntry *tle, List *sortList);
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index 1167997706a..130f125eff1 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_oper.h,v 1.32 2003/08/04 02:40:14 momjian Exp $
+ * $Id: parse_oper.h,v 1.33 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,15 +38,16 @@ extern Operator compatible_oper(List *op, Oid arg1, Oid arg2, bool noError);
/* currently no need for compatible_left_oper/compatible_right_oper */
-/* Routines for identifying "=" and "<" operators for a type */
+/* Routines for identifying "=", "<", ">" operators for a type */
extern Operator equality_oper(Oid argtype, bool noError);
extern Operator ordering_oper(Oid argtype, bool noError);
+extern Operator reverse_ordering_oper(Oid argtype, bool noError);
/* Convenience routines for common calls on the above */
extern Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError);
extern Oid equality_oper_funcid(Oid argtype);
extern Oid ordering_oper_opid(Oid argtype);
-extern Oid ordering_oper_funcid(Oid argtype);
+extern Oid reverse_ordering_oper_opid(Oid argtype);
/* Extract operator OID or underlying-function OID from an Operator tuple */
extern Oid oprid(Operator op);
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 59b5d106fa6..29a807744ca 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: acl.h,v 1.61 2003/08/08 21:42:55 momjian Exp $
+ * $Id: acl.h,v 1.62 2003/08/17 19:58:06 tgl Exp $
*
* NOTES
* For backward-compatibility purposes we have to allow there
@@ -209,6 +209,7 @@ extern Datum aclremove(PG_FUNCTION_ARGS);
extern Datum aclcontains(PG_FUNCTION_ARGS);
extern Datum makeaclitem(PG_FUNCTION_ARGS);
extern Datum aclitem_eq(PG_FUNCTION_ARGS);
+extern Datum hash_aclitem(PG_FUNCTION_ARGS);
/*
* prototypes for functions in aclchk.c
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index a84f8512256..71615b6610f 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.227 2003/08/08 21:42:55 momjian Exp $
+ * $Id: builtins.h,v 1.228 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -222,6 +222,8 @@ extern Datum btfloat8cmp(PG_FUNCTION_ARGS);
extern Datum btoidcmp(PG_FUNCTION_ARGS);
extern Datum btoidvectorcmp(PG_FUNCTION_ARGS);
extern Datum btabstimecmp(PG_FUNCTION_ARGS);
+extern Datum btreltimecmp(PG_FUNCTION_ARGS);
+extern Datum bttintervalcmp(PG_FUNCTION_ARGS);
extern Datum btcharcmp(PG_FUNCTION_ARGS);
extern Datum btnamecmp(PG_FUNCTION_ARGS);
extern Datum bttextcmp(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h
index 305304c20d2..b78da25edd1 100644
--- a/src/include/utils/cash.h
+++ b/src/include/utils/cash.h
@@ -23,6 +23,7 @@ extern Datum cash_lt(PG_FUNCTION_ARGS);
extern Datum cash_le(PG_FUNCTION_ARGS);
extern Datum cash_gt(PG_FUNCTION_ARGS);
extern Datum cash_ge(PG_FUNCTION_ARGS);
+extern Datum cash_cmp(PG_FUNCTION_ARGS);
extern Datum cash_pl(PG_FUNCTION_ARGS);
extern Datum cash_mi(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index 4c9c073adea..927190e35d9 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lsyscache.h,v 1.80 2003/08/11 23:04:50 tgl Exp $
+ * $Id: lsyscache.h,v 1.81 2003/08/17 19:58:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,6 +28,7 @@ extern bool op_in_opclass(Oid opno, Oid opclass);
extern bool op_requires_recheck(Oid opno, Oid opclass);
extern Oid get_opclass_member(Oid opclass, int16 strategy);
extern Oid get_op_hash_function(Oid opno);
+extern Oid get_opclass_proc(Oid opclass, int16 procnum);
extern char *get_attname(Oid relid, AttrNumber attnum);
extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
extern AttrNumber get_attnum(Oid relid, const char *attname);
diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h
new file mode 100644
index 00000000000..ae080d3feed
--- /dev/null
+++ b/src/include/utils/typcache.h
@@ -0,0 +1,66 @@
+/*-------------------------------------------------------------------------
+ *
+ * typcache.h
+ * Type cache definitions.
+ *
+ * The type cache exists to speed lookup of certain information about data
+ * types that is not directly available from a type's pg_type row.
+ *
+ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: typcache.h,v 1.1 2003/08/17 19:58:06 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TYPCACHE_H
+#define TYPCACHE_H
+
+#include "fmgr.h"
+
+
+typedef struct TypeCacheEntry
+{
+ /* typeId is the hash lookup key and MUST BE FIRST */
+ Oid type_id; /* OID of the data type */
+
+ /* some subsidiary information copied from the pg_type row */
+ int16 typlen;
+ bool typbyval;
+ char typalign;
+
+ /*
+ * Information obtained from opclass entries
+ *
+ * These will be InvalidOid if no match could be found, or if the
+ * information hasn't yet been requested.
+ */
+ Oid btree_opc; /* OID of the default btree opclass */
+ Oid hash_opc; /* OID of the default hash opclass */
+ Oid eq_opr; /* OID of the equality operator */
+ Oid lt_opr; /* OID of the less-than operator */
+ Oid gt_opr; /* OID of the greater-than operator */
+ Oid cmp_proc; /* OID of the btree comparison function */
+
+ /*
+ * Pre-set-up fmgr call info for the equality operator and the btree
+ * comparison function. These are kept in the type cache to avoid
+ * problems with memory leaks in repeated calls to array_eq and array_cmp.
+ * There is not currently a need to maintain call info for the lt_opr
+ * or gt_opr.
+ */
+ FmgrInfo eq_opr_finfo;
+ FmgrInfo cmp_proc_finfo;
+} TypeCacheEntry;
+
+/* Bit flags to indicate which fields a given caller needs to have set */
+#define TYPECACHE_EQ_OPR 0x0001
+#define TYPECACHE_LT_OPR 0x0002
+#define TYPECACHE_GT_OPR 0x0004
+#define TYPECACHE_CMP_PROC 0x0008
+#define TYPECACHE_EQ_OPR_FINFO 0x0010
+#define TYPECACHE_CMP_PROC_FINFO 0x0020
+
+extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags);
+
+#endif /* TYPCACHE_H */