Debian Codegraph @

mysql-test/suite/innodb/t/tablespace_per_table_not_windows.test

raw
1 --echo #
2 --echo # Test the limits of a file-per-table tablespace name. MySQL combines
3 --echo # the database name with the table name to make a unique table name.
4 --echo #
5
6 --source include/not_windows.inc
7 # This will test the limit of a filename in MySQL at 512 bytes.
8 # We control that by making it a relative path starting with "./".
9
10 SET default_storage_engine=InnoDB;
11 LET $MYSQLD_DATADIR = `select @@datadir`;
12
13 --disable_query_log
14 # Suppress errors about too long filenames in error log.
15 call mtr.add_suppression("\\[Warning\\] .* '.*' name too long, can't delete!");
16 call mtr.add_suppression("\\[ERROR\\] .* Operating system error number .* in a file operation.");
17 call mtr.add_suppression("\\[ERROR\\] .* Error number .* means '.*'");
18 call mtr.add_suppression("\\[ERROR\\] .* Cannot create file .*");
19 call mtr.add_suppression("\\[ERROR\\] .* File .* 'create' returned OS error .*");
20 call mtr.add_suppression("\\[ERROR\\] .* File .* 'delete' returned OS error .*");
21 call mtr.add_suppression("\\[ERROR\\] .* File .* 'stat' returned OS error .*");
22 --enable_query_log
23
24 --echo #
25 --echo # MySQL limits each database and tablename identifier to 64 characters
26 --echo # of up to 3 bytes per character, corresponding to 192 bytes.
27 --echo #
28 LET $too_long_name = this_sixty_five_byte_name_is_too_long____________________________;
29 --error ER_TOO_LONG_IDENT
30 --eval CREATE DATABASE `$too_long_name`
31
32 LET $long_name = this_sixty_four_byte_name_is_not_too_long_______________________;
33 --eval CREATE DATABASE `$long_name`
34 --eval USE `$long_name`
35
36 --echo #
37 --echo # A 64 character tablename can be created in a 64 character database name
38 --echo #
39 --eval CREATE TABLE `$long_name`.`$long_name` (a SERIAL)
40
41 --echo #
42 --echo # A 65 character tablename is too long.
43 --echo #
44 --error ER_TOO_LONG_IDENT
45 --eval CREATE TABLE `test`.`$too_long_name` (a SERIAL)
46 --error ER_TOO_LONG_IDENT
47 --eval CREATE TABLE `$long_name`.`$too_long_name` (a SERIAL)
48
49 --echo #
50 --echo # Non-non-filename-safe characters like '#' are expanded to '@0023'.
51 --echo # On many file systems, such as Linux extfs, you can create a database name
52 --echo # that expands to up to 255 bytes long.
53 --echo # `##################################################_long` is expanded to
54 --echo # (50 * 5) + 5 = 255.
55 --echo #
56 LET $long_db_name = ##################################################_long;
57 --eval CREATE DATABASE `$long_db_name`;
58 --eval USE `$long_db_name`
59
60 --echo #
61 --echo # This 256-byte name is only one byte longer but fails with an error code
62 --echo # from the stat operation.
63 --echo # `##################################################_long_` is expanded to
64 --echo # (50 * 5) + 6 = 256.
65 --echo #
66 --replace_regex /OS errno [0-9]+/Errcode: ##/ /@0023/#/ /Filename/File name/
67 --error 13
68 CREATE DATABASE `##################################################_long_`;
69
70 --echo #
71 --echo # This 300-byte name which is the longest name that gets an error code
72 --echo # from the stat operation.
73 --echo # `###########################################################_long` is expanded to
74 --echo # (59 * 5) + 5 = 300.
75 --echo #
76 --replace_regex /OS errno [0-9]+/Errcode: ##/ /@0023/#/ /Filename/File name/
77 --error 13
78 CREATE DATABASE `###########################################################_long`;
79
80 --echo #
81 --echo # This 301-byte name which is only one byte longer but fails with ER_TOO_LONG_IDENT.
82 --echo # `###########################################################_long_` is expanded to
83 --echo # (59 * 5) + 6 = 301.
84 --echo #
85 --replace_result @0023 #
86 --error ER_TOO_LONG_IDENT
87 CREATE DATABASE `###########################################################_long_`;
88
89 USE test;
90
91 LET $long_249_byte_table_name = #################################################long;
92 LET $long_250_byte_table_name = #################################################_long;
93 LET $long_251_byte_table_name = #################################################_long_;
94 LET $long_252_byte_table_name = #################################################_long___;
95
96 --echo #
97 --echo # An expanded table name is limited to 251 bytes
98 --echo #
99 --eval CREATE TABLE `test`.`$long_251_byte_table_name` (a SERIAL)
100
101 --echo #
102 --echo # A 252-byte tablename is too long
103 --echo #
104 --replace_regex /@0023/#/
105 --error ER_GET_ERRNO
106 --eval CREATE TABLE `test`.`$long_252_byte_table_name` (a SERIAL)
107
108 CREATE DATABASE twenty_byte_db_name_;
109 USE `twenty_byte_db_name_`;
110
111 --echo #
112 --echo # A 251 byte expanded table name will fit with a longer database name
113 --echo #
114 --eval CREATE TABLE `twenty_byte_db_name_`.`$long_251_byte_table_name` (a SERIAL)
115
116 --echo #
117 --echo # A 252 byte expanded table name is also too long in a longer database name
118 --echo #
119 --replace_regex /@0023/#/
120 --error ER_GET_ERRNO
121 --eval CREATE TABLE `twenty_byte_db_name_`.`$long_252_byte_table_name` (a SERIAL)
122
123 --echo #
124 --echo # Another limitation is a 512 byte length to an expanded path that includes
125 --echo # the datadir which is './' in this test, the expanded database name,
126 --echo # the directory separator '/', the expanded table name, and the file extension.
127 --echo # './long_db_name.long_250_byte_table_name.frm'
128 --echo # 2+ 255 +1+ 250 +1+3 = 512
129 --echo #
130 --eval CREATE TABLE `$long_db_name`.`$long_250_byte_table_name` (a SERIAL)
131
132 --error ER_IDENT_CAUSES_TOO_LONG_PATH
133 --eval CREATE TABLE `$long_db_name`.`$long_251_byte_table_name` (a SERIAL)
134 SHOW WARNINGS;
135
136 --echo #
137 --echo # Show the successfully created databases and tables
138 --echo #
139 --echo ---- list_files MYSQLD_DATADIR/test
140 --replace_result @0023 #
141 --list_files $MYSQLD_DATADIR/test
142 --echo ---- list_files MYSQLD_DATADIR/$long_name
143 --replace_result @0023 #
144 --list_files $MYSQLD_DATADIR/$long_name
145 --echo ---- list_files MYSQLD_DATADIR/$long_db_name
146 --replace_result @0023 #
147 --list_files $MYSQLD_DATADIR/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023_long
148
149 --replace_result @0023 #
150 SELECT name FROM information_schema.innodb_tables WHERE name LIKE '%long%';
151 --replace_result @0023 #
152 SELECT name FROM information_schema.innodb_tablespaces WHERE name LIKE '%long%';
153 --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @0023 #
154 SELECT path FROM information_schema.innodb_datafiles WHERE path LIKE '%long%' order by path;
155 --vertical_results
156 --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @0023 #
157 SELECT file_name, tablespace_name FROM information_schema.files
158 WHERE file_name LIKE '%long%' ORDER BY file_name;
159 --horizontal_results
160
161 --echo #
162 --echo # Cleanup
163 --echo #
164
165 --eval DROP TABLE `$long_name`.`$long_name`
166 --eval DROP TABLE `test`.`$long_251_byte_table_name`
167 --eval DROP TABLE `twenty_byte_db_name_`.`$long_251_byte_table_name`
168 --eval DROP TABLE `$long_db_name`.`$long_250_byte_table_name`
169 --eval DROP DATABASE `$long_name`
170 --eval DROP DATABASE `$long_db_name`
171 DROP DATABASE `twenty_byte_db_name_`;