Commit e233dc2b authored by Ramil Kalimullin's avatar Ramil Kalimullin

Fix for bug #54459: Assertion failed: param.sort_length,

file .\filesort.cc, line 149 (part II)

Problem: the server didn't disregard sort order 
for some zero length tuples.

Fix: skip sort order in such a case 
(zero length NOT NULL string functions).
parent f4830634
...@@ -4782,4 +4782,19 @@ a b c ...@@ -4782,4 +4782,19 @@ a b c
SELECT * FROM t1 WHERE 102 < c; SELECT * FROM t1 WHERE 102 < c;
a b c a b c
DROP TABLE t1; DROP TABLE t1;
#
# Bug #54459: Assertion failed: param.sort_length,
# file .\filesort.cc, line 149 (part II)
#
CREATE TABLE t1(a ENUM('') NOT NULL);
INSERT INTO t1 VALUES (), (), ();
EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
1
1
1
1
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
...@@ -4077,4 +4077,19 @@ SELECT * FROM t1 WHERE 102 < c; ...@@ -4077,4 +4077,19 @@ SELECT * FROM t1 WHERE 102 < c;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #54459: Assertion failed: param.sort_length,
--echo # file .\filesort.cc, line 149 (part II)
--echo #
CREATE TABLE t1(a ENUM('') NOT NULL);
INSERT INTO t1 VALUES (), (), ();
EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
DROP TABLE t1;
create table t1(a enum('a'))engine=myisam charset=latin1;
insert into t1 values (''),(''),(''),(NULL);
select a, substr(a, 0, 0) from t1 order by substr(a, 0, 0);
select a, a collate latin1_german2_ci from t1 order by a collate latin1_german2_ci;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -564,13 +564,21 @@ JOIN::prepare(Item ***rref_pointer_array, ...@@ -564,13 +564,21 @@ JOIN::prepare(Item ***rref_pointer_array,
{ {
Item *item= *ord->item; Item *item= *ord->item;
/* /*
Disregard sort order if there's only "{VAR}CHAR(0) NOT NULL" fields Disregard sort order if there's only
there. Such fields don't contain any data to sort. zero length NOT NULL fields (e.g. {VAR}CHAR(0) NOT NULL") or
zero length NOT NULL string functions there.
Such tuples don't contain any data to sort.
*/ */
if (!real_order && if (!real_order &&
(item->type() != Item::FIELD_ITEM || /* Not a zero length NOT NULL field */
((item->type() != Item::FIELD_ITEM ||
((Item_field *) item)->field->maybe_null() || ((Item_field *) item)->field->maybe_null() ||
((Item_field *) item)->field->sort_length())) ((Item_field *) item)->field->sort_length()) &&
/* AND not a zero length NOT NULL string function. */
(item->type() != Item::FUNC_ITEM ||
item->maybe_null ||
item->result_type() != STRING_RESULT ||
item->max_length)))
real_order= TRUE; real_order= TRUE;
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment