Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W8shi-0006vU-Bt for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Jan 2014 14:34:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W8shh-0000Cq-QY for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Jan 2014 14:34:53 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W8SmZ-0004vB-HX for pgsql-bugs@postgresql.org; Wed, 29 Jan 2014 10:54:11 +0000 Received: from mail-ea0-x236.google.com ([2a00:1450:4013:c01::236]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W8SmT-0002PZ-Db for pgsql-bugs@postgresql.org; Wed, 29 Jan 2014 10:54:10 +0000 Received: by mail-ea0-f182.google.com with SMTP id r15so833403ead.27 for ; Wed, 29 Jan 2014 02:54:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:subject:references:content-type:from:date:message-id :in-reply-to:user-agent; bh=2HT6eQlCVnw7TF8RpAuFjLWuwqpA3sAqu7sM8bNah/Y=; b=cVpFomQVTSx11Sv4O2DqqLVsffX3urwbaMESAnOqRjIA5SBbyO2DUjVlPbaU5hnOj+ 62OKIAKCG1ZW6t+ELaxzvS79RLiOTMnu+PwPQsDCrlZqNz6h7phaZiH74xcujrW3Ttv3 1LmW8sppRE/VFWJfZOcTNBHje4VFboOc97Je+59sNHaUSgSvy/5uhhLi2fj6m+Dtrx1W Hy/UKmStWBptaaspuBYnA+lEJRKD1OJUoY4ouYclrJv5f+a1JMOd6QktQZloSZYe1iB8 xONO+zJyztB/zuZjP5dVC6batxccv8JQeofPJj9maUlkMwHv2LRrELeLtjZVwKPdTKiH VJDg== X-Received: by 10.14.209.129 with SMTP id s1mr8738711eeo.21.1390992844054; Wed, 29 Jan 2014 02:54:04 -0800 (PST) Received: from mamre ([212.49.88.99]) by mx.google.com with ESMTPSA id b41sm7019234eef.16.2014.01.29.02.54.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 29 Jan 2014 02:54:03 -0800 (PST) To: "Tom Lane" Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9006: Incorrect update when using where with non-existent column in subselect References: <20140128000840.26702.60938@wrigleys.postgresql.org> <420.1390875223@sss.pgh.pa.us> Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes From: "Martin Nzioki" Date: Wed, 29 Jan 2014 13:53:52 +0300 Message-ID: In-Reply-To: <420.1390875223@sss.pgh.pa.us> User-Agent: Opera Mail/12.16 (Win32) X-Pg-Spam-Score: -2.0 (--) 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 That is clear. Thanks. On Tue, 28 Jan 2014 05:13:43 +0300, Tom Lane wrote: > martin.nzioki@gmail.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs