summaryrefslogtreecommitdiff
path: root/mysql-test/t/status.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-08-28 18:51:03 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-08-28 18:51:03 +0300
commit310afbd4a96baeedc7202a3b2cac7860c76d83e2 (patch)
treea6f10748580275e7b10aa99d7f88d2a5e1f10d02 /mysql-test/t/status.test
parent42aa480b4345aa920e0ff60001b09eb52c9c04c5 (diff)
downloadmariadb-git-310afbd4a96baeedc7202a3b2cac7860c76d83e2.tar.gz
Bug #30377: EXPLAIN loses last_query_cost when used with UNION
Currently the Last_query_cost session status variable shows only the cost of a single flat subselect. For complex queries (with subselects or unions etc) Last_query_cost is not valid as it was showing the cost for the last optimized subselect. Fixed by reseting to zero Last_query_cost when the complete cost of the query cannot be determined. Last_query_cost will be non-zero only for single flat queries. mysql-test/r/status.result: Bug #30377: test case mysql-test/t/status.test: Bug #30377: test case sql/sql_lex.h: Bug #30377: helper function sql/sql_select.cc: Bug #30377: don't assign cost if not on single level statement
Diffstat (limited to 'mysql-test/t/status.test')
-rw-r--r--mysql-test/t/status.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 6fcb82e160d..33bba3a626a 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -139,4 +139,36 @@ disconnect con3;
disconnect con2;
disconnect con1;
+
+#
+# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
+#
+
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1), (2);
+
+SELECT a FROM t1 LIMIT 1;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+EXPLAIN SELECT a FROM t1;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+SELECT * FROM t1 a, t1 b LIMIT 1;
+SHOW SESSION STATUS LIKE 'Last_query_cost';
+
+DROP TABLE t1;
+
+
# End of 5.0 tests