diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2012-06-29 22:17:16 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2012-06-29 22:17:16 +0400 |
commit | b9093d370bc8185ed067b41a6d5765a26ef21f89 (patch) | |
tree | febe73e9c78980d3f74b1b620c53edeacc798ebf /mysql-test | |
parent | 94bf016321825209353b41c03e0ea8399787303e (diff) | |
download | mariadb-git-b9093d370bc8185ed067b41a6d5765a26ef21f89.tar.gz |
MWL#182: Explain running statements: address review feedback
- Fix the year in Monty Program Ab copyrights in the new files.
- Fix permissions handling so that SHOW EXPLAIN's handling is the
same as SHOW PROCESSLIST's.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/show_explain.result | 45 | ||||
-rw-r--r-- | mysql-test/t/show_explain.test | 67 |
2 files changed, 109 insertions, 3 deletions
diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result index 07bcb29a7ea..a4097b9d65e 100644 --- a/mysql-test/r/show_explain.result +++ b/mysql-test/r/show_explain.result @@ -728,4 +728,49 @@ a 2 set debug_dbug=''; drop table t1,t3,t4; +# +# ---------- SHOW EXPLAIN and permissions ----------------- +# +grant ALL on test.* to test2@localhost; +# +# First, make sure that user 'test2' cannot do SHOW EXPLAIN on us +# +set debug_dbug='d,show_explain_probe_join_exec_start'; +select * from t0 where a < 3; +show explain for $thr2; +ERROR 42000: Access denied; you need (at least one of) the PROCESSLIST privilege(s) for this operation +show explain for $thr2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +Warnings: +Note 1003 select * from t0 where a < 3 +a +0 +1 +2 +set debug_dbug=''; +# +# Unfortunately, our test setup doesn't allow to check that test2 +# can do SHOW EXPLAIN on his own queries. This is because SET debug_dbug +# requires SUPER privilege. Giving SUPER to test2 will make the test +# meaningless +# +# +# Now, grant test2 a PROCESSLIST permission, and see that he's able to observe us +# +grant process on *.* to test2@localhost; +set debug_dbug='d,show_explain_probe_join_exec_start'; +select * from t0 where a < 3; +show explain for $thr2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +Warnings: +Note 1003 select * from t0 where a < 3 +a +0 +1 +2 +set debug_dbug=''; +revoke all privileges on test.* from test2@localhost; +drop user test2@localhost; drop table t0; diff --git a/mysql-test/t/show_explain.test b/mysql-test/t/show_explain.test index ffd2c25dfd9..5db6b96d93b 100644 --- a/mysql-test/t/show_explain.test +++ b/mysql-test/t/show_explain.test @@ -727,10 +727,71 @@ reap; set debug_dbug=''; drop table t1,t3,t4; + +--echo # +--echo # ---------- SHOW EXPLAIN and permissions ----------------- +--echo # +grant ALL on test.* to test2@localhost; + +connect (con2, localhost, test2,,); +connection con1; + +--echo # +--echo # First, make sure that user 'test2' cannot do SHOW EXPLAIN on us +--echo # +set debug_dbug='d,show_explain_probe_join_exec_start'; +send +select * from t0 where a < 3; + +connection default; +--source include/wait_condition.inc + +connection con2; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +evalp show explain for $thr2; + +connection default; +evalp show explain for $thr2; + +connection con1; +reap; +set debug_dbug=''; + +--echo # +--echo # Unfortunately, our test setup doesn't allow to check that test2 +--echo # can do SHOW EXPLAIN on his own queries. This is because SET debug_dbug +--echo # requires SUPER privilege. Giving SUPER to test2 will make the test +--echo # meaningless +--echo # + +--echo # +--echo # Now, grant test2 a PROCESSLIST permission, and see that he's able to observe us +--echo # +disconnect con2; +grant process on *.* to test2@localhost; +connect (con2, localhost, test2,,); +connection con1; + +set debug_dbug='d,show_explain_probe_join_exec_start'; +send +select * from t0 where a < 3; + +connection default; +--source include/wait_condition.inc + +connection con2; +evalp show explain for $thr2; + +connection con1; +reap; +set debug_dbug=''; + + + +revoke all privileges on test.* from test2@localhost; +drop user test2@localhost; + ## TODO: Test this: have several SHOW EXPLAIN requests be queued up for a ## thread and served together. -## TODO: SHOW EXPLAIN while the primary query is running EXPLAIN EXTENDED/PARTITIONS -## - drop table t0; |