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

Commit92516bf

Browse files
committed
Restore old pgwin32_message_to_UTF16() behavior outside transactions.
Commit49c817e replaced with a harderror the dubious pg_do_encoding_conversion() behavior when outside atransaction. Reintroduce the historic soft failure locally withinpgwin32_message_to_UTF16(). This fixes errors when writing messages inless-common encodings to the Windows event log or console. Back-patchto 9.4, where the aforementioned commit first appeared.Per bug #13427 from Dmitri Bourlatchkov.
1 parentb435f19 commit92516bf

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,8 @@ pgwin32_message_to_UTF16(const char *str, int len, int *utf16len)
10631063

10641064
/*
10651065
* Use MultiByteToWideChar directly if there is a corresponding codepage,
1066-
* or double conversion through UTF8 if not.
1066+
* or double conversion through UTF8 if not. Double conversion is needed,
1067+
* for example, in an ENCODING=LATIN8, LC_CTYPE=C database.
10671068
*/
10681069
if (codepage!=0)
10691070
{
@@ -1075,12 +1076,21 @@ pgwin32_message_to_UTF16(const char *str, int len, int *utf16len)
10751076
{
10761077
char*utf8;
10771078

1078-
utf8= (char*)pg_do_encoding_conversion((unsignedchar*)str,
1079-
len,
1080-
GetMessageEncoding(),
1081-
PG_UTF8);
1082-
if (utf8!=str)
1083-
len=strlen(utf8);
1079+
/*
1080+
* XXX pg_do_encoding_conversion() requires a transaction. In the
1081+
* absence of one, hope for the input to be valid UTF8.
1082+
*/
1083+
if (IsTransactionState())
1084+
{
1085+
utf8= (char*)pg_do_encoding_conversion((unsignedchar*)str,
1086+
len,
1087+
GetMessageEncoding(),
1088+
PG_UTF8);
1089+
if (utf8!=str)
1090+
len=strlen(utf8);
1091+
}
1092+
else
1093+
utf8= (char*)str;
10841094

10851095
utf16= (WCHAR*)palloc(sizeof(WCHAR)* (len+1));
10861096
dstlen=MultiByteToWideChar(CP_UTF8,0,utf8,len,utf16,len);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp