PostgreSQL Source Code  git master
btree_enum.c File Reference
#include "postgres.h"
#include "fmgr.h"
#include "utils/builtins.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
Include dependency graph for btree_enum.c:

Go to the source code of this file.

Data Structures

struct  oidKEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_enum_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_union)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_enum_same)
 
static bool gbt_enumgt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumeq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumle (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_enumlt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_enumkey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
Datum gbt_enum_compress (PG_FUNCTION_ARGS)
 
Datum gbt_enum_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_enum_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_enum_union (PG_FUNCTION_ARGS)
 
Datum gbt_enum_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_enum_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_enum_same (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Function Documentation

◆ gbt_enum_compress()

Datum gbt_enum_compress ( PG_FUNCTION_ARGS  )

Definition at line 107 of file btree_enum.c.

References gbt_num_compress(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

108 {
109  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
110 
112 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)

◆ gbt_enum_consistent()

Datum gbt_enum_consistent ( PG_FUNCTION_ARGS  )

Definition at line 123 of file btree_enum.c.

References DatumGetPointer, gbt_num_consistent(), GIST_LEAF, sort-test::key, GISTENTRY::key, oidKEY::lower, GBT_NUMKEY_R::lower, PG_GETARG_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, oidKEY::upper, and GBT_NUMKEY_R::upper.

124 {
125  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
126  Oid query = PG_GETARG_OID(1);
128 
129  /* Oid subtype = PG_GETARG_OID(3); */
130  bool *recheck = (bool *) PG_GETARG_POINTER(4);
131  oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
133 
134  /* All cases served by this function are exact */
135  *recheck = false;
136 
137  key.lower = (GBT_NUMKEY *) &kkk->lower;
138  key.upper = (GBT_NUMKEY *) &kkk->upper;
139 
141  gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
142  );
143 }
#define GIST_LEAF(entry)
Definition: gist.h:141
Oid lower
Definition: btree_enum.c:15
const GBT_NUMKEY * lower
uint16 StrategyNumber
Definition: stratnum.h:22
const GBT_NUMKEY * upper
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
unsigned int Oid
Definition: postgres_ext.h:31
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86
Datum key
Definition: gist.h:131
char GBT_NUMKEY
#define PG_GETARG_OID(n)
Definition: fmgr.h:270
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:349
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:267
#define DatumGetPointer(X)
Definition: postgres.h:549
Oid upper
Definition: btree_enum.c:16

◆ gbt_enum_fetch()

Datum gbt_enum_fetch ( PG_FUNCTION_ARGS  )

Definition at line 115 of file btree_enum.c.

References gbt_num_fetch(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

116 {
117  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
118 
120 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86

◆ gbt_enum_penalty()

Datum gbt_enum_penalty ( PG_FUNCTION_ARGS  )

Definition at line 157 of file btree_enum.c.

References DatumGetPointer, sort-test::key, oidKEY::lower, penalty_num, PG_GETARG_POINTER, PG_RETURN_POINTER, and oidKEY::upper.

158 {
159  oidKEY *origentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
160  oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
161  float *result = (float *) PG_GETARG_POINTER(2);
162 
163  penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
164 
165  PG_RETURN_POINTER(result);
166 }
Oid lower
Definition: btree_enum.c:15
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define penalty_num(result, olower, oupper, nlower, nupper)
#define DatumGetPointer(X)
Definition: postgres.h:549
Oid upper
Definition: btree_enum.c:16

◆ gbt_enum_picksplit()

Datum gbt_enum_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 169 of file btree_enum.c.

References gbt_num_picksplit(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

170 {
174  &tinfo, fcinfo->flinfo
175  ));
176 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86
GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

◆ gbt_enum_same()

Datum gbt_enum_same ( PG_FUNCTION_ARGS  )

Definition at line 179 of file btree_enum.c.

References gbt_num_same(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

180 {
181  oidKEY *b1 = (oidKEY *) PG_GETARG_POINTER(0);
182  oidKEY *b2 = (oidKEY *) PG_GETARG_POINTER(1);
183  bool *result = (bool *) PG_GETARG_POINTER(2);
184 
185  *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
186  PG_RETURN_POINTER(result);
187 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86

◆ gbt_enum_union()

Datum gbt_enum_union ( PG_FUNCTION_ARGS  )

Definition at line 146 of file btree_enum.c.

References gbt_num_union(), palloc(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

147 {
149  void *out = palloc(sizeof(oidKEY));
150 
151  *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY);
152  PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
153 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
Definition: btree_enum.c:86
void * palloc(Size size)
Definition: mcxt.c:949
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

◆ gbt_enumeq()

static bool gbt_enumeq ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 46 of file btree_enum.c.

47 {
48  return (*((const Oid *) a) == *((const Oid *) b));
49 }
unsigned int Oid
Definition: postgres_ext.h:31

◆ gbt_enumge()

static bool gbt_enumge ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 39 of file btree_enum.c.

References CallerFInfoFunctionCall2(), DatumGetBool, enum_ge(), InvalidOid, and ObjectIdGetDatum.

40 {
41  return DatumGetBool(
42  CallerFInfoFunctionCall2(enum_ge, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
43  );
44 }
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define DatumGetBool(X)
Definition: postgres.h:393
Datum enum_ge(PG_FUNCTION_ARGS)
Definition: enum.c:337
#define InvalidOid
Definition: postgres_ext.h:36

◆ gbt_enumgt()

static bool gbt_enumgt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 32 of file btree_enum.c.

References CallerFInfoFunctionCall2(), DatumGetBool, enum_gt(), InvalidOid, and ObjectIdGetDatum.

33 {
34  return DatumGetBool(
35  CallerFInfoFunctionCall2(enum_gt, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
36  );
37 }
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
unsigned int Oid
Definition: postgres_ext.h:31
Datum enum_gt(PG_FUNCTION_ARGS)
Definition: enum.c:346
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define DatumGetBool(X)
Definition: postgres.h:393
#define InvalidOid
Definition: postgres_ext.h:36

◆ gbt_enumkey_cmp()

static int gbt_enumkey_cmp ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 66 of file btree_enum.c.

References CallerFInfoFunctionCall2(), DatumGetInt32, enum_cmp(), InvalidOid, oidKEY::lower, ObjectIdGetDatum, and oidKEY::upper.

67 {
68  oidKEY *ia = (oidKEY *) (((const Nsrt *) a)->t);
69  oidKEY *ib = (oidKEY *) (((const Nsrt *) b)->t);
70 
71  if (ia->lower == ib->lower)
72  {
73  if (ia->upper == ib->upper)
74  return 0;
75 
76  return DatumGetInt32(
78  );
79  }
80 
81  return DatumGetInt32(
83  );
84 }
Oid lower
Definition: btree_enum.c:15
#define DatumGetInt32(X)
Definition: postgres.h:472
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define InvalidOid
Definition: postgres_ext.h:36
Datum enum_cmp(PG_FUNCTION_ARGS)
Definition: enum.c:373
Oid upper
Definition: btree_enum.c:16

◆ gbt_enumle()

static bool gbt_enumle ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 51 of file btree_enum.c.

References CallerFInfoFunctionCall2(), DatumGetBool, enum_le(), InvalidOid, and ObjectIdGetDatum.

52 {
53  return DatumGetBool(
54  CallerFInfoFunctionCall2(enum_le, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
55  );
56 }
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Datum enum_le(PG_FUNCTION_ARGS)
Definition: enum.c:310
#define DatumGetBool(X)
Definition: postgres.h:393
#define InvalidOid
Definition: postgres_ext.h:36

◆ gbt_enumlt()

static bool gbt_enumlt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 58 of file btree_enum.c.

References CallerFInfoFunctionCall2(), DatumGetBool, enum_lt(), InvalidOid, and ObjectIdGetDatum.

59 {
60  return DatumGetBool(
61  CallerFInfoFunctionCall2(enum_lt, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
62  );
63 }
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
unsigned int Oid
Definition: postgres_ext.h:31
Datum enum_lt(PG_FUNCTION_ARGS)
Definition: enum.c:301
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define DatumGetBool(X)
Definition: postgres.h:393
#define InvalidOid
Definition: postgres_ext.h:36

◆ PG_FUNCTION_INFO_V1() [1/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_compress  )

◆ PG_FUNCTION_INFO_V1() [2/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_fetch  )

◆ PG_FUNCTION_INFO_V1() [3/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_union  )

◆ PG_FUNCTION_INFO_V1() [4/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_picksplit  )

◆ PG_FUNCTION_INFO_V1() [5/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_consistent  )

◆ PG_FUNCTION_INFO_V1() [6/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_penalty  )

◆ PG_FUNCTION_INFO_V1() [7/7]

PG_FUNCTION_INFO_V1 ( gbt_enum_same  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(Oid),
8,
NULL
}
static bool gbt_enumlt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:58
static int gbt_enumkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:66
unsigned int Oid
Definition: postgres_ext.h:31
static bool gbt_enumge(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:39
static bool gbt_enumeq(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:46
static bool gbt_enumgt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:32
static bool gbt_enumle(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_enum.c:51

Definition at line 86 of file btree_enum.c.