summaryrefslogtreecommitdiff
path: root/mysql-test/t/analyze_format_json.test
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2015-10-06 18:03:10 +0300
committerSergei Petrunia <psergey@askmonty.org>2015-10-06 18:03:10 +0300
commitd6371d3a8eccedb056708b9d8abae9cc4db3ed4e (patch)
tree3c388fd874823c46c0935e9501932b004c7b3d5b /mysql-test/t/analyze_format_json.test
parent21adad000a00a62357c0da63ff9ae98850475618 (diff)
downloadmariadb-git-d6371d3a8eccedb056708b9d8abae9cc4db3ed4e.tar.gz
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.
Diffstat (limited to 'mysql-test/t/analyze_format_json.test')
-rw-r--r--mysql-test/t/analyze_format_json.test36
1 files changed, 36 insertions, 0 deletions
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;
+