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

Commite9931bf

Browse files
committed
Remove support for null pg_locale_t most places.
Previously, passing NULL for pg_locale_t meant "use the libc providerand the server environment". Now that the database collation isrepresented as a proper pg_locale_t (not dependent on setlocale()),remove special cases for NULL.Leave wchar2char() and char2wchar() unchanged for now, because thecallers don't always have a libc-based pg_locale_t available.Discussion:https://postgr.es/m/cfd9eb85-c52a-4ec9-a90e-a5e4de56e57d@eisentraut.orgReviewed-by: Peter Eisentraut, Andreas Karlsson
1 parentf80b09b commite9931bf

File tree

7 files changed

+73
-255
lines changed

7 files changed

+73
-255
lines changed

‎src/backend/access/hash/hashfunc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ hashtext(PG_FUNCTION_ARGS)
268268
{
269269
text*key=PG_GETARG_TEXT_PP(0);
270270
Oidcollid=PG_GET_COLLATION();
271-
pg_locale_tmylocale=0;
271+
pg_locale_tmylocale;
272272
Datumresult;
273273

274274
if (!collid)
@@ -277,8 +277,7 @@ hashtext(PG_FUNCTION_ARGS)
277277
errmsg("could not determine which collation to use for string hashing"),
278278
errhint("Use the COLLATE clause to set the collation explicitly.")));
279279

280-
if (!lc_collate_is_c(collid))
281-
mylocale=pg_newlocale_from_collation(collid);
280+
mylocale=pg_newlocale_from_collation(collid);
282281

283282
if (pg_locale_deterministic(mylocale))
284283
{
@@ -324,7 +323,7 @@ hashtextextended(PG_FUNCTION_ARGS)
324323
{
325324
text*key=PG_GETARG_TEXT_PP(0);
326325
Oidcollid=PG_GET_COLLATION();
327-
pg_locale_tmylocale=0;
326+
pg_locale_tmylocale;
328327
Datumresult;
329328

330329
if (!collid)
@@ -333,8 +332,7 @@ hashtextextended(PG_FUNCTION_ARGS)
333332
errmsg("could not determine which collation to use for string hashing"),
334333
errhint("Use the COLLATE clause to set the collation explicitly.")));
335334

336-
if (!lc_collate_is_c(collid))
337-
mylocale=pg_newlocale_from_collation(collid);
335+
mylocale=pg_newlocale_from_collation(collid);
338336

339337
if (pg_locale_deterministic(mylocale))
340338
{

‎src/backend/regex/regc_pg_locale.c

Lines changed: 4 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ typedef enum
6767
{
6868
PG_REGEX_LOCALE_C,/* C locale (encoding independent) */
6969
PG_REGEX_BUILTIN,/* built-in Unicode semantics */
70-
PG_REGEX_LOCALE_WIDE,/* Use <wctype.h> functions */
71-
PG_REGEX_LOCALE_1BYTE,/* Use <ctype.h> functions */
7270
PG_REGEX_LOCALE_WIDE_L,/* Use locale_t <wctype.h> functions */
7371
PG_REGEX_LOCALE_1BYTE_L,/* Use locale_t <ctype.h> functions */
7472
PG_REGEX_LOCALE_ICU,/* Use ICU uchar.h functions */
@@ -261,33 +259,23 @@ pg_set_regex_collation(Oid collation)
261259
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
262260
errmsg("nondeterministic collations are not supported for regular expressions")));
263261

264-
if (pg_regex_locale&&pg_regex_locale->provider==COLLPROVIDER_BUILTIN)
262+
if (pg_regex_locale->provider==COLLPROVIDER_BUILTIN)
265263
{
266264
Assert(GetDatabaseEncoding()==PG_UTF8);
267265
pg_regex_strategy=PG_REGEX_BUILTIN;
268266
}
269267
#ifdefUSE_ICU
270-
elseif (pg_regex_locale&&pg_regex_locale->provider==COLLPROVIDER_ICU)
268+
elseif (pg_regex_locale->provider==COLLPROVIDER_ICU)
271269
{
272270
pg_regex_strategy=PG_REGEX_LOCALE_ICU;
273271
}
274272
#endif
275273
else
276274
{
277275
if (GetDatabaseEncoding()==PG_UTF8)
278-
{
279-
if (pg_regex_locale)
280-
pg_regex_strategy=PG_REGEX_LOCALE_WIDE_L;
281-
else
282-
pg_regex_strategy=PG_REGEX_LOCALE_WIDE;
283-
}
276+
pg_regex_strategy=PG_REGEX_LOCALE_WIDE_L;
284277
else
285-
{
286-
if (pg_regex_locale)
287-
pg_regex_strategy=PG_REGEX_LOCALE_1BYTE_L;
288-
else
289-
pg_regex_strategy=PG_REGEX_LOCALE_1BYTE;
290-
}
278+
pg_regex_strategy=PG_REGEX_LOCALE_1BYTE_L;
291279
}
292280

