PostgreSQL Source Code  git master
ltree_gist.c File Reference
#include "postgres.h"
#include "access/gist.h"
#include "access/stratnum.h"
#include "crc32.h"
#include "ltree.h"
Include dependency graph for ltree_gist.c:

Go to the source code of this file.

Data Structures

struct  rix
 

Macros

#define NEXTVAL(x)   ( (lquery*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
 
#define ISEQ(a, b)   ( (a)->numlevel == (b)->numlevel && ltree_compare(a,b)==0 )
 
#define GETENTRY(vec, pos)   ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
 

Typedefs

typedef struct rix RIX
 

Functions

 PG_FUNCTION_INFO_V1 (ltree_gist_in)
 
 PG_FUNCTION_INFO_V1 (ltree_gist_out)
 
Datum ltree_gist_in (PG_FUNCTION_ARGS)
 
Datum ltree_gist_out (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (ltree_compress)
 
 PG_FUNCTION_INFO_V1 (ltree_decompress)
 
 PG_FUNCTION_INFO_V1 (ltree_same)
 
 PG_FUNCTION_INFO_V1 (ltree_union)
 
 PG_FUNCTION_INFO_V1 (ltree_penalty)
 
 PG_FUNCTION_INFO_V1 (ltree_picksplit)
 
 PG_FUNCTION_INFO_V1 (ltree_consistent)
 
Datum ltree_compress (PG_FUNCTION_ARGS)
 
Datum ltree_decompress (PG_FUNCTION_ARGS)
 
Datum ltree_same (PG_FUNCTION_ARGS)
 
static void hashing (BITVECP sign, ltree *t)
 
Datum ltree_union (PG_FUNCTION_ARGS)
 
Datum ltree_penalty (PG_FUNCTION_ARGS)
 
static int treekey_cmp (const void *a, const void *b)
 
Datum ltree_picksplit (PG_FUNCTION_ARGS)
 
static bool gist_isparent (ltree_gist *key, ltree *query)
 
static ltreecopy_ltree (ltree *src)
 
static bool gist_ischild (ltree_gist *key, ltree *query)
 
static bool gist_qe (ltree_gist *key, lquery *query)
 
static int gist_tqcmp (ltree *t, lquery *q)
 
static bool gist_between (ltree_gist *key, lquery *query)
 
static bool checkcondition_bit (void *checkval, ITEM *val)
 
static bool gist_qtxt (ltree_gist *key, ltxtquery *query)
 
static bool arrq_cons (ltree_gist *key, ArrayType *_query)
 
Datum ltree_consistent (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ GETENTRY

#define GETENTRY (   vec,
  pos 
)    ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))

Definition at line 45 of file ltree_gist.c.

Referenced by ltree_picksplit(), and ltree_union().

◆ ISEQ

#define ISEQ (   a,
 
)    ( (a)->numlevel == (b)->numlevel && ltree_compare(a,b)==0 )

Definition at line 44 of file ltree_gist.c.

Referenced by ltree_picksplit(), ltree_same(), and ltree_union().

◆ NEXTVAL

#define NEXTVAL (   x)    ( (lquery*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )

Definition at line 13 of file ltree_gist.c.

Referenced by arrq_cons().

Typedef Documentation

◆ RIX

typedef struct rix RIX

Function Documentation

◆ arrq_cons()

static bool arrq_cons ( ltree_gist key,
ArrayType _query 
)
static

Definition at line 578 of file ltree_gist.c.

References ARR_DATA_PTR, ARR_DIMS, ARR_NDIM, array_contains_nulls(), ArrayGetNItems(), ereport, errcode(), errmsg(), ERROR, gist_between(), gist_qe(), and NEXTVAL.

Referenced by ltree_consistent().

579 {
580  lquery *query = (lquery *) ARR_DATA_PTR(_query);
581  int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
582 
583  if (ARR_NDIM(_query) > 1)
584  ereport(ERROR,
585  (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
586  errmsg("array must be one-dimensional")));
587  if (array_contains_nulls(_query))
588  ereport(ERROR,
589  (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
590  errmsg("array must not contain nulls")));
591 
592  while (num > 0)
593  {
594  if (gist_qe(key, query) && gist_between(key, query))
595  return true;
596  num--;
597  query = NEXTVAL(query);
598  }
599  return false;
600 }
Definition: ltree.h:69
int ArrayGetNItems(int ndim, const int *dims)
Definition: arrayutils.c:75
int errcode(int sqlerrcode)
Definition: elog.c:608
#define ERROR
Definition: elog.h:43
#define ARR_DIMS(a)
Definition: array.h:282
#define ARR_DATA_PTR(a)
Definition: array.h:310
#define ereport(elevel, rest)
Definition: elog.h:141
static bool gist_qe(ltree_gist *key, lquery *query)
Definition: ltree_gist.c:478
static bool gist_between(ltree_gist *key, lquery *query)
Definition: ltree_gist.c:546
#define NEXTVAL(x)
Definition: ltree_gist.c:13
#define ARR_NDIM(a)
Definition: array.h:278
int errmsg(const char *fmt,...)
Definition: elog.c:822
bool array_contains_nulls(ArrayType *array)
Definition: arrayfuncs.c:3528

◆ checkcondition_bit()

static bool checkcondition_bit ( void *  checkval,
ITEM val 
)
static

Definition at line 561 of file ltree_gist.c.

References ITEM::flag, FLG_CANLOOKSIGN, GETBIT, HASHVAL, and ITEM::val.

Referenced by gist_qtxt().

562 {
563  return (FLG_CANLOOKSIGN(val->flag)) ? GETBIT(checkval, HASHVAL(val->val)) : true;
564 }
uint8 flag
Definition: ltree.h:96
#define true
Definition: c.h:321
#define GETBIT(x, i)
Definition: blutils.c:33
int32 val
Definition: _int.h:123
#define HASHVAL(val)
Definition: hstore_gist.c:33
#define FLG_CANLOOKSIGN(x)
Definition: ltree.h:65

◆ copy_ltree()

static ltree* copy_ltree ( ltree src)
static

Definition at line 444 of file ltree_gist.c.

References palloc0(), and VARSIZE.

Referenced by gist_ischild().

445 {
446  ltree *dst = (ltree *) palloc0(VARSIZE(src));
447 
448  memcpy(dst, src, VARSIZE(src));
449  return dst;
450 }
#define VARSIZE(PTR)
Definition: postgres.h:303
Definition: ltree.h:19
void * palloc0(Size size)
Definition: mcxt.c:980

◆ gist_between()

static bool gist_between ( ltree_gist key,
lquery query 
)
static

Definition at line 546 of file ltree_gist.c.

References lquery::firstgood, gist_tqcmp(), LTG_GETLNODE, and LTG_GETRNODE.

Referenced by arrq_cons(), and ltree_consistent().

547 {
548  if (query->firstgood == 0)
549  return true;
550 
551  if (gist_tqcmp(LTG_GETLNODE(key), query) > 0)
552  return false;
553 
554  if (gist_tqcmp(LTG_GETRNODE(key), query) < 0)
555  return false;
556 
557  return true;
558 }
uint16 firstgood
Definition: ltree.h:73
#define LTG_GETRNODE(x)
Definition: ltree.h:238
#define LTG_GETLNODE(x)
Definition: ltree.h:237
static int gist_tqcmp(ltree *t, lquery *q)
Definition: ltree_gist.c:517

◆ gist_ischild()

static bool gist_ischild ( ltree_gist key,
ltree query 
)
static

Definition at line 453 of file ltree_gist.c.

References copy_ltree(), LTG_GETLNODE, LTG_GETRNODE, ltree_compare(), ltree::numlevel, and pfree().

Referenced by ltree_consistent().

454 {
455  ltree *left = copy_ltree(LTG_GETLNODE(key));
456  ltree *right = copy_ltree(LTG_GETRNODE(key));
457  bool res = true;
458 
459  if (left->numlevel > query->numlevel)
460  left->numlevel = query->numlevel;
461 
462  if (ltree_compare(query, left) < 0)
463  res = false;
464 
465  if (right->numlevel > query->numlevel)
466  right->numlevel = query->numlevel;
467 
468  if (res && ltree_compare(query, right) > 0)
469  res = false;
470 
471  pfree(left);
472  pfree(right);
473 
474  return res;
475 }
void pfree(void *pointer)
Definition: mcxt.c:1056
static ltree * copy_ltree(ltree *src)
Definition: ltree_gist.c:444
#define LTG_GETRNODE(x)
Definition: ltree.h:238
#define LTG_GETLNODE(x)
Definition: ltree.h:237
Definition: ltree.h:19
uint16 numlevel
Definition: ltree.h:22
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42

◆ gist_isparent()

static bool gist_isparent ( ltree_gist key,
ltree query 
)
static

Definition at line 424 of file ltree_gist.c.

References i, LTG_GETLNODE, LTG_GETRNODE, ltree_compare(), and ltree::numlevel.

Referenced by ltree_consistent().

425 {
426  int32 numlevel = query->numlevel;
427  int i;
428 
429  for (i = query->numlevel; i >= 0; i--)
430  {
431  query->numlevel = i;
432  if (ltree_compare(query, LTG_GETLNODE(key)) >= 0 && ltree_compare(query, LTG_GETRNODE(key)) <= 0)
433  {
434  query->numlevel = numlevel;
435  return true;
436  }
437  }
438 
439  query->numlevel = numlevel;
440  return false;
441 }
signed int int32
Definition: c.h:355
#define LTG_GETRNODE(x)
Definition: ltree.h:238
#define LTG_GETLNODE(x)
Definition: ltree.h:237
uint16 numlevel
Definition: ltree.h:22
int i
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42

◆ gist_qe()

static bool gist_qe ( ltree_gist key,
lquery query 
)
static

Definition at line 478 of file ltree_gist.c.

References GETBIT, HASHVAL, LQL_CANLOOKSIGN, LQL_FIRST, LQL_NEXT, LQUERY_FIRST, LTG_ISALLTRUE, LTG_SIGN, LVAR_NEXT, lquery::numlevel, lquery_level::numvar, sign, and lquery_variant::val.

Referenced by arrq_cons(), and ltree_consistent().

479 {
480  lquery_level *curq = LQUERY_FIRST(query);
481  BITVECP sign = LTG_SIGN(key);
482  int qlen = query->numlevel;
483 
484  if (LTG_ISALLTRUE(key))
485  return true;
486 
487  while (qlen > 0)
488  {
489  if (curq->numvar && LQL_CANLOOKSIGN(curq))
490  {
491  bool isexist = false;
492  int vlen = curq->numvar;
493  lquery_variant *curv = LQL_FIRST(curq);
494 
495  while (vlen > 0)
496  {
497  if (GETBIT(sign, HASHVAL(curv->val)))
498  {
499  isexist = true;
500  break;
501  }
502  curv = LVAR_NEXT(curv);
503  vlen--;
504  }
505  if (!isexist)
506  return false;
507  }
508 
509  curq = LQL_NEXT(curq);
510  qlen--;
511  }
512 
513  return true;
514 }
#define LQUERY_FIRST(x)
Definition: ltree.h:79
#define LTG_ISALLTRUE(x)
Definition: ltree.h:231
#define LTG_SIGN(x)
Definition: ltree.h:228
#define LQL_FIRST(x)
Definition: ltree.h:59
#define LQL_NEXT(x)
Definition: ltree.h:58
#define LVAR_NEXT(x)
Definition: ltree.h:41
#define GETBIT(x, i)
Definition: blutils.c:33
char sign
Definition: informix.c:668
#define HASHVAL(val)
Definition: hstore_gist.c:33
int32 val
Definition: ltree.h:34
uint16 numlevel
Definition: ltree.h:72
uint16 numvar
Definition: ltree.h:51
char * BITVECP
Definition: hstore_gist.c:19
#define LQL_CANLOOKSIGN(x)
Definition: ltree.h:67

◆ gist_qtxt()

static bool gist_qtxt ( ltree_gist key,
ltxtquery query 
)
static

Definition at line 567 of file ltree_gist.c.

References checkcondition_bit(), GETQUERY, LTG_ISALLTRUE, LTG_SIGN, and ltree_execute().

Referenced by ltree_consistent().

568 {
569  if (LTG_ISALLTRUE(key))
570  return true;
571 
572  return ltree_execute(GETQUERY(query),
573  (void *) LTG_SIGN(key), false,
575 }
#define LTG_ISALLTRUE(x)
Definition: ltree.h:231
#define LTG_SIGN(x)
Definition: ltree.h:228
#define GETQUERY(x)
Definition: _int.h:136
bool ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val))
Definition: ltxtquery_op.c:20
static bool checkcondition_bit(void *checkval, ITEM *val)
Definition: ltree_gist.c:561

◆ gist_tqcmp()

static int gist_tqcmp ( ltree t,
lquery q 
)
static

Definition at line 517 of file ltree_gist.c.

References lquery::firstgood, ltree_level::len, lquery_variant::len, LEVEL_NEXT, LQL_FIRST, LQL_NEXT, LQUERY_FIRST, LTREE_FIRST, Min, ltree_level::name, lquery_variant::name, and ltree::numlevel.

Referenced by gist_between().

518 {
519  ltree_level *al = LTREE_FIRST(t);
520  lquery_level *ql = LQUERY_FIRST(q);
521  lquery_variant *bl;
522  int an = t->numlevel;
523  int bn = q->firstgood;
524  int res = 0;
525 
526  while (an > 0 && bn > 0)
527  {
528  bl = LQL_FIRST(ql);
529  if ((res = memcmp(al->name, bl->name, Min(al->len, bl->len))) == 0)
530  {
531  if (al->len != bl->len)
532  return al->len - bl->len;
533  }
534  else
535  return res;
536  an--;
537  bn--;
538  al = LEVEL_NEXT(al);
539  ql = LQL_NEXT(ql);
540  }
541 
542  return Min(t->numlevel, q->firstgood) - q->firstgood;
543 }
uint16 firstgood
Definition: ltree.h:73
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: ltree.h:13
#define LQUERY_FIRST(x)
Definition: ltree.h:79
uint16 len
Definition: ltree.h:35
uint16 len
Definition: ltree.h:12
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: ltree.h:37
#define Min(x, y)
Definition: c.h:920
#define LQL_FIRST(x)
Definition: ltree.h:59
#define LQL_NEXT(x)
Definition: ltree.h:58
#define LEVEL_NEXT(x)
Definition: ltree.h:17
uint16 numlevel
Definition: ltree.h:22
#define LTREE_FIRST(x)
Definition: ltree.h:27

◆ hashing()

static void hashing ( BITVECP  sign,
ltree t 
)
static

Definition at line 135 of file ltree_gist.c.

References cur, HASH, hash(), ltree_level::len, LEVEL_NEXT, ltree_crc32_sz(), LTREE_FIRST, ltree_level::name, and ltree::numlevel.

Referenced by ltree_picksplit(), and ltree_union().

136 {
137  int tlen = t->numlevel;
139  int hash;
140 
141  while (tlen > 0)
142  {
143  hash = ltree_crc32_sz(cur->name, cur->len);
144  HASH(sign, hash);
145  cur = LEVEL_NEXT(cur);
146  tlen--;
147  }
148 }
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: ltree.h:13
uint16 len
Definition: ltree.h:12
struct cursor * cur
Definition: ecpg.c:28
#define HASH(sign, val)
Definition: hstore_gist.c:34
unsigned int ltree_crc32_sz(char *buf, int size)
Definition: crc32.c:23
char sign
Definition: informix.c:668
#define LEVEL_NEXT(x)
Definition: ltree.h:17
uint16 numlevel
Definition: ltree.h:22
#define LTREE_FIRST(x)
Definition: ltree.h:27
static unsigned hash(unsigned *uv, int n)
Definition: rege_dfa.c:541

◆ ltree_compress()

Datum ltree_compress ( PG_FUNCTION_ARGS  )

Definition at line 48 of file ltree_gist.c.

References DatumGetLtreeP, ltree_gist::flag, gistentryinit, sort-test::key, GISTENTRY::key, GISTENTRY::leafkey, LTG_HDRSIZE, LTG_NODE, LTG_ONENODE, GISTENTRY::offset, GISTENTRY::page, palloc(), palloc0(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum, GISTENTRY::rel, SET_VARSIZE, val, and VARSIZE.

Referenced by ltree_gist_out().

49 {
50  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
51  GISTENTRY *retval = entry;
52 
53  if (entry->leafkey)
54  { /* ltree */
55  ltree_gist *key;
56  ltree *val = DatumGetLtreeP(entry->key);
57  int32 len = LTG_HDRSIZE + VARSIZE(val);
58 
59  key = (ltree_gist *) palloc0(len);
60  SET_VARSIZE(key, len);
61  key->flag = LTG_ONENODE;
62  memcpy((void *) LTG_NODE(key), (void *) val, VARSIZE(val));
63 
64  retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
65  gistentryinit(*retval, PointerGetDatum(key),
66  entry->rel, entry->page,
67  entry->offset, false);
68  }
69  PG_RETURN_POINTER(retval);
70 }
Relation rel
Definition: gist.h:132
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define VARSIZE(PTR)
Definition: postgres.h:303
#define PointerGetDatum(X)
Definition: postgres.h:556
uint32 flag
Definition: ltree.h:219
#define LTG_NODE(x)
Definition: ltree.h:229
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
signed int int32
Definition: c.h:355
Page page
Definition: gist.h:133
Datum key
Definition: gist.h:131
Definition: ltree.h:19
bool leafkey
Definition: gist.h:135
#define DatumGetLtreeP(X)
Definition: ltree.h:169
void * palloc0(Size size)
Definition: mcxt.c:980
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:215
void * palloc(Size size)
Definition: mcxt.c:949
#define LTG_ONENODE
Definition: ltree.h:223
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
#define LTG_HDRSIZE
Definition: ltree.h:227
OffsetNumber offset
Definition: gist.h:134
long val
Definition: informix.c:664

◆ ltree_consistent()

Datum ltree_consistent ( PG_FUNCTION_ARGS  )

Definition at line 603 of file ltree_gist.c.

References arrq_cons(), BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, DatumGetBool, DatumGetPointer, DirectFunctionCall2, elog, ERROR, gist_between(), gist_ischild(), gist_isparent(), GIST_LEAF, gist_qe(), gist_qtxt(), inner_isparent(), sort-test::key, GISTENTRY::key, lt_q_regex(), LTG_GETLNODE, LTG_GETRNODE, LTG_NODE, ltq_regex(), ltree_compare(), ltxtq_exec(), PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LQUERY_P, PG_GETARG_LTREE_P, PG_GETARG_LTREE_P_COPY, PG_GETARG_LTXTQUERY_P, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and PointerGetDatum.

Referenced by ltree_gist_out().

604 {
605  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
607 
608  /* Oid subtype = PG_GETARG_OID(3); */
609  bool *recheck = (bool *) PG_GETARG_POINTER(4);
611  void *query = NULL;
612  bool res = false;
613 
614  /* All cases served by this function are exact */
615  *recheck = false;
616 
617  switch (strategy)
618  {
620  query = PG_GETARG_LTREE_P(1);
621  res = (GIST_LEAF(entry)) ?
622  (ltree_compare((ltree *) query, LTG_NODE(key)) > 0)
623  :
624  (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
625  break;
627  query = PG_GETARG_LTREE_P(1);
628  res = (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
629  break;
631  query = PG_GETARG_LTREE_P(1);
632  if (GIST_LEAF(entry))
633  res = (ltree_compare((ltree *) query, LTG_NODE(key)) == 0);
634  else
635  res = (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0
636  &&
637  ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
638  break;
640  query = PG_GETARG_LTREE_P(1);
641  res = (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
642  break;
644  query = PG_GETARG_LTREE_P(1);
645  res = (GIST_LEAF(entry)) ?
646  (ltree_compare((ltree *) query, LTG_GETRNODE(key)) < 0)
647  :
648  (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
649  break;
650  case 10:
651  query = PG_GETARG_LTREE_P_COPY(1);
652  res = (GIST_LEAF(entry)) ?
653  inner_isparent((ltree *) query, LTG_NODE(key))
654  :
655  gist_isparent(key, (ltree *) query);
656  break;
657  case 11:
658  query = PG_GETARG_LTREE_P(1);
659  res = (GIST_LEAF(entry)) ?
660  inner_isparent(LTG_NODE(key), (ltree *) query)
661  :
662  gist_ischild(key, (ltree *) query);
663  break;
664  case 12:
665  case 13:
666  query = PG_GETARG_LQUERY_P(1);
667  if (GIST_LEAF(entry))
670  PointerGetDatum((lquery *) query)
671  ));
672  else
673  res = (gist_qe(key, (lquery *) query) && gist_between(key, (lquery *) query));
674  break;
675  case 14:
676  case 15:
677  query = PG_GETARG_LTXTQUERY_P(1);
678  if (GIST_LEAF(entry))
681  PointerGetDatum((ltxtquery *) query)
682  ));
683  else
684  res = gist_qtxt(key, (ltxtquery *) query);
685  break;
686  case 16:
687  case 17:
688  query = PG_GETARG_ARRAYTYPE_P(1);
689  if (GIST_LEAF(entry))
692  PointerGetDatum((ArrayType *) query)
693  ));
694  else
695  res = arrq_cons(key, (ArrayType *) query);
696  break;
697  default:
698  /* internal error */
699  elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
700  }
701 
702  PG_FREE_IF_COPY(query, 1);
703  PG_RETURN_BOOL(res);
704 }
#define GIST_LEAF(entry)
Definition: gist.h:141
#define PG_GETARG_LTREE_P_COPY(n)
Definition: ltree.h:172
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define PointerGetDatum(X)
Definition: postgres.h:556
bool inner_isparent(const ltree *c, const ltree *p)
Definition: ltree_op.c:143
Definition: ltree.h:69
static bool gist_ischild(ltree_gist *key, ltree *query)
Definition: ltree_gist.c:453
uint16 StrategyNumber
Definition: stratnum.h:22
#define LTG_NODE(x)
Definition: ltree.h:229
#define PG_GETARG_LTREE_P(n)
Definition: ltree.h:171
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static bool gist_isparent(ltree_gist *key, ltree *query)
Definition: ltree_gist.c:424
#define PG_GETARG_LQUERY_P(n)
Definition: ltree.h:176
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:251
static bool arrq_cons(ltree_gist *key, ArrayType *_query)
Definition: ltree_gist.c:578
#define ERROR
Definition: elog.h:43
#define LTG_GETRNODE(x)
Definition: ltree.h:238
#define LTG_GETLNODE(x)
Definition: ltree.h:237
Datum ltq_regex(PG_FUNCTION_ARGS)
Definition: lquery_op.c:296
Datum key
Definition: gist.h:131
#define DatumGetBool(X)
Definition: postgres.h:393
Definition: ltree.h:19
Datum lt_q_regex(PG_FUNCTION_ARGS)
Definition: lquery_op.c:332
static bool gist_qe(ltree_gist *key, lquery *query)
Definition: ltree_gist.c:478
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:349
static bool gist_between(ltree_gist *key, lquery *query)
Definition: ltree_gist.c:546
Datum ltxtq_exec(PG_FUNCTION_ARGS)
Definition: ltxtquery_op.c:84
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:255
#define PG_GETARG_LTXTQUERY_P(n)
Definition: ltree.h:181
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:267
#define DatumGetPointer(X)
Definition: postgres.h:549
#define elog(elevel,...)
Definition: elog.h:228
static bool gist_qtxt(ltree_gist *key, ltxtquery *query)
Definition: ltree_gist.c:567
#define BTLessStrategyNumber
Definition: stratnum.h:29
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define BTGreaterEqualStrategyNumber
Definition: stratnum.h:32

◆ ltree_decompress()

Datum ltree_decompress ( PG_FUNCTION_ARGS  )

Definition at line 73 of file ltree_gist.c.

References gistentryinit, sort-test::key, GISTENTRY::key, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_DETOAST_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum, and GISTENTRY::rel.

Referenced by ltree_gist_out().

74 {
75  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
77 
78  if (PointerGetDatum(key) != entry->key)
79  {
80  GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
81 
82  gistentryinit(*retval, PointerGetDatum(key),
83  entry->rel, entry->page,
84  entry->offset, false);
85  PG_RETURN_POINTER(retval);
86  }
87  PG_RETURN_POINTER(entry);
88 }
Relation rel
Definition: gist.h:132
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PointerGetDatum(X)
Definition: postgres.h:556
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
Page page
Definition: gist.h:133
Datum key
Definition: gist.h:131
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:215
void * palloc(Size size)
Definition: mcxt.c:949
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:235
OffsetNumber offset
Definition: gist.h:134

◆ ltree_gist_in()

Datum ltree_gist_in ( PG_FUNCTION_ARGS  )

Definition at line 19 of file ltree_gist.c.

References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_DATUM.

20 {
21  ereport(ERROR,
22  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
23  errmsg("ltree_gist_in() not implemented")));
24  PG_RETURN_DATUM(0);
25 }
int errcode(int sqlerrcode)
Definition: elog.c:608
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:343
int errmsg(const char *fmt,...)
Definition: elog.c:822

◆ ltree_gist_out()

Datum ltree_gist_out ( PG_FUNCTION_ARGS  )

Definition at line 28 of file ltree_gist.c.

References ereport, errcode(), errmsg(), ERROR, ltree_compress(), ltree_consistent(), ltree_decompress(), ltree_penalty(), ltree_picksplit(), ltree_same(), ltree_union(), PG_FUNCTION_INFO_V1(), and PG_RETURN_DATUM.

29 {
30  ereport(ERROR,
31  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
32  errmsg("ltree_gist_out() not implemented")));
33  PG_RETURN_DATUM(0);
34 }
int errcode(int sqlerrcode)
Definition: elog.c:608
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:343
int errmsg(const char *fmt,...)
Definition: elog.c:822

◆ ltree_penalty()

Datum ltree_penalty ( PG_FUNCTION_ARGS  )

Definition at line 235 of file ltree_gist.c.

References DatumGetPointer, sort-test::key, LTG_GETLNODE, LTG_GETRNODE, ltree_compare(), Max, newval, PG_GETARG_POINTER, and PG_RETURN_POINTER.

Referenced by ltree_gist_out().

