1 #include "btree_gist.h"
2 #include "btree_utils_num.h"
13 PG_FUNCTION_INFO_V1(gbt_oid_compress);
14 PG_FUNCTION_INFO_V1(gbt_oid_union);
15 PG_FUNCTION_INFO_V1(gbt_oid_picksplit);
16 PG_FUNCTION_INFO_V1(gbt_oid_consistent);
17 PG_FUNCTION_INFO_V1(gbt_oid_penalty);
18 PG_FUNCTION_INFO_V1(gbt_oid_same);
20 Datum gbt_oid_compress(PG_FUNCTION_ARGS);
21 Datum gbt_oid_union(PG_FUNCTION_ARGS);
22 Datum gbt_oid_picksplit(PG_FUNCTION_ARGS);
23 Datum gbt_oid_consistent(PG_FUNCTION_ARGS);
24 Datum gbt_oid_penalty(PG_FUNCTION_ARGS);
25 Datum gbt_oid_same(PG_FUNCTION_ARGS);
29 gbt_oidgt(const void *a, const void *b)
31 return (*((Oid *) a) > *((Oid *) b));
34 gbt_oidge(const void *a, const void *b)
36 return (*((Oid *) a) >= *((Oid *) b));
39 gbt_oideq(const void *a, const void *b)
41 return (*((Oid *) a) == *((Oid *) b));
44 gbt_oidle(const void *a, const void *b)
46 return (*((Oid *) a) <= *((Oid *) b));
49 gbt_oidlt(const void *a, const void *b)
51 return (*((Oid *) a) < *((Oid *) b));
55 gbt_oidkey_cmp(const void *a, const void *b)
58 if (*(Oid *) &(((Nsrt *) a)->t[0]) > *(Oid *) &(((Nsrt *) b)->t[0]))
60 else if (*(Oid *) &(((Nsrt *) a)->t[0]) < *(Oid *) &(((Nsrt *) b)->t[0]))
67 static const gbtree_ninfo tinfo =
80 /**************************************************
82 **************************************************/
86 gbt_oid_compress(PG_FUNCTION_ARGS)
88 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
89 GISTENTRY *retval = NULL;
91 PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
96 gbt_oid_consistent(PG_FUNCTION_ARGS)
98 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
99 Oid query = PG_GETARG_OID(1);
100 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
101 /* Oid subtype = PG_GETARG_OID(3); */
102 bool *recheck = (bool *) PG_GETARG_POINTER(4);
103 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
106 /* All cases served by this function are exact */
109 key.lower = (GBT_NUMKEY *) & kkk->lower;
110 key.upper = (GBT_NUMKEY *) & kkk->upper;
113 gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
119 gbt_oid_union(PG_FUNCTION_ARGS)
121 GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
122 void *out = palloc(sizeof(oidKEY));
124 *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY);
125 PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
130 gbt_oid_penalty(PG_FUNCTION_ARGS)
132 oidKEY *origentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
133 oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
134 float *result = (float *) PG_GETARG_POINTER(2);
136 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
138 PG_RETURN_POINTER(result);
142 gbt_oid_picksplit(PG_FUNCTION_ARGS)
144 PG_RETURN_POINTER(gbt_num_picksplit(
145 (GistEntryVector *) PG_GETARG_POINTER(0),
146 (GIST_SPLITVEC *) PG_GETARG_POINTER(1),
152 gbt_oid_same(PG_FUNCTION_ARGS)
154 oidKEY *b1 = (oidKEY *) PG_GETARG_POINTER(0);
155 oidKEY *b2 = (oidKEY *) PG_GETARG_POINTER(1);
156 bool *result = (bool *) PG_GETARG_POINTER(2);
158 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
159 PG_RETURN_POINTER(result);