Permalink
Browse files

Do not use _partitionne trigger on mother table to populate partition…

….trigger table
  • Loading branch information...
1 parent 816ae09 commit 54540a5d33595ddd5851a2a011f6319bfdfad6f3 Sébastien Lardière committed Jul 4, 2012
Showing with 25 additions and 0 deletions.
  1. +1 −0 part_triggers.sql
  2. +24 −0 tests/parttesttable.sql
View
@@ -74,6 +74,7 @@ begin
where c.relkind='r'
and ( t.tgconstraint is null or t.tgconstraint = 0 )
and n.nspname = new.schemaname and c.relname = new.tablename
+ and t.tgname != '_partitionne'
loop
insert into partition.trigger values ( r_trigg.nspname, r_trigg.relname, r_trigg.tgname, r_trigg.triggerdef ) ;
View
@@ -1,3 +1,10 @@
+\c postgres
+drop database part;
+create database part;
+\c part
+
+\i partition.sql
+
begin ;
drop schema if exists test cascade ;
@@ -152,3 +159,20 @@ commit ;
\dt test.
select partition.drop() ;
+
+
+-- stupid test about _partitionne trigger. Never do that !
+begin;
+create temp table temptrg (like partition.trigger);
+insert into temptrg select * from partition.trigger ;
+delete from partition.trigger ;
+delete from partition.table ;
+insert into partition.table (schemaname, tablename, keycolumn, pattern, cleanable, retention_period) values
+ ('test','test1an','ev_date','Y','t','3 year'),
+ ('test','test1mois','ev_date','M','f', null),
+ ('test','test_mois','ev_date','M','t', '1 month'),
+ ('test','test1week','ev_date','W','t','3 weeks'),
+ ('test','test1jour','ev_date','D','t','2 month') ;
+insert into partition.trigger select * from temptrg ;
+select * from partition.trigger;
+commit;

0 comments on commit 54540a5

Please sign in to comment.