PostgreSQL Source Code git master
btree_text.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_var.h"
#include "mb/pg_wchar.h"
#include "utils/fmgrprotos.h"
#include "utils/sortsupport.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)
 
 PG_FUNCTION_INFO_V1 (gbt_text_sortsupport)
 
 PG_FUNCTION_INFO_V1 (gbt_bpchar_sortsupport)
 
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)
 
static bool gbt_bpchargt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_bpcharge (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_bpchareq (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_bpcharle (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static bool gbt_bpcharlt (const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 
static int32 gbt_bpcharcmp (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)
 
static int gbt_text_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_text_sortsupport (PG_FUNCTION_ARGS)
 
static int gbt_bpchar_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_bpchar_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static gbtree_vinfo tinfo
 
static gbtree_vinfo bptinfo
 

Function Documentation

◆ gbt_bpchar_compress()

Datum gbt_bpchar_compress ( PG_FUNCTION_ARGS  )

Definition at line 184 of file btree_text.c.

185{
186 /* This should never have been distinct from gbt_text_compress */
187 return gbt_text_compress(fcinfo);
188}
Datum gbt_text_compress(PG_FUNCTION_ARGS)
Definition: btree_text.c:171

References gbt_text_compress().

◆ gbt_bpchar_consistent()

Datum gbt_bpchar_consistent ( PG_FUNCTION_ARGS  )

Definition at line 218 of file btree_text.c.

219{
220 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
221 void *query = DatumGetTextP(PG_GETARG_DATUM(1));
223
224 /* Oid subtype = PG_GETARG_OID(3); */
225 bool *recheck = (bool *) PG_GETARG_POINTER(4);
226 bool retval;
229
230 /* All cases served by this function are exact */
231 *recheck = false;
232
233 if (bptinfo.eml == 0)
234 {
236 }
237
238 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
239 GIST_LEAF(entry), &bptinfo, fcinfo->flinfo);
240 PG_RETURN_BOOL(retval);
241}
static gbtree_vinfo bptinfo
Definition: btree_text.c:151
bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query, StrategyNumber strategy, Oid collation, bool is_leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:272
#define PG_GET_COLLATION()
Definition: fmgr.h:198
#define DatumGetTextP(X)
Definition: fmgr.h:332
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
#define GIST_LEAF(entry)
Definition: gist.h:171
int pg_database_encoding_max_length(void)
Definition: mbutils.c:1546
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:317
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
Definition: c.h:658

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

◆ gbt_bpchar_sortsupport()

Datum gbt_bpchar_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 342 of file btree_text.c.

343{
345
347 ssup->ssup_extra = NULL;
348
350}
static int gbt_bpchar_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_text.c:320
#define PG_RETURN_VOID()
Definition: fmgr.h:349
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106
void * ssup_extra
Definition: sortsupport.h:87

References SortSupportData::comparator, gbt_bpchar_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_bpchar_ssup_cmp()

static int gbt_bpchar_ssup_cmp ( Datum  x,
Datum  y,
SortSupport  ssup 
)
static

Definition at line 320 of file btree_text.c.

321{
324
327 Datum result;
328
329 /* for leaf items we expect lower == upper, so only compare lower */
331 ssup->ssup_collation,
333 PointerGetDatum(arg2.lower));
334
335 GBT_FREE_IF_COPY(key1, x);
336 GBT_FREE_IF_COPY(key2, y);
337
338 return DatumGetInt32(result);
339}
#define GBT_FREE_IF_COPY(ptr1, ptr2)
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:812
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
int y
Definition: isn.c:76
int x
Definition: isn.c:75
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:327
uintptr_t Datum
Definition: postgres.h:69
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207
Datum bpcharcmp(PG_FUNCTION_ARGS)
Definition: varchar.c:909

References bpcharcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), GBT_FREE_IF_COPY, gbt_var_key_readable(), GBT_VARKEY_R::lower, PG_DETOAST_DATUM, PointerGetDatum(), SortSupportData::ssup_collation, x, and y.

Referenced by gbt_bpchar_sortsupport().

◆ gbt_bpcharcmp()

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

Definition at line 143 of file btree_text.c.

144{
146 collation,
149}
int b
Definition: isn.c:74
int a
Definition: isn.c:73

References a, b, bpcharcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_bpchareq()

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

Definition at line 116 of file btree_text.c.

117{
119 collation,
122}
static bool DatumGetBool(Datum X)
Definition: postgres.h:95
Datum bpchareq(PG_FUNCTION_ARGS)
Definition: varchar.c:743

References a, b, bpchareq(), DatumGetBool(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_bpcharge()

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

Definition at line 107 of file btree_text.c.

108{
110 collation,
113}
Datum bpcharge(PG_FUNCTION_ARGS)
Definition: varchar.c:888

References a, b, bpcharge(), DatumGetBool(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_bpchargt()

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

Definition at line 98 of file btree_text.c.

99{
101 collation,
104}
Datum bpchargt(PG_FUNCTION_ARGS)
Definition: varchar.c:867

References a, b, bpchargt(), DatumGetBool(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_bpcharle()

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

Definition at line 125 of file btree_text.c.

126{
128 collation,
131}
Datum bpcharle(PG_FUNCTION_ARGS)
Definition: varchar.c:846

References a, b, bpcharle(), DatumGetBool(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_bpcharlt()

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

Definition at line 134 of file btree_text.c.

135{
137 collation,
140}
Datum bpcharlt(PG_FUNCTION_ARGS)
Definition: varchar.c:825

References a, b, bpcharlt(), DatumGetBool(), DirectFunctionCall2Coll(), and PointerGetDatum().

◆ gbt_text_compress()

Datum gbt_text_compress ( PG_FUNCTION_ARGS  )

Definition at line 171 of file btree_text.c.

172{
173 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
174
175 if (tinfo.eml == 0)
176 {
178 }
179
181}
static gbtree_vinfo tinfo
Definition: btree_text.c:81
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361

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

Referenced by gbt_bpchar_compress().

◆ gbt_text_consistent()

Datum gbt_text_consistent ( PG_FUNCTION_ARGS  )

Definition at line 191 of file btree_text.c.

192{
193 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
194 void *query = DatumGetTextP(PG_GETARG_DATUM(1));
196
197 /* Oid subtype = PG_GETARG_OID(3); */
198 bool *recheck = (bool *) PG_GETARG_POINTER(4);
199 bool retval;
202
203 /* All cases served by this function are exact */
204 *recheck = false;
205
206 if (tinfo.eml == 0)
207 {
209 }
210
211 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
212 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
213
214 PG_RETURN_BOOL(retval);
215}

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

◆ gbt_text_penalty()

Datum gbt_text_penalty ( PG_FUNCTION_ARGS  )

Definition at line 276 of file btree_text.c.

277{
280 float *result = (float *) PG_GETARG_POINTER(2);
281
283 &tinfo, fcinfo->flinfo));
284}
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

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

◆ gbt_text_picksplit()

Datum gbt_text_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 254 of file btree_text.c.

255{
258
259 gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
260 &tinfo, fcinfo->flinfo);
262}
GIST_SPLITVEC * gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

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

◆ gbt_text_same()

Datum gbt_text_same ( PG_FUNCTION_ARGS  )

Definition at line 265 of file btree_text.c.

266{
267 Datum d1 = PG_GETARG_DATUM(0);
268 Datum d2 = PG_GETARG_DATUM(1);
269 bool *result = (bool *) PG_GETARG_POINTER(2);
270
271 *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
272 PG_RETURN_POINTER(result);
273}
bool gbt_var_same(Datum d1, Datum d2, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

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

◆ gbt_text_sortsupport()

Datum gbt_text_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 309 of file btree_text.c.

310{
312
314 ssup->ssup_extra = NULL;
315
317}
static int gbt_text_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_text.c:287

References SortSupportData::comparator, gbt_text_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_text_ssup_cmp()

static int gbt_text_ssup_cmp ( Datum  x,
Datum  y,
SortSupport  ssup 
)
static

Definition at line 287 of file btree_text.c.

288{
291
294 Datum result;
295
296 /* for leaf items we expect lower == upper, so only compare lower */
298 ssup->ssup_collation,
300 PointerGetDatum(arg2.lower));
301
302 GBT_FREE_IF_COPY(key1, x);
303 GBT_FREE_IF_COPY(key2, y);
304
305 return DatumGetInt32(result);
306}
Datum bttextcmp(PG_FUNCTION_ARGS)
Definition: varlena.c:1886

References bttextcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), GBT_FREE_IF_COPY, gbt_var_key_readable(), GBT_VARKEY_R::lower, PG_DETOAST_DATUM, PointerGetDatum(), SortSupportData::ssup_collation, x, and y.

Referenced by gbt_text_sortsupport().

◆ gbt_text_union()

Datum gbt_text_union ( PG_FUNCTION_ARGS  )

Definition at line 244 of file btree_text.c.

245{
247 int32 *size = (int *) PG_GETARG_POINTER(1);
248
250 &tinfo, fcinfo->flinfo));
251}
GBT_VARKEY * gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
int32_t int32
Definition: c.h:498

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