293281
pg_regex_collation=collation;
@@ -304,13 +292,6 @@ pg_wc_isdigit(pg_wchar c)
304292
(pg_char_properties[c]&PG_ISDIGIT));
305293
casePG_REGEX_BUILTIN:
306294
returnpg_u_isdigit(c, true);
307-
casePG_REGEX_LOCALE_WIDE:
308-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
309-
returniswdigit((wint_t)c);
310-
/* FALL THRU */
311-
casePG_REGEX_LOCALE_1BYTE:
312-
return (c <= (pg_wchar)UCHAR_MAX&&
313-
isdigit((unsignedchar)c));
314295
casePG_REGEX_LOCALE_WIDE_L:
315296
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
316297
returniswdigit_l((wint_t)c,pg_regex_locale->info.lt);
@@ -338,13 +319,6 @@ pg_wc_isalpha(pg_wchar c)
338319
(pg_char_properties[c]&PG_ISALPHA));
339320
casePG_REGEX_BUILTIN:
340321
returnpg_u_isalpha(c);
341-
casePG_REGEX_LOCALE_WIDE:
342-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
343-
returniswalpha((wint_t)c);
344-
/* FALL THRU */
345-
casePG_REGEX_LOCALE_1BYTE:
346-
return (c <= (pg_wchar)UCHAR_MAX&&
347-
isalpha((unsignedchar)c));
348322
casePG_REGEX_LOCALE_WIDE_L:
349323
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
350324
returniswalpha_l((wint_t)c,pg_regex_locale->info.lt);
@@ -372,13 +346,6 @@ pg_wc_isalnum(pg_wchar c)
372346
(pg_char_properties[c]&PG_ISALNUM));
373347
casePG_REGEX_BUILTIN:
374348
returnpg_u_isalnum(c, true);
375-
casePG_REGEX_LOCALE_WIDE:
376-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
377-
returniswalnum((wint_t)c);
378-
/* FALL THRU */
379-
casePG_REGEX_LOCALE_1BYTE:
380-
return (c <= (pg_wchar)UCHAR_MAX&&
381-
isalnum((unsignedchar)c));
382349
casePG_REGEX_LOCALE_WIDE_L:
383350
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
384351
returniswalnum_l((wint_t)c,pg_regex_locale->info.lt);
@@ -415,13 +382,6 @@ pg_wc_isupper(pg_wchar c)
415382
(pg_char_properties[c]&PG_ISUPPER));
416383
casePG_REGEX_BUILTIN:
417384
returnpg_u_isupper(c);
418-
casePG_REGEX_LOCALE_WIDE:
419-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
420-
returniswupper((wint_t)c);
421-
/* FALL THRU */
422-
casePG_REGEX_LOCALE_1BYTE:
423-
return (c <= (pg_wchar)UCHAR_MAX&&
424-
isupper((unsignedchar)c));
425385
casePG_REGEX_LOCALE_WIDE_L:
426386
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
427387
returniswupper_l((wint_t)c,pg_regex_locale->info.lt);
@@ -449,13 +409,6 @@ pg_wc_islower(pg_wchar c)
449409
(pg_char_properties[c]&PG_ISLOWER));
450410
casePG_REGEX_BUILTIN:
451411
returnpg_u_islower(c);
452-
casePG_REGEX_LOCALE_WIDE:
453-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
454-
returniswlower((wint_t)c);
455-
/* FALL THRU */
456-
casePG_REGEX_LOCALE_1BYTE:
457-
return (c <= (pg_wchar)UCHAR_MAX&&
458-
islower((unsignedchar)c));
459412
casePG_REGEX_LOCALE_WIDE_L:
460413
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
461414
returniswlower_l((wint_t)c,pg_regex_locale->info.lt);
@@ -483,13 +436,6 @@ pg_wc_isgraph(pg_wchar c)
483436
(pg_char_properties[c]&PG_ISGRAPH));
484437
casePG_REGEX_BUILTIN:
485438
returnpg_u_isgraph(c);
486-
casePG_REGEX_LOCALE_WIDE:
487-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
488-
returniswgraph((wint_t)c);
489-
/* FALL THRU */
490-
casePG_REGEX_LOCALE_1BYTE:
491-
return (c <= (pg_wchar)UCHAR_MAX&&
492-
isgraph((unsignedchar)c));
493439
casePG_REGEX_LOCALE_WIDE_L:
494440
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
495441
returniswgraph_l((wint_t)c,pg_regex_locale->info.lt);
@@ -517,13 +463,6 @@ pg_wc_isprint(pg_wchar c)
517463
(pg_char_properties[c]&PG_ISPRINT));
518464
casePG_REGEX_BUILTIN:
519465
returnpg_u_isprint(c);
520-
casePG_REGEX_LOCALE_WIDE:
521-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
522-
returniswprint((wint_t)c);
523-
/* FALL THRU */
524-
casePG_REGEX_LOCALE_1BYTE:
525-
return (c <= (pg_wchar)UCHAR_MAX&&
526-
isprint((unsignedchar)c));
527466
casePG_REGEX_LOCALE_WIDE_L:
528467
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
529468
returniswprint_l((wint_t)c,pg_regex_locale->info.lt);
@@ -551,13 +490,6 @@ pg_wc_ispunct(pg_wchar c)
551490
(pg_char_properties[c]&PG_ISPUNCT));
552491
casePG_REGEX_BUILTIN:
553492
returnpg_u_ispunct(c, true);
554-
casePG_REGEX_LOCALE_WIDE:
555-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
556-
returniswpunct((wint_t)c);
557-
/* FALL THRU */
558-
casePG_REGEX_LOCALE_1BYTE:
559-
return (c <= (pg_wchar)UCHAR_MAX&&
560-
ispunct((unsignedchar)c));
561493
casePG_REGEX_LOCALE_WIDE_L:
562494
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
563495
returniswpunct_l((wint_t)c,pg_regex_locale->info.lt);
@@ -585,13 +517,6 @@ pg_wc_isspace(pg_wchar c)
585517
(pg_char_properties[c]&PG_ISSPACE));
586518
casePG_REGEX_BUILTIN:
587519
returnpg_u_isspace(c);
588-
casePG_REGEX_LOCALE_WIDE:
589-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
590-
returniswspace((wint_t)c);
591-
/* FALL THRU */
592-
casePG_REGEX_LOCALE_1BYTE:
593-
return (c <= (pg_wchar)UCHAR_MAX&&
594-
isspace((unsignedchar)c));
595520
casePG_REGEX_LOCALE_WIDE_L:
596521
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
597522
returniswspace_l((wint_t)c,pg_regex_locale->info.lt);
@@ -620,20 +545,6 @@ pg_wc_toupper(pg_wchar c)
620545
returnc;
621546
casePG_REGEX_BUILTIN:
622547
returnunicode_uppercase_simple(c);
623-
casePG_REGEX_LOCALE_WIDE:
624-
/* force C behavior for ASCII characters, per comments above */
625-
if (c <= (pg_wchar)127)
626-
returnpg_ascii_toupper((unsignedchar)c);
627-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
628-
returntowupper((wint_t)c);
629-
/* FALL THRU */
630-
casePG_REGEX_LOCALE_1BYTE:
631-
/* force C behavior for ASCII characters, per comments above */
632-
if (c <= (pg_wchar)127)
633-
returnpg_ascii_toupper((unsignedchar)c);
634-
if (c <= (pg_wchar)UCHAR_MAX)
635-
returntoupper((unsignedchar)c);
636-
returnc;
637548
casePG_REGEX_LOCALE_WIDE_L:
638549
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
639550
returntowupper_l((wint_t)c,pg_regex_locale->info.lt);
@@ -662,20 +573,6 @@ pg_wc_tolower(pg_wchar c)
662573
returnc;
663574
casePG_REGEX_BUILTIN:
664575
returnunicode_lowercase_simple(c);
665-
casePG_REGEX_LOCALE_WIDE:
666-
/* force C behavior for ASCII characters, per comments above */
667-
if (c <= (pg_wchar)127)
668-
returnpg_ascii_tolower((unsignedchar)c);
669-
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
670-
returntowlower((wint_t)c);
671-
/* FALL THRU */
672-
casePG_REGEX_LOCALE_1BYTE:
673-
/* force C behavior for ASCII characters, per comments above */
674-
if (c <= (pg_wchar)127)
675-
returnpg_ascii_tolower((unsignedchar)c);
676-
if (c <= (pg_wchar)UCHAR_MAX)
677-
returntolower((unsignedchar)c);
678-
returnc;
679576
casePG_REGEX_LOCALE_WIDE_L:
680577
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
681578
returntowlower_l((wint_t)c,pg_regex_locale->info.lt);
@@ -829,11 +726,9 @@ pg_ctype_get_cache(pg_wc_probefunc probefunc, int cclasscode)
829726
casePG_REGEX_BUILTIN:
830727
max_chr= (pg_wchar)MAX_SIMPLE_CHR;
831728
break;
832-
casePG_REGEX_LOCALE_WIDE:
833729
casePG_REGEX_LOCALE_WIDE_L:
834730
max_chr= (pg_wchar)MAX_SIMPLE_CHR;
835731
break;
836-
casePG_REGEX_LOCALE_1BYTE:
837732
casePG_REGEX_LOCALE_1BYTE_L:
838733
#ifMAX_SIMPLE_CHR >=UCHAR_MAX
839734
max_chr= (pg_wchar)UCHAR_MAX;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp