Search Postgresql Archives

Re: constraint checking on partitions

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

 



"Chris Spotts" <rfusca@xxxxxxxxx> writes:
> I mistyped, that should be 

> alter table D add constraint onlyjuly check (date1 >= '2009-07-01' and date1
> < '2009-08-01')
> Then this is also run
> alter table O add constraint notjuly check (NOT(date1 >= '2009-07-01' and
> date1 < '2009-08-01'))

> If I ran a select * from A where date1 >= '2009-07-02' and date1 <
> '2009-07-15' then I would think it wouldn't check O. 

Works for me ...

regression=# create table a (date1 date);
CREATE TABLE
regression=# create table july() inherits(a);
CREATE TABLE
regression=# create table other() inherits(a);
CREATE TABLE
regression=# alter table other add constraint notjuly check (NOT(date1 >= '2009-07-01' and date1 < '2009-08-01'));
ALTER TABLE
regression=# explain select * from a where date1 >= '2009-07-02' and date1 < '2009-07-15';
                                       QUERY PLAN                                       
----------------------------------------------------------------------------------------
 Result  (cost=0.00..92.00 rows=24 width=4)
   ->  Append  (cost=0.00..92.00 rows=24 width=4)
         ->  Seq Scan on a  (cost=0.00..46.00 rows=12 width=4)
               Filter: ((date1 >= '2009-07-02'::date) AND (date1 < '2009-07-15'::date))
         ->  Seq Scan on july a  (cost=0.00..46.00 rows=12 width=4)
               Filter: ((date1 >= '2009-07-02'::date) AND (date1 < '2009-07-15'::date))
(6 rows)

regression=# 

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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