2002-03-22 21:55:08 +01:00
|
|
|
-- source include/have_query_cache.inc
|
|
|
|
|
2001-12-22 14:13:31 +01:00
|
|
|
#
|
|
|
|
# Test grants with query cache
|
|
|
|
#
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2001-12-22 14:13:31 +01:00
|
|
|
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
|
2003-08-11 21:44:43 +02:00
|
|
|
drop database if exists mysqltest;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
|
|
|
|
2001-12-22 14:13:31 +01:00
|
|
|
reset query cache;
|
|
|
|
flush status;
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection root;
|
2004-04-05 14:55:26 +02:00
|
|
|
show grants for current_user;
|
|
|
|
show grants;
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2001-12-22 14:13:31 +01:00
|
|
|
create database if not exists mysqltest;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
2001-12-22 14:13:31 +01:00
|
|
|
|
|
|
|
create table mysqltest.t1 (a int,b int,c int);
|
|
|
|
create table mysqltest.t2 (a int,b int,c int);
|
|
|
|
insert into mysqltest.t1 values (1,1,1),(2,2,2);
|
|
|
|
insert into mysqltest.t2 values (3,3,3);
|
|
|
|
create table test.t1 (a char (10));
|
|
|
|
insert into test.t1 values ("test.t1");
|
|
|
|
select * from t1;
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (root2,localhost,root,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection root2;
|
|
|
|
# put queries in cache
|
|
|
|
select * from t1;
|
|
|
|
select a from t1;
|
|
|
|
select c from t1;
|
|
|
|
select * from t2;
|
|
|
|
select * from mysqltest.t1,test.t1;
|
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits%";
|
|
|
|
|
|
|
|
# Create the test users
|
|
|
|
grant SELECT on mysqltest.* to mysqltest_1@localhost;
|
|
|
|
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
|
|
|
|
grant SELECT on test.t1 to mysqltest_2@localhost;
|
|
|
|
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
|
|
|
|
|
|
|
# The following queries should be fetched from cache
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection user1;
|
2004-04-05 14:55:26 +02:00
|
|
|
show grants for current_user();
|
2004-03-21 10:48:51 +01:00
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
2001-12-22 14:13:31 +01:00
|
|
|
select "user1";
|
2004-03-21 10:48:51 +01:00
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
2001-12-22 14:13:31 +01:00
|
|
|
select * from t1;
|
2004-03-21 10:48:51 +01:00
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
2001-12-22 14:13:31 +01:00
|
|
|
# The pre and end space are intentional
|
|
|
|
select a from t1 ;
|
2004-03-21 10:48:51 +01:00
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
2001-12-22 14:13:31 +01:00
|
|
|
select c from t1;
|
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
|
|
|
|
2004-08-12 13:12:09 +02:00
|
|
|
# Don't use '' as user because it will pick Unix login
|
2004-09-06 14:14:10 +02:00
|
|
|
connect (unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2004-04-05 14:55:26 +02:00
|
|
|
connection unkuser;
|
|
|
|
show grants for current_user();
|
|
|
|
|
2001-12-22 14:13:31 +01:00
|
|
|
# The following queries should be fetched from cache
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection user2;
|
|
|
|
select "user2";
|
|
|
|
select * from t1;
|
|
|
|
select a from t1;
|
|
|
|
select c from t1;
|
|
|
|
select * from mysqltest.t1,test.t1;
|
2003-01-28 07:38:28 +01:00
|
|
|
--replace_result 127.0.0.1 localhost
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1142
|
|
|
|
select * from t2;
|
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
|
|
|
|
|
|
|
# The following queries should not be fetched from cache
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection user3;
|
|
|
|
select "user3";
|
2003-01-28 07:38:28 +01:00
|
|
|
--replace_result 127.0.0.1 localhost
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1143
|
|
|
|
select * from t1;
|
|
|
|
select a from t1;
|
2003-01-28 07:38:28 +01:00
|
|
|
--replace_result 127.0.0.1 localhost
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1143
|
|
|
|
select c from t1;
|
2003-01-28 07:38:28 +01:00
|
|
|
--replace_result 127.0.0.1 localhost
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1142
|
|
|
|
select * from t2;
|
2003-01-28 07:38:28 +01:00
|
|
|
--replace_result 127.0.0.1 localhost
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1143
|
|
|
|
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
|
|
|
|
|
|
|
# Connect without a database
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2001-12-22 14:13:31 +01:00
|
|
|
connection user4;
|
|
|
|
select "user4";
|
2004-04-05 14:55:26 +02:00
|
|
|
show grants;
|
2001-12-22 14:13:31 +01:00
|
|
|
--error 1046
|
|
|
|
select a from t1;
|
|
|
|
# The following query is not cached before (different database)
|
|
|
|
select * from mysqltest.t1,test.t1;
|
|
|
|
# Cache a query with 'no database'
|
|
|
|
select a from mysqltest.t1;
|
|
|
|
select a from mysqltest.t1;
|
|
|
|
show status like "Qcache_queries_in_cache";
|
|
|
|
show status like "Qcache_hits";
|
|
|
|
show status like "Qcache_not_cached";
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
|
|
|
|
connection root;
|
2004-07-08 15:54:07 +02:00
|
|
|
#
|
|
|
|
# A temporary 4.1 workaround to make this test pass if
|
|
|
|
# mysql was compiled with other than latin1 --with-charset=XXX.
|
|
|
|
# Without "set names binary" the below queries fail with
|
|
|
|
# "Illegal mix of collations" error.
|
|
|
|
# In 5.0 we will change grant tables to use NCHAR(N) instead
|
|
|
|
# of "CHAR(N) BINARY", and use cast-to-nchar: N'mysqltest_1'.
|
|
|
|
#
|
|
|
|
set names binary;
|
2001-12-22 14:13:31 +01:00
|
|
|
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
|
|
|
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
|
|
|
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
|
|
|
delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
|
|
|
flush privileges;
|
|
|
|
drop table test.t1,mysqltest.t1,mysqltest.t2;
|
|
|
|
drop database mysqltest;
|