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@momjian.us> http://momjian.us EnterpriseDB
http://enterprisedb.comPG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do + If your life is a hard
drive,Christ can be your backup. +