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

Go to the source code of this file.

Data Structures

struct  boolkey
 

Typedefs

typedef struct boolkey boolKEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_bool_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_union)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_same)
 
 PG_FUNCTION_INFO_V1 (gbt_bool_sortsupport)
 
static bool gbt_boolgt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_boolge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_booleq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_boolle (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_boollt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_boolkey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
Datum gbt_bool_compress (PG_FUNCTION_ARGS)
 
Datum gbt_bool_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_bool_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_bool_union (PG_FUNCTION_ARGS)
 
Datum gbt_bool_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_bool_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_bool_same (PG_FUNCTION_ARGS)
 
static int gbt_bool_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_bool_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Typedef Documentation

◆ boolKEY

Function Documentation

◆ gbt_bool_compress()

Datum gbt_bool_compress ( PG_FUNCTION_ARGS  )

Definition at line 90 of file btree_bool.c.

91{
93
95}
static const gbtree_ninfo tinfo
Definition btree_bool.c:71
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363

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

◆ gbt_bool_consistent()

Datum gbt_bool_consistent ( PG_FUNCTION_ARGS  )

Definition at line 106 of file btree_bool.c.

107{
108 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
109 bool query = PG_GETARG_INT16(1);
111#ifdef NOT_USED
112 Oid subtype = PG_GETARG_OID(3);
113#endif
114 bool *recheck = (bool *) PG_GETARG_POINTER(4);
115 boolKEY *kkk = (boolKEY *) DatumGetPointer(entry->key);
117
118 /* All cases served by this function are exact */
119 *recheck = false;
120
121 key.lower = (GBT_NUMKEY *) &kkk->lower;
122 key.upper = (GBT_NUMKEY *) &kkk->upper;
123
124 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
125 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
126}
bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
char GBT_NUMKEY
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_GETARG_UINT16(n)
Definition fmgr.h:272
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define PG_GETARG_INT16(n)
Definition fmgr.h:271
#define GIST_LEAF(entry)
Definition gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
unsigned int Oid
static int fb(int x)
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161

References DatumGetPointer(), fb(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and tinfo.

◆ gbt_bool_fetch()

Datum gbt_bool_fetch ( PG_FUNCTION_ARGS  )

Definition at line 98 of file btree_bool.c.

99{
100 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
101
103}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

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

◆ gbt_bool_penalty()

Datum gbt_bool_penalty ( PG_FUNCTION_ARGS  )

Definition at line 139 of file btree_bool.c.

140{
143 float *result = (float *) PG_GETARG_POINTER(2);
144
145 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
146
147 PG_RETURN_POINTER(result);
148}
#define penalty_num(result, olower, oupper, nlower, nupper)

References DatumGetPointer(), fb(), penalty_num, PG_GETARG_POINTER, and PG_RETURN_POINTER.

◆ gbt_bool_picksplit()

Datum gbt_bool_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 151 of file btree_bool.c.

152{
155 &tinfo, fcinfo->flinfo));
156}
GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

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

◆ gbt_bool_same()

Datum gbt_bool_same ( PG_FUNCTION_ARGS  )

Definition at line 159 of file btree_bool.c.

160{
163 bool *result = (bool *) PG_GETARG_POINTER(2);
164
165 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
166 PG_RETURN_POINTER(result);
167}
bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References fb(), gbt_num_same(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_bool_sortsupport()

Datum gbt_bool_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 180 of file btree_bool.c.

181{
183
185 ssup->ssup_extra = NULL;
186
188}
static int gbt_bool_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition btree_bool.c:170
#define PG_RETURN_VOID()
Definition fmgr.h:350
struct SortSupportData * SortSupport
Definition sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)

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

◆ gbt_bool_ssup_cmp()

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

Definition at line 170 of file btree_bool.c.

171{
174
175 /* for leaf items we expect lower == upper, so only compare lower */
176 return (int32) arg1->lower - (int32) arg2->lower;
177}
int32_t int32
Definition c.h:542
int y
Definition isn.c:76
int x
Definition isn.c:75
bool lower
Definition btree_bool.c:13

References DatumGetPointer(), fb(), boolkey::lower, x, and y.

Referenced by gbt_bool_sortsupport().

◆ gbt_bool_union()

Datum gbt_bool_union ( PG_FUNCTION_ARGS  )

Definition at line 129 of file btree_bool.c.

130{
132 void *out = palloc(sizeof(boolKEY));
133
134 *(int *) PG_GETARG_POINTER(1) = sizeof(boolKEY);
135 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
136}
struct boolkey boolKEY
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
void * palloc(Size size)
Definition mcxt.c:1387

References fb(), gbt_num_union(), palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_booleq()

static bool gbt_booleq ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 38 of file btree_bool.c.

39{
40 return (*((const bool *) a) == *((const bool *) b));
41}
int b
Definition isn.c:74
int a
Definition isn.c:73

References a, and b.

◆ gbt_boolge()

static bool gbt_boolge ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 33 of file btree_bool.c.

34{
35 return (*((const bool *) a) >= *((const bool *) b));
36}

References a, and b.

◆ gbt_boolgt()

static bool gbt_boolgt ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 28 of file btree_bool.c.

29{
30 return (*((const bool *) a) > *((const bool *) b));
31}

References a, and b.

◆ gbt_boolkey_cmp()

static int gbt_boolkey_cmp ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 54 of file btree_bool.c.

55{
56 boolKEY *ia = (boolKEY *) (((const Nsrt *) a)->t);
57 boolKEY *ib = (boolKEY *) (((const Nsrt *) b)->t);
58
59 if (ia->lower == ib->lower)
60 {
61 if (ia->upper == ib->upper)
62 return 0;
63
64 return (ia->upper > ib->upper) ? 1 : -1;
65 }
66
67 return (ia->lower > ib->lower) ? 1 : -1;
68}

References a, b, and fb().

◆ gbt_boolle()

static bool gbt_boolle ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 43 of file btree_bool.c.

44{
45 return (*((const bool *) a) <= *((const bool *) b));
46}

References a, and b.

◆ gbt_boollt()

static bool gbt_boollt ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 48 of file btree_bool.c.

49{
50 return (*((const bool *) a) < *((const bool *) b));
51}

References a, and b.

◆ PG_FUNCTION_INFO_V1() [1/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_compress  )

◆ PG_FUNCTION_INFO_V1() [2/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_fetch  )

◆ PG_FUNCTION_INFO_V1() [4/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_penalty  )

◆ PG_FUNCTION_INFO_V1() [5/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_picksplit  )

◆ PG_FUNCTION_INFO_V1() [6/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_same  )

◆ PG_FUNCTION_INFO_V1() [7/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [8/8]

PG_FUNCTION_INFO_V1 ( gbt_bool_union  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(bool),
2,
}
static bool gbt_boolgt(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:28
static bool gbt_boollt(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:48
static bool gbt_boolge(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:33
static int gbt_boolkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:54
static bool gbt_boolle(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:43
static bool gbt_booleq(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_bool.c:38
@ gbt_t_bool
Definition btree_gist.h:35

Definition at line 71 of file btree_bool.c.

72{
74 sizeof(bool),
75 2, /* sizeof(gbtreekey2) */
82};

Referenced by gbt_bool_compress(), gbt_bool_consistent(), gbt_bool_fetch(), gbt_bool_picksplit(), gbt_bool_same(), and gbt_bool_union().