diff options
32 files changed, 155 insertions, 912 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index a61b67d67c8..4fc1bf0c537 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -672,6 +672,7 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + opt_verbose ? "--verbose": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } @@ -687,6 +688,7 @@ static int run_mysqlcheck_fixnames(void) "--all-databases", "--fix-db-names", "--fix-table-names", + opt_verbose ? "--verbose": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 62eab5bf6e4..57f40e6b9b1 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,4 +1,5 @@ /* Copyright (C) 2000 MySQL AB + Copyright (C) 2010 Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +16,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.5.0" +#define CHECK_VERSION "2.6.0" #include "client_priv.h" #include <m_ctype.h> @@ -416,6 +417,8 @@ static int process_all_databases() MYF(0), mysql_error(sock)); return 1; } + if (verbose) + printf("Processing databases\n"); while ((row = mysql_fetch_row(tableres))) { if (process_one_db(row[0])) @@ -429,6 +432,8 @@ static int process_all_databases() static int process_databases(char **db_names) { int result = 0; + if (verbose) + printf("Processing databases\n"); for ( ; *db_names ; db_names++) { if (process_one_db(*db_names)) @@ -624,6 +629,8 @@ static int fix_database_storage_name(const char *name) static int process_one_db(char *database) { + if (verbose) + puts(database); if (what_to_do == DO_UPGRADE) { int rc= 0; @@ -731,7 +738,7 @@ static void print_result() { MYSQL_RES *res; MYSQL_ROW row; - char prev[NAME_LEN*2+2]; + char prev[(NAME_LEN+9)*2+2]; uint i; my_bool found_error=0; @@ -761,7 +768,15 @@ static void print_result() printf("%-50s %s", row[0], row[3]); else if (!status && changed) { - printf("%s\n%-9s: %s", row[0], row[2], row[3]); + /* + If the error message includes REPAIR TABLE, we assume it means + we have to run upgrade on it. In this case we write a nicer message + than "Please do "REPAIR TABLE""... + */ + if (!strcmp(row[2],"error") && strinstr(row[3],"REPAIR TABLE") != 0) + printf("%-50s %s", row[0], "Needs upgrade"); + else + printf("%s\n%-9s: %s", row[0], row[2], row[3]); if (strcmp(row[2],"note")) found_error=1; } @@ -780,7 +795,7 @@ static void print_result() static int dbConnect(char *host, char *user, char *passwd) { DBUG_ENTER("dbConnect"); - if (verbose) + if (verbose > 1) { fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost"); } @@ -813,7 +828,7 @@ static int dbConnect(char *host, char *user, char *passwd) static void dbDisconnect(char *host) { - if (verbose) + if (verbose > 1) fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost"); mysql_close(sock); } /* dbDisconnect */ diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index b798b49dd34..602b2d03d80 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -115,9 +115,14 @@ create table `#mysql50#abc``def` ( id int ); create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int); +ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345' +show tables; +Tables_in_mysqltestbug26703 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +#mysql50#abc`def use test; drop database mysqltestbug26703; End of 5.1 tests diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index b8f13723eb8..713b21ce7fd 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1424,7 +1424,7 @@ ERROR 42S02: Table 'db1.../db2/tb2' doesn't exist SELECT * FROM `../db2`.tb2; ERROR 42000: SELECT command denied to user 'testbug'@'localhost' for table 'tb2' SELECT * FROM `#mysql50#/../db2/tb2`; -ERROR 42S02: Table 'db1.#mysql50#/../db2/tb2' doesn't exist +ERROR 42000: Incorrect table name '#mysql50#/../db2/tb2' DROP USER 'testbug'@localhost; DROP TABLE db2.t1; DROP DATABASE db1; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 4da176aa1a6..31c612500d9 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -977,7 +977,7 @@ NULL test t1 c NULL NO int NULL NULL int(11) PRI select,insert,update,reference ---------------------------------------------------------------- SHOW TABLES LIKE 't1'; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def TABLE_NAMES TABLE_NAME Tables_in_test (t1) 253 192 2 N 1 0 33 +def TABLE_NAMES TABLE_NAME Tables_in_test (t1) 253 219 2 N 1 0 33 Tables_in_test (t1) t1 ---------------------------------------------------------------- diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index da2f55b5bb1..bdfac990a9a 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -139,4 +139,12 @@ USE `#mysql50#.`; ERROR 42000: Incorrect database name '#mysql50#.' USE `#mysql50#../blablabla`; ERROR 42000: Incorrect database name '#mysql50#../blablabla' +show full tables; +Tables_in_test Table_type +#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com BASE TABLE +rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; +show full tables; +Tables_in_test Table_type +ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com BASE TABLE +drop table `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; # End of 5.1 tests diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD Binary files differnew file mode 100644 index 00000000000..2ff33451b5f --- /dev/null +++ b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI Binary files differnew file mode 100644 index 00000000000..cffa158beae --- /dev/null +++ b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm Binary files differnew file mode 100644 index 00000000000..6a812a8b137 --- /dev/null +++ b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index bcfe138206e..59e5c6ecf57 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -245,351 +245,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_INDEX_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCKS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCK_WAITS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_RSEG -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_INDEXES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_TABLES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TABLE_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TRX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -636,29 +291,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME PBXT_STATISTICS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1002,52 +634,6 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ADMIN_COMMAND -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ENHANCEMENTS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- DROP USER testuser1@localhost; CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; @@ -1297,351 +883,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_INDEX_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCKS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCK_WAITS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_RSEG -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_INDEXES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_TABLES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TABLE_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TRX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1688,29 +929,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME PBXT_STATISTICS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -2054,52 +1272,6 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ADMIN_COMMAND -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ENHANCEMENTS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- # Switch to connection default and close connection testuser1 DROP USER testuser1@localhost; DROP DATABASE test1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index bb4dd3e11f9..66fe3bb03b2 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -195,9 +195,10 @@ create table `#mysql50#abc``def` ( id int ); --error ER_WRONG_TABLE_NAME create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int); --error ER_WRONG_TABLE_NAME -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int); +show tables; use test; drop database mysqltestbug26703; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 5bdb3ebe9bf..65e987dfa24 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1541,7 +1541,7 @@ connect (con1,localhost,testbug,,db1); SELECT * FROM `../db2/tb2`; --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM `../db2`.tb2; ---error ER_NO_SUCH_TABLE +--error ER_WRONG_TABLE_NAME SELECT * FROM `#mysql50#/../db2/tb2`; connection default; disconnect con1; diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index a7b9a1531ff..a3ae6b1298a 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -169,5 +169,16 @@ USE `#mysql50#.`; --error ER_WRONG_DB_NAME USE `#mysql50#../blablabla`; +# +# Test of Bug #56441: mysql_upgrade 5.0->5.1 fails for tables with long names +# +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; +show full tables; +rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; +show full tables; +drop table `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; + --echo # End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9e07ea7258f..bde8ff053e7 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -996,7 +996,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type, Protocol *protocol= thd->protocol; uint length, msg_length; char msgbuf[HA_MAX_MSG_BUF]; - char name[NAME_LEN*2+2]; + char name[SAFE_NAME_LEN*2+2]; va_start(args, fmt); msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); diff --git a/sql/item.cc b/sql/item.cc index ecd208b838d..1c1137fa75c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3728,7 +3728,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) int found_match_degree= 0; Item_ident *cur_field; int cur_match_degree= 0; - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; if (find_item->type() == Item::FIELD_ITEM || find_item->type() == Item::REF_ITEM) diff --git a/sql/log_event.cc b/sql/log_event.cc index 3db7929331d..262e8cae705 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6234,7 +6234,7 @@ void Create_file_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Create_file_log_event::pack_info(Protocol *protocol) { - char buf[NAME_LEN*2 + 30 + 21*2], *pos; + char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos; pos= strmov(buf, "db="); memcpy(pos, db, db_len); pos= strmov(pos + db_len, ";table="); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index bc2cff9ac50..efb92108781 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2288,6 +2288,7 @@ const char *get_canonical_filename(handler *file, const char *path, #define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" #define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 +#define SAFE_NAME_LEN (NAME_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH) uint build_table_shadow_filename(char *buff, size_t bufflen, ALTER_PARTITION_PARAM_TYPE *lpt); diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index ee3fc358b60..ae5808de9e9 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -91,7 +91,7 @@ Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables) for (; tables; tables= tables->next_global) { - char hash_key[2*NAME_LEN+2]; + char hash_key[SAFE_NAME_LEN*2+2]; char *end; uint len; @@ -225,7 +225,7 @@ Rpl_filter::db_ok_with_wild_table(const char *db) { DBUG_ENTER("Rpl_filter::db_ok_with_wild_table"); - char hash_key[NAME_LEN+2]; + char hash_key[SAFE_NAME_LEN+2]; char *end; int len; end= strmov(hash_key, db); diff --git a/sql/sp.cc b/sql/sp.cc index ddddaee2e10..bcfcb0c4f36 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -717,7 +717,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, { LEX *old_lex= thd->lex, newlex; String defstr; - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; @@ -1928,7 +1928,7 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, Hence, the overrun happens only if the name is in length > 32 and uses multibyte (cyrillic, greek, etc.) */ - char n[NAME_LEN*2+2]; + char n[SAFE_NAME_LEN*2+2]; /* m_qname.str is not always \0 terminated */ memcpy(n, name.m_qname.str, name.m_qname.length); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1084c3efc82..2d5eb24de7f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1085,7 +1085,7 @@ bool sp_head::execute(THD *thd) { DBUG_ENTER("sp_head::execute"); - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed= FALSE; @@ -3851,7 +3851,7 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check) for (; table ; table= table->next_global) if (!table->derived && !table->schema_table) { - char tname[(NAME_LEN + 1) * 3]; // db\0table\0alias\0 + char tname[(SAFE_NAME_LEN + 1) * 3]; // db\0table\0alias\0 uint tlen, alen; tlen= table->db_length; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5e03175dd72..24f590f893a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -313,7 +313,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) READ_RECORD read_record_info; my_bool return_val= TRUE; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; - char tmp_name[NAME_LEN+1]; + char tmp_name[SAFE_NAME_LEN+1]; int password_length; ulong old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("acl_load"); @@ -2453,7 +2453,7 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, const char *user, const char *tname, bool exact, bool name_tolower) { - char helping [NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr; + char helping [SAFE_NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr; uint len; GRANT_NAME *grant_name,*found=0; HASH_SEARCH_STATE state; @@ -3431,7 +3431,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, { List_iterator <LEX_USER> str_list (list); LEX_USER *Str, *tmp_Str; - char tmp_db[NAME_LEN+1]; + char tmp_db[SAFE_NAME_LEN+1]; bool create_new_users=0; TABLE_LIST tables[2]; bool save_binlog_row_based; @@ -4316,7 +4316,7 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash) bool check_grant_db(THD *thd,const char *db) { Security_context *sctx= thd->security_ctx; - char helping [NAME_LEN+USERNAME_LENGTH+2]; + char helping [SAFE_NAME_LEN + USERNAME_LENGTH+2]; uint len; bool error= TRUE; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1c8648afafd..33ea834247e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -613,7 +613,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type) TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name) { - char key[NAME_LEN*2+2]; + char key[SAFE_NAME_LEN*2+2]; TABLE_LIST table_list; uint key_length; safe_mutex_assert_owner(&LOCK_open); @@ -6311,7 +6311,7 @@ find_field_in_tables(THD *thd, Item_ident *item, const char *table_name= item->table_name; const char *name= item->field_name; uint length=(uint) strlen(name); - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; TABLE_LIST *cur_table= first_table; TABLE_LIST *actual_table; bool allow_rowid; @@ -6468,7 +6468,7 @@ find_field_in_tables(THD *thd, Item_ident *item, (report_error == REPORT_ALL_ERRORS || report_error == REPORT_EXCEPT_NON_UNIQUE)) { - char buff[NAME_LEN*2 + 2]; + char buff[SAFE_NAME_LEN*2 + 2]; if (db && db[0]) { strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS); @@ -7854,7 +7854,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, { Field_iterator_table_ref field_iterator; bool found; - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; DBUG_ENTER("insert_fields"); DBUG_PRINT("arena", ("stmt arena: 0x%lx", (ulong)thd->stmt_arena)); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 67d52b26900..4811ce3cb45 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -851,8 +851,8 @@ static int check_connection(THD *thd) char *passwd= strend(user)+1; uint user_len= passwd - user - 1; char *db= passwd; - char db_buff[NAME_LEN + 1]; // buffer to store db in utf8 - char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 + char db_buff[SAFE_NAME_LEN*2 + 1]; // buffer to store db in utf8 + char user_buff[USERNAME_LENGTH*2 + 1]; // buffer to store user in utf8 uint dummy_errors; /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fddd8626a19..0148854165e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1125,7 +1125,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, Cast *passwd to an unsigned char, so that it doesn't extend the sign for *passwd > 127 and become 2**32-127 after casting to uint. */ - char db_buff[NAME_LEN+1]; // buffer to store db in utf8 + char db_buff[SAFE_NAME_LEN*2+1]; // buffer to store db in utf8 char *db= passwd; char *save_db; /* @@ -1329,7 +1329,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *fields, *packet_end= packet + packet_length, *wildcard; /* Locked closure of all tables */ TABLE_LIST table_list; - char db_buff[NAME_LEN+1]; + char db_buff[SAFE_NAME_LEN+1]; uint32 db_length; uint dummy_errors, query_length; @@ -1348,7 +1348,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, db_length= wildcard - packet; wildcard++; query_length= (uint) (packet_end - wildcard); // Don't count end \0 - if (db_length > NAME_LEN || query_length > NAME_LEN) + if (db_length > SAFE_NAME_LEN || query_length > NAME_LEN) { my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index f5594dfe520..cde5005b038 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3338,7 +3338,7 @@ reexecute: bool Prepared_statement::reprepare() { - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; LEX_STRING stmt_db_name= { db, db_length }; @@ -3499,7 +3499,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) Query_arena *old_stmt_arena; bool error= TRUE; - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f7da7413eef..8381e257e26 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16707,7 +16707,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, the UNION to provide precise EXPLAIN information will hardly be appreciated :) */ - char table_name_buffer[NAME_LEN]; + char table_name_buffer[SAFE_NAME_LEN]; item_list.empty(); /* id */ item_list.push_back(new Item_null); @@ -16780,7 +16780,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, char buff1[512], buff2[512], buff3[512]; char keylen_str_buf[64]; String extra(buff, sizeof(buff),cs); - char table_name_buffer[NAME_LEN]; + char table_name_buffer[SAFE_NAME_LEN]; String tmp1(buff1,sizeof(buff1),cs); String tmp2(buff2,sizeof(buff2),cs); String tmp3(buff3,sizeof(buff3),cs); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 30d6b13b0c9..683b0e67929 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -493,7 +493,7 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db, for (i=0 ; i < (uint) dirp->number_off_files ; i++) { - char uname[NAME_LEN + 1]; /* Unencoded name */ + char uname[SAFE_NAME_LEN + 1]; /* Unencoded name */ file=dirp->dir_entry+i; if (dir) { /* Return databases */ @@ -4254,7 +4254,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, MYSQL_TIME time; LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; - char sp_db_buff[NAME_LEN + 1], sp_name_buff[NAME_LEN + 1], + char sp_db_buff[SAFE_NAME_LEN + 1], sp_name_buff[SAFE_NAME_LEN + 1], definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 2]; String sp_db(sp_db_buff, sizeof(sp_db_buff), cs); String sp_name(sp_name_buff, sizeof(sp_name_buff), cs); @@ -6589,8 +6589,8 @@ ST_FIELD_INFO table_names_fields_info[]= { {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_", - SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH, + MYSQL_TYPE_STRING, 0, 0, "Tables_in_", SKIP_OPEN_TABLE}, {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1d3bb23cc3d..a0621dbbdcf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,6 +54,7 @@ static bool mysql_prepare_alter_table(THD *thd, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info); +static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list); #ifndef DBUG_OFF @@ -4172,7 +4173,7 @@ mysql_rename_table(handlerton *base, const char *old_db, char from[FN_REFLEN + 1], to[FN_REFLEN + 1], lc_from[FN_REFLEN + 1], lc_to[FN_REFLEN + 1]; char *from_base= from, *to_base= to; - char tmp_name[NAME_LEN+1]; + char tmp_name[SAFE_NAME_LEN+1]; handler *file; int error=0; DBUG_ENTER("mysql_rename_table"); @@ -4567,6 +4568,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, Protocol *protocol= thd->protocol; LEX *lex= thd->lex; int result_code; + bool need_repair_or_alter= 0; DBUG_ENTER("mysql_admin_table"); if (end_active_trans(thd)) @@ -4587,7 +4589,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, for (table= tables; table; table= table->next_local) { - char table_name[NAME_LEN*2+2]; + char table_name[SAFE_NAME_LEN*2+2]; char* db = table->db; bool fatal_error=0; @@ -4795,32 +4797,35 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (operator_func == &handler::ha_repair && !(check_opt->sql_flags & TT_USEFRM)) { - if ((table->table->file->check_old_types() == HA_ADMIN_NEEDS_ALTER) || - (table->table->file->ha_check_for_upgrade(check_opt) == - HA_ADMIN_NEEDS_ALTER)) + handler *file= table->table->file; + int check_old_types= file->check_old_types(); + int check_for_upgrade= file->ha_check_for_upgrade(check_opt); + + if (check_old_types == HA_ADMIN_NEEDS_ALTER || + check_for_upgrade == HA_ADMIN_NEEDS_ALTER) { - DBUG_PRINT("admin", ("recreating table")); - ha_autocommit_or_rollback(thd, 1); - close_thread_tables(thd); - tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table); - reenable_binlog(thd); - /* - mysql_recreate_table() can push OK or ERROR. - Clear 'OK' status. If there is an error, keep it: - we will store the error message in a result set row - and then clear. - */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + result_code= admin_recreate_table(thd, table); goto send_result; } + if (check_old_types || check_for_upgrade) + { + /* If repair is not implemented for the engine, run ALTER TABLE */ + need_repair_or_alter= 1; + } } DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name)); result_code = (table->table->file->*operator_func)(thd, check_opt); DBUG_PRINT("admin", ("operator_func returned: %d", result_code)); + if (result_code == HA_ADMIN_NOT_IMPLEMENTED && need_repair_or_alter) + { + /* + repair was not implemented and we need to upgrade the table + to a new version so we recreate the table with ALTER TABLE + */ + result_code= admin_recreate_table(thd, table); + } send_result: lex->cleanup_after_one_table_open(); @@ -4920,23 +4925,13 @@ send_result_message: system_charset_info); if (protocol->write()) goto err; - ha_autocommit_or_rollback(thd, 0); - close_thread_tables(thd); DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze...")); TABLE_LIST *save_next_local= table->next_local, *save_next_global= table->next_global; table->next_local= table->next_global= 0; - tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table); - reenable_binlog(thd); - /* - mysql_recreate_table() can push OK or ERROR. - Clear 'OK' status. If there is an error, keep it: - we will store the error message in a result set row - and then clear. - */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + + result_code= admin_recreate_table(thd, table); + ha_autocommit_or_rollback(thd, 0); close_thread_tables(thd); if (!result_code) // recreation went ok @@ -7954,6 +7949,30 @@ err: } +/* Prepare, run and cleanup for mysql_recreate_table() */ + +static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list) +{ + bool result_code; + DBUG_ENTER("admin_recreate_table"); + + ha_autocommit_or_rollback(thd, 1); + close_thread_tables(thd); + tmp_disable_binlog(thd); // binlogging is done by caller if wanted + result_code= mysql_recreate_table(thd, table_list); + reenable_binlog(thd); + /* + mysql_recreate_table() can push OK or ERROR. + Clear 'OK' status. If there is an error, keep it: + we will store the error message in a result set row + and then clear. + */ + if (thd->main_da.is_ok()) + thd->main_da.reset_diagnostics_area(); + DBUG_RETURN(result_code); +} + + /* Recreates tables by calling mysql_alter_table(). @@ -8010,7 +8029,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, /* Open one table after the other to keep lock time as short as possible. */ for (table= tables; table; table= table->next_local) { - char table_name[NAME_LEN*2+2]; + char table_name[SAFE_NAME_LEN*2+2]; TABLE *t; strxmov(table_name, table->db ,".", table->table_name, NullS); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bf4a46a4c67..e8a382ca8f6 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1391,7 +1391,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, To remove this prefix we use check_n_cut_mysql50_prefix(). */ - char fname[NAME_LEN + 1]; + char fname[SAFE_NAME_LEN + 1]; DBUG_ASSERT((!my_strcasecmp(table_alias_charset, lex.query_tables->db, db) || (check_n_cut_mysql50_prefix(db, fname, sizeof(fname)) && !my_strcasecmp(table_alias_charset, lex.query_tables->db, fname))) && @@ -1917,7 +1917,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, */ if (my_strcasecmp(table_alias_charset, db, new_db)) { - char dbname[NAME_LEN + 1]; + char dbname[SAFE_NAME_LEN + 1]; if (check_n_cut_mysql50_prefix(db, dbname, sizeof(dbname)) && !my_strcasecmp(table_alias_charset, dbname, new_db)) { diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index d455a66c4f2..584704d869f 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -209,7 +209,7 @@ void udf_init() } tmp->dlhandle = dl; { - char buf[NAME_LEN+16], *missing; + char buf[SAFE_NAME_LEN+16], *missing; if ((missing= init_syms(tmp, buf))) { sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), missing); @@ -463,7 +463,7 @@ int mysql_create_function(THD *thd,udf_func *udf) } udf->dlhandle=dl; { - char buf[NAME_LEN+16], *missing; + char buf[SAFE_NAME_LEN+16], *missing; if ((missing= init_syms(udf, buf))) { my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), missing); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 280d33aa654..4d92f234ed0 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1189,7 +1189,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local; { - char old_db_buf[NAME_LEN+1]; + char old_db_buf[SAFE_NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; Parser_state parser_state; diff --git a/sql/table.cc b/sql/table.cc index 2129da90a29..a7ed2dd40ff 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2699,15 +2699,15 @@ bool check_db_name(LEX_STRING *org_name) uint name_length= org_name->length; bool check_for_path_chars; - if (!name_length || name_length > NAME_LEN) - return 1; - if ((check_for_path_chars= check_mysql50_prefix(name))) { name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH; name_length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH; } + if (!name_length || name_length > NAME_LEN) + return 1; + if (lower_case_table_names && name != any_db) my_casedn_str(files_charset_info, name); @@ -2725,6 +2725,15 @@ bool check_table_name(const char *name, uint length, bool check_for_path_chars) { uint name_length= 0; // name length in symbols const char *end= name+length; + + + if (!check_for_path_chars && + (check_for_path_chars= check_mysql50_prefix(name))) + { + name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + } + if (!length || length > NAME_LEN) return 1; #if defined(USE_MB) && defined(USE_MB_IDENT) |