mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 10:31:54 +01:00
10e2581f4d
mysql-test/r/innodb.result: Auto merged BitKeeper/deleted/.del-select.result.es~240635f6a3f1a079: Auto merged BitKeeper/deleted/.del-type_float.result.es~a5533e4118eadc04: Auto merged BitKeeper/deleted/.del-type_ranges.result.es~bb77517f4c9dc978: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/connect.test: Auto merged mysql-test/t/grant2.test: Auto merged mysql-test/t/grant_cache.test: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqlbinlog2.test: Auto merged mysql-test/t/mysqldump.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/select.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/system_mysql_db_fix.test: Auto merged mysql-test/t/type_blob.test: Auto merged mysql-test/t/type_float.test: Auto merged mysql-test/t/variables.test: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged mysql-test/mysql-test-run.sh: Merge mysql-test/r/alter_table.result: Update results mysql-test/r/ctype_ucs.result: Update results mysql-test/r/grant.result: Update results mysql-test/r/insert_select.result: Update results mysql-test/r/ps_1general.result: Update results mysql-test/r/select.result: Update results mysql-test/r/timezone2.result: Update results mysql-test/r/type_blob.result: Update results mysql-test/r/type_ranges.result: Update results mysql-test/r/user_var.result: Update results mysql-test/t/ctype_ucs.test: Merge mysql-test/t/grant.test: Merge mysql-test/t/insert_select.test: Merge mysql-test/t/timezone2.test: Merge mysql-test/t/type_ranges.test: Merge mysql-test/t/user_var.test: Merge
147 lines
4.6 KiB
Text
147 lines
4.6 KiB
Text
# Grant tests not performed with embedded server
|
|
-- source include/not_embedded.inc
|
|
-- source include/have_query_cache.inc
|
|
|
|
#
|
|
# Test grants with query cache
|
|
#
|
|
--disable_warnings
|
|
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
|
|
drop database if exists mysqltest;
|
|
--enable_warnings
|
|
|
|
reset query cache;
|
|
flush status;
|
|
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection root;
|
|
show grants for current_user;
|
|
show grants;
|
|
--disable_warnings
|
|
create database if not exists mysqltest;
|
|
--enable_warnings
|
|
|
|
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;
|
|
connect (root2,localhost,root,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
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
|
|
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection user1;
|
|
show grants for current_user();
|
|
show status like "Qcache_queries_in_cache";
|
|
show status like "Qcache_hits";
|
|
show status like "Qcache_not_cached";
|
|
select "user1";
|
|
show status like "Qcache_queries_in_cache";
|
|
show status like "Qcache_hits";
|
|
show status like "Qcache_not_cached";
|
|
select * from t1;
|
|
show status like "Qcache_queries_in_cache";
|
|
show status like "Qcache_hits";
|
|
show status like "Qcache_not_cached";
|
|
# The pre and end space are intentional
|
|
select a from t1 ;
|
|
show status like "Qcache_queries_in_cache";
|
|
show status like "Qcache_hits";
|
|
show status like "Qcache_not_cached";
|
|
select c from t1;
|
|
show status like "Qcache_queries_in_cache";
|
|
show status like "Qcache_hits";
|
|
show status like "Qcache_not_cached";
|
|
|
|
# Don't use '' as user because it will pick Unix login
|
|
connect (unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection unkuser;
|
|
show grants for current_user();
|
|
|
|
# The following queries should be fetched from cache
|
|
connect (user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection user2;
|
|
select "user2";
|
|
select * from t1;
|
|
select a from t1;
|
|
select c from t1;
|
|
select * from mysqltest.t1,test.t1;
|
|
--replace_result 127.0.0.1 localhost
|
|
--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
|
|
connect (user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection user3;
|
|
select "user3";
|
|
--replace_result 127.0.0.1 localhost
|
|
--error 1143
|
|
select * from t1;
|
|
select a from t1;
|
|
--replace_result 127.0.0.1 localhost
|
|
--error 1143
|
|
select c from t1;
|
|
--replace_result 127.0.0.1 localhost
|
|
--error 1142
|
|
select * from t2;
|
|
--replace_result 127.0.0.1 localhost
|
|
--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
|
|
connect (user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
|
|
connection user4;
|
|
select "user4";
|
|
show grants;
|
|
--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;
|
|
#
|
|
# 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;
|
|
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;
|