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

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (gbt_text_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_bpchar_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_text_union)
 
 PG_FUNCTION_INFO_V1 (gbt_text_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_text_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_bpchar_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_text_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_text_same)
 
static bool gbt_textgt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_textge (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_texteq (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_textle (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_textlt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static int32 gbt_textcmp (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
Datum gbt_text_compress (PG_FUNCTION_ARGS)
 
Datum gbt_bpchar_compress (PG_FUNCTION_ARGS)
 
Datum gbt_text_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_bpchar_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_text_union (PG_FUNCTION_ARGS)
 
Datum gbt_text_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_text_same (PG_FUNCTION_ARGS)
 
Datum gbt_text_penalty (PG_FUNCTION_ARGS)
 

Variables

static gbtree_vinfo tinfo
 

Function Documentation

◆ gbt_bpchar_compress()

Datum gbt_bpchar_compress ( PG_FUNCTION_ARGS  )

Definition at line 113 of file btree_text.c.

References DirectFunctionCall1, gbtree_vinfo::eml, gbt_var_compress(), gistentryinit, GISTENTRY::key, GISTENTRY::leafkey, GISTENTRY::offset, GISTENTRY::page, pg_database_encoding_max_length(), PG_GETARG_POINTER, PG_RETURN_POINTER, GISTENTRY::rel, and rtrim1().

114 {
115  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
116  GISTENTRY *retval;
117 
118  if (tinfo.eml == 0)
119  {
121  }
122 
123  if (entry->leafkey)
124  {
125 
126  Datum d = DirectFunctionCall1(rtrim1, entry->key);
127  GISTENTRY trim;
128 
129  gistentryinit(trim, d,
130  entry->rel, entry->page,
131  entry->offset, true);
132  retval = gbt_var_compress(&trim, &tinfo);
133  }
134  else
135  retval = entry;
136 
137  PG_RETURN_POINTER(retval);
138 }
Relation rel
Definition: gist.h:124
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
static gbtree_vinfo tinfo
Definition: btree_text.c:79
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:585
Page page
Definition: gist.h:125
Datum rtrim1(PG_FUNCTION_ARGS)
Datum key
Definition: gist.h:123
int pg_database_encoding_max_length(void)
Definition: wchar.c:1833
bool leafkey
Definition: gist.h:127
uintptr_t Datum
Definition: postgres.h:372
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:169
OffsetNumber offset
Definition: gist.h:126

◆ gbt_bpchar_consistent()

Datum gbt_bpchar_consistent ( PG_FUNCTION_ARGS  )

Definition at line 171 of file btree_text.c.

References DatumGetPointer, DatumGetTextP, DirectFunctionCall1, gbtree_vinfo::eml, gbt_var_consistent(), gbt_var_key_readable(), GIST_LEAF, GISTENTRY::key, pg_database_encoding_max_length(), PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, PointerGetDatum, and rtrim1().

172 {
173  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
174  void *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
176 
177  /* Oid subtype = PG_GETARG_OID(3); */
178  bool *recheck = (bool *) PG_GETARG_POINTER(4);
179  bool retval;
180  GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
182  void *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
183 
184  /* All cases served by this function are exact */
185  *recheck = false;
186 
187  if (tinfo.eml == 0)
188  {
190  }
191 
192  retval = gbt_var_consistent(&r, trim, strategy, PG_GET_COLLATION(),
193  GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
194  PG_RETURN_BOOL(retval);
195 }
#define GIST_LEAF(entry)
Definition: gist.h:133
#define PointerGetDatum(X)
Definition: postgres.h:562
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:233
static gbtree_vinfo tinfo
Definition: btree_text.c:79
uint16 StrategyNumber
Definition: stratnum.h:22
bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query, StrategyNumber strategy, Oid collation, bool is_leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:585
#define PG_GET_COLLATION()
Definition: fmgr.h:163
Datum rtrim1(PG_FUNCTION_ARGS)
Datum key
Definition: gist.h:123
int pg_database_encoding_max_length(void)
Definition: wchar.c:1833
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k)
#define DatumGetTextP(X)
Definition: fmgr.h:296
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:237
#define DatumGetPointer(X)
Definition: postgres.h:555
Definition: c.h:487

◆ gbt_text_compress()

Datum gbt_text_compress ( PG_FUNCTION_ARGS  )

Definition at line 100 of file btree_text.c.

References gbtree_vinfo::eml, gbt_var_compress(), pg_database_encoding_max_length(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

101 {
102  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
103 
104  if (tinfo.eml == 0)
105  {
107  }
108 
110 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
static gbtree_vinfo tinfo
Definition: btree_text.c:79
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
int pg_database_encoding_max_length(void)
Definition: wchar.c:1833
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)

◆ gbt_text_consistent()

Datum gbt_text_consistent ( PG_FUNCTION_ARGS  )

Definition at line 143 of file btree_text.c.

References DatumGetPointer, DatumGetTextP, gbtree_vinfo::eml, gbt_var_consistent(), gbt_var_key_readable(), GIST_LEAF, GISTENTRY::key, pg_database_encoding_max_length(), PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_GETARG_UINT16, and PG_RETURN_BOOL.

144 {
145  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
146  void *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
148 
149  /* Oid subtype = PG_GETARG_OID(3); */
150  bool *recheck = (bool *) PG_GETARG_POINTER(4);
151  bool retval;
152  GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
154 
155  /* All cases served by this function are exact */
156  *recheck = false;
157 
158  if (tinfo.eml == 0)
159  {
161  }
162 
163  retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
164  GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
165 
166  PG_RETURN_BOOL(retval);
167 }
#define GIST_LEAF(entry)
Definition: gist.h:133
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:233
static gbtree_vinfo tinfo
Definition: btree_text.c:79
uint16 StrategyNumber
Definition: stratnum.h:22
bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query, StrategyNumber strategy, Oid collation, bool is_leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define PG_GET_COLLATION()
Definition: fmgr.h:163
Datum key
Definition: gist.h:123
int pg_database_encoding_max_length(void)
Definition: wchar.c:1833
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k)
#define DatumGetTextP(X)
Definition: fmgr.h:296
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:237
#define DatumGetPointer(X)
Definition: postgres.h:555
Definition: c.h:487

◆ gbt_text_penalty()

Datum gbt_text_penalty ( PG_FUNCTION_ARGS  )

Definition at line 233 of file btree_text.c.

References gbt_var_penalty(), PG_GET_COLLATION, PG_GETARG_POINTER, and PG_RETURN_POINTER.

234 {
237  float *result = (float *) PG_GETARG_POINTER(2);
238 
240  &tinfo, fcinfo->flinfo));
241 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
static gbtree_vinfo tinfo
Definition: btree_text.c:79
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define PG_GET_COLLATION()
Definition: fmgr.h:163
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

◆ gbt_text_picksplit()

Datum gbt_text_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 210 of file btree_text.c.

References gbt_var_picksplit(), PG_GET_COLLATION, PG_GETARG_POINTER, and PG_RETURN_POINTER.

211 {
214 
215  gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
216  &tinfo, fcinfo->flinfo);
218 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
GIST_SPLITVEC * gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
static gbtree_vinfo tinfo
Definition: btree_text.c:79
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define PG_GET_COLLATION()
Definition: fmgr.h:163

◆ gbt_text_same()

Datum gbt_text_same ( PG_FUNCTION_ARGS  )

Definition at line 221 of file btree_text.c.

References gbt_var_same(), PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_POINTER, and PG_RETURN_POINTER.

222 {
223  Datum d1 = PG_GETARG_DATUM(0);
224  Datum d2 = PG_GETARG_DATUM(1);
225  bool *result = (bool *) PG_GETARG_POINTER(2);
226 
227  *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
228  PG_RETURN_POINTER(result);
229 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:233
static gbtree_vinfo tinfo
Definition: btree_text.c:79
bool gbt_var_same(Datum d1, Datum d2, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define PG_GET_COLLATION()
Definition: fmgr.h:163
uintptr_t Datum
Definition: postgres.h:372

◆ gbt_text_union()

Datum gbt_text_union ( PG_FUNCTION_ARGS  )

Definition at line 199 of file btree_text.c.

References gbt_var_union(), PG_GET_COLLATION, PG_GETARG_POINTER, and PG_RETURN_POINTER.

200 {
202  int32 *size = (int *) PG_GETARG_POINTER(1);
203 
205  &tinfo, fcinfo->flinfo));
206 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:321
static gbtree_vinfo tinfo
Definition: btree_text.c:79
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:241
#define PG_GET_COLLATION()
Definition: fmgr.h:163
signed int int32
Definition: c.h:284
GBT_VARKEY * gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

◆ gbt_textcmp()

static int32 gbt_textcmp ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 71 of file btree_text.c.

References bttextcmp(), DatumGetInt32, DirectFunctionCall2Coll(), and PointerGetDatum.

72 {
74  collation,
75  PointerGetDatum(a),
76  PointerGetDatum(b)));
77 }
#define DatumGetInt32(X)
Definition: postgres.h:478
#define PointerGetDatum(X)
Definition: postgres.h:562
Datum bttextcmp(PG_FUNCTION_ARGS)
Definition: varlena.c:1766
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ gbt_texteq()

static bool gbt_texteq ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 44 of file btree_text.c.

References DatumGetBool, DirectFunctionCall2Coll(), PointerGetDatum, and texteq().

45 {
47  collation,
48  PointerGetDatum(a),
49  PointerGetDatum(b)));
50 }
#define PointerGetDatum(X)
Definition: postgres.h:562
Datum texteq(PG_FUNCTION_ARGS)
Definition: varlena.c:1642
#define DatumGetBool(X)
Definition: postgres.h:399
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ gbt_textge()

static bool gbt_textge ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 35 of file btree_text.c.

References DatumGetBool, DirectFunctionCall2Coll(), PointerGetDatum, and text_ge().

36 {
38  collation,
39  PointerGetDatum(a),
40  PointerGetDatum(b)));
41 }
#define PointerGetDatum(X)
Definition: postgres.h:562
#define DatumGetBool(X)
Definition: postgres.h:399
Datum text_ge(PG_FUNCTION_ARGS)
Definition: varlena.c:1751
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ gbt_textgt()

static bool gbt_textgt ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 26 of file btree_text.c.

References DatumGetBool, DirectFunctionCall2Coll(), PointerGetDatum, and text_gt().

27 {
29  collation,
30  PointerGetDatum(a),
31  PointerGetDatum(b)));
32 }
#define PointerGetDatum(X)
Definition: postgres.h:562
#define DatumGetBool(X)
Definition: postgres.h:399
Datum text_gt(PG_FUNCTION_ARGS)
Definition: varlena.c:1736
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ gbt_textle()

static bool gbt_textle ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 53 of file btree_text.c.

References DatumGetBool, DirectFunctionCall2Coll(), PointerGetDatum, and text_le().

54 {
56  collation,
57  PointerGetDatum(a),
58  PointerGetDatum(b)));
59 }
#define PointerGetDatum(X)
Definition: postgres.h:562
#define DatumGetBool(X)
Definition: postgres.h:399
Datum text_le(PG_FUNCTION_ARGS)
Definition: varlena.c:1721
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ gbt_textlt()

static bool gbt_textlt ( const void *  a,
const void *  b,
Oid  collation,
FmgrInfo flinfo 
)
static

Definition at line 62 of file btree_text.c.

References DatumGetBool, DirectFunctionCall2Coll(), PointerGetDatum, and text_lt().

63 {
65  collation,
66  PointerGetDatum(a),
67  PointerGetDatum(b)));
68 }
Datum text_lt(PG_FUNCTION_ARGS)
Definition: varlena.c:1706
#define PointerGetDatum(X)
Definition: postgres.h:562
#define DatumGetBool(X)
Definition: postgres.h:399
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:722

◆ PG_FUNCTION_INFO_V1() [1/8]

PG_FUNCTION_INFO_V1 ( gbt_text_compress  )

◆ PG_FUNCTION_INFO_V1() [2/8]

PG_FUNCTION_INFO_V1 ( gbt_bpchar_compress  )

◆ PG_FUNCTION_INFO_V1() [3/8]

PG_FUNCTION_INFO_V1 ( gbt_text_union  )

◆ PG_FUNCTION_INFO_V1() [4/8]

PG_FUNCTION_INFO_V1 ( gbt_text_picksplit  )

◆ PG_FUNCTION_INFO_V1() [5/8]

PG_FUNCTION_INFO_V1 ( gbt_text_consistent  )

◆ PG_FUNCTION_INFO_V1() [6/8]

PG_FUNCTION_INFO_V1 ( gbt_bpchar_consistent  )

◆ PG_FUNCTION_INFO_V1() [7/8]

PG_FUNCTION_INFO_V1 ( gbt_text_penalty  )

◆ PG_FUNCTION_INFO_V1() [8/8]

PG_FUNCTION_INFO_V1 ( gbt_text_same  )

Variable Documentation

◆ tinfo

gbtree_vinfo tinfo
static
Initial value:
=
{
0,
false,
NULL
}
static bool gbt_textlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:62
static bool gbt_texteq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:44
static bool gbt_textle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:53
static int32 gbt_textcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:71
static bool gbt_textge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:35
static bool gbt_textgt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:26

Definition at line 79 of file btree_text.c.