PostgreSQL Source Code  git master
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, FmgrInfo *flinfo)
 
bool gbt_num_same (const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
 
void gbt_num_bin_union (Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
 
bool gbt_num_consistent (const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
 
float8 gbt_num_distance (const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
 
GIST_SPLITVECgbt_num_picksplit (const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
 

Function Documentation

◆ gbt_num_bin_union()

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

Definition at line 228 of file btree_utils_num.c.

229 {
230  GBT_NUMKEY_R rd;
231 
232  rd.lower = &e[0];
233  rd.upper = &e[tinfo->size];
234 
235  if (!DatumGetPointer(*u))
236  {
237  *u = PointerGetDatum(palloc0(tinfo->indexsize));
238  memcpy(&(((GBT_NUMKEY *) DatumGetPointer(*u))[0]), rd.lower, tinfo->size);
239  memcpy(&(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]), rd.upper, tinfo->size);
240  }
241  else
242  {
243  GBT_NUMKEY_R ur;
244 
245  ur.lower = &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]);
246  ur.upper = &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]);
247  if (tinfo->f_gt(ur.lower, rd.lower, flinfo))
248  memcpy(unconstify(GBT_NUMKEY *, ur.lower), rd.lower, tinfo->size);
249  if (tinfo->f_lt(ur.upper, rd.upper, flinfo))
250  memcpy(unconstify(GBT_NUMKEY *, ur.upper), rd.upper, tinfo->size);
251  }
252 }
static const gbtree_vinfo tinfo
Definition: btree_bit.c:109
char GBT_NUMKEY
#define unconstify(underlying_type, expr)
Definition: c.h:1251
void * palloc0(Size size)
Definition: mcxt.c:1099
#define DatumGetPointer(X)
Definition: postgres.h:593
#define PointerGetDatum(X)
Definition: postgres.h:600
e
Definition: preproc-init.c:82
const GBT_NUMKEY * upper
const GBT_NUMKEY * lower
bool(* f_lt)(const void *, const void *, Oid, FmgrInfo *)
bool(* f_gt)(const void *, const void *, Oid, FmgrInfo *)

References DatumGetPointer, gbtree_vinfo::f_gt, gbtree_vinfo::f_lt, GBT_NUMKEY_R::lower, palloc0(), PointerGetDatum, tinfo, unconstify, and GBT_NUMKEY_R::upper.

Referenced by gbt_num_picksplit().

◆ gbt_num_compress()

GISTENTRY* gbt_num_compress ( GISTENTRY entry,
const gbtree_ninfo tinfo 
)

Definition at line 14 of file btree_utils_num.c.

15 {
16  GISTENTRY *retval;
17 
18  if (entry->leafkey)
19  {
20  union
21  {
22  bool bo;
23  int16 i2;
24  int32 i4;
25  int64 i8;
26  float4 f4;
27  float8 f8;
28  DateADT dt;
29  TimeADT tm;
30  Timestamp ts;
31  Cash ch;
32  } v;
33 
34  GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(tinfo->indexsize);
35  void *leaf = NULL;
36 
37  switch (tinfo->t)
38  {
39  case gbt_t_bool:
40  v.bo = DatumGetBool(entry->key);
41  leaf = &v.bo;
42  break;
43  case gbt_t_int2:
44  v.i2 = DatumGetInt16(entry->key);
45  leaf = &v.i2;
46  break;
47  case gbt_t_int4:
48  v.i4 = DatumGetInt32(entry->key);
49  leaf = &v.i4;
50  break;
51  case gbt_t_int8:
52  v.i8 = DatumGetInt64(entry->key);
53  leaf = &v.i8;
54  break;
55  case gbt_t_oid:
56  case gbt_t_enum:
57  v.i4 = DatumGetObjectId(entry->key);
58  leaf = &v.i4;
59  break;
60  case gbt_t_float4:
61  v.f4 = DatumGetFloat4(entry->key);
62  leaf = &v.f4;
63  break;
64  case gbt_t_float8:
65  v.f8 = DatumGetFloat8(entry->key);
66  leaf = &v.f8;
67  break;
68  case gbt_t_date:
69  v.dt = DatumGetDateADT(entry->key);
70  leaf = &v.dt;
71  break;
72  case gbt_t_time:
73  v.tm = DatumGetTimeADT(entry->key);
74  leaf = &v.tm;
75  break;
76  case gbt_t_ts:
77  v.ts = DatumGetTimestamp(entry->key);
78  leaf = &v.ts;
79  break;
80  case gbt_t_cash:
81  v.ch = DatumGetCash(entry->key);
82  leaf = &v.ch;
83  break;
84  default:
85  leaf = DatumGetPointer(entry->key);
86  }
87 
88  Assert(tinfo->indexsize >= 2 * tinfo->size);
89 
90  memcpy((void *) &r[0], leaf, tinfo->size);
91  memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
92  retval = palloc(sizeof(GISTENTRY));
93  gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
94  entry->offset, false);
95  }
96  else
97  retval = entry;
98 
99  return retval;
100 }
@ gbt_t_enum
Definition: btree_gist.h:38
@ gbt_t_int4
Definition: btree_gist.h:18
@ gbt_t_cash
Definition: btree_gist.h:24
@ gbt_t_float8
Definition: btree_gist.h:21
@ gbt_t_date
Definition: btree_gist.h:27
@ gbt_t_float4
Definition: btree_gist.h:20
@ gbt_t_oid
Definition: btree_gist.h:25
@ gbt_t_bool
Definition: btree_gist.h:35
@ gbt_t_time
Definition: btree_gist.h:26
@ gbt_t_int8
Definition: btree_gist.h:19
@ gbt_t_int2
Definition: btree_gist.h:17
@ gbt_t_ts
Definition: btree_gist.h:23
signed short int16
Definition: c.h:439
signed int int32
Definition: c.h:440
double float8
Definition: c.h:576
float float4
Definition: c.h:575
int64 Cash
Definition: cash.h:17
#define DatumGetCash(X)
Definition: cash.h:20
int64 Timestamp
Definition: timestamp.h:38
int32 DateADT
Definition: date.h:23
#define DatumGetTimeADT(X)
Definition: date.h:54
int64 TimeADT
Definition: date.h:25
#define DatumGetDateADT(X)
Definition: date.h:53
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:242
Assert(fmt[strlen(fmt) - 1] !='\n')
static struct pg_tm tm
Definition: localtime.c:102
void * palloc(Size size)
Definition: mcxt.c:1068
#define DatumGetObjectId(X)
Definition: postgres.h:544
static float4 DatumGetFloat4(Datum X)
Definition: postgres.h:708
#define DatumGetBool(X)
Definition: postgres.h:437
#define DatumGetFloat8(X)
Definition: postgres.h:758
#define DatumGetInt32(X)
Definition: postgres.h:516
#define DatumGetInt16(X)
Definition: postgres.h:488
#define DatumGetInt64(X)
Definition: postgres.h:651
OffsetNumber offset
Definition: gist.h:161
Datum key
Definition: gist.h:158
Page page
Definition: gist.h:160
Relation rel
Definition: gist.h:159
bool leafkey
Definition: gist.h:162
enum gbtree_type t
#define DatumGetTimestamp(X)
Definition: timestamp.h:27

References Assert(), DatumGetBool, DatumGetCash, DatumGetDateADT, DatumGetFloat4(), DatumGetFloat8, DatumGetInt16, DatumGetInt32, DatumGetInt64, DatumGetObjectId, DatumGetPointer, DatumGetTimeADT, DatumGetTimestamp, gbt_t_bool, gbt_t_cash, gbt_t_date, gbt_t_enum, 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, GISTENTRY::key, GISTENTRY::leafkey, GISTENTRY::offset, GISTENTRY::page, palloc(), palloc0(), PointerGetDatum, GISTENTRY::rel, gbtree_vinfo::t, tinfo, and tm.

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

◆ gbt_num_consistent()

bool gbt_num_consistent ( const GBT_NUMKEY_R key,
const void *  query,
const StrategyNumber strategy,
bool  is_leaf,
const gbtree_ninfo tinfo,
FmgrInfo flinfo 
)

Definition at line 263 of file btree_utils_num.c.

269 {
270  bool retval;
271 
272  switch (*strategy)
273  {
275  retval = tinfo->f_ge(query, key->lower, flinfo);
276  break;
278  if (is_leaf)
279  retval = tinfo->f_gt(query, key->lower, flinfo);
280  else
281  retval = tinfo->f_ge(query, key->lower, flinfo);
282  break;
284  if (is_leaf)
285  retval = tinfo->f_eq(query, key->lower, flinfo);
286  else
287  retval = (tinfo->f_le(key->lower, query, flinfo) &&
288  tinfo->f_le(query, key->upper, flinfo));
289  break;
291  if (is_leaf)
292  retval = tinfo->f_lt(query, key->upper, flinfo);
293  else
294  retval = tinfo->f_le(query, key->upper, flinfo);
295  break;
297  retval = tinfo->f_le(query, key->upper, flinfo);
298  break;
300  retval = (!(tinfo->f_eq(query, key->lower, flinfo) &&
301  tinfo->f_eq(query, key->upper, flinfo)));
302  break;
303  default:
304  retval = false;
305  }
306 
307  return retval;
308 }
#define BtreeGistNotEqualStrategyNumber
Definition: btree_gist.h:10
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
#define BTGreaterEqualStrategyNumber
Definition: stratnum.h:32
bool(* f_eq)(const void *, const void *, Oid, FmgrInfo *)
bool(* f_ge)(const void *, const void *, Oid, FmgrInfo *)
bool(* f_le)(const void *, const void *, Oid, FmgrInfo *)

References BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BtreeGistNotEqualStrategyNumber, gbtree_vinfo::f_eq, gbtree_vinfo::f_ge, gbtree_vinfo::f_gt, gbtree_vinfo::f_le, gbtree_vinfo::f_lt, sort-test::key, and tinfo.

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

◆ gbt_num_distance()

float8 gbt_num_distance ( const GBT_NUMKEY_R key,
const void *  query,
bool  is_leaf,
const gbtree_ninfo tinfo,
FmgrInfo flinfo 
)

Definition at line 316 of file btree_utils_num.c.

321 {
322  float8 retval;
323 
324  if (tinfo->f_dist == NULL)
325  elog(ERROR, "KNN search is not supported for btree_gist type %d",
326  (int) tinfo->t);
327  if (tinfo->f_le(query, key->lower, flinfo))
328  retval = tinfo->f_dist(query, key->lower, flinfo);
329  else if (tinfo->f_ge(query, key->upper, flinfo))
330  retval = tinfo->f_dist(query, key->upper, flinfo);
331  else
332  retval = 0.0;
333 
334  return retval;
335 }
#define ERROR
Definition: elog.h:33

References elog(), ERROR, gbtree_vinfo::f_ge, gbtree_vinfo::f_le, sort-test::key, gbtree_vinfo::t, and tinfo.

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().

◆ gbt_num_fetch()

GISTENTRY* gbt_num_fetch ( GISTENTRY entry,
const gbtree_ninfo tinfo 
)

Definition at line 107 of file btree_utils_num.c.

108 {
109  GISTENTRY *retval;
110  Datum datum;
111 
112  Assert(tinfo->indexsize >= 2 * tinfo->size);
113 
114  /*
115  * Get the original Datum from the stored datum. On leaf entries, the
116  * lower and upper bound are the same. We just grab the lower bound and
117  * return it.
118  */
119  switch (tinfo->t)
120  {
121  case gbt_t_bool:
122  datum = BoolGetDatum(*(bool *) entry->key);
123  break;
124  case gbt_t_int2:
125  datum = Int16GetDatum(*(int16 *) entry->key);
126  break;
127  case gbt_t_int4:
128  datum = Int32GetDatum(*(int32 *) entry->key);
129  break;
130  case gbt_t_int8:
131  datum = Int64GetDatum(*(int64 *) entry->key);
132  break;
133  case gbt_t_oid:
134  case gbt_t_enum:
135  datum = ObjectIdGetDatum(*(Oid *) entry->key);
136  break;
137  case gbt_t_float4:
138  datum = Float4GetDatum(*(float4 *) entry->key);
139  break;
140  case gbt_t_float8:
141  datum = Float8GetDatum(*(float8 *) entry->key);
142  break;
143  case gbt_t_date:
144  datum = DateADTGetDatum(*(DateADT *) entry->key);
145  break;
146  case gbt_t_time:
147  datum = TimeADTGetDatum(*(TimeADT *) entry->key);
148  break;
149  case gbt_t_ts:
150  datum = TimestampGetDatum(*(Timestamp *) entry->key);
151  break;
152  case gbt_t_cash:
153  datum = CashGetDatum(*(Cash *) entry->key);
154  break;
155  default:
156  datum = PointerGetDatum(entry->key);
157  }
158 
159  retval = palloc(sizeof(GISTENTRY));
160  gistentryinit(*retval, datum, entry->rel, entry->page, entry->offset,
161  false);
162  return retval;
163 }
#define CashGetDatum(X)
Definition: cash.h:21
#define DateADTGetDatum(X)
Definition: date.h:57
#define TimeADTGetDatum(X)
Definition: date.h:58
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1683
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:1692
static Datum Float4GetDatum(float4 X)
Definition: postgres.h:725
uintptr_t Datum
Definition: postgres.h:411
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define BoolGetDatum(X)
Definition: postgres.h:446
#define Int32GetDatum(X)
Definition: postgres.h:523
#define Int16GetDatum(X)
Definition: postgres.h:495
unsigned int Oid
Definition: postgres_ext.h:31
#define TimestampGetDatum(X)
Definition: timestamp.h:31

References Assert(), BoolGetDatum, CashGetDatum, DateADTGetDatum, Float4GetDatum(), Float8GetDatum(), gbt_t_bool, gbt_t_cash, gbt_t_date, gbt_t_enum, 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, Int16GetDatum, Int32GetDatum, Int64GetDatum(), GISTENTRY::key, ObjectIdGetDatum, GISTENTRY::offset, GISTENTRY::page, palloc(), PointerGetDatum, GISTENTRY::rel, gbtree_vinfo::t, TimeADTGetDatum, TimestampGetDatum, and tinfo.

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

◆ gbt_num_picksplit()

GIST_SPLITVEC* gbt_num_picksplit ( const GistEntryVector entryvec,
GIST_SPLITVEC v,
const gbtree_ninfo tinfo,
FmgrInfo flinfo 
)

Definition at line 339 of file btree_utils_num.c.

341 {
342  OffsetNumber i,
343  maxoff = entryvec->n - 1;
344  Nsrt *arr;
345  int nbytes;
346 
347  arr = (Nsrt *) palloc((maxoff + 1) * sizeof(Nsrt));
348  nbytes = (maxoff + 2) * sizeof(OffsetNumber);
349  v->spl_left = (OffsetNumber *) palloc(nbytes);
350  v->spl_right = (OffsetNumber *) palloc(nbytes);
351  v->spl_ldatum = PointerGetDatum(0);
352  v->spl_rdatum = PointerGetDatum(0);
353  v->spl_nleft = 0;
354  v->spl_nright = 0;
355 
356  /* Sort entries */
357 
358  for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
359  {
360  arr[i].t = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
361  arr[i].i = i;
362  }
363  qsort_arg((void *) &arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, (void *) flinfo);
364 
365  /* We do simply create two parts */
366 
367  for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
368  {
369  if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
370  {
371  gbt_num_bin_union(&v->spl_ldatum, arr[i].t, tinfo, flinfo);
372  v->spl_left[v->spl_nleft] = arr[i].i;
373  v->spl_nleft++;
374  }
375  else
376  {
377  gbt_num_bin_union(&v->spl_rdatum, arr[i].t, tinfo, flinfo);
378  v->spl_right[v->spl_nright] = arr[i].i;
379  v->spl_nright++;
380  }
381  }
382 
383  return v;
384 }
void gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
int i
Definition: isn.c:73
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
int(* qsort_arg_comparator)(const void *a, const void *b, void *arg)
Definition: port.h:497
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
int spl_nleft
Definition: gist.h:141
OffsetNumber * spl_right
Definition: gist.h:145
Datum spl_ldatum
Definition: gist.h:142
Datum spl_rdatum
Definition: gist.h:147
int spl_nright
Definition: gist.h:146
OffsetNumber * spl_left
Definition: gist.h:140
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
Definition: gist.h:234
int32 n
Definition: gist.h:233
GBT_NUMKEY * t
int32(* f_cmp)(const void *, const void *, Oid, FmgrInfo *)

References DatumGetPointer, gbtree_vinfo::f_cmp, FirstOffsetNumber, gbt_num_bin_union(), Nsrt::i, i, GISTENTRY::key, GistEntryVector::n, OffsetNumberNext, palloc(), PointerGetDatum, qsort_arg(), 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, tinfo, and GistEntryVector::vector.

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

◆ gbt_num_same()

bool gbt_num_same ( const GBT_NUMKEY a,
const GBT_NUMKEY b,
const gbtree_ninfo tinfo,
FmgrInfo flinfo 
)

Definition at line 212 of file btree_utils_num.c.

213 {
214  GBT_NUMKEY_R b1,
215  b2;
216 
217  b1.lower = &(a[0]);
218  b1.upper = &(a[tinfo->size]);
219  b2.lower = &(b[0]);
220  b2.upper = &(b[tinfo->size]);
221 
222  return (tinfo->f_eq(b1.lower, b2.lower, flinfo) &&
223  tinfo->f_eq(b1.upper, b2.upper, flinfo));
224 }
int b
Definition: isn.c:70
int a
Definition: isn.c:69

References a, b, gbtree_vinfo::f_eq, GBT_NUMKEY_R::lower, tinfo, and GBT_NUMKEY_R::upper.

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

◆ gbt_num_union()

void* gbt_num_union ( GBT_NUMKEY out,
const GistEntryVector entryvec,
const gbtree_ninfo tinfo,
FmgrInfo flinfo 
)

Definition at line 172 of file btree_utils_num.c.

173 {
174  int i,
175  numranges;
176  GBT_NUMKEY *cur;
177  GBT_NUMKEY_R o,
178  c;
179 
180  numranges = entryvec->n;
181  cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[0].key));
182 
183 
184  o.lower = &((GBT_NUMKEY *) out)[0];
185  o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
186 
187  memcpy((void *) out, (void *) cur, 2 * tinfo->size);
188 
189  for (i = 1; i < numranges; i++)
190  {
191  cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
192  c.lower = &cur[0];
193  c.upper = &cur[tinfo->size];
194  /* if out->lower > cur->lower, adopt cur as lower */
195  if (tinfo->f_gt(o.lower, c.lower, flinfo))
196  memcpy(unconstify(GBT_NUMKEY *, o.lower), c.lower, tinfo->size);
197  /* if out->upper < cur->upper, adopt cur as upper */
198  if (tinfo->f_lt(o.upper, c.upper, flinfo))
199  memcpy(unconstify(GBT_NUMKEY *, o.upper), c.upper, tinfo->size);
200  }
201 
202  return out;
203 }
struct cursor * cur
Definition: ecpg.c:28
char * c

References cur, DatumGetPointer, gbtree_vinfo::f_gt, gbtree_vinfo::f_lt, i, GISTENTRY::key, GBT_NUMKEY_R::lower, GistEntryVector::n, tinfo, unconstify, GBT_NUMKEY_R::upper, and GistEntryVector::vector.

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