Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uk7cS-0004eV-VY for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Jun 2013 06:54:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Uk7cS-0004NM-F7 for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Jun 2013 06:54:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uk7cR-0004NG-JX for pgsql-bugs@postgresql.org; Wed, 05 Jun 2013 06:54:51 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uk7cF-0003xZ-3c for pgsql-bugs@postgresql.org; Wed, 05 Jun 2013 06:54:51 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Uk7cB-0004iH-D2 for pgsql-bugs@postgresql.org; Wed, 05 Jun 2013 06:54:37 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1Uk7c5-0001IJ-KP for pgsql-bugs@postgresql.org; Wed, 05 Jun 2013 06:54:29 +0000 Date: Wed, 05 Jun 2013 06:54:29 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8210: UTF8 column names corrupted by server To: pgsql-bugs@postgresql.org From: martin.schaefer@cadcorp.com X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8210 Logged by: Martin Schaefer Email address: martin.schaefer@cadcorp.com PostgreSQL version: 9.2.1 Operating system: Windows 8 Description:=20=20=20=20=20=20=20=20 The following code: const wchar_t *strName =3D L"id_=C3=A4=C3=9F"; wstring strCreate =3D wstring(L"create table test_umlaut(") + strName += L" integer primary key)"; PGconn *pConn =3D PQsetdbLogin("", "", NULL, NULL, "dev503", "postgres", "******"); if (!pConn) FAIL; if (PQsetClientEncoding(pConn, "UTF-8")) FAIL; PGresult *pResult =3D PQexec(pConn, "drop table test_umlaut"); if (pResult) PQclear(pResult); pResult =3D PQexec(pConn, ToUtf8(strCreate.c_str()).c_str()); if (pResult) PQclear(pResult); pResult =3D PQexec(pConn, "select * from test_umlaut"); if (!pResult) FAIL; if (PQresultStatus(pResult)!=3DPGRES_TUPLES_OK) FAIL; if (PQnfields(pResult)!=3D1) FAIL; const char *fName =3D 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_=C3=A4=C3=9F in UTF8: id_=C3=83=C2=A4=C3=83=C5=B8 from DB: id_=C3=A3=C2=A4=C3=A3=C3=BF 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=E2=80=99m using PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-b= it The database uses: ENCODING =3D 'UTF8' LC_COLLATE =3D 'English_United Kingdom.1252' LC_CTYPE =3D 'English_United Kingdom.1252' --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs