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

Commitd02768d

Browse files
committed
Fail pgwin32_message_to_UTF16() for SQL_ASCII messages.
The function had been interpreting SQL_ASCII messages as UTF8, throwingan error when they were invalid UTF8. The new behavior is consistentwith pg_do_encoding_conversion(). This affects LOG_DESTINATION_STDERRand LOG_DESTINATION_EVENTLOG, which will send untranslated bytes towrite() and ReportEventA(). On buildfarm member bowerbird, enablinglog_connections caused an error whenever the role name was not validUTF8. Back-patch to 9.4 (all supported versions).Discussion:https://postgr.es/m/20190512015615.GD1124997@rfd.leadboat.com
1 parent85ccb68 commitd02768d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

‎src/backend/utils/mb/mbutils.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,16 @@ GetMessageEncoding(void)
10461046
WCHAR*
10471047
pgwin32_message_to_UTF16(constchar*str,intlen,int*utf16len)
10481048
{
1049+
intmsgenc=GetMessageEncoding();
10491050
WCHAR*utf16;
10501051
intdstlen;
10511052
UINTcodepage;
10521053

1053-
codepage=pg_enc2name_tbl[GetMessageEncoding()].codepage;
1054+
if (msgenc==PG_SQL_ASCII)
1055+
/* No conversion is possible, and SQL_ASCII is never utf16. */
1056+
returnNULL;
1057+
1058+
codepage=pg_enc2name_tbl[msgenc].codepage;
10541059

10551060
/*
10561061
* Use MultiByteToWideChar directly if there is a corresponding codepage,
@@ -1075,7 +1080,7 @@ pgwin32_message_to_UTF16(const char *str, int len, int *utf16len)
10751080
{
10761081
utf8= (char*)pg_do_encoding_conversion((unsignedchar*)str,
10771082
len,
1078-
GetMessageEncoding(),
1083+
msgenc,
10791084
PG_UTF8);
10801085
if (utf8!=str)
10811086
len=strlen(utf8);

‎src/bin/pg_dump/t/010_dump_connstr.pl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
plantests=> 14;
1515
}
1616

17-
# In a SQL_ASCII database, pgwin32_message_to_UTF16() needs to
18-
# interpret everything as UTF8. We're going to use byte sequences
19-
# that aren't valid UTF-8 strings, so that would fail. Use LATIN1,
20-
# which accepts any byte and has a conversion from each byte to UTF-8.
17+
# We're going to use byte sequences that aren't valid UTF-8 strings. Use
18+
# LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
2119
$ENV{LC_ALL} ='C';
2220
$ENV{PGCLIENTENCODING} ='LATIN1';
2321

‎src/bin/scripts/t/200_connstr.pl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
# Tests to check connection string handling in utilities
99

10-
# In a SQL_ASCII database, pgwin32_message_to_UTF16() needs to
11-
# interpret everything as UTF8. We're going to use byte sequences
12-
# that aren't valid UTF-8 strings, so that would fail. Use LATIN1,
13-
# which accepts any byte and has a conversion from each byte to UTF-8.
10+
# We're going to use byte sequences that aren't valid UTF-8 strings. Use
11+
# LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
1412
$ENV{LC_ALL} ='C';
1513
$ENV{PGCLIENTENCODING} ='LATIN1';
1614

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp