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

Commit8b87e92

Browse files
committed
Fix t_isspace(), etc., when datlocprovider=i and datctype=C.
Check whether the datctype is C to determine whether t_isspace() andrelated functions use isspace() or iswspace().Previously, t_isspace() checked whether the database default collationwas C; which is incorrect when the default collation uses the ICUprovider.Discussion:https://postgr.es/m/79e4354d9eccfdb00483146a6b9f6295202e7890.camel@j-davis.comReviewed-by: Peter EisentrautBackpatch-through: 15
1 parent2b216da commit8b87e92

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

‎src/backend/tsearch/ts_locale.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ t_isdigit(const char *ptr)
3838
{
3939
intclen=pg_mblen(ptr);
4040
wchar_tcharacter[WC_BUF_LEN];
41-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
4241
pg_locale_tmylocale=0;/* TODO */
4342

44-
if (clen==1||lc_ctype_is_c(collation))
43+
if (clen==1||database_ctype_is_c)
4544
returnisdigit(TOUCHAR(ptr));
4645

4746
char2wchar(character,WC_BUF_LEN,ptr,clen,mylocale);
@@ -54,10 +53,9 @@ t_isspace(const char *ptr)
5453
{
5554
intclen=pg_mblen(ptr);
5655
wchar_tcharacter[WC_BUF_LEN];
57-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
5856
pg_locale_tmylocale=0;/* TODO */
5957

60-
if (clen==1||lc_ctype_is_c(collation))
58+
if (clen==1||database_ctype_is_c)
6159
returnisspace(TOUCHAR(ptr));
6260

6361
char2wchar(character,WC_BUF_LEN,ptr,clen,mylocale);
@@ -70,10 +68,9 @@ t_isalpha(const char *ptr)
7068
{
7169
intclen=pg_mblen(ptr);
7270
wchar_tcharacter[WC_BUF_LEN];
73-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
7471
pg_locale_tmylocale=0;/* TODO */
7572

76-
if (clen==1||lc_ctype_is_c(collation))
73+
if (clen==1||database_ctype_is_c)
7774
returnisalpha(TOUCHAR(ptr));
7875

7976
char2wchar(character,WC_BUF_LEN,ptr,clen,mylocale);
@@ -86,10 +83,9 @@ t_isprint(const char *ptr)
8683
{
8784
intclen=pg_mblen(ptr);
8885
wchar_tcharacter[WC_BUF_LEN];
89-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
9086
pg_locale_tmylocale=0;/* TODO */
9187

92-
if (clen==1||lc_ctype_is_c(collation))
88+
if (clen==1||database_ctype_is_c)
9389
returnisprint(TOUCHAR(ptr));
9490

9591
char2wchar(character,WC_BUF_LEN,ptr,clen,mylocale);
@@ -257,7 +253,6 @@ char *
257253
lowerstr_with_len(constchar*str,intlen)
258254
{
259255
char*out;
260-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
261256
pg_locale_tmylocale=0;/* TODO */
262257

263258
if (len==0)
@@ -269,7 +264,7 @@ lowerstr_with_len(const char *str, int len)
269264
* Also, for a C locale there is no need to process as multibyte. From
270265
* backend/utils/adt/oracle_compat.c Teodor
271266
*/
272-
if (pg_database_encoding_max_length()>1&& !lc_ctype_is_c(collation))
267+
if (pg_database_encoding_max_length()>1&& !database_ctype_is_c)
273268
{
274269
wchar_t*wstr,
275270
*wptr;

‎src/backend/tsearch/wparser_def.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,10 @@ TParserInit(char *str, int len)
297297
*/
298298
if (prs->charmaxlen>1)
299299
{
300-
Oidcollation=DEFAULT_COLLATION_OID;/* TODO */
301300
pg_locale_tmylocale=0;/* TODO */
302301

303302
prs->usewide= true;
304-
if (lc_ctype_is_c(collation))
303+
if (database_ctype_is_c)
305304
{
306305
/*
307306
* char2wchar doesn't work for C-locale and sizeof(pg_wchar) could

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ char *localized_full_days[7 + 1];
9999
char*localized_abbrev_months[12+1];
100100
char*localized_full_months[12+1];
101101

102+
/* is the databases's LC_CTYPE the C locale? */
103+
booldatabase_ctype_is_c= false;
104+
102105
/* indicates whether locale information cache is valid */
103106
staticboolCurrentLocaleConvValid= false;
104107
staticboolCurrentLCTimeValid= false;

‎src/backend/utils/init/postinit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
418418
" which is not recognized by setlocale().",ctype),
419419
errhint("Recreate the database with another locale or install the missing locale.")));
420420

421+
if (strcmp(ctype,"C")==0||
422+
strcmp(ctype,"POSIX")==0)
423+
database_ctype_is_c= true;
424+
421425
if (dbform->datlocprovider==COLLPROVIDER_ICU)
422426
{
423427
datum=SysCacheGetAttr(DATABASEOID,tup,Anum_pg_database_daticulocale,&isnull);

‎src/include/utils/pg_locale.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ extern PGDLLIMPORT char *localized_full_days[];
4949
externPGDLLIMPORTchar*localized_abbrev_months[];
5050
externPGDLLIMPORTchar*localized_full_months[];
5151

52+
/* is the databases's LC_CTYPE the C locale? */
53+
externPGDLLIMPORTbooldatabase_ctype_is_c;
5254

5355
externboolcheck_locale_messages(char**newval,void**extra,GucSourcesource);
5456
externvoidassign_locale_messages(constchar*newval,void*extra);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp