PostgreSQL Source Code  git master
citext.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "catalog/pg_collation.h"
#include "utils/builtins.h"
#include "utils/formatting.h"
#include "utils/varlena.h"
Include dependency graph for citext.c:

Go to the source code of this file.

Functions

static int32 citextcmp (text *left, text *right, Oid collid)
 
static int32 internal_citext_pattern_cmp (text *left, text *right, Oid collid)
 
 PG_FUNCTION_INFO_V1 (citext_cmp)
 
Datum citext_cmp (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_pattern_cmp)
 
Datum citext_pattern_cmp (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_hash)
 
Datum citext_hash (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_eq)
 
Datum citext_eq (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_ne)
 
Datum citext_ne (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_lt)
 
Datum citext_lt (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_le)
 
Datum citext_le (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_gt)
 
Datum citext_gt (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_ge)
 
Datum citext_ge (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_pattern_lt)
 
Datum citext_pattern_lt (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_pattern_le)
 
Datum citext_pattern_le (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_pattern_gt)
 
Datum citext_pattern_gt (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_pattern_ge)
 
Datum citext_pattern_ge (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_smaller)
 
Datum citext_smaller (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (citext_larger)
 
Datum citext_larger (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ citext_cmp()

Datum citext_cmp ( PG_FUNCTION_ARGS  )

Definition at line 106 of file citext.c.

References citext_pattern_cmp(), citextcmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_INT32.

Referenced by internal_citext_pattern_cmp().

107 {
108  text *left = PG_GETARG_TEXT_PP(0);
109  text *right = PG_GETARG_TEXT_PP(1);
110  int32 result;
111 
112  result = citextcmp(left, right, PG_GET_COLLATION());
113 
114  PG_FREE_IF_COPY(left, 0);
115  PG_FREE_IF_COPY(right, 1);
116 
117  PG_RETURN_INT32(result);
118 }
#define PG_RETURN_INT32(x)
Definition: fmgr.h:314
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
signed int int32
Definition: c.h:284
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_eq()

Datum citext_eq ( PG_FUNCTION_ARGS  )

Definition at line 165 of file citext.c.

References citext_ne(), DEFAULT_COLLATION_OID, pfree(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by citext_hash().

166 {
167  text *left = PG_GETARG_TEXT_PP(0);
168  text *right = PG_GETARG_TEXT_PP(1);
169  char *lcstr,
170  *rcstr;
171  bool result;
172 
173  /* We can't compare lengths in advance of downcasing ... */
174 
177 
178  /*
179  * Since we only care about equality or not-equality, we can avoid all the
180  * expense of strcoll() here, and just do bitwise comparison.
181  */
182  result = (strcmp(lcstr, rcstr) == 0);
183 
184  pfree(lcstr);
185  pfree(rcstr);
186  PG_FREE_IF_COPY(left, 0);
187  PG_FREE_IF_COPY(right, 1);
188 
189  PG_RETURN_BOOL(result);
190 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
char * str_tolower(const char *buff, size_t nbytes, Oid collid)
Definition: formatting.c:1508
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
void pfree(void *pointer)
Definition: mcxt.c:949
#define DEFAULT_COLLATION_OID
Definition: pg_collation.h:75
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:340
Definition: c.h:487

◆ citext_ge()

Datum citext_ge ( PG_FUNCTION_ARGS  )

Definition at line 276 of file citext.c.

References citext_pattern_lt(), citextcmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_gt().

277 {
278  text *left = PG_GETARG_TEXT_PP(0);
279  text *right = PG_GETARG_TEXT_PP(1);
280  bool result;
281 
282  result = citextcmp(left, right, PG_GET_COLLATION()) >= 0;
283 
284  PG_FREE_IF_COPY(left, 0);
285  PG_FREE_IF_COPY(right, 1);
286 
287  PG_RETURN_BOOL(result);
288 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_gt()

Datum citext_gt ( PG_FUNCTION_ARGS  )

Definition at line 259 of file citext.c.

References citext_ge(), citextcmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_le().

260 {
261  text *left = PG_GETARG_TEXT_PP(0);
262  text *right = PG_GETARG_TEXT_PP(1);
263  bool result;
264 
265  result = citextcmp(left, right, PG_GET_COLLATION()) > 0;
266 
267  PG_FREE_IF_COPY(left, 0);
268  PG_FREE_IF_COPY(right, 1);
269 
270  PG_RETURN_BOOL(result);
271 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_hash()

Datum citext_hash ( PG_FUNCTION_ARGS  )

Definition at line 140 of file citext.c.

References citext_eq(), DEFAULT_COLLATION_OID, hash_any(), pfree(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GETARG_TEXT_PP, PG_RETURN_DATUM, generate_unaccent_rules::str, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by citext_pattern_cmp().

141 {
142  text *txt = PG_GETARG_TEXT_PP(0);
143  char *str;
144  Datum result;
145 
147  result = hash_any((unsigned char *) str, strlen(str));
148  pfree(str);
149 
150  /* Avoid leaking memory for toasted inputs */
151  PG_FREE_IF_COPY(txt, 0);
152 
153  PG_RETURN_DATUM(result);
154 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
char * str_tolower(const char *buff, size_t nbytes, Oid collid)
Definition: formatting.c:1508
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
void pfree(void *pointer)
Definition: mcxt.c:949
#define DEFAULT_COLLATION_OID
Definition: pg_collation.h:75
uintptr_t Datum
Definition: postgres.h:372
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:313
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:428
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:340
Definition: c.h:487

◆ citext_larger()

Datum citext_larger ( PG_FUNCTION_ARGS  )

Definition at line 380 of file citext.c.

References citextcmp(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_TEXT_P.

Referenced by citext_smaller().

381 {
382  text *left = PG_GETARG_TEXT_PP(0);
383  text *right = PG_GETARG_TEXT_PP(1);
384  text *result;
385 
386  result = citextcmp(left, right, PG_GET_COLLATION()) > 0 ? left : right;
387  PG_RETURN_TEXT_P(result);
388 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:331
Definition: c.h:487

◆ citext_le()

Datum citext_le ( PG_FUNCTION_ARGS  )

Definition at line 242 of file citext.c.

References citext_gt(), citextcmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_lt().

243 {
244  text *left = PG_GETARG_TEXT_PP(0);
245  text *right = PG_GETARG_TEXT_PP(1);
246  bool result;
247 
248  result = citextcmp(left, right, PG_GET_COLLATION()) <= 0;
249 
250  PG_FREE_IF_COPY(left, 0);
251  PG_FREE_IF_COPY(right, 1);
252 
253  PG_RETURN_BOOL(result);
254 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_lt()

Datum citext_lt ( PG_FUNCTION_ARGS  )

Definition at line 225 of file citext.c.

References citext_le(), citextcmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_ne().

226 {
227  text *left = PG_GETARG_TEXT_PP(0);
228  text *right = PG_GETARG_TEXT_PP(1);
229  bool result;
230 
231  result = citextcmp(left, right, PG_GET_COLLATION()) < 0;
232 
233  PG_FREE_IF_COPY(left, 0);
234  PG_FREE_IF_COPY(right, 1);
235 
236  PG_RETURN_BOOL(result);
237 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_ne()

Datum citext_ne ( PG_FUNCTION_ARGS  )

Definition at line 195 of file citext.c.

References citext_lt(), DEFAULT_COLLATION_OID, pfree(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by citext_eq().

196 {
197  text *left = PG_GETARG_TEXT_PP(0);
198  text *right = PG_GETARG_TEXT_PP(1);
199  char *lcstr,
200  *rcstr;
201  bool result;
202 
203  /* We can't compare lengths in advance of downcasing ... */
204 
207 
208  /*
209  * Since we only care about equality or not-equality, we can avoid all the
210  * expense of strcoll() here, and just do bitwise comparison.
211  */
212  result = (strcmp(lcstr, rcstr) != 0);
213 
214  pfree(lcstr);
215  pfree(rcstr);
216  PG_FREE_IF_COPY(left, 0);
217  PG_FREE_IF_COPY(right, 1);
218 
219  PG_RETURN_BOOL(result);
220 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
char * str_tolower(const char *buff, size_t nbytes, Oid collid)
Definition: formatting.c:1508
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
void pfree(void *pointer)
Definition: mcxt.c:949
#define DEFAULT_COLLATION_OID
Definition: pg_collation.h:75
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:340
Definition: c.h:487

◆ citext_pattern_cmp()

Datum citext_pattern_cmp ( PG_FUNCTION_ARGS  )

Definition at line 123 of file citext.c.

References citext_hash(), internal_citext_pattern_cmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_INT32.

Referenced by citext_cmp().

124 {
125  text *left = PG_GETARG_TEXT_PP(0);
126  text *right = PG_GETARG_TEXT_PP(1);
127  int32 result;
128 
129  result = internal_citext_pattern_cmp(left, right, PG_GET_COLLATION());
130 
131  PG_FREE_IF_COPY(left, 0);
132  PG_FREE_IF_COPY(right, 1);
133 
134  PG_RETURN_INT32(result);
135 }
static int32 internal_citext_pattern_cmp(text *left, text *right, Oid collid)
Definition: citext.c:68
#define PG_RETURN_INT32(x)
Definition: fmgr.h:314
#define PG_GET_COLLATION()
Definition: fmgr.h:163
signed int int32
Definition: c.h:284
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_pattern_ge()

Datum citext_pattern_ge ( PG_FUNCTION_ARGS  )

Definition at line 344 of file citext.c.

References citext_smaller(), internal_citext_pattern_cmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_pattern_gt().

345 {
346  text *left = PG_GETARG_TEXT_PP(0);
347  text *right = PG_GETARG_TEXT_PP(1);
348  bool result;
349 
350  result = internal_citext_pattern_cmp(left, right, PG_GET_COLLATION()) >= 0;
351 
352  PG_FREE_IF_COPY(left, 0);
353  PG_FREE_IF_COPY(right, 1);
354 
355  PG_RETURN_BOOL(result);
356 }
static int32 internal_citext_pattern_cmp(text *left, text *right, Oid collid)
Definition: citext.c:68
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_pattern_gt()

Datum citext_pattern_gt ( PG_FUNCTION_ARGS  )

Definition at line 327 of file citext.c.

References citext_pattern_ge(), internal_citext_pattern_cmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_pattern_le().

328 {
329  text *left = PG_GETARG_TEXT_PP(0);
330  text *right = PG_GETARG_TEXT_PP(1);
331  bool result;
332 
333  result = internal_citext_pattern_cmp(left, right, PG_GET_COLLATION()) > 0;
334 
335  PG_FREE_IF_COPY(left, 0);
336  PG_FREE_IF_COPY(right, 1);
337 
338  PG_RETURN_BOOL(result);
339 }
static int32 internal_citext_pattern_cmp(text *left, text *right, Oid collid)
Definition: citext.c:68
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_pattern_le()

Datum citext_pattern_le ( PG_FUNCTION_ARGS  )

Definition at line 310 of file citext.c.

References citext_pattern_gt(), internal_citext_pattern_cmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_pattern_lt().

311 {
312  text *left = PG_GETARG_TEXT_PP(0);
313  text *right = PG_GETARG_TEXT_PP(1);
314  bool result;
315 
316  result = internal_citext_pattern_cmp(left, right, PG_GET_COLLATION()) <= 0;
317 
318  PG_FREE_IF_COPY(left, 0);
319  PG_FREE_IF_COPY(right, 1);
320 
321  PG_RETURN_BOOL(result);
322 }
static int32 internal_citext_pattern_cmp(text *left, text *right, Oid collid)
Definition: citext.c:68
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_pattern_lt()

Datum citext_pattern_lt ( PG_FUNCTION_ARGS  )

Definition at line 293 of file citext.c.

References citext_pattern_le(), internal_citext_pattern_cmp(), PG_FREE_IF_COPY, PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

Referenced by citext_ge().

294 {
295  text *left = PG_GETARG_TEXT_PP(0);
296  text *right = PG_GETARG_TEXT_PP(1);
297  bool result;
298 
299  result = internal_citext_pattern_cmp(left, right, PG_GET_COLLATION()) < 0;
300 
301  PG_FREE_IF_COPY(left, 0);
302  PG_FREE_IF_COPY(right, 1);
303 
304  PG_RETURN_BOOL(result);
305 }
static int32 internal_citext_pattern_cmp(text *left, text *right, Oid collid)
Definition: citext.c:68
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:319
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:225
Definition: c.h:487

◆ citext_smaller()

Datum citext_smaller ( PG_FUNCTION_ARGS  )

Definition at line 367 of file citext.c.

References citext_larger(), citextcmp(), PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_TEXT_P.

Referenced by citext_pattern_ge().

368 {
369  text *left = PG_GETARG_TEXT_PP(0);
370  text *right = PG_GETARG_TEXT_PP(1);
371  text *result;
372 
373  result = citextcmp(left, right, PG_GET_COLLATION()) < 0 ? left : right;
374  PG_RETURN_TEXT_P(result);
375 }
static int32 citextcmp(text *left, text *right, Oid collid)
Definition: citext.c:35
#define PG_GET_COLLATION()
Definition: fmgr.h:163
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:273
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:331
Definition: c.h:487

◆ citextcmp()

static int32 citextcmp ( text left,
text right,
Oid  collid 
)
static

Definition at line 35 of file citext.c.

References DEFAULT_COLLATION_OID, pfree(), str_tolower(), VARDATA_ANY, VARSIZE_ANY_EXHDR, and varstr_cmp().

Referenced by citext_cmp(), citext_ge(), citext_gt(), citext_larger(), citext_le(), citext_lt(), and citext_smaller().

36 {
37  char *lcstr,
38  *rcstr;
39  int32 result;
40 
41  /*
42  * We must do our str_tolower calls with DEFAULT_COLLATION_OID, not the
43  * input collation as you might expect. This is so that the behavior of
44  * citext's equality and hashing functions is not collation-dependent. We
45  * should change this once the core infrastructure is able to cope with
46  * collation-dependent equality and hashing functions.
47  */
48 
51 
52  result = varstr_cmp(lcstr, strlen(lcstr),
53  rcstr, strlen(rcstr),
54  collid);
55 
56  pfree(lcstr);
57  pfree(rcstr);
58 
59  return result;
60 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
char * str_tolower(const char *buff, size_t nbytes, Oid collid)
Definition: formatting.c:1508
signed int int32
Definition: c.h:284
void pfree(void *pointer)
Definition: mcxt.c:949
int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)
Definition: varlena.c:1382
#define DEFAULT_COLLATION_OID
Definition: pg_collation.h:75
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:340

◆ internal_citext_pattern_cmp()

static int32 internal_citext_pattern_cmp ( text left,
text right,
Oid  collid 
)
static

Definition at line 68 of file citext.c.

References citext_cmp(), DEFAULT_COLLATION_OID, Min, pfree(), PG_FUNCTION_INFO_V1(), str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by citext_pattern_cmp(), citext_pattern_ge(), citext_pattern_gt(), citext_pattern_le(), and citext_pattern_lt().

69 {
70  char *lcstr,
71  *rcstr;
72  int llen,
73  rlen;
74  int32 result;
75 
78 
79  llen = strlen(lcstr);
80  rlen = strlen(rcstr);
81 
82  result = memcmp((void *) lcstr, (void *) rcstr, Min(llen, rlen));
83  if (result == 0)
84  {
85  if (llen < rlen)
86  result = -1;
87  else if (llen > rlen)
88  result = 1;
89  }
90 
91  pfree(lcstr);
92  pfree(rcstr);
93 
94  return result;
95 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
char * str_tolower(const char *buff, size_t nbytes, Oid collid)
Definition: formatting.c:1508
#define Min(x, y)
Definition: c.h:802
signed int int32
Definition: c.h:284
void pfree(void *pointer)
Definition: mcxt.c:949
#define DEFAULT_COLLATION_OID
Definition: pg_collation.h:75
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:340

◆ PG_FUNCTION_INFO_V1() [1/15]

◆ PG_FUNCTION_INFO_V1() [2/15]

PG_FUNCTION_INFO_V1 ( citext_pattern_cmp  )

◆ PG_FUNCTION_INFO_V1() [3/15]

PG_FUNCTION_INFO_V1 ( citext_hash  )

◆ PG_FUNCTION_INFO_V1() [4/15]

PG_FUNCTION_INFO_V1 ( citext_eq  )

◆ PG_FUNCTION_INFO_V1() [5/15]

PG_FUNCTION_INFO_V1 ( citext_ne  )

◆ PG_FUNCTION_INFO_V1() [6/15]

PG_FUNCTION_INFO_V1 ( citext_lt  )

◆ PG_FUNCTION_INFO_V1() [7/15]

PG_FUNCTION_INFO_V1 ( citext_le  )

◆ PG_FUNCTION_INFO_V1() [8/15]

PG_FUNCTION_INFO_V1 ( citext_gt  )

◆ PG_FUNCTION_INFO_V1() [9/15]

PG_FUNCTION_INFO_V1 ( citext_ge  )

◆ PG_FUNCTION_INFO_V1() [10/15]

PG_FUNCTION_INFO_V1 ( citext_pattern_lt  )

◆ PG_FUNCTION_INFO_V1() [11/15]

PG_FUNCTION_INFO_V1 ( citext_pattern_le  )

◆ PG_FUNCTION_INFO_V1() [12/15]

PG_FUNCTION_INFO_V1 ( citext_pattern_gt  )

◆ PG_FUNCTION_INFO_V1() [13/15]

PG_FUNCTION_INFO_V1 ( citext_pattern_ge  )

◆ PG_FUNCTION_INFO_V1() [14/15]

PG_FUNCTION_INFO_V1 ( citext_smaller  )

◆ PG_FUNCTION_INFO_V1() [15/15]

PG_FUNCTION_INFO_V1 ( citext_larger  )

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 12 of file citext.c.