From: | martin(dot)schaefer(at)cadcorp(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #8210: UTF8 column names corrupted by server |
Date: | 2013-06-05 06:54:29 |
Message-ID: | E1Uk7c5-0001IJ-KP@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 8210
Logged by: Martin Schaefer
Email address: martin(dot)schaefer(at)cadcorp(dot)com
PostgreSQL version: 9.2.1
Operating system: Windows 8
Description:
The following code:
const wchar_t *strName = L"id_äß";
wstring strCreate = wstring(L"create table test_umlaut(") + strName + L"
integer primary key)";
PGconn *pConn = PQsetdbLogin("", "", NULL, NULL, "dev503", "postgres",
"******");
if (!pConn) FAIL;
if (PQsetClientEncoding(pConn, "UTF-8")) FAIL;
PGresult *pResult = PQexec(pConn, "drop table test_umlaut");
if (pResult) PQclear(pResult);
pResult = PQexec(pConn, ToUtf8(strCreate.c_str()).c_str());
if (pResult) PQclear(pResult);
pResult = PQexec(pConn, "select * from test_umlaut");
if (!pResult) FAIL;
if (PQresultStatus(pResult)!=PGRES_TUPLES_OK) FAIL;
if (PQnfields(pResult)!=1) FAIL;
const char *fName = PQfname(pResult,0);
ShowW("Name: ", strName);
ShowA("in UTF8: ", ToUtf8(strName).c_str());
ShowA("from DB: ", fName);
ShowW("in UTF16: ", ToWide(fName).c_str());
PQclear(pResult);
PQreset(pConn);
(ShowA/W call OutputDebugStringA/W, and ToUtf8/ToWide use
WideCharToMultiByte/MultiByteToWideChar with CP_UTF8.)
generates this output:
Name: id_äß
in UTF8: id_äß
from DB: id_ã¤ãÿ
in UTF16: id_???
The back-end treats the name as if it were in ANSI encoding, not in UTF-8,
when it lower-cases the name. The resulting column name is corrupted.
I’m using PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-bit
The database uses:
ENCODING = 'UTF8'
LC_COLLATE = 'English_United Kingdom.1252'
LC_CTYPE = 'English_United Kingdom.1252'
From | Date | Subject | |
---|---|---|---|
Next Message | acizov | 2013-06-05 15:24:28 | BUG #8211: Syntax error when creating index on expression |
Previous Message | Amit Kapila | 2013-06-05 05:58:56 | Re: BUG #8198: ROW() literals not supported in an IN clause |