Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YvwxC-0005h9-HH for pgsql-bugs@arkaria.postgresql.org; Sat, 23 May 2015 00:06:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YvwxB-0005Zv-0l for pgsql-bugs@arkaria.postgresql.org; Sat, 23 May 2015 00:06:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YvwxA-0005Zi-1v for pgsql-bugs@postgresql.org; Sat, 23 May 2015 00:06:12 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Yvwx1-0003J0-HC for pgsql-bugs@postgresql.org; Sat, 23 May 2015 00:06:11 +0000 MIME-Version: 1.0 Subject: BUG #13336: Unexpected result from invalid query To: pgsql-bugs@postgresql.org From: chris@chrullrich.net Date: Sat, 23 May 2015 00:05:27 +0000 Message-ID: <20150523000527.17709.45231@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) 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: 13336 Logged by: Christian Ullrich Email address: chris@chrullrich.net PostgreSQL version: 9.4.2 Operating system: Windows 8.1 Description: An invalid column name in a subquery will be silently resolved against the main query's table: postgres=# create table test_table (foo varchar(10), bar integer); CREATE TABLE postgres=# insert into test_table values ('one', 1); INSERT 0 1 postgres=# insert into test_table values ('two', 2); INSERT 0 1 postgres=# create table test_table2 (baz varchar(10)); CREATE TABLE postgres=# insert into test_table2 values ('gromp'); INSERT 0 1 -- Note: No column "foo" in test_table2 postgres=# select * from test_table where foo in (select foo from test_table2); foo | bar -----+----- one | 1 two | 2 I actually noticed this when querying "select * from pg_available_extension_versions where name in (select name from pg_extension)", which returns the whole contents of the pg_available_extension_versions view although I got the column name in pg_extension wrong. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs