PostgreSQL Source Code git master
Loading...
Searching...
No Matches
btree_oid.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_oid.c:

Go to the source code of this file.

Data Structures

struct  oidKEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_oid_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_union)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_distance)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_same)
 
 PG_FUNCTION_INFO_V1 (gbt_oid_sortsupport)
 
static bool gbt_oidgt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_oidge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_oideq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_oidle (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_oidlt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_oidkey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
static float8 gbt_oid_dist (const void *a, const void *b, FmgrInfo *flinfo)
 
 PG_FUNCTION_INFO_V1 (oid_dist)
 
Datum oid_dist (PG_FUNCTION_ARGS)
 
Datum gbt_oid_compress (PG_FUNCTION_ARGS)
 
Datum gbt_oid_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_oid_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_oid_distance (PG_FUNCTION_ARGS)
 
Datum gbt_oid_union (PG_FUNCTION_ARGS)
 
Datum gbt_oid_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_oid_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_oid_same (PG_FUNCTION_ARGS)
 
static int gbt_oid_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_oid_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Function Documentation

◆ gbt_oid_compress()

Datum gbt_oid_compress ( PG_FUNCTION_ARGS  )

Definition at line 121 of file btree_oid.c.

122{
123 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
124
126}
static const gbtree_ninfo tinfo
Definition btree_oid.c:85
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_oid_consistent()

Datum gbt_oid_consistent ( PG_FUNCTION_ARGS  )

Definition at line 137 of file btree_oid.c.

138{
139 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
140 Oid query = PG_GETARG_OID(1);
142#ifdef NOT_USED
143 Oid subtype = PG_GETARG_OID(3);
144#endif
145 bool *recheck = (bool *) PG_GETARG_POINTER(4);
146 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
148
149 /* All cases served by this function are exact */
150 *recheck = false;
151
152 key.lower = (GBT_NUMKEY *) &kkk->lower;
153 key.upper = (GBT_NUMKEY *) &kkk->upper;
154
155 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
156 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
157}
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 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_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and tinfo.

◆ gbt_oid_dist()

static float8 gbt_oid_dist ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 73 of file btree_oid.c.

74{
75 Oid aa = *(const Oid *) a;
76 Oid bb = *(const Oid *) b;
77
78 if (aa < bb)
79 return (float8) (bb - aa);
80 else
81 return (float8) (aa - bb);
82}
double float8
Definition c.h:644
int b
Definition isn.c:74
int a
Definition isn.c:73

References a, b, and fb().

◆ gbt_oid_distance()

Datum gbt_oid_distance ( PG_FUNCTION_ARGS  )

Definition at line 160 of file btree_oid.c.

161{
162 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
163 Oid query = PG_GETARG_OID(1);
164#ifdef NOT_USED
165 Oid subtype = PG_GETARG_OID(3);
166#endif
167 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
169
170 key.lower = (GBT_NUMKEY *) &kkk->lower;
171 key.upper = (GBT_NUMKEY *) &kkk->upper;
172
173 PG_RETURN_FLOAT8(gbt_num_distance(&key, &query, GIST_LEAF(entry),
174 &tinfo, fcinfo->flinfo));
175}
float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
#define PG_RETURN_FLOAT8(x)
Definition fmgr.h:369

References DatumGetPointer(), fb(), gbt_num_distance(), GIST_LEAF, GISTENTRY::key, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, and tinfo.

◆ gbt_oid_fetch()

Datum gbt_oid_fetch ( PG_FUNCTION_ARGS  )

Definition at line 129 of file btree_oid.c.

130{
131 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
132
134}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

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

◆ gbt_oid_penalty()

Datum gbt_oid_penalty ( PG_FUNCTION_ARGS  )

Definition at line 188 of file btree_oid.c.

189{
192 float *result = (float *) PG_GETARG_POINTER(2);
193
194 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
195
196 PG_RETURN_POINTER(result);
197}
#define penalty_num(result, olower, oupper, nlower, nupper)

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

◆ gbt_oid_picksplit()

Datum gbt_oid_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 200 of file btree_oid.c.

201{
204 &tinfo, fcinfo->flinfo));
205}
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_oid_same()

Datum gbt_oid_same ( PG_FUNCTION_ARGS  )

Definition at line 208 of file btree_oid.c.

