Commit fad7a4ba authored by unknown's avatar unknown

Merge spachev@bk-internal.mysql.com:/home/bk/mysql-4.1

into  asksasha.com:/reiser-data/mysql-dev/mysql-4.1

parents ad8c5c9d 4652c6b0
...@@ -1054,3 +1054,5 @@ vio/test-sslclient ...@@ -1054,3 +1054,5 @@ vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
ndb/tools/ndb_config ndb/tools/ndb_config
support-files/MacOSX/postflight
support-files/MacOSX/preflight
This diff is collapsed.
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (n int not null primary key);
insert into t1 values (1);
create table t2 (n int);
insert into t2 values (1);
insert ignore into t1 select * from t2;
insert into t1 values (2);
select * from t1;
n
1
2
drop table t1,t2;
# test case for BUG#4680 -- if there are extra files in the db directory
# dropping the db on the master causes replication problems
-- source include/master-slave.inc
connection master;
--disable_warnings
drop database if exists d1;
--enable_warnings
create database d1;
create table d1.t1 (n int);
insert into d1.t1 values (1);
select * from d1.t1 into outfile 'd1/f1.txt';
create table d1.t2 (n int);
create table d1.t3 (n int);
--error 1010
drop database d1;
use d1;
show tables;
# test the branch of the code that deals with the query buffer overflow
let $1=1000;
while ($1)
{
eval create table d1.t$1(n int);
dec $1;
}
--error 1010
drop database d1;
use d1;
show tables;
use test;
create table t1 (n int);
insert into t1 values (1234);
sync_slave_with_master;
connection slave;
use d1;
show tables;
use test;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
#cleanup
connection slave;
stop slave;
system rm -rf var/master-data/d1;
# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key
# breaks replication
-- source include/master-slave.inc
connection master;
create table t1 (n int not null primary key);
insert into t1 values (1);
create table t2 (n int);
insert into t2 values (1);
insert ignore into t1 select * from t2;
insert into t1 values (2);
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
drop table t1,t2;
sync_slave_with_master;
...@@ -25,14 +25,20 @@ ...@@ -25,14 +25,20 @@
#include <direct.h> #include <direct.h>
#endif #endif
#define MAX_DROP_TABLE_Q_LEN 1024
const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS}; const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS};
static TYPELIB deletable_extentions= static TYPELIB deletable_extentions=
{array_elements(del_exts)-1,"del_exts", del_exts, NULL}; {array_elements(del_exts)-1,"del_exts", del_exts, NULL};
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
const char *db, const char *path, const char *db, const char *path, uint level,
uint level); TABLE_LIST** dropped_tables);
static inline void write_to_binlog(THD* thd, char* query, uint q_len,
char* db, uint db_len);
/* Database options hash */ /* Database options hash */
static HASH dboptions; static HASH dboptions;
static my_bool dboptions_init= 0; static my_bool dboptions_init= 0;
...@@ -57,6 +63,19 @@ static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, ...@@ -57,6 +63,19 @@ static byte* dboptions_get_key(my_dbopt_t *opt, uint *length,
return (byte*) opt->name; return (byte*) opt->name;
} }
/*
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 Function to free dboptions hash element
...@@ -585,6 +604,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -585,6 +604,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1];
MY_DIR *dirp; MY_DIR *dirp;
uint length; uint length;
TABLE_LIST* dropped_tables= 0;
DBUG_ENTER("mysql_rm_db"); DBUG_ENTER("mysql_rm_db");
VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
...@@ -621,8 +641,10 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -621,8 +641,10 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
remove_db_from_cache(db); remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
error= -1; 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); ha_drop_database(path);
query_cache_invalidate1(db); query_cache_invalidate1(db);
...@@ -672,6 +694,45 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -672,6 +694,45 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
send_ok(thd, (ulong) deleted); send_ok(thd, (ulong) deleted);
thd->server_status&= ~SERVER_STATUS_DB_DROPPED; thd->server_status&= ~SERVER_STATUS_DB_DROPPED;
} }
else if (mysql_bin_log.is_open())
{
char* query= thd->alloc(MAX_DROP_TABLE_Q_LEN);
if (!query)
goto exit; /* not much else we can do */
char* p= strmov(query,"drop table ");
char* p_end= query + MAX_DROP_TABLE_Q_LEN;
TABLE_LIST* tbl;
bool last_query_needs_write= 0;
uint db_len= strlen(db);
for (tbl= dropped_tables;tbl;tbl= tbl->next)
{
if (!tbl->was_dropped)
continue;
/* 3 for the quotes and the comma*/
uint tbl_name_len= strlen(tbl->real_name) + 3;
if (p + tbl_name_len + 1 >= p_end)
{
*--p= 0; /* kill , */
write_to_binlog(thd, query, p - query, db, db_len);
p= query + 11; /* reuse the initial "drop table" */
}
*p++ = '`';
p= strmov(p,tbl->real_name);
*p++ = '`';
*p++ = ',';
last_query_needs_write= 1;
}
if (last_query_needs_write)
{
*--p= 0;
write_to_binlog(thd, query, p - query, db, db_len);
}
}
exit: exit:
start_waiting_global_read_lock(thd); start_waiting_global_read_lock(thd);
...@@ -716,7 +777,7 @@ exit2: ...@@ -716,7 +777,7 @@ exit2:
*/ */
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, 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; long deleted=0;
ulong found_other_files=0; ulong found_other_files=0;
...@@ -758,7 +819,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, ...@@ -758,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)))) if ((new_dirp = my_dir(newpath,MYF(MY_DONT_SORT))))
{ {
DBUG_PRINT("my",("New subdir found: %s", newpath)); 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; goto err;
if (!(copy_of_path= thd->memdup(newpath, length+1)) || if (!(copy_of_path= thd->memdup(newpath, length+1)) ||
!(dir= new (thd->mem_root) String(copy_of_path, length, !(dir= new (thd->mem_root) String(copy_of_path, length,
...@@ -818,6 +879,9 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, ...@@ -818,6 +879,9 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
} }
my_dirend(dirp); my_dirend(dirp);
if (dropped_tables)
*dropped_tables= tot_list;
/* /*
If the directory is a symbolic link, remove the link first, then If the directory is a symbolic link, remove the link first, then
remove the directory the symbolic link pointed at remove the directory the symbolic link pointed at
......
...@@ -220,6 +220,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -220,6 +220,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table=tables ; table ; table=table->next) for (table=tables ; table ; table=table->next)
{ {
char *db=table->db; char *db=table->db;
table->was_dropped= 0;
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL); mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL);
if (!close_temporary_table(thd, db, table->real_name)) if (!close_temporary_table(thd, db, table->real_name))
{ {
...@@ -280,6 +281,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -280,6 +281,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
wrong_tables.append(','); wrong_tables.append(',');
wrong_tables.append(String(table->real_name,system_charset_info)); wrong_tables.append(String(table->real_name,system_charset_info));
} }
else
table->was_dropped= 1;
} }
thd->tmp_table_used= tmp_table_deleted; thd->tmp_table_used= tmp_table_deleted;
error= 0; error= 0;
......
...@@ -235,6 +235,9 @@ typedef struct st_table_list ...@@ -235,6 +235,9 @@ typedef struct st_table_list
bool cacheable_table; /* stop PS caching */ bool cacheable_table; /* stop PS caching */
/* used in multi-upd privelege check */ /* used in multi-upd privelege check */
bool table_in_update_from_clause; bool table_in_update_from_clause;
/* used for proper partially successful DROP DATABASE binlogging */
bool was_dropped;
} TABLE_LIST; } TABLE_LIST;
typedef struct st_changed_table_list typedef struct st_changed_table_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment