test3.sql

text/plain

Filename: test3.sql
Type: text/plain
Part: 2
Message: Re: Partitioning option for COPY
set copy_partitioning_cache_size = 0;

drop table parent cascade;
drop table audit cascade;
drop function audit();

create table parent(i int);
create table c1 (check (i > 0 and i <= 1)) inherits (parent);
create table c2 (check (i > 1 and i <= 2)) inherits (parent);
create table c3 (check (i > 2 and i <= 3)) inherits (parent);

create table audit(i int);

create function audit() returns trigger as $$ begin insert into audit(i) values (new.i); return new; end; $$ language plpgsql;

create trigger parent_a after insert on parent for each row execute procedure audit();
-- the before trigger on the parent would get fired
-- create trigger parent_a2 before insert on parent for each row execute procedure audit();
create trigger c1_a before insert on c1 for each row execute procedure audit();
create trigger c1_a2 after insert on c1 for each row execute procedure audit();

copy parent from stdin with (partitioning);
1
2
3
\.

-- no rows
select * from audit;