diff options
author | unknown <oystein.grovlen@sun.com> | 2010-04-13 11:38:28 +0200 |
---|---|---|
committer | unknown <oystein.grovlen@sun.com> | 2010-04-13 11:38:28 +0200 |
commit | 6a5b47a40015acfaf348e89d80d7b114dd53b120 (patch) | |
tree | d70457c22681aa24e0fc9cf4bdf3e2ac7ee21215 /mysql-test/r/count_distinct.result | |
parent | 1b9adec789038d1059ff6a4d12058eed31619c6e (diff) | |
download | mariadb-git-6a5b47a40015acfaf348e89d80d7b114dd53b120.tar.gz |
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.
Diffstat (limited to 'mysql-test/r/count_distinct.result')
-rw-r--r-- | mysql-test/r/count_distinct.result | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result index 804bc1f4788..3b65dd0e608 100644 --- a/mysql-test/r/count_distinct.result +++ b/mysql-test/r/count_distinct.result @@ -86,3 +86,11 @@ select count(distinct if(f1,3,f2)) from t1; 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; |