Re: BUG #9006: Incorrect update when using where with non-existent column in subselect

From: "Martin Nzioki" <martin(dot)nzioki(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #9006: Incorrect update when using where with non-existent column in subselect
Date: 2014-01-29 10:53:52
Message-ID: op.xaf272a9oyrabm@mamre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

That is clear. Thanks.

On Tue, 28 Jan 2014 05:13:43 +0300, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> martin(dot)nzioki(at)gmail(dot)com writes:
>> create table _test1 (id int not null primary key, c2 int);
>> insert into _test1 (id) select * from generate_series(1, 5);
>
>> create table _tmp_test2 (id_fk int not null);
>> insert into _tmp_test2 (id_fk) select id from _test1 limit 2;
>
>> update _test1 set c2 = 7 where id in (select id from _tmp_test2);
>
> This is a FAQ ... that statement is perfectly valid per SQL standard,
> it just doesn't do what you expect, because the sub-select's "id" is
> taken as an outer reference to _test1's id column.
>
> regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Tiikkaja 2014-01-29 11:25:27 Re: BUG #8984: ERROR: t_xmin is uncommitted in tuple to be updated
Previous Message cezary.dowhan 2014-01-29 10:21:39 BUG #9026: National characters in the user profile name