[pgsql-jp: 32900] Re: フロントエンコーディング

ISHIDA Akio iakio @ pjam.jpweb.net
2004年 5月 6日 (木) 10:15:47 JST


こんにちは。石田@苫小牧市です。

SAISHO Kazuhiro wrote:
> さて、早速質問させて戴きたいと思いますが、
> psql の \encoding と client_encoding の関係がわかりません。
> FreeBSD 4.9-STABLE + PostgreSQL 7.3.1 の環境で次のようになります。
> どうして結果が一致しないのかご教授戴けましたら幸いです。
(中略)
> dbname=> \encoding UTF-8                        ──┐
> dbname=> \encoding                                  │
> UNICODE                                         ←─┤UNICODE
> dbname=> show client_encoding;                      │
>  client_encoding                                    │
> -----------------                                   │
>  UTF-8                                          ←─┤UTF-8
> (1 row)                                             │
>> dbname=> select pg_client_encoding();               │
>  pg_client_encoding                                 │
> --------------------                                │
>  UNICODE                                        ←─┘UNICODE
> (1 row)

ちょっとへんな気もしますが、ここでの "unicode" は "utf-8" の
別名です。

> dbname=> set client_encoding to 'Shift_JIS';    ──┐
> SET                                                 │
> dbname=> \encoding                                  │
> UNICODE                                         ←─┤UNICODE
> dbname=> show client_encoding;                      │
>  client_encoding                                    │
> -----------------                                   │
>  Shift_JIS                                      ←─┤Shift_JIS
> (1 row)                                             │
>> dbname=> select pg_client_encoding();               │
>  pg_client_encoding                                 │
> --------------------                                │
>  SJIS                                           ←─┘SJIS
> (1 row)

以降に関しては、"\encoding" 以外の方法で client_encoding
を変更すると、psql 内部の "\encoding" の値とlibpq
の client_encoding が一致しないバグ?のようです。7.4 以降
では直っています。

Welcome to psql 7.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

ishida=> \encoding UTF-8
ishida=> \encoding
UNICODE
ishida=> set client_encoding to 'Shift_JIS';
SET
ishida=> \encoding
SJIS


http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/bin/psql/common.c
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/bin/psql/common.c.diff?r1=1.73&r2=1.74
-- 
ISHIDA Akio <iakio @ pjam.jpweb.net/iakio @ mono-space.net>



pgsql-jp メーリングリストの案内