Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YYyZ3-0008GE-Ob for pgsql-odbc@arkaria.postgresql.org; Fri, 20 Mar 2015 15:10:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YYyZ3-0006bU-1u for pgsql-odbc@arkaria.postgresql.org; Fri, 20 Mar 2015 15:10:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YYyZ1-0006Yi-RW for pgsql-odbc@postgresql.org; Fri, 20 Mar 2015 15:10:20 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YYyYu-0000QN-BN for pgsql-odbc@postgresql.org; Fri, 20 Mar 2015 15:10:18 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id EAF1C20856 for ; Fri, 20 Mar 2015 11:10:08 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Fri, 20 Mar 2015 11:10:11 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=TvA8wDL8BNj7Un+6ryBqVq006ig=; b=icZ3aKQwZdn1wGZE3C rr1cXGaiJSo8TTkt73XorRGsOTn5TJeumjAUdN48TNbb4WBMIUXt4ifGjofqIbyg UIGTOqLsiWMm35gODDaW+fDk5QqWtijrCzqKmyIi8iUSmiUH9FCHGhFEphZz9G3F SyfNKoD476IKQT7k2A8PuGsYY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=TvA8wDL8BNj7Un+6ryBqVq 006ig=; b=CE8nZ4eO4Xge+hK8GYuuDUu3dWAXWobcl2jzMpIMJubLsrFydzWCPU HywfDhv5Z0zP9kJ/X2aK1rTWPwtwfHkN1Y4omNryp6t+mQuzSoMy8spX8m/RlGvv 8Ml+KZvT4kHJHZqd5uvQF53wTJgTQAKMbVmWf75pxoSQMAe87wCqk= X-Sasl-enc: 7KnkTu8RqnrKBDjnpdGq5d9Py15nkWsvMT7DBK56kID2 1426864210 Received: from [192.168.1.4] (unknown [174.21.191.40]) by mail.messagingengine.com (Postfix) with ESMTPA id B24246800F3; Fri, 20 Mar 2015 11:10:10 -0400 (EDT) Message-ID: <550C3851.1080808@aklaver.com> Date: Fri, 20 Mar 2015 08:10:09 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Kadri Raudsepp , pgsql-odbc@postgresql.org Subject: Re: Problem with client_encoding and PsqlODBC driver. References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org 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