Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5E90D16108B6 for ; Fri, 23 Dec 2011 14:59:08 -0400 (AST) Received: from exprod7og126.obsmtp.com ([64.18.2.206]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ReAKe-00030K-3Y for pgsql-bugs@postgresql.org; Fri, 23 Dec 2011 18:59:07 +0000 Received: from mail-ee0-f47.google.com ([74.125.83.47]) (using TLSv1) by exprod7ob126.postini.com ([64.18.6.12]) with SMTP ID DSNKTvTPaQKwdEhLxV4OIJrMfFkbaRcgJVyX@postini.com; Fri, 23 Dec 2011 10:59:03 PST Received: by eeit10 with SMTP id t10so6497538eei.34 for ; Fri, 23 Dec 2011 10:58:48 -0800 (PST) Received: by 10.213.2.146 with SMTP id 18mr5506378ebj.105.1324666727324; Fri, 23 Dec 2011 10:58:47 -0800 (PST) Received: from [10.0.0.34] (dsl-prvbrasgw1-fe14dc00-239.dhcp.inet.fi. [80.220.20.239]) by mx.google.com with ESMTPS id a60sm51877609eeb.4.2011.12.23.10.58.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Dec 2011 10:58:46 -0800 (PST) Message-ID: <4EF4CF61.2070209@enterprisedb.com> Date: Fri, 23 Dec 2011 20:58:41 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: Robert Haas CC: "Holec, JPH Software" , pgsql-bugs@postgresql.org Subject: Re: user names & non-ASCII References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------080609040901040105050704" X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201112/215 X-Sequence-Number: 32026 This is a multi-part message in MIME format. --------------080609040901040105050704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 23.12.2011 19:21, Robert Haas wrote: > On Thu, Dec 15, 2011 at 3:40 PM, Holec, JPH Software wrote: >> I Have PostgreSQL server 8.4.9 on Linux, database utf-8 and Client app on >> Windows (VC++ and libpq.dll). >> I need to use user account with non-ASCII and PQconnectdb() with >> options="client_encoding=WIN1250" doesn't work. > > I think you need a "-c" in there somewhere, maybe something like this: > > options='-cclient_encoding=WIN1250' > > ...although, for some reason, I can't get that to work from psql, even > though I can set other parameters using that syntax. That's because of the changes in 9.1 to determine client_encoding automatically from the system locale (commit 02e14562). Unless PGCLIENTENCODING environment variable is set, psql adds client_encoding='auto' to the params it passes to PQconnectdbParams. That overrides any setting you manually pass in the backend command-line options. That doesn't seem desirable, actually. That could be changed easily, by passing the client_encoding='auto' setting *before* dbname in the PQconnectdbParams call. The options given by the user are parsed from dbname setting, so if we passed them in different order, the manually given options would override the client_encoding='auto' setting, not the other way round. That seems like better behavior. Patch attached. It might be better to not backpatch this, though, to avoid surprising and subtle changes in behavior in application. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------080609040901040105050704 Content-Type: text/x-diff; name="let-client_encoding-be-manually-overrideable-in-psql-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="let-client_encoding-be-manually-overrideable-in-psql-1.patch" diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index e5cf5ff..1e6e207 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1561,12 +1561,12 @@ do_connect(char *dbname, char *user, char *host, char *port) values[2] = user; keywords[3] = "password"; values[3] = password; - keywords[4] = "dbname"; - values[4] = dbname; - keywords[5] = "fallback_application_name"; - values[5] = pset.progname; - keywords[6] = "client_encoding"; - values[6] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto"; + keywords[4] = "client_encoding"; + values[4] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto"; + keywords[5] = "dbname"; + values[5] = dbname; + keywords[6] = "fallback_application_name"; + values[6] = pset.progname; keywords[7] = NULL; values[7] = NULL; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 71829eb..b142080 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -183,14 +183,14 @@ main(int argc, char *argv[]) values[2] = options.username; keywords[3] = "password"; values[3] = password; - keywords[4] = "dbname"; - values[4] = (options.action == ACT_LIST_DB && + keywords[4] = "client_encoding"; + values[4] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto"; + keywords[5] = "dbname"; + values[5] = (options.action == ACT_LIST_DB && options.dbname == NULL) ? "postgres" : options.dbname; - keywords[5] = "fallback_application_name"; - values[5] = pset.progname; - keywords[6] = "client_encoding"; - values[6] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto"; + keywords[6] = "fallback_application_name"; + values[6] = pset.progname; keywords[7] = NULL; values[7] = NULL; --------------080609040901040105050704--