Re: client encoding that psql command sets

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: Tsubasa Sakamoto *EXTERN* <sakamoto(dot)tsubasa(at)ryobi(dot)co(dot)jp>, 'Adrian Klaver' <adrian(dot)klaver(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client encoding that psql command sets
Date: 2014-02-07 09:12:10
Message-ID: A737B7A37273E048B164557ADEF4A58B17CA3DA7@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

[CC'ed -hackers]

Tsubasa Sakamoto wrote:
>> Not sure that it makes a difference but the docs say psql looks at
>> LC_CTYPE not LANG for Unix systems. You did not say what OS you are
>> working on though from the examples I am guessing some form of Unix.

> The LC_CTYPE environment variable was set up and re-verified.
> The result of psql command is following.
>
> [Result]
> % setenv LC_CTYPE ja_JP.eucJP
>
> % psql postgres -f test.txt -o result.txt EUC_JP
>
> % psql postgres -f test.txt > result.txt
> UTF8
>
> % psql postgres -o result.txt < test.txt
> UTF8
>
> % psql postgres < test.txt > result.txt
> UTF8
>
> Even when a LC_CTYPE environment variable was set up, the result did not change.
> What do you think?

I think that the documentation contradicts the code.

In bin/psql/settings.h:

typedef struct _psqlSettings
{
[...]
bool notty; /* stdin or stdout is not a tty (as determined
* on startup) */
[...]
} PsqlSettings;

extern PsqlSettings pset;

In bin/psql/command.c and bin/psql/startup.c:

keywords[6] = "client_encoding";
values[6] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto";

That matches your observations: client_encoding=auto is only
used if both stdin and stdout are attached to a tty.

I suggest the attached documentation fix.

Yours,
Laurenz Albe

Attachment Content-Type Size
psql-doc.patch application/octet-stream 852 bytes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Thomas 2014-02-07 15:00:38 Better Connection Statistics
Previous Message Albe Laurenz 2014-02-07 08:30:59 Re: WAL archive on slave

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2014-02-07 09:14:09 Re: Inconsistency between pg_stat_activity and log_duration
Previous Message Heikki Linnakangas 2014-02-07 08:26:21 Re: Typo in a comment?