Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-29 00:50:00+04:00, evgen@stripped +3 -0
Fixed bug#20503: Server crash due to the ORDER clause not taken into account
while space allocation
Under some circumstances DISTINCT clause can be converted to grouping.
In such cases grouping is performed by all items in the select list.
If an ORDER clause is present then items from it is prepended to group list.
But the case with ORDER wasn't taken into account when allocating the
array for sum functions. This leads to memory corruption and crash.
The JOIN::alloc_func_list() function now allocates additional space if there
is an ORDER by clause is specified and DISTINCT -> GROUP BY optimization is
possible.
mysql-test/r/select.result@stripped, 2006-09-29 00:48:52+04:00, evgen@stripped +6 -0
Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
mysql-test/t/select.test@stripped, 2006-09-29 00:47:37+04:00, evgen@stripped +10 -1
Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
sql/sql_select.cc@stripped, 2006-09-29 00:49:11+04:00, evgen@stripped +12 -0
Fixed bug#20503: Server crash due to the ORDER clause not taken into account
while space allocation
The JOIN::alloc_func_list() function now allocates additional space if there
is an ORDER by clause is specified and DISTINCT -> GROUP BY optimization is
possible.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/20503-bug-5.0-mysql
--- 1.456/sql/sql_select.cc 2006-09-29 00:50:04 +04:00
+++ 1.457/sql/sql_select.cc 2006-09-29 00:50:04 +04:00
@@ -13515,7 +13515,19 @@
disctinct->group_by optimization
*/
if (select_distinct)
+ {
group_parts+= fields_list.elements;
+ /*
+ If the ORDER clause is specified then it's possible that
+ it also will be optimized, so reserve space for it too
+ */
+ if (order)
+ {
+ ORDER *ord;
+ for (ord= order; ord; ord= ord->next)
+ group_parts++;
+ }
+ }
/* This must use calloc() as rollup_make_fields depends on this */
sum_funcs= (Item_sum**) thd->calloc(sizeof(Item_sum**) * (func_count+1) +
--- 1.138/mysql-test/r/select.result 2006-09-29 00:50:04 +04:00
+++ 1.139/mysql-test/r/select.result 2006-09-29 00:50:04 +04:00
@@ -3517,3 +3517,9 @@
2 NULL NULL NULL 2 40
2 NULL NULL NULL 2 50
DROP TABLE t1,t2,t3;
+create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int,
+c7 int, c8 int, c9 int, fulltext key (`c1`));
+select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8
+from t1 where c9=1 order by c2, c2;
+match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8
+drop table t1;
--- 1.112/mysql-test/t/select.test 2006-09-29 00:50:04 +04:00
+++ 1.113/mysql-test/t/select.test 2006-09-29 00:50:04 +04:00
@@ -2996,5 +2996,14 @@
SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
WHERE t1.id=2;
-
DROP TABLE t1,t2,t3;
+
+#
+# Bug#20503: Server crash due to the ORDER clause isn't taken into account
+# while space allocation
+#
+create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int,
+c7 int, c8 int, c9 int, fulltext key (`c1`));
+select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8
+ from t1 where c9=1 order by c2, c2;
+drop table t1;
Thread |
---|
• bk commit into 5.0 tree (evgen:1.2286) BUG#20503 | eugene | 28 Sep |