Bug #723 Unknown error returned instead of the empty set
Submitted: 25 Jun 2003 12:04 Modified: 3 Jul 2003 7:45
Reporter: SINISA MILIVOJEVIC Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0 OS:Any (All)
Assigned to: MySQL Verification Team CPU Architecture:Any

[25 Jun 2003 12:04] SINISA MILIVOJEVIC
Description:
Unknown error is issued instead of empty set.

This is caused by a fact that a self join is done which resolve to no rows.

But  in the process, first filtering on constants is performed and when JT_REF is to be optimised (for filesort), reference to a NULL is made for a NOT NULL column.

This is because this is how join was devised.

How to repeat:
drop table if exists t1;
create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
insert into t1 values (0,1,NULL,"aaa");
insert into t1 values (1,1,NULL,"aaa");
insert into t1 values (2,1,NULL,"aaa");
insert into t1 values (3,1,NULL,"aaa");
insert into t1 values (4,1,NULL,"aaa");
insert into t1 values (5,1,NULL,"aaa");
insert into t1 values (6,1,NULL,"aaa");
insert into t1 values (7,1,NULL,"aaa");
insert into t1 values (8,1,NULL,"aaa");
insert into t1 values (9,1,NULL,"aaa");
insert into t1 values (10,1,NULL,"aaa");
insert into t1 values (11,1,NULL,"aaa");
insert into t1 values (12,1,NULL,"aaa");
insert into t1 values (13,1,NULL,"aaa");
insert into t1 values (14,1,NULL,"aaa");
insert into t1 values (15,1,NULL,"aaa");
insert into t1 values (16,1,NULL,"aaa");
insert into t1 values (17,1,NULL,"aaa");
insert into t1 values (18,1,NULL,"aaa");
insert into t1 values (19,1,NULL,"aaa");
insert into t1 values (20,1,NULL,"aaa");
select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
drop table  if exists t1;
[3 Jul 2003 7:45] Michael Widenius
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

Will be fixed in 4.0.14