~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
use test;
2
3
#
4
# BUG#16777: Can not create trigger nor view w/o definer if --skip-grant-tables
5
# specified
6
#
7
# Also, the following test cases have been moved here:
8
#   - test that we can create VIEW if privileges check switched off has been
9
#     moved here;
10
#   - test that we can create and drop procedure without warnings (BUG#9993);
11
#   - BUG#17595: "DROP FUNCTION IF EXISTS" crashes server;
12
#   - BUG#13504: creation view with DEFINER clause if --skip-grant-tables
13
#
14
15
# Prepare.
16
17
--disable_warnings
18
19
DROP VIEW IF EXISTS v1;
20
DROP VIEW IF EXISTS v2;
21
DROP VIEW IF EXISTS v3;
22
23
DROP TABLE IF EXISTS t1;
24
25
DROP PROCEDURE IF EXISTS p1;
26
DROP PROCEDURE IF EXISTS p2;
27
DROP PROCEDURE IF EXISTS p3;
28
29
DROP FUNCTION IF EXISTS f1;
30
DROP FUNCTION IF EXISTS f2;
31
DROP FUNCTION IF EXISTS f3;
32
33
--enable_warnings
34
35
# Test case.
36
37
CREATE TABLE t1(c INT);
38
39
# - try to create with implicit definer (definer would be ''@'');
40
41
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
42
  FOR EACH ROW
43
    SET @a = 1;
44
45
CREATE VIEW v1 AS SELECT * FROM t1;
46
47
CREATE PROCEDURE p1()
48
  SELECT 1;
49
50
CREATE FUNCTION f1() RETURNS INT
51
  RETURN 1;
52
53
# - try to create with explicit definer;
54
55
CREATE DEFINER=a@b TRIGGER ti_ai AFTER INSERT ON t1
56
  FOR EACH ROW
57
    SET @b = 1;
58
59
CREATE DEFINER=a@b VIEW v2 AS SELECT * FROM t1;
60
61
CREATE DEFINER=a@b PROCEDURE p2()
62
  SELECT 2;
63
64
CREATE DEFINER=a@b FUNCTION f2() RETURNS INT
65
  RETURN 2;
66
67
# - try to create with explicit definer with empty host;
68
69
CREATE DEFINER=a@'' TRIGGER ti_bu BEFORE UPDATE ON t1
70
  FOR EACH ROW
71
    SET @c = 1;
72
73
CREATE DEFINER=a@'' VIEW v3 AS SELECT * FROM t1;
74
75
CREATE DEFINER=a@'' PROCEDURE p3()
76
  SELECT 3;
77
78
CREATE DEFINER=a@'' FUNCTION f3() RETURNS INT
79
  RETURN 3;
80
81
# - check that empty host name is treated correctly;
82
83
SHOW CREATE VIEW v3;
84
85
SHOW CREATE PROCEDURE p3;
86
87
SHOW CREATE FUNCTION f3;
88
89
# Cleanup.
90
91
DROP TRIGGER t1_bi;
92
DROP TRIGGER ti_ai;
93
DROP TRIGGER ti_bu;
94
95
DROP VIEW v1;
96
DROP VIEW v2;
97
DROP VIEW v3;
98
99
DROP TABLE t1;
100
101
DROP PROCEDURE p1;
102
DROP PROCEDURE p2;
103
DROP PROCEDURE p3;
104
105
DROP FUNCTION f1;
106
DROP FUNCTION f2;
107
DROP FUNCTION f3;
108
109
#
110
# Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server
111
#
112
--error ER_OPTION_PREVENTS_STATEMENT
113
set global event_scheduler=1;
114
115
#
116
# Bug#26285 Selecting information_schema crahes server
117
#
118
select count(*) from information_schema.COLUMN_PRIVILEGES;
119
select count(*) from information_schema.SCHEMA_PRIVILEGES;
120
select count(*) from information_schema.TABLE_PRIVILEGES;
121
select count(*) from information_schema.USER_PRIVILEGES;
122
--echo End of 5.0 tests
123
124
--echo #
125
--echo # Bug#29817 Queries with UDF fail with non-descriptive error
126
--echo # if mysql.proc is missing
127
--echo #
128
--error ER_SP_DOES_NOT_EXIST
129
select no_such_function(1);
130
131
--echo End of 5.1 tests