Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
913b7672
Commit
913b7672
authored
Dec 06, 2014
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Plain Diff
Merge bb-10.1-explain-json into 10.1
parents
db21fddc
eeef80d0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
195 additions
and
7 deletions
+195
-7
mysql-test/r/explain_json.result
mysql-test/r/explain_json.result
+53
-1
mysql-test/r/explain_json_innodb.result
mysql-test/r/explain_json_innodb.result
+57
-0
mysql-test/t/explain_json.test
mysql-test/t/explain_json.test
+19
-1
mysql-test/t/explain_json_innodb.test
mysql-test/t/explain_json_innodb.test
+28
-0
sql/my_json_writer.cc
sql/my_json_writer.cc
+5
-1
sql/sql_explain.cc
sql/sql_explain.cc
+25
-4
sql/sql_explain.h
sql/sql_explain.h
+6
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-0
No files found.
mysql-test/r/explain_json.result
View file @
913b7672
drop table if exists t0,t1;
drop table if exists t0,t1
,t2
;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
explain format=json select * from t0;
...
...
@@ -551,6 +551,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"const_condition": "1",
"table": {
"table_name": "t1",
"access_type": "ALL",
...
...
@@ -813,3 +814,54 @@ EXPLAIN
}
}
DROP TABLE t1, t2;
#
# Join's constant expression
#
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int, b int);
insert into t1 select tbl1.a+10*tbl2.a, 1234 from t0 tbl1, t0 tbl2;
explain format=json
select * from t0
where
20000 > all (select max(tbl1.a + tbl2.a)
from t1 tbl1, t1 tbl2 where tbl1.b=tbl2.b);
EXPLAIN
{
"query_block": {
"select_id": 1,
"const_condition": "<not>(<in_optimizer>(20000,(<max>(subquery#2) >= 20000)))",
"table": {
"table_name": "t0",
"access_type": "ALL",
"rows": 10,
"filtered": 100
},
"subqueries": [
{
"query_block": {
"select_id": 2,
"table": {
"table_name": "tbl1",
"access_type": "ALL",
"rows": 100,
"filtered": 100
},
"block-nl-join": {
"table": {
"table_name": "tbl2",
"access_type": "ALL",
"rows": 100,
"filtered": 100
},
"buffer_type": "flat",
"join_type": "BNL",
"attached_condition": "(tbl2.b = tbl1.b)"
}
}
}
]
}
}
drop table t1;
drop table t0;
mysql-test/r/explain_json_innodb.result
0 → 100644
View file @
913b7672
drop table if exists t0,t1,t2;
#
# MDEV-7266: Assertion `!element_started' failed in Json_writer& Json_writer::add_member
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (column_name_1 INT, column_name_2 VARCHAR(52)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (3,'United States');
CREATE TABLE t3 (b INT, c VARCHAR(3), PRIMARY KEY (c,b)) ENGINE=InnoDB;
INSERT INTO t3 VALUES (4,'USA'),(5,'CAN');
EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0 < ALL (
SELECT tbl_alias1.column_name_1 FROM t2 AS tbl_alias1, t3 AS tbl_alias2
WHERE tbl_alias2.b = tbl_alias1.column_name_1 AND tbl_alias2.c = tbl_alias1.column_name_2
);
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 2,
"filtered": 100
},
"subqueries": [
{
"query_block": {
"select_id": 2,
"table": {
"table_name": "tbl_alias1",
"access_type": "ALL",
"rows": 1,
"filtered": 100,
"attached_condition": "((tbl_alias1.column_name_2 is not null) and (tbl_alias1.column_name_1 is not null))"
},
"table": {
"table_name": "tbl_alias2",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "9",
"used_key_parts": ["c", "b"],
"ref": [
"test.tbl_alias1.column_name_2",
"test.tbl_alias1.column_name_1"
],
"rows": 1,
"filtered": 100,
"attached_condition": "(tbl_alias2.c = tbl_alias1.column_name_2)",
"using_index": true
}
}
}
]
}
}
drop table t1,t2,t3;
mysql-test/t/explain_json.test
View file @
913b7672
...
...
@@ -2,7 +2,7 @@
# EXPLAIN FORMAT=JSON tests. These are tests developed for MariaDB.
#
--
disable_warnings
drop
table
if
exists
t0
,
t1
;
drop
table
if
exists
t0
,
t1
,
t2
;
--
enable_warnings
create
table
t0
(
a
int
);
...
...
@@ -167,6 +167,24 @@ EXPLAIN FORMAT=JSON SELECT * FROM t1 AS outer_t1 WHERE a <> ALL ( SELECT a FROM
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Join's constant expression
--
echo
#
create
table
t0
(
a
int
);
insert
into
t0
values
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
select
tbl1
.
a
+
10
*
tbl2
.
a
,
1234
from
t0
tbl1
,
t0
tbl2
;
explain
format
=
json
select
*
from
t0
where
20000
>
all
(
select
max
(
tbl1
.
a
+
tbl2
.
a
)
from
t1
tbl1
,
t1
tbl2
where
tbl1
.
b
=
tbl2
.
b
);
drop
table
t1
;
drop
table
t0
;
--
echo
#
--
echo
# MDEV-7264: Assertion `0' failed in subselect_engine::get_identifier() on EXPLAIN JSON
--
echo
#
...
...
mysql-test/t/explain_json_innodb.test
0 → 100644
View file @
913b7672
#
# MariaDB's EXPLAIN FORMAT=JSON tests that require InnoDB.
#
--
source
include
/
have_innodb
.
inc
--
disable_warnings
drop
table
if
exists
t0
,
t1
,
t2
;
--
enable_warnings
--
echo
#
--
echo
# MDEV-7266: Assertion `!element_started' failed in Json_writer& Json_writer::add_member
--
echo
#
CREATE
TABLE
t1
(
a
INT
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
column_name_1
INT
,
column_name_2
VARCHAR
(
52
))
ENGINE
=
InnoDB
;
INSERT
INTO
t2
VALUES
(
3
,
'United States'
);
CREATE
TABLE
t3
(
b
INT
,
c
VARCHAR
(
3
),
PRIMARY
KEY
(
c
,
b
))
ENGINE
=
InnoDB
;
INSERT
INTO
t3
VALUES
(
4
,
'USA'
),(
5
,
'CAN'
);
EXPLAIN
FORMAT
=
JSON
SELECT
*
FROM
t1
WHERE
0
<
ALL
(
SELECT
tbl_alias1
.
column_name_1
FROM
t2
AS
tbl_alias1
,
t3
AS
tbl_alias2
WHERE
tbl_alias2
.
b
=
tbl_alias1
.
column_name_1
AND
tbl_alias2
.
c
=
tbl_alias1
.
column_name_2
);
drop
table
t1
,
t2
,
t3
;
sql/my_json_writer.cc
View file @
913b7672
...
...
@@ -218,7 +218,8 @@ bool Single_line_formatting_helper::on_start_array()
}
else
{
state
=
INACTIVE
;
if
(
state
!=
DISABLED
)
state
=
INACTIVE
;
// TODO: what if we have accumulated some stuff already? shouldn't we
// flush it?
return
false
;
// not handled
...
...
@@ -313,6 +314,9 @@ void Single_line_formatting_helper::flush_on_one_line()
void
Single_line_formatting_helper
::
disable_and_flush
()
{
if
(
state
==
DISABLED
)
return
;
bool
start_array
=
(
state
==
IN_ARRAY
);
state
=
DISABLED
;
// deactivate ourselves and flush all accumulated calls.
...
...
sql/sql_explain.cc
View file @
913b7672
...
...
@@ -27,6 +27,8 @@ const char * STR_DELETING_ALL_ROWS= "Deleting all rows";
const
char
*
STR_IMPOSSIBLE_WHERE
=
"Impossible WHERE"
;
const
char
*
STR_NO_ROWS_AFTER_PRUNING
=
"No matching rows after partition pruning"
;
static
void
write_item
(
Json_writer
*
writer
,
Item
*
item
);
Explain_query
::
Explain_query
(
THD
*
thd_arg
,
MEM_ROOT
*
root
)
:
mem_root
(
root
),
upd_del_plan
(
NULL
),
insert_plan
(
NULL
),
unions
(
root
),
selects
(
root
),
thd
(
thd_arg
),
apc_enabled
(
false
),
...
...
@@ -732,7 +734,17 @@ void Explain_select::print_explain_json(Explain_query *query,
Explain_basic_join does not have ORDER/GROUP.
A: factor out join tab printing loop into a common func.
*/
Explain_basic_join
::
print_explain_json
(
query
,
writer
,
is_analyze
);
writer
->
add_member
(
"query_block"
).
start_object
();
writer
->
add_member
(
"select_id"
).
add_ll
(
select_id
);
if
(
exec_const_cond
)
{
writer
->
add_member
(
"const_condition"
);
write_item
(
writer
,
exec_const_cond
);
}
Explain_basic_join
::
print_explain_json_interns
(
query
,
writer
,
is_analyze
);
writer
->
end_object
();
}
}
...
...
@@ -742,10 +754,20 @@ void Explain_basic_join::print_explain_json(Explain_query *query,
Json_writer
*
writer
,
bool
is_analyze
)
{
Json_writer_nesting_guard
guard
(
writer
);
writer
->
add_member
(
"query_block"
).
start_object
();
writer
->
add_member
(
"select_id"
).
add_ll
(
select_id
);
print_explain_json_interns
(
query
,
writer
,
is_analyze
);
writer
->
end_object
();
}
void
Explain_basic_join
::
print_explain_json_interns
(
Explain_query
*
query
,
Json_writer
*
writer
,
bool
is_analyze
)
{
Json_writer_nesting_guard
guard
(
writer
);
for
(
uint
i
=
0
;
i
<
n_join_tabs
;
i
++
)
{
if
(
join_tabs
[
i
]
->
start_dups_weedout
)
...
...
@@ -757,7 +779,6 @@ void Explain_basic_join::print_explain_json(Explain_query *query,
writer
->
end_object
();
}
print_explain_json_for_children
(
query
,
writer
,
is_analyze
);
writer
->
end_object
();
}
...
...
sql/sql_explain.h
View file @
913b7672
...
...
@@ -175,6 +175,9 @@ class Explain_basic_join : public Explain_node
void
print_explain_json
(
Explain_query
*
query
,
Json_writer
*
writer
,
bool
is_analyze
);
void
print_explain_json_interns
(
Explain_query
*
query
,
Json_writer
*
writer
,
bool
is_analyze
);
/* A flat array of Explain structs for tables. */
Explain_table_access
**
join_tabs
;
uint
n_join_tabs
;
...
...
@@ -222,6 +225,9 @@ class Explain_select : public Explain_basic_join
*/
const
char
*
message
;
/* Expensive constant condition */
Item
*
exec_const_cond
;
/* Global join attributes. In tabular form, they are printed on the first row */
bool
using_temporary
;
bool
using_filesort
;
...
...
sql/sql_select.cc
View file @
913b7672
...
...
@@ -23768,6 +23768,8 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
if
(
need_order
)
xpl_sel
->
using_filesort
=
true
;
xpl_sel
->
exec_const_cond
=
exec_const_cond
;
JOIN_TAB
*
const
first_top_tab
=
first_breadth_first_tab
(
join
,
WALK_OPTIMIZATION_TABS
);
JOIN_TAB
*
prev_bush_root_tab
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment