#include "postgres.h"
#include "access/hash.h"
#include "catalog/pg_collation.h"
#include "utils/builtins.h"
#include "utils/formatting.h"
Go to the source code of this file.
Functions | |
static int32 | citextcmp (text *left, text *right, Oid collid) |
Datum | citext_cmp (PG_FUNCTION_ARGS) |
Datum | citext_hash (PG_FUNCTION_ARGS) |
Datum | citext_eq (PG_FUNCTION_ARGS) |
Datum | citext_ne (PG_FUNCTION_ARGS) |
Datum | citext_gt (PG_FUNCTION_ARGS) |
Datum | citext_ge (PG_FUNCTION_ARGS) |
Datum | citext_lt (PG_FUNCTION_ARGS) |
Datum | citext_le (PG_FUNCTION_ARGS) |
Datum | citext_smaller (PG_FUNCTION_ARGS) |
Datum | citext_larger (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (citext_cmp) | |
PG_FUNCTION_INFO_V1 (citext_hash) | |
PG_FUNCTION_INFO_V1 (citext_eq) | |
PG_FUNCTION_INFO_V1 (citext_ne) | |
PG_FUNCTION_INFO_V1 (citext_lt) | |
PG_FUNCTION_INFO_V1 (citext_le) | |
PG_FUNCTION_INFO_V1 (citext_gt) | |
PG_FUNCTION_INFO_V1 (citext_ge) | |
PG_FUNCTION_INFO_V1 (citext_smaller) | |
PG_FUNCTION_INFO_V1 (citext_larger) |
Datum citext_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 81 of file citext.c.
References citextcmp(), PG_FREE_IF_COPY, PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_INT32.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); int32 result; result = citextcmp(left, right, PG_GET_COLLATION()); PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_INT32(result); }
Datum citext_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 123 of file citext.c.
References DEFAULT_COLLATION_OID, pfree(), PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); char *lcstr, *rcstr; bool result; /* We can't compare lengths in advance of downcasing ... */ lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left), DEFAULT_COLLATION_OID); rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right), DEFAULT_COLLATION_OID); /* * Since we only care about equality or not-equality, we can avoid all the * expense of strcoll() here, and just do bitwise comparison. */ result = (strcmp(lcstr, rcstr) == 0); pfree(lcstr); pfree(rcstr); PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_ge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 234 of file citext.c.
References citextcmp(), PG_FREE_IF_COPY, PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); bool result; result = citextcmp(left, right, PG_GET_COLLATION()) >= 0; PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_gt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 217 of file citext.c.
References citextcmp(), PG_FREE_IF_COPY, PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); bool result; result = citextcmp(left, right, PG_GET_COLLATION()) > 0; PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_hash | ( | PG_FUNCTION_ARGS | ) |
Definition at line 98 of file citext.c.
References DEFAULT_COLLATION_OID, hash_any(), pfree(), PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
{ text *txt = PG_GETARG_TEXT_PP(0); char *str; Datum result; str = str_tolower(VARDATA_ANY(txt), VARSIZE_ANY_EXHDR(txt), DEFAULT_COLLATION_OID); result = hash_any((unsigned char *) str, strlen(str)); pfree(str); /* Avoid leaking memory for toasted inputs */ PG_FREE_IF_COPY(txt, 0); PG_RETURN_DATUM(result); }
Datum citext_larger | ( | PG_FUNCTION_ARGS | ) |
Definition at line 270 of file citext.c.
References citextcmp(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_TEXT_P.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); text *result; result = citextcmp(left, right, PG_GET_COLLATION()) > 0 ? left : right; PG_RETURN_TEXT_P(result); }
Datum citext_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 200 of file citext.c.
References citextcmp(), PG_FREE_IF_COPY, PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); bool result; result = citextcmp(left, right, PG_GET_COLLATION()) <= 0; PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_lt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 183 of file citext.c.
References citextcmp(), PG_FREE_IF_COPY, PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); bool result; result = citextcmp(left, right, PG_GET_COLLATION()) < 0; PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 153 of file citext.c.
References DEFAULT_COLLATION_OID, pfree(), PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, str_tolower(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); char *lcstr, *rcstr; bool result; /* We can't compare lengths in advance of downcasing ... */ lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left), DEFAULT_COLLATION_OID); rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right), DEFAULT_COLLATION_OID); /* * Since we only care about equality or not-equality, we can avoid all the * expense of strcoll() here, and just do bitwise comparison. */ result = (strcmp(lcstr, rcstr) != 0); pfree(lcstr); pfree(rcstr); PG_FREE_IF_COPY(left, 0); PG_FREE_IF_COPY(right, 1); PG_RETURN_BOOL(result); }
Datum citext_smaller | ( | PG_FUNCTION_ARGS | ) |
Definition at line 257 of file citext.c.
References citextcmp(), PG_GET_COLLATION, PG_GETARG_TEXT_PP, and PG_RETURN_TEXT_P.
{ text *left = PG_GETARG_TEXT_PP(0); text *right = PG_GETARG_TEXT_PP(1); text *result; result = citextcmp(left, right, PG_GET_COLLATION()) < 0 ? left : right; PG_RETURN_TEXT_P(result); }
Definition at line 45 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().
{ char *lcstr, *rcstr; int32 result; /* * We must do our str_tolower calls with DEFAULT_COLLATION_OID, not the * input collation as you might expect. This is so that the behavior of * citext's equality and hashing functions is not collation-dependent. We * should change this once the core infrastructure is able to cope with * collation-dependent equality and hashing functions. */ lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left), DEFAULT_COLLATION_OID); rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right), DEFAULT_COLLATION_OID); result = varstr_cmp(lcstr, strlen(lcstr), rcstr, strlen(rcstr), collid); pfree(lcstr); pfree(rcstr); return result; }
PG_FUNCTION_INFO_V1 | ( | citext_larger | ) |
PG_FUNCTION_INFO_V1 | ( | citext_ne | ) |
PG_FUNCTION_INFO_V1 | ( | citext_le | ) |
PG_FUNCTION_INFO_V1 | ( | citext_lt | ) |
PG_FUNCTION_INFO_V1 | ( | citext_smaller | ) |
PG_FUNCTION_INFO_V1 | ( | citext_ge | ) |
PG_FUNCTION_INFO_V1 | ( | citext_eq | ) |
PG_FUNCTION_INFO_V1 | ( | citext_hash | ) |
PG_FUNCTION_INFO_V1 | ( | citext_gt | ) |
PG_FUNCTION_INFO_V1 | ( | citext_cmp | ) |