mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE <name>
UPGRADE)
Bug 17565 (RENAME DATABASE destroys events)
Bug#28360 (RENAME DATABASE destroys routines)
Removed the
RENAME DATABASE db1 TO db2
statement.
Implemented the
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
statement, which has the same function.
client/mysqlcheck.c:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/create.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/query_cache.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/renamedb.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/sp-code.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/sp-error.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/upgrade.result:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/create.test:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/query_cache.test:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/renamedb.test:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/sp-error.test:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/upgrade.test:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/mysql_priv.h:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_lex.h:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_parse.cc:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_prepare.cc:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_yacc.yy:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_db.cc:
ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
This commit is contained in:
@@ -539,13 +539,13 @@ static int process_all_tables_in_db(char *database)
|
||||
|
||||
|
||||
|
||||
static int fix_object_name(const char *obj, const char *name)
|
||||
static int fix_table_storage_name(const char *name)
|
||||
{
|
||||
char qbuf[100 + NAME_LEN*4];
|
||||
int rc= 0;
|
||||
if (strncmp(name, "#mysql50#", 9))
|
||||
return 1;
|
||||
sprintf(qbuf, "RENAME %s `%s` TO `%s`", obj, name, name + 9);
|
||||
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
|
||||
if (mysql_query(sock, qbuf))
|
||||
{
|
||||
fprintf(stderr, "Failed to %s\n", qbuf);
|
||||
@@ -557,6 +557,23 @@ static int fix_object_name(const char *obj, const char *name)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int fix_database_storage_name(const char *name)
|
||||
{
|
||||
char qbuf[100 + NAME_LEN*4];
|
||||
int rc= 0;
|
||||
if (strncmp(name, "#mysql50#", 9))
|
||||
return 1;
|
||||
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
|
||||
if (mysql_query(sock, qbuf))
|
||||
{
|
||||
fprintf(stderr, "Failed to %s\n", qbuf);
|
||||
fprintf(stderr, "Error: %s\n", mysql_error(sock));
|
||||
rc= 1;
|
||||
}
|
||||
if (verbose)
|
||||
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int process_one_db(char *database)
|
||||
{
|
||||
@@ -565,7 +582,7 @@ static int process_one_db(char *database)
|
||||
int rc= 0;
|
||||
if (opt_fix_db_names && !strncmp(database,"#mysql50#", 9))
|
||||
{
|
||||
rc= fix_object_name("DATABASE", database);
|
||||
rc= fix_database_storage_name(database);
|
||||
database+= 9;
|
||||
}
|
||||
if (rc || !opt_fix_table_names)
|
||||
@@ -620,7 +637,7 @@ static int handle_request_for_tables(char *tables, uint length)
|
||||
op= (opt_write_binlog) ? "OPTIMIZE" : "OPTIMIZE NO_WRITE_TO_BINLOG";
|
||||
break;
|
||||
case DO_UPGRADE:
|
||||
return fix_object_name("TABLE", tables);
|
||||
return fix_table_storage_name(tables);
|
||||
}
|
||||
|
||||
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
|
||||
|
||||
Reference in New Issue
Block a user