Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 518276338AF for ; Sat, 6 Jun 2009 22:23:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 01798-06 for ; Sat, 6 Jun 2009 22:23:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from joeconway.com (wsip-72-214-29-243.sd.sd.cox.net [72.214.29.243]) by mail.postgresql.org (Postfix) with ESMTP id EBEAD633683 for ; Sat, 6 Jun 2009 22:23:15 -0300 (ADT) Received: from [192.168.4.40] (account jconway [192.168.4.40] verified) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 7905401; Sat, 06 Jun 2009 18:23:13 -0700 Message-ID: <4A2B1681.4050405@joeconway.com> Date: Sat, 06 Jun 2009 18:23:13 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20071019 Fedora/1.5.0.12-3.fc6 pango-text Thunderbird/1.5.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Tom Lane CC: "Hackers (PostgreSQL)" Subject: Re: [Fwd: Re: dblink patches for comment] References: <4A29E789.1050405@joeconway.com> <10658.1244304503@sss.pgh.pa.us> <4A2AAA80.9060905@joeconway.com> <12129.1244310667@sss.pgh.pa.us> In-Reply-To: <12129.1244310667@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------080904090304080704070209" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.168 tagged_above=0 required=5 tests=AWL=0.068, RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200906/541 X-Sequence-Number: 139596 This is a multi-part message in MIME format. --------------080904090304080704070209 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Tom Lane wrote: > But that reminds me, weren't you going to add something to force > libpq to set client_encoding to the database encoding? I think the attached is what you had in mind. But I don't know right off how to trigger the failure (and therefore how to test the solution). A naive test with two databases, one LATIN2, the other UTF8 does not produce the error with simple text literals. Any guidance on specific literals that would trigger the problem? Thanks, Joe --------------080904090304080704070209 Content-Type: text/x-patch; name="dblink.2009.06.06.01-encoding.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dblink.2009.06.06.01-encoding.diff" Index: dblink.c =================================================================== RCS file: /opt/src/cvs/pgsql/contrib/dblink/dblink.c,v retrieving revision 1.79 diff -c -r1.79 dblink.c *** dblink.c 6 Jun 2009 21:27:56 -0000 1.79 --- dblink.c 7 Jun 2009 01:14:44 -0000 *************** *** 48,53 **** --- 48,54 ---- #include "executor/spi.h" #include "foreign/foreign.h" #include "lib/stringinfo.h" + #include "mb/pg_wchar.h" #include "miscadmin.h" #include "nodes/execnodes.h" #include "nodes/nodes.h" *************** *** 185,190 **** --- 186,192 ---- errdetail("%s", msg))); \ } \ dblink_security_check(conn, rconn); \ + PQsetClientEncoding(conn, GetDatabaseEncodingName()); \ freeconn = true; \ } \ } while (0) *************** *** 263,268 **** --- 265,273 ---- /* check password actually used if not superuser */ dblink_security_check(conn, rconn); + /* attempt to set client encoding to match server encoding */ + PQsetClientEncoding(conn, GetDatabaseEncodingName()); + if (connname) { rconn->conn = conn; --------------080904090304080704070209--