mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
Fixed 'Unknown error' when doing ORDER BY on reference table which
was used with NULL value on NOT NULL column. (Bug #479)
This commit is contained in:
parent
dcbcb78536
commit
730776c452
3 changed files with 40 additions and 1 deletions
|
@ -142,3 +142,7 @@ t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 where used
|
|||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 where used
|
||||
t2_id str
|
||||
112633 t2 112633
|
||||
112634 t2 112634
|
||||
t2_id str
|
||||
|
|
|
@ -247,3 +247,26 @@ EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and
|
|||
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
|
||||
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
#
|
||||
# Problem with lookup on NULL (Bug 479)
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (
|
||||
t1_id int(10) unsigned NOT NULL default '0',
|
||||
ref_id int(10) unsigned default NULL,
|
||||
PRIMARY KEY (t1_id)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO t1 VALUES (2401,14590),(2425,NULL);
|
||||
CREATE TABLE t2 (
|
||||
t2_id int(10) unsigned NOT NULL default '0',
|
||||
ref_id int(10) unsigned NOT NULL default '0',
|
||||
str varchar(20) default NULL,
|
||||
PRIMARY KEY (t2_id),
|
||||
KEY ref_id (ref_id)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO t2 VALUES (112633,14590,'t2 112633'),(112634,14590,'t2 112634'),(113166,14641,'t2 113166'),(113167,14641,'t2 113167'),(113168,14641,'t2 113168'),(113169,14641,'t2 113169'),(113170,14641,'t2 113170'),(113171,14641,'t2 113171'),(113172,14641,'t2 113172'),(113173,14641,'t2 113173'),(113174,14641,'t2 113174'),(113175,14641,'t2 113175'),(113436,14674,'t2 113436'),(113437,14674,'t2 113437'),(113486,14689,'t2 113486'),(113487,14689,'t2 113487'),(113488,14689,'t2 113488'),(113489,14689,'t2 113489'),(113504,14795,'t2 113504'),(115396,15024,'t2 115396'),(115397,15024,'t2 115397');
|
||||
SELECT t2_id, str FROM t1, t2 WHERE t1_id = 2401 AND t1.ref_id = t2.ref_id ORDER BY str, t2_id;
|
||||
# This one gave an error
|
||||
SELECT t2_id, str FROM t1, t2 WHERE t1_id = 2425 AND t1.ref_id = t2.ref_id ORDER BY str, t2_id;
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -5326,11 +5326,23 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
|
|||
can use.
|
||||
*/
|
||||
if (!(select->quick=get_ft_or_quick_select_for_ref(table, tab)))
|
||||
goto err;
|
||||
{
|
||||
if (current_thd->fatal_error)
|
||||
goto err; // End of memory
|
||||
/*
|
||||
Impossible range (for example lookup on NULL on not null field)
|
||||
Create empty result set
|
||||
*/
|
||||
if (!(table->record_pointers= my_malloc(1, MYF(MY_WME))))
|
||||
goto err;
|
||||
table->found_records= 0;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
table->found_records=filesort(&table,sortorder,length,
|
||||
select, 0L, select_limit, &examined_rows);
|
||||
end:
|
||||
delete select; // filesort did select
|
||||
tab->select=0;
|
||||
tab->select_cond=0;
|
||||
|
|
Loading…
Reference in a new issue