Hi !

I'm running pgadmin v. 1.12.2 on winxp and postgres "PostgreSQL 9.0.2,
compiled by Visual C++ build 1500, 32-bit".

When selecting a table in the tree-navigator to the left the table
definition and its triggers appears to the right.
However the trigger definition doesn't appear to be right ( a constraint
trigger appears as an ordinary trigger ).

To reproduce:

create the table and trigger below then refresh the table definition in
pgadmin and look at the trigger.
It is not shown as a constraint trigger !

create table tst (txn_id int primary key, amount numeric(15,2));

create or replace function def_constr_tst_chk_balance()
returns trigger as
$$
declare
    v_amount numeric(15,2);
begin
    if (tg_op='INSERT') then
        select sum(amount)
        into v_amount
        from tst;

        if (v_amount<>0) then
            raise exception 'error: sum does not balance';
        end if;
        return new;
    end if;
    raise exception 'only allowed to insert';
end;
$$
language plpgsql;

create constraint trigger tst_constraint
after insert or update or delete
on tst
deferrable initially deferred
for each row
execute procedure def_constr_tst_chk_balance();

-- should succeed on commit
begin transaction;
insert into tst values(1,100);
insert into tst values(2,-100);
commit transaction;

-- should fail on commit
begin transaction;
insert into tst values(3,100);
insert into tst values(4,-110);
commit transaction;


Best Regards
Dan S

Reply via email to