PostgreSQL Source Code  git master
btree_bool.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.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)
 
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)
 

Variables

static const gbtree_ninfo tinfo
 

Typedef Documentation

◆ boolKEY

typedef struct boolkey boolKEY

Function Documentation

◆ gbt_bool_compress()

Datum gbt_bool_compress ( PG_FUNCTION_ARGS  )

Definition at line 90 of file btree_bool.c.

91 {
92  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
93 
95 }
static const gbtree_ninfo tinfo
Definition: btree_bool.c:70
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361

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 
112  /* Oid subtype = PG_GETARG_OID(3); */
113  bool *recheck = (bool *) PG_GETARG_POINTER(4);
114  boolKEY *kkk = (boolKEY *) DatumGetPointer(entry->key);
116 
117  /* All cases served by this function are exact */
118  *recheck = false;
119 
120  key.lower = (GBT_NUMKEY *) &kkk->lower;
121  key.upper = (GBT_NUMKEY *) &kkk->upper;
122 
123  PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
124  GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
125 }
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_UINT16(n)
Definition: fmgr.h:272
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
#define PG_GETARG_INT16(n)
Definition: fmgr.h:271
#define GIST_LEAF(entry)
Definition: gist.h:170
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:160
bool lower
Definition: btree_bool.c:11
bool upper
Definition: btree_bool.c:12

References DatumGetPointer(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, sort-test::key, boolkey::lower, PG_GETARG_INT16, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, tinfo, and boolkey::upper.

◆ 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 140 of file btree_bool.c.

141 {
142  boolKEY *origentry = (boolKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
143  boolKEY *newentry = (boolKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
144  float *result = (float *) PG_GETARG_POINTER(2);
145 
146  penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
147 
148  PG_RETURN_POINTER(result);
149 }
#define penalty_num(result, olower, oupper, nlower, nupper)

References DatumGetPointer(), sort-test::key, boolkey::lower, penalty_num, PG_GETARG_POINTER, PG_RETURN_POINTER, and boolkey::upper.

◆ gbt_bool_picksplit()

Datum gbt_bool_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 152 of file btree_bool.c.

153 {
156  &tinfo, fcinfo->flinfo));
157 }
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 160 of file btree_bool.c.

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

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

◆ 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:1317

References 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 37 of file btree_bool.c.

38 {
39  return (*((const bool *) a) == *((const bool *) b));
40 }
int b
Definition: isn.c:69
int a
Definition: isn.c:68

References a, and b.

◆ gbt_boolge()

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

Definition at line 32 of file btree_bool.c.

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

References a, and b.

◆ gbt_boolgt()

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

Definition at line 27 of file btree_bool.c.

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

References a, and b.

◆ gbt_boolkey_cmp()

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

Definition at line 53 of file btree_bool.c.

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

References a, b, boolkey::lower, and boolkey::upper.

◆ gbt_boolle()

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

Definition at line 42 of file btree_bool.c.

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

References a, and b.

◆ gbt_boollt()

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

Definition at line 47 of file btree_bool.c.

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

References a, and b.

◆ PG_FUNCTION_INFO_V1() [1/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_compress  )

◆ PG_FUNCTION_INFO_V1() [2/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_fetch  )

◆ PG_FUNCTION_INFO_V1() [4/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_penalty  )

◆ PG_FUNCTION_INFO_V1() [5/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_picksplit  )

◆ PG_FUNCTION_INFO_V1() [6/7]

PG_FUNCTION_INFO_V1 ( gbt_bool_same  )

◆ PG_FUNCTION_INFO_V1() [7/7]

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:27
static bool gbt_boollt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_bool.c:47
static bool gbt_boolge(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_bool.c:32
static int gbt_boolkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_bool.c:53
static bool gbt_boolle(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_bool.c:42
static bool gbt_booleq(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_bool.c:37
@ gbt_t_bool
Definition: btree_gist.h:35

Definition at line 70 of file btree_bool.c.

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