PostgreSQL Source Code git master
Loading...
Searching...
No Matches
btree_bytea.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_var.h"
#include "utils/fmgrprotos.h"
#include "utils/sortsupport.h"
Include dependency graph for btree_bytea.c:

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (gbt_bytea_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_union)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_same)
 
 PG_FUNCTION_INFO_V1 (gbt_bytea_sortsupport)
 
static bool gbt_byteagt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_byteage (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_byteaeq (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_byteale (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_bytealt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static int32 gbt_byteacmp (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
Datum gbt_bytea_compress (PG_FUNCTION_ARGS)
 
Datum gbt_bytea_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_bytea_union (PG_FUNCTION_ARGS)
 
Datum gbt_bytea_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_bytea_same (PG_FUNCTION_ARGS)
 
Datum gbt_bytea_penalty (PG_FUNCTION_ARGS)
 
static int gbt_bytea_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_bytea_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_vinfo tinfo
 

Function Documentation

◆ gbt_bytea_compress()

Datum gbt_bytea_compress ( PG_FUNCTION_ARGS  )

Definition at line 92 of file btree_bytea.c.

93{
95
97}
static const gbtree_vinfo tinfo
Definition btree_bytea.c:73
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363

References gbt_var_compress(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_bytea_consistent()

Datum gbt_bytea_consistent ( PG_FUNCTION_ARGS  )

Definition at line 100 of file btree_bytea.c.

101{
102 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
103 void *query = DatumGetByteaP(PG_GETARG_DATUM(1));
105#ifdef NOT_USED
106 Oid subtype = PG_GETARG_OID(3);
107#endif
108 bool *recheck = (bool *) PG_GETARG_POINTER(4);
109 bool retval;
112
113 /* All cases served by this function are exact */
114 *recheck = false;
115
116 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
117 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
118 PG_RETURN_BOOL(retval);
119}
bool gbt_var_consistent(const GBT_VARKEY_R *key, const void *query, StrategyNumber strategy, Oid collation, bool is_leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k)
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_GETARG_DATUM(n)
Definition fmgr.h:268
#define PG_GETARG_UINT16(n)
Definition fmgr.h:272
#define PG_GET_COLLATION()
Definition fmgr.h:198
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define DatumGetByteaP(X)
Definition fmgr.h:332
#define GIST_LEAF(entry)
Definition gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
unsigned int Oid
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161
Definition c.h:835

References DatumGetByteaP, DatumGetPointer(), gbt_var_consistent(), gbt_var_key_readable(), GIST_LEAF, GISTENTRY::key, PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and tinfo.

◆ gbt_bytea_penalty()

Datum gbt_bytea_penalty ( PG_FUNCTION_ARGS  )

Definition at line 154 of file btree_bytea.c.

155{
158 float *result = (float *) PG_GETARG_POINTER(2);
159
161 &tinfo, fcinfo->flinfo));
162}
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
uint32 result
static int fb(int x)

References fb(), gbt_var_penalty(), PG_GET_COLLATION, PG_GETARG_POINTER, PG_RETURN_POINTER, result, and tinfo.

◆ gbt_bytea_picksplit()

Datum gbt_bytea_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 132 of file btree_bytea.c.

133{
136
138 &tinfo, fcinfo->flinfo);
140}
GIST_SPLITVEC * gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

References fb(), gbt_var_picksplit(), PG_GET_COLLATION, PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_bytea_same()

Datum gbt_bytea_same ( PG_FUNCTION_ARGS  )

Definition at line 143 of file btree_bytea.c.

144{
145 Datum d1 = PG_GETARG_DATUM(0);
146 Datum d2 = PG_GETARG_DATUM(1);
147 bool *result = (bool *) PG_GETARG_POINTER(2);
148
149 *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
151}
bool gbt_var_same(Datum d1, Datum d2, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
uint64_t Datum
Definition postgres.h:70

References gbt_var_same(), PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, result, and tinfo.

◆ gbt_bytea_sortsupport()

Datum gbt_bytea_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 186 of file btree_bytea.c.

187{
189
191 ssup->ssup_extra = NULL;
192
194}
static int gbt_bytea_ssup_cmp(Datum x, Datum y, SortSupport ssup)
struct SortSupportData * SortSupport
Definition execnodes.h:61
#define PG_RETURN_VOID()
Definition fmgr.h:350
int(* comparator)(Datum x, Datum y, SortSupport ssup)

References SortSupportData::comparator, fb(), gbt_bytea_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_bytea_ssup_cmp()

static int gbt_bytea_ssup_cmp ( Datum  x,
Datum  y,
SortSupport  ssup 
)
static

Definition at line 165 of file btree_bytea.c.

166{
169
173
174 /* for leaf items we expect lower == upper, so only compare lower */
176 PointerGetDatum(xkey.lower),
177 PointerGetDatum(ykey.lower));
178
181
182 return DatumGetInt32(result);
183}
#define GBT_FREE_IF_COPY(ptr1, ptr2)
Datum byteacmp(PG_FUNCTION_ARGS)
Definition bytea.c:959
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:690
#define PG_DETOAST_DATUM(datum)
Definition fmgr.h:240
int y
Definition isn.c:76
int x
Definition isn.c:75
static int32 DatumGetInt32(Datum X)
Definition postgres.h:202
#define PointerGetDatum(X)
Definition postgres.h:354

References byteacmp(), DatumGetInt32(), DirectFunctionCall2, fb(), GBT_FREE_IF_COPY, gbt_var_key_readable(), PG_DETOAST_DATUM, PointerGetDatum, result, x, and y.

Referenced by gbt_bytea_sortsupport().

◆ gbt_bytea_union()

Datum gbt_bytea_union ( PG_FUNCTION_ARGS  )

Definition at line 122 of file btree_bytea.c.

123{
125 int32 *size = (int *) PG_GETARG_POINTER(1);
126
128 &tinfo, fcinfo->flinfo));
129}
GBT_VARKEY * gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
int32_t int32
Definition c.h:679

