PostgreSQL Source Code git master
Loading...
Searching...
No Matches
btree_bytea.c
Go to the documentation of this file.
1/*
2 * contrib/btree_gist/btree_bytea.c
3 */
4#include "postgres.h"
5
6#include "btree_gist.h"
7#include "btree_utils_var.h"
8#include "utils/fmgrprotos.h"
9#include "utils/sortsupport.h"
10
11/* GiST support functions */
19
20
21/* define for comparison */
22
23static bool
24gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
25{
29}
30
31static bool
32gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
33{
37}
38
39static bool
40gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
41{
45}
46
47static bool
48gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
49{
53}
54
55static bool
56gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
57{
61}
62
63static int32
64gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
65{
69}
70
71static const gbtree_vinfo tinfo =
72{
74 0,
75 true,
82 NULL
83};
84
85
86/**************************************************
87 * GiST support functions
88 **************************************************/
89
97
100{
101 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
102 void *query = DatumGetByteaP(PG_GETARG_DATUM(1));
104#ifdef NOT_USED
105 Oid subtype = PG_GETARG_OID(3);
106#endif
107 bool *recheck = (bool *) PG_GETARG_POINTER(4);
108 bool retval;
109 GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
111
112 /* All cases served by this function are exact */
113 *recheck = false;
114
115 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
116 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
117 PG_RETURN_BOOL(retval);
118}
119
120Datum
129
130Datum
140
141Datum
143{
144 Datum d1 = PG_GETARG_DATUM(0);
145 Datum d2 = PG_GETARG_DATUM(1);
146 bool *result = (bool *) PG_GETARG_POINTER(2);
147
148 *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
149 PG_RETURN_POINTER(result);
150}
151
152Datum
154{
157 float *result = (float *) PG_GETARG_POINTER(2);
158
160 &tinfo, fcinfo->flinfo));
161}
162
163static int
165{
168
171 Datum result;
172
173 /* for leaf items we expect lower == upper, so only compare lower */
175 PointerGetDatum(xkey.lower),
176 PointerGetDatum(ykey.lower));
177
180
181 return DatumGetInt32(result);
182}
183
184Datum
static bool gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:24
Datum gbt_bytea_sortsupport(PG_FUNCTION_ARGS)
static bool gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:32
Datum gbt_bytea_consistent(PG_FUNCTION_ARGS)
Definition btree_bytea.c:99
Datum gbt_bytea_compress(PG_FUNCTION_ARGS)
Definition btree_bytea.c:91
Datum gbt_bytea_union(PG_FUNCTION_ARGS)
Datum gbt_bytea_penalty(PG_FUNCTION_ARGS)
static const gbtree_vinfo tinfo
Definition btree_bytea.c:71
static bool gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:40
static int gbt_bytea_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Datum gbt_bytea_same(PG_FUNCTION_ARGS)
static int32 gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:64
static bool gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:48
Datum gbt_bytea_picksplit(PG_FUNCTION_ARGS)
static bool gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:56
@ gbt_t_bytea
Definition btree_gist.h:33
GBT_VARKEY * gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query, StrategyNumber strategy, Oid collation, bool is_leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
GIST_SPLITVEC * gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k)
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
bool gbt_var_same(Datum d1, Datum d2, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
#define GBT_FREE_IF_COPY(ptr1, ptr2)
Datum byteaeq(PG_FUNCTION_ARGS)
Definition bytea.c:815
Datum byteagt(PG_FUNCTION_ARGS)
Definition bytea.c:919
Datum byteage(PG_FUNCTION_ARGS)
Definition bytea.c:939
Datum byteacmp(PG_FUNCTION_ARGS)
Definition bytea.c:959
Datum byteale(PG_FUNCTION_ARGS)
Definition bytea.c:899
Datum bytealt(PG_FUNCTION_ARGS)
Definition bytea.c:879
int32_t int32
Definition c.h:542
#define PG_RETURN_VOID()
Definition fmgr.h:350
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:686
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_GETARG_DATUM(n)
Definition fmgr.h:268
#define PG_FUNCTION_INFO_V1(funcname)
Definition fmgr.h:417
#define PG_GETARG_UINT16(n)
Definition fmgr.h:272
#define PG_DETOAST_DATUM(datum)
Definition fmgr.h:240
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363
#define PG_GET_COLLATION()
Definition fmgr.h:198
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define DatumGetByteaP(X)
Definition fmgr.h:332
#define GIST_LEAF(entry)
Definition gist.h:171
int y
Definition isn.c:76
int b
Definition isn.c:74
int x
Definition isn.c:75
int a
Definition isn.c:73
static bool DatumGetBool(Datum X)
Definition postgres.h:100
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
uint64_t Datum
Definition postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
static int32 DatumGetInt32(Datum X)
Definition postgres.h:212
unsigned int Oid
static int fb(int x)
struct SortSupportData * SortSupport
Definition sortsupport.h:58
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition c.h:706