1 # This file is a collection of utility tests
2 # for WL#4897: Add EXPLAIN INSERT/UPDATE/DELETE.
4 # Since MTR doesn't have functions, we use this file instead
5 # including it many times.
9 # $query: INSERT/REPLACE/UPDATE/DELETE query to explain
10 # NOTE: this file resets this variable
12 # $select: may be empty; the SELECT query similar to $query
13 # We use it to compare:
14 # 1) table data before and after EXPLAIN $query evaluation;
15 # 2) EXPLAIN $query and EXPLAIN $select output and
16 # handler/filesort statistics
17 # NOTE: this file resets this variable
18 # $innodb: take $no_rows parameter into account if not 0;
19 # $no_rows: filter out "rows" and "filtered" columns of EXPLAIN if not 0;
20 # it may be necessary for InnoDB tables since InnoDB's table row
21 # counter can't return precise and repeatable values;
22 # NOTE: ANALYZE TABLE doesn't help
23 # NOTE: this file resets this variable
26 --echo #
query: $query
27 --echo # select: $select
32 --eval $select INTO OUTFILE
'$MYSQLTEST_VARDIR/tmp/before_explain.txt'
42 if (`SELECT ROW_COUNT() > 0`) {
43 --echo # Erroneous
query: EXPLAIN $query
44 --die Unexpected ROW_COUNT() <> 0
51 --replace_column 9 X 10 X
54 --eval EXPLAIN EXTENDED $query
55 if (`SELECT ROW_COUNT() > 0`) {
56 --echo # Erroneous
query: EXPLAIN EXTENDED $query
57 --die Unexpected ROW_COUNT() <> 0
59 --echo # Status of EXPLAIN EXTENDED
query
61 SHOW STATUS WHERE (Variable_name LIKE
'Sort%' OR
62 Variable_name LIKE
'Handler_read_%' OR
63 Variable_name =
'Handler_write' OR
64 Variable_name =
'Handler_update' OR
65 Variable_name =
'Handler_delete') AND Value <> 0;
71 --replace_regex /
"rows": [0-9]+/
"rows":
"X"/ /
"filtered": [0-9.]+/
"filtered":
"X"/
74 --eval EXPLAIN FORMAT=JSON $query;
77 --replace_result $MASTER_MYSOCK MASTER_MYSOCK
78 --exec $MYSQL -S $MASTER_MYSOCK -u root -r
test -e
"EXPLAIN FORMAT=JSON $query;" > $MYSQLTEST_VARDIR/tmp/explain.json
80 --exec python $MYSQL_TEST_DIR/suite/opt_trace/validate_json.py $MYSQLTEST_VARDIR/tmp/explain.json
81 --remove_file
'$MYSQLTEST_VARDIR/tmp/explain.json'
91 --replace_column 9 X 10 X
94 --eval EXPLAIN EXTENDED $select
95 --echo # Status of EXPLAIN EXTENDED
"equivalent" SELECT
query execution
97 SHOW STATUS WHERE (Variable_name LIKE
'Sort%' OR
98 Variable_name LIKE
'Handler_read_%' OR
99 Variable_name =
'Handler_write' OR
100 Variable_name =
'Handler_update' OR
101 Variable_name =
'Handler_delete') AND Value <> 0;
106 --replace_regex /
"rows": [0-9]+/
"rows":
"X"/ /
"filtered": [0-9.]+/
"filtered":
"X"/
109 --eval EXPLAIN FORMAT=JSON $select;
112 --replace_result $MASTER_MYSOCK MASTER_MYSOCK
113 --exec $MYSQL -S $MASTER_MYSOCK -u root -r
test -e
"EXPLAIN FORMAT=JSON $select;" > $MYSQLTEST_VARDIR/tmp/explain.json
114 --replace_regex /[-]*
115 --exec python $MYSQL_TEST_DIR/suite/opt_trace/validate_json.py $MYSQLTEST_VARDIR/tmp/explain.json
116 --remove_file
'$MYSQLTEST_VARDIR/tmp/explain.json'
125 --eval $select INTO OUTFILE
'$MYSQLTEST_VARDIR/tmp/after_explain.txt'
126 --diff_files
'$MYSQLTEST_VARDIR/tmp/before_explain.txt' '$MYSQLTEST_VARDIR/tmp/after_explain.txt'
127 --remove_file
'$MYSQLTEST_VARDIR/tmp/before_explain.txt'
128 --remove_file
'$MYSQLTEST_VARDIR/tmp/after_explain.txt'
137 --echo # Status of
"equivalent" SELECT
query execution:
138 SHOW STATUS WHERE (Variable_name LIKE
'Sort%' OR
139 Variable_name LIKE
'Handler_read_%' OR
140 Variable_name =
'Handler_write' OR
141 Variable_name =
'Handler_update' OR
142 Variable_name =
'Handler_delete') AND Value <> 0;
148 --echo
# Status of testing query execution:
149 SHOW STATUS WHERE (Variable_name LIKE
'Sort%' OR
150 Variable_name LIKE
'Handler_read_%' OR
151 Variable_name =
'Handler_write' OR
152 Variable_name =
'Handler_update' OR
153 Variable_name =
'Handler_delete') AND Value <> 0;