Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubspm-0006KZ-PN for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2013 13:30:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ubspm-0004cB-8P for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2013 13:30:34 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubspl-0004c2-H6 for pgsql-bugs@postgresql.org; Mon, 13 May 2013 13:30:33 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubspi-0007sA-Hi for pgsql-bugs@postgresql.org; Mon, 13 May 2013 13:30:32 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubsph-0003IV-A1 for pgsql-bugs@postgresql.org; Mon, 13 May 2013 13:30:30 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1Ubspc-0005ly-3s for pgsql-bugs@postgresql.org; Mon, 13 May 2013 13:30:24 +0000 Date: Mon, 13 May 2013 13:30:24 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8153: check constraint results in a lot of casts To: pgsql-bugs@postgresql.org From: marc@intershop.de X-Pg-Spam-Score: -0.6 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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:=20=20=20=20=20=20=20=20 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] ));=20=20=20=20 (3) alter table test add constraint test_ck_3 check ( a =3D ANY (ARRAY['a'::text, 'b'] ));=20=20=20=20 \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 --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs