Bug #62526 MySQL failed to parse Subquery with wrong column name

Submitted: 24 Sep 2011 0:53 Modified: 24 Oct 2011 5:49
Reporter: kevin yan Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:5.1.49-1ubuntu8.1 (Ubuntu) OS:Any
Assigned to: CPU Architecture:Any
Tags: So critical bug

[24 Sep 2011 0:53] kevin yan
Description:
I have two tables:

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `disabled` int(11) NOT NULL DEFAULT '0',
  `fullname` varchar(47) NOT NULL,
  `location_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKF022FD4A25ED92E4` (`location_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1450 DEFAULT CHARSET=latin1;

CREATE TABLE `locations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `description` varchar(255) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `currency_id` bigint(20) NOT NULL,
  `finrole_id` int(11) DEFAULT NULL,
  `oarole_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK714F9FB5D8F56564` (`currency_id`),
  KEY `FK714F9FB52CCBA632` (`oarole_id`),
  KEY `FK714F9FB54EE365D9` (`finrole_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=latin1;

I can get results by run the following query:

select id from users where location_id in (select location_id from locations where oarole_id = 4);

but the correct query should be:

select id from users where location_id in (select id from locations where oarole_id = 4);

And I got differet results from both queries.

How to repeat:
create two tables and run queries.
[24 Sep 2011 5:49] Valeriy Kravchuk
Are you sure this is a bug? Subquery can reference columns of outer table. Read http://dev.mysql.com/doc/refman/5.1/en/correlated-subqueries.html
[24 Oct 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.