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 const gbtree_vinfo tinfo
 
static const gbtree_vinfo bptinfo
 

Function Documentation

◆ gbt_bpchar_compress()

Datum gbt_bpchar_compress ( PG_FUNCTION_ARGS  )

Definition at line 185 of file btree_text.c.

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

References gbt_text_compress().

◆ gbt_bpchar_consistent()

Datum gbt_bpchar_consistent ( PG_FUNCTION_ARGS  )

Definition at line 215 of file btree_text.c.

216{
217 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
218 void *query = DatumGetTextP(PG_GETARG_DATUM(1));
220#ifdef NOT_USED
221 Oid subtype = PG_GETARG_OID(3);
222#endif
223 bool *recheck = (bool *) PG_GETARG_POINTER(4);
224 bool retval;
227
228 /* All cases served by this function are exact */
229 *recheck = false;
230
231 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
232 GIST_LEAF(entry), &bptinfo, fcinfo->flinfo);
233 PG_RETURN_BOOL(retval);
234}
static const gbtree_vinfo bptinfo
Definition btree_text.c:158
bool gbt_var_consistent(const 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
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
unsigned int Oid
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161
Definition c.h:835

References bptinfo, DatumGetPointer(), DatumGetTextP, gbt_var_consistent(), gbt_var_key_readable(), GIST_LEAF, GISTENTRY::key, 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 335 of file btree_text.c.

336{
338
340 ssup->ssup_extra = NULL;
341
343}
static int gbt_bpchar_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition btree_text.c:313
struct SortSupportData * SortSupport
Definition execnodes.h:61
#define PG_RETURN_VOID()
Definition fmgr.h:350
static int fb(int x)
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 313 of file btree_text.c.

314{
317
321
322 /* for leaf items we expect lower == upper, so only compare lower */
324 ssup->ssup_collation,
325 PointerGetDatum(arg1.lower),
326 PointerGetDatum(arg2.lower));
327
330
331 return DatumGetInt32(result);
332}
#define GBT_FREE_IF_COPY(ptr1, ptr2)
uint32 result
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
Definition fmgr.c:814
#define PG_DETOAST_DATUM(datum)
Definition fmgr.h:240
int y
Definition isn.c:76
int x
Definition isn.c:75
uint64_t Datum
Definition postgres.h:70
static int32 DatumGetInt32(Datum X)
Definition postgres.h:202
#define PointerGetDatum(X)
Definition postgres.h:354
Datum bpcharcmp(PG_FUNCTION_ARGS)
Definition varchar.c:912

References bpcharcmp(), DatumGetInt32(), DirectFunctionCall2Coll(), fb(), GBT_FREE_IF_COPY, gbt_var_key_readable(), PG_DETOAST_DATUM, PointerGetDatum, result, 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 150 of file btree_text.c.

151{
153 collation,
156}
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 123 of file btree_text.c.

124{
126 collation,
129}
static bool DatumGetBool(Datum X)
Definition postgres.h:100
Datum bpchareq(PG_FUNCTION_ARGS)
Definition varchar.c:746

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 114 of file btree_text.c.

115{
117 collation,
120}
Datum bpcharge(PG_FUNCTION_ARGS)
Definition varchar.c:891

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 105 of file btree_text.c.

106{
108 collation,
111}
Datum bpchargt(PG_FUNCTION_ARGS)
Definition varchar.c:870

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 132 of file btree_text.c.

133{
135 collation,
138}
Datum bpcharle(PG_FUNCTION_ARGS)
Definition varchar.c:849

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 141 of file btree_text.c.

142{
144 collation,
147}
Datum bpcharlt(PG_FUNCTION_ARGS)
Definition varchar.c:828

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

◆ gbt_text_compress()

Datum gbt_text_compress ( PG_FUNCTION_ARGS  )

Definition at line 177 of file btree_text.c.

178{
179 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
180
182}
static const gbtree_vinfo tinfo
Definition btree_text.c:89
GISTENTRY * gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363

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

193{
194 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
195 void *query = DatumGetTextP(PG_GETARG_DATUM(1));
197#ifdef NOT_USED
198 Oid subtype = PG_GETARG_OID(3);
199#endif
200 bool *recheck = (bool *) PG_GETARG_POINTER(4);
201 bool retval;
204
205 /* All cases served by this function are exact */
206 *recheck = false;
207
208 retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
209 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
210
211 PG_RETURN_BOOL(retval);
212}

References DatumGetPointer(), DatumGetTextP, gbt_var_consistent(), gbt_var_key_readable(), GIST_LEAF, GISTENTRY::key, 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 269 of file btree_text.c.

270{
273 float *result = (float *) PG_GETARG_POINTER(2);
274
276 &tinfo, fcinfo->flinfo));
277}
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, result, and tinfo.

◆ gbt_text_picksplit()

Datum gbt_text_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 247 of file btree_text.c.

248{
251
253 &tinfo, fcinfo->flinfo);
255}
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 258 of file btree_text.c.

259{
260 Datum d1 = PG_GETARG_DATUM(0);
261 Datum d2 = PG_GETARG_DATUM(1);
262 bool *result = (bool *) PG_GETARG_POINTER(2);
263
264 *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
266}
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, result, and tinfo.

◆ gbt_text_sortsupport()

Datum gbt_text_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 302 of file btree_text.c.

303{
305
307 ssup->ssup_extra = NULL;
308
310}
static int gbt_text_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition btree_text.c:280

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 280 of file btree_text.c.

281{
284
288
289 /* for leaf items we expect lower == upper, so only compare lower */
291 ssup->ssup_collation,
292 PointerGetDatum(arg1.lower),
293 PointerGetDatum(arg2.lower));
294
297
298 return DatumGetInt32(result);
299}
Datum bttextcmp(PG_FUNCTION_ARGS)
Definition varlena.c:1632

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

Referenced by gbt_text_sortsupport().

◆ gbt_text_union()

Datum gbt_text_union ( PG_FUNCTION_ARGS  )

Definition at line 237 of file btree_text.c.

238{
240 int32 *size = (int *) PG_GETARG_POINTER(1);
241
243 &tinfo, fcinfo->flinfo));
244}
GBT_VARKEY * gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
int32_t int32
Definition c.h:679

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 75 of file btree_text.c.

76{
78 collation,
81}

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 48 of file btree_text.c.

49{
51 collation,
54}
Datum texteq(PG_FUNCTION_ARGS)
Definition varlena.c:1429

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 39 of file btree_text.c.

40{
42 collation,
45}
Datum text_ge(PG_FUNCTION_ARGS)
Definition varlena.c:1578

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 30 of file btree_text.c.

31{
33 collation,
36}
Datum text_gt(PG_FUNCTION_ARGS)
Definition varlena.c:1563

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 57 of file btree_text.c.

58{
60 collation,
63}
Datum text_le(PG_FUNCTION_ARGS)
Definition varlena.c:1548

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 66 of file btree_text.c.

67{
69 collation,
72}
Datum text_lt(PG_FUNCTION_ARGS)
Definition varlena.c:1533

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

const gbtree_vinfo bptinfo
static
Initial value:
=
{
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:114
static int32 gbt_bpcharcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:150
static bool gbt_bpchareq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:123
static bool gbt_bpcharle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:132
static bool gbt_bpcharlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:141
static bool gbt_bpchargt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:105

Definition at line 158 of file btree_text.c.

159{
161 false, /* as above, no truncation permitted */
168 NULL
169};

Referenced by gbt_bpchar_consistent().

◆ tinfo

const gbtree_vinfo tinfo
static
Initial value:
=
{
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:66
static bool gbt_textge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:39
static int32 gbt_textcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:75
static bool gbt_texteq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:48
static bool gbt_textle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:57
static bool gbt_textgt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
Definition btree_text.c:30

Definition at line 89 of file btree_text.c.

90{
92 false, /* no truncation permitted */
99 NULL
100};

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