236 {
237  ltree_gist *origval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
239  float *penalty = (float *) PG_GETARG_POINTER(2);
240  int32 cmpr,
241  cmpl;
242 
243  cmpl = ltree_compare(LTG_GETLNODE(origval), LTG_GETLNODE(newval));
244  cmpr = ltree_compare(LTG_GETRNODE(newval), LTG_GETRNODE(origval));
245 
246  *penalty = Max(cmpl, 0) + Max(cmpr, 0);
247 
248  PG_RETURN_POINTER(penalty);
249 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
signed int int32
Definition: c.h:355
#define LTG_GETRNODE(x)
Definition: ltree.h:238
#define LTG_GETLNODE(x)
Definition: ltree.h:237
#define Max(x, y)
Definition: c.h:914
#define newval
#define DatumGetPointer(X)
Definition: postgres.h:549
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42

◆ ltree_picksplit()

Datum ltree_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 267 of file ltree_gist.c.

References FirstOffsetNumber, ltree_gist::flag, GETENTRY, hashing(), i, rix::index, ISEQ, LOOPBYTE, LTG_ALLTRUE, LTG_GETLNODE, LTG_GETRNODE, LTG_HDRSIZE, LTG_ISALLTRUE, LTG_ISONENODE, LTG_LNODE, LTG_NODE, LTG_NORIGHT, LTG_RNODE, LTG_SIGN, ltree_compare(), GistEntryVector::n, OffsetNumberNext, palloc(), palloc0(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum, qsort, rix::r, SET_VARSIZE, SIGLEN, GIST_SPLITVEC::spl_ldatum, GIST_SPLITVEC::spl_left, GIST_SPLITVEC::spl_nleft, GIST_SPLITVEC::spl_nright, GIST_SPLITVEC::spl_rdatum, GIST_SPLITVEC::spl_right, treekey_cmp(), and VARSIZE.

Referenced by ltree_gist_out().

268 {
271  OffsetNumber j;
272  int32 i;
273  RIX *array;
274  OffsetNumber maxoff;
275  int nbytes;
276  int size;
277  ltree *lu_l,
278  *lu_r,
279  *ru_l,
280  *ru_r;
281  ltree_gist *lu,
282  *ru;
283  BITVEC ls,
284  rs;
285  bool lisat = false,
286  risat = false,
287  isleqr;
288 
289  memset((void *) ls, 0, sizeof(BITVEC));
290  memset((void *) rs, 0, sizeof(BITVEC));
291  maxoff = entryvec->n - 1;
292  nbytes = (maxoff + 2) * sizeof(OffsetNumber);
293  v->spl_left = (OffsetNumber *) palloc(nbytes);
294  v->spl_right = (OffsetNumber *) palloc(nbytes);
295  v->spl_nleft = 0;
296  v->spl_nright = 0;
297  array = (RIX *) palloc(sizeof(RIX) * (maxoff + 1));
298 
299  /* copy the data into RIXes, and sort the RIXes */
300  for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
301  {
302  array[j].index = j;
303  lu = GETENTRY(entryvec, j); /* use as tmp val */
304  array[j].r = LTG_GETLNODE(lu);
305  }
306 
307  qsort((void *) &array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1,
308  sizeof(RIX), treekey_cmp);
309 
310  lu_l = lu_r = ru_l = ru_r = NULL;
311  for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
312  {
313  lu = GETENTRY(entryvec, array[j].index); /* use as tmp val */
314  if (j <= (maxoff - FirstOffsetNumber + 1) / 2)
315  {
316  v->spl_left[v->spl_nleft] = array[j].index;
317  v->spl_nleft++;
318  if (lu_r == NULL || ltree_compare(LTG_GETRNODE(lu), lu_r) > 0)
319  lu_r = LTG_GETRNODE(lu);
320  if (LTG_ISONENODE(lu))
321  hashing(ls, LTG_NODE(lu));
322  else
323  {
324  if (lisat || LTG_ISALLTRUE(lu))
325  lisat = true;
326  else
327  {
328  BITVECP sc = LTG_SIGN(lu);
329 
330  LOOPBYTE
331  ((unsigned char *) ls)[i] |= sc[i];
332  }
333  }
334  }
335  else
336  {
337  v->spl_right[v->spl_nright] = array[j].index;
338  v->spl_nright++;
339  if (ru_r == NULL || ltree_compare(LTG_GETRNODE(lu), ru_r) > 0)
340  ru_r = LTG_GETRNODE(lu);
341  if (LTG_ISONENODE(lu))
342  hashing(rs, LTG_NODE(lu));
343  else
344  {
345  if (risat || LTG_ISALLTRUE(lu))
346  risat = true;
347  else
348  {
349  BITVECP sc = LTG_SIGN(lu);
350 
351  LOOPBYTE
352  ((unsigned char *) rs)[i] |= sc[i];
353  }
354  }
355  }
356  }
357 
358  if (lisat == false)
359  {
360  lisat = true;
361  LOOPBYTE
362  {
363  if (((unsigned char *) ls)[i] != 0xff)
364  {
365  lisat = false;
366  break;
367  }
368  }
369  }
370 
371  if (risat == false)
372  {
373  risat = true;
374  LOOPBYTE
375  {
376  if (((unsigned char *) rs)[i] != 0xff)
377  {
378  risat = false;
379  break;
380  }
381  }
382  }
383 
384  lu_l = LTG_GETLNODE(GETENTRY(entryvec, array[FirstOffsetNumber].index));
385  isleqr = (lu_l == lu_r || ISEQ(lu_l, lu_r)) ? true : false;
386  size = LTG_HDRSIZE + ((lisat) ? 0 : SIGLEN) + VARSIZE(lu_l) + ((isleqr) ? 0 : VARSIZE(lu_r));
387  lu = (ltree_gist *) palloc0(size);
388  SET_VARSIZE(lu, size);
389  lu->flag = 0;
390  if (lisat)
391  lu->flag |= LTG_ALLTRUE;
392  else
393  memcpy((void *) LTG_SIGN(lu), ls, SIGLEN);
394  memcpy((void *) LTG_LNODE(lu), (void *) lu_l, VARSIZE(lu_l));
395  if (isleqr)
396  lu->flag |= LTG_NORIGHT;
397  else
398  memcpy((void *) LTG_RNODE(lu), (void *) lu_r, VARSIZE(lu_r));
399 
400 
401  ru_l = LTG_GETLNODE(GETENTRY(entryvec, array[1 + ((maxoff - FirstOffsetNumber + 1) / 2)].index));
402  isleqr = (ru_l == ru_r || ISEQ(ru_l, ru_r)) ? true : false;
403  size = LTG_HDRSIZE + ((risat) ? 0 : SIGLEN) + VARSIZE(ru_l) + ((isleqr) ? 0 : VARSIZE(ru_r));
404  ru = (ltree_gist *) palloc0(size);
405  SET_VARSIZE(ru, size);
406  ru->flag = 0;
407  if (risat)
408  ru->flag |= LTG_ALLTRUE;
409  else
410  memcpy((void *) LTG_SIGN(ru), rs, SIGLEN);
411  memcpy((void *) LTG_LNODE(ru), (void *) ru_l, VARSIZE(ru_l));
412  if (isleqr)
413  ru->flag |= LTG_NORIGHT;
414  else
415  memcpy((void *) LTG_RNODE(ru), (void *) ru_r, VARSIZE(ru_r));
416 
417  v->spl_ldatum = PointerGetDatum(lu);
418  v->spl_rdatum = PointerGetDatum(ru);
419 
421 }
static void hashing(BITVECP sign, ltree *t)
Definition: ltree_gist.c:135
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
ltree * r
Definition: ltree_gist.c:255
#define LTG_ISALLTRUE(x)
Definition: ltree.h:231
#define VARSIZE(PTR)
Definition: postgres.h:303
#define PointerGetDatum(X)
Definition: postgres.h:556
#define LTG_SIGN(x)
Definition: ltree.h:228
uint32 flag
Definition: ltree.h:219
OffsetNumber * spl_left
Definition: gist.h:113
Datum spl_rdatum
Definition: gist.h:120
int32 n
Definition: gist.h:206
#define LTG_NODE(x)
Definition: ltree.h:229
#define LTG_RNODE(x)
Definition: ltree.h:235
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define LTG_NORIGHT
Definition: ltree.h:225
int spl_nleft
Definition: gist.h:114
signed int int32
Definition: c.h:355
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
#define LTG_GETRNODE(x)
Definition: ltree.h:238
int spl_nright
Definition: gist.h:119
#define LTG_GETLNODE(x)
Definition: ltree.h:237
char BITVEC[SIGLEN]
Definition: hstore_gist.c:18
#define FirstOffsetNumber
Definition: off.h:27
#define LTG_ALLTRUE
Definition: ltree.h:224
static int treekey_cmp(const void *a, const void *b)
Definition: ltree_gist.c:259
#define GETENTRY(vec, pos)
Definition: ltree_gist.c:45
Definition: ltree.h:19
#define ISEQ(a, b)
Definition: ltree_gist.c:44
void * palloc0(Size size)
Definition: mcxt.c:980
#define LTG_LNODE(x)
Definition: ltree.h:233
#define LTG_ISONENODE(x)
Definition: ltree.h:230
Datum spl_ldatum
Definition: gist.h:115
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
OffsetNumber * spl_right
Definition: gist.h:118
void * palloc(Size size)
Definition: mcxt.c:949
#define LOOPBYTE
Definition: hstore_gist.c:21
int i
#define SIGLEN
Definition: hstore_gist.c:15
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
char * BITVECP
Definition: hstore_gist.c:19
#define qsort(a, b, c, d)
Definition: port.h:474
#define LTG_HDRSIZE
Definition: ltree.h:227
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42
int index
Definition: ltree_gist.c:254

◆ ltree_same()

Datum ltree_same ( PG_FUNCTION_ARGS  )

Definition at line 91 of file ltree_gist.c.

References i, ISEQ, LOOPBYTE, LTG_ISALLTRUE, LTG_ISONENODE, LTG_LNODE, LTG_NODE, LTG_RNODE, LTG_SIGN, PG_GETARG_POINTER, and PG_RETURN_POINTER.

Referenced by ltree_gist_out().

92 {
95  bool *result = (bool *) PG_GETARG_POINTER(2);
96 
97  *result = false;
98  if (LTG_ISONENODE(a) != LTG_ISONENODE(b))
99  PG_RETURN_POINTER(result);
100 
101  if (LTG_ISONENODE(a))
102  *result = (ISEQ(LTG_NODE(a), LTG_NODE(b))) ? true : false;
103  else
104  {
105  int32 i;
106  BITVECP sa = LTG_SIGN(a),
107  sb = LTG_SIGN(b);
108 
109  if (LTG_ISALLTRUE(a) != LTG_ISALLTRUE(b))
110  PG_RETURN_POINTER(result);
111 
112  if (!ISEQ(LTG_LNODE(a), LTG_LNODE(b)))
113  PG_RETURN_POINTER(result);
114  if (!ISEQ(LTG_RNODE(a), LTG_RNODE(b)))
115  PG_RETURN_POINTER(result);
116 
117  *result = true;
118  if (!LTG_ISALLTRUE(a))
119  {
120  LOOPBYTE
121  {
122  if (sa[i] != sb[i])
123  {
124  *result = false;
125  break;
126  }
127  }
128  }
129  }
130 
131  PG_RETURN_POINTER(result);
132 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define LTG_ISALLTRUE(x)
Definition: ltree.h:231
#define LTG_SIGN(x)
Definition: ltree.h:228
#define LTG_NODE(x)
Definition: ltree.h:229
#define LTG_RNODE(x)
Definition: ltree.h:235
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
signed int int32
Definition: c.h:355
#define ISEQ(a, b)
Definition: ltree_gist.c:44
#define LTG_LNODE(x)
Definition: ltree.h:233
#define LTG_ISONENODE(x)
Definition: ltree.h:230
#define LOOPBYTE
Definition: hstore_gist.c:21
int i
char * BITVECP
Definition: hstore_gist.c:19

◆ ltree_union()

Datum ltree_union ( PG_FUNCTION_ARGS  )

Definition at line 151 of file ltree_gist.c.

References cur, ltree_gist::flag, GETENTRY, hashing(), i, ISEQ, LOOPBYTE, LTG_ALLTRUE, LTG_HDRSIZE, LTG_ISALLTRUE, LTG_ISONENODE, LTG_LNODE, LTG_NODE, LTG_NORIGHT, LTG_RNODE, LTG_SIGN, ltree_compare(), MemSet, GistEntryVector::n, palloc0(), PG_GETARG_POINTER, PG_RETURN_POINTER, SET_VARSIZE, SIGLEN, and VARSIZE.

Referenced by ltree_gist_out().

152 {
154  int *size = (int *) PG_GETARG_POINTER(1);
155  BITVEC base;
156  int32 i,
157  j;
158  ltree_gist *result,
159  *cur;
160  ltree *left = NULL,
161  *right = NULL,
162  *curtree;
163  bool isalltrue = false;
164  bool isleqr;
165 
166  MemSet((void *) base, 0, sizeof(BITVEC));
167  for (j = 0; j < entryvec->n; j++)
168  {
169  cur = GETENTRY(entryvec, j);
170  if (LTG_ISONENODE(cur))
171  {
172  curtree = LTG_NODE(cur);
173  hashing(base, curtree);
174  if (!left || ltree_compare(left, curtree) > 0)
175  left = curtree;
176  if (!right || ltree_compare(right, curtree) < 0)
177  right = curtree;
178  }
179  else
180  {
181  if (isalltrue || LTG_ISALLTRUE(cur))
182  isalltrue = true;
183  else
184  {
185  BITVECP sc = LTG_SIGN(cur);
186 
187  LOOPBYTE
188  ((unsigned char *) base)[i] |= sc[i];
189  }
190 
191  curtree = LTG_LNODE(cur);
192  if (!left || ltree_compare(left, curtree) > 0)
193  left = curtree;
194  curtree = LTG_RNODE(cur);
195  if (!right || ltree_compare(right, curtree) < 0)
196  right = curtree;
197  }
198  }
199 
200  if (isalltrue == false)
201  {
202  isalltrue = true;
203  LOOPBYTE
204  {
205  if (((unsigned char *) base)[i] != 0xff)
206  {
207  isalltrue = false;
208  break;
209  }
210  }
211  }
212 
213  isleqr = (left == right || ISEQ(left, right)) ? true : false;
214  *size = LTG_HDRSIZE + ((isalltrue) ? 0 : SIGLEN) + VARSIZE(left) + ((isleqr) ? 0 : VARSIZE(right));
215 
216  result = (ltree_gist *) palloc0(*size);
217  SET_VARSIZE(result, *size);
218  result->flag = 0;
219 
220  if (isalltrue)
221  result->flag |= LTG_ALLTRUE;
222  else
223  memcpy((void *) LTG_SIGN(result), base, SIGLEN);
224 
225  memcpy((void *) LTG_LNODE(result), (void *) left, VARSIZE(left));
226  if (isleqr)
227  result->flag |= LTG_NORIGHT;
228  else
229  memcpy((void *) LTG_RNODE(result), (void *) right, VARSIZE(right));
230 
231  PG_RETURN_POINTER(result);
232 }
static void hashing(BITVECP sign, ltree *t)
Definition: ltree_gist.c:135
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define LTG_ISALLTRUE(x)
Definition: ltree.h:231
#define VARSIZE(PTR)
Definition: postgres.h:303
#define LTG_SIGN(x)
Definition: ltree.h:228
uint32 flag
Definition: ltree.h:219
int32 n
Definition: gist.h:206
struct cursor * cur
Definition: ecpg.c:28
#define LTG_NODE(x)
Definition: ltree.h:229
#define LTG_RNODE(x)
Definition: ltree.h:235
#define MemSet(start, val, len)
Definition: c.h:971
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define LTG_NORIGHT
Definition: ltree.h:225
signed int int32
Definition: c.h:355
char BITVEC[SIGLEN]
Definition: hstore_gist.c:18
#define LTG_ALLTRUE
Definition: ltree.h:224
#define GETENTRY(vec, pos)
Definition: ltree_gist.c:45
Definition: ltree.h:19
#define ISEQ(a, b)
Definition: ltree_gist.c:44
void * palloc0(Size size)
Definition: mcxt.c:980
#define LTG_LNODE(x)
Definition: ltree.h:233
#define LTG_ISONENODE(x)
Definition: ltree.h:230
#define LOOPBYTE
Definition: hstore_gist.c:21
int i
#define SIGLEN
Definition: hstore_gist.c:15
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
char * BITVECP
Definition: hstore_gist.c:19
#define LTG_HDRSIZE
Definition: ltree.h:227
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42

◆ PG_FUNCTION_INFO_V1() [1/9]

PG_FUNCTION_INFO_V1 ( ltree_gist_in  )

Referenced by ltree_gist_out().

◆ PG_FUNCTION_INFO_V1() [2/9]

PG_FUNCTION_INFO_V1 ( ltree_gist_out  )

◆ PG_FUNCTION_INFO_V1() [3/9]

PG_FUNCTION_INFO_V1 ( ltree_compress  )

◆ PG_FUNCTION_INFO_V1() [4/9]

PG_FUNCTION_INFO_V1 ( ltree_decompress  )

◆ PG_FUNCTION_INFO_V1() [5/9]

PG_FUNCTION_INFO_V1 ( ltree_same  )

◆ PG_FUNCTION_INFO_V1() [6/9]

PG_FUNCTION_INFO_V1 ( ltree_union  )

◆ PG_FUNCTION_INFO_V1() [7/9]

PG_FUNCTION_INFO_V1 ( ltree_penalty  )

◆ PG_FUNCTION_INFO_V1() [8/9]

PG_FUNCTION_INFO_V1 ( ltree_picksplit  )

◆ PG_FUNCTION_INFO_V1() [9/9]

PG_FUNCTION_INFO_V1 ( ltree_consistent  )

◆ treekey_cmp()

static int treekey_cmp ( const void *  a,
const void *  b 
)
static

Definition at line 259 of file ltree_gist.c.

References ltree_compare(), and rix::r.

Referenced by ltree_picksplit().

260 {
261  return ltree_compare(((const RIX *) a)->r,
262  ((const RIX *) b)->r);
263 }
int ltree_compare(const ltree *a, const ltree *b)
Definition: ltree_op.c:42