2
drop tables if exists t1, t2;
3
drop view if exists v1;
7
# Test for bug #6116 "SET time_zone := ... requires access to mysql.time_zone
8
# tables". We should allow implicit access to time zone description tables
9
# even for unprivileged users.
12
# Let us prepare playground
13
delete from mysql.user where user like 'mysqltest\_%';
14
delete from mysql.db where user like 'mysqltest\_%';
15
delete from mysql.tables_priv where user like 'mysqltest\_%';
16
delete from mysql.columns_priv where user like 'mysqltest\_%';
18
create table t1 (a int, b datetime);
19
create table t2 (c int, d datetime);
21
grant all privileges on test.* to mysqltest_1@localhost;
22
connect (tzuser, localhost, mysqltest_1,,);
24
show grants for current_user();
25
set time_zone= '+00:00';
26
set time_zone= 'Europe/Moscow';
27
select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC');
28
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
29
# Let us also check whenever multi-update works ok
30
update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
31
where t1.a = t2.c and t2.d = (select max(d) from t2);
32
# But still these two statements should not work:
34
select * from mysql.time_zone_name;
36
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
39
# Test for bug #6765 "Implicit access to time zone description tables
40
# requires privileges for them if some table or column level grants
44
# Let use some table-level grants instead of db-level
45
# to make life more interesting
46
delete from mysql.db where user like 'mysqltest\_%';
48
grant all privileges on test.t1 to mysqltest_1@localhost;
49
grant all privileges on test.t2 to mysqltest_1@localhost;
50
# The test itself is almost the same as previous one
51
connect (tzuser2, localhost, mysqltest_1,,);
53
show grants for current_user();
54
set time_zone= '+00:00';
55
set time_zone= 'Europe/Moscow';
56
select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC');
57
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
58
update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
59
where t1.a = t2.c and t2.d = (select max(d) from t2);
60
# Again these two statements should not work (but with different errors):
62
select * from mysql.time_zone_name;
64
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
67
# Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus
71
create table t1 (a int, b datetime);
72
create table t2 (a int, b varchar(40));
73
update t1 set b = '2005-01-01 10:00';
74
update t1 set b = convert_tz(b, 'UTC', 'UTC');
75
update t1 join t2 on (t1.a = t2.a) set t1.b = '2005-01-01 10:00' where t2.b = 'foo';
76
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';
80
delete from mysql.user where user like 'mysqltest\_%';
81
delete from mysql.db where user like 'mysqltest\_%';
82
delete from mysql.tables_priv where user like 'mysqltest\_%';
89
# Additional test for bug #15153: CONVERT_TZ() is not allowed in all
92
# Let us check that usage of CONVERT_TZ() function in view does not
93
# require additional privileges.
95
# Let us rely on that previous tests done proper cleanups
96
create table t1 (a int, b datetime);
97
insert into t1 values (1, 20010101000000), (2, 20020101000000);
98
grant all privileges on test.* to mysqltest_1@localhost;
99
connect (tzuser3, localhost, mysqltest_1,,);
100
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1;
102
# Of course we should not be able select from mysql.time_zone tables
103
--error ER_TABLEACCESS_DENIED_ERROR
104
select * from v1, mysql.time_zone;
106
--error ER_TABLEACCESS_DENIED_ERROR
107
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1, mysql.time_zone;
110
drop user mysqltest_1@localhost;