diff options
author | Ramil Kalimullin <ramil@mysql.com> | 2010-01-29 13:17:57 +0400 |
---|---|---|
committer | Ramil Kalimullin <ramil@mysql.com> | 2010-01-29 13:17:57 +0400 |
commit | 172af3722ef34876f5e33bdf63c10d46573a2864 (patch) | |
tree | 84dfec8ca6db5f95bf5e4bc26159146943c1c829 /sql/sql_select.cc | |
parent | b13ed2975d2c7be450596b429020b0b91af1dbf9 (diff) | |
download | mariadb-git-172af3722ef34876f5e33bdf63c10d46573a2864.tar.gz |
Fix for bug#49897: crash in ptr_compare when char(0) NOT NULL
column is used for ORDER BY
Problem: filesort isn't meant for null length sort data
(e.g. char(0)), that leads to a server crash.
Fix: disregard sort order if sort data record length is 0 (nothing
to sort).
mysql-test/r/select.result:
Fix for bug#49897: crash in ptr_compare when char(0) NOT NULL
column is used for ORDER BY
- test result.
mysql-test/t/select.test:
Fix for bug#49897: crash in ptr_compare when char(0) NOT NULL
column is used for ORDER BY
- test case.
sql/filesort.cc:
Fix for bug#49897: crash in ptr_compare when char(0) NOT NULL
column is used for ORDER BY
- assert added as filesort cannot handle null length sort data.
sql/sql_select.cc:
Fix for bug#49897: crash in ptr_compare when char(0) NOT NULL
column is used for ORDER BY
- don't sort null length data e.g. in case of ORDER BY CHAR(0).
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d8ec5eff5c1..239809f1d4c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -521,13 +521,26 @@ JOIN::prepare(Item ***rref_pointer_array, if (order) { + bool real_order= FALSE; ORDER *ord; for (ord= order; ord; ord= ord->next) { Item *item= *ord->item; + /* + Disregard sort order if there's only "{VAR}CHAR(0) NOT NULL" fields + there. Such fields don't contain any data to sort. + */ + if (!real_order && + (item->type() != Item::Item::FIELD_ITEM || + ((Item_field *) item)->field->maybe_null() || + ((Item_field *) item)->field->sort_length())) + real_order= TRUE; + if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) item->split_sum_func(thd, ref_pointer_array, all_fields); } + if (!real_order) + order= NULL; } if (having && having->with_sum_func) |