1# suite/funcs_1/t/is_character_sets.test
2#
3# Check the layout of information_schema.character_sets and run some
4# functionality related tests.
5#
6# Author:
7# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
8#                           testsuite funcs_1
9#                   Create this script based on older scripts and new code.
10#
11
12if (`SELECT VERSION() LIKE '%embedded%'`)
13{
14   --skip Bug#37456 funcs_1: Several tests crash when used with embedded server
15}
16
17let $is_table = CHARACTER_SETS;
18
19# The table INFORMATION_SCHEMA.CHARACTER_SETS must exist
20eval SHOW TABLES FROM information_schema LIKE '$is_table';
21
22--echo #######################################################################
23--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
24--echo #######################################################################
25# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
26# statement, just as if it were an ordinary user-defined table.
27#
28--source suite/funcs_1/datadict/is_table_query.inc
29
30
31--echo #########################################################################
32--echo # Testcase 3.2.2.1: INFORMATION_SCHEMA.CHARACTER_SETS layout
33--echo #########################################################################
34# Ensure that the INFORMATION_SCHEMA.CHARACTER_SETS table has the following
35# columns, in the following order:
36#
37# CHARACTER_SET_NAME (shows a character set name),
38# DEFAULT_COLLATE_NAME (shows the name of the default collation for that
39#       character set),
40# DESCRIPTION (shows a descriptive name for that character set),
41# MAXLEN (shows the number of bytes used to store each character supported by
42#       that character set).
43#
44eval DESCRIBE          information_schema.$is_table;
45eval SHOW CREATE TABLE information_schema.$is_table;
46eval SHOW COLUMNS FROM information_schema.$is_table;
47
48# Note: Retrieval of information within information_schema.columns about
49#       information_schema.character_sets is in is_columns_is.test.
50#       Retrieval of information_schema.character_sets content is in
51#       charset_collation.inc (sourced by charset_collation_*.test).
52
53
54echo # Testcases 3.2.2.2 and 3.2.2.3 are checked in suite/funcs_1/t/charset_collation*.test;
55
56--echo ########################################################################
57--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
58--echo #           DDL on INFORMATION_SCHEMA tables are not supported
59--echo ########################################################################
60# 3.2.1.3:  Ensure that no user may execute an INSERT statement on any
61#           INFORMATION_SCHEMA table.
62# 3.2.1.4:  Ensure that no user may execute an UPDATE statement on any
63#           INFORMATION_SCHEMA table.
64# 3.2.1.5:  Ensure that no user may execute a DELETE statement on any
65#           INFORMATION_SCHEMA table.
66# 3.2.1.8:  Ensure that no user may create an index on an
67#           INFORMATION_SCHEMA table.
68# 3.2.1.9:  Ensure that no user may alter the definition of an
69#           INFORMATION_SCHEMA table.
70# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
71# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
72#           other database.
73# 3.2.1.12: Ensure that no user may directly add to, alter, or delete any data
74#           in an INFORMATION_SCHEMA table.
75#
76--disable_warnings
77DROP DATABASE IF EXISTS db_datadict;
78--enable_warnings
79CREATE DATABASE db_datadict;
80
81--error ER_DBACCESS_DENIED_ERROR
82INSERT INTO information_schema.character_sets
83SELECT * FROM information_schema.character_sets;
84
85--error ER_DBACCESS_DENIED_ERROR
86UPDATE information_schema.character_sets SET description = 'just updated';
87
88--error ER_DBACCESS_DENIED_ERROR
89DELETE FROM information_schema.character_sets WHERE table_name = 't1';
90--error ER_DBACCESS_DENIED_ERROR
91TRUNCATE information_schema.character_sets;
92
93--error ER_DBACCESS_DENIED_ERROR
94CREATE INDEX my_idx ON information_schema.character_sets(character_set_name);
95
96--error ER_DBACCESS_DENIED_ERROR
97ALTER TABLE information_schema.character_sets DROP PRIMARY KEY;
98--error ER_DBACCESS_DENIED_ERROR
99ALTER TABLE information_schema.character_sets ADD f1 INT;
100
101--error ER_DBACCESS_DENIED_ERROR
102DROP TABLE information_schema.character_sets;
103
104--error ER_DBACCESS_DENIED_ERROR
105ALTER TABLE information_schema.character_sets RENAME db_datadict.character_sets;
106--error ER_DBACCESS_DENIED_ERROR
107ALTER TABLE information_schema.character_sets
108RENAME information_schema.xcharacter_sets;
109
110# Cleanup
111DROP DATABASE db_datadict;
112
113