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

Commit409f530

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 parentc3d1131 commit409f530

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
@@ -1057,11 +1057,16 @@ GetMessageEncoding(void)
10571057
WCHAR*
10581058
pgwin32_message_to_UTF16(constchar*str,intlen,int*utf16len)
10591059
{
1060+
intmsgenc=GetMessageEncoding();
10601061
WCHAR*utf16;
10611062
intdstlen;
10621063
UINTcodepage;
10631064

1064-
codepage=pg_enc2name_tbl[GetMessageEncoding()].codepage;
1065+
if (msgenc==PG_SQL_ASCII)
1066+
/* No conversion is possible, and SQL_ASCII is never utf16. */
1067+
returnNULL;
1068+
1069+
codepage=pg_enc2name_tbl[msgenc].codepage;
10651070

10661071
/*
10671072
* Use MultiByteToWideChar directly if there is a corresponding codepage,
@@ -1086,7 +1091,7 @@ pgwin32_message_to_UTF16(const char *str, int len, int *utf16len)
10861091
{
10871092
utf8= (char*)pg_do_encoding_conversion((unsignedchar*)str,
10881093
len,
1089-
GetMessageEncoding(),
1094+
msgenc,
10901095
PG_UTF8);
10911096
if (utf8!=str)
10921097
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