1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

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.
This commit is contained in:
Sergei Petrunia
2015-10-06 18:03:10 +03:00
parent 21adad000a
commit d6371d3a8e
8 changed files with 279 additions and 9 deletions

View File

@@ -580,3 +580,186 @@ ANALYZE
}
}
drop table t0, t1, t2;
#
# MDEV-7267: Server crashes in Item_field::print on ANALYZE FORMAT=JSON
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (3),(4);
ANALYZE FORMAT=JSON SELECT STRAIGHT_JOIN * FROM t1, t2 WHERE b IN ( SELECT a FROM t1 );
ANALYZE
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"volatile parameter": "REPLACED",
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"block-nl-join": {
"table": {
"table_name": "<subquery2>",
"access_type": "ALL",
"possible_keys": ["distinct_key"],
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"r_filtered": 100,
"materialized": {
"unique": 1,
"query_block": {
"select_id": 2,
"r_loops": 1,
"volatile parameter": "REPLACED",
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 100
}
}
}
},
"block-nl-join": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"buffer_type": "incremental",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t2.b = `<subquery2>`.a)",
"r_filtered": 0
}
}
}
drop table t1,t2;
#
# MDEV-8864: Server crash #2 in Item_field::print on ANALYZE FORMAT=JSON
#
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);
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;
ANALYZE
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"volatile parameter": "REPLACED",
"filesort": {
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 0,
"volatile parameter": "REPLACED",
"filesort": {
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 0,
"volatile parameter": "REPLACED",
"temporary_table": {
"temporary_table": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"block-nl-join": {
"table": {
"table_name": "t3",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 0,
"attached_condition": "(t3.f3 in (1,2))"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"r_filtered": null
},
"subqueries": [
{
"expression_cache": {
"state": "uninitialized",
"r_loops": 0,
"query_block": {
"select_id": 2,
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 0,
"rows": 2,
"r_rows": null,
"filtered": 100,
"r_filtered": null
},
"block-nl-join": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"r_loops": 0,
"rows": 2,
"r_rows": null,
"filtered": 100,
"r_filtered": null
},
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t2.f2 = t3.f3)",
"r_filtered": null
}
}
}
}
]
}
}
}
}
}
}
drop table t1,t2,t3;