~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/datadict/datadict_master.inc

  • Committer: Bazaar Package Importer
  • Author(s): sean finney
  • Date: 2007-05-13 12:32:45 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20070513123245-8c3l187dk34cz2ar
Tags: 5.0.41-2
the previous "translation changes" inadvertently introduced unrelated
changes in the package control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#### suite/funcs_1/datadict/datadict_master.inc
 
2
#
 
3
--disable_abort_on_error
 
4
let $message=
 
5
.
 
6
. It is intended that the 3 <engine>__datadict.test files are named this way to be
 
7
. sure they are - in a *full run* of the suite - the first tests done for each
 
8
. storage engine. Using two _ and the order of processing in mysql-test-run.pl
 
9
. ensures this in an easy way.
 
10
.
 
11
. If needed a restart could be implemented later between the storage engines if
 
12
. values changes in the result depending from the position where the
 
13
. *__datadict.test are started. This can be a result of showing e.g. maximum
 
14
. values of the number of rows of tables.
 
15
.
 
16
. This .result file has been checked OK with Linux 5.0.23-bk,
 
17
. ChangeSet@1.2211, 2006-06-28 10:11:43-07:00.
 
18
.;
 
19
--source include/show_msg80.inc
 
20
 
 
21
################################################################################
 
22
#
 
23
   let $message= FIXME: There are subtests that are switched off due to known bugs:;
 
24
   --source include/show_msg.inc
 
25
   #set variable(s) here to be able to switch crashing sub tests with ONE change HERE.
 
26
   #change the variable(s) to enable / disable the crashing parts.
 
27
 
 
28
   # different 'logics' are used because sometimes codelines needs to be switched off
 
29
   # and otherwise some extra statements needs to be executed as long as the bug is not
 
30
   # fixed:
 
31
   let $have_bug_11589= 1;
 
32
 
 
33
   #seems not to work: --vertical_results
 
34
   eval SELECT $have_bug_11589 AS "have_bug_11589";
 
35
   #seems not to work: --horizontal_results
 
36
 
 
37
   # As long as
 
38
   # Bug#11589: mysqltest, --ps-protocol, strange output, float/double/real with zerofill
 
39
   # is not fixed, we must switch the ps-protocol for some statements off.
 
40
   # If this bug is fixed, please
 
41
   # 1. set the following variable to 0
 
42
   # 2. check, if the test passes
 
43
   # 3. remove the workarounds
 
44
   if ($have_bug_11589)
 
45
   {
 
46
      let $message= There are some statements where the ps-protocol is switched off.
 
47
                    This may come from the bug listed below, ir from other problems.
 
48
                    Bug#11589: mysqltest, --ps-protocol, strange output, float/double/real with zerofill;
 
49
      --source include/show_msg80.inc
 
50
   }
 
51
#
 
52
################################################################################
 
53
 
 
54
 
 
55
# loading the tables (data is not really needed in this test) is separated to
 
56
# make it easier in this file to show the message above.
 
57
--source suite/funcs_1/datadict/datadict_load.inc
 
58
 
 
59
#FIXME:  -  check for remaining change of object names to standards: db_, tb_, v_, u_, ...
 
60
#FIXME:  -  check warnings when data is loaded (Data truncated for column ...)
 
61
#FIXME:  -  change connect() to use less users / connections
 
62
#
 
63
#FIXME:  -  check for additional 'FIXME' here in the script
 
64
 
 
65
use information_schema;
 
66
--source suite/funcs_1/include/show_connection.inc
 
67
 
 
68
 
 
69
################################################################################
 
70
#
 
71
#  Data Dictionary
 
72
#
 
73
################################################################################
 
74
 
 
75
let $message= Testcase 3.2.1.1:;
 
76
--source include/show_msg80.inc
 
77
 
 
78
################################################################################
 
79
# Testcase 3.2.1.1: Ensure that every INFORMATION_SCHEMA table can be queried
 
80
#                   with a SELECT statement, just as if it were an ordinary
 
81
#                   user-defined table.
 
82
################################################################################
 
83
 
 
84
# create at least one object for all 'tables' to be checked
 
85
--disable_warnings
 
86
DROP DATABASE IF EXISTS db_datadict;
 
87
--enable_warnings
 
88
CREATE DATABASE db_datadict;
 
89
USE db_datadict;
 
90
 
 
91
CREATE VIEW v1 AS SELECT * FROM information_schema.tables;
 
92
 
 
93
# try to get the server's name to be able to clean-up the result from machine
 
94
#  specific stuff.
 
95
CREATE OR REPLACE VIEW db_datadict.vu1 as
 
96
SELECT grantee AS u
 
97
  FROM information_schema.user_privileges;
 
98
CREATE OR REPLACE VIEW db_datadict.vu as
 
99
SELECT DISTINCT u,
 
100
  SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,_utf8'@',1))+3 )
 
101
    AS server,
 
102
  SUBSTRING( u, LENGTH(SUBSTRING_INDEX(u,_utf8'@',1))+3,
 
103
    LENGTH( SUBSTRING( u,
 
104
    LENGTH( SUBSTRING_INDEX(u, _utf8'@',1)) +3 )) - 1 )
 
105
    AS Server_Clean
 
106
FROM db_datadict.vu1;
 
107
--replace_result $SERVER_NAME <SERVER_NAME>
 
108
SELECT * FROM db_datadict.vu;
 
109
 
 
110
delimiter //;
 
111
CREATE PROCEDURE db_datadict.sp_1()
 
112
  BEGIN
 
113
    SELECT * FROM db_datadict.v1;
 
114
  END//
 
115
delimiter ;//
 
116
 
 
117
#FIXME 3.2.1.1: add missing objects of each type to have something to select
 
118
#FIXME 3.2.1.1: - FUNCTION
 
119
#FIXME 3.2.1.1: - TRIGGER
 
120
 
 
121
USE information_schema;
 
122
SHOW tables;
 
123
 
 
124
select * from schemata ORDER BY 2 DESC, 1 ASC;
 
125
 
 
126
if ($have_bug_11589)
 
127
{
 
128
--disable_ps_protocol
 
129
}
 
130
--vertical_results
 
131
#SELECT * FROM tables;
 
132
#
 
133
#FIXME 3.2.1.1: we split the "SELECT * FROM tables" in two parts until
 
134
#FIXME 3.2.1.1: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
135
#FIXME 3.2.1.1: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
136
#FIXME 3.2.1.1: with 'less' replace
 
137
#  9 AVG_ROW_LENGTH
 
138
# 10 DATA_LENGTH
 
139
# 11 MAX_DATA_LENGTH
 
140
# 12 INDEX_LENGTH
 
141
# 13 DATA_FREE
 
142
# 15 CREATE_TIME
 
143
# 16 UPDATE_TIME
 
144
# 20 CREATE_OPTIONS
 
145
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
146
SELECT * FROM tables
 
147
 WHERE table_schema = 'information_schema';
 
148
#  9 AVG_ROW_LENGTH
 
149
# 10 DATA_LENGTH
 
150
# 11 MAX_DATA_LENGTH
 
151
# 12 INDEX_LENGTH
 
152
# 13 DATA_FREE
 
153
# 15 CREATE_TIME
 
154
# 16 UPDATE_TIME
 
155
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
156
SELECT * FROM tables
 
157
 WHERE NOT( table_schema = 'information_schema');
 
158
--horizontal_results
 
159
--enable_ps_protocol
 
160
 
 
161
select s.catalog_name, s.schema_name, s.default_character_set_name,
 
162
       t.table_type, t.engine
 
163
  from schemata s inner join tables t
 
164
 ORDER BY s.schema_name, s.default_character_set_name, table_type, engine;
 
165
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
166
select * from columns;
 
167
select * from character_sets;
 
168
select sum(id) from collations;
 
169
select collation_name, character_set_name into @x,@y
 
170
  from collation_character_set_applicability limit 1;
 
171
  select @x, @y;
 
172
 
 
173
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
174
select * from routines;
 
175
 
 
176
select count(*) from routines;
 
177
select * from statistics;
 
178
select * from views;
 
179
--replace_result $SERVER_NAME <SERVER_NAME>
 
180
select * from user_privileges;
 
181
select * from schema_privileges;
 
182
select * from table_privileges;
 
183
select * from column_privileges;
 
184
select * from table_constraints;
 
185
select * from key_column_usage;
 
186
select count(*) as max_recs from key_column_usage;
 
187
 
 
188
select max(cardinality) from statistics;
 
189
 
 
190
select concat("View '",
 
191
       table_name, "' is associated with the database '", table_schema, "'.")
 
192
       AS "Who is Who for the Views"
 
193
  from views;
 
194
 
 
195
select concat("Table or view '", table_name,
 
196
              "' is associated with the database '", table_schema, "'.") as "Who is Who"
 
197
  from tables;
 
198
 
 
199
--replace_result $SERVER_NAME <SERVER_NAME>
 
200
select grantee as "user's having select privilege",
 
201
       substring( grantee, length(SUBSTRING_INDEX(grantee,_utf8'@',1))+2 )
 
202
  from user_privileges where privilege_type = 'select';
 
203
 
 
204
select all table_schema from schema_privileges limit 0,5;
 
205
 
 
206
select distinct(privilege_type) from table_privileges;
 
207
 
 
208
select * from column_privileges
 
209
 group by table_schema having table_schema = 'db_datadict';
 
210
 
 
211
select * from table_constraints limit 0,5;
 
212
select count(*) as max_recs from key_column_usage limit 0,5;
 
213
 
 
214
select information_schema.tables.table_name as "table name",
 
215
       count(distinct(column_name)) as "no of columns in the table"
 
216
  from information_schema.tables left outer join information_schema.columns on
 
217
    information_schema.tables.table_name = information_schema.columns.table_name
 
218
 group by information_schema.tables.table_name;
 
219
 
 
220
# Reference Manual 22.1.16 - we will add more ...:
 
221
# select * from parameters;
 
222
# select * from referential_constraints;
 
223
# select * from triggers;
 
224
 
 
225
let $message= root: simple select to check all - and never forget some - tables;
 
226
let $dd_part1= SELECT * FROM;
 
227
let $dd_part2= LIMIT 1;
 
228
--source suite/funcs_1/datadict/datadict_tables.inc
 
229
 
 
230
# check again, but from different database (will fail due to missing database name)
 
231
use db_datadict;
 
232
 
 
233
--error 1146
 
234
select * from schemata;
 
235
--error 1146
 
236
select * from tables;
 
237
--error 1146
 
238
select s.catalog_name, s.schema_name, s.default_character_set_name,
 
239
       t.table_type, t.engine
 
240
  from schemata s inner join tables t
 
241
 ORDER BY s.catalog_name, s.schema_name, s.default_character_set_name;
 
242
--error 1146
 
243
select * from columns limit 0, 5;
 
244
--error 1146
 
245
select * from character_sets limit 0, 5;
 
246
--error 1146
 
247
select * from collations limit 0, 5;
 
248
--error 1146
 
249
select * from collation_character_set_applicability limit 0, 5;
 
250
--error 1146
 
251
select * from routines limit 0, 5;
 
252
--error 1146
 
253
select * from statistics limit 0, 5;
 
254
--error 1146
 
255
select * from views limit 0, 5;
 
256
--error 1146
 
257
select * from user_privileges limit 0, 5;
 
258
--error 1146
 
259
select * from schema_privileges limit 0, 5;
 
260
--error 1146
 
261
select * from table_privileges limit 0, 5;
 
262
--error 1146
 
263
select * from column_privileges limit 0, 5;
 
264
--error 1146
 
265
select * from table_constraints limit 0, 5;
 
266
--error 1146
 
267
select * from key_column_usage limit 0, 5;
 
268
# Reference Manual 22.1.16 - we will add more ...:
 
269
# --error 1146
 
270
# select * from parameters;
 
271
# --error 1146
 
272
# select * from referential_constraints;
 
273
# --error 1146
 
274
# select * from triggers;
 
275
let $message= will fail due to missing database name;
 
276
let $dd_part1= SELECT * FROM;
 
277
let $dd_part2=;
 
278
--source suite/funcs_1/datadict/datadict_tables_error_1146.inc
 
279
 
 
280
# now check from "other" database, but with database name
 
281
select * from information_schema.schemata ORDER BY 2 DESC;
 
282
 
 
283
#SELECT * FROM information_schema.tables;
 
284
#
 
285
#FIXME 3.2.1.1: we split the "SELECT * FROM tables" in two parts until
 
286
#FIXME 3.2.1.1: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
287
#FIXME 3.2.1.1: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
288
#FIXME 3.2.1.1: with 'less' replace
 
289
#  9 AVG_ROW_LENGTH
 
290
# 10 DATA_LENGTH
 
291
# 11 MAX_DATA_LENGTH
 
292
# 12 INDEX_LENGTH
 
293
# 13 DATA_FREE
 
294
# 15 CREATE_TIME
 
295
# 16 UPDATE_TIME
 
296
# 20 CREATE_OPTIONS
 
297
if ($have_bug_11589)
 
298
{
 
299
--disable_ps_protocol
 
300
}
 
301
--vertical_results
 
302
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
303
SELECT * FROM information_schema.tables
 
304
 WHERE table_schema = 'information_schema';
 
305
#  9 AVG_ROW_LENGTH
 
306
# 10 DATA_LENGTH
 
307
# 11 MAX_DATA_LENGTH
 
308
# 12 INDEX_LENGTH
 
309
# 13 DATA_FREE
 
310
# 15 CREATE_TIME
 
311
# 16 UPDATE_TIME
 
312
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
313
SELECT * FROM information_schema.tables
 
314
 WHERE NOT( table_schema = 'information_schema');
 
315
--horizontal_results
 
316
--enable_ps_protocol
 
317
 
 
318
select s.catalog_name, s.schema_name, s.default_character_set_name,
 
319
       t.table_type, t.engine
 
320
  from information_schema.schemata s inner join information_schema.tables t
 
321
 ORDER BY s.schema_name, s.default_character_set_name, table_type, engine;
 
322
 
 
323
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
324
select * from information_schema.columns limit 0, 5;
 
325
select * from information_schema.character_sets limit 0, 5;
 
326
select * from information_schema.collations limit 0, 5;
 
327
select * from information_schema.collation_character_set_applicability limit 0, 5;
 
328
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
329
select * from information_schema.routines limit 0, 5;
 
330
select * from information_schema.statistics limit 0, 5;
 
331
select * from information_schema.views limit 0, 5;
 
332
--replace_result $SERVER_NAME <SERVER_NAME>
 
333
select * from information_schema.user_privileges limit 0, 5;
 
334
select * from information_schema.schema_privileges limit 0, 5;
 
335
select * from information_schema.table_privileges limit 0, 5;
 
336
select * from information_schema.column_privileges limit 0, 5;
 
337
select * from information_schema.table_constraints limit 0, 5;
 
338
select * from information_schema.key_column_usage limit 0, 5;
 
339
select count(*) as max_recs from information_schema.key_column_usage limit 0, 5;
 
340
 
 
341
# Reference Manual 22.1.16 - we will add more ...:
 
342
# select * from information_schema.parameters;
 
343
# select * from information_schema.referential_constraints;
 
344
# select * from information_schema.triggers;
 
345
 
 
346
let $message= root: check with db name;
 
347
let $dd_part1= SELECT COUNT(*) FROM information_schema.;
 
348
let $dd_part2=;
 
349
--source suite/funcs_1/datadict/datadict_tables.inc
 
350
 
 
351
# cleanup
 
352
USE db_datadict;
 
353
DROP VIEW v1, vu1, vu;
 
354
DROP PROCEDURE db_datadict.sp_1;
 
355
USE information_schema;
 
356
# ------------------------------------------------------------------------------
 
357
 
 
358
let $message= Testcase 3.2.1.2:;
 
359
--source include/show_msg80.inc
 
360
 
 
361
################################################################################
 
362
# Testcase 3.2.1.2: Ensure that queries on an INFORMATION_SCHEMA table can
 
363
#                   accept all SELECT statement options and are always
 
364
#                   correctly evaluated.
 
365
################################################################################
 
366
 
 
367
# currently here only a subset of select statement options is checked, it's still
 
368
# not possible to check here all possible options
 
369
select catalog_name, schema_name, default_character_set_name
 
370
  from schemata where schema_name like '%s%';
 
371
 
 
372
select count(*) as tot_tabs from tables;
 
373
select count(*) as the_cols from columns;
 
374
 
 
375
select max(maxlen) as the_max from character_sets;
 
376
select * from collations order by id asc  limit 0, 5;
 
377
select * from collation_character_set_applicability
 
378
 order by character_set_name desc, collation_name limit 0, 5;
 
379
 
 
380
select routine_definition from routines;
 
381
select * from statistics group by index_name asc  limit 0, 5;
 
382
select concat(table_schema, ', ', table_name, ', ', view_definition) view_info
 
383
  from views;
 
384
select concat(table_schema, ', ', table_name) "Table_info"
 
385
  from tables ORDER BY 1;
 
386
 
 
387
--replace_result $SERVER_NAME <SERVER_NAME>
 
388
select distinct grantee from user_privileges;
 
389
select * from schema_privileges where table_catalog is null limit 0, 5;
 
390
select * from table_privileges where grantee like '%r%'  limit 0, 5;
 
391
 
 
392
select * from column_privileges where table_catalog is not null limit 0, 5;
 
393
select HIGH_PRIORITY * from table_constraints
 
394
 group by constraint_name desc  limit 0, 5;
 
395
select sum(ordinal_position) from key_column_usage;
 
396
 
 
397
select * from schemata limit 0,5;
 
398
select * from schemata  limit 0,5;
 
399
--replace_result $SERVER_NAME <SERVER_NAME>
 
400
select distinct grantee from user_privileges;
 
401
--replace_result $SERVER_NAME <SERVER_NAME>
 
402
select all      grantee from user_privileges;
 
403
 
 
404
select id , character_set_name from collations order by id asc limit 10;
 
405
 
 
406
select table_catalog from columns
 
407
 union all
 
408
select table_catalog from tables limit 0,5;
 
409
select table_catalog from columns
 
410
 union
 
411
select table_catalog from tables limit 0,5;
 
412
 
 
413
select all schema_name from information_schema.schemata;
 
414
 
 
415
# the $ENGINE_TYPE variable is used here ONLY to have 3 different file names in
 
416
# the three datadict testcases innodb_*, memory_* and myisam_*
 
417
eval SELECT *
 
418
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.file'
 
419
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
420
  LINES TERMINATED BY '\n'
 
421
  FROM schemata LIMIT 0, 5;
 
422
 
 
423
USE test;
 
424
 
 
425
eval SELECT *
 
426
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.db.file'
 
427
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
428
  LINES TERMINATED BY '\n'
 
429
  FROM information_schema.schemata
 
430
  WHERE schema_name LIKE 'db_%';
 
431
 
 
432
# check also with a 'simple' user
 
433
CREATE USER user_3212@localhost;
 
434
GRANT ALL ON db_datadict.* TO user_3212@localhost;
 
435
 
 
436
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
437
connect (u3212,localhost,user_3212,,db_datadict);
 
438
--source suite/funcs_1/include/show_connection.inc
 
439
 
 
440
# no db given --> db_datadict.schema does not exist
 
441
--error 1045
 
442
eval SELECT *
 
443
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user.file'
 
444
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
445
  LINES TERMINATED BY '\n'
 
446
  FROM schemata LIMIT 0, 5;
 
447
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
 
448
--error 1146
 
449
eval SELECT *
 
450
  FROM schemata LIMIT 0, 5;
 
451
 
 
452
eval SELECT *
 
453
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user.db.file'
 
454
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
455
  LINES TERMINATED BY '\n'
 
456
  FROM information_schema.schemata
 
457
  WHERE schema_name LIKE 'db_%';
 
458
# FIXME: why do we get different error numbers with and without OUTFILE ?
 
459
#FIXME this should fail! --error 1146
 
460
eval SELECT *
 
461
  FROM information_schema.schemata
 
462
  WHERE schema_name LIKE 'db_%';
 
463
 
 
464
USE information_schema;
 
465
 
 
466
# no db given --> db_datadict.schema does not exist
 
467
eval SELECT *
 
468
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user_2.file'
 
469
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
470
  LINES TERMINATED BY '\n'
 
471
  FROM schemata LIMIT 0, 5;
 
472
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
 
473
eval SELECT *
 
474
  FROM schemata LIMIT 0, 5;
 
475
 
 
476
eval SELECT *
 
477
  INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user_2.db.file'
 
478
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
479
  LINES TERMINATED BY '\n'
 
480
  FROM information_schema.schemata
 
481
  WHERE schema_name LIKE 'db_%';
 
482
# FIXME: why do we get different error numbers with and without OUTFILE ?
 
483
#FIXME this should fail! --error 1146
 
484
eval SELECT *
 
485
  FROM information_schema.schemata
 
486
  WHERE schema_name LIKE 'db_%';
 
487
 
 
488
disconnect u3212;
 
489
connection default;
 
490
USE information_schema;
 
491
--source suite/funcs_1/include/show_connection.inc
 
492
 
 
493
use db_datadict;
 
494
select table_catalog "1", table_schema "2", table_name "3", column_name "4"
 
495
  from information_schema.columns
 
496
union
 
497
select table_catalog, table_schema, table_name,
 
498
       concat( "*** type = ", table_type )
 
499
  from information_schema.tables
 
500
 order by 3, 4 desc, 1, 2 limit 30;
 
501
 
 
502
use information_schema;
 
503
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
504
select table_catalog "1", table_schema "2", table_name "3", column_name "4"
 
505
  from columns
 
506
union
 
507
select table_catalog, table_schema, table_name,
 
508
       concat( "*** type = ", table_type )
 
509
  from tables
 
510
 order by 3, 4 desc, 1, 2 limit 30;
 
511
 
 
512
# cleanup
 
513
DROP USER user_3212@localhost;
 
514
 
 
515
# ------------------------------------------------------------------------------
 
516
 
 
517
let $message= Testcase 3.2.1.3:;
 
518
--source include/show_msg80.inc
 
519
 
 
520
################################################################################
 
521
# Testcase 3.2.1.3:  Ensure that no user may execute an INSERT statement on any
 
522
#                    INFORMATION_SCHEMA table.
 
523
################################################################################
 
524
 
 
525
#FIXME: in this block we had --error 1288 until Mid Sep05, check the change!
 
526
--error 1044
 
527
insert into schemata (catalog_name, schema_name, default_character_set_name, sql_path)
 
528
  values ('null', 'db1', 'latin1', 'null');
 
529
--error 1044
 
530
insert into tables (table_schema, table_name)values('db_datadict', 't1');
 
531
--error 1044
 
532
insert into columns (table_name, column_name)values('t3', 'f2');
 
533
--error 1044
 
534
insert into character_sets (character_set_name, default_collate_name, description, maxlen)
 
535
  values('cp1251', 'cp1251_general_ci', 'windows  cyrillic', 1);
 
536
--error 1044
 
537
insert into collations ( collation_name, character_set_name, id, is_default, is_compiled, sortlen)
 
538
  values ('cp1251_bin', 'cp1251', 50, '', '', 0);
 
539
--error 1044
 
540
insert into collation_character_set_applicability (collation_name, character_set_name)
 
541
  values (' big5_chinese_ci', 'big6');
 
542
--error 1044
 
543
insert into routines(routine_name, routine_type ) values ('p2', 'procedure');
 
544
--error 1044
 
545
insert into statistics(table_schema, table_name, index_name)
 
546
  values ('mysql', 'db', 'primary');
 
547
--error 1044
 
548
insert into views(table_schema, table_name) values ('db2', 'v2');
 
549
--error 1044
 
550
insert into user_privileges (privilege_type, is_grantable) values ('select', 'yes');
 
551
--error 1044
 
552
insert into schema_privileges (table_schema, privilege_type) values('db2', 'insert');
 
553
--error 1044
 
554
insert into table_privileges (able_schema, table_name, privilege_type)
 
555
  values('db2', 'v2', 'insert');
 
556
--error 1044
 
557
insert into  column_privileges (table_name, column_name, privilege_type)
 
558
  values ('t3', 'f3', 'insert');
 
559
--error 1044
 
560
insert into table_constraints ( constraint_schema, constraint_name, table_schema)
 
561
  values ('primary', 'mysql', 'user');
 
562
--error 1044
 
563
insert into key_column_usage (constraint_schema, constraint_name, table_name)
 
564
  values ('mysql', 'primary', 'db');
 
565
 
 
566
# insert through a procedure
 
567
--disable_warnings
 
568
drop procedure if exists db_datadict.sp_4_1_3;
 
569
--enable_warnings
 
570
 
 
571
delimiter //;
 
572
create procedure db_datadict.sp_4_1_3()
 
573
begin
 
574
   insert into information_schema.schema_privileges (table_schema,privilege_type)
 
575
      values('db2','insert');
 
576
end//
 
577
delimiter ;//
 
578
 
 
579
#FIXME: check for the diffs Win ./. Linux
 
580
SELECT table_schema, privilege_type FROM information_schema.schema_privileges
 
581
 WHERE table_schema LIKE 'db%';
 
582
 
 
583
--error 1044
 
584
call db_datadict.sp_4_1_3();
 
585
 
 
586
#FIXME: check for the diffs Win ./. Linux
 
587
SELECT table_schema, privilege_type FROM information_schema.schema_privileges
 
588
 WHERE table_schema LIKE 'db%';
 
589
 
 
590
# cleanup
 
591
drop procedure db_datadict.sp_4_1_3;
 
592
 
 
593
# insert into information_schema as a limited user
 
594
 
 
595
CREATE USER user_4_1_3@localhost;
 
596
 
 
597
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
598
connect (u413,localhost,user_4_1_3,,test);
 
599
--source suite/funcs_1/include/show_connection.inc
 
600
 
 
601
use information_schema;
 
602
 
 
603
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05)
 
604
--error 1044
 
605
insert into table_constraints ( constraint_schema, constraint_name,  table_schema)
 
606
  values ('primary', 'mysql', 'user');
 
607
 
 
608
connection default;
 
609
--source suite/funcs_1/include/show_connection.inc
 
610
# ------------------------------------------------------------------------------
 
611
 
 
612
let $message= Testcase 3.2.1.4:;
 
613
--source include/show_msg80.inc
 
614
 
 
615
################################################################################
 
616
# Testcase 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
 
617
#                   INFORMATION_SCHEMA table.
 
618
################################################################################
 
619
 
 
620
use information_schema;
 
621
--source suite/funcs_1/include/show_connection.inc
 
622
 
 
623
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05) in the whole next block
 
624
--error 1044
 
625
update schemata set schema_name = 'db5' where default_character_set_name = 'latin1';
 
626
--error 1044
 
627
update tables set table_schema = 'db_datadict1' where table_name = 't1';
 
628
--error 1044
 
629
update columns set table_name = 't4' where column_name = 'f2';
 
630
--error 1044
 
631
update character_sets set character_set_name = 'cp1252' where maxlen = 1;
 
632
--error 1044
 
633
update collations set collation_name = 'cp1253_bin'
 
634
 where character_set_name = 'cp1251';
 
635
--error 1044
 
636
update collation_character_set_applicability set collation_name = 'big6_chinese_ci'
 
637
  where character_set_name = 'big6';
 
638
--error 1044
 
639
update routines set routine_name = p2 where routine_body = 'sql';
 
640
--error 1044
 
641
update statistics set table_schema = 'mysql1' where table_name = 'db';
 
642
--error 1044
 
643
update views set table_schema = 'db3' where table_name = 'v1';
 
644
--error 1044
 
645
update  user_privileges set privilege_type = 'insert' where is_grantable = 'yes';
 
646
--error 1044
 
647
update schema_privileges set table_schema = 'db2' where privilege_type = 'select';
 
648
--error 1044
 
649
update table_privileges set table_name = 'v3' where privilege_type = 'select';
 
650
--error 1044
 
651
update column_privileges set table_name = 't4' where column_name = 'f3';
 
652
--error 1044
 
653
update  table_constraints set constraint_schema = 'primary'
 
654
 where table_schema = 'proc';
 
655
--error 1044
 
656
update key_column_usage set  table_name = 'db1' where constraint_name = 'primary';
 
657
 
 
658
# update through a procedure
 
659
--disable_warnings
 
660
drop procedure if exists db_datadict.sp_4_1_4;
 
661
--enable_warnings
 
662
 
 
663
delimiter //;
 
664
create procedure db_datadict.sp_4_1_4()
 
665
begin
 
666
  update information_schema.routines set routine_name = 'p2'
 
667
   where routine_name = 'sp_4_1_4';
 
668
end//
 
669
delimiter ;//
 
670
 
 
671
#FIXME: check for the diffs Win ./. Linux
 
672
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
673
select * from information_schema.routines;
 
674
 
 
675
--error 1044
 
676
call db_datadict.sp_4_1_4();
 
677
 
 
678
#FIXME: check for the diffs Win ./. Linux
 
679
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
680
select * from information_schema.routines;
 
681
 
 
682
# cleanup
 
683
drop procedure db_datadict.sp_4_1_4;
 
684
 
 
685
# update information_schema as a limited user
 
686
 
 
687
connection u413;
 
688
 
 
689
use information_schema;
 
690
--source suite/funcs_1/include/show_connection.inc
 
691
 
 
692
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05)
 
693
--error 1044
 
694
update  user_privileges set privilege_type = 'insert' where is_grantable = 'yes';
 
695
 
 
696
connection default;
 
697
--source suite/funcs_1/include/show_connection.inc
 
698
#
 
699
# ------------------------------------------------------------------------------
 
700
 
 
701
let $message= Testcase 3.2.1.5:;
 
702
--source include/show_msg80.inc
 
703
 
 
704
################################################################################
 
705
# Testcase 3.2.1.5: Ensure that no user may execute a DELETE statement on any
 
706
#                   INFORMATION_SCHEMA table.
 
707
################################################################################
 
708
 
 
709
use information_schema;
 
710
 
 
711
let $message= root: DELETE FROM any table in IS;
 
712
let $dd_part1= DELETE FROM;
 
713
let $dd_part2=;
 
714
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
715
 
 
716
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05) in the whole next block
 
717
--error 1044
 
718
delete from schemata where schema_name = 'mysql';
 
719
--error 1044
 
720
delete from tables where table_name = 'abc';
 
721
--error 1044
 
722
delete from columns;
 
723
--error 1044
 
724
delete from character_sets;
 
725
--error 1044
 
726
delete from collations;
 
727
--error 1044
 
728
delete from collation_character_set_applicability;
 
729
--error 1044
 
730
delete from routines;
 
731
--error 1044
 
732
delete from statistics;
 
733
--error 1044
 
734
delete from views;
 
735
--error 1044
 
736
delete from user_privileges;
 
737
--error 1044
 
738
delete from schema_privileges;
 
739
--error 1044
 
740
delete from table_privileges;
 
741
--error 1044
 
742
delete from column_privileges;
 
743
--error 1044
 
744
delete from table_constraints;
 
745
--error 1044
 
746
delete from key_column_usage;
 
747
 
 
748
# delete through a procedure
 
749
--disable_warnings
 
750
drop procedure if exists db_datadict.sp_4_1_5;
 
751
--enable_warnings
 
752
 
 
753
delimiter //;
 
754
create procedure db_datadict.sp_4_1_5()
 
755
begin
 
756
  delete from information_schema.column_privileges;
 
757
end//
 
758
delimiter ;//
 
759
 
 
760
--error 1044
 
761
call db_datadict.sp_4_1_5();
 
762
 
 
763
# cleanup
 
764
drop procedure db_datadict.sp_4_1_5;
 
765
 
 
766
# delete from information_schema as a limited user
 
767
 
 
768
connection u413;
 
769
 
 
770
use information_schema;
 
771
--source suite/funcs_1/include/show_connection.inc
 
772
 
 
773
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05)
 
774
--error 1044
 
775
delete from tables where table_name = 'abc';
 
776
 
 
777
disconnect u413;
 
778
 
 
779
connection default;
 
780
--source suite/funcs_1/include/show_connection.inc
 
781
 
 
782
# cleanup
 
783
DROP USER user_4_1_3@localhost;
 
784
# ------------------------------------------------------------------------------
 
785
 
 
786
let $message= Testcase 3.2.1.6:;
 
787
--source include/show_msg80.inc
 
788
 
 
789
################################################################################
 
790
# Testcase 3.2.1.6: Ensure that no user may create an INFORMATION_SCHEMA base
 
791
#                   table.
 
792
################################################################################
 
793
 
 
794
use information_schema;
 
795
 
 
796
let $message= root: create a table with a name of an IS table directly in IS;
 
797
let $dd_part1= CREATE TABLE;
 
798
let $dd_part2= ( c1 INT );
 
799
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
800
#FIXME solved - 3.2.1.6: check for better error message - 42S02: Unknown table '<xxx>' in <db> ?
 
801
--error 1109
 
802
create table t1 (f1 int, f2 int, f3 int);
 
803
 
 
804
use db_datadict;
 
805
 
 
806
#FIXME: check correct error message - HY000 Can't create/write to file '.\information_schema\columns.frm' (Errcode: 2)
 
807
let $message= root: create a table with a name of an IS table from other db;
 
808
let $dd_part1= CREATE TABLE information_schema.;
 
809
let $dd_part2= ( c1 INT );
 
810
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
811
#FIXME solved - 3.2.1.6: check for better error message - 42S02: Unknown table '<xxx>' in <db> ?
 
812
--error 1109
 
813
create table information_schema.t1 (f1 int, f2 int, f3 int);
 
814
 
 
815
# create a table in information_schema as a limited user with sufficient permissions
 
816
CREATE USER user_4_1_6@localhost;
 
817
 
 
818
grant all on *.* to user_4_1_6@localhost;
 
819
 
 
820
FLUSH PRIVILEGES;
 
821
 
 
822
SHOW GRANTS FOR user_4_1_6@localhost;
 
823
 
 
824
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
825
connect (u2, localhost, user_4_1_6, , information_schema);
 
826
--source suite/funcs_1/include/show_connection.inc
 
827
 
 
828
use information_schema;
 
829
 
 
830
let $message= user: create a table with a name of an IS table directly in IS;
 
831
let $dd_part1= CREATE TABLE;
 
832
let $dd_part2= ( c1 INT );
 
833
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
834
#FIXME solved - 3.2.1.6: check for better error message - 42S02: Unknown table '<xxx>' in <db> ?
 
835
--error 1109
 
836
create table t1 (f1 int, f2 int, f3 int);
 
837
 
 
838
use test;
 
839
 
 
840
#FIXME 3.2.1.6: check correct error message - HY000 Can't create/write to file '.\information_schema\columns.frm' (Errcode: 2)
 
841
let $message= user: create a table with a name of an IS table from other db;
 
842
let $dd_part1= CREATE TABLE information_schema.;
 
843
let $dd_part2= ( c1 INT );
 
844
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
845
#FIXME solved - 3.2.1.6: check for better error message - 42S02: Unknown table '<xxx>' in <db> ?
 
846
--error 1109
 
847
create table information_schema.t1 (f1 int, f2 int, f3 int);
 
848
 
 
849
#cleanup
 
850
connection default;
 
851
--source suite/funcs_1/include/show_connection.inc
 
852
disconnect u2;
 
853
DROP USER user_4_1_6@localhost;
 
854
# ------------------------------------------------------------------------------
 
855
 
 
856
let $message= Testcase 3.2.1.7:;
 
857
--source include/show_msg80.inc
 
858
 
 
859
################################################################################
 
860
# Testcase 3.2.1.7: Ensure that no user may create an INFORMATION_SCHEMA view.
 
861
################################################################################
 
862
 
 
863
use information_schema;
 
864
 
 
865
let $message= root: create a view with a name of an IS table directly in IS;
 
866
let $dd_part1= CREATE VIEW ;
 
867
let $dd_part2= AS SELECT * FROM mysql.time_zone;
 
868
#FIXME: check change from error 1 to 1044
 
869
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
870
 
 
871
--error 1109
 
872
CREATE VIEW v1 AS SELECT * FROM information_schema.schemata;
 
873
 
 
874
USE db_datadict;
 
875
 
 
876
let $message= root: create a view with a name of an IS table from other db;
 
877
let $dd_part1= CREATE VIEW information_schema.;
 
878
let $dd_part2= AS SELECT * FROM mysql.time_zone;
 
879
#FIXME: check change from error 1 to 1044
 
880
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
881
 
 
882
# ... but creating a view that 'uses' the information_schema is allowed:
 
883
CREATE VIEW v1 AS SELECT * FROM information_schema.columns;
 
884
 
 
885
SELECT * FROM v1 LIMIT 5;
 
886
 
 
887
# create a view in information_schema as a limited user with sufficient permissions
 
888
CREATE USER user_4_1_7@localhost;
 
889
 
 
890
GRANT ALL ON db_datadict.*        TO user_4_1_7@localhost;
 
891
#FIXME: check that GRANT ON i_s is no longer allowed
 
892
--error 1044
 
893
GRANT ALL ON information_schema.* TO user_4_1_7@localhost;
 
894
 
 
895
FLUSH PRIVILEGES;
 
896
 
 
897
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
898
connect (u3, localhost, user_4_1_7, , db_datadict);
 
899
use information_schema;
 
900
--source suite/funcs_1/include/show_connection.inc
 
901
 
 
902
let $message= user: create a view with a name of an IS table directly in IS;
 
903
let $dd_part1= CREATE VIEW ;
 
904
let $dd_part2= AS SELECT * FROM db_datadict.v1;
 
905
#FIXME: check change from error 1 to 1044
 
906
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
907
--error 1109
 
908
create view v1 as select * from table_privileges;
 
909
 
 
910
use db_datadict;
 
911
 
 
912
let $message= user: create a view with a name of an IS table from other db;
 
913
let $dd_part1= CREATE VIEW information_schema.;
 
914
let $dd_part2= AS SELECT * FROM db_datadict.v1;
 
915
#FIXME: check change from error 1 to 1044
 
916
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
917
disconnect u3;
 
918
 
 
919
# cleanup
 
920
connection default;
 
921
--source suite/funcs_1/include/show_connection.inc
 
922
DROP USER user_4_1_7@localhost;
 
923
DROP VIEW db_datadict.v1;
 
924
# ------------------------------------------------------------------------------
 
925
 
 
926
let $message= Testcase 3.2.1.8:;
 
927
--source include/show_msg80.inc
 
928
 
 
929
################################################################################
 
930
# Testcase 3.2.1.8: Ensure that no user may create an index on an
 
931
#                   INFORMATION_SCHEMA table.
 
932
################################################################################
 
933
 
 
934
use information_schema;
 
935
 
 
936
#FIXME: check later the change from 1288 to 1044 (since Mid Sep05)
 
937
--error 1044
 
938
create index i1 on schemata(schema_name);
 
939
--error 1044
 
940
create index i2 on tables(table_schema);
 
941
--error 1044
 
942
create index i3 on columns(table_name);
 
943
 
 
944
--error 1044
 
945
create index i4 on character_sets(character_set_name);
 
946
--error 1044
 
947
create index i5 on collations( collation_name);
 
948
--error 1044
 
949
create index i6 on collation_character_set_applicability(collation_name);
 
950
 
 
951
--error 1044
 
952
create index i7 on routines(routine_name);
 
953
--error 1044
 
954
create index i8 on statistics(table_schema);
 
955
--error 1044
 
956
create index i9 on views(table_schema);
 
957
 
 
958
--error 1044
 
959
create index i10 on user_privileges(privilege_type);
 
960
--error 1044
 
961
create index i11 on schema_privileges(table_schema);
 
962
--error 1044
 
963
create index i12 on table_privileges(able_schema);
 
964
 
 
965
--error 1044
 
966
create index i13 on column_privileges(table_name);
 
967
--error 1044
 
968
create index i14 on table_constraints(constraint_schema);
 
969
--error 1044
 
970
create index i15 on key_column_usage(constraint_schema);
 
971
--error 1044
 
972
create index i16 on triggers(trigger_name);
 
973
 
 
974
use db_datadict;
 
975
--error 1044
 
976
create index i15 on information_schema.key_column_usage(constraint_schema);
 
977
 
 
978
use information_schema;
 
979
 
 
980
# create an index on an information_schema table as a limited user with sufficient permissions
 
981
CREATE USER user_4_1_8@localhost;
 
982
 
 
983
grant select, index on *.* to user_4_1_8@localhost;
 
984
 
 
985
FLUSH PRIVILEGES;
 
986
 
 
987
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
988
connect (u4, localhost, user_4_1_8, , test);
 
989
--source suite/funcs_1/include/show_connection.inc
 
990
 
 
991
use information_schema;
 
992
 
 
993
--error 1044
 
994
create index i1 on schemata(schema_name);
 
995
--error 1044
 
996
create index i2 on tables(table_schema);
 
997
--error 1044
 
998
create index i3 on columns(table_name);
 
999
 
 
1000
--error 1044
 
1001
create index i4 on character_sets(character_set_name);
 
1002
--error 1044
 
1003
create index i5 on collations( collation_name);
 
1004
--error 1044
 
1005
create index i6 on collation_character_set_applicability(collation_name);
 
1006
 
 
1007
--error 1044
 
1008
create index i7 on routines(routine_name);
 
1009
--error 1044
 
1010
create index i8 on statistics(table_schema);
 
1011
--error 1044
 
1012
create index i9 on views(table_schema);
 
1013
 
 
1014
--error 1044
 
1015
create index i10 on user_privileges(privilege_type);
 
1016
--error 1044
 
1017
create index i11 on schema_privileges(table_schema);
 
1018
--error 1044
 
1019
create index i12 on table_privileges(able_schema);
 
1020
 
 
1021
--error 1044
 
1022
create index i13 on column_privileges(table_name);
 
1023
--error 1044
 
1024
create index i14 on table_constraints(constraint_schema);
 
1025
--error 1044
 
1026
create index i15 on key_column_usage(constraint_schema);
 
1027
--error 1044
 
1028
create index i16 on triggers(trigger_name);
 
1029
 
 
1030
use db_datadict;
 
1031
--error 1044
 
1032
create index i15 on information_schema.key_column_usage(constraint_schema);
 
1033
 
 
1034
disconnect u4;
 
1035
 
 
1036
connection default;
 
1037
--source suite/funcs_1/include/show_connection.inc
 
1038
 
 
1039
# cleanup
 
1040
DROP USER user_4_1_8@localhost;
 
1041
# ------------------------------------------------------------------------------
 
1042
 
 
1043
let $message= Testcase 3.2.1.9:;
 
1044
--source include/show_msg80.inc
 
1045
 
 
1046
################################################################################
 
1047
# Testcase 3.2.1.9: Ensure that no user may alter the definition of an
 
1048
#                   INFORMATION_SCHEMA table.
 
1049
################################################################################
 
1050
 
 
1051
#FIXME: 3.2.1.9 check for better error message than ERROR 42S02: Table 'information_schema.schemata' doesn't exist
 
1052
 
 
1053
# first simple check all known - so we never forget one ...
 
1054
let $message= root: alter a table from other db;
 
1055
let $dd_part1= ALTER TABLE information_schema.;
 
1056
let $dd_part2= ADD f1 INT;
 
1057
#FIXME: check change from error 1146 to 1044
 
1058
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1059
use information_schema;
 
1060
let $message= root: alter a table from directly;
 
1061
let $dd_part1= ALTER TABLE ;
 
1062
let $dd_part2= ADD f1 INT;
 
1063
#FIXME: check change from error 1146 to 1044
 
1064
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1065
# now more detailed checks
 
1066
--error 1044
 
1067
alter table schemata add f1 int;
 
1068
--error 1044
 
1069
alter table tables drop primary key;
 
1070
--error 1044
 
1071
alter table columns add f1 int;
 
1072
--error 1044
 
1073
alter table character_sets disable keys;
 
1074
--error 1044
 
1075
alter table collations enable keys;
 
1076
--error 1044
 
1077
alter table collation_character_set_applicability add f1 int;
 
1078
--error 1044
 
1079
alter table routines discard tablespace;
 
1080
--error 1044
 
1081
alter table statistics import tablespace;
 
1082
--error 1044
 
1083
alter table views drop column table_name;
 
1084
--error 1044
 
1085
alter table user_privileges drop index privilege_type;
 
1086
--error 1044
 
1087
alter table schema_privileges drop column is_grantable;
 
1088
--error 1044
 
1089
alter table table_privileges order by constraint_type;
 
1090
--error 1044
 
1091
alter table column_privileges rename to aaxyz;
 
1092
--error 1044
 
1093
alter table table_constraints order by schema_name;
 
1094
--error 1044
 
1095
alter table key_column_usage rename to information_schema.aabxyz;
 
1096
--error 1044
 
1097
alter table triggers rename to information_schema.sql_mode;
 
1098
# Alter an information_schema table as a limited user with sufficient permissions
 
1099
 
 
1100
CREATE USER user_4_1_9@localhost;
 
1101
 
 
1102
grant select, alter, create, insert on *.* to user_4_1_9@localhost;
 
1103
 
 
1104
FLUSH PRIVILEGES;
 
1105
 
 
1106
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1107
connect (u5, localhost, user_4_1_9, , db_datadict);
 
1108
--source suite/funcs_1/include/show_connection.inc
 
1109
 
 
1110
use db_datadict;
 
1111
 
 
1112
let $message= user: alter a table from other db;
 
1113
let $dd_part1= ALTER TABLE information_schema.;
 
1114
let $dd_part2= ADD f1 INT;
 
1115
#FIXME: check change from error 1146 to 1044
 
1116
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1117
use information_schema;
 
1118
let $message= user: alter a table from directly;
 
1119
let $dd_part1= ALTER TABLE ;
 
1120
let $dd_part2= ADD f1 INT;
 
1121
#FIXME: check change from error 1146 to 1044
 
1122
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1123
disconnect u5;
 
1124
 
 
1125
# cleanup
 
1126
connection default;
 
1127
--source suite/funcs_1/include/show_connection.inc
 
1128
DROP USER user_4_1_9@localhost;
 
1129
# ------------------------------------------------------------------------------
 
1130
 
 
1131
let $message= Testcase 3.2.1.10:;
 
1132
--source include/show_msg80.inc
 
1133
 
 
1134
################################################################################
 
1135
# Testcase 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
 
1136
################################################################################
 
1137
 
 
1138
use information_schema;
 
1139
 
 
1140
let $message= root: drop a table from IS;
 
1141
let $dd_part1= DROP TABLE ;
 
1142
let $dd_part2=;
 
1143
#FIXME: check change from error 1051 to 1044
 
1144
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1145
use db_datadict;
 
1146
 
 
1147
let $message= root: drop a table from other db;
 
1148
let $dd_part1= DROP TABLE information_schema.;
 
1149
let $dd_part2=;
 
1150
#FIXME: check change from error 1051 to 1044
 
1151
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1152
use information_schema;
 
1153
 
 
1154
# drop an information_schema table as a limited user with sufficient permissions
 
1155
 
 
1156
CREATE USER user_4_1_10@localhost;
 
1157
 
 
1158
GRANT SELECT, DROP ON *.* TO user_4_1_10@localhost;
 
1159
 
 
1160
FLUSH PRIVILEGES;
 
1161
 
 
1162
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1163
connect (u6,localhost,user_4_1_10,,db_datadict);
 
1164
 
 
1165
use information_schema;
 
1166
--source suite/funcs_1/include/show_connection.inc
 
1167
 
 
1168
let $message= user: drop a table from IS;
 
1169
let $dd_part1= DROP TABLE ;
 
1170
let $dd_part2=;
 
1171
#FIXME: check change from error 1051 to 1044
 
1172
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1173
use db_datadict;
 
1174
 
 
1175
let $message= user: drop a table from other db;
 
1176
let $dd_part1= DROP TABLE information_schema.;
 
1177
let $dd_part2=;
 
1178
#FIXME: check change from error 1051 to 1044
 
1179
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1180
disconnect u6;
 
1181
 
 
1182
connection default;
 
1183
--source suite/funcs_1/include/show_connection.inc
 
1184
 
 
1185
# cleanup
 
1186
DROP USER user_4_1_10@localhost;
 
1187
 
 
1188
# Try to carry out information_schema modification operations with a user other than root having SUPER privileges
 
1189
CREATE USER user_4_1_11@localhost;
 
1190
 
 
1191
GRANT SUPER ON *.* TO user_4_1_11@localhost;
 
1192
 
 
1193
FLUSH PRIVILEGES;
 
1194
 
 
1195
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1196
connect (u7,localhost,user_4_1_11, ,test);
 
1197
 
 
1198
use information_schema;
 
1199
--source suite/funcs_1/include/show_connection.inc
 
1200
 
 
1201
--error 1044
 
1202
drop table routines;
 
1203
 
 
1204
--error 1044
 
1205
alter table collations enable keys;
 
1206
 
 
1207
--error 1044
 
1208
create index i5 on collations( collation_name );
 
1209
 
 
1210
--error 1109
 
1211
create view v1 as select * from schemata;
 
1212
 
 
1213
--error 1044
 
1214
delete from columns;
 
1215
 
 
1216
--error 1044
 
1217
update columns set table_name = 't4' where column_name = 'f2';
 
1218
 
 
1219
--error 1044
 
1220
insert into collations ( collation_name, character_set_name, id, is_default,
 
1221
  is_compiled, sortlen)
 
1222
  values ('cp1251_bin', 'cp1251', 50, '', '', 0);
 
1223
 
 
1224
disconnect u7;
 
1225
 
 
1226
connection default;
 
1227
--source suite/funcs_1/include/show_connection.inc
 
1228
DROP USER user_4_1_11@localhost;
 
1229
# ------------------------------------------------------------------------------
 
1230
 
 
1231
let $message= Testcase 3.2.1.11:;
 
1232
--source include/show_msg80.inc
 
1233
 
 
1234
################################################################################
 
1235
# Testcase 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table
 
1236
#                    to any other database.
 
1237
################################################################################
 
1238
 
 
1239
--disable_warnings
 
1240
DROP DATABASE IF EXISTS db_datadict;
 
1241
--enable_warnings
 
1242
 
 
1243
CREATE DATABASE db_datadict;
 
1244
CREATE USER 'u_6_401011'@'localhost';
 
1245
 
 
1246
#FIXME: check that GRANT ON i_s is no longer allowed
 
1247
--error 1044
 
1248
GRANT ALL ON information_schema.* TO 'u_6_401011'@'localhost';
 
1249
GRANT ALL ON db_datadict.* TO 'u_6_401011'@'localhost';
 
1250
 
 
1251
FLUSH PRIVILEGES;
 
1252
 
 
1253
--error 1044
 
1254
ALTER TABLE information_schema.schemata RENAME db_datadict.schemata;
 
1255
 
 
1256
let $message= root: move table to other DB;
 
1257
let $dd_part1= ALTER TABLE information_schema.;
 
1258
let $dd_part2= RENAME db_datadict.tb_01;
 
1259
#FIXME: check change from error 1146 to 1044
 
1260
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1261
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1262
connect (u_6_401011, localhost, u_6_401011, , db_datadict);
 
1263
 
 
1264
USE information_schema;
 
1265
--source suite/funcs_1/include/show_connection.inc
 
1266
 
 
1267
--error 1044
 
1268
ALTER TABLE information_schema.schemata RENAME db_datadict.schemata;
 
1269
 
 
1270
let $message= user: move table to other DB;
 
1271
let $dd_part1= ALTER TABLE information_schema.;
 
1272
let $dd_part2= RENAME db_datadict.tb_01;
 
1273
#FIXME: check change from error 1146 to 1044
 
1274
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1275
disconnect u_6_401011;
 
1276
 
 
1277
connection default;
 
1278
--source suite/funcs_1/include/show_connection.inc
 
1279
 
 
1280
#cleanup
 
1281
--disable_warnings
 
1282
#DROP DATABASE db_datadict;
 
1283
DROP TABLE IF EXISTS db_datadict.schemata;
 
1284
DROP USER 'u_6_401011'@'localhost';
 
1285
--enable_warnings
 
1286
# ------------------------------------------------------------------------------
 
1287
 
 
1288
let $message= Testcase 3.2.1.12:;
 
1289
--source include/show_msg80.inc
 
1290
 
 
1291
################################################################################
 
1292
# Testcase 3.2.1.12: Ensure that no user may directly add to, alter, or delete
 
1293
#                    any data in an INFORMATION_SCHEMA table.
 
1294
################################################################################
 
1295
 
 
1296
# first as root a DELETE check on all tables
 
1297
let $message= root: delete from IS tables;
 
1298
let $dd_part1= DELETE FROM information_schema.;
 
1299
let $dd_part2=;
 
1300
#FIXME: check change from error 1288 to 1044
 
1301
--source suite/funcs_1/datadict/datadict_tables_error_1044.inc
 
1302
# check UPDATE for all ...
 
1303
--error 1044
 
1304
UPDATE information_schema.tables SET table_name = 't_4711';
 
1305
--error 1044
 
1306
UPDATE information_schema.columns SET table_name = 't_4711';
 
1307
--error 1044
 
1308
UPDATE information_schema.statistics SET table_name = 't_4711';
 
1309
--error 1044
 
1310
UPDATE information_schema.views SET table_name = 't_4711';
 
1311
--error 1044
 
1312
UPDATE information_schema.table_privileges SET table_name = 't_4711';
 
1313
--error 1044
 
1314
UPDATE information_schema.column_privileges SET table_name = 't_4711';
 
1315
--error 1044
 
1316
UPDATE information_schema.table_constraints SET table_name = 't_4711';
 
1317
--error 1044
 
1318
UPDATE information_schema.key_column_usage SET table_name = 't_4711';
 
1319
--error 1044
 
1320
UPDATE information_schema.schemata SET catalog_name = 't_4711';
 
1321
--error 1044
 
1322
UPDATE information_schema.character_sets SET description = 't_4711';
 
1323
--error 1044
 
1324
UPDATE information_schema.collations SET character_set_name = 't_4711';
 
1325
--error 1044
 
1326
UPDATE information_schema.collation_character_set_applicability
 
1327
   SET character_set_name = 't_4711';
 
1328
--error 1044
 
1329
UPDATE information_schema.routines SET routine_type = 't_4711';
 
1330
--error 1044
 
1331
UPDATE information_schema.user_privileges SET grantee = 't_4711';
 
1332
--error 1044
 
1333
UPDATE information_schema.schema_privileges SET grantee = 't_4711';
 
1334
--error 1044
 
1335
UPDATE information_schema.triggers SET sql_mode = 't_4711';
 
1336
 
 
1337
CREATE USER 'u_6_401012'@'localhost';
 
1338
 
 
1339
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1340
connect (u_6_401012, localhost, u_6_401012, , test);
 
1341
 
 
1342
use information_schema;
 
1343
 
 
1344
--error 1044
 
1345
insert into information_schema.schemata  (catalog_name, schema_name,
 
1346
  default_character_set_name, sql_path)
 
1347
  values (null, information_schema1, utf16, null);
 
1348
#FIXME: check later the change from 1142 to 1044 (since Mid Sep05)
 
1349
--error 1044
 
1350
alter table information_schema.schemata rename db_datadict1.schemata;
 
1351
#FIXME: check later the change from 1146 to 1044 (since Mid Sep05)
 
1352
--error 1044
 
1353
alter table information_schema.tables drop column checksum;
 
1354
--error 1044
 
1355
alter table information_schema.statistics modify packed int;
 
1356
--error 1044
 
1357
alter table information_schema.routines modify created int not null;
 
1358
--error 1044
 
1359
alter table information_schema.key_column_usage drop column ordinal_position;
 
1360
--error 1044
 
1361
alter table information_schema.table_privileges
 
1362
  change privilege_type rights_approved varchar(32);
 
1363
--error 1044
 
1364
update columns set table_name = 't4' where column_name = 'f2';
 
1365
--error 1044
 
1366
delete from information_schema.collations;
 
1367
 
 
1368
disconnect u_6_401012;
 
1369
 
 
1370
# cleanup
 
1371
connection default;
 
1372
--source suite/funcs_1/include/show_connection.inc
 
1373
 
 
1374
--disable_warnings
 
1375
drop table if exists db_datadict1.schemata;
 
1376
DROP USER 'u_6_401012'@'localhost';
 
1377
--enable_warnings
 
1378
#-------------------------------------------------------------------------------------------------
 
1379
 
 
1380
let $message= Testcase 3.2.1.13:;
 
1381
--source include/show_msg80.inc
 
1382
 
 
1383
################################################################################
 
1384
# Testcase 3.2.1.13: Ensure that the creation of any new database object
 
1385
#                    (e.g. table or column) automatically inserts all relevant
 
1386
#                    information on that object into every appropriate
 
1387
#                    INFORMATION_SCHEMA table.
 
1388
################################################################################
 
1389
 
 
1390
use information_schema;
 
1391
 
 
1392
let $dbname=db_datadict;
 
1393
let $message= first check status >before< creating the objects ...;
 
1394
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1395
 
 
1396
--disable_warnings
 
1397
DROP DATABASE IF EXISTS db_datadict;
 
1398
--enable_warnings
 
1399
CREATE DATABASE db_datadict;
 
1400
USE db_datadict;
 
1401
 
 
1402
eval create table res_t_401013(f1 char(10), f2 char(25), f3 int)
 
1403
            engine = $ENGINE_TYPE;
 
1404
create view res_v_401013 as select * from res_t_401013;
 
1405
CREATE USER u_6_401013@localhost;
 
1406
create procedure sp_6_401013() select 'db_datadict';
 
1407
create function fn_6_401013() returns int return 0;
 
1408
create index i_6_401013 on res_t_401013(f3);
 
1409
 
 
1410
use information_schema;
 
1411
 
 
1412
let $message= now check whether all new objects exists in IS ...;
 
1413
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1414
 
 
1415
# cleanup objects
 
1416
use db_datadict;
 
1417
drop index i_6_401013 on res_t_401013;
 
1418
drop table db_datadict.res_t_401013;
 
1419
drop view  db_datadict.res_v_401013;
 
1420
DROP USER u_6_401013@localhost;
 
1421
drop procedure sp_6_401013;
 
1422
drop function fn_6_401013;
 
1423
drop database db_datadict;
 
1424
 
 
1425
use information_schema;
 
1426
 
 
1427
let $message= and now check whether all objects are removed from IS ...;
 
1428
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1429
# ------------------------------------------------------------------------------
 
1430
 
 
1431
let $message= Testcase 3.2.1.14:;
 
1432
--source include/show_msg80.inc
 
1433
 
 
1434
################################################################################
 
1435
# Testcase 3.2.1.14: Ensure that the alteration of any existing database object
 
1436
#                    automatically updates all relevant information on that
 
1437
#                    object in every appropriate INFORMATION_SCHEMA table.
 
1438
################################################################################
 
1439
 
 
1440
--disable_warnings
 
1441
DROP DATABASE IF EXISTS db_datadict;
 
1442
--enable_warnings
 
1443
CREATE DATABASE db_datadict;
 
1444
USE db_datadict;
 
1445
 
 
1446
create table res_t_401014(f1 char(10), f2 text(25), f3 int);
 
1447
create view res_v_401014 as select * from res_t_401014;
 
1448
create procedure sp_6_401014() select 'db_datadict';
 
1449
create function fn_6_401014() returns int return 0;
 
1450
 
 
1451
# check current information in information_schema
 
1452
 
 
1453
let $dbname=db_datadict;
 
1454
let $message= show existing objects >before< changing them ...;
 
1455
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1456
 
 
1457
# alter objects
 
1458
 
 
1459
use db_datadict;
 
1460
 
 
1461
alter table res_t_401014 change f1 ff1 int;
 
1462
alter table res_t_401014 engine = innodb;
 
1463
alter table res_t_401014 change f3 f3_new bigint;
 
1464
alter view res_v_401014 as select ff1 from res_t_401014;
 
1465
alter procedure sp_6_401014 sql security invoker;
 
1466
alter function fn_6_401014 comment 'updated comments';
 
1467
alter database db_datadict character set utf8;
 
1468
 
 
1469
# check updated information in information_schema
 
1470
let $message= now check whether the changes are visible in IS ...;
 
1471
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1472
 
 
1473
 
 
1474
# cleanup
 
1475
 
 
1476
use db_datadict;
 
1477
drop table db_datadict.res_t_401014;
 
1478
drop view  db_datadict.res_v_401014;
 
1479
drop procedure sp_6_401014;
 
1480
drop function fn_6_401014;
 
1481
drop database db_datadict;
 
1482
# ------------------------------------------------------------------------------
 
1483
 
 
1484
let $message= Testcase 3.2.1.15:;
 
1485
--source include/show_msg80.inc
 
1486
 
 
1487
################################################################################
 
1488
# Testcase 3.2.1.15: Ensure that the dropping of any existing database object
 
1489
#                    automatically deletes all relevant information on that
 
1490
#                    object from every appropriate INFORMATION_SCHEMA table.
 
1491
################################################################################
 
1492
 
 
1493
--disable_warnings
 
1494
DROP DATABASE IF EXISTS db_datadict;
 
1495
--enable_warnings
 
1496
CREATE DATABASE db_datadict;
 
1497
USE db_datadict;
 
1498
 
 
1499
create table res_t_401015(f1 char(10), f2 text(25), f3 int);
 
1500
create view res_v_401015 as select * from res_t_401015;
 
1501
CREATE USER u_6_401015@localhost;
 
1502
create procedure sp_6_401015() select 'test';
 
1503
create function fn_6_401015() returns int return 0;
 
1504
create index i_6_401015 on res_t_401015(f3);
 
1505
 
 
1506
let $dbname=db_datadict;
 
1507
let $message= show existing objects >before< dropping them ...;
 
1508
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1509
 
 
1510
use db_datadict;
 
1511
drop index i_6_401015 on res_t_401015;
 
1512
drop table db_datadict.res_t_401015;
 
1513
drop view  db_datadict.res_v_401015;
 
1514
DROP USER u_6_401015@localhost;
 
1515
drop procedure sp_6_401015;
 
1516
drop function fn_6_401015;
 
1517
#drop database db_datadict;
 
1518
 
 
1519
let $message= now check they are really gone ...;
 
1520
--source suite/funcs_1/datadict/datadict_show_schema.inc
 
1521
# ------------------------------------------------------------------------------
 
1522
 
 
1523
let $message= Testcase 3.2.1.16:;
 
1524
--source include/show_msg80.inc
 
1525
 
 
1526
################################################################################
 
1527
# Testcase 3.2.1.16: Ensure that no user may use any INFORMATION_SCHEMA table to
 
1528
#                    determine any information on a database and/or its
 
1529
#                    structure unless authorized to get that information.
 
1530
################################################################################
 
1531
 
 
1532
--disable_warnings
 
1533
DROP DATABASE IF EXISTS db_datadict;
 
1534
--enable_warnings
 
1535
CREATE DATABASE db_datadict;
 
1536
 
 
1537
CREATE DATABASE db_hidden;
 
1538
USE db_hidden;
 
1539
CREATE TABLE tb_hidden ( c1 TEXT );
 
1540
 
 
1541
USE db_datadict;
 
1542
 
 
1543
CREATE TABLE res_t_401016(f1 char(10),f2 text(25),f3 int);
 
1544
CREATE TABLE res_t_401016_1(f1 char(10),f2 text(25),f3 int);
 
1545
 
 
1546
CREATE USER 'u_6_401016'@'localhost';
 
1547
GRANT SELECT ON db_datadict.res_t_401016 TO 'u_6_401016'@'localhost';
 
1548
 
 
1549
FLUSH PRIVILEGES;
 
1550
 
 
1551
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1552
connect (u_6_401016, localhost, u_6_401016, , test);
 
1553
 
 
1554
USE information_schema;
 
1555
 
 
1556
SELECT table_schema, table_name, engine
 
1557
  FROM TABLES;
 
1558
# WHERE table_name LIKE 'res_t_401016%';
 
1559
 
 
1560
SHOW TABLES;
 
1561
SELECT * FROM schemata;
 
1562
 
 
1563
disconnect u_6_401016;
 
1564
 
 
1565
connection default;
 
1566
--source suite/funcs_1/include/show_connection.inc
 
1567
 
 
1568
#FIXME: check that GRANT ON i_s is no longer allowed
 
1569
--error 1044
 
1570
grant usage on information_schema.* to 'u_6_401016'@'localhost';
 
1571
FLUSH PRIVILEGES;
 
1572
 
 
1573
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1574
connect (u_6_401016_1, localhost, u_6_401016, , db_datadict);
 
1575
 
 
1576
USE information_schema;
 
1577
SHOW TABLES;
 
1578
SELECT * FROM schemata;
 
1579
 
 
1580
disconnect u_6_401016_1;
 
1581
 
 
1582
# all tables are checked again later with permission tests
 
1583
 
 
1584
# cleanup
 
1585
connection default;
 
1586
use db_datadict;
 
1587
--source suite/funcs_1/include/show_connection.inc
 
1588
DROP USER 'u_6_401016'@'localhost';
 
1589
drop table res_t_401016;
 
1590
drop table res_t_401016_1;
 
1591
DROP DATABASE db_hidden;
 
1592
#drop database db_datadict;
 
1593
# ------------------------------------------------------------------------------
 
1594
 
 
1595
let $message= Testcase 3.2.1.17:;
 
1596
--source include/show_msg80.inc
 
1597
 
 
1598
################################################################################
 
1599
# Testcase 3.2.1.17: Ensure that the SELECT privilege is granted TO PUBLIC WITH
 
1600
#                    GRANT OPTION on every INFORMATION_SCHEMA table.
 
1601
################################################################################
 
1602
 
 
1603
CREATE USER 'u_6_401017'@'localhost';
 
1604
 
 
1605
#FIXME: check that GRANT ON i_s is no longer allowed
 
1606
--error 1044
 
1607
grant select on information_schema.* to u_6_401017@localhost;
 
1608
 
 
1609
FLUSH PRIVILEGES;
 
1610
 
 
1611
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1612
connect (u_6_401017, localhost, u_6_401017, , test);
 
1613
 
 
1614
use information_schema;
 
1615
 
 
1616
select * from collation_character_set_applicability;
 
1617
select * from schemata;
 
1618
select table_name from tables;
 
1619
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
1620
select table_name, column_name, column_type from columns;
 
1621
select character_set_name from character_sets;
 
1622
select collation_name from collations;
 
1623
select routine_name, routine_type from routines;
 
1624
select table_name, index_name from statistics;
 
1625
select table_name from views;
 
1626
select privilege_type from user_privileges;
 
1627
select grantee, privilege_type from schema_privileges;
 
1628
select * from table_privileges;
 
1629
select column_name, privilege_type from column_privileges;
 
1630
select table_name,constraint_type from table_constraints;
 
1631
select table_schema, table_name, column_name from key_column_usage;
 
1632
 
 
1633
disconnect u_6_401017;
 
1634
 
 
1635
# cleanup
 
1636
connection default;
 
1637
--source suite/funcs_1/include/show_connection.inc
 
1638
DROP USER 'u_6_401017'@'localhost';
 
1639
# ------------------------------------------------------------------------------
 
1640
 
 
1641
let $message= Testcase 3.2.1.18:;
 
1642
--source include/show_msg80.inc
 
1643
 
 
1644
################################################################################
 
1645
# Testcase 3.2.1.18: Ensure that the CREATE VIEW privilege on an
 
1646
#                    INFORMATION_SCHEMA table may be granted to any user.
 
1647
################################################################################
 
1648
 
 
1649
CREATE USER 'u_6_401018'@'localhost';
 
1650
 
 
1651
#FIXME: check GRANT on IS
 
1652
--error 1044
 
1653
GRANT CREATE VIEW ON information_schema.* TO 'u_6_401018'@'localhost';
 
1654
GRANT ALL         ON db_datadict.*        TO 'u_6_401018'@'localhost';
 
1655
 
 
1656
SHOW GRANTS FOR 'u_6_401018'@'localhost';
 
1657
FLUSH PRIVILEGES;
 
1658
 
 
1659
--disable_warnings
 
1660
DROP DATABASE IF EXISTS db_datadict;
 
1661
--enable_warnings
 
1662
CREATE DATABASE db_datadict;
 
1663
 
 
1664
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1665
connect (u_6_401018, localhost, u_6_401018, , test);
 
1666
 
 
1667
USE db_datadict;
 
1668
 
 
1669
create view db_datadict.v_401018 as
 
1670
 select * from information_schema.schemata;
 
1671
SELECT * FROM v_401018 ORDER BY 2 DESC;
 
1672
 
 
1673
disconnect u_6_401018;
 
1674
 
 
1675
#cleanup
 
1676
connection default;
 
1677
--source suite/funcs_1/include/show_connection.inc
 
1678
DROP USER 'u_6_401018'@'localhost';
 
1679
DROP DATABASE db_datadict;
 
1680
# ------------------------------------------------------------------------------
 
1681
 
 
1682
let $message= Testcase 3.2.1.19:;
 
1683
--source include/show_msg80.inc
 
1684
 
 
1685
################################################################################
 
1686
# Testcase 3.2.1.19: Ensure that no other privilege on an INFORMATION_SCHEMA
 
1687
#                    table is granted, or may be granted, to any user.
 
1688
################################################################################
 
1689
 
 
1690
CREATE USER 'u_6_401019'@'localhost';
 
1691
 
 
1692
#FIXME: check GRANT on IS
 
1693
--error 1044
 
1694
grant alter on information_schema.* to 'u_6_401019'@'localhost';
 
1695
 
 
1696
#FIXME: check GRANT on IS
 
1697
--error 1044
 
1698
grant alter routine on information_schema.* to 'u_6_401019'@'localhost';
 
1699
 
 
1700
#FIXME: check GRANT on IS
 
1701
--error 1044
 
1702
grant create on information_schema.* to 'u_6_401019'@'localhost';
 
1703
 
 
1704
#FIXME: check GRANT on IS
 
1705
--error 1044
 
1706
grant create routine on information_schema.* to 'u_6_401019'@'localhost';
 
1707
 
 
1708
#FIXME: check GRANT on IS
 
1709
--error 1044
 
1710
grant create temporary tables
 
1711
   on information_schema.* to 'u_6_401019'@'localhost';
 
1712
 
 
1713
#FIXME: check GRANT on IS
 
1714
--error 1044
 
1715
grant delete on information_schema.* to 'u_6_401019'@'localhost';
 
1716
 
 
1717
#FIXME: check GRANT on IS
 
1718
--error 1044
 
1719
grant drop on information_schema.* to 'u_6_401019'@'localhost';
 
1720
 
 
1721
#FIXME: check GRANT on IS
 
1722
--error 1044
 
1723
grant execute on information_schema.* to 'u_6_401019'@'localhost';
 
1724
 
 
1725
#FIXME: check GRANT on IS
 
1726
--error 1044
 
1727
grant index on information_schema.* to 'u_6_401019'@'localhost';
 
1728
 
 
1729
#FIXME: check GRANT on IS
 
1730
--error 1044
 
1731
grant insert on information_schema.* to 'u_6_401019'@'localhost';
 
1732
 
 
1733
#FIXME: check GRANT on IS
 
1734
--error 1044
 
1735
grant lock tables on information_schema.* to 'u_6_401019'@'localhost';
 
1736
 
 
1737
#FIXME: check GRANT on IS
 
1738
--error 1044
 
1739
grant update on information_schema.* to 'u_6_401019'@'localhost';
 
1740
 
 
1741
SELECT * FROM information_schema.table_privileges
 
1742
 WHERE table_schema = "information_schema";
 
1743
SELECT * FROM information_schema.column_privileges
 
1744
 WHERE table_schema = "information_schema";
 
1745
 
 
1746
# cleanup
 
1747
DROP USER 'u_6_401019'@'localhost';
 
1748
# ------------------------------------------------------------------------------
 
1749
 
 
1750
let $message= Testcase 3.2.1.20:;
 
1751
--source include/show_msg80.inc
 
1752
 
 
1753
################################################################################
 
1754
# Testcase 3.2.1.20: Ensure that USE INFORMATION_SCHEMA allows the user to
 
1755
#                    switch to the INFORMATION_SCHEMA database, for query
 
1756
#                    purposes only.
 
1757
################################################################################
 
1758
 
 
1759
CREATE USER 'u_6_401020'@'localhost';
 
1760
 
 
1761
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1762
connect (u_6_401020, localhost, u_6_401020, , test);
 
1763
 
 
1764
USE information_schema;
 
1765
SELECT * FROM schemata;
 
1766
 
 
1767
--error 1109
 
1768
CREATE TABLE tb_not_allowed ( col TEXT );
 
1769
#FIXME 3.2.1.20: bad message: ERROR 42S02: Unknown table 'tb_not_allowed' in information_schema
 
1770
#FIXME 3.2.1.20: better:      ERROR 42000: Access denied for user 'u_6_401020'@'localhost' to database 'information_schema'
 
1771
 
 
1772
--error 1109
 
1773
create view res_v1 as select * from information_schema.schemata;
 
1774
 
 
1775
--error 1044
 
1776
alter table schemata modify catalog_name varchar(255);
 
1777
 
 
1778
--error 1044
 
1779
update schemata set catalog_name = 'abc'
 
1780
 where schema_name = 'information_schema';
 
1781
 
 
1782
delimiter //;
 
1783
--error ER_BAD_DB_ERROR
 
1784
CREATE PROCEDURE sp_3_2_1_20()
 
1785
  BEGIN
 
1786
    INSERT INTO information_schema.schema_privileges (table_schema,privilege_type)
 
1787
      VALUES('db2','insert');
 
1788
  END//
 
1789
delimiter ;//
 
1790
 
 
1791
--error 1044
 
1792
DELETE FROM schemata WHERE schema_name = 'information_schema';
 
1793
 
 
1794
disconnect u_6_401020;
 
1795
 
 
1796
# cleanup
 
1797
connection default;
 
1798
--source suite/funcs_1/include/show_connection.inc
 
1799
DROP USER 'u_6_401020'@'localhost';
 
1800
# ------------------------------------------------------------------------------
 
1801
 
 
1802
let $message= Testcase 3.2.2.1:;
 
1803
--source include/show_msg80.inc
 
1804
 
 
1805
################################################################################
 
1806
# Testcase 3.2.2.1:  Ensure that the INFORMATION_SCHEMA.CHARACTER_SETS
 
1807
#                    table has the following columns, in the following order:
 
1808
#
 
1809
#                    CHARACTER_SET_NAME (shows a character set name),
 
1810
#                    DEFAULT_COLLATE_NAME (shows the name of the default
 
1811
#                          collation for that character set),
 
1812
#                    DESCRIPTION (shows a descriptive name for that character
 
1813
#                          set),
 
1814
#                    MAXLEN (shows the number of bytes used to store each
 
1815
#                          character supported by that character set).
 
1816
################################################################################
 
1817
 
 
1818
let $is_table= character_sets;
 
1819
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
1820
# ------------------------------------------------------------------------------
 
1821
 
 
1822
let $message= Testcase 3.2.2.2:;
 
1823
--source include/show_msg80.inc
 
1824
 
 
1825
################################################################################
 
1826
# Testcase 3.2.2.2: Ensure that the table shows the relevant information on
 
1827
#                   every character set for which the current user or PUBLIC
 
1828
#                   have the USAGE privilege.
 
1829
################################################################################
 
1830
 
 
1831
--source suite/funcs_1/include/show_connection.inc
 
1832
SELECT * FROM information_schema.character_sets;
 
1833
# ------------------------------------------------------------------------------
 
1834
 
 
1835
let $message= Testcase 3.2.2.3:;
 
1836
--source include/show_msg80.inc
 
1837
 
 
1838
################################################################################
 
1839
# Testcase 3.2.2.3:  Ensure that the table shows the relevant information on
 
1840
#                    every character set for which the current user or PUBLIC
 
1841
#                    have the USAGE privilege.
 
1842
################################################################################
 
1843
 
 
1844
# Test requirement is erroneous... we cannot grant / revoke privilege for using
 
1845
# a character set.
 
1846
# ------------------------------------------------------------------------------
 
1847
 
 
1848
let $message= Testcase 3.2.3.1:;
 
1849
--source include/show_msg80.inc
 
1850
 
 
1851
################################################################################
 
1852
# Testcase 3.2.3.1:  Ensure that the INFORMATION_SCHEMA.COLLATIONS
 
1853
#                    table has the following columns, in the following order:
 
1854
#
 
1855
#                    COLLATION_NAME (shows a collation name),
 
1856
#                    CHARACTER_SET_NAME (shows the name of the character set to
 
1857
#                          which the collation applies),
 
1858
#                    ID (shows a numeric identifier for that collation/character
 
1859
#                          set combination),
 
1860
#                    IS_DEFAULT (shows whether the collation is the default
 
1861
#                          collation for the character set shown),
 
1862
#                    IS_COMPILED (indicates whether the collation is compiled
 
1863
#                          into the MySQL server),
 
1864
#                    SORTLEN (shows a value related to the amount of memory
 
1865
#                          required to sort strings using this
 
1866
#                          collation/character set combination).
 
1867
################################################################################
 
1868
 
 
1869
let $is_table= collations;
 
1870
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
1871
# -------------------------------------------------------------------------------------------------------
 
1872
 
 
1873
let $message= Testcase 3.2.3.2:;
 
1874
--source include/show_msg80.inc
 
1875
 
 
1876
################################################################################
 
1877
# Testcase 3.2.3.2:  Ensure that the table shows the relevant information on
 
1878
#                    every collation for which the current user or PUBLIC have
 
1879
#                    the USAGE privilege.
 
1880
################################################################################
 
1881
 
 
1882
SELECT * FROM collations;
 
1883
# -------------------------------------------------------------------------------------------------------
 
1884
 
 
1885
let $message= Testcase 3.2.3.3:;
 
1886
--source include/show_msg80.inc
 
1887
 
 
1888
###############################################################################
 
1889
# Testcase 3.2.3.3:  Ensure that the table does not show any information on any
 
1890
#                    collations for which the current user and PUBLIC have no
 
1891
#                    USAGE privilege.
 
1892
################################################################################
 
1893
 
 
1894
# Test requirement is erroneous... we cannot grant / revoke privilege for using
 
1895
# a collation.
 
1896
# -------------------------------------------------------------------------------------------------------
 
1897
 
 
1898
let $message= Testcase 3.2.4.1:;
 
1899
--source include/show_msg80.inc
 
1900
 
 
1901
################################################################################
 
1902
# Testcase 3.2.4.1:  Ensure that the
 
1903
#                      INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
 
1904
#                    table has the following columns, in the following order:
 
1905
#
 
1906
#                    COLLATION_NAME (shows the name of a collation),
 
1907
#                    CHARACTER_SET_NAME (shows the name of a character set to
 
1908
#                          which that collation applies).
 
1909
################################################################################
 
1910
 
 
1911
let $is_table= collation_character_set_applicability;
 
1912
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
1913
# -------------------------------------------------------------------------------------------------------
 
1914
 
 
1915
let $message= Testcase 3.2.4.2:;
 
1916
--source include/show_msg80.inc
 
1917
 
 
1918
################################################################################
 
1919
# Testcase 3.2.4.2:  Ensure that the table shows the relevant information on
 
1920
#                    every collation/character set combination for which the
 
1921
#                    current user or PUBLIC have the USAGE privilege.
 
1922
################################################################################
 
1923
 
 
1924
SELECT * FROM collation_character_set_applicability;
 
1925
# -------------------------------------------------------------------------------------------------------
 
1926
 
 
1927
let $message= Testcase 3.2.4.3:;
 
1928
--source include/show_msg80.inc
 
1929
 
 
1930
################################################################################
 
1931
# Testcase 3.2.4.3:  Ensure that the table does not show any information on any
 
1932
#                    collation/character set combinations for which the current
 
1933
#                    user and PUBLIC have no USAGE privilege.
 
1934
################################################################################
 
1935
 
 
1936
# Test requirement is erroneous... we cannot grant / revoke privilege for using a collation.
 
1937
# -------------------------------------------------------------------------------------------------------
 
1938
 
 
1939
let $message= Testcase 3.2.5.1:;
 
1940
--source include/show_msg80.inc
 
1941
 
 
1942
################################################################################
 
1943
# Testcase 3.2.5.1:  Ensure that the INFORMATION_SCHEMA.COLUMN_PRIVILEGES
 
1944
#                    table has the following columns, in the following order:
 
1945
#
 
1946
#                    GRANTEE (shows the name of a user who has either granted,
 
1947
#                          or been granted a column privilege),
 
1948
#                    TABLE_CATALOG (always shows NULL),
 
1949
#                    TABLE_SCHEMA (shows the name of the schema, or database,
 
1950
#                          in which the table for which a column privilege has
 
1951
#                          been granted resides),
 
1952
#                    TABLE_NAME (shows the name of the table),
 
1953
#                    COLUMN_NAME (shows the name of the column on which a
 
1954
#                          column privilege has been granted),
 
1955
#                    PRIVILEGE_TYPE (shows the type of privilege that was
 
1956
#                          granted; must be either SELECT, INSERT, UPDATE, or
 
1957
#                          REFERENCES),
 
1958
#                    IS_GRANTABLE (shows whether that privilege was granted
 
1959
#                          WITH GRANT OPTION).
 
1960
################################################################################
 
1961
 
 
1962
let $is_table= column_privileges;
 
1963
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
1964
# -------------------------------------------------------------------------------------------------------
 
1965
 
 
1966
let $message= Testcase 3.2.5.2 + 3.2.5.3 + 3.2.5.4:;
 
1967
--source include/show_msg80.inc
 
1968
 
 
1969
################################################################################
 
1970
# Testcase 3.2.5.2:  Ensure that the table shows the relevant information on
 
1971
#                    every column privilege which has been granted to the
 
1972
#                    current user or PUBLIC, or which was granted by the current
 
1973
#                    user.
 
1974
################################################################################
 
1975
# Testcase 3.2.5.3:  Ensure that the table does not show any information on any
 
1976
#                    column privilege which was granted to any user other than
 
1977
#                    the current user or PUBLIC, or which was granted by any
 
1978
#                    user other than the current user.
 
1979
################################################################################
 
1980
# Testcase 3.2.5.4:  Ensure that the table does not show any information on any
 
1981
#                    privileges that are not column privileges for the current
 
1982
#                    user.
 
1983
################################################################################
 
1984
 
 
1985
CREATE USER 'user_1'@'localhost';
 
1986
CREATE USER 'user_2'@'localhost';
 
1987
CREATE USER 'user_3'@'localhost';
 
1988
 
 
1989
--disable_warnings
 
1990
DROP DATABASE IF EXISTS db_datadict;
 
1991
--enable_warnings
 
1992
CREATE DATABASE db_datadict;
 
1993
USE db_datadict;
 
1994
 
 
1995
CREATE TABLE db_datadict.res_t40502 (f1 INT, f2 DECIMAL, f3 TEXT);
 
1996
 
 
1997
GRANT SELECT(f1, f3) ON db_datadict.res_t40502 TO 'user_1'@'localhost';
 
1998
GRANT INSERT(f1)     ON db_datadict.res_t40502 TO 'user_1'@'localhost';
 
1999
GRANT UPDATE(f2)     ON db_datadict.res_t40502 TO 'user_1'@'localhost';
 
2000
GRANT SELECT(f2)     ON db_datadict.res_t40502 TO 'user_2'@'localhost';
 
2001
GRANT INSERT, SELECT ON db_datadict.res_t40502 TO 'user_3'@'localhost';
 
2002
GRANT SELECT(f3)     ON db_datadict.res_t40502 TO 'user_3'@'localhost';
 
2003
 
 
2004
GRANT INSERT, SELECT ON db_datadict.res_t40502 TO 'user_3'@'localhost' WITH GRANT OPTION;
 
2005
GRANT ALL            ON db_datadict.*          TO 'user_3'@'localhost';
 
2006
 
 
2007
let $select= SELECT * FROM information_schema.column_privileges
 
2008
 WHERE grantee LIKE "'user%"
 
2009
 ORDER BY grantee, table_name, column_name, privilege_type;
 
2010
eval $select;
 
2011
 
 
2012
let $message= FIXME: Check it is correct that the following GRANT changes ALL privs that user_1 has;
 
2013
--source include/show_msg.inc
 
2014
 
 
2015
GRANT UPDATE(f3)     ON db_datadict.res_t40502 TO 'user_1'@'localhost' WITH GRANT OPTION;
 
2016
 
 
2017
eval $select;
 
2018
 
 
2019
FLUSH PRIVILEGES;
 
2020
 
 
2021
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2022
connect (user_5_1, localhost, user_1, , db_datadict);
 
2023
eval $select;
 
2024
 
 
2025
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2026
connect (user_5_2, localhost, user_2, , db_datadict);
 
2027
eval $select;
 
2028
 
 
2029
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2030
connect (user_5_3, localhost, user_3, , db_datadict);
 
2031
 
 
2032
let $message= FIXME: check it is correct that granted TABLES doesn_t occur in COLUMN_PRIVILEGES;
 
2033
--source include/show_msg.inc
 
2034
SELECT * FROM information_schema.table_privileges WHERE grantee LIKE "'user%";
 
2035
SELECT * FROM information_schema.schema_privileges WHERE grantee LIKE "'user%";
 
2036
eval $select;
 
2037
GRANT SELECT(f1, f3) ON db_datadict.res_t40502 TO 'user_2'@'localhost';
 
2038
 
 
2039
let $message= FIXME: check whether it is intended that *my* grants to others are *NOT* shown here;
 
2040
--source include/show_msg.inc
 
2041
eval $select;
 
2042
 
 
2043
connection user_5_2;
 
2044
--source suite/funcs_1/include/show_connection.inc
 
2045
eval $select;
 
2046
 
 
2047
disconnect user_5_1;
 
2048
disconnect user_5_2;
 
2049
disconnect user_5_3;
 
2050
 
 
2051
#cleanup
 
2052
connection default;
 
2053
--source suite/funcs_1/include/show_connection.inc
 
2054
--disable_warnings
 
2055
DROP TABLE IF EXISTS db_datadict.res_t40502;
 
2056
DROP DATABASE IF EXISTS db_datadict;
 
2057
--enable_warnings
 
2058
 
 
2059
DROP USER 'user_1'@'localhost';
 
2060
DROP USER 'user_2'@'localhost';
 
2061
DROP USER 'user_3'@'localhost';
 
2062
# -------------------------------------------------------------------------------------------------------
 
2063
 
 
2064
let $message= Testcase 3.2.6.1:;
 
2065
--source include/show_msg80.inc
 
2066
 
 
2067
################################################################################
 
2068
# Testcase 3.2.6.1:  Ensure that the INFORMATION_SCHEMA.COLUMNS table has the
 
2069
#                    following columns, in the following order:
 
2070
#
 
2071
#                    TABLE_CATALOG (always shows NULL),
 
2072
#                    TABLE_SCHEMA (shows the name of the database, or schema,
 
2073
#                          in which an accessible table resides),
 
2074
#                    TABLE_NAME (shows the name of an accessible table),
 
2075
#                    COLUMN_NAME (shows the name of a column within that
 
2076
#                          table),
 
2077
#                    ORDINAL_POSITION (shows the ordinal position of that
 
2078
#                          column in that table),
 
2079
#                    COLUMN_DEFAULT (shows the column's default value),
 
2080
#                    IS_NULLABLE (shows whether the column may accept NULL
 
2081
#                          values),
 
2082
#                    DATA_TYPE (shows the column's defined data type; keyword
 
2083
#                          only),
 
2084
#                    CHARACTER_MAXIMUM_LENGTH (shows, for a string column, the
 
2085
#                          column's defined maximum length in characters;
 
2086
#                          otherwise NULL),
 
2087
#                    CHARACTER_OCTET_LENGTH (shows, for a string column, the
 
2088
#                          column's defined maximum length in octets;
 
2089
#                          otherwise NULL),
 
2090
#                    NUMERIC_PRECISION (shows, for a numeric column, the
 
2091
#                          column's or data type's defined precision;
 
2092
#                          otherwise NULL),
 
2093
#                    NUMERIC_SCALE (shows, for a numeric column, the column's
 
2094
#                          or data type's defined scale; otherwise NULL),
 
2095
#                    CHARACTER_SET_NAME (shows, for a character string column,
 
2096
#                          the column's default character set; otherwise NULL),
 
2097
#                    COLLATION_NAME (shows, for a character string column, the
 
2098
#                          column's default collation; otherwise NULL),
 
2099
#                    COLUMN_TYPE (shows the column's complete, defined data
 
2100
#                          type),
 
2101
#                    COLUMN_KEY (shows whether the column is indexed; possible
 
2102
#                          values are PRI if the column is part of a PRIMARY
 
2103
#                          KEY, UNI if the column is part of a UNIQUE key, MUL
 
2104
#                          if the column is part of an index key that allows
 
2105
#                          duplicates),
 
2106
#                    EXTRA (shows any additional column definition information,
 
2107
#                          e.g. whether the column was defined with the
 
2108
#                          AUTO_INCREMENT attribute),
 
2109
#                    PRIVILEGES (shows the privileges available to the user on
 
2110
#                          the column),
 
2111
#                    COLUMN_COMMENT (shows the comment, if any, defined for the
 
2112
#                          comment; otherwise NULL).
 
2113
################################################################################
 
2114
 
 
2115
let $is_table= columns;
 
2116
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2117
# -------------------------------------------------------------------------------------------------------
 
2118
 
 
2119
let $message= Testcase 3.2.6.2 + 3.2.6.3:;
 
2120
--source include/show_msg80.inc
 
2121
 
 
2122
################################################################################
 
2123
# Testcase 3.2.6.2:  Ensure that the table shows the relevant information on the
 
2124
#                    columns of every table that is accessible to the current
 
2125
#                    user or to PUBLIC.
 
2126
################################################################################
 
2127
# Testcase 3.2.6.3:  Ensure that the table does not show any information on the
 
2128
#                    columns of any table which is not accessible to the current
 
2129
#                    user or PUBLIC.
 
2130
################################################################################
 
2131
 
 
2132
--disable_warnings
 
2133
DROP DATABASE IF EXISTS db_datadict;
 
2134
--enable_warnings
 
2135
CREATE DATABASE db_datadict;
 
2136
 
 
2137
CREATE USER 'user_1'@'localhost';
 
2138
CREATE USER 'user_2'@'localhost';
 
2139
 
 
2140
USE db_datadict;
 
2141
 
 
2142
create table t_6_406001(f1 char(10), f2 text, f3 date, f4 int);
 
2143
grant select(f1, f2) on db_datadict.t_6_406001 to 'user_1'@'localhost';
 
2144
 
 
2145
create table t_6_406002(f1 char(10), f2 text, f3 date, f4 int);
 
2146
GRANT INSERT(f1, f2) ON db_datadict.t_6_406002 TO 'user_2'@'localhost';
 
2147
 
 
2148
FLUSH PRIVILEGES;
 
2149
 
 
2150
let $select= SELECT * FROM information_schema.columns
 
2151
 ORDER BY table_schema, table_name, ordinal_position;
 
2152
 
 
2153
# show view of user root
 
2154
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
2155
eval $select;
 
2156
 
 
2157
# reconnect to mysql with user credential of user u_6_406002_1.
 
2158
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2159
connect (user_6_1, localhost, user_1, , db_datadict);
 
2160
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
2161
eval $select;
 
2162
 
 
2163
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2164
connect (user_6_2, localhost, user_2, , db_datadict);
 
2165
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
2166
eval $select;
 
2167
 
 
2168
disconnect user_6_1;
 
2169
disconnect user_6_2;
 
2170
 
 
2171
connection default;
 
2172
--source suite/funcs_1/include/show_connection.inc
 
2173
 
 
2174
let $message= Show the quotient of COL and CML for all COLUMNS;
 
2175
--source include/show_msg.inc
 
2176
SELECT DISTINCT
 
2177
       CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
 
2178
       DATA_TYPE,
 
2179
       CHARACTER_SET_NAME,
 
2180
       COLLATION_NAME
 
2181
  FROM information_schema.columns
 
2182
 WHERE CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1
 
2183
 ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
 
2184
 
 
2185
#FIXME 3.2.6.2: check the value 2.0079 tinytext ucs2 ucs2_general_ci
 
2186
SELECT DISTINCT
 
2187
       CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
 
2188
       DATA_TYPE,
 
2189
       CHARACTER_SET_NAME,
 
2190
       COLLATION_NAME
 
2191
  FROM information_schema.columns
 
2192
 WHERE CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH <> 1
 
2193
 ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
 
2194
 
 
2195
SELECT DISTINCT
 
2196
       CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
 
2197
       DATA_TYPE,
 
2198
       CHARACTER_SET_NAME,
 
2199
       COLLATION_NAME
 
2200
  FROM information_schema.columns
 
2201
 WHERE CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH IS NULL
 
2202
 ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
 
2203
 
 
2204
echo --> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values;
 
2205
echo --> are 0, which is intended behavior, and the result of 0 / 0 IS NULL;
 
2206
--source suite/funcs_1/datadict/datadict_bug_12777.inc
 
2207
SELECT CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
 
2208
       TABLE_SCHEMA,
 
2209
       TABLE_NAME,
 
2210
       COLUMN_NAME,
 
2211
       DATA_TYPE,
 
2212
       CHARACTER_MAXIMUM_LENGTH,
 
2213
       CHARACTER_OCTET_LENGTH,
 
2214
       CHARACTER_SET_NAME,
 
2215
       COLLATION_NAME,
 
2216
       COLUMN_TYPE
 
2217
  FROM information_schema.columns
 
2218
 ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION;
 
2219
 
 
2220
#cleanup
 
2221
DROP USER 'user_1'@'localhost';
 
2222
DROP USER 'user_2'@'localhost';
 
2223
DROP TABLE IF EXISTS t_6_406001;
 
2224
DROP TABLE IF EXISTS t_6_406002;
 
2225
DROP DATABASE IF EXISTS db_datadict;
 
2226
# -------------------------------------------------------------------------------------------------------
 
2227
 
 
2228
let $message= Testcase 3.2.7.1:;
 
2229
--source include/show_msg80.inc
 
2230
 
 
2231
################################################################################
 
2232
# Testcase 3.2.7.1:  Ensure that the INFORMATION_SCHEMA.KEY_COLUMN_USAGE
 
2233
#                    table has the following columns, in the following order:
 
2234
#
 
2235
#                    CONSTRAINT_CATALOG (always shows NULL),
 
2236
#                    CONSTRAINT_SCHEMA (shows the database, or schema, in which
 
2237
#                          an accessible constraint, or index, resides),
 
2238
#                    CONSTRAINT_NAME (shows the name of the accessible
 
2239
#                          constraint),
 
2240
#                    TABLE_CATALOG (always shows NULL),
 
2241
#                    TABLE_SCHEMA (shows the database, or schema, in which the
 
2242
#                          table constrained by that constraint resides),
 
2243
#                    TABLE_NAME (shows the name of the table constrained by the
 
2244
#                           constraint),
 
2245
#                    COLUMN_NAME (shows the name of a column that is the index
 
2246
#                          key, or part of the index key),
 
2247
#                    ORDINAL_POSITION (shows the ordinal position of the column
 
2248
#                          within the constraint index),
 
2249
#                    POSITION_IN_UNIQUE_CONSTRAINT (shows, for a foreign key
 
2250
#                          column, the ordinal position of the referenced
 
2251
#                          column within the referenced unique index;
 
2252
#                          otherwise NULL).
 
2253
# added with 5.0.6:  REFERENCED_TABLE_SCHEMA,
 
2254
#                    REFERENCED_TABLE_NAME,
 
2255
#                    REFERENCED_COLUMN_NAME
 
2256
################################################################################
 
2257
 
 
2258
let $is_table= key_column_usage;
 
2259
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2260
# -------------------------------------------------------------------------------------------------------
 
2261
 
 
2262
let $message= Testcase 3.2.7.2 + 3.2.7.3:;
 
2263
--source include/show_msg80.inc
 
2264
 
 
2265
################################################################################
 
2266
# Testcase 3.2.7.2:  Ensure that the table shows the relevant information on
 
2267
#                    every column, defined to be part of an index key, which is
 
2268
#                    accessible to the current user or to PUBLIC.
 
2269
################################################################################
 
2270
# Testcase 3.2.7.3:  Ensure that the table does not show any information on any
 
2271
#                    indexed column that is not accessible to the current user
 
2272
#                    or PUBLIC.
 
2273
################################################################################
 
2274
 
 
2275
--disable_warnings
 
2276
DROP DATABASE IF EXISTS db_datadict;
 
2277
--enable_warnings
 
2278
CREATE DATABASE db_datadict;
 
2279
 
 
2280
CREATE USER 'user_1'@'localhost';
 
2281
CREATE USER 'user_2'@'localhost';
 
2282
 
 
2283
USE db_datadict;
 
2284
 
 
2285
CREATE TABLE t_40701 (
 
2286
      f1 INT NOT NULL, PRIMARY KEY(f1),
 
2287
      f2 INT,          INDEX f2_ind(f2)
 
2288
      );
 
2289
GRANT SELECT ON t_40701 to 'user_1'@'localhost';
 
2290
 
 
2291
CREATE TABLE t_40702 (
 
2292
      f1 INT NOT NULL, PRIMARY KEY(f1),
 
2293
      f2 INT,          INDEX f2_ind(f2)
 
2294
      );
 
2295
GRANT SELECT ON t_40702 to 'user_2'@'localhost';
 
2296
#FIXME: add foreign keys
 
2297
 
 
2298
FLUSH PRIVILEGES;
 
2299
 
 
2300
let $select= SELECT * FROM information_schema.key_column_usage
 
2301
 ORDER BY constraint_catalog, constraint_schema, constraint_name,
 
2302
          table_catalog, table_schema, table_name, ordinal_position;
 
2303
 
 
2304
# show view of user root
 
2305
eval $select;
 
2306
 
 
2307
# reconnect to mysql with user credential of user u_6_406002_1.
 
2308
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2309
connect (user_7_1, localhost, user_1, , db_datadict);
 
2310
eval $select;
 
2311
 
 
2312
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2313
connect (user_7_2, localhost, user_2, , db_datadict);
 
2314
eval $select;
 
2315
 
 
2316
disconnect user_7_1;
 
2317
disconnect user_7_2;
 
2318
 
 
2319
#cleanup
 
2320
connection default;
 
2321
--source suite/funcs_1/include/show_connection.inc
 
2322
DROP USER 'user_1'@'localhost';
 
2323
DROP USER 'user_2'@'localhost';
 
2324
DROP TABLE t_40701;
 
2325
DROP TABLE t_40702;
 
2326
DROP DATABASE IF EXISTS db_datadict;
 
2327
# -------------------------------------------------------------------------------------------------------
 
2328
 
 
2329
let $message= Testcase 3.2.8.1:;
 
2330
--source include/show_msg80.inc
 
2331
 
 
2332
################################################################################
 
2333
# Testcase 3.2.8.1: Ensure that the INFORMATION_SCHEMA.ROUTINES
 
2334
#                   table has the following columns, in the following order:
 
2335
#
 
2336
#                   SPECIFIC_NAME (shows the name of an accessible stored
 
2337
#                          procedure, or routine),
 
2338
#                   ROUTINE_CATALOG (always shows NULL),
 
2339
#                   ROUTINE_SCHEMA (shows the database, or schema, in which
 
2340
#                          the routine resides),
 
2341
#                   ROUTINE_NAME (shows the same stored procedure name),
 
2342
#                   ROUTINE_TYPE (shows whether the stored procedure is a
 
2343
#                          procedure or a function),
 
2344
#                   DTD_IDENTIFIER (shows, for a function, the complete
 
2345
#                          data type definition of the value the function will
 
2346
#                          return; otherwise NULL),
 
2347
#                   ROUTINE_BODY (shows the language in which the stored
 
2348
#                          procedure is written; currently always SQL),
 
2349
#                   ROUTINE_DEFINITION (shows as much of the routine body as
 
2350
#                          is possible in the allotted space),
 
2351
#                   EXTERNAL_NAME (always shows NULL),
 
2352
#                   EXTERNAL_LANGUAGE (always shows NULL),
 
2353
#                   PARAMETER_STYLE (shows the routine's parameter style;
 
2354
#                          always SQL),
 
2355
#                   IS_DETERMINISTIC (shows whether the routine is
 
2356
#                          deterministic),
 
2357
#                   SQL_DATA_ACCESS (shows the routine's defined
 
2358
#                          sql-data-access clause value),
 
2359
#                   SQL_PATH (always shows NULL),
 
2360
#                   SECURITY_TYPE (shows whether the routine's defined
 
2361
#                          security_type is 'definer' or 'invoker'),
 
2362
#                   CREATED (shows the timestamp of the time the routine was
 
2363
#                          created),
 
2364
#                   LAST_ALTERED (shows the timestamp of the time the routine
 
2365
#                          was last altered),
 
2366
#                   SQL_MODE (shows the sql_mode setting at the time the
 
2367
#                          routine was created),
 
2368
#                   ROUTINE_COMMENT (shows the comment, if any, defined for
 
2369
#                          the routine; otherwise NULL),
 
2370
#                   DEFINER (shows the user who created the routine).
 
2371
################################################################################
 
2372
 
 
2373
let $is_table= routines;
 
2374
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2375
# -------------------------------------------------------------------------------------------------------
 
2376
 
 
2377
let $message= Testcase 3.2.8.2 + 3.2.8.3:;
 
2378
--source include/show_msg80.inc
 
2379
 
 
2380
################################################################################
 
2381
# Testcase 3.2.8.2:  Ensure that the table shows the relevant information on
 
2382
#                    every SQL-invoked routine (i.e. stored procedure) which is
 
2383
#                    accessible to the current user or to PUBLIC.
 
2384
################################################################################
 
2385
# Testcase 3.2.8.3:  Ensure that the table does not show any information on any
 
2386
#                    stored procedure that is not accessible to the current user
 
2387
#                    or PUBLIC.;
 
2388
##############################################################################
 
2389
 
 
2390
--disable_warnings
 
2391
DROP DATABASE IF EXISTS db_datadict;
 
2392
DROP DATABASE IF EXISTS db_datadict_2;
 
2393
--enable_warnings
 
2394
 
 
2395
CREATE DATABASE db_datadict;
 
2396
USE db_datadict;
 
2397
 
 
2398
CREATE USER 'user_1'@'localhost';
 
2399
CREATE USER 'user_2'@'localhost';
 
2400
CREATE USER 'user_3'@'localhost';
 
2401
 
 
2402
CREATE TABLE res_6_408002_1(f1 CHAR(3), f2 TEXT(25), f3 DATE, f4 INT);
 
2403
 
 
2404
INSERT INTO res_6_408002_1(f1, f2, f3, f4)
 
2405
   VALUES('abc', 'xyz', '1989-11-09', 0815);
 
2406
 
 
2407
--disable_warnings
 
2408
DROP PROCEDURE IF EXISTS sp_6_408002_1;
 
2409
--enable_warnings
 
2410
 
 
2411
delimiter //;
 
2412
CREATE PROCEDURE sp_6_408002_1()
 
2413
BEGIN
 
2414
   SELECT * FROM db_datadict.res_6_408002_1;
 
2415
END//
 
2416
delimiter ;//
 
2417
 
 
2418
CREATE DATABASE db_datadict_2;
 
2419
USE db_datadict_2;
 
2420
 
 
2421
CREATE TABLE res_6_408002_2(f1 CHAR(3), f2 TEXT(25), f3 DATE, f4 INT);
 
2422
 
 
2423
INSERT INTO res_6_408002_2(f1, f2, f3, f4)
 
2424
   VALUES('abc', 'xyz', '1990-10-03', 4711);
 
2425
 
 
2426
--disable_warnings
 
2427
DROP PROCEDURE IF EXISTS sp_6_408002_2;
 
2428
--enable_warnings
 
2429
 
 
2430
delimiter //;
 
2431
CREATE PROCEDURE sp_6_408002_2()
 
2432
BEGIN
 
2433
   SELECT * FROM db_datadict_2.res_6_408002_2;
 
2434
END//
 
2435
delimiter ;//
 
2436
 
 
2437
GRANT SELECT  ON db_datadict_2.*         TO 'user_1'@'localhost';
 
2438
GRANT EXECUTE ON db_datadict_2.*         TO 'user_1'@'localhost';
 
2439
 
 
2440
GRANT EXECUTE ON           db_datadict.*               TO 'user_1'@'localhost';
 
2441
GRANT SELECT  ON           db_datadict.*               TO 'user_2'@'localhost';
 
2442
 
 
2443
GRANT EXECUTE ON PROCEDURE db_datadict_2.sp_6_408002_2 TO 'user_2'@'localhost';
 
2444
GRANT EXECUTE ON           db_datadict_2.*             TO 'user_2'@'localhost';
 
2445
FLUSH PRIVILEGES;
 
2446
 
 
2447
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2448
connect (user_8_1, localhost, user_1, , db_datadict);
 
2449
 
 
2450
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
2451
SELECT * FROM information_schema.routines;
 
2452
disconnect user_8_1;
 
2453
 
 
2454
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2455
connect (user_8_2, localhost, user_2, , db_datadict);
 
2456
 
 
2457
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
2458
SELECT * FROM information_schema.routines;
 
2459
disconnect user_8_2;
 
2460
 
 
2461
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2462
connect (user_8_3, localhost, user_3, , test);
 
2463
 
 
2464
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
2465
SELECT * FROM information_schema.routines;
 
2466
disconnect user_8_3;
 
2467
 
 
2468
# clean-up
 
2469
connection default;
 
2470
--source suite/funcs_1/include/show_connection.inc
 
2471
DROP USER 'user_1'@'localhost';
 
2472
DROP USER 'user_2'@'localhost';
 
2473
DROP USER 'user_3'@'localhost';
 
2474
 
 
2475
use db_datadict;
 
2476
DROP TABLE res_6_408002_1;
 
2477
DROP PROCEDURE sp_6_408002_1;
 
2478
 
 
2479
USE db_datadict_2;
 
2480
DROP TABLE res_6_408002_2;
 
2481
DROP PROCEDURE sp_6_408002_2;
 
2482
 
 
2483
USE test;
 
2484
DROP DATABASE db_datadict;
 
2485
DROP DATABASE db_datadict_2;
 
2486
# -------------------------------------------------------------------------------------------------------
 
2487
 
 
2488
let $message= Testcase 3.2.8.4:;
 
2489
--source include/show_msg80.inc
 
2490
 
 
2491
################################################################################
 
2492
# Testcase 3.2.8.4:  Ensure that a stored procedure with a routine body that is
 
2493
#                    too large to fit into the
 
2494
#                    INFORMATION_SCHEMA.ROUTINES.ROUTINE_DEFINITION column
 
2495
#                    correctly shows as much of the information as is possible
 
2496
#                    within the allotted size.
 
2497
################################################################################
 
2498
 
 
2499
--disable_warnings
 
2500
DROP DATABASE IF EXISTS db_datadict;
 
2501
--enable_warnings
 
2502
 
 
2503
CREATE DATABASE db_datadict;
 
2504
USE db_datadict;
 
2505
 
 
2506
create table res_6_408004_1(f1 longtext , f2 mediumint , f3 longblob , f4 real , f5 year);
 
2507
 
 
2508
insert into res_6_408004_1 values ('abc', 98765 , 99999999 , 98765, 10);
 
2509
 
 
2510
--disable_warnings
 
2511
drop procedure if exists sp_6_408004;
 
2512
--enable_warnings
 
2513
 
 
2514
create table res_6_408004_2(f1 longtext , f2 mediumint , f3 longblob , f4 real , f5 year);
 
2515
 
 
2516
insert into res_6_408004_2 values ('abc', 98765 , 99999999 , 98765, 10);
 
2517
 
 
2518
let $message= Checking the max. possible length of (currently) 4 GByte is not possible in this environment here.;
 
2519
--source include/show_msg.inc
 
2520
 
 
2521
delimiter //;
 
2522
create procedure sp_6_408004 ()
 
2523
begin
 
2524
   declare done integer default 0;
 
2525
   declare variable_number_1 longtext;
 
2526
   declare variable_number_2 mediumint;
 
2527
   declare variable_number_3 longblob;
 
2528
   declare variable_number_4 real;
 
2529
   declare variable_number_5 year;
 
2530
   declare cursor_number_1 cursor for select * from res_6_408004_1 limit 0, 10;
 
2531
   declare cursor_number_2 cursor for select * from res_6_408004_1 limit 0, 10;
 
2532
   declare cursor_number_3 cursor for select * from res_6_408004_1 limit 0, 10;
 
2533
   declare cursor_number_4 cursor for select * from res_6_408004_1 limit 0, 10;
 
2534
   declare cursor_number_5 cursor for select * from res_6_408004_1 limit 0, 10;
 
2535
   declare continue handler for sqlstate '02000' set done = 1;
 
2536
   begin
 
2537
      open cursor_number_1;
 
2538
      while done <> 1 do
 
2539
         fetch cursor_number_1 into variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5;
 
2540
         if done <> 0 then
 
2541
                 insert into res_6_408004_2 values (variable_number_1, variable_number_2, variable_number_3,
 
2542
                                 variable_number_4, variable_number_5);
 
2543
         end if;
 
2544
      end while;
 
2545
      begin
 
2546
         begin
 
2547
            set done = 0;
 
2548
            open cursor_number_2;
 
2549
            while done <> 1 do
 
2550
               fetch cursor_number_2 into variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5;
 
2551
               if done <> 0 then
 
2552
                  insert into res_6_408004_2 values(variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5);
 
2553
               end if;
 
2554
            end while;
 
2555
         end;
 
2556
         set done = 0;
 
2557
         open cursor_number_3;
 
2558
         while done <> 1 do
 
2559
            fetch cursor_number_3 into variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5;
 
2560
            if done <> 0 then
 
2561
               insert into res_6_408004_2 values(variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5);
 
2562
            end if;
 
2563
         end while;
 
2564
      end;
 
2565
   end;
 
2566
   begin
 
2567
      set done = 0;
 
2568
      open cursor_number_4;
 
2569
      while done <> 1 do
 
2570
         fetch cursor_number_4 into variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5;
 
2571
         if done <> 0 then
 
2572
            insert into res_6_408004_2 values (variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5);
 
2573
         end if;
 
2574
      end while;
 
2575
   end;
 
2576
   begin
 
2577
      set @a='test row';
 
2578
      select @a;
 
2579
      select @a;
 
2580
      select @a;
 
2581
   end;
 
2582
   begin
 
2583
      set done = 0;
 
2584
      open cursor_number_5;
 
2585
      while done <> 1 do
 
2586
         fetch cursor_number_5 into variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5;
 
2587
         if done <> 0 then
 
2588
            insert into res_6_408004_2 values (variable_number_1, variable_number_2, variable_number_3, variable_number_4, variable_number_5);
 
2589
         end if;
 
2590
      end while;
 
2591
   end;
 
2592
   begin
 
2593
      set @a='test row';
 
2594
      select @a;
 
2595
      select @a;
 
2596
      select @a;
 
2597
   end;
 
2598
end//
 
2599
delimiter ;//
 
2600
 
 
2601
call sp_6_408004 ();
 
2602
select * from res_6_408004_2;
 
2603
 
 
2604
--vertical_results
 
2605
--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
 
2606
SELECT *, LENGTH(routine_definition)
 
2607
  FROM information_schema.routines
 
2608
 WHERE routine_schema = 'db_datadict';
 
2609
--horizontal_results
 
2610
 
 
2611
# clean-up
 
2612
use db_datadict;
 
2613
drop procedure sp_6_408004;
 
2614
drop table res_6_408004_1;
 
2615
drop table res_6_408004_2;
 
2616
use test;
 
2617
drop database db_datadict;
 
2618
# -------------------------------------------------------------------------------------------------------
 
2619
 
 
2620
let $message= Testcase 3.2.9.1:;
 
2621
--source include/show_msg80.inc
 
2622
 
 
2623
################################################################################
 
2624
# Testcase 3.2.9.1: Ensure that the INFORMATION_SCHEMA.SCHEMATA
 
2625
#                   table has the following columns, in the following order:
 
2626
#
 
2627
#                   CATALOG_NAME (always shows NULL),
 
2628
#                   SCHEMA_NAME (shows the name of a database, or schema, on
 
2629
#                          which the current user or PUBLIC has privileges),
 
2630
#                   DEFAULT_CHARACTER_SET_NAME (shows the name of that
 
2631
#                          database's default character set),
 
2632
#                   DEFAULT_COLLATION_NAME (shows the database default
 
2633
#                          collation)
 
2634
#                   SQL_PATH (always shows NULL).
 
2635
################################################################################
 
2636
 
 
2637
let $is_table= schemata;
 
2638
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2639
# -------------------------------------------------------------------------------------------------------
 
2640
 
 
2641
let $message= Testcase 3.2.9.2 + 3.2.9.3:;
 
2642
--source include/show_msg80.inc
 
2643
 
 
2644
################################################################################
 
2645
# Testcase 3.2.9.2:  Ensure that the table shows the relevant information for
 
2646
#                    every database on which the current user or PUBLIC have
 
2647
#                    privileges.
 
2648
################################################################################
 
2649
# Testcase 3.2.9.3:  Ensure that the table does not show any information on any
 
2650
#                    databases on which the current user and PUBLIC have no
 
2651
#                    privileges.
 
2652
################################################################################
 
2653
 
 
2654
CREATE USER 'user_1'@'localhost';
 
2655
CREATE USER 'user_2'@'localhost';
 
2656
CREATE USER 'user_3'@'localhost';
 
2657
 
 
2658
--disable_warnings
 
2659
DROP DATABASE IF EXISTS db_datadict_1;
 
2660
DROP DATABASE IF EXISTS db_datadict_2;
 
2661
--enable_warnings
 
2662
 
 
2663
CREATE DATABASE db_datadict_1;
 
2664
CREATE DATABASE db_datadict_2;
 
2665
 
 
2666
GRANT SELECT ON db_datadict_1.* to 'user_1'@'localhost';
 
2667
GRANT SELECT ON db_datadict_2.* to 'user_2'@'localhost';
 
2668
 
 
2669
FLUSH PRIVILEGES;
 
2670
 
 
2671
# shows db_1
 
2672
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2673
connect (user_9_1, localhost, user_1, , db_datadict_1);
 
2674
 
 
2675
SELECT COUNT(*) FROM information_schema.schemata;
 
2676
SELECT * FROM information_schema.schemata;
 
2677
disconnect user_9_1;
 
2678
 
 
2679
 
 
2680
# shows db_2
 
2681
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2682
connect (user_9_2, localhost, user_2, , db_datadict_2);
 
2683
 
 
2684
SELECT COUNT(*) FROM information_schema.schemata;
 
2685
SELECT * FROM information_schema.schemata;
 
2686
disconnect user_9_2;
 
2687
 
 
2688
 
 
2689
# shows neither db_1 nor db_2
 
2690
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2691
connect (user_9_3, localhost, user_3, , test);
 
2692
 
 
2693
SELECT COUNT(*) FROM information_schema.schemata;
 
2694
SELECT * FROM information_schema.schemata;
 
2695
disconnect user_9_3;
 
2696
 
 
2697
 
 
2698
# clean-up
 
2699
connection default;
 
2700
--source suite/funcs_1/include/show_connection.inc
 
2701
DROP USER 'user_1'@'localhost';
 
2702
DROP USER 'user_2'@'localhost';
 
2703
DROP USER 'user_3'@'localhost';
 
2704
DROP DATABASE db_datadict_1;
 
2705
DROP DATABASE db_datadict_2;
 
2706
# -------------------------------------------------------------------------------------------------------
 
2707
 
 
2708
let $message= Testcase 3.2.10.1:;
 
2709
--source include/show_msg80.inc
 
2710
 
 
2711
################################################################################
 
2712
# Testcase 3.2.10.1: Ensure that the INFORMATION_SCHEMA.TABLE_CONSTRAINTS
 
2713
#                    table has the following columns, in the following order:
 
2714
#
 
2715
#                    CONSTRAINT_CATALOG (always shows NULL),
 
2716
#                    CONSTRAINT_SCHEMA (shows the database, or schema, in which
 
2717
#                          a constraint an accessible table resides),
 
2718
#                    CONSTRAINT_NAME (shows the name of a constraint defined on
 
2719
#                          an accessible table),
 
2720
#                    TABLE_SCHEMA (shows the database, or schema, in which the
 
2721
#                          table resides),
 
2722
#                    TABLE_NAME (shows the name of the table),
 
2723
#                    CONSTRAINT_TYPE (shows the type of the constraint; either
 
2724
#                          'primary key', 'foreign key', 'unique', 'check').
 
2725
################################################################################
 
2726
 
 
2727
let $is_table= table_constraints;
 
2728
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2729
# -------------------------------------------------------------------------------------------------------
 
2730
 
 
2731
let $message= Testcase 3.2.10.2 + 3.2.10.3:;
 
2732
--source include/show_msg80.inc
 
2733
 
 
2734
################################################################################
 
2735
# Testcase 3.2.10.2: Ensure that the table shows the relevant information on all
 
2736
#                    constraints defined on every table for which the current
 
2737
#                    user or PUBLIC have privileges.
 
2738
################################################################################
 
2739
# Testcase 3.2.10.3: Ensure that the table does not show any information on
 
2740
#                    constraints defined on any table for which the current user
 
2741
#                    and PUBLIC have no privileges.
 
2742
################################################################################
 
2743
 
 
2744
CREATE USER 'user_1'@'localhost';
 
2745
CREATE USER 'user_2'@'localhost';
 
2746
 
 
2747
--disable_warnings
 
2748
DROP DATABASE IF EXISTS db_datadict;
 
2749
DROP DATABASE IF EXISTS db_datadict_2;
 
2750
--enable_warnings
 
2751
 
 
2752
CREATE DATABASE db_datadict;
 
2753
CREATE DATABASE db_datadict_2;
 
2754
 
 
2755
USE db_datadict;
 
2756
 
 
2757
CREATE TABLE res_6_401003_1(f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2));
 
2758
 
 
2759
USE db_datadict_2;
 
2760
 
 
2761
CREATE TABLE res_6_401003_2(f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2));
 
2762
 
 
2763
GRANT SELECT ON db_datadict.res_6_401003_1 TO 'user_1'@'localhost';
 
2764
GRANT SELECT ON db_datadict_2.res_6_401003_2 TO 'user_2'@'localhost';
 
2765
 
 
2766
FLUSH PRIVILEGES;
 
2767
 
 
2768
 
 
2769
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2770
connect (user_10_1, localhost, user_1, , db_datadict);
 
2771
 
 
2772
SELECT * FROM information_schema.table_constraints;
 
2773
SELECT COUNT(*) FROM information_schema.table_constraints;
 
2774
disconnect user_10_1;
 
2775
 
 
2776
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2777
connect (user_10_2, localhost, user_2, , db_datadict_2);
 
2778
 
 
2779
SELECT * FROM information_schema.table_constraints;
 
2780
SELECT COUNT(*) FROM information_schema.table_constraints;
 
2781
disconnect user_10_2;
 
2782
 
 
2783
# clean-up
 
2784
connection default;
 
2785
use db_datadict;
 
2786
--source suite/funcs_1/include/show_connection.inc
 
2787
DROP USER 'user_1'@'localhost';
 
2788
DROP USER 'user_2'@'localhost';
 
2789
DROP TABLE res_6_401003_1;
 
2790
USE db_datadict_2;
 
2791
DROP TABLE res_6_401003_2;
 
2792
USE test;
 
2793
DROP DATABASE db_datadict;
 
2794
DROP DATABASE db_datadict_2;
 
2795
# -------------------------------------------------------------------------------------------------------
 
2796
 
 
2797
let $message= Testcase 3.2.11.1:;
 
2798
--source include/show_msg80.inc
 
2799
 
 
2800
################################################################################
 
2801
# Testcase 3.2.11.1: Ensure that the INFORMATION_SCHEMA.TABLE_PRIVILEGES
 
2802
#                    table has the following columns, in the following order:
 
2803
#
 
2804
#                    GRANTEE (shows the name of a user who has either granted,
 
2805
#                          or been granted a table privilege),
 
2806
#                    TABLE_CATALOG (always shows NULL),
 
2807
#                    TABLE_SCHEMA (shows the name of the schema, or database,
 
2808
#                          in which the table for which a privilege has been
 
2809
#                          granted resides),
 
2810
#                    TABLE_NAME (shows the name of the table),
 
2811
#                    PRIVILEGE_TYPE (shows the type of privilege that was
 
2812
#                          granted; must be either SELECT, INSERT, UPDATE,
 
2813
#                          DELETE, REFERENCES, ALTER, INDEX, DROP, or CREATE
 
2814
#                          VIEW),
 
2815
#                    IS_GRANTABLE (shows whether that privilege was granted
 
2816
#                          WITH GRANT OPTION).
 
2817
################################################################################
 
2818
 
 
2819
let $is_table= table_privileges;
 
2820
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2821
# -------------------------------------------------------------------------------------------------------
 
2822
 
 
2823
let $message= Testcase 3.2.11.2 + 3.2.11.3 + 3.2.11.4:;
 
2824
--source include/show_msg80.inc
 
2825
 
 
2826
################################################################################
 
2827
# Testcase 3.2.11.2: Ensure that the table shows the relevant information on
 
2828
#                    every table privilege which has been granted to the current
 
2829
#                    user or PUBLIC, or which was granted by the current user.
 
2830
################################################################################
 
2831
# Testcase 3.2.11.3: Ensure that the table does not show any information on any
 
2832
#                    table privilege which was granted to any user other than
 
2833
#                    the current user or PUBLIC, or which was granted by any
 
2834
#                    user other than the current user.
 
2835
################################################################################
 
2836
# Testcase 3.2.11.4: Ensure that the table does not show any information on any
 
2837
#                    privileges that are not table privileges for the current
 
2838
#                    user.
 
2839
################################################################################
 
2840
 
 
2841
--disable_warnings
 
2842
DROP DATABASE IF EXISTS db_datadict;
 
2843
--enable_warnings
 
2844
 
 
2845
create database db_datadict;
 
2846
 
 
2847
CREATE USER 'user_1'@'localhost';
 
2848
GRANT CREATE, SELECT ON db_datadict.* TO 'user_1'@'localhost' WITH GRANT OPTION;
 
2849
CREATE USER 'user_2'@'localhost';
 
2850
CREATE USER 'user_3'@'localhost';
 
2851
 
 
2852
use db_datadict;
 
2853
 
 
2854
create table tb1(f1 int, f2 int, f3 int);
 
2855
 
 
2856
grant select on db_datadict.tb1 to 'user_1'@'localhost';
 
2857
GRANT ALL    on db_datadict.tb1 to 'user_2'@'localhost' WITH GRANT OPTION;
 
2858
 
 
2859
FLUSH PRIVILEGES;
 
2860
 
 
2861
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2862
connect (user_11_1, localhost, user_1, , db_datadict);
 
2863
 
 
2864
CREATE TABLE tb3 (f1 TEXT);
 
2865
GRANT SELECT ON db_datadict.tb3 to 'user_3'@'localhost';
 
2866
 
 
2867
SELECT * FROM information_schema.table_privileges
 
2868
 WHERE table_name LIKE 'tb%';
 
2869
 
 
2870
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2871
connect (user_11_2, localhost, user_2, , db_datadict);
 
2872
 
 
2873
# we see only table privileges for this user, and not any other privileges
 
2874
SELECT * FROM information_schema.table_privileges;
 
2875
 
 
2876
SELECT USER(), COUNT(*)
 
2877
  FROM information_schema.table_privileges
 
2878
 WHERE grantee = USER();
 
2879
 
 
2880
SELECT USER(), COUNT(*)
 
2881
  FROM information_schema.table_privileges
 
2882
 WHERE grantee = "'user_2'@'localhost'";
 
2883
 
 
2884
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2885
connect (user_11_3, localhost, user_3, , db_datadict);
 
2886
 
 
2887
# we see only table privileges for this user, and not any other privileges
 
2888
SELECT * FROM information_schema.table_privileges;
 
2889
 
 
2890
connection default;
 
2891
--source suite/funcs_1/include/show_connection.inc
 
2892
 
 
2893
# we see only 'public' table privileges
 
2894
SELECT * FROM information_schema.table_privileges;
 
2895
 
 
2896
# clean-up
 
2897
connection default;
 
2898
--source suite/funcs_1/include/show_connection.inc
 
2899
disconnect user_11_1;
 
2900
disconnect user_11_2;
 
2901
disconnect user_11_3;
 
2902
DROP USER 'user_1'@'localhost';
 
2903
DROP USER 'user_2'@'localhost';
 
2904
DROP USER 'user_3'@'localhost';
 
2905
drop table db_datadict.tb1;
 
2906
drop table db_datadict.tb3;
 
2907
use test;
 
2908
drop database db_datadict;
 
2909
# -------------------------------------------------------------------------------------------------------
 
2910
 
 
2911
let $message= Testcase 3.2.12.1:;
 
2912
--source include/show_msg80.inc
 
2913
 
 
2914
################################################################################
 
2915
# Testcase 3.2.12.1: Ensure that the INFORMATION_SCHEMA.TABLES
 
2916
#                    table has the following columns, in the following order:
 
2917
#
 
2918
#                    TABLE_CATALOG (always shows NULL),
 
2919
#                    TABLE_SCHEMA (shows the name of the database, or schema,
 
2920
#                          in which an accessible table resides),
 
2921
#                    TABLE_NAME (shows the name of a table which the current
 
2922
#                          user may access),
 
2923
#                    TABLE_TYPE (shows whether the table is a BASE TABLE, a
 
2924
#                          TEMPORARY table, or a VIEW),
 
2925
#                    ENGINE (shows the storage engine used for the table),
 
2926
#                    VERSION (shows the version number of the table's .frm
 
2927
#                          file),
 
2928
#                    ROW_FORMAT (shows the table's row storage format; either
 
2929
#                          FIXED, DYNAMIC or COMPRESSED),
 
2930
#                    TABLE_ROWS (shows the number of rows in the table),
 
2931
#                    AVG_ROW_LENGTH (shows the average length of the table's
 
2932
#                          rows),
 
2933
#                    DATA_LENGTH (shows the length of the table's data file),
 
2934
#                    MAX_DATA_LENGTH (shows the maximum length of the table's
 
2935
#                          data file),
 
2936
#                    INDEX_LENGTH (shows the length of the index file
 
2937
#                          associated with the table),
 
2938
#                    DATA_FREE (shows the number of allocated, unused bytes),
 
2939
#                    AUTO_INCREMENT (shows the next AUTO_INCREMENT value, where
 
2940
#                          applicable),
 
2941
#                    CREATE_TIME (shows the timestamp of the time the table was
 
2942
#                          created),
 
2943
#                    UPDATE_TIME (shows the timestamp of the time the table's
 
2944
#                          data file was last updated),
 
2945
#                    CHECK_TIME (shows the timestamp of the time the table was
 
2946
#                          last checked),
 
2947
#                    TABLE_COLLATION (shows the table's default collation),
 
2948
#                    CHECKSUM (shows the live checksum value for the table, if
 
2949
#                          any; otherwise NULL),
 
2950
#                    CREATE_OPTIONS (shows any additional options used in the
 
2951
#                          table's definition; otherwise NULL),
 
2952
#                    TABLE_COMMENT (shows the comment added to the table's
 
2953
#                          definition; otherwise NULL).
 
2954
################################################################################
 
2955
 
 
2956
let $is_table= tables;
 
2957
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
2958
# -------------------------------------------------------------------------------------------------------
 
2959
 
 
2960
let $message= Testcase 3.2.12.2 + 3.2.12.3:;
 
2961
--source include/show_msg80.inc
 
2962
 
 
2963
################################################################################
 
2964
# Testcase 3.2.12.2: Ensure that the table shows the relevant information on
 
2965
#                    every base table and view on which the current user or
 
2966
#                    PUBLIC has privileges.
 
2967
################################################################################
 
2968
# Testcase 3.2.12.3: Ensure that the table does not show any information on any
 
2969
#                    tables on which the current user and public have no
 
2970
#                    privileges.
 
2971
################################################################################
 
2972
 
 
2973
--disable_warnings
 
2974
DROP DATABASE IF EXISTS db_datadict;
 
2975
--enable_warnings
 
2976
 
 
2977
create database db_datadict;
 
2978
 
 
2979
CREATE USER 'user_1'@'localhost';
 
2980
GRANT CREATE, CREATE VIEW, INSERT, SELECT ON db_datadict.*
 
2981
   TO 'user_1'@'localhost' WITH GRANT OPTION;
 
2982
CREATE USER 'user_2'@'localhost';
 
2983
CREATE USER 'user_3'@'localhost';
 
2984
 
 
2985
use db_datadict;
 
2986
 
 
2987
create table tb1(f1 int, f2 int, f3 int);
 
2988
 
 
2989
grant select on db_datadict.tb1 to 'user_1'@'localhost';
 
2990
GRANT ALL    on db_datadict.tb1 to 'user_2'@'localhost' WITH GRANT OPTION;
 
2991
 
 
2992
FLUSH PRIVILEGES;
 
2993
 
 
2994
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
2995
connect (user_12_1, localhost, user_1, , db_datadict);
 
2996
 
 
2997
# tb2 is not granted to anyone
 
2998
CREATE TABLE tb2 (f1 DECIMAL);
 
2999
CREATE TABLE tb3 (f1 TEXT);
 
3000
GRANT SELECT ON db_datadict.tb3 to 'user_3'@'localhost';
 
3001
GRANT INSERT ON db_datadict.tb3 to 'user_2'@'localhost';
 
3002
 
 
3003
CREATE VIEW v3 AS SELECT * FROM tb3;
 
3004
GRANT SELECT ON db_datadict.v3 to 'user_3'@'localhost';
 
3005
 
 
3006
#FIXME 3.2.12: we split the "SELECT * FROM tables" in two parts until
 
3007
#FIXME 3.2.12: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
3008
#FIXME 3.2.12: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
3009
#FIXME 3.2.12: with 'less' replace
 
3010
#  9 AVG_ROW_LENGTH
 
3011
# 10 DATA_LENGTH
 
3012
# 11 MAX_DATA_LENGTH
 
3013
# 12 INDEX_LENGTH
 
3014
# 13 DATA_FREE
 
3015
# 15 CREATE_TIME
 
3016
# 16 UPDATE_TIME
 
3017
# 20 CREATE_OPTIONS
 
3018
if ($have_bug_11589)
 
3019
{
 
3020
--disable_ps_protocol
 
3021
}
 
3022
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
3023
SELECT * FROM information_schema.tables
 
3024
 WHERE table_schema = 'information_schema';
 
3025
#  9 AVG_ROW_LENGTH
 
3026
# 10 DATA_LENGTH
 
3027
# 11 MAX_DATA_LENGTH
 
3028
# 12 INDEX_LENGTH
 
3029
# 13 DATA_FREE
 
3030
# 15 CREATE_TIME
 
3031
# 16 UPDATE_TIME
 
3032
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
3033
SELECT * FROM information_schema.tables
 
3034
 WHERE NOT( table_schema = 'information_schema');
 
3035
--enable_ps_protocol
 
3036
 
 
3037
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3038
connect (user_12_2, localhost, user_2, , db_datadict);
 
3039
 
 
3040
# we see only tables for this user, and not any other
 
3041
#FIXME 3.2.12: we split the "SELECT * FROM tables" in two parts until
 
3042
#FIXME 3.2.12: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
3043
#FIXME 3.2.12: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
3044
#FIXME 3.2.12: with 'less' replace
 
3045
#  9 AVG_ROW_LENGTH
 
3046
# 10 DATA_LENGTH
 
3047
# 11 MAX_DATA_LENGTH
 
3048
# 12 INDEX_LENGTH
 
3049
# 13 DATA_FREE
 
3050
# 15 CREATE_TIME
 
3051
# 16 UPDATE_TIME
 
3052
# 20 CREATE_OPTIONS
 
3053
if ($have_bug_11589)
 
3054
{
 
3055
--disable_ps_protocol
 
3056
}
 
3057
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
3058
SELECT * FROM information_schema.tables
 
3059
 WHERE table_schema = 'information_schema';
 
3060
#  9 AVG_ROW_LENGTH
 
3061
# 10 DATA_LENGTH
 
3062
# 11 MAX_DATA_LENGTH
 
3063
# 12 INDEX_LENGTH
 
3064
# 13 DATA_FREE
 
3065
# 15 CREATE_TIME
 
3066
# 16 UPDATE_TIME
 
3067
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
3068
SELECT * FROM information_schema.tables
 
3069
 WHERE NOT( table_schema = 'information_schema');
 
3070
--enable_ps_protocol
 
3071
 
 
3072
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3073
connect (user_12_3, localhost, user_3, , db_datadict);
 
3074
 
 
3075
# we see only tables for this user, and not any other
 
3076
#
 
3077
#FIXME 3.2.12: we split the "SELECT * FROM tables" in two parts until
 
3078
#FIXME 3.2.12: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
3079
#FIXME 3.2.12: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
3080
#FIXME 3.2.12: with 'less' replace
 
3081
#  9 AVG_ROW_LENGTH
 
3082
# 10 DATA_LENGTH
 
3083
# 11 MAX_DATA_LENGTH
 
3084
# 12 INDEX_LENGTH
 
3085
# 13 DATA_FREE
 
3086
# 15 CREATE_TIME
 
3087
# 16 UPDATE_TIME
 
3088
# 20 CREATE_OPTIONS
 
3089
if ($have_bug_11589)
 
3090
{
 
3091
--disable_ps_protocol
 
3092
}
 
3093
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
3094
SELECT * FROM information_schema.tables
 
3095
 WHERE table_schema = 'information_schema';
 
3096
#  9 AVG_ROW_LENGTH
 
3097
# 10 DATA_LENGTH
 
3098
# 11 MAX_DATA_LENGTH
 
3099
# 12 INDEX_LENGTH
 
3100
# 13 DATA_FREE
 
3101
# 15 CREATE_TIME
 
3102
# 16 UPDATE_TIME
 
3103
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
3104
SELECT * FROM information_schema.tables
 
3105
 WHERE NOT( table_schema = 'information_schema');
 
3106
--enable_ps_protocol
 
3107
 
 
3108
connection default;
 
3109
--source suite/funcs_1/include/show_connection.inc
 
3110
 
 
3111
# we see only 'public' tables
 
3112
#
 
3113
#FIXME 3.2.12: we split the "SELECT * FROM tables" in two parts until
 
3114
#FIXME 3.2.12: Bug #12397: wrong values shown in column CREATE_OPTIONS of
 
3115
#FIXME 3.2.12: INFORMATION_SCHEMA.TABLES is solved, one with 'more' and one
 
3116
#FIXME 3.2.12: with 'less' replace
 
3117
#  9 AVG_ROW_LENGTH
 
3118
# 10 DATA_LENGTH
 
3119
# 11 MAX_DATA_LENGTH
 
3120
# 12 INDEX_LENGTH
 
3121
# 13 DATA_FREE
 
3122
# 15 CREATE_TIME
 
3123
# 16 UPDATE_TIME
 
3124
# 20 CREATE_OPTIONS
 
3125
if ($have_bug_11589)
 
3126
{
 
3127
--disable_ps_protocol
 
3128
}
 
3129
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"  20 "#CO#"
 
3130
SELECT * FROM information_schema.tables
 
3131
 WHERE table_schema = 'information_schema';
 
3132
#  9 AVG_ROW_LENGTH
 
3133
# 10 DATA_LENGTH
 
3134
# 11 MAX_DATA_LENGTH
 
3135
# 12 INDEX_LENGTH
 
3136
# 13 DATA_FREE
 
3137
# 15 CREATE_TIME
 
3138
# 16 UPDATE_TIME
 
3139
--replace_column  9 "#ARL#"  10 "#DL#"  11 "#MDL#"  12 "#IL#"  13 "#DF#"  15 "YYYY-MM-DD hh:mm:ss"  16 "YYYY-MM-DD hh:mm:ss"
 
3140
SELECT * FROM information_schema.tables
 
3141
 WHERE NOT( table_schema = 'information_schema');
 
3142
--enable_ps_protocol
 
3143
 
 
3144
# clean-up
 
3145
disconnect user_12_1;
 
3146
disconnect user_12_2;
 
3147
disconnect user_12_3;
 
3148
DROP USER 'user_1'@'localhost';
 
3149
DROP USER 'user_2'@'localhost';
 
3150
DROP USER 'user_3'@'localhost';
 
3151
DROP TABLE db_datadict.tb1;
 
3152
DROP TABLE db_datadict.tb3;
 
3153
DROP VIEW db_datadict.v3;
 
3154
USE test;
 
3155
DROP DATABASE db_datadict;
 
3156
# -------------------------------------------------------------------------------------------------------
 
3157
 
 
3158
let $message= Testcase 3.2.13.1:;
 
3159
--source include/show_msg80.inc
 
3160
 
 
3161
################################################################################
 
3162
# Testcase 3.2.13.1: Ensure that the INFORMATION_SCHEMA.VIEWS
 
3163
#                    table has the following columns, in the following order:
 
3164
#
 
3165
#                    TABLE_CATALOG (always shows NULL),
 
3166
#                    TABLE_SCHEMA (shows the database, or schema, in which an
 
3167
#                          accessible view resides),
 
3168
#                    TABLE_NAME (shows the name of a view accessible to the
 
3169
#                          current user),
 
3170
#                    VIEW_DEFINITION (shows the SELECT statement that makes
 
3171
#                          up the view's definition),
 
3172
#                    CHECK_OPTION (shows the value of the WITH CHECK OPTION
 
3173
#                          clause used to define the view, either NONE, LOCAL
 
3174
#                          or CASCADED),
 
3175
#                    IS_UPDATABLE (shows whether the view is an updatable
 
3176
#                          view),
 
3177
#                    DEFINER (added with 5.0.14),
 
3178
#                    SECURITY_TYPE (added with 5.0.14).
 
3179
################################################################################
 
3180
 
 
3181
let $is_table= views;
 
3182
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3183
# -------------------------------------------------------------------------------------------------------
 
3184
 
 
3185
let $message= Testcase 3.2.13.2 + 3.2.13.3:;
 
3186
--source include/show_msg80.inc
 
3187
 
 
3188
################################################################################
 
3189
# Testcase 3.2.13.2: Ensure that the table shows the relevant information on
 
3190
#                    every view for which the current user or PUBLIC has the
 
3191
#                    SHOW CREATE VIEW privilege.
 
3192
################################################################################
 
3193
# Testcase 3.2.13.3: Ensure that the table does not show any information on any
 
3194
#                    views for which the current user and PUBLIC have no SHOW
 
3195
#                    CREATE VIEW privilege.
 
3196
################################################################################
 
3197
 
 
3198
--disable_warnings
 
3199
DROP DATABASE IF EXISTS db_datadict;
 
3200
--enable_warnings
 
3201
 
 
3202
CREATE DATABASE db_datadict;
 
3203
 
 
3204
CREATE USER 'user_1'@'localhost';
 
3205
CREATE USER 'user_2'@'localhost';
 
3206
CREATE USER 'user_no_views'@'localhost';
 
3207
USE db_datadict;
 
3208
 
 
3209
CREATE TABLE tb_401302(f1 INT, f2 INT, f3 INT);
 
3210
CREATE VIEW v_granted_to_1 AS SELECT * FROM tb_401302;
 
3211
CREATE VIEW v_granted_glob AS SELECT f2, f3 FROM tb_401302;
 
3212
 
 
3213
GRANT SELECT ON db_datadict.tb_401302 TO 'user_1'@'localhost';
 
3214
GRANT SELECT ON db_datadict.v_granted_to_1 TO 'user_1'@'localhost';
 
3215
GRANT SHOW VIEW, CREATE VIEW ON db_datadict.* TO 'user_2'@'localhost';
 
3216
 
 
3217
FLUSH PRIVILEGES;
 
3218
 
 
3219
SELECT * FROM information_schema.views;
 
3220
 
 
3221
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3222
connect (user_13_1, localhost, user_1, , test);
 
3223
 
 
3224
SELECT * FROM information_schema.views;
 
3225
 
 
3226
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3227
connect (user_13_2, localhost, user_2, , test);
 
3228
 
 
3229
SELECT * FROM information_schema.views;
 
3230
 
 
3231
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3232
connect (user_no_views, localhost, user_no_views, , test);
 
3233
 
 
3234
SELECT * FROM information_schema.views;
 
3235
 
 
3236
# clean-up
 
3237
connection default;
 
3238
--source suite/funcs_1/include/show_connection.inc
 
3239
disconnect user_13_1;
 
3240
disconnect user_13_2;
 
3241
disconnect user_no_views;
 
3242
USE db_datadict;
 
3243
DROP USER 'user_1'@'localhost';
 
3244
DROP USER 'user_2'@'localhost';
 
3245
DROP USER 'user_no_views'@'localhost';
 
3246
DROP VIEW v_granted_to_1;
 
3247
DROP TABLE tb_401302;
 
3248
DROP VIEW v_granted_glob;
 
3249
USE test;
 
3250
DROP DATABASE db_datadict;
 
3251
# -------------------------------------------------------------------------------------------------------
 
3252
 
 
3253
let $message= Testcase 3.2.14.1:;
 
3254
--source include/show_msg80.inc
 
3255
 
 
3256
################################################################################
 
3257
# Testcase 3.2.14.1: Ensure that the INFORMATION_SCHEMA.STATISTICS
 
3258
#                    table has the following columns, in the following order:
 
3259
#
 
3260
#                    TABLE_CATALOG (always shows NULL),
 
3261
#                    TABLE_SCHEMA (shows the database, or schema, in which a
 
3262
#                          table indexed by an accessible index resides),
 
3263
#                    TABLE_NAME (shows the name of  the indexed table),
 
3264
#                    NON_UNIQUE (shows whether the index may contain duplicate
 
3265
#                          values; 0 if it cannot, 1 if it can),
 
3266
#                    INDEX_SCHEMA (shows the database, or schema, in which an
 
3267
#                          accessible index resides),
 
3268
#                    INDEX_NAME (shows the name of an index which the current
 
3269
#                          user may access),
 
3270
#                    SEQ_IN_INDEX (shows the ordinal position of an indexed
 
3271
#                          column within the index),
 
3272
#                    COLUMN_NAME (shows the name of a column that comprises
 
3273
#                          some, or all, of an index key),
 
3274
#                    COLLATION (shows how the column is sorted in the index;
 
3275
#                          either A for ascending or NULL for unsorted
 
3276
#                          columns),
 
3277
#                    CARDINALITY (shows the number of unique values in the
 
3278
#                          index),
 
3279
#                    SUB_PART (shows the number of indexed characters if the
 
3280
#                          index is a prefix index),
 
3281
#                    PACKED (shows how the index key is packed),
 
3282
#                    NULLABLE (shows whether the index column may contain NULL
 
3283
#                          values),
 
3284
#                    INDEX_TYPE (shows the index type; either BTREE, FULLTEXT,
 
3285
#                          HASH or RTREE),
 
3286
#                    COMMENT (shows a comment on the index, if any).
 
3287
################################################################################
 
3288
 
 
3289
let $is_table= statistics;
 
3290
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3291
# -------------------------------------------------------------------------------------------------------
 
3292
 
 
3293
let $message= Testcase 3.2.14.2 + 3.2.14.3:;
 
3294
--source include/show_msg80.inc
 
3295
 
 
3296
################################################################################
 
3297
# Testcase 3.2.14.2: Ensure that the table shows the relevant information on
 
3298
#                    every index which the current user or PUBLIC may access
 
3299
#                    (usually because privileges on the indexed table have been
 
3300
#                    granted).
 
3301
################################################################################
 
3302
# Testcase 3.2.14.3: Ensure that the table does not show any information on any
 
3303
#                    indexes which the current user and PUBLIC may not access.
 
3304
################################################################################
 
3305
 
 
3306
--disable_warnings
 
3307
DROP DATABASE IF EXISTS db_datadict;
 
3308
DROP DATABASE IF EXISTS db_datadict_2;
 
3309
--enable_warnings
 
3310
 
 
3311
CREATE DATABASE db_datadict;
 
3312
CREATE DATABASE db_datadict_2;
 
3313
 
 
3314
CREATE USER 'user_1'@'localhost';
 
3315
CREATE USER 'user_2'@'localhost';
 
3316
USE db_datadict;
 
3317
 
 
3318
create table tb_6_401402_1(f1 int not null, primary key(f1), f2 int, index f2_ind(f2));
 
3319
create table tb_6_401402_2(f1 int not null, primary key(f1), f2 int, index f2_ind(f2));
 
3320
grant select on db_datadict.tb_6_401402_1 to 'user_1'@'localhost' WITH GRANT OPTION;
 
3321
 
 
3322
USE db_datadict_2;
 
3323
 
 
3324
create table tb_2_1(f1 int not null, primary key(f1), f2 int, index f2_ind(f2));
 
3325
create table tb_2_2(f1 int not null, primary key(f1), f2 int, index f2_ind(f2));
 
3326
grant select on db_datadict_2.tb_2_1 to 'user_1'@'localhost';
 
3327
 
 
3328
FLUSH PRIVILEGES;
 
3329
 
 
3330
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3331
connect (user_14_1, localhost, user_1, , test);
 
3332
SELECT * FROM information_schema.statistics;
 
3333
 
 
3334
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3335
connect (user_14_2, localhost, user_2, , test);
 
3336
SELECT * FROM information_schema.statistics;
 
3337
 
 
3338
connection default;
 
3339
--source suite/funcs_1/include/show_connection.inc
 
3340
REVOKE SELECT ON db_datadict.tb_6_401402_1 FROM 'user_1'@'localhost';
 
3341
SELECT * FROM information_schema.statistics;
 
3342
 
 
3343
# nothing visible for user_1
 
3344
connection user_14_1;
 
3345
--source suite/funcs_1/include/show_connection.inc
 
3346
SELECT * FROM information_schema.statistics;
 
3347
 
 
3348
# no changes visible for user_2
 
3349
connection user_14_2;
 
3350
--source suite/funcs_1/include/show_connection.inc
 
3351
SELECT * FROM information_schema.statistics;
 
3352
 
 
3353
# cleanup
 
3354
connection default;
 
3355
--source suite/funcs_1/include/show_connection.inc
 
3356
disconnect user_14_1;
 
3357
disconnect user_14_2;
 
3358
USE db_datadict;
 
3359
DROP USER 'user_1'@'localhost';
 
3360
DROP USER 'user_2'@'localhost';
 
3361
DROP TABLE tb_6_401402_1;
 
3362
DROP TABLE tb_6_401402_2;
 
3363
USE test;
 
3364
DROP DATABASE db_datadict;
 
3365
# -------------------------------------------------------------------------------------------------------
 
3366
 
 
3367
let $message= Testcase 3.2.15.1:;
 
3368
--source include/show_msg80.inc
 
3369
 
 
3370
################################################################################
 
3371
# Testcase 3.2.15.1: Ensure that the INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
 
3372
#                    table has the following columns, in the following order:
 
3373
#
 
3374
#                    GRANTEE (shows a user to whom a schema privilege has been
 
3375
#                          granted),
 
3376
#                    TABLE_CATALOG (always shows NULL),
 
3377
#                    TABLE_SCHEMA (shows the name of the database, or schema,
 
3378
#                          on which the privilege has been granted),
 
3379
#                    PRIVILEGE_TYPE (shows the granted privilege),
 
3380
#                    IS_GRANTABLE (shows whether the privilege was granted WITH
 
3381
#                          GRANT OPTION).
 
3382
################################################################################
 
3383
 
 
3384
let $is_table= schema_privileges;
 
3385
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3386
# -------------------------------------------------------------------------------------------------------
 
3387
 
 
3388
let $message= Testcase 3.2.15.2:;
 
3389
--source include/show_msg80.inc
 
3390
 
 
3391
################################################################################
 
3392
# Testcase 3.2.15.2: Ensure that the table shows the relevant information on
 
3393
#                    every schema-level privilege which has been granted to the
 
3394
#                    current user or to PUBLIC, or has been granted by the
 
3395
#                    current user.
 
3396
################################################################################
 
3397
 
 
3398
--disable_warnings
 
3399
DROP DATABASE IF EXISTS db_datadict;
 
3400
DROP DATABASE IF EXISTS db_datadict_2;
 
3401
--enable_warnings
 
3402
 
 
3403
create database db_datadict;
 
3404
create database db_datadict_2;
 
3405
 
 
3406
CREATE USER 'u_6_401502'@'localhost';
 
3407
 
 
3408
use db_datadict;
 
3409
 
 
3410
create table res_6_401502(f1 int, f2 int, f3 int);
 
3411
grant insert on db_datadict.* to 'u_6_401502'@'localhost';
 
3412
 
 
3413
FLUSH PRIVILEGES;
 
3414
 
 
3415
SELECT * FROM information_schema.schema_privileges;
 
3416
 
 
3417
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3418
connect (u_6_401502, localhost, u_6_401502, , test);
 
3419
 
 
3420
SELECT * FROM information_schema.schema_privileges;
 
3421
 
 
3422
disconnect u_6_401502;
 
3423
 
 
3424
# clean-up
 
3425
 
 
3426
connection default;
 
3427
use db_datadict;
 
3428
--source suite/funcs_1/include/show_connection.inc
 
3429
DROP USER 'u_6_401502'@'localhost';
 
3430
drop table res_6_401502;
 
3431
use test;
 
3432
drop database db_datadict;
 
3433
drop database db_datadict_2;
 
3434
# -------------------------------------------------------------------------------------------------------
 
3435
 
 
3436
let $message= Testcase 3.2.15.3 + 3.2.15.4:;
 
3437
--source include/show_msg80.inc
 
3438
 
 
3439
################################################################################
 
3440
# Testcase 3.2.15.3: Ensure that the table does not show any information on any
 
3441
#                    schema-level privileges which have been granted to users
 
3442
#                    other than the current user or to PUBLIC, or that have been
 
3443
#                    granted by any user other than the current user.
 
3444
################################################################################
 
3445
# Testcase 3.2.15.4: Ensure that the table does not show any information on any
 
3446
#                    privileges that are not schema-level privileges for the
 
3447
#                    current user.
 
3448
################################################################################
 
3449
 
 
3450
--disable_warnings
 
3451
DROP DATABASE IF EXISTS db_datadict;
 
3452
DROP DATABASE IF EXISTS db_datadict_2;
 
3453
--enable_warnings
 
3454
 
 
3455
create database db_datadict;
 
3456
create database db_datadict_2;
 
3457
 
 
3458
CREATE USER 'u_6_401503_1'@'localhost';
 
3459
CREATE USER 'u_6_401503_2'@'localhost';
 
3460
CREATE USER 'u_6_401503_3'@'localhost';
 
3461
 
 
3462
use db_datadict;
 
3463
 
 
3464
create table res_6_401503_1(f1 int, f2 int, f3 int);
 
3465
 
 
3466
use db_datadict_2;
 
3467
 
 
3468
create table res_6_401503_2(f1 int, f2 int, f3 int);
 
3469
 
 
3470
grant update on db_datadict.* to 'u_6_401503_1'@'localhost';
 
3471
grant delete on db_datadict_2.* to 'u_6_401503_2'@'localhost';
 
3472
 
 
3473
FLUSH PRIVILEGES;
 
3474
 
 
3475
SELECT * FROM information_schema.schema_privileges;
 
3476
 
 
3477
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3478
connect (u_6_401503_1, localhost, u_6_401503_1, , test);
 
3479
 
 
3480
SELECT * FROM information_schema.schema_privileges;
 
3481
 
 
3482
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3483
connect (u_6_401503_2, localhost, u_6_401503_2, , test);
 
3484
 
 
3485
SELECT * FROM information_schema.schema_privileges;
 
3486
 
 
3487
# should not show anything
 
3488
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3489
connect (u_6_401503_3, localhost, u_6_401503_3, , test);
 
3490
 
 
3491
SELECT * FROM information_schema.schema_privileges;
 
3492
 
 
3493
# clean-up
 
3494
 
 
3495
connection default;
 
3496
--source suite/funcs_1/include/show_connection.inc
 
3497
disconnect u_6_401503_1;
 
3498
disconnect u_6_401503_2;
 
3499
disconnect u_6_401503_3;
 
3500
use db_datadict;
 
3501
DROP USER 'u_6_401503_1'@'localhost';
 
3502
DROP USER 'u_6_401503_2'@'localhost';
 
3503
DROP USER 'u_6_401503_3'@'localhost';
 
3504
drop table res_6_401503_1;
 
3505
use db_datadict_2;
 
3506
drop table res_6_401503_2;
 
3507
use test;
 
3508
drop database db_datadict;
 
3509
drop database db_datadict_2;
 
3510
# -------------------------------------------------------------------------------------------------------
 
3511
 
 
3512
let $message= Testcase 3.2.16.1:;
 
3513
--source include/show_msg80.inc
 
3514
 
 
3515
################################################################################
 
3516
# Testcase 3.2.16.1: Ensure that the INFORMATION_SCHEMA.USER_PRIVILEGES
 
3517
#                    table has the following columns, in the following order:
 
3518
#
 
3519
#                    GRANTEE (shows a user to whom a user privilege has been
 
3520
#                          granted),
 
3521
#                    TABLE_CATALOG (always shows NULL),
 
3522
#                    PRIVILEGE_TYPE (shows the granted privilege),
 
3523
#                    IS_GRANTABLE (shows whether the privilege was granted WITH
 
3524
#                          GRANT OPTION).
 
3525
################################################################################
 
3526
 
 
3527
#-----------
 
3528
# Bug #12063 column 'TABLE_SCHEMA' is missing in table
 
3529
#                 INFORMATION_SCHEMA.USER_PRIVILEGE
 
3530
# ... is not a bug, it has been added by mistake in the TP requirement document.
 
3531
#-----------
 
3532
 
 
3533
let $is_table= user_privileges;
 
3534
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3535
# -------------------------------------------------------------------------------------------------------
 
3536
 
 
3537
let $message= Testcase 3.2.16.2 + 3.2.16.3 + 3.2.16.4:;
 
3538
--source include/show_msg80.inc
 
3539
 
 
3540
################################################################################
 
3541
# Testcase 3.2.16.2: Ensure that the table shows the relevant information on
 
3542
#                    every user privilege which has been granted to the current
 
3543
#                    user or to PUBLIC, or has been granted by the current user.
 
3544
################################################################################
 
3545
# Testcase 3.2.16.3: Ensure that the table does not show any information on any
 
3546
#                    user privileges which have been granted to users other than
 
3547
#                    the current user or  have been granted by any user other
 
3548
#                    than the current user.
 
3549
################################################################################
 
3550
# Testcase 3.2.16.4: Ensure that the table does not show any information on any
 
3551
#                    privileges that are not user privileges for the current
 
3552
#                    user.
 
3553
################################################################################
 
3554
 
 
3555
#FIXME 3.2.16: - when Bug #12269 is fixed a some of the outputs here may be
 
3556
#FIXME 3.2.16:   deleted as I added them for checking where / which information
 
3557
#FIXME 3.2.16:   is shown.
 
3558
 
 
3559
--disable_warnings
 
3560
DROP DATABASE IF EXISTS db_datadict;
 
3561
--enable_warnings
 
3562
 
 
3563
let $cmd1= SELECT * FROM information_schema.user_privileges
 
3564
            WHERE grantee LIKE "%user%"
 
3565
            ORDER BY grantee, table_catalog, privilege_type;
 
3566
let $cmd2= SELECT * FROM mysql.user WHERE user LIKE "%user%" ORDER BY host, user;
 
3567
let $cmd3= SHOW GRANTS;
 
3568
 
 
3569
CREATE DATABASE db_datadict;
 
3570
 
 
3571
CREATE USER 'user_1'@'localhost';
 
3572
CREATE USER 'user_2'@'localhost';
 
3573
CREATE USER 'user_3'@'localhost';
 
3574
 
 
3575
GRANT SELECT ON db_datadict.* TO 'user_1'@'localhost';
 
3576
GRANT SELECT ON mysql.user TO 'user_1'@'localhost';
 
3577
 
 
3578
GRANT INSERT ON *.* TO 'user_2'@'localhost';
 
3579
GRANT UPDATE ON *.* TO 'user_2'@'localhost';
 
3580
 
 
3581
FLUSH PRIVILEGES;
 
3582
 
 
3583
let $message= FIXME (see Bug 12269) Here we expect more than only <USAGE> for user_1;
 
3584
--source include/show_msg.inc
 
3585
eval $cmd1;
 
3586
eval $cmd2;
 
3587
eval $cmd3;
 
3588
 
 
3589
let $message= add GRANT OPTION db_datadict.* to user_1;
 
3590
--source include/show_msg.inc
 
3591
GRANT UPDATE ON db_datadict.* TO 'user_1'@'localhost' WITH GRANT OPTION;
 
3592
 
 
3593
let $message= FIXME (see Bug 12269) Here the <YES> is missing for the GRANT OPTION for user_1;
 
3594
--source include/show_msg.inc
 
3595
eval $cmd1;
 
3596
eval $cmd2;
 
3597
eval $cmd3;
 
3598
 
 
3599
FLUSH PRIVILEGES;
 
3600
 
 
3601
 
 
3602
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3603
connect (user_16_1, localhost, user_1, , db_datadict);
 
3604
eval $cmd1;
 
3605
eval $cmd2;
 
3606
eval $cmd3;
 
3607
 
 
3608
# add SELECT on *.* to user_1
 
3609
let $message= Now add SELECT on *.* to user_1;
 
3610
--source include/show_msg.inc
 
3611
 
 
3612
connection default;
 
3613
--source suite/funcs_1/include/show_connection.inc
 
3614
GRANT SELECT ON *.* TO 'user_1'@'localhost';
 
3615
let $message= Here <SELECT NO> is shown correctly for user_1;
 
3616
--source include/show_msg.inc
 
3617
eval $cmd1;
 
3618
eval $cmd2;
 
3619
eval $cmd3;
 
3620
 
 
3621
GRANT SELECT ON *.* TO 'user_1'@'localhost' WITH GRANT OPTION;
 
3622
let $message= Here <SELECT YES> is shown correctly for user_1;
 
3623
--source include/show_msg.inc
 
3624
eval $cmd1;
 
3625
eval $cmd2;
 
3626
eval $cmd3;
 
3627
 
 
3628
FLUSH PRIVILEGES;
 
3629
eval $cmd1;
 
3630
eval $cmd2;
 
3631
eval $cmd3;
 
3632
 
 
3633
# check that this appears
 
3634
connection user_16_1;
 
3635
--source suite/funcs_1/include/show_connection.inc
 
3636
eval $cmd1;
 
3637
eval $cmd2;
 
3638
eval $cmd3;
 
3639
 
 
3640
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3641
connect (user_16_2, localhost, user_2, , db_datadict);
 
3642
eval $cmd1;
 
3643
--error 1142
 
3644
eval $cmd2;
 
3645
eval $cmd3;
 
3646
 
 
3647
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
3648
connect (user_16_3, localhost, user_3, , test);
 
3649
eval $cmd1;
 
3650
--error 1142
 
3651
eval $cmd2;
 
3652
eval $cmd3;
 
3653
 
 
3654
let $message= revoke privileges from user_1;
 
3655
--source include/show_msg.inc
 
3656
 
 
3657
connection default;
 
3658
--source suite/funcs_1/include/show_connection.inc
 
3659
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user_1'@'localhost';
 
3660
eval $cmd1;
 
3661
eval $cmd2;
 
3662
eval $cmd3;
 
3663
 
 
3664
# check for changes
 
3665
connection user_16_1;
 
3666
--source suite/funcs_1/include/show_connection.inc
 
3667
eval $cmd1;
 
3668
--error 1142
 
3669
eval $cmd2;
 
3670
eval $cmd3;
 
3671
 
 
3672
--source suite/funcs_1/include/show_connection.inc
 
3673
# checks entered before bug #12269 was reported
 
3674
# OK, user_1 has no privs here
 
3675
--error 1142
 
3676
CREATE TABLE db_datadict.tb_55 ( c1 TEXT );
 
3677
--source suite/funcs_1/include/show_connection.inc
 
3678
eval $cmd1;
 
3679
--error 1142
 
3680
eval $cmd2;
 
3681
eval $cmd3;
 
3682
# OK, user_1 has no privs here
 
3683
--error 1142
 
3684
CREATE TABLE db_datadict.tb_66 ( c1 TEXT );
 
3685
 
 
3686
let $message= add ALL on db_datadict.* (and select on mysql.user) to user_1;
 
3687
--source include/show_msg.inc
 
3688
 
 
3689
connection default;
 
3690
--source suite/funcs_1/include/show_connection.inc
 
3691
 
 
3692
GRANT ALL ON db_datadict.* TO 'user_1'@'localhost' WITH GRANT OPTION;
 
3693
GRANT SELECT ON mysql.user TO 'user_1'@'localhost';
 
3694
eval $cmd1;
 
3695
eval $cmd2;
 
3696
eval $cmd3;
 
3697
 
 
3698
# check for changes
 
3699
connection user_16_1;
 
3700
--source suite/funcs_1/include/show_connection.inc
 
3701
eval $cmd1;
 
3702
eval $cmd2;
 
3703
eval $cmd3;
 
3704
 
 
3705
# OK, user_1 has no privs here
 
3706
--error 1142
 
3707
CREATE TABLE db_datadict.tb_56 ( c1 TEXT );
 
3708
 
 
3709
# using 'USE' lets the server read the privileges new, so now the CREATE works
 
3710
USE db_datadict;
 
3711
--source suite/funcs_1/include/show_connection.inc
 
3712
eval $cmd1;
 
3713
eval $cmd2;
 
3714
eval $cmd3;
 
3715
CREATE TABLE tb_57 ( c1 TEXT );
 
3716
 
 
3717
let $message= revoke privileges from user_1;
 
3718
--source include/show_msg.inc
 
3719
 
 
3720
connection default;
 
3721
--source suite/funcs_1/include/show_connection.inc
 
3722
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user_1'@'localhost';
 
3723
FLUSH PRIVILEGES;
 
3724
eval $cmd1;
 
3725
eval $cmd2;
 
3726
eval $cmd3;
 
3727
 
 
3728
# check for changes
 
3729
connection user_16_1;
 
3730
--source suite/funcs_1/include/show_connection.inc
 
3731
eval $cmd1;
 
3732
--error 1142
 
3733
eval $cmd2;
 
3734
eval $cmd3;
 
3735
# WORKS, as the existing old privileges are used!
 
3736
CREATE TABLE db_datadict.tb_58 ( c1 TEXT );
 
3737
# existing privileges are "read" new when USE is called, user has no priviliges
 
3738
--error 1044
 
3739
USE db_datadict;
 
3740
#FIXME 3.2.16: check that it is correct that this now 'works': --error 1142
 
3741
CREATE TABLE db_datadict.tb_59 ( c1 TEXT );
 
3742
 
 
3743
 
 
3744
# clean-up
 
3745
connection default;
 
3746
--source suite/funcs_1/include/show_connection.inc
 
3747
disconnect user_16_1;
 
3748
disconnect user_16_2;
 
3749
disconnect user_16_3;
 
3750
DROP USER 'user_1'@'localhost';
 
3751
DROP USER 'user_2'@'localhost';
 
3752
DROP USER 'user_3'@'localhost';
 
3753
DROP DATABASE IF EXISTS db_datadict;
 
3754
# -------------------------------------------------------------------------------------------------------
 
3755
 
 
3756
let $message=  Testcase 3.2.17: Checks on Performance - not here in this script!;
 
3757
--source include/show_msg80.inc
 
3758
 
 
3759
################################################################################
 
3760
# Testcase 3.2.17.1: Ensure that every INFORMATION_SCHEMA table shows all the
 
3761
#                    correct information, and no incorrect information, for a
 
3762
#                    database to which 100 different users, each of which has a
 
3763
#                     randomly issued set of privileges and access to a
 
3764
#                    randomly chosen set of database objects, have access.
 
3765
#                    The database should contain a mixture of all types of
 
3766
#                    database objects (i.e. tables, views, stored procedures,
 
3767
#                    triggers).
 
3768
################################################################################
 
3769
 
 
3770
################################################################################
 
3771
# Testcase 3.2.17.2: Ensure that every INFORMATION_SCHEMA table shows all the
 
3772
#                    correct information, and no incorrect information, for 10
 
3773
#                    different databases to which 50 different users, each of
 
3774
#                    which has a randomly issued set of privileges and access
 
3775
#                    to a randomly chosen set of database objects in two or
 
3776
#                    more of the databases, have access. The databases should
 
3777
#                    each contain a mixture of all types of database objects
 
3778
#                    (i.e. tables, views, stored procedures, triggers).
 
3779
################################################################################
 
3780
 
 
3781
# -------------------------------------------------------------------------------------------------------
 
3782
 
 
3783
let $message= Testcase 3.2.18.1:;
 
3784
--source include/show_msg80.inc
 
3785
 
 
3786
################################################################################
 
3787
# Testcase 3.2.18.1: Ensure that the INFORMATION_SCHEMA.TRIGGERS
 
3788
#                    table has the following columns, in the following order:
 
3789
#
 
3790
#
 
3791
#                    (FIXME - list copied from WL#1996)
 
3792
#
 
3793
#                    TRIGGER_CATALOG               NULL
 
3794
#                    TRIGGER_SCHEMA
 
3795
#                    TRIGGER_NAME
 
3796
#                    EVENT_MANIPULATION
 
3797
#                    EVENT_OBJECT_CATALOG          NULL
 
3798
#                    EVENT_OBJECT_SCHEMA
 
3799
#                    EVENT_OBJECT_TABLE
 
3800
#                    ACTION_ORDER                  NULL
 
3801
#                    ACTION_CONDITION              NULL
 
3802
#                    ACTION_STATEMENT
 
3803
#                    ACTION_ORIENTATION
 
3804
#                    ACTION_TIMING
 
3805
#                    ACTION_REFERENCE_OLD_TABLE    NULL
 
3806
#                    ACTION_REFERENCE_NEW_TABLE    NULL
 
3807
#                    ACTION_REFERENCE_OLD_ROW
 
3808
#                    ACTION_REFERENCE_NEW_ROW
 
3809
#                    CREATED
 
3810
#                    SQL_MODE
 
3811
#
 
3812
################################################################################
 
3813
 
 
3814
let $is_table= triggers;
 
3815
--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3816
# -------------------------------------------------------------------------------------------------------
 
3817
 
 
3818
let $message= Testcase 3.2.18.2 + 3.2.18.3:;
 
3819
--source include/show_msg80.inc
 
3820
 
 
3821
################################################################################
 
3822
# Testcase 3.2.18.2: Ensure that the table shows the relevant information on
 
3823
#                    every trigger on which the current user or PUBLIC has
 
3824
#                    privileges.
 
3825
################################################################################
 
3826
# Testcase 3.2.18.3: Ensure that the table does not show any information on any
 
3827
#                    trigger on which the current user and public have no
 
3828
#                    privileges.
 
3829
################################################################################
 
3830
 
 
3831
#FIXME 3.2.18.2: to be added.
 
3832
#FIXME 3.2.18.2: don't forget to add the test description to QATestPlanV50func
 
3833
 
 
3834
# -------------------------------------------------------------------------------------------------------
 
3835
 
 
3836
let $message= Testcase 3.2.19.1:;
 
3837
--source include/show_msg80.inc
 
3838
 
 
3839
################################################################################
 
3840
# Testcase 3.2.19.1: Ensure that the INFORMATION_SCHEMA.PARAMETERS
 
3841
#                    table has the following columns, in the following order:
 
3842
#
 
3843
################################################################################
 
3844
 
 
3845
let $is_table= parameters;
 
3846
# when table is implemented remove this and the next 4 lines and "enable" 5th line:
 
3847
# and don't forget to add the test description to QATestPlanV50func
 
3848
let $message= checking a table that will be implemented later;
 
3849
--source include/show_msg.inc
 
3850
--error 1109
 
3851
eval DESC $is_table;
 
3852
#--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3853
# -------------------------------------------------------------------------------------------------------
 
3854
 
 
3855
let $message= Testcase 3.2.20.1:;
 
3856
--source include/show_msg80.inc
 
3857
 
 
3858
################################################################################
 
3859
# Testcase 3.2.20.1: Ensure that the INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
 
3860
#                    table has the following columns, in the following order:
 
3861
#
 
3862
################################################################################
 
3863
 
 
3864
let $is_table= referential_constraints;
 
3865
# when table is implemented remove this and the next 4 lines and "enable" 5th line:
 
3866
# and don't forget to add the test description to QATestPlanV50func
 
3867
let $message= checking a table that will be implemented later;
 
3868
--source include/show_msg.inc
 
3869
--error 1109
 
3870
eval DESC $is_table;
 
3871
#--source suite/funcs_1/datadict/datadict_show_table_design.inc
 
3872
# -------------------------------------------------------------------------------------------------------
 
3873
 
 
3874
 
 
3875
################################################################################
 
3876
#
 
3877
let $message= *** End of Data Dictionary Tests ***;
 
3878
--source include/show_msg80.inc
 
3879
#
 
3880
################################################################################
 
3881
 
 
3882
 
 
3883
# some cleanup to be sure nothing remains
 
3884
--disable_warnings
 
3885
DROP TABLE IF EXISTS test.tb1;
 
3886
DROP TABLE IF EXISTS test.tb2;
 
3887
DROP TABLE IF EXISTS test.tb3;
 
3888
DROP TABLE IF EXISTS test.tb4;
 
3889
DROP TABLE IF EXISTS test.t1;
 
3890
DROP TABLE IF EXISTS test.t2;
 
3891
DROP TABLE IF EXISTS test.t3;
 
3892
DROP TABLE IF EXISTS test.t4;
 
3893
DROP TABLE IF EXISTS test.t7;
 
3894
DROP TABLE IF EXISTS test.t8;
 
3895
DROP TABLE IF EXISTS test.t9;
 
3896
DROP TABLE IF EXISTS test.t10;
 
3897
DROP TABLE IF EXISTS test.t11;
 
3898
DROP DATABASE IF EXISTS test1;
 
3899
DROP DATABASE IF EXISTS test4;
 
3900
DROP DATABASE IF EXISTS db_datadict;
 
3901
DROP DATABASE IF EXISTS db_datadict_1;
 
3902
DROP DATABASE IF EXISTS db_datadict_2;
 
3903
--enable_warnings