Debian Codegraph @

mysql-test/suite/sys_vars/inc/explain_default_format.inc

raw
1 --source include/elide_costs.inc
2
3 # WL15040: Add system variable to control EXPLAIN format
4
5 # Save the original explain_format value.
6 set @orig_explain_format=@@global.explain_format;
7
8 # Test the initial value. It should be TRADITIONAL_STRICT.
9 select @@explain_format, @@global.explain_format;
10
11 # hypergraph with TRADITIONAL_STRICT should error out, rather than convert to TREE.
12 --error 0, ER_HYPERGRAPH_NOT_SUPPORTED_YET
13 explain select 1;
14
15 set explain_format=traditional;
16
17 --echo # With hypergraph and TRADITIONAL, EXPLAIN should use TREE format.
18 explain select 1;
19
20 --echo # Test that explain_format can be set to any of the scopes; i.e. session,
21 --echo # global and persist.
22
23 set persist explain_format=tree;
24 select @@explain_format, @@global.explain_format;
25 set global explain_format=json;
26 select @@explain_format, @@global.explain_format;
27 set explain_format=tree;
28 select @@explain_format, @@global.explain_format;
29 set explain_format=default;
30 select @@explain_format, @@global.explain_format;
31 set global explain_format=default;
32 select @@explain_format, @@global.explain_format;
33 set persist explain_format=default;
34 select @@explain_format, @@global.explain_format;
35 set explain_format=default;
36 select @@explain_format, @@global.explain_format;
37 reset persist explain_format; # Required to clear the conf file.
38 select @@explain_format, @@global.explain_format;
39 # Also delete the conf file to remote test foot-prints
40 let $MYSQLD_DATADIR= `select @@datadir`;
41 --remove_file $MYSQLD_DATADIR/mysqld-auto.cnf
42
43 explain select 1;
44 explain format=tree select 1;
45 explain format=json select 1;
46
47 set explain_format=tree;
48 explain select 1;
49 explain format=json select 1;
50
51 set explain_format=json;
52 explain format=tree select 1;
53 explain select 1;
54
55 set explain_format=default;
56 explain select 1;
57 explain format=tree select 1;
58
59 set global explain_format=json; # Test that global setting does not interfere
60 set explain_format=traditional;
61 explain select 1;
62
63 # Analyze should work with both traditional and traditional_strict, regardless
64 # of hypergraph.
65 set explain_format=traditional;
66 --replace_regex $elide_time
67 explain analyze select 1;
68 set explain_format=traditional_strict;
69 --replace_regex $elide_time
70 explain analyze select 1;
71
72 # But explicit use of unsupported format should error out.
73 --error ER_NOT_SUPPORTED_YET
74 explain analyze format=traditional select 1;
75
76 # TRADITIONAL_STRICT value is only allowed in the sys variable; not in EXPLAIN.
77 --error ER_UNKNOWN_EXPLAIN_FORMAT
78 explain format=traditional_strict select 1;
79
80 # Reset the global var to the original value
81 set global explain_format=@orig_explain_format;
82
83 select @@explain_format, @@global.explain_format;