209{
212 bool *result = (bool *) PG_GETARG_POINTER(2);
213
214 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
215 PG_RETURN_POINTER(result);
216}
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_oid_sortsupport()

Datum gbt_oid_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 234 of file btree_oid.c.

235{
237
239 ssup->ssup_extra = NULL;
240
242}
static int gbt_oid_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition btree_oid.c:219
#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_oid_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_oid_ssup_cmp()

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

Definition at line 219 of file btree_oid.c.

220{
223
224 /* for leaf items we expect lower == upper, so only compare lower */
225 if (arg1->lower > arg2->lower)
226 return 1;
227 else if (arg1->lower < arg2->lower)
228 return -1;
229 else
230 return 0;
231}
int y
Definition isn.c:76
int x
Definition isn.c:75

References DatumGetPointer(), fb(), x, and y.

Referenced by gbt_oid_sortsupport().

◆ gbt_oid_union()

Datum gbt_oid_union ( PG_FUNCTION_ARGS  )

Definition at line 178 of file btree_oid.c.

179{
181 void *out = palloc(sizeof(oidKEY));
182
183 *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY);
184 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
185}
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_oideq()

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

Definition at line 40 of file btree_oid.c.

41{
42 return (*((const Oid *) a) == *((const Oid *) b));
43}

References a, and b.

◆ gbt_oidge()

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

Definition at line 35 of file btree_oid.c.

36{
37 return (*((const Oid *) a) >= *((const Oid *) b));
38}

References a, and b.

◆ gbt_oidgt()

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

Definition at line 30 of file btree_oid.c.

31{
32 return (*((const Oid *) a) > *((const Oid *) b));
33}

References a, and b.

◆ gbt_oidkey_cmp()

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

Definition at line 56 of file btree_oid.c.

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

References a, b, and fb().

◆ gbt_oidle()

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

Definition at line 45 of file btree_oid.c.

46{
47 return (*((const Oid *) a) <= *((const Oid *) b));
48}

References a, and b.

◆ gbt_oidlt()

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

Definition at line 50 of file btree_oid.c.

51{
52 return (*((const Oid *) a) < *((const Oid *) b));
53}

References a, and b.

◆ oid_dist()

Datum oid_dist ( PG_FUNCTION_ARGS  )

Definition at line 102 of file btree_oid.c.

103{
104 Oid a = PG_GETARG_OID(0);
105 Oid b = PG_GETARG_OID(1);
106 Oid res;
107
108 if (a < b)
109 res = b - a;
110 else
111 res = a - b;
112 PG_RETURN_OID(res);
113}
#define PG_RETURN_OID(x)
Definition fmgr.h:361

References a, b, PG_GETARG_OID, and PG_RETURN_OID.

◆ PG_FUNCTION_INFO_V1() [1/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_compress  )

◆ PG_FUNCTION_INFO_V1() [2/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_distance  )

◆ PG_FUNCTION_INFO_V1() [4/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_fetch  )

◆ PG_FUNCTION_INFO_V1() [5/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_penalty  )

◆ PG_FUNCTION_INFO_V1() [6/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_picksplit  )

◆ PG_FUNCTION_INFO_V1() [7/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_same  )

◆ PG_FUNCTION_INFO_V1() [8/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [9/10]

PG_FUNCTION_INFO_V1 ( gbt_oid_union  )

◆ PG_FUNCTION_INFO_V1() [10/10]

PG_FUNCTION_INFO_V1 ( oid_dist  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(Oid),
8,
}
@ gbt_t_oid
Definition btree_gist.h:25
static bool gbt_oidlt(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:50
static bool gbt_oidle(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:45
static bool gbt_oideq(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:40
static bool gbt_oidge(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:35
static int gbt_oidkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:56
static bool gbt_oidgt(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:30
static float8 gbt_oid_dist(const void *a, const void *b, FmgrInfo *flinfo)
Definition btree_oid.c:73

Definition at line 85 of file btree_oid.c.

86{
88 sizeof(Oid),
89 8, /* sizeof(gbtreekey8) */
97};

Referenced by gbt_oid_compress(), gbt_oid_consistent(), gbt_oid_distance(), gbt_oid_fetch(), gbt_oid_picksplit(), gbt_oid_same(), and gbt_oid_union().