PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 91 of file btree_bytea.c.

92{
94
96}
static const gbtree_vinfo tinfo
Definition: btree_bytea.c:71
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361

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 99 of file btree_bytea.c.

100{
101 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
102 void *query = DatumGetByteaP(PG_GETARG_DATUM(1));
104
105 /* Oid subtype = PG_GETARG_OID(3); */
106 bool *recheck = (bool *) PG_GETARG_POINTER(4);
107 bool retval;
110
111 /* All cases served by this function are exact */
112 *recheck = false;
113
114 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
115 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
116 PG_RETURN_BOOL(retval);
117}
bool gbt_var_consistent(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_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:359
#define DatumGetByteaP(X)
Definition: fmgr.h:331
#define GIST_LEAF(entry)
Definition: gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:317
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
Definition: c.h:658

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

◆ gbt_bytea_penalty()

Datum gbt_bytea_penalty ( PG_FUNCTION_ARGS  )

Definition at line 152 of file btree_bytea.c.

153{
156 float *result = (float *) PG_GETARG_POINTER(2);
157
159 &tinfo, fcinfo->flinfo));
160}
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

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

◆ gbt_bytea_picksplit()

Datum gbt_bytea_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 130 of file btree_bytea.c.

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

References 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 141 of file btree_bytea.c.

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

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

◆ gbt_bytea_sortsupport()

Datum gbt_bytea_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 184 of file btree_bytea.c.

185{
187
189 ssup->ssup_extra = NULL;
190
192}
static int gbt_bytea_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_bytea.c:163
#define PG_RETURN_VOID()
Definition: fmgr.h:349
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106
void * ssup_extra
Definition: sortsupport.h:87

References SortSupportData::comparator, 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 163 of file btree_bytea.c.

164{
167
170 Datum result;
171
172 /* for leaf items we expect lower == upper, so only compare lower */
175 PointerGetDatum(ykey.lower));
176
177 GBT_FREE_IF_COPY(key1, x);
178 GBT_FREE_IF_COPY(key2, y);
179
180 return DatumGetInt32(result);
181}
#define GBT_FREE_IF_COPY(ptr1, ptr2)
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:684
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
int y
Definition: isn.c:76
int x
Definition: isn.c:75
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:327
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207
Datum byteacmp(PG_FUNCTION_ARGS)
Definition: varlena.c:4006

References byteacmp(), DatumGetInt32(), DirectFunctionCall2, GBT_FREE_IF_COPY, gbt_var_key_readable(), GBT_VARKEY_R::lower, PG_DETOAST_DATUM, PointerGetDatum(), x, and y.

Referenced by gbt_bytea_sortsupport().

◆ gbt_bytea_union()

Datum gbt_bytea_union ( PG_FUNCTION_ARGS  )

Definition at line 120 of file btree_bytea.c.

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

References 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 64 of file btree_bytea.c.

65{
69}
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 40 of file btree_bytea.c.

41{
45}
static bool DatumGetBool(Datum X)
Definition: postgres.h:95
Datum byteaeq(PG_FUNCTION_ARGS)
Definition: varlena.c:3862

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 32 of file btree_bytea.c.

33{
37}
Datum byteage(PG_FUNCTION_ARGS)
Definition: varlena.c:3986

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 24 of file btree_bytea.c.

25{
29}
Datum byteagt(PG_FUNCTION_ARGS)
Definition: varlena.c:3966

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 48 of file btree_bytea.c.

49{
53}
Datum byteale(PG_FUNCTION_ARGS)
Definition: varlena.c:3946

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 56 of file btree_bytea.c.

57{
61}
Datum bytealt(PG_FUNCTION_ARGS)
Definition: varlena.c:3926

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:
=
{
0,
true,
NULL
}
static bool gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_bytea.c:24
static bool gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_bytea.c:32
static bool gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_bytea.c:40
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
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

Definition at line 71 of file btree_bytea.c.

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