pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Hackers (PostgreSQL) <pgsql-hackers@postgresql.org>
Subject: Re: [Fwd: Re: dblink patches for comment]
Date: Sat, 06 Jun 2009 18:23:13 -0700
Message-ID: <4A2B1681.4050405@joeconway.com> (raw)
In-Reply-To: <12129.1244310667@sss.pgh.pa.us>
References: <4A29E789.1050405@joeconway.com>
	<10658.1244304503@sss.pgh.pa.us>
	<4A2AAA80.9060905@joeconway.com>
	<12129.1244310667@sss.pgh.pa.us>

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

Attachments:

  [text/x-patch] dblink.2009.06.06.01-encoding.diff (1.1K, ../4A2B1681.4050405@joeconway.com/2-dblink.2009.06.06.01-encoding.diff)
  download | inline 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;

view thread (12+ messages)  latest in thread

Message-ID: <4A2B1681.4050405@joeconway.com>
Permalink:  ../4A2B1681.4050405@joeconway.com/
Also on:    postgresql.org/message-id/4A2B1681.4050405@joeconway.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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: mail@joeconway.com, tgl@sss.pgh.pa.us
  Subject: Re: [Fwd: Re: dblink patches for comment]
  In-Reply-To: <4A2B1681.4050405@joeconway.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