◆ gbt_textcmp()

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

Definition at line 73 of file btree_text.c.

74{
76 collation,
79}

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

◆ gbt_texteq()

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

Definition at line 46 of file btree_text.c.

47{
49 collation,
52}
Datum texteq(PG_FUNCTION_ARGS)
Definition: varlena.c:1683

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

◆ gbt_textge()

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

Definition at line 37 of file btree_text.c.

38{
40 collation,
43}
Datum text_ge(PG_FUNCTION_ARGS)
Definition: varlena.c:1832

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

◆ gbt_textgt()

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

Definition at line 28 of file btree_text.c.

29{
31 collation,
34}
Datum text_gt(PG_FUNCTION_ARGS)
Definition: varlena.c:1817

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

◆ gbt_textle()

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

Definition at line 55 of file btree_text.c.

56{
58 collation,
61}
Datum text_le(PG_FUNCTION_ARGS)
Definition: varlena.c:1802

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

◆ gbt_textlt()

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

Definition at line 64 of file btree_text.c.

65{
67 collation,
70}
Datum text_lt(PG_FUNCTION_ARGS)
Definition: varlena.c:1787

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

◆ PG_FUNCTION_INFO_V1() [1/10]

PG_FUNCTION_INFO_V1 ( gbt_bpchar_compress  )

◆ PG_FUNCTION_INFO_V1() [2/10]

PG_FUNCTION_INFO_V1 ( gbt_bpchar_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/10]

PG_FUNCTION_INFO_V1 ( gbt_bpchar_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [4/10]

PG_FUNCTION_INFO_V1 ( gbt_text_compress  )

◆ PG_FUNCTION_INFO_V1() [5/10]

PG_FUNCTION_INFO_V1 ( gbt_text_consistent  )

◆ PG_FUNCTION_INFO_V1() [6/10]

PG_FUNCTION_INFO_V1 ( gbt_text_penalty  )

◆ PG_FUNCTION_INFO_V1() [7/10]

PG_FUNCTION_INFO_V1 ( gbt_text_picksplit  )

◆ PG_FUNCTION_INFO_V1() [8/10]

PG_FUNCTION_INFO_V1 ( gbt_text_same  )

◆ PG_FUNCTION_INFO_V1() [9/10]

PG_FUNCTION_INFO_V1 ( gbt_text_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [10/10]

PG_FUNCTION_INFO_V1 ( gbt_text_union  )

Variable Documentation

◆ bptinfo

gbtree_vinfo bptinfo
static
Initial value:
=
{
0,
false,
NULL
}
@ gbt_t_bpchar
Definition: btree_gist.h:32
static bool gbt_bpcharge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:107
static int32 gbt_bpcharcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:143
static bool gbt_bpchareq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:116
static bool gbt_bpcharle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:125
static bool gbt_bpcharlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:134
static bool gbt_bpchargt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:98

Definition at line 151 of file btree_text.c.

Referenced by gbt_bpchar_consistent().

◆ tinfo

gbtree_vinfo tinfo
static
Initial value:
=
{
0,
false,
NULL
}
@ gbt_t_text
Definition: btree_gist.h:31
static bool gbt_textlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:64
static bool gbt_textge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:37
static int32 gbt_textcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:73
static bool gbt_texteq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:46
static bool gbt_textle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:55
static bool gbt_textgt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition: btree_text.c:28

Definition at line 81 of file btree_text.c.

Referenced by gbt_text_compress(), gbt_text_consistent(), gbt_text_penalty(), gbt_text_picksplit(), gbt_text_same(), and gbt_text_union().