~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/timezone_grant.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Embedded server testing does not support grants
 
2
-- source include/not_embedded.inc
 
3
 
 
4
--disable_warnings
 
5
drop tables if exists t1, t2;
 
6
drop view if exists v1;
 
7
--enable_warnings
 
8
 
 
9
#
 
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.
 
13
#
 
14
 
 
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\_%';
 
20
flush privileges;
 
21
create table t1 (a int, b datetime);
 
22
create table t2 (c int, d datetime);
 
23
 
 
24
grant all privileges on test.* to mysqltest_1@localhost;
 
25
connect (tzuser, localhost, mysqltest_1,,);
 
26
connection tzuser;
 
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:
 
36
--error 1142
 
37
select * from mysql.time_zone_name;
 
38
--error 1142
 
39
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
 
40
 
 
41
#
 
42
# Test for bug #6765 "Implicit access to time zone description tables
 
43
# requires privileges for them if some table or column level grants
 
44
# present"
 
45
#
 
46
connection default;
 
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\_%';
 
50
flush privileges;
 
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,,);
 
55
connection tzuser2;
 
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):
 
64
--error 1142
 
65
select * from mysql.time_zone_name;
 
66
--error 1142
 
67
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
 
68
 
 
69
#
 
70
# Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus
 
71
# privilege error
 
72
#
 
73
drop table t1, t2;
 
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';
 
80
 
 
81
# Clean-up
 
82
connection default;
 
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\_%';
 
86
flush privileges;
 
87
drop table t1, t2;
 
88
 
 
89
# End of 4.1 tests
 
90
 
 
91
#
 
92
# Additional test for bug #15153: CONVERT_TZ() is not allowed in all
 
93
# places in views.
 
94
#
 
95
# Let us check that usage of CONVERT_TZ() function in view does not 
 
96
# require additional privileges.
 
97
 
 
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;
 
104
select * from v1;
 
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;
 
108
drop view v1;
 
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;
 
111
connection default;
 
112
drop table t1;
 
113
drop user mysqltest_1@localhost;
 
114
 
 
115
# End of 5.0 tests