mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge mishka.local:/home/my/mysql-4.1
into mishka.local:/home/my/mysql-5.0 BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-Grep.cpp~ad798e9ae519d667: Auto merged BitKeeper/deleted/.del-Grep.hpp~b05e3af6cfabe387: Auto merged BitKeeper/deleted/.del-ctype_cp932.result: Auto merged BitKeeper/deleted/.del-ctype_cp932.test: Auto merged BitKeeper/deleted/.del-have_lowercase0.inc: Delete: mysql-test/include/have_lowercase0.inc VC++Files/mysql-test/mysql_test_run_new.dsp: Auto merged configure.in: Auto merged mysql-test/include/ps_conv.inc: Auto merged mysql-test/mysql-test-run.pl: Auto merged sql/ha_innodb.cc: Auto merged sql/mysql_priv.h: Auto merged sql/set_var.cc: Auto merged sql/examples/ha_archive.cc: Auto merged sql/examples/ha_example.cc: Auto merged sql/sql_table.cc: Auto merged support-files/mysql.spec.sh: Auto merged VC++Files/client/mysqltest.dsp: manual merge VC++Files/sql/mysqld.dsp: manual merge mysql-test/r/grant2.result: patch merge mysql-test/r/subselect2.result: manual merge mysql-test/t/grant2.test: patch merge mysys/charset.c: Remove already deleted function sql/examples/ha_archive.h: Manual merge sql/sql_acl.cc: manual merge sql/sql_db.cc: merge (no differences) sql/sql_select.cc: manual merge sql/table.h: merge (no differences) tests/mysql_client_test.c: patch merge
This commit is contained in:
@@ -26,13 +26,16 @@
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#define MAX_DROP_TABLE_Q_LEN 1024
|
||||
|
||||
const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS};
|
||||
static TYPELIB deletable_extentions=
|
||||
{array_elements(del_exts)-1,"del_exts", del_exts, NULL};
|
||||
|
||||
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
|
||||
const char *db, const char *path,
|
||||
uint level);
|
||||
const char *db, const char *path, uint level,
|
||||
TABLE_LIST **dropped_tables);
|
||||
|
||||
static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
|
||||
static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error);
|
||||
/* Database options hash */
|
||||
@@ -52,6 +55,7 @@ typedef struct my_dbopt_st
|
||||
/*
|
||||
Function we use in the creation of our hash to get key.
|
||||
*/
|
||||
|
||||
static byte* dboptions_get_key(my_dbopt_t *opt, uint *length,
|
||||
my_bool not_used __attribute__((unused)))
|
||||
{
|
||||
@@ -60,6 +64,21 @@ static byte* dboptions_get_key(my_dbopt_t *opt, uint *length,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Helper function to write a query to binlog used by mysql_rm_db()
|
||||
*/
|
||||
|
||||
static inline void write_to_binlog(THD *thd, char *query, uint q_len,
|
||||
char *db, uint db_len)
|
||||
{
|
||||
Query_log_event qinfo(thd, query, q_len, 0, 0);
|
||||
qinfo.error_code= 0;
|
||||
qinfo.db= db;
|
||||
qinfo.db_len= db_len;
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function to free dboptions hash element
|
||||
*/
|
||||
@@ -593,6 +612,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
||||
char path[FN_REFLEN+16];
|
||||
MY_DIR *dirp;
|
||||
uint length;
|
||||
TABLE_LIST* dropped_tables= 0;
|
||||
DBUG_ENTER("mysql_rm_db");
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
|
||||
@@ -629,8 +649,10 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
||||
remove_db_from_cache(db);
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
|
||||
|
||||
error= -1;
|
||||
if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0)
|
||||
if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0,
|
||||
&dropped_tables)) >= 0)
|
||||
{
|
||||
ha_drop_database(path);
|
||||
query_cache_invalidate1(db);
|
||||
@@ -672,6 +694,43 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
||||
send_ok(thd, (ulong) deleted);
|
||||
thd->server_status&= ~SERVER_STATUS_DB_DROPPED;
|
||||
}
|
||||
else if (mysql_bin_log.is_open())
|
||||
{
|
||||
char *query, *query_pos, *query_end, *query_data_start;
|
||||
TABLE_LIST *tbl;
|
||||
uint db_len;
|
||||
|
||||
if (!(query= thd->alloc(MAX_DROP_TABLE_Q_LEN)))
|
||||
goto exit; /* not much else we can do */
|
||||
query_pos= query_data_start= strmov(query,"drop table ");
|
||||
query_end= query + MAX_DROP_TABLE_Q_LEN;
|
||||
db_len= strlen(db);
|
||||
|
||||
for (tbl= dropped_tables; tbl; tbl= tbl->next)
|
||||
{
|
||||
uint tbl_name_len;
|
||||
if (!tbl->was_dropped)
|
||||
continue;
|
||||
|
||||
/* 3 for the quotes and the comma*/
|
||||
tbl_name_len= strlen(tbl->real_name) + 3;
|
||||
if (query_pos + tbl_name_len + 1 >= query_end)
|
||||
{
|
||||
write_to_binlog(thd, query, query_pos -1 - query, db, db_len);
|
||||
query_pos= query_data_start;
|
||||
}
|
||||
|
||||
*query_pos++ = '`';
|
||||
query_pos= strmov(query_pos,tbl->real_name);
|
||||
*query_pos++ = '`';
|
||||
*query_pos++ = ',';
|
||||
}
|
||||
|
||||
if (query_pos != query_data_start)
|
||||
{
|
||||
write_to_binlog(thd, query, query_pos -1 - query, db, db_len);
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
(void)sp_drop_db_routines(thd, db); /* QQ Ignore errors for now */
|
||||
@@ -717,7 +776,8 @@ exit2:
|
||||
*/
|
||||
|
||||
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
|
||||
const char *org_path, uint level)
|
||||
const char *org_path, uint level,
|
||||
TABLE_LIST **dropped_tables)
|
||||
{
|
||||
long deleted=0;
|
||||
ulong found_other_files=0;
|
||||
@@ -759,7 +819,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
|
||||
if ((new_dirp = my_dir(newpath,MYF(MY_DONT_SORT))))
|
||||
{
|
||||
DBUG_PRINT("my",("New subdir found: %s", newpath));
|
||||
if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1)) < 0)
|
||||
if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1,0)) < 0)
|
||||
goto err;
|
||||
if (!(copy_of_path= thd->memdup(newpath, length+1)) ||
|
||||
!(dir= new (thd->mem_root) String(copy_of_path, length,
|
||||
@@ -837,6 +897,9 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
|
||||
}
|
||||
my_dirend(dirp);
|
||||
|
||||
if (dropped_tables)
|
||||
*dropped_tables= tot_list;
|
||||
|
||||
/*
|
||||
If the directory is a symbolic link, remove the link first, then
|
||||
remove the directory the symbolic link pointed at
|
||||
|
Reference in New Issue
Block a user