From d6371d3a8eccedb056708b9d8abae9cc4db3ed4e Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 6 Oct 2015 18:03:10 +0300 Subject: Combined fix for MDEV-7267 and MDEV-8864 The problem was that GROUP BY code created Item_field objects that referred to fields in the temp. tables used for GROUP BY. Item_ref and set_items_ref_array() call caused pointers to temp. table fields to occur in many places. This patch introduces Item_temptable_field, which can handle item->print() calls made after the underlying table is freed. --- mysql-test/t/analyze_format_json.test | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'mysql-test/t/analyze_format_json.test') diff --git a/mysql-test/t/analyze_format_json.test b/mysql-test/t/analyze_format_json.test index db626dc387e..807e02d2334 100644 --- a/mysql-test/t/analyze_format_json.test +++ b/mysql-test/t/analyze_format_json.test @@ -176,3 +176,39 @@ analyze format=json select a, max(b) as TOP from t2 group by a having 1=2; --replace_regex /"(r_total_time_ms|r_buffer_size)": .*?,/"volatile parameter": "REPLACED",/ analyze format=json select a, max(b) as TOP from t2 group by a; drop table t0, t1, t2; + +--echo # +--echo # MDEV-7267: Server crashes in Item_field::print on ANALYZE FORMAT=JSON +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +--replace_regex /"(r_total_time_ms|r_buffer_size)": .*?,/"volatile parameter": "REPLACED",/ +ANALYZE FORMAT=JSON SELECT STRAIGHT_JOIN * FROM t1, t2 WHERE b IN ( SELECT a FROM t1 ); + +drop table t1,t2; + +--echo # +--echo # MDEV-8864: Server crash #2 in Item_field::print on ANALYZE FORMAT=JSON +--echo # +CREATE TABLE t1 (f1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (f2 INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (2),(3); + +CREATE TABLE t3 (f3 INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (3),(4); + +--replace_regex /"(r_total_time_ms|r_buffer_size)": .*?,/"volatile parameter": "REPLACED",/ +ANALYZE FORMAT=JSON +SELECT GROUP_CONCAT(f3) AS gc, ( SELECT MAX(f1) FROM t1, t2 WHERE f2 = f3 ) sq +FROM t2, t3 +WHERE f3 IN ( 1, 2 ) +GROUP BY sq ORDER BY gc; + +drop table t1,t2,t3; + -- cgit v1.2.1