1
# Embedded server testing does not support grants
2
-- source include/not_embedded.inc
4
# Save the initial number of concurrent sessions
5
--source include/count_sessions.inc
8
drop tables if exists t1, t2;
9
drop view if exists v1;
13
# Test for Bug#6116 SET time_zone := ... requires access to mysql.time_zone tables
14
# We should allow implicit access to time zone description tables even for
18
# Let us prepare playground
19
delete from mysql.user where user like 'mysqltest\_%';
20
delete from mysql.db where user like 'mysqltest\_%';
21
delete from mysql.tables_priv where user like 'mysqltest\_%';
22
delete from mysql.columns_priv where user like 'mysqltest\_%';
24
create table t1 (a int, b datetime);
25
create table t2 (c int, d datetime);
27
grant all privileges on test.* to mysqltest_1@localhost;
28
connect (tzuser, localhost, mysqltest_1,,);
30
show grants for current_user();
31
set time_zone= '+00:00';
32
set time_zone= 'Europe/Moscow';
33
select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC');
34
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
35
# Let us also check whenever multi-update works ok
36
update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
37
where t1.a = t2.c and t2.d = (select max(d) from t2);
38
# But still these two statements should not work:
39
--error ER_TABLEACCESS_DENIED_ERROR
40
select * from mysql.time_zone_name;
41
--error ER_TABLEACCESS_DENIED_ERROR
42
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
48
# Bug#6765 Implicit access to time zone description tables requires privileges
49
# for them if some table or column level grants present
52
# Let use some table-level grants instead of db-level
53
# to make life more interesting
54
delete from mysql.db where user like 'mysqltest\_%';
56
grant all privileges on test.t1 to mysqltest_1@localhost;
57
grant all privileges on test.t2 to mysqltest_1@localhost;
58
# The test itself is almost the same as previous one
59
connect (tzuser2, localhost, mysqltest_1,,);
61
show grants for current_user();
62
set time_zone= '+00:00';
63
set time_zone= 'Europe/Moscow';
64
select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC');
65
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
66
update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
67
where t1.a = t2.c and t2.d = (select max(d) from t2);
68
# Again these two statements should not work (but with different errors):
69
--error ER_TABLEACCESS_DENIED_ERROR
70
select * from mysql.time_zone_name;
71
--error ER_TABLEACCESS_DENIED_ERROR
72
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
75
# Bug#9979 Use of CONVERT_TZ in multiple-table UPDATE causes bogus
79
create table t1 (a int, b datetime);
80
create table t2 (a int, b varchar(40));
81
update t1 set b = '2005-01-01 10:00';
82
update t1 set b = convert_tz(b, 'UTC', 'UTC');
83
update t1 join t2 on (t1.a = t2.a) set t1.b = '2005-01-01 10:00' where t2.b = 'foo';
84
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';
89
delete from mysql.user where user like 'mysqltest\_%';
90
delete from mysql.db where user like 'mysqltest\_%';
91
delete from mysql.tables_priv where user like 'mysqltest\_%';
98
# Additional test for Bug#15153 CONVERT_TZ() is not allowed in all places in views.
100
# Let us check that usage of CONVERT_TZ() function in view does not
101
# require additional privileges.
103
# Let us rely on that previous tests done proper cleanups
104
create table t1 (a int, b datetime);
105
insert into t1 values (1, 20010101000000), (2, 20020101000000);
106
grant all privileges on test.* to mysqltest_1@localhost;
107
connect (tzuser3, localhost, mysqltest_1,,);
108
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1;
110
# Of course we should not be able select from mysql.time_zone tables
111
--error ER_TABLEACCESS_DENIED_ERROR
112
select * from v1, mysql.time_zone;
114
--error ER_TABLEACCESS_DENIED_ERROR
115
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1, mysql.time_zone;
119
drop user mysqltest_1@localhost;
123
# Wait till we reached the initial number of concurrent sessions
124
--source include/wait_until_count_sessions.inc