1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-05 12:42:17 +03:00

(manual port from 4.0 - was needed)

Fix for BUG#4971 "CREATE TABLE ... TYPE=HEAP SELECT ... stops slave (wrong DELETE in binlog)":
replacing the no_log argument of mysql_create_table() by some safer method
(temporarily setting OPTION_BIN_LOG to 0) which guarantees that even the automatic
DELETE FROM heap_table does not get into the binlog when a not-yet-existing HEAP table
is opened by mysql_create_table().
This commit is contained in:
guilhem@mysql.com
2004-08-19 23:24:35 +02:00
parent 2d7f4c30a7
commit 0db5b4d202
7 changed files with 68 additions and 20 deletions

View File

@ -1090,7 +1090,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
keys List of keys to create
tmp_table Set to 1 if this is an internal temporary table
(From ALTER TABLE)
no_log Don't log the query to binary log.
DESCRIPTION
If one creates a temporary table, this is automaticly opened
@ -1108,7 +1107,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
int mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields,
List<Key> &keys,bool tmp_table,bool no_log,
List<Key> &keys,bool tmp_table,
uint select_field_count)
{
char path[FN_REFLEN];
@ -1277,7 +1276,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
}
thd->tmp_table_used= 1;
}
if (!tmp_table && !no_log)
if (!tmp_table)
{
// Must be written before unlock
mysql_update_log.write(thd,thd->query, thd->query_length);
@ -1352,6 +1351,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
TABLE *table;
tmp_table.table_name=0;
uint select_field_count= items->elements;
Disable_binlog disable_binlog(thd);
DBUG_ENTER("create_table_from_items");
/* Add selected items to field list */
@ -1382,9 +1382,17 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
}
/* create and lock table */
/* QQ: This should be done atomic ! */
/* We don't log the statement, it will be logged later */
if (mysql_create_table(thd,db,name,create_info,*extra_fields,
*keys,0,1,select_field_count)) // no logging
*keys,0,select_field_count))
DBUG_RETURN(0);
/*
If this is a HEAP table, the automatic DELETE FROM which is written to the
binlog when a HEAP table is opened for the first time since startup, must
not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we
don't want to delete from it) 2) it would be written before the CREATE
TABLE, which is a wrong order. So we keep binary logging disabled.
*/
if (!(table=open_table(thd,db,name,name,(bool*) 0)))
{
quick_rm_table(create_info->db_type,db,table_case_name(create_info,name));
@ -1401,6 +1409,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
}
table->file->extra(HA_EXTRA_WRITE_CACHE);
DBUG_RETURN(table);
/* Note that leaving the function resets binlogging properties */
}
@ -3008,12 +3017,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
else
create_info->data_file_name=create_info->index_file_name=0;
if ((error=mysql_create_table(thd, new_db, tmp_name,
create_info,
create_list,key_list,1,1,0))) // no logging
DBUG_RETURN(error);
{
/* We don't log the statement, it will be logged later */
Disable_binlog disable_binlog(thd);
if ((error=mysql_create_table(thd, new_db, tmp_name,
create_info,
create_list,key_list,1,0)))
DBUG_RETURN(error);
}
if (table->tmp_table)
new_table=open_table(thd,new_db,tmp_name,tmp_name,0);
else