Search Postgresql Archives

Expression of check constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

 

if I add the following check constraint to a table:

 

ALTER TABLE public.times_places

   ADD CONSTRAINT ck_tp_ratified CHECK

          (ratified IS NULL OR (ratified IN ('Y', 'N')));

 

It becomes the following when describing the table in psql:

 

Check constraints:

    "ck_tp_ratified" CHECK (ratified IS NULL OR (ratified::text = ANY (ARRAY['Y'::character varying, 'N'::character varying]::text[])))

 

The behavior of the check constraint is logically identical and this seems plausible to me, but I still wonder why:

1.    does the _expression_ x in (a, b) become the _expression_ x = any(array(a, b)?

2.    why is the array _expression_ casted so wildly? First to character varying and then to text[]?

3.    The column ratified is of type character varying(1).  Why is it casted to text?

 

Dirk

--
Dirk Mika
Software Developer



mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany

fon +49 2202 2401-1197
dirk.mika@xxxxxxxxxxxxx
www.mikatiming.de

AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika


 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux