BUG #8153: check constraint results in a lot of casts

Поиск
Список
Период
Сортировка
От marc@intershop.de
Тема BUG #8153: check constraint results in a lot of casts
Дата
Msg-id E1Ubspc-0005ly-3s@wrigleys.postgresql.org
обсуждение исходный текст
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8153
Logged by:          Marc Mamin
Email address:      marc@intershop.de
PostgreSQL version: 9.2.4
Operating system:   Linux & windows
Description:        =


hello,

This is not a functional bugs, but it appers (at least for me...) that
following constraint gets defined with some unecessary overweight:

create table test (a varchar);

(1) alter table test add constraint test_ck check ( a in ('a','b'));

I'd expect this to be resolved in CHECK (a =3D ANY (ARRAY['a'::character
varying, 'b'::character varying]) ).
I've tried further variantes. (3) looks better but there is always a cast on
the table side.

(2) alter table test add constraint test_ck_2 check ( a =3D ANY
(ARRAY['a'::character varying, 'b'::character varying] ));    =

(3) alter table test add constraint test_ck_3 check ( a =3D ANY
(ARRAY['a'::text, 'b'] ));    =



\d+ test
                              Table "public.test"
 Column |       Type        | Modifiers | Storage  | Stats target |
Description
--------+-------------------+-----------+----------+--------------+--------=
-----
 a      | character varying |           | extended |              |
Check constraints:
    "test_ck"   CHECK (a::text =3D ANY (ARRAY['a'::character varying,
'b'::character varying]::text[]))
    "test_ck_2" CHECK (a::text =3D ANY (ARRAY['a'::character varying,
'b'::character varying]::text[]))
    "test_ck_3" CHECK (a::text =3D ANY (ARRAY['a'::text, 'b'::text]))

best regards,

Marc Mamin

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Inconsistency between TO_CHAR() and TO_NUMBER()
Следующее
От: willybas@gmail.com
Дата:
Сообщение: BUG #8154: pg_dump throws error beacause of field called "new".