Обсуждение: Re: [GENERAL] client encoding that psql command sets
[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
Вложения
On Fri, Feb 7, 2014 at 09:12:10AM +0000, Albe Laurenz wrote: > > 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. Patch applied and backpatched to 9.3. Thanks. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
Bruce Momjian wrote: >> I suggest the attached documentation fix. > > Patch applied and backpatched to 9.3. Thanks. What would PostgreSQL do without Bruce who undertakes the Herculean task of making sure that nothing gets forgotten and slips through the cracks? Thanks! Yours, Laurenz Albe
On Fri, Apr 18, 2014 at 07:42:06AM +0000, Albe Laurenz wrote: > Bruce Momjian wrote: > >> I suggest the attached documentation fix. > > > > Patch applied and backpatched to 9.3. Thanks. > > What would PostgreSQL do without Bruce who undertakes the > Herculean task of making sure that nothing gets forgotten > and slips through the cracks? Thanks. FYI, I finished going through all the unresolved email threads yesterday, so I have done as much as I can to prepare for beta. I will start the 9.4 major release notes now. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +