PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
btree_utils_num.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/cash.h"
#include "utils/date.h"
#include "utils/timestamp.h"
Include dependency graph for btree_utils_num.c:

Go to the source code of this file.

Functions

GISTENTRYgbt_num_compress (GISTENTRY *entry, const gbtree_ninfo *tinfo)
 
GISTENTRYgbt_num_fetch (GISTENTRY *entry, const gbtree_ninfo *tinfo)
 
void * gbt_num_union (GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo)
 
bool gbt_num_same (const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo)
 
void gbt_num_bin_union (Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo)
 
bool gbt_num_consistent (const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo)
 
float8 gbt_num_distance (const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo)
 
GIST_SPLITVECgbt_num_picksplit (const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo)
 

Function Documentation

void gbt_num_bin_union ( Datum u,
GBT_NUMKEY e,
const gbtree_ninfo tinfo 
)

Definition at line 216 of file btree_utils_num.c.

References DatumGetPointer, gbtree_ninfo::f_gt, gbtree_ninfo::f_lt, gbtree_ninfo::indexsize, GBT_NUMKEY_R::lower, palloc0(), PointerGetDatum, gbtree_ninfo::size, and GBT_NUMKEY_R::upper.

Referenced by gbt_num_picksplit().

217 {
218  GBT_NUMKEY_R rd;
219 
220  rd.lower = &e[0];
221  rd.upper = &e[tinfo->size];
222 
223  if (!DatumGetPointer(*u))
224  {
225  *u = PointerGetDatum(palloc0(tinfo->indexsize));
226  memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]), (void *) rd.lower, tinfo->size);
227  memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]), (void *) rd.upper, tinfo->size);
228  }
229  else
230  {
231  GBT_NUMKEY_R ur;
232 
233  ur.lower = &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]);
234  ur.upper = &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]);
235  if ((*tinfo->f_gt) ((void *) ur.lower, (void *) rd.lower))
236  memcpy((void *) ur.lower, (void *) rd.lower, tinfo->size);
237  if ((*tinfo->f_lt) ((void *) ur.upper, (void *) rd.upper))
238  memcpy((void *) ur.upper, (void *) rd.upper, tinfo->size);
239  }
240 }
const GBT_NUMKEY * lower
#define PointerGetDatum(X)
Definition: postgres.h:564
bool(* f_gt)(const void *, const void *)
const GBT_NUMKEY * upper
bool(* f_lt)(const void *, const void *)
char GBT_NUMKEY
void * palloc0(Size size)
Definition: mcxt.c:920
#define DatumGetPointer(X)
Definition: postgres.h:557
e
Definition: preproc-init.c:82
GISTENTRY* gbt_num_compress ( GISTENTRY entry,
const gbtree_ninfo tinfo 
)

Definition at line 14 of file btree_utils_num.c.

References Assert, DatumGetCash, DatumGetDateADT, DatumGetFloat4, DatumGetFloat8, DatumGetInt16, DatumGetInt32, DatumGetInt64, DatumGetObjectId, DatumGetPointer, DatumGetTimeADT, DatumGetTimestamp, FALSE, gbt_t_cash, gbt_t_date, gbt_t_float4, gbt_t_float8, gbt_t_int2, gbt_t_int4, gbt_t_int8, gbt_t_oid, gbt_t_time, gbt_t_ts, gistentryinit, gbtree_ninfo::indexsize, GISTENTRY::key, GISTENTRY::leafkey, NULL, GISTENTRY::offset, GISTENTRY::page, palloc(), palloc0(), PointerGetDatum, GISTENTRY::rel, gbtree_ninfo::size, gbtree_ninfo::t, and tm.

Referenced by gbt_cash_compress(), gbt_date_compress(), gbt_float4_compress(), gbt_float8_compress(), gbt_int2_compress(), gbt_int4_compress(), gbt_int8_compress(), gbt_macad_compress(), gbt_oid_compress(), gbt_time_compress(), and gbt_ts_compress().

15 {
16  GISTENTRY *retval;
17 
18  if (entry->leafkey)
19  {
20  union
21  {
22  int16 i2;
23  int32 i4;
24  int64 i8;
25  float4 f4;
26  float8 f8;
27  DateADT dt;
28  TimeADT tm;
29  Timestamp ts;
30  Cash ch;
31  } v;
32 
33  GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(tinfo->indexsize);
34  void *leaf = NULL;
35 
36  switch (tinfo->t)
37  {
38  case gbt_t_int2:
39  v.i2 = DatumGetInt16(entry->key);
40  leaf = &v.i2;
41  break;
42  case gbt_t_int4:
43  v.i4 = DatumGetInt32(entry->key);
44  leaf = &v.i4;
45  break;
46  case gbt_t_int8:
47  v.i8 = DatumGetInt64(entry->key);
48  leaf = &v.i8;
49  break;
50  case gbt_t_oid:
51  v.i4 = DatumGetObjectId(entry->key);
52  leaf = &v.i4;
53  break;
54  case gbt_t_float4:
55  v.f4 = DatumGetFloat4(entry->key);
56  leaf = &v.f4;
57  break;
58  case gbt_t_float8:
59  v.f8 = DatumGetFloat8(entry->key);
60  leaf = &v.f8;
61  break;
62  case gbt_t_date:
63  v.dt = DatumGetDateADT(entry->key);
64  leaf = &v.dt;
65  break;
66  case gbt_t_time:
67  v.tm = DatumGetTimeADT(entry->key);
68  leaf = &v.tm;
69  break;
70  case gbt_t_ts:
71  v.ts = DatumGetTimestamp(entry->key);
72  leaf = &v.ts;
73  break;
74  case gbt_t_cash:
75  v.ch = DatumGetCash(entry->key);
76  leaf = &v.ch;
77  break;
78  default:
79  leaf = DatumGetPointer(entry->key);
80  }
81 
82  Assert(tinfo->indexsize >= 2 * tinfo->size);
83 
84  memcpy((void *) &r[0], leaf, tinfo->size);
85  memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
86  retval = palloc(sizeof(GISTENTRY));
87  gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
88  entry->offset, FALSE);
89  }
90  else
91  retval = entry;
92 
93  return retval;
94 }
Relation rel
Definition: gist.h:124
signed short int16
Definition: c.h:252
#define DatumGetDateADT(X)
Definition: date.h:73
#define DatumGetInt32(X)
Definition: postgres.h:480
int32 DateADT
Definition: date.h:22
#define PointerGetDatum(X)
Definition: postgres.h:564
#define DatumGetObjectId(X)
Definition: postgres.h:508
enum gbtree_type t
signed int int32
Definition: c.h:253
static struct pg_tm tm
Definition: localtime.c:103
Page page
Definition: gist.h:125
double float8
Definition: c.h:377
#define FALSE
Definition: c.h:218
#define DatumGetInt64(X)
Definition: postgres.h:615
Datum key
Definition: gist.h:123
char GBT_NUMKEY
#define DatumGetInt16(X)
Definition: postgres.h:452
bool leafkey
Definition: gist.h:127
#define DatumGetTimeADT(X)
Definition: date.h:74
float float4
Definition: c.h:376
#define DatumGetCash(X)
Definition: cash.h:20
void * palloc0(Size size)
Definition: mcxt.c:920
double Timestamp
Definition: timestamp.h:50
#define DatumGetFloat8(X)
Definition: postgres.h:736
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:670
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:169
#define DatumGetFloat4(X)
Definition: postgres.h:688
#define DatumGetPointer(X)
Definition: postgres.h:557
int64 Cash
Definition: cash.h:17
float8 TimeADT
Definition: date.h:27
void * palloc(Size size)
Definition: mcxt.c:891
OffsetNumber offset
Definition: gist.h:126
#define DatumGetTimestamp(X)
Definition: timestamp.h:47
bool gbt_num_consistent ( const GBT_NUMKEY_R key,
const void *  query,
const StrategyNumber strategy,
bool  is_leaf,
const gbtree_ninfo tinfo 
)

Definition at line 251 of file btree_utils_num.c.

References BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BtreeGistNotEqualStrategyNumber, gbtree_ninfo::f_eq, gbtree_ninfo::f_ge, gbtree_ninfo::f_gt, gbtree_ninfo::f_le, gbtree_ninfo::f_lt, GBT_NUMKEY_R::lower, and GBT_NUMKEY_R::upper.

Referenced by gbt_cash_consistent(), gbt_date_consistent(), gbt_float4_consistent(), gbt_float8_consistent(), gbt_inet_consistent(), gbt_int2_consistent(), gbt_int4_consistent(), gbt_int8_consistent(), gbt_intv_consistent(), gbt_macad_consistent(), gbt_oid_consistent(), gbt_time_consistent(), gbt_timetz_consistent(), gbt_ts_consistent(), gbt_tstz_consistent(), and gbt_uuid_consistent().

256 {
257  bool retval;
258 
259  switch (*strategy)
260  {
262  retval = (*tinfo->f_ge) (query, key->lower);
263  break;
265  if (is_leaf)
266  retval = (*tinfo->f_gt) (query, key->lower);
267  else
268  retval = (*tinfo->f_ge) (query, key->lower);
269  break;
271  if (is_leaf)
272  retval = (*tinfo->f_eq) (query, key->lower);
273  else
274  retval = ((*tinfo->f_le) (key->lower, query) && (*tinfo->f_le) (query, key->upper)) ? true : false;
275  break;
277  if (is_leaf)
278  retval = (*tinfo->f_lt) (query, key->upper);
279  else
280  retval = (*tinfo->f_le) (query, key->upper);
281  break;
283  retval = (*tinfo->f_le) (query, key->upper);
284  break;
286  retval = (!((*tinfo->f_eq) (query, key->lower) &&
287  (*tinfo->f_eq) (query, key->upper))) ? true : false;
288  break;
289  default:
290  retval = false;
291  }
292 
293  return (retval);
294 }
bool(* f_le)(const void *, const void *)
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
const GBT_NUMKEY * lower
bool(* f_gt)(const void *, const void *)
const GBT_NUMKEY * upper
bool(* f_lt)(const void *, const void *)
bool(* f_ge)(const void *, const void *)
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
#define BtreeGistNotEqualStrategyNumber
Definition: btree_gist.h:10
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define BTGreaterEqualStrategyNumber
Definition: stratnum.h:32
bool(* f_eq)(const void *, const void *)
float8 gbt_num_distance ( const GBT_NUMKEY_R key,
const void *  query,
bool  is_leaf,
const gbtree_ninfo tinfo 
)

Definition at line 302 of file btree_utils_num.c.

References elog, ERROR, gbtree_ninfo::f_dist, gbtree_ninfo::f_ge, gbtree_ninfo::f_le, GBT_NUMKEY_R::lower, NULL, gbtree_ninfo::t, and GBT_NUMKEY_R::upper.

Referenced by gbt_cash_distance(), gbt_date_distance(), gbt_float4_distance(), gbt_float8_distance(), gbt_int2_distance(), gbt_int4_distance(), gbt_int8_distance(), gbt_intv_distance(), gbt_oid_distance(), gbt_time_distance(), gbt_ts_distance(), and gbt_tstz_distance().

306 {
307  float8 retval;
308 
309  if (tinfo->f_dist == NULL)
310  elog(ERROR, "KNN search is not supported for btree_gist type %d",
311  (int) tinfo->t);
312  if (tinfo->f_le(query, key->lower))
313  retval = tinfo->f_dist(query, key->lower);
314  else if (tinfo->f_ge(query, key->upper))
315  retval = tinfo->f_dist(query, key->upper);
316  else
317  retval = 0.0;
318 
319  return retval;
320 }
bool(* f_le)(const void *, const void *)
const GBT_NUMKEY * lower
const GBT_NUMKEY * upper
enum gbtree_type t
bool(* f_ge)(const void *, const void *)
#define ERROR
Definition: elog.h:43
double float8
Definition: c.h:377
float8(* f_dist)(const void *, const void *)
#define NULL
Definition: c.h:226
#define elog
Definition: elog.h:219
GISTENTRY* gbt_num_fetch ( GISTENTRY entry,
const gbtree_ninfo tinfo 
)

Definition at line 101 of file btree_utils_num.c.

References Assert, CashGetDatum, DateADTGetDatum, FALSE, Float4GetDatum(), Float8GetDatum(), gbt_t_cash, gbt_t_date, gbt_t_float4, gbt_t_float8, gbt_t_int2, gbt_t_int4, gbt_t_int8, gbt_t_oid, gbt_t_time, gbt_t_ts, gistentryinit, gbtree_ninfo::indexsize, Int16GetDatum, Int32GetDatum, Int64GetDatum(), GISTENTRY::key, ObjectIdGetDatum, GISTENTRY::offset, GISTENTRY::page, palloc(), PointerGetDatum, GISTENTRY::rel, gbtree_ninfo::size, gbtree_ninfo::t, TimeADTGetDatum, and TimestampGetDatum.

Referenced by gbt_cash_fetch(), gbt_date_fetch(), gbt_float4_fetch(), gbt_float8_fetch(), gbt_int2_fetch(), gbt_int4_fetch(), gbt_int8_fetch(), gbt_intv_fetch(), gbt_macad_fetch(), gbt_oid_fetch(), gbt_time_fetch(), gbt_ts_fetch(), and gbt_uuid_fetch().

102 {
103  GISTENTRY *retval;
104  Datum datum;
105 
106  Assert(tinfo->indexsize >= 2 * tinfo->size);
107 
108  /*
109  * Get the original Datum from the stored datum. On leaf entries, the
110  * lower and upper bound are the same. We just grab the lower bound and
111  * return it.
112  */
113  switch (tinfo->t)
114  {
115  case gbt_t_int2:
116  datum = Int16GetDatum(*(int16 *) entry->key);
117  break;
118  case gbt_t_int4:
119  datum = Int32GetDatum(*(int32 *) entry->key);
120  break;
121  case gbt_t_int8:
122  datum = Int64GetDatum(*(int64 *) entry->key);
123  break;
124  case gbt_t_oid:
125  datum = ObjectIdGetDatum(*(Oid *) entry->key);
126  break;
127  case gbt_t_float4:
128  datum = Float4GetDatum(*(float4 *) entry->key);
129  break;
130  case gbt_t_float8:
131  datum = Float8GetDatum(*(float8 *) entry->key);
132  break;
133  case gbt_t_date:
134  datum = DateADTGetDatum(*(DateADT *) entry->key);
135  break;
136  case gbt_t_time:
137  datum = TimeADTGetDatum(*(TimeADT *) entry->key);
138  break;
139  case gbt_t_ts:
140  datum = TimestampGetDatum(*(Timestamp *) entry->key);
141  break;
142  case gbt_t_cash:
143  datum = CashGetDatum(*(Cash *) entry->key);
144  break;
145  default:
146  datum = PointerGetDatum(entry->key);
147  }
148 
149  retval = palloc(sizeof(GISTENTRY));
150  gistentryinit(*retval, datum, entry->rel, entry->page, entry->offset,
151  FALSE);
152  return retval;
153 }
Relation rel
Definition: gist.h:124
signed short int16
Definition: c.h:252
int32 DateADT
Definition: date.h:22
#define PointerGetDatum(X)
Definition: postgres.h:564
#define Int16GetDatum(X)
Definition: postgres.h:459
#define DateADTGetDatum(X)
Definition: date.h:77
unsigned int Oid
Definition: postgres_ext.h:31
enum gbtree_type t
signed int int32
Definition: c.h:253
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:2126
Page page
Definition: gist.h:125
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
double float8
Definition: c.h:377
#define FALSE
Definition: c.h:218
Datum Float4GetDatum(float4 X)
Definition: fmgr.c:2114
Datum key
Definition: gist.h:123
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:2102
#define TimestampGetDatum(X)
Definition: timestamp.h:51
float float4
Definition: c.h:376
double Timestamp
Definition: timestamp.h:50
uintptr_t Datum
Definition: postgres.h:374
#define TimeADTGetDatum(X)
Definition: date.h:78
#define Assert(condition)
Definition: c.h:670
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:169
int64 Cash
Definition: cash.h:17
#define Int32GetDatum(X)
Definition: postgres.h:487
float8 TimeADT
Definition: date.h:27
void * palloc(Size size)
Definition: mcxt.c:891
#define CashGetDatum(X)
Definition: cash.h:21
OffsetNumber offset
Definition: gist.h:126
GIST_SPLITVEC* gbt_num_picksplit ( const GistEntryVector entryvec,
GIST_SPLITVEC v,
const gbtree_ninfo tinfo 
)

Definition at line 324 of file btree_utils_num.c.

References DatumGetPointer, gbtree_ninfo::f_cmp, FirstOffsetNumber, gbt_num_bin_union(), i, Nsrt::i, GISTENTRY::key, GistEntryVector::n, OffsetNumberNext, palloc(), PointerGetDatum, qsort, GIST_SPLITVEC::spl_ldatum, GIST_SPLITVEC::spl_left, GIST_SPLITVEC::spl_nleft, GIST_SPLITVEC::spl_nright, GIST_SPLITVEC::spl_rdatum, GIST_SPLITVEC::spl_right, Nsrt::t, and GistEntryVector::vector.

Referenced by gbt_cash_picksplit(), gbt_date_picksplit(), gbt_float4_picksplit(), gbt_float8_picksplit(), gbt_inet_picksplit(), gbt_int2_picksplit(), gbt_int4_picksplit(), gbt_int8_picksplit(), gbt_intv_picksplit(), gbt_macad_picksplit(), gbt_oid_picksplit(), gbt_time_picksplit(), gbt_ts_picksplit(), and gbt_uuid_picksplit().

326 {
327  OffsetNumber i,
328  maxoff = entryvec->n - 1;
329  Nsrt *arr;
330  int nbytes;
331 
332  arr = (Nsrt *) palloc((maxoff + 1) * sizeof(Nsrt));
333  nbytes = (maxoff + 2) * sizeof(OffsetNumber);
334  v->spl_left = (OffsetNumber *) palloc(nbytes);
335  v->spl_right = (OffsetNumber *) palloc(nbytes);
336  v->spl_ldatum = PointerGetDatum(0);
337  v->spl_rdatum = PointerGetDatum(0);
338  v->spl_nleft = 0;
339  v->spl_nright = 0;
340 
341  /* Sort entries */
342 
343  for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
344  {
345  arr[i].t = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
346  arr[i].i = i;
347  }
348  qsort((void *) &arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), tinfo->f_cmp);
349 
350  /* We do simply create two parts */
351 
352  for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
353  {
354  if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
355  {
356  gbt_num_bin_union(&v->spl_ldatum, arr[i].t, tinfo);
357  v->spl_left[v->spl_nleft] = arr[i].i;
358  v->spl_nleft++;
359  }
360  else
361  {
362  gbt_num_bin_union(&v->spl_rdatum, arr[i].t, tinfo);
363  v->spl_right[v->spl_nright] = arr[i].i;
364  v->spl_nright++;
365  }
366  }
367 
368  return v;
369 }
GBT_NUMKEY * t
int(* f_cmp)(const void *, const void *)
#define PointerGetDatum(X)
Definition: postgres.h:564
void gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo)
OffsetNumber * spl_left
Definition: gist.h:105
Datum spl_rdatum
Definition: gist.h:112
int32 n
Definition: gist.h:160
int spl_nleft
Definition: gist.h:106
uint16 OffsetNumber
Definition: off.h:24
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
Definition: gist.h:161
int spl_nright
Definition: gist.h:111
Datum key
Definition: gist.h:123
char GBT_NUMKEY
#define FirstOffsetNumber
Definition: off.h:27
Datum spl_ldatum
Definition: gist.h:107
#define OffsetNumberNext(offsetNumber)
Definition: off.h:53
OffsetNumber * spl_right
Definition: gist.h:110
#define DatumGetPointer(X)
Definition: postgres.h:557
void * palloc(Size size)
Definition: mcxt.c:891
int i
#define qsort(a, b, c, d)
Definition: port.h:440
bool gbt_num_same ( const GBT_NUMKEY a,
const GBT_NUMKEY b,
const gbtree_ninfo tinfo 
)

Definition at line 200 of file btree_utils_num.c.

References gbtree_ninfo::f_eq, GBT_NUMKEY_R::lower, gbtree_ninfo::size, and GBT_NUMKEY_R::upper.

Referenced by gbt_cash_same(), gbt_date_same(), gbt_float4_same(), gbt_float8_same(), gbt_inet_same(), gbt_int2_same(), gbt_int4_same(), gbt_int8_same(), gbt_intv_same(), gbt_macad_same(), gbt_oid_same(), gbt_time_same(), gbt_ts_same(), and gbt_uuid_same().

201 {
202  GBT_NUMKEY_R b1,
203  b2;
204 
205  b1.lower = &(((GBT_NUMKEY *) a)[0]);
206  b1.upper = &(((GBT_NUMKEY *) a)[tinfo->size]);
207  b2.lower = &(((GBT_NUMKEY *) b)[0]);
208  b2.upper = &(((GBT_NUMKEY *) b)[tinfo->size]);
209 
210  return ((*tinfo->f_eq) (b1.lower, b2.lower) &&
211  (*tinfo->f_eq) (b1.upper, b2.upper));
212 }
const GBT_NUMKEY * lower
const GBT_NUMKEY * upper
char GBT_NUMKEY
bool(* f_eq)(const void *, const void *)
void* gbt_num_union ( GBT_NUMKEY out,
const GistEntryVector entryvec,
const gbtree_ninfo tinfo 
)

Definition at line 162 of file btree_utils_num.c.

References cur, DatumGetPointer, gbtree_ninfo::f_gt, gbtree_ninfo::f_lt, i, GISTENTRY::key, GBT_NUMKEY_R::lower, GistEntryVector::n, gbtree_ninfo::size, GBT_NUMKEY_R::upper, and GistEntryVector::vector.

Referenced by gbt_cash_union(), gbt_date_union(), gbt_float4_union(), gbt_float8_union(), gbt_inet_union(), gbt_int2_union(), gbt_int4_union(), gbt_int8_union(), gbt_intv_union(), gbt_macad_union(), gbt_oid_union(), gbt_time_union(), gbt_ts_union(), and gbt_uuid_union().

163 {
164  int i,
165  numranges;
166  GBT_NUMKEY *cur;
167  GBT_NUMKEY_R o,
168  c;
169 
170  numranges = entryvec->n;
171  cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[0].key));
172 
173 
174  o.lower = &((GBT_NUMKEY *) out)[0];
175  o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
176 
177  memcpy((void *) out, (void *) cur, 2 * tinfo->size);
178 
179  for (i = 1; i < numranges; i++)
180  {
181  cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
182  c.lower = &cur[0];
183  c.upper = &cur[tinfo->size];
184  if ((*tinfo->f_gt) (o.lower, c.lower)) /* out->lower > cur->lower */
185  memcpy((void *) o.lower, (void *) c.lower, tinfo->size);
186  if ((*tinfo->f_lt) (o.upper, c.upper)) /* out->upper < cur->upper */
187  memcpy((void *) o.upper, (void *) c.upper, tinfo->size);
188  }
189 
190  return out;
191 }
const GBT_NUMKEY * lower
int32 n
Definition: gist.h:160
bool(* f_gt)(const void *, const void *)
struct cursor * cur
Definition: ecpg.c:28
const GBT_NUMKEY * upper
bool(* f_lt)(const void *, const void *)
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
Definition: gist.h:161
Datum key
Definition: gist.h:123
char * c
char GBT_NUMKEY
#define DatumGetPointer(X)
Definition: postgres.h:557
int i