Commit aa3c80fb authored by guilhem@mysql.com's avatar guilhem@mysql.com

Merge gbichot@213.136.52.20:/home/bk/mysql-4.1

into mysql.com:/home/mysql_src/mysql-4.1-874
parents 1b76aa07 2b20e84f
drop table if exists t1,t2;
set timestamp=1000000000;
drop table if exists t1,t2;
create table t1 (word varchar(20));
create table t2 (id int auto_increment not null primary key);
insert into t1 values ("abirvalg");
......@@ -17,6 +17,8 @@ flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
use test;
SET TIMESTAMP=1000000000;
drop table if exists t1,t2;
SET TIMESTAMP=1000000000;
create table t1 (word varchar(20));
SET TIMESTAMP=1000000000;
create table t2 (id int auto_increment not null primary key);
......@@ -51,6 +53,8 @@ insert into t1 values ("Alas");
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
use test;
SET TIMESTAMP=1000000000;
drop table if exists t1,t2;
SET TIMESTAMP=1000000000;
create table t1 (word varchar(20));
SET TIMESTAMP=1000000000;
create table t2 (id int auto_increment not null primary key);
......
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 database test1;
drop database if exists test1;
Warnings:
Note 1008 Can't drop database 'test1'; database doesn't exist
show tables from test1;
ERROR HY000: Can't read dir of './test1/' (Errcode: 2)
create table t1 (a int);
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 (a int);
insert into t1 values(1);
delete from t1;
select * from t1;
a
insert into t1 values(1);
insert into t1 values(2);
update t1 set a=2;
select * from t1;
a
2
2
drop table t1;
......@@ -14,4 +14,4 @@ start slave;
flush logs;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 79 4 None 0 No #
# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 161 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 161 4 None 0 No #
......@@ -28,4 +28,4 @@ ERROR 42S02: Table 'test.t11' doesn't exist
drop table if exists t1,t2,t11;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1325 None 0 No #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1340 slave-relay-bin.000002 1384 master-bin.000001 Yes Yes test.t1 0 0 1340 1384 None 0 No #
......@@ -39,17 +39,18 @@ f
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1(f int)
master-bin.000001 136 Query 1 136 use `test`; create table t2(f int)
master-bin.000001 193 Query 1 193 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
master-bin.000001 290 Query 1 290 use `test`; create temporary table t3(f int)
master-bin.000001 357 Query 1 357 use `test`; insert into t3 select * from t1 where f<6
master-bin.000001 433 Query 1 433 use `test`; create temporary table t3(f int)
master-bin.000001 500 Query 1 500 use `test`; insert into t2 select count(*) from t3
master-bin.000001 573 Query 1 573 use `test`; insert into t3 select * from t1 where f>=4
master-bin.000001 650 Query 1 650 use `test`; drop temporary table t3
master-bin.000001 708 Query 1 708 use `test`; insert into t2 select count(*) from t3
master-bin.000001 781 Query 1 781 use `test`; drop temporary table t3
master-bin.000001 79 Query 1 79 use `test`; drop table if exists t1,t2
master-bin.000001 140 Query 1 140 use `test`; create table t1(f int)
master-bin.000001 197 Query 1 197 use `test`; create table t2(f int)
master-bin.000001 254 Query 1 254 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
master-bin.000001 351 Query 1 351 use `test`; create temporary table t3(f int)
master-bin.000001 418 Query 1 418 use `test`; insert into t3 select * from t1 where f<6
master-bin.000001 494 Query 1 494 use `test`; create temporary table t3(f int)
master-bin.000001 561 Query 1 561 use `test`; insert into t2 select count(*) from t3
master-bin.000001 634 Query 1 634 use `test`; insert into t3 select * from t1 where f>=4
master-bin.000001 711 Query 1 711 use `test`; drop temporary table t3
master-bin.000001 769 Query 1 769 use `test`; insert into t2 select count(*) from t3
master-bin.000001 842 Query 1 842 use `test`; drop temporary table t3
drop table t1, t2;
use test;
SET TIMESTAMP=1040323920;
......
# We are using .opt file since we need small binlog size
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
# we need this for getting fixed timestamps inside of this test
set timestamp=1000000000;
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (word varchar(20));
create table t2 (id int auto_increment not null primary key);
......
source include/master-slave.inc;
connection slave;
create database test1;
connection master;
drop database if exists test1;
sync_slave_with_master;
# can't read dir
error 12;
show tables from test1;
connection slave;
create table t1 (a int);
connection master;
drop table if exists t1;
sync_slave_with_master;
# table does not exist
error 1146;
select * from t1;
connection master;
create table t1 (a int);
sync_slave_with_master;
insert into t1 values(1);
connection master;
delete from t1;
sync_slave_with_master;
select * from t1;
insert into t1 values(1);
connection master;
insert into t1 values(2);
update t1 set a=2;
sync_slave_with_master;
select * from t1;
# cleanup
connection master;
drop table t1;
sync_slave_with_master;
......@@ -358,15 +358,25 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
error= -1;
my_error(ER_DB_DROP_EXISTS,MYF(0),db);
goto exit;
}
else
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_DB_DROP_EXISTS, ER(ER_DB_DROP_EXISTS), db);
if (!silent)
send_ok(thd,0);
}
else
{
pthread_mutex_lock(&LOCK_open);
remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open);
error= -1;
if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0)
{
ha_drop_database(path);
query_cache_invalidate1(db);
error = 0;
}
goto exit;
}
if (lower_case_table_names)
{
......@@ -375,42 +385,30 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
my_casedn_str(files_charset_info, tmp_db);
db= tmp_db;
}
pthread_mutex_lock(&LOCK_open);
remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open);
error = -1;
if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd)
if (!silent && deleted>=0 && thd)
{
ha_drop_database(path);
query_cache_invalidate1(db);
if (!silent)
const char *query;
ulong query_length;
if (!thd->query)
{
const char *query;
ulong query_length;
if (!thd->query)
{
/* The client used the old obsolete mysql_drop_db() call */
query= path;
query_length = (uint) (strxmov(path,"drop database `", db, "`",
NullS)- path);
}
else
{
query=thd->query;
query_length=thd->query_length;
}
mysql_update_log.write(thd, query, query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, query, query_length, 0);
thd->clear_error();
mysql_bin_log.write(&qinfo);
}
send_ok(thd,(ulong) deleted);
/* The client used the old obsolete mysql_drop_db() call */
query= path;
query_length= (uint) (strxmov(path, "drop database `", db, "`",
NullS) - path);
}
else
{
query =thd->query;
query_length= thd->query_length;
}
mysql_update_log.write(thd, query, query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, query, query_length, 0);
thd->clear_error();
mysql_bin_log.write(&qinfo);
}
error = 0;
send_ok(thd, (ulong) deleted);
}
exit:
......
......@@ -199,7 +199,15 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if (deleted && (error <= 0 || !transactional_table))
/*
We write to the binary log even if we deleted no row, because maybe the
user is using this command to ensure that a table is clean on master *and
on slave*. Think of the case of a user having played separately with the
master's table and slave's table and wanting to take a fresh identical
start now.
error < 0 means "really no error". error <= 0 means "maybe some error".
*/
if ((deleted || (error < 0)) && (error <= 0 || !transactional_table))
{
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
......@@ -544,6 +552,8 @@ bool multi_delete::send_eof()
rows and we succeeded, or also in an error case when there
was a non-transaction-safe table involved, since
modifications in it cannot be rolled back.
Note that if we deleted nothing we don't write to the binlog (TODO:
fix this).
*/
if (deleted && (error <= 0 || normal_tables))
{
......
......@@ -254,7 +254,17 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
}
thd->tmp_table_used= tmp_table_deleted;
if (some_tables_deleted || tmp_table_deleted)
error= 0;
if (wrong_tables.length())
{
if (!foreign_key_error)
my_error(ER_BAD_TABLE_ERROR,MYF(0), wrong_tables.c_ptr());
else
my_error(ER_ROW_IS_REFERENCED, MYF(0));
error= 1;
}
if (some_tables_deleted || tmp_table_deleted || !error)
{
query_cache_invalidate3(thd, tables, 0);
if (!dont_log_query)
......@@ -262,7 +272,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
{
thd->clear_error();
if (!error)
thd->clear_error();
Query_log_event qinfo(thd, thd->query, thd->query_length,
tmp_table_deleted && !some_tables_deleted);
mysql_bin_log.write(&qinfo);
......@@ -271,15 +282,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
unlock_table_names(thd, tables);
error= 0;
if (wrong_tables.length())
{
if (!foreign_key_error)
my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr());
else
my_error(ER_ROW_IS_REFERENCED,MYF(0));
error= 1;
}
DBUG_RETURN(error);
}
......
......@@ -331,7 +331,7 @@ int mysql_update(THD *thd,
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if (updated && (error <= 0 || !transactional_table))
if ((updated || (error < 0)) && (error <= 0 || !transactional_table))
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
......@@ -1092,7 +1092,9 @@ bool multi_update::send_eof()
/*
Write the SQL statement to the binlog if we updated
rows and we succeeded or if we updated some non
transacational tables
transacational tables.
Note that if we updated nothing we don't write to the binlog (TODO:
fix this).
*/
if (updated && (local_error <= 0 || !trans_safe))
......
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