1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#
# Test the limits of a file-per-table tablespace name. MySQL combines
# the database name with the table name to make a unique table name.
#
SET default_storage_engine=InnoDB;
#
# MySQL limits each database and tablename identifier to 64 characters
# of up to 3 bytes per character, corresponding to 192 bytes.
#
CREATE DATABASE `this_sixty_five_byte_name_is_too_long____________________________`;
ERROR 42000: Incorrect database name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
USE `this_sixty_four_byte_name_is_not_too_long_______________________`;
#
# A 64 character tablename can be created in a 64 character database name
#
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________` (a SERIAL);
#
# A 65 character tablename is too long.
#
CREATE TABLE `test`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
#
# Non-non-filename-safe characters like '#' are expanded to '@0023'.
# On many file systems, such as Linux extfs, you can create a database name
# that expands to up to 255 bytes long.
# `##################################################_long` is expanded to
# (50 * 5) + 5 = 255.
#
CREATE DATABASE `##################################################_long`;;
USE `##################################################_long`;
#
# This 256-byte name is only one byte longer but fails with an error code
# from the stat operation.
# `##################################################_long_` is expanded to
# (50 * 5) + 6 = 256.
#
CREATE DATABASE `##################################################_long_`;
ERROR HY000: Can't get stat of './##################################################_long_' (Errcode: ## "File name too long")
#
# This 300-byte name which is the longest name that gets an error code
# from the stat operation.
# `###########################################################_long` is expanded to
# (59 * 5) + 5 = 300.
#
CREATE DATABASE `###########################################################_long`;
ERROR HY000: Can't get stat of './###########################################################_long' (Errcode: ## "File name too long")
#
# This 301-byte name which is only one byte longer but fails with ER_TOO_LONG_IDENT.
# `###########################################################_long_` is expanded to
# (59 * 5) + 6 = 301.
#
CREATE DATABASE `###########################################################_long_`;
ERROR 42000: Incorrect database name '###########################################################_long_'
USE test;
#
# An expanded table name is limited to 251 bytes
#
CREATE TABLE `test`.`#################################################_long_` (a SERIAL);
#
# A 252-byte tablename is too long
#
CREATE TABLE `test`.`#################################################_long___` (a SERIAL);
ERROR HY000: Can't create table `test`.`#################################################_long___` (errno: ## "File name too long")
CREATE DATABASE twenty_byte_db_name_;
USE `twenty_byte_db_name_`;
#
# A 251 byte expanded table name will fit with a longer database name
#
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long_` (a SERIAL);
#
# A 252 byte expanded table name is also too long in a longer database name
#
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long___` (a SERIAL);
ERROR HY000: Can't create table `twenty_byte_db_name_`.`#################################################_long___` (errno: ## "File name too long")
#
# Another limitation is a 512 byte length to an expanded path that includes
# the datadir which is './' in this test, the expanded database name,
# the directory separator '/', the expanded table name, and the file extension.
# './long_db_name.long_250_byte_table_name.frm'
# 2+ 255 +1+ 250 +1+3 = 512
#
CREATE TABLE `##################################################_long`.`#################################################_long` (a SERIAL);
CREATE TABLE `##################################################_long`.`#################################################_long_` (a SERIAL);
ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@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/@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@
SHOW WARNINGS;
Level Code Message
Error 1860 Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@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/@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@
#
# Show the successfully created databases and tables
#
---- list_files MYSQLD_DATADIR/test
#################################################_long_.frm
#################################################_long_.ibd
db.opt
---- list_files MYSQLD_DATADIR/this_sixty_four_byte_name_is_not_too_long_______________________
db.opt
this_sixty_four_byte_name_is_not_too_long_______________________.frm
this_sixty_four_byte_name_is_not_too_long_______________________.ibd
---- list_files MYSQLD_DATADIR/##################################################_long
#################################################_long.frm
#################################################_long.ibd
db.opt
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
name
##################################################_long/#################################################_long
test/#################################################_long_
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
twenty_byte_db_name_/#################################################_long_
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
name
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
test/#################################################_long_
twenty_byte_db_name_/#################################################_long_
##################################################_long/#################################################_long
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
Warnings:
Level Warning
Code 1287
Message 'information_schema.FILES' is deprecated and will be removed in a future release
#
# Cleanup
#
DROP TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________`;
DROP TABLE `test`.`#################################################_long_`;
DROP TABLE `twenty_byte_db_name_`.`#################################################_long_`;
DROP TABLE `##################################################_long`.`#################################################_long`;
DROP DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
DROP DATABASE `##################################################_long`;
DROP DATABASE `twenty_byte_db_name_`;
|