Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7y5c-0007cu-Mt for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jan 2014 02:07:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7y5a-0007xy-V7 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jan 2014 02:07:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7wEj-00049X-47 for pgsql-bugs@postgresql.org; Tue, 28 Jan 2014 00:09:05 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7wEg-00070B-MM for pgsql-bugs@postgresql.org; Tue, 28 Jan 2014 00:09:04 +0000 MIME-Version: 1.0 Subject: BUG #9006: Incorrect update when using where with non-existent column in subselect To: pgsql-bugs@postgresql.org From: martin.nzioki@gmail.com Date: Tue, 28 Jan 2014 00:08:40 +0000 Message-ID: <20140128000840.26702.60938@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 9006 Logged by: Martin Nzioki Email address: martin.nzioki@gmail.com PostgreSQL version: 9.3.2 Operating system: Windows 7 64-bit Professional SP1 Description: drop table if exists _test1; drop table if exists _tmp_test2; 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); select * from _test1 order by id; Expected results: id,c2 --,-- 1,7 2,7 3, 4, 5, Actual results: id,c2 --,-- 1,7 2,7 3,7 4,7 5,7 Changing the update to update _test1 set c2 = 7 where id in (select id_fk from _tmp_test2); returns the expected results. Expectation is that the non-existent id_fk would have been caught during parsing. This still happens even when each statement is executed in its own transaction. Using pgScript on pgAdmin: [QUERY ] drop table if exists _test1 NOTICE: table "_test1" does not exist, skipping [QUERY ] drop table if exists _tmp_test2 NOTICE: table "_tmp_test2" does not exist, skipping [QUERY ] create table _test1 (id int not null primary key, c2 int) [QUERY ] insert into _test1 (id) select * from generate_series(1, 5) [QUERY ] create table _tmp_test2 (id_fk int not null) [QUERY ] insert into _tmp_test2 (id_fk) select id from _test1 limit 2 [QUERY ] update _test1 set c2 = 7 where id in (select id from _tmp_test2) [QUERY ] select * from _test1 order by id -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs