From fc57b4cfb569635edc1613154d9b7ed14efaf840 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 15 May 2009 12:03:34 +0500 Subject: Bug#43612 crash with explain extended, union, order by In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list. mysql-test/r/union.result: test result mysql-test/t/union.test: test case sql/sql_union.cc: In UNION if we use last SELECT without braces and this SELECT have ORDER BY clause, such clause belongs to global UNION. It is parsed like last SELECT part and used further as 'unit->global_parameters->order_list' value. During DESCRIBE EXTENDED we call select_lex->print_order() for last SELECT where order fields refer to tmp table which already freed. It leads to crash. The fix is clean up global_parameters->order_list instead of fake_select_lex->order_list. --- mysql-test/r/union.result | 13 +++++++++++++ mysql-test/t/union.test | 12 ++++++++++++ 2 files changed, 25 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index a5f49eef8d1..e806ed49c34 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1518,4 +1518,17 @@ SHOW FIELDS FROM t2; Field Type Null Key Default Extra d double(9,6) YES NULL DROP TABLE t1, t2; +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +2 UNION t1 system NULL NULL NULL NULL 0 const row not found +NULL UNION RESULT ALL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a` +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 1dbbdae24b7..0c8e025e54e 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1038,4 +1038,16 @@ CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1; SHOW FIELDS FROM t2; DROP TABLE t1, t2; +# +# Bug#43612 crash with explain extended, union, order by +# +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +DROP TABLE t1; + + --echo End of 5.0 tests -- cgit v1.2.1 From 22e840d70700cd1aceec27d6aee3883203a5a566 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 15 May 2009 12:16:00 +0400 Subject: Bug #44792: valgrind warning when casting from time to time Field_time::get_time() did not initialize some members of MYSQL_TIME which led to valgrind warnings when those members were accessed in Protocol_simple::store_time(). It is unlikely that this bug could result in wrong data being returned, since Field_time::get_time() initializes the 'day' member of MYSQL_TIME to 0, so the value of 'day' in Protocol_simple::store_time() would be 0 regardless of the values for 'year' and 'month'. mysql-test/r/type_time.result: Added a test case for bug #44792. mysql-test/t/type_time.test: Added a test case for bug #44792. sql/field.cc: Field_time::get_time() did not initialize some members of MYSQL_TIME which led to valgrind warnings when those members were accessed in Protocol_simple::store_time(). --- mysql-test/r/type_time.result | 10 ++++++++++ mysql-test/t/type_time.test | 13 +++++++++++++ 2 files changed, 23 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 96bf23109df..69dca57398f 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -128,3 +128,13 @@ SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; sum(f3) 3 drop table t1; +# +# Bug #44792: valgrind warning when casting from time to time +# +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +CAST(c AS TIME) +00:00:00 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 5fc763be7fe..5bb521601e5 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -77,3 +77,16 @@ insert into t1 values('2007-07-02', 1); insert into t1 values('2007-07-02', 2); SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; drop table t1; + + +--echo # +--echo # Bug #44792: valgrind warning when casting from time to time +--echo # + +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +DROP TABLE t1; + + +--echo End of 5.0 tests -- cgit v1.2.1