pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
user names & non-ASCII
9+ messages / 5 participants
[nested] [flat]

* user names & non-ASCII
@ 2011-12-15 20:40  Holec, JPH Software <holec@jphsw.cz>
  0 siblings, 1 reply; 9+ messages in thread

From: Holec, JPH Software @ 2011-12-15 20:40 UTC (permalink / raw)
  To: pgsql-bugs

Hi All, please help.
 
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.
SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because connection fails.
 
Best regards,
 
Pavel Holec

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* user names & non-ASCII
@ 2011-12-15 22:02  Holec, JPH Software <holec@jphsw.cz>
  0 siblings, 0 replies; 9+ messages in thread

From: Holec, JPH Software @ 2011-12-15 22:02 UTC (permalink / raw)
  To: pgsql-bugs

Hi All, please help.
 
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.
SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because connection fails.
 
Best regards,
 
Pavel Holec

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* user names & non-ASCII
@ 2011-12-15 23:06  Pavel Holec <holec@email.cz>
  0 siblings, 1 reply; 9+ messages in thread

From: Pavel Holec @ 2011-12-15 23:06 UTC (permalink / raw)
  To: pgsql-bugs

Hi All, please help.
 
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.
SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because connection fails.
 
Best regards,
 
Pavel Holec

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2011-12-15 23:17  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Pavel Holec <holec@email.cz>
  0 siblings, 2 replies; 9+ messages in thread

From: Pavel Stehule @ 2011-12-15 23:17 UTC (permalink / raw)
  To: Pavel Holec <holec@email.cz>; +Cc: pgsql-bugs

Hello

this is not bug

you can try use a system variable PGCLIENTENCODING

bash-4.2$ PGCLIENTENCODING='latin2' psql postgres
psql (9.1.1)
Type "help" for help.

postgres=# show client_encoding ;
 client_encoding
-----------------
 LATIN2
(1 row)

other way is connect with "only ascii" user name, changing encoding
and changin current role

SET role TO specialcharsrole;

Regards

Pavel Stehule


2011/12/16 Pavel Holec <holec@email.cz>:
> Hi All, please help.
>
> 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.
> SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because
> connection fails.
>
> Best regards,
>
> Pavel Holec



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2011-12-16 13:21  Pavel Holec <holec@email.cz>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread

From: Pavel Holec @ 2011-12-16 13:21 UTC (permalink / raw)
  To: 'Pavel Stehule' <pavel.stehule@gmail.com>; +Cc: pgsql-bugs


PGCLIENTENCODING='latin2' - doesn't help (SetEnvironmentVariable)
SET CLIENT_ENCODING TO - doesn't help (too late)
connect with "only ascii" not possible (users are set)
SET role TO specialcharsrole? google doesn't know
On servers we have 8.4.7 not 9.1.1
In manual is PQconnectdb() with options="client_encoding =..." doesn't work

Pavel

-----Original Message-----
From: Pavel Stehule [mailto:pavel.stehule@gmail.com] 
Sent: Friday, December 16, 2011 12:18 AM
To: Pavel Holec
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] user names & non-ASCII

Hello

this is not bug

you can try use a system variable PGCLIENTENCODING

bash-4.2$ PGCLIENTENCODING='latin2' psql postgres psql (9.1.1) Type "help" for help.

postgres=# show client_encoding ;
 client_encoding
-----------------
 LATIN2
(1 row)

other way is connect with "only ascii" user name, changing encoding and changin current role

SET role TO specialcharsrole;

Regards

Pavel Stehule


2011/12/16 Pavel Holec <holec@email.cz>:
> Hi All, please help.
>
> 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.
> SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because 
> connection fails.
>
> Best regards,
>
> Pavel Holec




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2011-12-16 16:39  Pavel Holec <holec@email.cz>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread

From: Pavel Holec @ 2011-12-16 16:39 UTC (permalink / raw)
  To: 'Pavel Stehule' <pavel.stehule@gmail.com>; +Cc: pgsql-bugs

User name with PQescapeBytea also doesn't help. Pavel

-----Original Message-----
From: Pavel Stehule [mailto:pavel.stehule@gmail.com] 
Sent: Friday, December 16, 2011 12:18 AM
To: Pavel Holec
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] user names & non-ASCII

Hello

this is not bug

you can try use a system variable PGCLIENTENCODING

bash-4.2$ PGCLIENTENCODING='latin2' psql postgres psql (9.1.1) Type "help" for help.

postgres=# show client_encoding ;
 client_encoding
-----------------
 LATIN2
(1 row)

other way is connect with "only ascii" user name, changing encoding and changin current role

SET role TO specialcharsrole;

Regards

Pavel Stehule


2011/12/16 Pavel Holec <holec@email.cz>:
> Hi All, please help.
>
> 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.
> SET CLIENT_ENCODING TO 'WIN1250' after PQconnectdb is too late because 
> connection fails.
>
> Best regards,
>
> Pavel Holec




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2011-12-23 17:21  Robert Haas <robertmhaas@gmail.com>
  parent: Holec, JPH Software <holec@jphsw.cz>
  0 siblings, 1 reply; 9+ messages in thread

From: Robert Haas @ 2011-12-23 17:21 UTC (permalink / raw)
  To: Holec, JPH Software <holec@jphsw.cz>; +Cc: pgsql-bugs

On Thu, Dec 15, 2011 at 3:40 PM, Holec, JPH Software <holec@jphsw.cz> 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.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2011-12-23 18:58  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Heikki Linnakangas @ 2011-12-23 18:58 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Holec, JPH Software <holec@jphsw.cz>; pgsql-bugs

On 23.12.2011 19:21, Robert Haas wrote:
> On Thu, Dec 15, 2011 at 3:40 PM, Holec, JPH Software<holec@jphsw.cz>  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

Attachments:

let-client_encoding-be-manually-overrideable-in-psql-1.patch (text/x-diff, 1.7K) download 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;
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: user names & non-ASCII
@ 2012-01-09 17:34  Robert Haas <robertmhaas@gmail.com>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Robert Haas @ 2012-01-09 17:34 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: Holec, JPH Software <holec@jphsw.cz>; pgsql-bugs

On Fri, Dec 23, 2011 at 1:58 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> On 23.12.2011 19:21, Robert Haas wrote:
>>
>> On Thu, Dec 15, 2011 at 3:40 PM, Holec, JPH Software<holec@jphsw.cz>
>>  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.

That seems like a sensible approach, but this patch doesn't seem to
fix the problem for me.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2012-01-09 17:34 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15 20:40 user names & non-ASCII Holec, JPH Software <holec@jphsw.cz>
2011-12-23 17:21 ` Robert Haas <robertmhaas@gmail.com>
2011-12-23 18:58   ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2012-01-09 17:34     ` Robert Haas <robertmhaas@gmail.com>
2011-12-15 22:02 user names & non-ASCII Holec, JPH Software <holec@jphsw.cz>
2011-12-15 23:06 user names & non-ASCII Pavel Holec <holec@email.cz>
2011-12-15 23:17 ` Pavel Stehule <pavel.stehule@gmail.com>
2011-12-16 13:21   ` Pavel Holec <holec@email.cz>
2011-12-16 16:39   ` Pavel Holec <holec@email.cz>

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