Skip site navigation (1) Skip section navigation (2)

Re: BUG #4742: wrong resultset instead of syntax error

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Slava Moudry <smoudry(at)4info(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4742: wrong resultset instead of syntax error
Date: 2009-03-31 08:37:58
Message-ID: 49D1D666.7060600@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Slava Moudry wrote:
> I believe this is a parser error, it should fail rather than return all rows
> from keyword since there is no keyword_id in carrier table. The same can be
> illustrated with any other tables:
> 
> smslocate_edw=# select count(*) from keyword where keyword_id in (select
> keyword_id from carrier)   

It's not a bug, although I admit I've done the same mistake myself many 
times. keyword_id refers to keyword.keyword_id from the outer query in 
this case. It makes sense if you think of a more complex query like:

select count(*) from keyword where keyword_ratio > (select keyword_id / 
carrier_id from carrier)

If keyword_id wasn't allowed in the subquery, it would be impossible to 
write more complex queries like that.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2009-03-31 14:01:22
Subject: Re: BUG #4743: potential bug between int and uint
Previous:From: MATSUDA, DaikiDate: 2009-03-31 05:57:28
Subject: BUG #4743: potential bug between int and uint

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group