Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQS6p-0005Nl-8o for pgsql-admin@arkaria.postgresql.org; Fri, 12 Apr 2013 00:44:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQS6o-0002od-Jy for pgsql-admin@arkaria.postgresql.org; Fri, 12 Apr 2013 00:44:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQS6m-0002oV-Md for pgsql-admin@postgresql.org; Fri, 12 Apr 2013 00:44:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQS6f-00076H-65 for pgsql-admin@postgresql.org; Fri, 12 Apr 2013 00:44:52 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r3C0iha6029414; Thu, 11 Apr 2013 20:44:43 -0400 (EDT) From: Tom Lane To: Craig James cc: pgsql-admin@postgresql.org Subject: Re: Invalid SQL not rejected? In-reply-to: References: Comments: In-reply-to Craig James message dated "Thu, 11 Apr 2013 17:17:29 -0700" Date: Thu, 11 Apr 2013 20:44:43 -0400 Message-ID: <29413.1365727483@sss.pgh.pa.us> X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Craig James writes: > Hmmm.... the subselect is invalid, but not rejected. The outer select > returns every row in the customer_order_matches table. This seems pretty > wrong. This is PG 9.2.1 running on Ubuntu. > db=> select count(1) from customer_order_matches where > customer_order_item_id in (select customer_order_item_id from > customer_order where customer_order_id = 105862140); > count > ------- > 36180 > (1 row) Unfortunately, if customer_order_item_id doesn't exist in customer_order, that's still a perfectly valid outer reference to customer_order_matches.customer_order_item_id. People get confused by that kind of thing regularly, but it's required by spec to work like this. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin