summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Davis2024-09-12 20:35:56 +0000
committerJeff Davis2024-09-12 20:35:56 +0000
commitb0c30612c5f6ce519172396527781a0666937363 (patch)
tree73f869bbb84842d9286d784b98d3836a1de1f372
parent6a9fc11033e61d0dde30d5114887714dbd7612d5 (diff)
Simplify checks for deterministic collations.
Remove redundant checks for locale->collate_is_c now that we always have a valid pg_locale_t. Also, remove pg_locale_deterministic() wrapper, which is no longer useful after commit e9931bfb75. Just check the field directly, consistent with other fields in pg_locale_t. Author: Andreas Karlsson Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/access/hash/hashfunc.c4
-rw-r--r--src/backend/regex/regc_pg_locale.c2
-rw-r--r--src/backend/utils/adt/like.c4
-rw-r--r--src/backend/utils/adt/pg_locale.c7
-rw-r--r--src/backend/utils/adt/varchar.c8
-rw-r--r--src/backend/utils/adt/varlena.c18
-rw-r--r--src/include/utils/pg_locale.h1
7 files changed, 16 insertions, 28 deletions
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c
index 2e3e5b06a61..eacc146bae3 100644
--- a/src/backend/access/hash/hashfunc.c
+++ b/src/backend/access/hash/hashfunc.c
@@ -279,7 +279,7 @@ hashtext(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
result = hash_any((unsigned char *) VARDATA_ANY(key),
VARSIZE_ANY_EXHDR(key));
@@ -334,7 +334,7 @@ hashtextextended(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
result = hash_any_extended((unsigned char *) VARDATA_ANY(key),
VARSIZE_ANY_EXHDR(key),
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c
index 8f34948ad37..b75784b6ce5 100644
--- a/src/backend/regex/regc_pg_locale.c
+++ b/src/backend/regex/regc_pg_locale.c
@@ -260,7 +260,7 @@ pg_set_regex_collation(Oid collation)
{
locale = pg_newlocale_from_collation(collation);
- if (!pg_locale_deterministic(locale))
+ if (!locale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for regular expressions")));
diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c
index f87675d7557..286b737fd71 100644
--- a/src/backend/utils/adt/like.c
+++ b/src/backend/utils/adt/like.c
@@ -151,7 +151,7 @@ GenericMatchText(const char *s, int slen, const char *p, int plen, Oid collation
{
pg_locale_t locale = pg_newlocale_from_collation(collation);
- if (!pg_locale_deterministic(locale))
+ if (!locale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for LIKE")));
@@ -188,7 +188,7 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
locale = pg_newlocale_from_collation(collation);
- if (!pg_locale_deterministic(locale))
+ if (!locale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for ILIKE")));
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index a738da5674f..5bef1b113a8 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1415,13 +1415,6 @@ make_icu_collator(const char *iculocstr,
#endif /* not USE_ICU */
}
-
-bool
-pg_locale_deterministic(pg_locale_t locale)
-{
- return locale->deterministic;
-}
-
/*
* Initialize default_locale with database locale settings.
*/
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index d2d1c5709d3..8f86aca2973 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -757,7 +757,7 @@ bpchareq(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (mylocale->collate_is_c || pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
/*
* Since we only care about equality or not-equality, we can avoid all
@@ -798,7 +798,7 @@ bpcharne(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (mylocale->collate_is_c || pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
/*
* Since we only care about equality or not-equality, we can avoid all
@@ -1005,7 +1005,7 @@ hashbpchar(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
result = hash_any((unsigned char *) keydata, keylen);
}
@@ -1061,7 +1061,7 @@ hashbpcharextended(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
result = hash_any_extended((unsigned char *) keydata, keylen,
PG_GETARG_INT64(1));
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 3658d0047b0..d46ed3ccf9f 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1223,7 +1223,7 @@ text_position_setup(text *t1, text *t2, Oid collid, TextPositionState *state)
mylocale = pg_newlocale_from_collation(collid);
- if (!pg_locale_deterministic(mylocale))
+ if (!mylocale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for substring searches")));
@@ -1567,7 +1567,7 @@ varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)
result = pg_strncoll(arg1, len1, arg2, len2, mylocale);
/* Break tie if necessary. */
- if (result == 0 && pg_locale_deterministic(mylocale))
+ if (result == 0 && mylocale->deterministic)
{
result = memcmp(arg1, arg2, Min(len1, len2));
if ((result == 0) && (len1 != len2))
@@ -1618,7 +1618,7 @@ texteq(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
Datum arg1 = PG_GETARG_DATUM(0);
Datum arg2 = PG_GETARG_DATUM(1);
@@ -1673,7 +1673,7 @@ textne(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (pg_locale_deterministic(mylocale))
+ if (mylocale->deterministic)
{
Datum arg1 = PG_GETARG_DATUM(0);
Datum arg2 = PG_GETARG_DATUM(1);
@@ -1786,7 +1786,7 @@ text_starts_with(PG_FUNCTION_ARGS)
mylocale = pg_newlocale_from_collation(collid);
- if (!pg_locale_deterministic(mylocale))
+ if (!mylocale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for substring searches")));
@@ -2200,7 +2200,7 @@ varstrfastcmp_locale(char *a1p, int len1, char *a2p, int len2, SortSupport ssup)
result = pg_strcoll(sss->buf1, sss->buf2, sss->locale);
/* Break tie if necessary. */
- if (result == 0 && pg_locale_deterministic(sss->locale))
+ if (result == 0 && sss->locale->deterministic)
result = strcmp(sss->buf1, sss->buf2);
/* Cache result, perhaps saving an expensive strcoll() call next time */
@@ -2539,11 +2539,7 @@ btvarstrequalimage(PG_FUNCTION_ARGS)
locale = pg_newlocale_from_collation(collid);
- if (locale->collate_is_c ||
- pg_locale_deterministic(locale))
- PG_RETURN_BOOL(true);
- else
- PG_RETURN_BOOL(false);
+ PG_RETURN_BOOL(locale->deterministic);
}
Datum
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index ab1c37a44b3..faae868bfcc 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -108,7 +108,6 @@ extern void make_icu_collator(const char *iculocstr,
const char *icurules,
struct pg_locale_struct *resultp);
-extern bool pg_locale_deterministic(pg_locale_t locale);
extern void init_database_collation(void);
extern pg_locale_t pg_newlocale_from_collation(Oid collid);