calc_part integer;
begin
if (TG_OP = ''INSERT'') then
- raise notice ''trigger: % backup_id %'', TG_OP, new.backup_id;
+ -- raise notice ''trigger: % backup_id %'', TG_OP, new.backup_id;
b_id = new.backup_id;
my_part_nr = new.part_nr;
execute ''update backups set parts = parts + 1 where id = '' || b_id;
elsif (TG_OP = ''DELETE'') then
- raise notice ''trigger: % backup_id %, old.part_nr %'', TG_OP, old.backup_id, old.part_nr;
+ -- raise notice ''trigger: % backup_id %, old.part_nr %'', TG_OP, old.backup_id, old.part_nr;
b_id = old.backup_id;
my_part_nr = old.part_nr - 1;
execute ''update backups set parts = parts - 1 where id = '' || b_id;
end if;
calc_part := (select count(part_nr) from backup_parts where backup_id = b_id);
if ( my_part_nr != calc_part ) then
- raise exception ''Update of backup_parts with backup_id % aborted, requested part_nr is % and calulated next is %'', b_id, my_part_nr, calc_part;
-
+ raise exception ''Update of backup_parts with backup_id % aborted, requested part_nr is % and calulated next is %'', b_id, my_part_nr, calc_part;
end if;
return null;
end;