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 "access/gist.h"
10 #include "mb/pg_wchar.h"
11 
12 /* Variable length key */
13 typedef bytea GBT_VARKEY;
14 
15 /* Better readable key */
16 typedef struct
17 {
18 	bytea	   *lower,
19 			   *upper;
20 } GBT_VARKEY_R;
21 
22 /*
23  * type description
24  */
25 typedef struct
26 {
27 
28 	/* Attribs */
29 
30 	enum gbtree_type t;			/* data type */
31 	int32		eml;			/* cached pg_database_encoding_max_length (0:
32 								 * undefined) */
33 	bool		trnc;			/* truncate (=compress) key */
34 
35 	/* Methods */
36 
37 	bool		(*f_gt) (const void *, const void *, Oid, FmgrInfo *);	/* greater than */
38 	bool		(*f_ge) (const void *, const void *, Oid, FmgrInfo *);	/* greater equal */
39 	bool		(*f_eq) (const void *, const void *, Oid, FmgrInfo *);	/* equal */
40 	bool		(*f_le) (const void *, const void *, Oid, FmgrInfo *);	/* less equal */
41 	bool		(*f_lt) (const void *, const void *, Oid, FmgrInfo *);	/* less than */
42 	int32		(*f_cmp) (const void *, const void *, Oid, FmgrInfo *); /* compare */
43 	GBT_VARKEY *(*f_l2n) (GBT_VARKEY *, FmgrInfo *flinfo);	/* convert leaf to node */
44 } gbtree_vinfo;
45 
46 
47 
48 extern GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k);
49 
50 extern GBT_VARKEY *gbt_var_key_copy(const GBT_VARKEY_R *u);
51 
52 extern GISTENTRY *gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo);
53 
54 extern GBT_VARKEY *gbt_var_union(const GistEntryVector *entryvec, int32 *size,
55 			  Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
56 
57 extern bool gbt_var_same(Datum d1, Datum d2, Oid collation,
58 			 const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
59 
60 extern float *gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
61 				Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
62 
63 extern bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query,
64 				   StrategyNumber strategy, Oid collation, bool is_leaf,
65 				   const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
66 
67 extern GIST_SPLITVEC *gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
68 				  Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
69 
70 extern void gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
71 				  const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
72 
73 #endif
74