Re: issues with dropped columns in plpgsql code again

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: issues with dropped columns in plpgsql code again
Date: 2013-05-07 19:23:04
Message-ID: CAFj8pRBChL-EQRjBO_PTD5u=ebkHC1HZ=A3j3DZKLy6J+qmwRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

sorry

my test

create table f1(a int, b int, c varchar, dropped_column numeric, d varchar);

create or replace function f1_trg()
returns trigger as $$
declare _f1_var f1;
begin raise notice 'run trigger';
_f1_var := new;
return _f1_var;
end;
$$ language plpgsql;

create trigger xx before insert on f1 for row execute procedure f1_trg();

insert into f1 values(1,1,'aaa',1.1,'aaa');
alter table f1 drop column dropped_column ;

insert into f1 values(1,1,'aaa','aaa');

2013/5/7 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>

> Hello
>
> One user reported a issues with triggers related to dropped columns.
>
> When I checked his code, I found a more possible problems.
>
> He use a trigger in form
>
> $$
> DECLARE somevar targettable;
> BEGIN
> somevar := NEW;
> // do some with somevar;
> RETURN somevar;
> END;
> $$
>
> When I dropped column (I dropped numeric column) I had to finish session,
> because I got a error in assign
>
> LOCATION: exec_stmt_raise, pl_exec.c:2985
> ERROR: 22P02: invalid input syntax for type numeric: "aaa"
> CONTEXT: PL/pgSQL function f1_trg() line 4 at assignment
> LOCATION: set_var_from_str, numeric.c:3253
>
> Regards
>
> Pavel
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2013-05-07 19:48:29 Re: XLogFlush invoked about twice as much after 9.2 group commit enhancement
Previous Message Pavel Stehule 2013-05-07 19:19:58 issues with dropped columns in plpgsql code again