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