Re: new field content lost

Lists: pgsql-hackers
From: Gaetano Mendola <mendola(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: new field content lost
Date: 2008-04-17 16:12:30
Message-ID: 480776EE.1060005@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,
since long time I have implemented a materialized view, today I had to add a
new field and I faced the following (I believe) bug.

The bug can be replicated on a 8.2.7

-- SETUP
create table test (a integer, b integer);
create table test_trigger (a integer);

CREATE OR REPLACE FUNCTION trigger_test()
RETURNS TRIGGER AS'
DECLARE

BEGIN
update test set b = b*10 where a = NEW.a;

RETURN NEW;
END;
' LANGUAGE 'plpgsql';

CREATE CONSTRAINT TRIGGER trigger_test
AFTER INSERT OR UPDATE ON test_trigger DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW EXECUTE PROCEDURE trigger_test();

insert into test values (1,1),(2,2),(3,3);
insert into test_trigger values (1),(2),(3);

-- FROM CONNECTION A
update test_trigger set a=1 where a=1;

-- FROM CONNECTION B
alter table test add column c integer;
update test set c = 15;
select * from test;

-- FROM CONNECTION A
update test_trigger set a=2 where a=2;

--FROM CONNECTION B
select * from test;

you can see that the value c=15 for a=2 has been nullified

Regards
Gaetano


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gaetano Mendola <mendola(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: new field content lost
Date: 2008-04-17 16:14:50
Message-ID: 21008.1208448890@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gaetano Mendola <mendola(at)gmail(dot)com> writes:
> since long time I have implemented a materialized view, today I had to add a
> new field and I faced the following (I believe) bug.
> The bug can be replicated on a 8.2.7

Cached plan for the function's UPDATE. Should work okay in 8.3 ...

regards, tom lane


From: Gaetano Mendola <mendola(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: new field content lost
Date: 2008-04-18 08:06:02
Message-ID: fu9kns$2roq$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Gaetano Mendola <mendola(at)gmail(dot)com> writes:
>> since long time I have implemented a materialized view, today I had to add a
>> new field and I faced the following (I believe) bug.
>> The bug can be replicated on a 8.2.7
>
> Cached plan for the function's UPDATE. Should work okay in 8.3 ...
>

It does.

Regards
Gaetano Mendola