3010 oystein.grovlen@stripped 2010-04-13
Bug#51980 mysqld service crashes with a simple COUNT(DISTINCT) query over a view
Problem: Segmentation fault in add_group_and_distinct_keys() when accessing
field of what is assumed to be an Item_field object.
Cause: In case of views, the item added to list by is_indexed_agg_distinct()
was not of type Item_field, but Item_ref.
Resolution: Add the real Item_field object, the one referred to by
Item_ref object, to the list, instead.
@ mysql-test/r/count_distinct.result
Results for test case for Bug#51980.
@ mysql-test/t/count_distinct.test
Test case for Bug#51980.
Table needs to contain at least two rows to avoid const table optimization.
@ sql/sql_select.cc
Make sure it is the actual Item_field object that is pushed to the out_args
list of is_indexed_agg_distinct(), and not Item_ref objects.
modified:
mysql-test/r/count_distinct.result
mysql-test/t/count_distinct.test
sql/sql_select.cc
3009 Alexander Nozdrin 2010-04-12 [merge]
Auto-merge from mysql-trunk.
removed:
sql/lex_hash.h
sql/sql_yacc.h
modified:
sql/events.h
sql/lock.h
sql/mysqld.h
sql/rpl_filter.h
sql/sp.h
sql/sql_base.h
sql/sql_cache.h
sql/sql_delete.h
sql/sql_derived.h
sql/sql_handler.h
sql/sql_parse.h
sql/sql_profile.h
sql/sql_table.h
sql/sql_update.h
sql/table.h
storage/perfschema/unittest/pfs_timer-t.cc
=== modified file 'mysql-test/r/count_distinct.result'
--- a/mysql-test/r/count_distinct.result 2009-12-22 09:52:23 +0000
+++ b/mysql-test/r/count_distinct.result 2010-04-13 09:38:28 +0000
@@ -86,3 +86,11 @@ select count(distinct if(f1,3,f2)) from
count(distinct if(f1,3,f2))
2
drop table t1;
+create table t1 (i int);
+insert into t1 values (0), (1);
+create view v1 as select * from t1;
+select count(distinct i) from v1;
+count(distinct i)
+2
+drop table t1;
+drop view v1;
=== modified file 'mysql-test/t/count_distinct.test'
--- a/mysql-test/t/count_distinct.test 2009-12-22 09:52:23 +0000
+++ b/mysql-test/t/count_distinct.test 2010-04-13 09:38:28 +0000
@@ -96,3 +96,14 @@ insert into t1 values (0,1),(1,2);
select count(distinct if(f1,3,f2)) from t1;
drop table t1;
+#
+# Bug #51980 "mysqld service crashes with a simple COUNT(DISTINCT) query
+# over a view"
+#
+
+create table t1 (i int);
+insert into t1 values (0), (1);
+create view v1 as select * from t1;
+select count(distinct i) from v1;
+drop table t1;
+drop view v1;
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-03-31 14:05:33 +0000
+++ b/sql/sql_select.cc 2010-04-13 09:38:28 +0000
@@ -4157,7 +4157,7 @@ is_indexed_agg_distinct(JOIN *join, List
optimization is applicable
*/
if (out_args)
- out_args->push_back((Item_field *) expr);
+ out_args->push_back((Item_field *) expr->real_item());
result= true;
}
}
Attachment: [text/bzr-bundle]
| Thread |
|---|
| • bzr push into mysql-trunk-bugfixing branch (oystein.grovlen:3009 to3010) Bug#51980 | Oystein.Grovlen | 13 Apr |