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

Commit489be9c

Browse files
committed
Don't downcase non-ascii identifier chars in multi-byte encodings.
Long-standing code has called tolower() on identifier character byteswith the high bit set. This is clearly an error and produces junk outputwhen the encoding is multi-byte. This patch therefore restricts thisactivity to cases where there is a character with the high bit set ANDthe encoding is single-byte.There have been numerous gripes about this, most recently from MartinSchäfer.Backpatch to all live releases.
1 parent88ce29a commit489be9c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/parser/scansup.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,27 @@ downcase_truncate_identifier(const char *ident, int len, bool warn)
130130
{
131131
char*result;
132132
inti;
133+
boolenc_is_single_byte;
133134

134135
result=palloc(len+1);
136+
enc_is_single_byte=pg_database_encoding_max_length()==1;
135137

136138
/*
137139
* SQL99 specifies Unicode-aware case normalization, which we don't yet
138140
* have the infrastructure for. Instead we use tolower() to provide a
139141
* locale-aware translation. However, there are some locales where this
140142
* is not right either (eg, Turkish may do strange things with 'i' and
141143
* 'I'). Our current compromise is to use tolower() for characters with
142-
* the high bit set,and use an ASCII-only downcasing for 7-bit
143-
* characters.
144+
* the high bit set,as long as they aren't part of a multi-byte character,
145+
*and use an ASCII-only downcasing for 7-bitcharacters.
144146
*/
145147
for (i=0;i<len;i++)
146148
{
147149
unsignedcharch= (unsignedchar)ident[i];
148150

149151
if (ch >='A'&&ch <='Z')
150152
ch+='a'-'A';
151-
elseif (IS_HIGHBIT_SET(ch)&&isupper(ch))
153+
elseif (enc_is_single_byte&&IS_HIGHBIT_SET(ch)&&isupper(ch))
152154
ch=tolower(ch);
153155
result[i]= (char)ch;
154156
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp