failing_test_2.sql

application/sql

Filename: failing_test_2.sql
Type: application/sql
Part: 1
Message: Re: Declarative partitioning - another take
drop table if exists prueba cascade;
create table prueba (i int, d date); 
create table prueba_inh1(check (d between '2015-01-01' and '2015-12-31')) inherits (prueba);
create table prueba_inh2(check (d between '2016-01-01' and '2016-12-31')) inherits (prueba);

insert into prueba_inh1 select foo, '2015-12-31'::date - ((random() * 360)::integer  || ' days')::interval from generate_series(1, 10) foo;
insert into prueba_inh2 select foo, now() - ((random() * 300)::integer  || ' days')::interval from generate_series(11, 20) foo;

alter table prueba rename to prueba_old;
create table prueba (i int, d date) partition by range (extract(year from d), extract(month from d));
alter table prueba attach partition prueba_old for values start (unbounded, unbounded) end (2008,1) no validate;

select * from prueba;