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

Commitd96efc2

Browse files
jeff-davispull[bot]
authored andcommitted
Be more careful with error paths in pg_set_regex_collation().
Set global variables after error paths so that they don't end up in aninconsistent state.The inconsistent state doesn't lead to an actual problem, becauseafter an error, pg_set_regex_collation() will be called again beforethe globals are accessed.Change extracted from patch by Andreas Karlsson, though not discussedexplicitly.Discussion:https://postgr.es/m/60929555-4709-40a7-b136-bcb44cff5a3c@proxel.se
1 parent788fa9f commitd96efc2

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

‎src/backend/regex/regc_pg_locale.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ static const unsigned char pg_char_properties[128] = {
231231
void
232232
pg_set_regex_collation(Oidcollation)
233233
{
234+
pg_locale_tlocale=0;
235+
PG_Locale_Strategystrategy;
236+
234237
if (!OidIsValid(collation))
235238
{
236239
/*
@@ -246,40 +249,41 @@ pg_set_regex_collation(Oid collation)
246249
if (lc_ctype_is_c(collation))
247250
{
248251
/* C/POSIX collations use this path regardless of database encoding */
249-
pg_regex_strategy=PG_REGEX_STRATEGY_C;
250-
pg_regex_locale=0;
251-
pg_regex_collation=C_COLLATION_OID;
252+
strategy=PG_REGEX_STRATEGY_C;
253+
collation=C_COLLATION_OID;
252254
}
253255
else
254256
{
255-
pg_regex_locale=pg_newlocale_from_collation(collation);
257+
locale=pg_newlocale_from_collation(collation);
256258

257-
if (!pg_locale_deterministic(pg_regex_locale))
259+
if (!pg_locale_deterministic(locale))
258260
ereport(ERROR,
259261
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
260262
errmsg("nondeterministic collations are not supported for regular expressions")));
261263

262-
if (pg_regex_locale->provider==COLLPROVIDER_BUILTIN)
264+
if (locale->provider==COLLPROVIDER_BUILTIN)
263265
{
264266
Assert(GetDatabaseEncoding()==PG_UTF8);
265-
pg_regex_strategy=PG_REGEX_STRATEGY_BUILTIN;
267+
strategy=PG_REGEX_STRATEGY_BUILTIN;
266268
}
267269
#ifdefUSE_ICU
268-
elseif (pg_regex_locale->provider==COLLPROVIDER_ICU)
270+
elseif (locale->provider==COLLPROVIDER_ICU)
269271
{
270-
pg_regex_strategy=PG_REGEX_STRATEGY_ICU;
272+
strategy=PG_REGEX_STRATEGY_ICU;
271273
}
272274
#endif
273275
else
274276
{
275277
if (GetDatabaseEncoding()==PG_UTF8)
276-
pg_regex_strategy=PG_REGEX_STRATEGY_LIBC_WIDE;
278+
strategy=PG_REGEX_STRATEGY_LIBC_WIDE;
277279
else
278-
pg_regex_strategy=PG_REGEX_STRATEGY_LIBC_1BYTE;
280+
strategy=PG_REGEX_STRATEGY_LIBC_1BYTE;
279281
}
280-
281-
pg_regex_collation=collation;
282282
}
283+
284+
pg_regex_strategy=strategy;
285+
pg_regex_locale=locale;
286+
pg_regex_collation=collation;
283287
}
284288

285289
staticint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp