Re: MAX関数に関する報告
От | ITAGAKI Takahiro |
---|---|
Тема | Re: MAX関数に関する報告 |
Дата | |
Msg-id | 20080717184959.7A3C.52131E4D@oss.ntt.co.jp обсуждение исходный текст |
Ответ на | MAX関数に関する報告 ("y_takesue" <ytakesue05@hotmail.com>) |
Список | pgsql-bugs |
"y_takesue" <ytakesue05@hotmail.com> wrote: > PostgreSQL7.4 および PostgreSQL8.1 の間でMAX関数による出力結果の違いがありましたので報告いたします。 > item1がchar型のとき、パディングされている後方スペースがPostgreSQL8.1では取り除かれていませんでした。 リリースノートを見ても、どこで変更されたか特定できませんでしたが、 max() が text 型のみだけではなく、char 型のサポートが追加されたことが 影響しているようです。max() 後の値を必要な型に明示的にキャストするのが 安全だと思われます。 ---- BTW, max() returns bpchar type for char(10) and text for varchar(10) in HEAD. The type modifiers are lost. Is it a limitation? postgres=# \d b Table "public.b" Column | Type | Modifiers --------+-----------------------+----------- item1 | character(10) | item2 | character varying(10) | postgres=# select max(item1) as item1 , max(item2) as item2 into result from b; [in 7.4] postgres=# \d result Table "public.result" Column | Type | Modifiers --------+------+----------- item1 | text | <- not a char(10) item2 | text | <- not a varchar(10) [in HEAD] postgres=# \d result Table "public.result" Column | Type | Modifiers --------+--------+----------- item1 | bpchar | <- type modifier 10 is lost item2 | text | <- type modifier 10 is lost postgres=# EXPLAIN VERBOSE select max(item1) as item1 , max(item2) as item2 into result from b; QUERY PLAN ----------------------------------------------------------- Aggregate (cost=20.81..20.81 rows=1 width=82) Output: max(item1), max((item2)::text) -> Seq Scan on b (cost=0.00..17.20 rows=720 width=82) Output: item1, item2 (4 rows) Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
В списке pgsql-bugs по дате отправления: