1
by brian
clean slate |
1 |
--disable_warnings |
2 |
drop tables if exists t1, t2; |
|
3 |
drop view if exists v1; |
|
4 |
--enable_warnings |
|
5 |
||
6 |
#
|
|
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. |
|
10 |
#
|
|
11 |
||
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\_%'; |
|
17 |
flush privileges; |
|
18 |
create table t1 (a int, b datetime); |
|
19 |
create table t2 (c int, d datetime); |
|
20 |
||
21 |
grant all privileges on test.* to mysqltest_1@localhost; |
|
22 |
connect (tzuser, localhost, mysqltest_1,,); |
|
23 |
connection tzuser; |
|
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: |
|
33 |
--error 1142 |
|
34 |
select * from mysql.time_zone_name; |
|
35 |
--error 1142 |
|
36 |
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; |
|
37 |
||
38 |
#
|
|
39 |
# Test for bug #6765 "Implicit access to time zone description tables |
|
40 |
# requires privileges for them if some table or column level grants
|
|
41 |
# present"
|
|
42 |
#
|
|
43 |
connection default; |
|
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\_%'; |
|
47 |
flush privileges; |
|
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,,); |
|
52 |
connection tzuser2; |
|
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): |
|
61 |
--error 1142 |
|
62 |
select * from mysql.time_zone_name; |
|
63 |
--error 1142 |
|
64 |
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; |
|
65 |
||
66 |
#
|
|
67 |
# Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus |
|
68 |
# privilege error |
|
69 |
#
|
|
70 |
drop table t1, t2; |
|
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'; |
|
77 |
||
78 |
# Clean-up |
|
79 |
connection default; |
|
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\_%'; |
|
83 |
flush privileges; |
|
84 |
drop table t1, t2; |
|
85 |
||
86 |
# End of 4.1 tests |
|
87 |
||
88 |
#
|
|
89 |
# Additional test for bug #15153: CONVERT_TZ() is not allowed in all |
|
90 |
# places in views. |
|
91 |
#
|
|
92 |
# Let us check that usage of CONVERT_TZ() function in view does not |
|
93 |
# require additional privileges. |
|
94 |
||
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; |
|
101 |
select * from v1; |
|
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; |
|
105 |
drop view v1; |
|
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; |
|
108 |
connection default; |
|
109 |
drop table t1; |
|
110 |
drop user mysqltest_1@localhost; |
|
111 |
||
112 |
# End of 5.0 tests |