| 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 |
# There is no use in testing the maximum expanded filename using "#" or |
| 7 |
# some other character that is expanded by MySQL to "@0023" because |
| 8 |
# Windows imposes a maximum absolute path length of 260 bytes. So the |
| 9 |
# results will depend upon what local directory this test is run in. |
| 10 |
# See https://msdn.microsoft.com/en-us/library/aa365247.aspx |
| 11 |
# "Maximum Path Length Limitation |
| 12 |
# In the Windows API, the maximum length for a path is MAX_PATH, which is |
| 13 |
# defined as 260 characters. A local path is structured in the following |
| 14 |
# order: drive letter, colon, backslash, name components separated by |
| 15 |
# backslashes, and a terminating null character. For example, the maximum |
| 16 |
# path on drive D is "D:\some 256-character path string<NUL>" where |
| 17 |
# "<NUL>" represents the invisible terminating null character for the |
| 18 |
# current system codepage. (The characters < > are used here for visual |
| 19 |
# clarity and cannot be part of a valid path string.)" |
| 20 |
|
| 21 |
--source include/have_innodb.inc |
| 22 |
--source include/windows.inc |
| 23 |
# This will test the limit of a filename in MySQL at 512 bytes. |
| 24 |
# We control that by making it a relative path starting with "./". |
| 25 |
# The embedded server uses an absolute path as the datadir |
| 26 |
# which has a non-deterministic length. |
| 27 |
--source include/not_embedded.inc |
| 28 |
|
| 29 |
SET default_storage_engine=InnoDB; |
| 30 |
LET $MYSQLD_DATADIR = `select @@datadir`; |
| 31 |
|
| 32 |
--echo # |
| 33 |
--echo # MySQL limits each database and tablename identifier to 64 characters |
| 34 |
--echo # of up to 3 bytes per character, corresponding to 192 bytes. |
| 35 |
--echo # |
| 36 |
LET $too_long_name = this_sixty_five_byte_name_is_too_long____________________________; |
| 37 |
--error ER_WRONG_DB_NAME |
| 38 |
--eval CREATE DATABASE `$too_long_name` |
| 39 |
|
| 40 |
LET $long_name = this_sixty_four_byte_name_is_not_too_long_______________________; |
| 41 |
--eval CREATE DATABASE `$long_name` |
| 42 |
--eval USE `$long_name` |
| 43 |
|
| 44 |
--echo # |
| 45 |
--echo # A 64 character tablename can be created in a 64 character database name |
| 46 |
--echo # |
| 47 |
--eval CREATE TABLE `$long_name`.`$long_name` (a SERIAL) |
| 48 |
|
| 49 |
--echo # |
| 50 |
--echo # A 65 character tablename is too long. |
| 51 |
--echo # |
| 52 |
--error ER_WRONG_TABLE_NAME |
| 53 |
--eval CREATE TABLE `test`.`$too_long_name` (a SERIAL) |
| 54 |
--error ER_WRONG_TABLE_NAME |
| 55 |
--eval CREATE TABLE `$long_name`.`$too_long_name` (a SERIAL) |
| 56 |
|
| 57 |
--echo # |
| 58 |
--echo # Show the successfully created database and table |
| 59 |
--echo # |
| 60 |
--eval SHOW CREATE TABLE `$long_name`.`$long_name` |
| 61 |
|
| 62 |
--echo ---- list_files MYSQLD_DATADIR/$long_name |
| 63 |
--list_files $MYSQLD_DATADIR/$long_name |
| 64 |
|
| 65 |
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%'; |
| 66 |
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%'; |
| 67 |
--vertical_results |
| 68 |
--replace_regex /innodb_file_per_table_[0-9]*/innodb_file_per_table_##/ |
| 69 |
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR |
| 70 |
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%'; |
| 71 |
--horizontal_results |
| 72 |
|
| 73 |
--echo # |
| 74 |
--echo # Cleanup |
| 75 |
--echo # |
| 76 |
|
| 77 |
--eval DROP DATABASE `$long_name` |