PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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 219 of file btree_text.c.

220{
221 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
222 void *query = DatumGetTextP(PG_GETARG_DATUM(1));
224#ifdef NOT_USED
225 Oid subtype = PG_GETARG_OID(3);
226#endif
227 bool *recheck = (bool *) PG_GETARG_POINTER(4);
228 bool retval;
231
232 /* All cases served by this function are exact */
233 *recheck = false;
234
235 if (bptinfo.eml == 0)
236 {
238 }
239
240 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
241 GIST_LEAF(entry), &bptinfo, fcinfo->flinfo);
242 PG_RETURN_BOOL(retval);
243}
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_OID(n)
Definition fmgr.h:275
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#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:333
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define GIST_LEAF(entry)
Definition gist.h:171
int pg_database_encoding_max_length(void)
Definition mbutils.c:1549
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
unsigned int Oid
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161
Definition c.h:706

References bptinfo, 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_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, and PG_RETURN_BOOL.

◆ gbt_bpchar_sortsupport()

Datum gbt_bpchar_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 344 of file btree_text.c.

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

References SortSupportData::comparator, fb(), 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 322 of file btree_text.c.

323{
326
329 Datum result;
330
331 /* for leaf items we expect lower == upper, so only compare lower */
333 ssup->ssup_collation,
334 PointerGetDatum(arg1.lower),
335 PointerGetDatum(arg2.lower));
336
339
340 return DatumGetInt32(result);
341}
#define GBT_FREE_IF_COPY(ptr1, ptr2)
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition fmgr.c:813
#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:352
uint64_t Datum
Definition postgres.h:70
static int32 DatumGetInt32(Datum X)
Definition postgres.h:212
Datum bpcharcmp(PG_FUNCTION_ARGS)
Definition varchar.c:909

References bpcharcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), fb(), GBT_FREE_IF_COPY, gbt_var_key_readable(), 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:100
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:363

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#ifdef NOT_USED
197 Oid subtype = PG_GETARG_OID(3);
198#endif
199 bool *recheck = (bool *) PG_GETARG_POINTER(4);
200 bool retval;
203
204 /* All cases served by this function are exact */
205 *recheck = false;
206
207 if (tinfo.eml == 0)
208 {
210 }
211
212 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
213 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
214
215 PG_RETURN_BOOL(retval);
216}

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_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and tinfo.

◆ gbt_text_penalty()

Datum gbt_text_penalty ( PG_FUNCTION_ARGS  )

Definition at line 278 of file btree_text.c.

279{
282 float *result = (float *) PG_GETARG_POINTER(2);
283
285 &tinfo, fcinfo->flinfo));
286}
float * gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)

References fb(), 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 256 of file btree_text.c.

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

References fb(), 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 267 of file btree_text.c.

268{
269 Datum d1 = PG_GETARG_DATUM(0);
270 Datum d2 = PG_GETARG_DATUM(1);
271 bool *result = (bool *) PG_GETARG_POINTER(2);
272
273 *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
274 PG_RETURN_POINTER(result);
275}
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 311 of file btree_text.c.

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

References SortSupportData::comparator, fb(), 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 289 of file btree_text.c.

290{
293
296 Datum result;
297
298 /* for leaf items we expect lower == upper, so only compare lower */
300 ssup->ssup_collation,
301 PointerGetDatum(arg1.lower),
302 PointerGetDatum(arg2.lower));
303
306
307 return DatumGetInt32(result);
308}
Datum bttextcmp(PG_FUNCTION_ARGS)
Definition varlena.c:1584

References bttextcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), fb(), GBT_FREE_IF_COPY, gbt_var_key_readable(), 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 246 of file btree_text.c.

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

References fb(), 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:1381

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:1530

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:1515

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:1500

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:1485

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,
}
@ 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.

152{
154 0,
155 false,
162 NULL
163};

Referenced by gbt_bpchar_consistent().

◆ tinfo

gbtree_vinfo tinfo
static
Initial value:
=
{
0,
false,
}
@ 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.

82{
84 0,
85 false,
92 NULL
93};

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