PostgreSQL Source Code git master
Data Structures | Functions | Variables
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

 
 
 
 
 
 
 
 
 
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)
 
 
 
 
 
 
 
 
 
 
 
static int  gbt_oid_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
 

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:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361
Definition: gist.h:160

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
143 /* Oid subtype = PG_GETARG_OID(3); */
144 bool *recheck = (bool *) PG_GETARG_POINTER(4);
145 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
147
148 /* All cases served by this function are exact */
149 *recheck = false;
150
151 key.lower = (GBT_NUMKEY *) &kkk->lower;
152 key.upper = (GBT_NUMKEY *) &kkk->upper;
153
154 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
155 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
156}
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
Definition: btree_enum.c:17
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_oid_dist()

static float8 gbt_oid_dist ( const void *  a,
const void *  b,
FmgrInfoflinfo 
)
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:635
b
int b
Definition: isn.c:74
a
int a
Definition: isn.c:73

References a, and b.

gbt_oid_distance()

Datum gbt_oid_distance ( PG_FUNCTION_ARGS  )

Definition at line 159 of file btree_oid.c.

160{
161 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
162 Oid query = PG_GETARG_OID(1);
163
164 /* Oid subtype = PG_GETARG_OID(3); */
165 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
167
168 key.lower = (GBT_NUMKEY *) &kkk->lower;
169 key.upper = (GBT_NUMKEY *) &kkk->upper;
170
172 &tinfo, fcinfo->flinfo));
173}
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:367

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

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 186 of file btree_oid.c.

187{
188 oidKEY *origentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
189 oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
190 float *result = (float *) PG_GETARG_POINTER(2);
191
192 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
193
194 PG_RETURN_POINTER(result);
195}
#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_oid_picksplit()

Datum gbt_oid_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 198 of file btree_oid.c.

199{
202 &tinfo, fcinfo->flinfo));
203}
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 206 of file btree_oid.c.

207{
208 oidKEY *b1 = (oidKEY *) PG_GETARG_POINTER(0);
209 oidKEY *b2 = (oidKEY *) PG_GETARG_POINTER(1);
210 bool *result = (bool *) PG_GETARG_POINTER(2);
211
212 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
213 PG_RETURN_POINTER(result);
214}
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_oid_sortsupport()

Datum gbt_oid_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 232 of file btree_oid.c.

233{
235
237 ssup->ssup_extra = NULL;
238
240}
static int gbt_oid_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_oid.c:217
#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_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 217 of file btree_oid.c.

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

References DatumGetPointer(), oidKEY::lower, x, and y.

Referenced by gbt_oid_sortsupport().

gbt_oid_union()

Datum gbt_oid_union ( PG_FUNCTION_ARGS  )

Definition at line 176 of file btree_oid.c.

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

static bool gbt_oideq ( const void *  a,
const void *  b,
FmgrInfoflinfo 
)
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,
FmgrInfoflinfo 
)
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,
FmgrInfoflinfo 
)
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,
FmgrInfoflinfo 
)
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, oidKEY::lower, and oidKEY::upper.

gbt_oidle()

static bool gbt_oidle ( const void *  a,
const void *  b,
FmgrInfoflinfo 
)
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,
FmgrInfoflinfo 
)
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:360

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.

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

AltStyle によって変換されたページ (->オリジナル) /