[pgsql-jp: 34751] Re: charのlength について

ISHIDA Akio iakio @ mono-space.net
2005年 1月 28日 (金) 16:35:06 JST


石田@苫小牧市です。

TANIDA Yutaka wrote:
> 谷田です。
> 
> On Fri, 28 Jan 2005 14:13:29 +0900
> ISHIDA Akio <iakio @ mono-space.net> wrote:
> 
> 
>># octet_lengthが14というのは何でだろう。
> 
> 
> 単に2*4(マルチバイトの文字数)+6では?

ああ、char(10)に4文字いれたから、後続のスペースが
6 個つくから +6 ということですか。

で、もう少し調べてみたのですが、
まだよく理解できないケースがありました。


ishida=# SELECT octet_length('あいうえ'::char(4));
 octet_length
--------------
            8   -- 4 * 2 = 8
(1 行)

ishida=# SELECT octet_length('あいうえ'::char(6));
 octet_length
--------------
           10   -- 4 * 2 + (6 - 4)
(1 行)

ishida=# SELECT octet_length('あいうえ'::char(8));
 octet_length
--------------
            8   -- ??
(1 行)

ishida=# SELECT octet_length('あい'::char(5));
 octet_length
--------------
            7   -- 2 * 2 + (5 - 2)
(1 行)

ishida=# SELECT octet_length('あい '::char(5));
 octet_length
--------------
            5    -- ??
(1 行)



-- 
ISHIDA Akio <iakio @ mono-space.net / ishida @ cycleof5th.com>



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