Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
btree_enum.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "fmgr.h"
#include "utils/fmgrprotos.h"
#include "utils/fmgroids.h"
#include "utils/rel.h"
#include "utils/sortsupport.h"
Include dependency graph for btree_enum.c:

Go to the source code of this file.

Data Structures

struct  oidKEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_enum_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_union)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_same)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_sortsupport)
 
static bool gbt_enumgt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumeq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumle (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumlt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_enumkey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
Datum gbt_enum_compress (PG_FUNCTION_ARGS)
 
Datum gbt_enum_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_enum_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_enum_union (PG_FUNCTION_ARGS)
 
Datum gbt_enum_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_enum_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_enum_same (PG_FUNCTION_ARGS)
 
static int gbt_enum_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_enum_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Function Documentation

◆ gbt_enum_compress()

Datum gbt_enum_compress ( PG_FUNCTION_ARGS  )

Definition at line 108 of file btree_enum.c.

109{
110 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
111
113}
static const gbtree_ninfo tinfo
Definition: btree_enum.c:88
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_enum_consistent()

Datum gbt_enum_consistent ( PG_FUNCTION_ARGS  )

Definition at line 124 of file btree_enum.c.

125{
126 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
127 Oid query = PG_GETARG_OID(1);
129
130 /* Oid subtype = PG_GETARG_OID(3); */
131 bool *recheck = (bool *) PG_GETARG_POINTER(4);
132 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
134
135 /* All cases served by this function are exact */
136 *recheck = false;
137
138 key.lower = (GBT_NUMKEY *) &kkk->lower;
139 key.upper = (GBT_NUMKEY *) &kkk->upper;
140
141 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
142 GIST_LEAF(entry), &tinfo,
143 fcinfo->flinfo));
144}
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:359
#define GIST_LEAF(entry)
Definition: gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
unsigned int Oid
Definition: postgres_ext.h:32
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
Oid upper
Definition: btree_enum.c:19
Oid lower
Definition: btree_enum.c:18

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

◆ gbt_enum_fetch()

Datum gbt_enum_fetch ( PG_FUNCTION_ARGS  )

Definition at line 116 of file btree_enum.c.

117{
118 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
119
121}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

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

◆ gbt_enum_penalty()

Datum gbt_enum_penalty ( PG_FUNCTION_ARGS  )

Definition at line 157 of file btree_enum.c.

158{
159 oidKEY *origentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
160 oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
161 float *result = (float *) PG_GETARG_POINTER(2);
162
163 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
164
165 PG_RETURN_POINTER(result);
166}
#define penalty_num(result, olower, oupper, nlower, nupper)

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

◆ gbt_enum_picksplit()

Datum gbt_enum_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 169 of file btree_enum.c.

170{
173 &tinfo, fcinfo->flinfo));
174}
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_enum_same()

Datum gbt_enum_same ( PG_FUNCTION_ARGS  )

Definition at line 177 of file btree_enum.c.

178{
179 oidKEY *b1 = (oidKEY *) PG_GETARG_POINTER(0);
180 oidKEY *b2 = (oidKEY *) PG_GETARG_POINTER(1);
181 bool *result = (bool *) PG_GETARG_POINTER(2);
182
183 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
184 PG_RETURN_POINTER(result);
185}
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_enum_sortsupport()

Datum gbt_enum_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 202 of file btree_enum.c.

203{
205 FmgrInfo *flinfo;
206
208
209 /*
210 * Since gbt_enum_ssup_cmp() uses enum_cmp() like the rest of the
211 * comparison functions, it also needs to pass flinfo when calling it. The
212 * caller to a SortSupport comparison function doesn't provide an FmgrInfo
213 * struct, so look it up now, save it in ssup_extra and use it in
214 * gbt_enum_ssup_cmp() later.
215 */
216 flinfo = MemoryContextAlloc(ssup->ssup_cxt, sizeof(FmgrInfo));
217 fmgr_info_cxt(F_ENUM_CMP, flinfo, ssup->ssup_cxt);
218 ssup->ssup_extra = flinfo;
219
221}
static int gbt_enum_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_enum.c:188
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Definition: fmgr.c:137
#define PG_RETURN_VOID()
Definition: fmgr.h:349
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1229
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
Definition: fmgr.h:57
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106
void * ssup_extra
Definition: sortsupport.h:87
MemoryContext ssup_cxt
Definition: sortsupport.h:66

References SortSupportData::comparator, fmgr_info_cxt(), gbt_enum_ssup_cmp(), MemoryContextAlloc(), PG_GETARG_POINTER, PG_RETURN_VOID, SortSupportData::ssup_cxt, and SortSupportData::ssup_extra.

◆ gbt_enum_ssup_cmp()

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

Definition at line 188 of file btree_enum.c.

189{
190 oidKEY *arg1 = (oidKEY *) DatumGetPointer(x);
191 oidKEY *arg2 = (oidKEY *) DatumGetPointer(y);
192
193 /* for leaf items we expect lower == upper, so only compare lower */
195 ssup->ssup_extra,
197 ObjectIdGetDatum(arg1->lower),
198 ObjectIdGetDatum(arg2->lower)));
199}
Datum enum_cmp(PG_FUNCTION_ARGS)
Definition: enum.c:378
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1085
int y
Definition: isn.c:76
int x
Definition: isn.c:75
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:262
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:212
#define InvalidOid
Definition: postgres_ext.h:37

References CallerFInfoFunctionCall2(), DatumGetInt32(), DatumGetPointer(), enum_cmp(), InvalidOid, oidKEY::lower, ObjectIdGetDatum(), SortSupportData::ssup_extra, x, and y.

Referenced by gbt_enum_sortsupport().

◆ gbt_enum_union()

Datum gbt_enum_union ( PG_FUNCTION_ARGS  )

Definition at line 147 of file btree_enum.c.

148{
150 void *out = palloc(sizeof(oidKEY));
151
152 *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY);
153 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
154}
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
void * palloc(Size size)
Definition: mcxt.c:1365

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

◆ gbt_enumeq()

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

Definition at line 48 of file btree_enum.c.

49{
50 return (*((const Oid *) a) == *((const Oid *) b));
51}
int b
Definition: isn.c:74
int a
Definition: isn.c:73

References a, and b.

◆ gbt_enumge()

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

Definition at line 41 of file btree_enum.c.

42{
44 ObjectIdGetDatum(*((const Oid *) a)),
45 ObjectIdGetDatum(*((const Oid *) b))));
46}
Datum enum_ge(PG_FUNCTION_ARGS)
Definition: enum.c:342
static bool DatumGetBool(Datum X)
Definition: postgres.h:100

References a, b, CallerFInfoFunctionCall2(), DatumGetBool(), enum_ge(), InvalidOid, and ObjectIdGetDatum().

◆ gbt_enumgt()

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

Definition at line 34 of file btree_enum.c.

35{
37 ObjectIdGetDatum(*((const Oid *) a)),
38 ObjectIdGetDatum(*((const Oid *) b))));
39}
Datum enum_gt(PG_FUNCTION_ARGS)
Definition: enum.c:351

References a, b, CallerFInfoFunctionCall2(), DatumGetBool(), enum_gt(), InvalidOid, and ObjectIdGetDatum().

◆ gbt_enumkey_cmp()

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

Definition at line 68 of file btree_enum.c.

69{
70 oidKEY *ia = (oidKEY *) (((const Nsrt *) a)->t);
71 oidKEY *ib = (oidKEY *) (((const Nsrt *) b)->t);
72
73 if (ia->lower == ib->lower)
74 {
75 if (ia->upper == ib->upper)
76 return 0;
77
81 }
82
86}

References a, b, CallerFInfoFunctionCall2(), DatumGetInt32(), enum_cmp(), InvalidOid, oidKEY::lower, ObjectIdGetDatum(), and oidKEY::upper.

◆ gbt_enumle()

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

Definition at line 53 of file btree_enum.c.

54{
56 ObjectIdGetDatum(*((const Oid *) a)),
57 ObjectIdGetDatum(*((const Oid *) b))));
58}
Datum enum_le(PG_FUNCTION_ARGS)
Definition: enum.c:315

References a, b, CallerFInfoFunctionCall2(), DatumGetBool(), enum_le(), InvalidOid, and ObjectIdGetDatum().

◆ gbt_enumlt()

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

Definition at line 60 of file btree_enum.c.

61{
63 ObjectIdGetDatum(*((const Oid *) a)),
64 ObjectIdGetDatum(*((const Oid *) b))));
65}
Datum enum_lt(PG_FUNCTION_ARGS)
Definition: enum.c:306

References a, b, CallerFInfoFunctionCall2(), DatumGetBool(), enum_lt(), InvalidOid, and ObjectIdGetDatum().

◆ PG_FUNCTION_INFO_V1() [1/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_compress  )

◆ PG_FUNCTION_INFO_V1() [2/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_fetch  )

◆ PG_FUNCTION_INFO_V1() [4/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_penalty  )

◆ PG_FUNCTION_INFO_V1() [5/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_picksplit  )

◆ PG_FUNCTION_INFO_V1() [6/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_same  )

◆ PG_FUNCTION_INFO_V1() [7/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [8/8]

PG_FUNCTION_INFO_V1 ( gbt_enum_union  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(Oid),
8,
NULL
}
static bool gbt_enumeq(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:48
static bool gbt_enumge(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:41
static bool gbt_enumlt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:60
static int gbt_enumkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:68
static bool gbt_enumgt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:34
static bool gbt_enumle(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:53
@ gbt_t_enum
Definition: btree_gist.h:38

Definition at line 88 of file btree_enum.c.

Referenced by gbt_enum_compress(), gbt_enum_consistent(), gbt_enum_fetch(), gbt_enum_picksplit(), gbt_enum_same(), and gbt_enum_union().