2
* contrib/btree_gist/btree_bytea.c
4
#include "btree_gist.h"
5
#include "btree_utils_var.h"
6
#include "utils/bytea.h"
12
PG_FUNCTION_INFO_V1(gbt_bytea_compress);
13
PG_FUNCTION_INFO_V1(gbt_bytea_union);
14
PG_FUNCTION_INFO_V1(gbt_bytea_picksplit);
15
PG_FUNCTION_INFO_V1(gbt_bytea_consistent);
16
PG_FUNCTION_INFO_V1(gbt_bytea_penalty);
17
PG_FUNCTION_INFO_V1(gbt_bytea_same);
19
Datum gbt_bytea_compress(PG_FUNCTION_ARGS);
20
Datum gbt_bytea_union(PG_FUNCTION_ARGS);
21
Datum gbt_bytea_picksplit(PG_FUNCTION_ARGS);
22
Datum gbt_bytea_consistent(PG_FUNCTION_ARGS);
23
Datum gbt_bytea_penalty(PG_FUNCTION_ARGS);
24
Datum gbt_bytea_same(PG_FUNCTION_ARGS);
27
/* define for comparison */
30
gbt_byteagt(const void *a, const void *b, Oid collation)
32
return DatumGetBool(DirectFunctionCall2(byteagt,
38
gbt_byteage(const void *a, const void *b, Oid collation)
40
return DatumGetBool(DirectFunctionCall2(byteage,
46
gbt_byteaeq(const void *a, const void *b, Oid collation)
48
return DatumGetBool(DirectFunctionCall2(byteaeq,
54
gbt_byteale(const void *a, const void *b, Oid collation)
56
return DatumGetBool(DirectFunctionCall2(byteale,
62
gbt_bytealt(const void *a, const void *b, Oid collation)
64
return DatumGetBool(DirectFunctionCall2(bytealt,
70
gbt_byteacmp(const void *a, const void *b, Oid collation)
72
return DatumGetInt32(DirectFunctionCall2(byteacmp,
78
static const gbtree_vinfo tinfo =
93
/**************************************************
95
**************************************************/
99
gbt_bytea_compress(PG_FUNCTION_ARGS)
101
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
103
PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
109
gbt_bytea_consistent(PG_FUNCTION_ARGS)
111
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
112
void *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
113
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
115
/* Oid subtype = PG_GETARG_OID(3); */
116
bool *recheck = (bool *) PG_GETARG_POINTER(4);
118
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
119
GBT_VARKEY_R r = gbt_var_key_readable(key);
121
/* All cases served by this function are exact */
124
retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
125
GIST_LEAF(entry), &tinfo);
126
PG_RETURN_BOOL(retval);
132
gbt_bytea_union(PG_FUNCTION_ARGS)
134
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
135
int32 *size = (int *) PG_GETARG_POINTER(1);
137
PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
143
gbt_bytea_picksplit(PG_FUNCTION_ARGS)
145
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
146
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
148
gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
150
PG_RETURN_POINTER(v);
154
gbt_bytea_same(PG_FUNCTION_ARGS)
156
Datum d1 = PG_GETARG_DATUM(0);
157
Datum d2 = PG_GETARG_DATUM(1);
158
bool *result = (bool *) PG_GETARG_POINTER(2);
160
*result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
161
PG_RETURN_POINTER(result);
166
gbt_bytea_penalty(PG_FUNCTION_ARGS)
168
GISTENTRY *o = (GISTENTRY *) PG_GETARG_POINTER(0);
169
GISTENTRY *n = (GISTENTRY *) PG_GETARG_POINTER(1);
170
float *result = (float *) PG_GETARG_POINTER(2);
172
PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),