~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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
# Save the initial number of concurrent sessions
 
5
--source include/count_sessions.inc
 
6
 
 
7
--disable_warnings
 
8
drop tables if exists t1, t2;
 
9
drop view if exists v1;
 
10
--enable_warnings
 
11
 
 
12
#
 
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
 
15
# unprivileged users.
 
16
#
 
17
 
 
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\_%';
 
23
flush privileges;
 
24
create table t1 (a int, b datetime);
 
25
create table t2 (c int, d datetime);
 
26
 
 
27
grant all privileges on test.* to mysqltest_1@localhost;
 
28
connect (tzuser, localhost, mysqltest_1,,);
 
29
connection tzuser;
 
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;
 
43
 
 
44
connection default;
 
45
disconnect tzuser;
 
46
 
 
47
#
 
48
# Bug#6765 Implicit access to time zone description tables requires privileges
 
49
#          for them if some table or column level grants present
 
50
#
 
51
connection default;
 
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\_%';
 
55
flush privileges;
 
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,,);
 
60
connection tzuser2;
 
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;
 
73
 
 
74
#
 
75
# Bug#9979 Use of CONVERT_TZ in multiple-table UPDATE causes bogus
 
76
#          privilege error
 
77
#
 
78
drop table t1, t2;
 
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';
 
85
 
 
86
# Clean-up
 
87
connection default;
 
88
disconnect tzuser2;
 
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\_%';
 
92
flush privileges;
 
93
drop table t1, t2;
 
94
 
 
95
# End of 4.1 tests
 
96
 
 
97
#
 
98
# Additional test for Bug#15153 CONVERT_TZ() is not allowed in all places in views.
 
99
#
 
100
# Let us check that usage of CONVERT_TZ() function in view does not
 
101
# require additional privileges.
 
102
 
 
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;
 
109
select * from v1;
 
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;
 
113
drop view v1;
 
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;
 
116
connection default;
 
117
disconnect tzuser3;
 
118
drop table t1;
 
119
drop user mysqltest_1@localhost;
 
120
 
 
121
# End of 5.0 tests
 
122
 
 
123
# Wait till we reached the initial number of concurrent sessions
 
124
--source include/wait_until_count_sessions.inc