pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Kadri Raudsepp <raudsepp.kadri@gmail.com>
To: pgsql-odbc@postgresql.org
Subject: Re: Problem with client_encoding and PsqlODBC driver.
Date: Fri, 20 Mar 2015 08:10:09 -0700
Message-ID: <550C3851.1080808@aklaver.com> (raw)
In-Reply-To: <CA+qYNGODy66NzmNaw7pp7Gpz+Ta1DCTeFt_wbZJViDLdC6UqMg@mail.gmail.com>
References: <CA+qYNGODy66NzmNaw7pp7Gpz+Ta1DCTeFt_wbZJViDLdC6UqMg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

On 03/20/2015 04:38 AM, Kadri Raudsepp wrote:
> Hello,
>
> I have some trouble with client_encoding using psqlodbc driver and -
> being unable to solve it - was hoping you would be able to help me.
>
> I need to import large amount of data to SQL Server from postgres
> database. I'm using psqlodbc driver version 9.03.04.00, Microsoft SQL
> Server 2012 and postgres version 9.2. My postgres cluster has the
> encoding SQL_ASCII and database encoding is LATIN1.
>
> I tried both Unicode(x64) and ANSI(x64) drivers, writing "SET
> CLIENT_ENCODING TO 'LATIN1'" to Connect Settings textbox. For both
> drivers, connection is successful and I use openquery to read the data,
> but my text data is all garbled.

So what is the encoding set for in openquery?

>
> Looking into the driver log I can see that the client_encoding is indeed
> set to LATIN1 as expected, but after that cc_lookup_characterset is
> called and with that the encoding is changed to UTF8 with Unicode driver
> and - I'm not sure what happens with ANSI driver, but the result does
> not look like desired. I have attached a log file that contains the logs
> for both driver's connection test.
>
> Is there a setting I've overlooked or an action I could take to have the
> driver not to override my desired client_encoding? Am I doing something
> wrong altogether? Or is there maybe an older version of the driver that
> doesn't behave this way?

I would not supply the "SET CLIENT_ENCODING TO 'LATIN1'" settings. I 
would use the ANSI driver because:

1) From the logs:

Right at the beginning it does:
-----ANSI-----

[6088-0.000]CC_connect: entering...
[6088-0.000]sslmode=require
[6088-0.000]LIBPQ_CC_connect: entering...
[6088-0.000]Driver Version='09.03.0400,Oct 26 2014' linking 1600 dynamic 
Multithread library
[6088-0.000]extracted a client_encoding 'LATIN1' from conn_settings

and at the end:
[6088-0.156]CC_lookup_characterset: entering...
[6088-0.156]conn->unicode=0

whereas the Unicode driver does:

6088-63527.931]conn->unicode=1

2) https://odbc.postgresql.org/faq.html#4.1

>
> Thank you in advance and all the best,
> Katie
>
>
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (9+ messages)  latest in thread

Message-ID: <550C3851.1080808@aklaver.com>
Permalink:  ../550C3851.1080808@aklaver.com/
Also on:    postgresql.org/message-id/550C3851.1080808@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: adrian.klaver@aklaver.com, raudsepp.kadri@gmail.com
  Subject: Re: Problem with client_encoding and PsqlODBC driver.
  In-Reply-To: <550C3851.1080808@aklaver.com>
  References: <CA+qYNGODy66NzmNaw7pp7Gpz+Ta1DCTeFt_wbZJViDLdC6UqMg@mail.gmail.com> <550C3851.1080808@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox