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

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/is_views_embedded.result

  • 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
SHOW TABLES FROM information_schema LIKE 'VIEWS';
 
2
Tables_in_information_schema (VIEWS)
 
3
VIEWS
 
4
#######################################################################
 
5
# Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
 
6
#######################################################################
 
7
DROP VIEW      IF EXISTS test.v1;
 
8
DROP PROCEDURE IF EXISTS test.p1;
 
9
DROP FUNCTION  IF EXISTS test.f1;
 
10
CREATE VIEW test.v1 AS     SELECT * FROM information_schema.VIEWS;
 
11
CREATE PROCEDURE test.p1() SELECT * FROM information_schema.VIEWS;
 
12
CREATE FUNCTION test.f1() returns BIGINT
 
13
BEGIN
 
14
DECLARE counter BIGINT DEFAULT NULL;
 
15
SELECT COUNT(*) INTO counter FROM information_schema.VIEWS;
 
16
RETURN counter;
 
17
END//
 
18
# Attention: The printing of the next result sets is disabled.
 
19
SELECT * FROM information_schema.VIEWS;
 
20
SELECT * FROM test.v1;
 
21
CALL test.p1;
 
22
SELECT test.f1();
 
23
DROP VIEW test.v1;
 
24
DROP PROCEDURE test.p1;
 
25
DROP FUNCTION test.f1;
 
26
#########################################################################
 
27
# Testcase 3.2.13.1: INFORMATION_SCHEMA.VIEWS layout
 
28
#########################################################################
 
29
DESCRIBE          information_schema.VIEWS;
 
30
Field   Type    Null    Key     Default Extra
 
31
TABLE_CATALOG   varchar(512)    YES             NULL    
 
32
TABLE_SCHEMA    varchar(64)     NO                      
 
33
TABLE_NAME      varchar(64)     NO                      
 
34
VIEW_DEFINITION longtext        NO              NULL    
 
35
CHECK_OPTION    varchar(8)      NO                      
 
36
IS_UPDATABLE    varchar(3)      NO                      
 
37
DEFINER varchar(77)     NO                      
 
38
SECURITY_TYPE   varchar(7)      NO                      
 
39
SHOW CREATE TABLE information_schema.VIEWS;
 
40
Table   Create Table
 
41
VIEWS   CREATE TEMPORARY TABLE `VIEWS` (
 
42
  `TABLE_CATALOG` varchar(512) default NULL,
 
43
  `TABLE_SCHEMA` varchar(64) NOT NULL default '',
 
44
  `TABLE_NAME` varchar(64) NOT NULL default '',
 
45
  `VIEW_DEFINITION` longtext NOT NULL,
 
46
  `CHECK_OPTION` varchar(8) NOT NULL default '',
 
47
  `IS_UPDATABLE` varchar(3) NOT NULL default '',
 
48
  `DEFINER` varchar(77) NOT NULL default '',
 
49
  `SECURITY_TYPE` varchar(7) NOT NULL default ''
 
50
) ENGINE=MyISAM DEFAULT CHARSET=utf8
 
51
SHOW COLUMNS FROM information_schema.VIEWS;
 
52
Field   Type    Null    Key     Default Extra
 
53
TABLE_CATALOG   varchar(512)    YES             NULL    
 
54
TABLE_SCHEMA    varchar(64)     NO                      
 
55
TABLE_NAME      varchar(64)     NO                      
 
56
VIEW_DEFINITION longtext        NO              NULL    
 
57
CHECK_OPTION    varchar(8)      NO                      
 
58
IS_UPDATABLE    varchar(3)      NO                      
 
59
DEFINER varchar(77)     NO                      
 
60
SECURITY_TYPE   varchar(7)      NO                      
 
61
SELECT table_catalog, table_schema, table_name
 
62
FROM information_schema.views WHERE table_catalog IS NOT NULL;
 
63
table_catalog   table_schema    table_name
 
64
################################################################################
 
65
# Testcase 3.2.13.2 + 3.2.13.3: INFORMATION_SCHEMA.VIEWS accessible information
 
66
################################################################################
 
67
DROP DATABASE IF EXISTS db_datadict;
 
68
CREATE DATABASE db_datadict;
 
69
DROP   USER 'testuser1'@'localhost';
 
70
CREATE USER 'testuser1'@'localhost';
 
71
DROP   USER 'testuser2'@'localhost';
 
72
CREATE USER 'testuser2'@'localhost';
 
73
DROP   USER 'test_no_views'@'localhost';
 
74
CREATE USER 'test_no_views'@'localhost';
 
75
CREATE TABLE db_datadict.t1(f1 INT, f2 INT, f3 INT)
 
76
ENGINE = <engine_type>;
 
77
CREATE VIEW db_datadict.v_granted_to_1 AS SELECT * FROM db_datadict.t1;
 
78
CREATE VIEW db_datadict.v_granted_glob AS SELECT f2, f3 FROM db_datadict.t1;
 
79
GRANT SELECT ON db_datadict.t1 TO 'testuser1'@'localhost';
 
80
GRANT SELECT ON db_datadict.v_granted_to_1 TO 'testuser1'@'localhost';
 
81
GRANT SHOW VIEW, CREATE VIEW ON db_datadict.* TO 'testuser2'@'localhost';
 
82
SELECT * FROM information_schema.views
 
83
WHERE table_schema = 'db_datadict' ORDER BY table_name;
 
84
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
85
NULL    db_datadict     v_granted_glob  /* ALGORITHM=UNDEFINED */ select `db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1`        NONE    YES     root@localhost  DEFINER
 
86
NULL    db_datadict     v_granted_to_1  /* ALGORITHM=UNDEFINED */ select `db_datadict`.`t1`.`f1` AS `f1`,`db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1`        NONE    YES     root@localhost  DEFINER
 
87
# Establish connection testuser1 (user=testuser1)
 
88
SELECT * FROM information_schema.views
 
89
WHERE table_schema = 'db_datadict' ORDER BY table_name;
 
90
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
91
NULL    db_datadict     v_granted_glob          NONE    YES     root@localhost  DEFINER
 
92
NULL    db_datadict     v_granted_to_1          NONE    YES     root@localhost  DEFINER
 
93
# Establish connection testuser2 (user=testuser2)
 
94
SELECT * FROM information_schema.views
 
95
WHERE table_schema = 'db_datadict' ORDER BY table_name;
 
96
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
97
NULL    db_datadict     v_granted_glob          NONE    YES     root@localhost  DEFINER
 
98
NULL    db_datadict     v_granted_to_1          NONE    YES     root@localhost  DEFINER
 
99
# Establish connection test_no_views (user=test_no_views)
 
100
SELECT * FROM information_schema.views
 
101
WHERE table_schema = 'db_datadict' ORDER BY table_name;
 
102
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
103
NULL    db_datadict     v_granted_glob          NONE    YES     root@localhost  DEFINER
 
104
NULL    db_datadict     v_granted_to_1          NONE    YES     root@localhost  DEFINER
 
105
# Switch to connection default and close all other connections
 
106
DROP USER 'testuser1'@'localhost';
 
107
DROP USER 'testuser2'@'localhost';
 
108
DROP USER 'test_no_views'@'localhost';
 
109
DROP DATABASE db_datadict;
 
110
#########################################################################
 
111
# 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.VIEWS modifications
 
112
#########################################################################
 
113
DROP TABLE IF EXISTS test.t1_my_table;
 
114
DROP DATABASE IF EXISTS db_datadict;
 
115
CREATE DATABASE db_datadict;
 
116
CREATE TABLE test.t1_table (f1 BIGINT, f2 CHAR(10))
 
117
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
 
118
ENGINE = <engine_type>;
 
119
DROP   USER 'testuser1'@'localhost';
 
120
CREATE USER 'testuser1'@'localhost';
 
121
SELECT * FROM information_schema.views
 
122
WHERE table_name LIKE 't1_%';
 
123
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
124
CREATE VIEW test.t1_view AS SELECT DISTINCT f1 FROM test.t1_table;
 
125
SELECT * FROM information_schema.views
 
126
WHERE table_name LIKE 't1_%';
 
127
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      VIEW_DEFINITION CHECK_OPTION    IS_UPDATABLE    DEFINER SECURITY_TYPE
 
128
NULL    test    t1_view /* ALGORITHM=UNDEFINED */ select distinct `test`.`t1_table`.`f1` AS `f1` from `test`.`t1_table` NONE    NO      root@localhost  DEFINER
 
129
SELECT table_name,definer FROM information_schema.views
 
130
WHERE table_name = 't1_view';
 
131
table_name      definer
 
132
t1_view root@localhost
 
133
ALTER DEFINER = 'testuser1'@'localhost' VIEW test.t1_view AS
 
134
SELECT DISTINCT f1 FROM test.t1_table;
 
135
SELECT table_name,definer,security_type FROM information_schema.views
 
136
WHERE table_name LIKE 't1_%';
 
137
table_name      definer security_type
 
138
t1_view testuser1@localhost     DEFINER
 
139
ALTER DEFINER = 'root'@'localhost' SQL SECURITY INVOKER VIEW test.t1_view AS
 
140
SELECT f1 FROM test.t1_table WITH LOCAL CHECK OPTION;
 
141
SELECT table_name,definer,security_type FROM information_schema.views
 
142
WHERE table_name LIKE 't1_%';
 
143
table_name      definer security_type
 
144
t1_view root@localhost  INVOKER
 
145
SELECT table_schema,table_name FROM information_schema.views
 
146
WHERE table_name LIKE 't1_%'
 
147
ORDER BY table_schema,table_name;
 
148
table_schema    table_name
 
149
test    t1_view
 
150
RENAME TABLE test.t1_view TO db_datadict.t1_view;
 
151
ERROR HY000: Changing schema from 'test' to 'db_datadict' is not allowed.
 
152
DROP VIEW test.t1_view;
 
153
CREATE VIEW db_datadict.t1_view AS SELECT * FROM test.t1_table;
 
154
SELECT table_schema,table_name FROM information_schema.views
 
155
WHERE table_name LIKE 't1_%'
 
156
ORDER BY table_schema,table_name;
 
157
table_schema    table_name
 
158
db_datadict     t1_view
 
159
SELECT table_name FROM information_schema.views
 
160
WHERE table_name LIKE 't1_%'
 
161
ORDER BY table_name;
 
162
table_name
 
163
t1_view
 
164
RENAME TABLE db_datadict.t1_view TO db_datadict.t1_viewx;
 
165
SELECT table_name FROM information_schema.views
 
166
WHERE table_name LIKE 't1_%'
 
167
ORDER BY table_name;
 
168
table_name
 
169
t1_viewx
 
170
SELECT table_name FROM information_schema.views
 
171
WHERE table_name LIKE 't1_%'
 
172
ORDER BY table_name;
 
173
table_name
 
174
t1_viewx
 
175
DROP VIEW db_datadict.t1_viewx;
 
176
SELECT table_name FROM information_schema.views
 
177
WHERE table_name LIKE 't1_%'
 
178
ORDER BY table_name;
 
179
table_name
 
180
CREATE VIEW db_datadict.t1_view AS SELECT * FROM test.t1_table;
 
181
SELECT table_name FROM information_schema.views
 
182
WHERE table_name LIKE 't1_%'
 
183
ORDER BY table_name;
 
184
table_name
 
185
t1_view
 
186
DROP TABLE test.t1_table;
 
187
SELECT table_name FROM information_schema.views
 
188
WHERE table_name LIKE 't1_%'
 
189
ORDER BY table_name;
 
190
table_name
 
191
t1_view
 
192
Warnings:
 
193
Warning 1356    View 'db_datadict.t1_view' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
 
194
CREATE TABLE test.t1_table (f1 BIGINT, f2 CHAR(10))
 
195
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci COMMENT = 'Initial Comment'
 
196
ENGINE = <engine_type>;
 
197
SELECT table_name FROM information_schema.views
 
198
WHERE table_name LIKE 't1_%'
 
199
ORDER BY table_name;
 
200
table_name
 
201
t1_view
 
202
DROP DATABASE db_datadict;
 
203
SELECT table_name FROM information_schema.views
 
204
WHERE table_name LIKE 't1_%'
 
205
ORDER BY table_name;
 
206
table_name
 
207
DROP USER 'testuser1'@'localhost';
 
208
DROP TABLE test.t1_table;
 
209
########################################################################
 
210
# Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
 
211
#           DDL on INFORMATION_SCHEMA table are not supported
 
212
########################################################################
 
213
DROP DATABASE IF EXISTS db_datadict;
 
214
CREATE DATABASE db_datadict;
 
215
CREATE VIEW db_datadict.v1 AS SELECT 1;
 
216
INSERT INTO information_schema.views
 
217
SELECT * FROM information_schema.views;
 
218
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
219
INSERT INTO information_schema.views(table_schema, table_name)
 
220
VALUES ('db2', 'v2');
 
221
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
222
UPDATE information_schema.views SET table_schema = 'test'
 
223
WHERE table_name = 't1';
 
224
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
225
DELETE FROM information_schema.views WHERE table_name = 't1';
 
226
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
227
TRUNCATE information_schema.views;
 
228
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
229
CREATE INDEX my_idx_on_views ON information_schema.views(table_schema);
 
230
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
231
ALTER TABLE information_schema.views DROP PRIMARY KEY;
 
232
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
233
ALTER TABLE information_schema.views ADD f1 INT;
 
234
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
235
DROP TABLE information_schema.views;
 
236
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
237
ALTER TABLE information_schema.views RENAME db_datadict.views;
 
238
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
239
ALTER TABLE information_schema.views RENAME information_schema.xviews;
 
240
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
 
241
DROP DATABASE db_datadict;