Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd115de9

Browse files
committed
Special case C_COLLATION_OID in pg_newlocale_from_collation().
Allow pg_newlocale_from_collation(C_COLLATION_OID) to work even ifthere's no catalog access, which some extensions expect.Not known to be a bug without extensions involved, but backport to 18.Also corrects an issue in master with dummy_c_locale (introduced incommit5a38104) where deterministic was not set. That wasn't a bug,but could have been if that structure was used more widely.Reported-by: Alexander Kukushkin <cyberdemn@gmail.com>Reviewed-by: Alexander Kukushkin <cyberdemn@gmail.com>Discussion:https://postgr.es/m/CAFh8B=nj966ECv5vi_u3RYij12v0j-7NPZCXLYzNwOQp9AcPWQ@mail.gmail.comBackpatch-through: 18
1 parent8ae0f6a commitd115de9

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

‎src/backend/regex/regc_pg_locale.c‎

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323

2424
staticpg_locale_tpg_regex_locale;
2525

26-
staticstructpg_locale_structdummy_c_locale= {
27-
.collate_is_c= true,
28-
.ctype_is_c= true,
29-
};
30-
3126

3227
/*
3328
* pg_set_regex_collation: set collation for these functions to obey
@@ -53,33 +48,12 @@ pg_set_regex_collation(Oid collation)
5348
errhint("Use the COLLATE clause to set the collation explicitly.")));
5449
}
5550

56-
if (collation==C_COLLATION_OID)
57-
{
58-
/*
59-
* Some callers expect regexes to work for C_COLLATION_OID before
60-
* catalog access is available, so we can't call
61-
* pg_newlocale_from_collation().
62-
*/
63-
locale=&dummy_c_locale;
64-
}
65-
else
66-
{
67-
locale=pg_newlocale_from_collation(collation);
68-
69-
if (!locale->deterministic)
70-
ereport(ERROR,
71-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
72-
errmsg("nondeterministic collations are not supported for regular expressions")));
51+
locale=pg_newlocale_from_collation(collation);
7352

74-
if (locale->ctype_is_c)
75-
{
76-
/*
77-
* C/POSIX collations use this path regardless of database
78-
* encoding
79-
*/
80-
locale=&dummy_c_locale;
81-
}
82-
}
53+
if (!locale->deterministic)
54+
ereport(ERROR,
55+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
56+
errmsg("nondeterministic collations are not supported for regular expressions")));
8357

8458
pg_regex_locale=locale;
8559
}

‎src/backend/utils/adt/pg_locale.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ static pg_locale_t default_locale = NULL;
106106
staticboolCurrentLocaleConvValid= false;
107107
staticboolCurrentLCTimeValid= false;
108108

109+
staticstructpg_locale_structc_locale= {
110+
.deterministic= true,
111+
.collate_is_c= true,
112+
.ctype_is_c= true,
113+
};
114+
109115
/* Cache for collation-related knowledge */
110116

111117
typedefstruct
@@ -1185,6 +1191,13 @@ pg_newlocale_from_collation(Oid collid)
11851191
if (collid==DEFAULT_COLLATION_OID)
11861192
returndefault_locale;
11871193

1194+
/*
1195+
* Some callers expect C_COLLATION_OID to succeed even without catalog
1196+
* access.
1197+
*/
1198+
if (collid==C_COLLATION_OID)
1199+
return&c_locale;
1200+
11881201
if (!OidIsValid(collid))
11891202
elog(ERROR,"cache lookup failed for collation %u",collid);
11901203

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp