timezone_grant.test
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:3k
源码类别:
MySQL数据库
开发平台:
Visual C++
- # Embedded server testing does not support grants
- -- source include/not_embedded.inc
- #
- # Test for bug #6116 "SET time_zone := ... requires access to mysql.time_zone
- # tables". We should allow implicit access to time zone description tables
- # even for unprivileged users.
- #
- # Let us prepare playground
- delete from mysql.user where user like 'mysqltest_%';
- delete from mysql.db where user like 'mysqltest_%';
- delete from mysql.tables_priv where user like 'mysqltest_%';
- delete from mysql.columns_priv where user like 'mysqltest_%';
- flush privileges;
- create table t1 (a int, b datetime);
- create table t2 (c int, d datetime);
- grant all privileges on test.* to mysqltest_1@localhost;
- connect (tzuser, localhost, mysqltest_1,,);
- connection tzuser;
- show grants for current_user();
- set time_zone= '+00:00';
- set time_zone= 'Europe/Moscow';
- select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC');
- select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
- # Let us also check whenever multi-update works ok
- update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
- where t1.a = t2.c and t2.d = (select max(d) from t2);
- # But still these two statements should not work:
- --error 1044
- select * from mysql.time_zone_name;
- --error 1044
- select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
- #
- # Test for bug #6765 "Implicit access to time zone description tables
- # requires privileges for them if some table or column level grants
- # present"
- #
- connection default;
- # Let use some table-level grants instead of db-level
- # to make life more interesting
- delete from mysql.db where user like 'mysqltest_%';
- flush privileges;
- grant all privileges on test.t1 to mysqltest_1@localhost;
- grant all privileges on test.t2 to mysqltest_1@localhost;
- # The test itself is almost the same as previous one
- connect (tzuser2, localhost, mysqltest_1,,);
- connection tzuser2;
- show grants for current_user();
- set time_zone= '+00:00';
- set time_zone= 'Europe/Moscow';
- select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC');
- select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
- update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
- where t1.a = t2.c and t2.d = (select max(d) from t2);
- # Again these two statements should not work (but with different errors):
- --error 1142
- select * from mysql.time_zone_name;
- --error 1142
- select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
- #
- # Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus
- # privilege error
- #
- drop table t1, t2;
- create table t1 (a int, b datetime);
- create table t2 (a int, b varchar(40));
- update t1 set b = '2005-01-01 10:00';
- update t1 set b = convert_tz(b, 'UTC', 'UTC');
- update t1 join t2 on (t1.a = t2.a) set t1.b = '2005-01-01 10:00' where t2.b = 'foo';
- update t1 join t2 on (t1.a = t2.a) set t1.b = convert_tz('2005-01-01 10:00','UTC','UTC') where t2.b = 'foo';
- # Clean-up
- connection default;
- delete from mysql.user where user like 'mysqltest_%';
- delete from mysql.db where user like 'mysqltest_%';
- delete from mysql.tables_priv where user like 'mysqltest_%';
- flush privileges;
- drop table t1, t2;
- # End of 4.1 tests