Re: Determining client_encoding from client locale

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Determining client_encoding from client locale
Date: 2010-02-24 16:07:02
Message-ID: 201002241607.o1OG72f23087@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Did this patch go anywhere? Is it a TODO?

---------------------------------------------------------------------------

Heikki Linnakangas wrote:
> Here's my first attempt at setting client_encoding automatically from
> locale.
>
> It adds a new conninfo parameter to libpq, "client_encoding". If set to
> "auto", libpq uses the encoding as returned by
> pg_get_encoding_from_locale(). Any other value is passed through to the
> server as is.
>
> psql is modified to set "client_encoding=auto", unless overridden by
> PGCLIENTENCODING.
>
>
> BTW, I had to modify psql to use PQconnectdb() instead of
> PQsetdblogin(), so that it can pass the extra parameter. I found it a
> bit laboursome to construct the conninfo string with proper escaping,
> just to have libpq parse and split it into components again. Could we
> have a version of PQconnectdb() with an API more suited for setting the
> params programmatically? The PQsetdbLogin() approach doesn't scale as
> parameters are added/removed in future versions, but we could have
> something like this:
>
> PGconn *PQconnectParams(const char **params)
>
> Where "params" is an array with an even number of parameters, forming
> key/value pairs. Usage example:
>
> char *connparams[] = {
> "dbname", "mydb",
> "user", username,
> NULL /* terminate with NULL */
> };
> conn = PQconnectParams(connparams);
>
> This is similar to what I did internally in psql in the attached patch.
>
> Another idea is to use an array of PQconninfoOption structs:
>
> PQconn *PQconnectParams(PQconninfoOption *params);
>
> This would be quite natural since that's the format returned by
> PQconnDefaults() and PQconninfoParse(), but a bit more cumbersome to use
> in applications that don't use those functions, as in the previous example.
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do
+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gokulakannan Somasundaram 2010-02-24 16:12:24 Re: A thought on Index Organized Tables
Previous Message Tom Lane 2010-02-24 16:06:03 Re: pgsql: Remove pre-7.4 documentaiton mentions, now that 8.0 is the oldest