PostgreSQL Source Code  git master
hstore_gist.c
Go to the documentation of this file.
1 /*
2  * contrib/hstore/hstore_gist.c
3  */
4 #include "postgres.h"
5 
6 #include "access/gist.h"
7 #include "access/reloptions.h"
8 #include "access/stratnum.h"
9 #include "catalog/pg_type.h"
10 #include "hstore.h"
11 #include "utils/pg_crc.h"
12 
13 /* gist_hstore_ops opclass options */
14 typedef struct
15 {
16  int32 vl_len_; /* varlena header (do not touch directly!) */
17  int siglen; /* signature length in bytes */
19 
20 /* bigint defines */
21 #define BITBYTE 8
22 #define SIGLEN_DEFAULT (sizeof(int32) * 4)
23 #define SIGLEN_MAX GISTMaxIndexKeySize
24 #define SIGLENBIT(siglen) ((siglen) * BITBYTE)
25 #define GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
26  ((GistHstoreOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
27  SIGLEN_DEFAULT)
28 
29 
30 typedef char *BITVECP;
31 
32 #define LOOPBYTE(siglen) \
33  for (i = 0; i < (siglen); i++)
34 
35 #define LOOPBIT(siglen) \
36  for (i = 0; i < SIGLENBIT(siglen); i++)
37 
38 /* beware of multiple evaluation of arguments to these macros! */
39 #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
40 #define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
41 #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
42 #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
43 #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
44 #define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
45 #define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
46 
47 typedef struct
48 {
49  int32 vl_len_; /* varlena header (do not touch directly!) */
52 } GISTTYPE;
53 
54 #define ALLISTRUE 0x04
55 
56 #define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
57 
58 #define GTHDRSIZE (VARHDRSZ + sizeof(int32))
59 #define CALCGTSIZE(flag, siglen) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : (siglen)) )
60 
61 #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
62 
63 #define SUMBIT(val) ( \
64  GETBITBYTE((val),0) + \
65  GETBITBYTE((val),1) + \
66  GETBITBYTE((val),2) + \
67  GETBITBYTE((val),3) + \
68  GETBITBYTE((val),4) + \
69  GETBITBYTE((val),5) + \
70  GETBITBYTE((val),6) + \
71  GETBITBYTE((val),7) \
72 )
73 
74 #define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
75 
76 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
77 
78 /* shorthand for calculating CRC-32 of a single chunk of data. */
79 static pg_crc32
80 crc32_sz(char *buf, int size)
81 {
82  pg_crc32 crc;
83 
87 
88  return crc;
89 }
90 
91 
94 
95 
96 Datum
98 {
99  ereport(ERROR,
100  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
101  errmsg("cannot accept a value of type %s", "ghstore")));
102 
103  PG_RETURN_VOID(); /* keep compiler quiet */
104 }
105 
106 Datum
108 {
109  ereport(ERROR,
110  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
111  errmsg("cannot display a value of type %s", "ghstore")));
112 
113  PG_RETURN_VOID(); /* keep compiler quiet */
114 }
115 
116 static GISTTYPE *
117 ghstore_alloc(bool allistrue, int siglen, BITVECP sign)
118 {
119  int flag = allistrue ? ALLISTRUE : 0;
120  int size = CALCGTSIZE(flag, siglen);
121  GISTTYPE *res = palloc(size);
122 
123  SET_VARSIZE(res, size);
124  res->flag = flag;
125 
126  if (!allistrue)
127  {
128  if (sign)
129  memcpy(GETSIGN(res), sign, siglen);
130  else
131  memset(GETSIGN(res), 0, siglen);
132  }
133 
134  return res;
135 }
136 
145 
146 Datum
148 {
149  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
150  int siglen = GET_SIGLEN();
151  GISTENTRY *retval = entry;
152 
153  if (entry->leafkey)
154  {
155  GISTTYPE *res = ghstore_alloc(false, siglen, NULL);
156  HStore *val = DatumGetHStoreP(entry->key);
157  HEntry *hsent = ARRPTR(val);
158  char *ptr = STRPTR(val);
159  int count = HS_COUNT(val);
160  int i;
161 
162  for (i = 0; i < count; ++i)
163  {
164  int h;
165 
166  h = crc32_sz((char *) HSTORE_KEY(hsent, ptr, i),
167  HSTORE_KEYLEN(hsent, i));
168  HASH(GETSIGN(res), h, siglen);
169  if (!HSTORE_VALISNULL(hsent, i))
170  {
171  h = crc32_sz((char *) HSTORE_VAL(hsent, ptr, i),
172  HSTORE_VALLEN(hsent, i));
173  HASH(GETSIGN(res), h, siglen);
174  }
175  }
176 
177  retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
179  entry->rel, entry->page,
180  entry->offset,
181  false);
182  }
183  else if (!ISALLTRUE(DatumGetPointer(entry->key)))
184  {
185  int32 i;
186  GISTTYPE *res;
188 
189  LOOPBYTE(siglen)
190  {
191  if ((sign[i] & 0xff) != 0xff)
192  PG_RETURN_POINTER(retval);
193  }
194 
195  res = ghstore_alloc(true, siglen, NULL);
196 
197  retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
199  entry->rel, entry->page,
200  entry->offset,
201  false);
202  }
203 
204  PG_RETURN_POINTER(retval);
205 }
206 
207 /*
208  * Since type ghstore isn't toastable (and doesn't need to be),
209  * this function can be a no-op.
210  */
211 Datum
213 {
215 }
216 
217 Datum
219 {
222  bool *result = (bool *) PG_GETARG_POINTER(2);
223  int siglen = GET_SIGLEN();
224 
225 
226  if (ISALLTRUE(a) && ISALLTRUE(b))
227  *result = true;
228  else if (ISALLTRUE(a))
229  *result = false;
230  else if (ISALLTRUE(b))
231  *result = false;
232  else
233  {
234  int32 i;
235  BITVECP sa = GETSIGN(a),
236  sb = GETSIGN(b);
237 
238  *result = true;
239  LOOPBYTE(siglen)
240  {
241  if (sa[i] != sb[i])
242  {
243  *result = false;
244  break;
245  }
246  }
247  }
248  PG_RETURN_POINTER(result);
249 }
250 
251 static int32
252 sizebitvec(BITVECP sign, int siglen)
253 {
254  int32 size = 0,
255  i;
256 
257  LOOPBYTE(siglen)
258  {
259  size += SUMBIT(sign);
260  sign = (BITVECP) (((char *) sign) + 1);
261  }
262  return size;
263 }
264 
265 static int
267 {
268  int i,
269  dist = 0;
270 
271  LOOPBIT(siglen)
272  {
273  if (GETBIT(a, i) != GETBIT(b, i))
274  dist++;
275  }
276  return dist;
277 }
278 
279 static int
280 hemdist(GISTTYPE *a, GISTTYPE *b, int siglen)
281 {
282  if (ISALLTRUE(a))
283  {
284  if (ISALLTRUE(b))
285  return 0;
286  else
287  return SIGLENBIT(siglen) - sizebitvec(GETSIGN(b), siglen);
288  }
289  else if (ISALLTRUE(b))
290  return SIGLENBIT(siglen) - sizebitvec(GETSIGN(a), siglen);
291 
292  return hemdistsign(GETSIGN(a), GETSIGN(b), siglen);
293 }
294 
295 static int32
296 unionkey(BITVECP sbase, GISTTYPE *add, int siglen)
297 {
298  int32 i;
299  BITVECP sadd = GETSIGN(add);
300 
301  if (ISALLTRUE(add))
302  return 1;
303  LOOPBYTE(siglen)
304  sbase[i] |= sadd[i];
305  return 0;
306 }
307 
308 Datum
310 {
312  int32 len = entryvec->n;
313 
314  int *size = (int *) PG_GETARG_POINTER(1);
315  int siglen = GET_SIGLEN();
316  int32 i;
317  GISTTYPE *result = ghstore_alloc(false, siglen, NULL);
318  BITVECP base = GETSIGN(result);
319 
320  for (i = 0; i < len; i++)
321  {
322  if (unionkey(base, GETENTRY(entryvec, i), siglen))
323  {
324  result->flag |= ALLISTRUE;
325  SET_VARSIZE(result, CALCGTSIZE(ALLISTRUE, siglen));
326  break;
327  }
328  }
329 
330  *size = VARSIZE(result);
331 
332  PG_RETURN_POINTER(result);
333 }
334 
335 Datum
337 {
338  GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); /* always ISSIGNKEY */
339  GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
340  float *penalty = (float *) PG_GETARG_POINTER(2);
341  int siglen = GET_SIGLEN();
342  GISTTYPE *origval = (GISTTYPE *) DatumGetPointer(origentry->key);
343  GISTTYPE *newval = (GISTTYPE *) DatumGetPointer(newentry->key);
344 
345  *penalty = hemdist(origval, newval, siglen);
346  PG_RETURN_POINTER(penalty);
347 }
348 
349 
350 typedef struct
351 {
354 } SPLITCOST;
355 
356 static int
357 comparecost(const void *a, const void *b)
358 {
359  return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
360 }
361 
362 
363 Datum
365 {
367  OffsetNumber maxoff = entryvec->n - 2;
368 
370  int siglen = GET_SIGLEN();
371  OffsetNumber k,
372  j;
373  GISTTYPE *datum_l,
374  *datum_r;
375  BITVECP union_l,
376  union_r;
377  int32 size_alpha,
378  size_beta;
379  int32 size_waste,
380  waste = -1;
381  int32 nbytes;
382  OffsetNumber seed_1 = 0,
383  seed_2 = 0;
384  OffsetNumber *left,
385  *right;
386  BITVECP ptr;
387  int i;
388  SPLITCOST *costvector;
389  GISTTYPE *_k,
390  *_j;
391 
392  nbytes = (maxoff + 2) * sizeof(OffsetNumber);
393  v->spl_left = (OffsetNumber *) palloc(nbytes);
394  v->spl_right = (OffsetNumber *) palloc(nbytes);
395 
396  for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
397  {
398  _k = GETENTRY(entryvec, k);
399  for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
400  {
401  size_waste = hemdist(_k, GETENTRY(entryvec, j), siglen);
402  if (size_waste > waste)
403  {
404  waste = size_waste;
405  seed_1 = k;
406  seed_2 = j;
407  }
408  }
409  }
410 
411  left = v->spl_left;
412  v->spl_nleft = 0;
413  right = v->spl_right;
414  v->spl_nright = 0;
415 
416  if (seed_1 == 0 || seed_2 == 0)
417  {
418  seed_1 = 1;
419  seed_2 = 2;
420  }
421 
422  /* form initial .. */
423  datum_l = ghstore_alloc(ISALLTRUE(GETENTRY(entryvec, seed_1)), siglen,
424  GETSIGN(GETENTRY(entryvec, seed_1)));
425  datum_r = ghstore_alloc(ISALLTRUE(GETENTRY(entryvec, seed_2)), siglen,
426  GETSIGN(GETENTRY(entryvec, seed_2)));
427 
428  maxoff = OffsetNumberNext(maxoff);
429  /* sort before ... */
430  costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
431  for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
432  {
433  costvector[j - 1].pos = j;
434  _j = GETENTRY(entryvec, j);
435  size_alpha = hemdist(datum_l, _j, siglen);
436  size_beta = hemdist(datum_r, _j, siglen);
437  costvector[j - 1].cost = abs(size_alpha - size_beta);
438  }
439  qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
440 
441  union_l = GETSIGN(datum_l);
442  union_r = GETSIGN(datum_r);
443 
444  for (k = 0; k < maxoff; k++)
445  {
446  j = costvector[k].pos;
447  if (j == seed_1)
448  {
449  *left++ = j;
450  v->spl_nleft++;
451  continue;
452  }
453  else if (j == seed_2)
454  {
455  *right++ = j;
456  v->spl_nright++;
457  continue;
458  }
459  _j = GETENTRY(entryvec, j);
460  size_alpha = hemdist(datum_l, _j, siglen);
461  size_beta = hemdist(datum_r, _j, siglen);
462 
463  if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
464  {
465  if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
466  {
467  if (!ISALLTRUE(datum_l))
468  memset(union_l, 0xff, siglen);
469  }
470  else
471  {
472  ptr = GETSIGN(_j);
473  LOOPBYTE(siglen)
474  union_l[i] |= ptr[i];
475  }
476  *left++ = j;
477  v->spl_nleft++;
478  }
479  else
480  {
481  if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
482  {
483  if (!ISALLTRUE(datum_r))
484  memset(union_r, 0xff, siglen);
485  }
486  else
487  {
488  ptr = GETSIGN(_j);
489  LOOPBYTE(siglen)
490  union_r[i] |= ptr[i];
491  }
492  *right++ = j;
493  v->spl_nright++;
494  }
495  }
496 
497  *right = *left = FirstOffsetNumber;
498 
499  v->spl_ldatum = PointerGetDatum(datum_l);
500  v->spl_rdatum = PointerGetDatum(datum_r);
501 
503 }
504 
505 
506 Datum
508 {
509  GISTTYPE *entry = (GISTTYPE *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
511 
512  /* Oid subtype = PG_GETARG_OID(3); */
513  bool *recheck = (bool *) PG_GETARG_POINTER(4);
514  int siglen = GET_SIGLEN();
515  bool res = true;
516  BITVECP sign;
517 
518  /* All cases served by this function are inexact */
519  *recheck = true;
520 
521  if (ISALLTRUE(entry))
522  PG_RETURN_BOOL(true);
523 
524  sign = GETSIGN(entry);
525 
526  if (strategy == HStoreContainsStrategyNumber ||
528  {
529  HStore *query = PG_GETARG_HSTORE_P(1);
530  HEntry *qe = ARRPTR(query);
531  char *qv = STRPTR(query);
532  int count = HS_COUNT(query);
533  int i;
534 
535  for (i = 0; res && i < count; ++i)
536  {
537  int crc = crc32_sz((char *) HSTORE_KEY(qe, qv, i),
538  HSTORE_KEYLEN(qe, i));
539 
540  if (GETBIT(sign, HASHVAL(crc, siglen)))
541  {
542  if (!HSTORE_VALISNULL(qe, i))
543  {
544  crc = crc32_sz((char *) HSTORE_VAL(qe, qv, i),
545  HSTORE_VALLEN(qe, i));
546  if (!GETBIT(sign, HASHVAL(crc, siglen)))
547  res = false;
548  }
549  }
550  else
551  res = false;
552  }
553  }
554  else if (strategy == HStoreExistsStrategyNumber)
555  {
556  text *query = PG_GETARG_TEXT_PP(1);
557  int crc = crc32_sz(VARDATA_ANY(query), VARSIZE_ANY_EXHDR(query));
558 
559  res = (GETBIT(sign, HASHVAL(crc, siglen))) ? true : false;
560  }
561  else if (strategy == HStoreExistsAllStrategyNumber)
562  {
563  ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
564  Datum *key_datums;
565  bool *key_nulls;
566  int key_count;
567  int i;
568 
569  deconstruct_array_builtin(query, TEXTOID, &key_datums, &key_nulls, &key_count);
570 
571  for (i = 0; res && i < key_count; ++i)
572  {
573  int crc;
574 
575  if (key_nulls[i])
576  continue;
577  crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ);
578  if (!(GETBIT(sign, HASHVAL(crc, siglen))))
579  res = false;
580  }
581  }
582  else if (strategy == HStoreExistsAnyStrategyNumber)
583  {
584  ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
585  Datum *key_datums;
586  bool *key_nulls;
587  int key_count;
588  int i;
589 
590  deconstruct_array_builtin(query, TEXTOID, &key_datums, &key_nulls, &key_count);
591 
592  res = false;
593 
594  for (i = 0; !res && i < key_count; ++i)
595  {
596  int crc;
597 
598  if (key_nulls[i])
599  continue;
600  crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ);
601  if (GETBIT(sign, HASHVAL(crc, siglen)))
602  res = true;
603  }
604  }
605  else
606  elog(ERROR, "Unsupported strategy number: %d", strategy);
607 
609 }
610 
611 Datum
613 {
615 
616  init_local_reloptions(relopts, sizeof(GistHstoreOptions));
617  add_local_int_reloption(relopts, "siglen",
618  "signature length in bytes",
620  offsetof(GistHstoreOptions, siglen));
621 
622  PG_RETURN_VOID();
623 }
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:256
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3644
signed int int32
Definition: c.h:483
#define VARHDRSZ
Definition: c.h:681
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:387
#define ARRPTR(x)
Definition: cube.c:25
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:272
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:242
#define newval
#define HStoreExistsAllStrategyNumber
Definition: hstore.h:183
#define HStoreExistsStrategyNumber
Definition: hstore.h:181
#define DatumGetHStoreP(d)
Definition: hstore.h:152
#define HS_COUNT(hsp_)
Definition: hstore.h:61
#define HSTORE_KEY(arr_, str_, i_)
Definition: hstore.h:79
#define PG_GETARG_HSTORE_P(x)
Definition: hstore.h:154
#define HStoreOldContainsStrategyNumber
Definition: hstore.h:184
#define HStoreExistsAnyStrategyNumber
Definition: hstore.h:182
#define HStoreContainsStrategyNumber
Definition: hstore.h:180
#define HSTORE_VALISNULL(arr_, i_)
Definition: hstore.h:83
#define HSTORE_VALLEN(arr_, i_)
Definition: hstore.h:82
#define HSTORE_KEYLEN(arr_, i_)
Definition: hstore.h:81
#define HSTORE_VAL(arr_, str_, i_)
Definition: hstore.h:80
#define STRPTR(x)
Definition: hstore.h:76
#define HASHVAL(val, siglen)
Definition: hstore_gist.c:44
Datum ghstore_options(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:612
#define LOOPBYTE(siglen)
Definition: hstore_gist.c:32
#define ALLISTRUE
Definition: hstore_gist.c:54
#define WISH_F(a, b, c)
Definition: hstore_gist.c:76
Datum ghstore_union(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:309
Datum ghstore_picksplit(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:364
#define GETBIT(x, i)
Definition: hstore_gist.c:43
#define LOOPBIT(siglen)
Definition: hstore_gist.c:35
static int hemdist(GISTTYPE *a, GISTTYPE *b, int siglen)
Definition: hstore_gist.c:280
PG_FUNCTION_INFO_V1(ghstore_in)
static int32 sizebitvec(BITVECP sign, int siglen)
Definition: hstore_gist.c:252
static int hemdistsign(BITVECP a, BITVECP b, int siglen)
Definition: hstore_gist.c:266
Datum ghstore_compress(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:147
Datum ghstore_out(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:107
#define CALCGTSIZE(flag, siglen)
Definition: hstore_gist.c:59
#define GETENTRY(vec, pos)
Definition: hstore_gist.c:74
Datum ghstore_consistent(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:507
static int32 unionkey(BITVECP sbase, GISTTYPE *add, int siglen)
Definition: hstore_gist.c:296
static pg_crc32 crc32_sz(char *buf, int size)
Definition: hstore_gist.c:80
#define ISALLTRUE(x)
Definition: hstore_gist.c:56
#define SIGLEN_MAX
Definition: hstore_gist.c:23
#define SIGLEN_DEFAULT
Definition: hstore_gist.c:22
static GISTTYPE * ghstore_alloc(bool allistrue, int siglen, BITVECP sign)
Definition: hstore_gist.c:117
char * BITVECP
Definition: hstore_gist.c:30
#define GET_SIGLEN()
Definition: hstore_gist.c:25
#define SUMBIT(val)
Definition: hstore_gist.c:63
Datum ghstore_penalty(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:336
#define SIGLENBIT(siglen)
Definition: hstore_gist.c:24
Datum ghstore_decompress(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:212
Datum ghstore_in(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:97
Datum ghstore_same(PG_FUNCTION_ARGS)
Definition: hstore_gist.c:218
#define GETSIGN(x)
Definition: hstore_gist.c:61
#define HASH(sign, val, siglen)
Definition: hstore_gist.c:45
static int comparecost(const void *a, const void *b)
Definition: hstore_gist.c:357
long val
Definition: informix.c:664
char sign
Definition: informix.c:668
int b
Definition: isn.c:70
int a
Definition: isn.c:69
int j
Definition: isn.c:74
int i
Definition: isn.c:73
void * palloc(Size size)
Definition: mcxt.c:1226
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
const void size_t len
const void * data
return crc
uint32 pg_crc32
Definition: pg_crc.h:37
#define FIN_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:47
#define INIT_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:46
#define COMP_TRADITIONAL_CRC32(crc, data, len)
Definition: pg_crc.h:48
static char * buf
Definition: pg_test_fsync.c:67
#define qsort(a, b, c, d)
Definition: port.h:445
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
void init_local_reloptions(local_relopts *relopts, Size relopt_struct_size)
Definition: reloptions.c:736
void add_local_int_reloption(local_relopts *relopts, const char *name, const char *desc, int default_val, int min_val, int max_val, int offset)
Definition: reloptions.c:920
uint16 StrategyNumber
Definition: stratnum.h:22
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
int32 flag
Definition: hstore_gist.c:50
int32 vl_len_
Definition: hstore_gist.c:49
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
int32 n
Definition: gist.h:233
Definition: hstore.h:19
Definition: hstore.h:45
int32 cost
Definition: hstore_gist.c:353
OffsetNumber pos
Definition: hstore_gist.c:352
Definition: c.h:676
char * flag(int b)
Definition: test-ctype.c:33
#define VARDATA(PTR)
Definition: varatt.h:278
#define VARDATA_ANY(PTR)
Definition: varatt.h:324
#define SET_VARSIZE(PTR, len)
Definition: varatt.h:305
#define VARSIZE(PTR)
Definition: varatt.h:279
#define VARSIZE_ANY_EXHDR(PTR)
Definition: varatt.h:317