References fb(), gbt_var_union(), PG_GET_COLLATION, PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_byteacmp()

static int32 gbt_byteacmp ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 66 of file btree_bytea.c.

67{
71}
int b
Definition isn.c:74
int a
Definition isn.c:73

References a, b, byteacmp(), DatumGetInt32(), DirectFunctionCall2, and PointerGetDatum.

◆ gbt_byteaeq()

static bool gbt_byteaeq ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 42 of file btree_bytea.c.

43{
47}
Datum byteaeq(PG_FUNCTION_ARGS)
Definition bytea.c:815
static bool DatumGetBool(Datum X)
Definition postgres.h:100

References a, b, byteaeq(), DatumGetBool(), DirectFunctionCall2, and PointerGetDatum.

◆ gbt_byteage()

static bool gbt_byteage ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 34 of file btree_bytea.c.

35{
39}
Datum byteage(PG_FUNCTION_ARGS)
Definition bytea.c:939

References a, b, byteage(), DatumGetBool(), DirectFunctionCall2, and PointerGetDatum.

◆ gbt_byteagt()

static bool gbt_byteagt ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 26 of file btree_bytea.c.

27{
31}
Datum byteagt(PG_FUNCTION_ARGS)
Definition bytea.c:919

References a, b, byteagt(), DatumGetBool(), DirectFunctionCall2, and PointerGetDatum.

◆ gbt_byteale()

static bool gbt_byteale ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 50 of file btree_bytea.c.

51{
55}
Datum byteale(PG_FUNCTION_ARGS)
Definition bytea.c:899

References a, b, byteale(), DatumGetBool(), DirectFunctionCall2, and PointerGetDatum.

◆ gbt_bytealt()

static bool gbt_bytealt ( const void a,
const void b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 58 of file btree_bytea.c.

59{
63}
Datum bytealt(PG_FUNCTION_ARGS)
Definition bytea.c:879

References a, b, bytealt(), DatumGetBool(), DirectFunctionCall2, and PointerGetDatum.

◆ PG_FUNCTION_INFO_V1() [1/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_compress  )

◆ PG_FUNCTION_INFO_V1() [2/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_penalty  )

◆ PG_FUNCTION_INFO_V1() [4/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_picksplit  )

◆ PG_FUNCTION_INFO_V1() [5/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_same  )

◆ PG_FUNCTION_INFO_V1() [6/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [7/7]

PG_FUNCTION_INFO_V1 ( gbt_bytea_union  )

Variable Documentation

◆ tinfo

const gbtree_vinfo tinfo
static
Initial value:
=
{
true,
}
static bool gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:26
static bool gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:34
static bool gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:42
static int32 gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:66
static bool gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:50
static bool gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_bytea.c:58
@ gbt_t_bytea
Definition btree_gist.h:33

Definition at line 73 of file btree_bytea.c.

74{
76 true, /* internal keys can be truncated */
83 NULL
84};

Referenced by gbt_bytea_compress(), gbt_bytea_consistent(), gbt_bytea_penalty(), gbt_bytea_picksplit(), gbt_bytea_same(), and gbt_bytea_union().