Re: Invalid SQL not rejected?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig James <cjames(at)emolecules(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Invalid SQL not rejected?
Date: 2013-04-12 00:44:43
Message-ID: 29413.1365727483@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Craig James <cjames(at)emolecules(dot)com> 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jeff Janes 2013-04-12 01:15:49 Re: [ADMIN] after 9.2.4 patch vacuumdb -avz not analyzing all tables
Previous Message Craig James 2013-04-12 00:17:29 Invalid SQL not rejected?