diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index 3de741b5efb..a81ff554ca2 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -155,6 +155,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` DROP TABLE t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY); +EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; # # Bug#37870: Usage of uninitialized value caused failed assertion. # @@ -182,3 +186,4 @@ dt 2001-01-01 01:01:01 2001-01-01 01:01:01 drop tables t1, t2; +End of 5.1 tests. diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 3a71fde4421..755e126baf2 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -123,6 +123,21 @@ execute s1; DROP TABLE t1,t2; + +# +# Bug #43354: Use key hint can crash server in explain extended query +# + +CREATE TABLE t1 (a INT PRIMARY KEY); + +--error ER_KEY_DOES_NOT_EXITS +EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a); + +DROP TABLE t1; + + +# End of 5.0 tests. + --echo # --echo # Bug#37870: Usage of uninitialized value caused failed assertion. --echo # @@ -141,4 +156,4 @@ flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); drop tables t1, t2; -# End of 5.0 tests. +--echo End of 5.1 tests. diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1821136cc9d..a6d8bb8a52d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -439,7 +439,8 @@ void Item_sum::make_field(Send_field *tmp_field) void Item_sum::print(String *str, enum_query_type query_type) { - Item **pargs= orig_args; + /* orig_args is not filled with valid values until fix_fields() */ + Item **pargs= fixed ? orig_args : args; str->append(func_name()); for (uint i=0 ; i < arg_count ; i++) {