]> granicus.if.org Git - postgresql/blob - contrib/btree_gist/btree_utils_var.h
Convert contrib modules to use the extension facility.
[postgresql] / contrib / btree_gist / btree_utils_var.h
1 /*
2  * contrib/btree_gist/btree_utils_var.h
3  */
4 #ifndef __BTREE_UTILS_VAR_H__
5 #define __BTREE_UTILS_VAR_H__
6
7 #include "btree_gist.h"
8
9 #include "mb/pg_wchar.h"
10
11 /* Variable length key */
12 typedef bytea GBT_VARKEY;
13
14 /* Better readable key */
15 typedef struct
16 {
17         bytea      *lower,
18                            *upper;
19 } GBT_VARKEY_R;
20
21 /* used for key sorting */
22 typedef struct
23 {
24         int                     i;
25         GBT_VARKEY *t;
26 } Vsrt;
27
28 /*
29   type description
30 */
31
32
33 typedef struct
34 {
35
36         /* Attribs */
37
38         enum gbtree_type t;                     /* data type */
39         int32           eml;                    /* cached pg_database_encoding_max_length (0:
40                                                                  * undefined) */
41         bool            trnc;                   /* truncate (=compress) key */
42
43         /* Methods */
44
45         bool            (*f_gt) (const void *, const void *);   /* greater then */
46         bool            (*f_ge) (const void *, const void *);   /* greater equal */
47         bool            (*f_eq) (const void *, const void *);   /* equal */
48         bool            (*f_le) (const void *, const void *);   /* less equal */
49         bool            (*f_lt) (const void *, const void *);   /* less then */
50         int32           (*f_cmp) (const bytea *, const bytea *);                /* node compare */
51         GBT_VARKEY *(*f_l2n) (GBT_VARKEY *);            /* convert leaf to node */
52 } gbtree_vinfo;
53
54
55
56 extern GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k);
57
58 extern GBT_VARKEY *gbt_var_key_copy(const GBT_VARKEY_R *u, bool force_node);
59
60 extern GISTENTRY *gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo);
61
62 extern GBT_VARKEY *gbt_var_union(const GistEntryVector *entryvec, int32 *size,
63                           const gbtree_vinfo *tinfo);
64
65 extern bool gbt_var_same(bool *result, const Datum d1, const Datum d2,
66                          const gbtree_vinfo *tinfo);
67
68 extern float *gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
69                                 const gbtree_vinfo *tinfo);
70
71 extern bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query,
72                                    const StrategyNumber *strategy, bool is_leaf,
73                                    const gbtree_vinfo *tinfo);
74
75 extern GIST_SPLITVEC *gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
76                                   const gbtree_vinfo *tinfo);
77 extern void gbt_var_bin_union(Datum *u, GBT_VARKEY *e,
78                                   const gbtree_vinfo *tinfo);
79
80 #endif