Commit 2ca7ff9d authored by unknown's avatar unknown

Replacing class Disable_binlog by macros. Patch already approved by Monty.


sql/log.cc:
  removing unneeded class Disable_binlog
sql/sql_class.h:
  removing unneeded class Disable_binlog
sql/sql_table.cc:
  As discussed, class Disable_binlog is removed and replaced by macros.
parent cf43c238
......@@ -1682,22 +1682,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
}
Disable_binlog::Disable_binlog(THD *thd_arg) :
thd(thd_arg),
save_options(thd_arg->options), save_master_access(thd_arg->master_access)
{
thd_arg->options&= ~OPTION_BIN_LOG;
thd_arg->master_access|= SUPER_ACL; // unneeded in 4.1
};
Disable_binlog::~Disable_binlog()
{
thd->options= save_options;
thd->master_access= save_master_access;
}
/*
Check if a string is a valid number
......
......@@ -638,27 +638,6 @@ class THD :public ilink
#define SYSTEM_THREAD_SLAVE_IO 2
#define SYSTEM_THREAD_SLAVE_SQL 4
/*
Disables binary logging for one thread, and resets it back to what it was
before being disabled.
Some functions (like the internal mysql_create_table() when it's called by
mysql_alter_table()) must NOT write to the binlog (binlogging is done at the
at a later stage of the command already, and must be, for locking reasons);
so we internally disable it temporarily by creating the Disable_binlog
object and reset the state by destroying the object (don't forget that! or
write code so that the object gets automatically destroyed when leaving a
block, see example in sql_table.cc).
*/
class Disable_binlog {
private:
THD *thd;
ulong save_options;
ulong save_master_access;
public:
Disable_binlog(THD *thd_arg);
~Disable_binlog();
};
/*
Used to hold information about file and file structure in exchainge
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
......
......@@ -30,6 +30,16 @@
#include <io.h>
#endif
#include "sql_acl.h" // for SUPER_ACL
# define tmp_disable_binlog(A) \
ulong save_options= (A)->options, save_master_access= (A)->master_access; \
(A)->options&= ~OPTION_BIN_LOG; \
(A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */
#define reenable_binlog(A) \
(A)->options= save_options; \
(A)->master_access= save_master_access;
extern HASH open_cache;
static const char *primary_key_name="PRIMARY";
......@@ -840,9 +850,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
MYSQL_LOCK **lock)
{
TABLE tmp_table; // Used during 'create_field()'
TABLE *table;
TABLE *table= 0;
tmp_table.table_name=0;
Disable_binlog disable_binlog(thd);
DBUG_ENTER("create_table_from_items");
/* Add selected items to field list */
......@@ -872,23 +881,25 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
extra_fields->push_back(cr_field);
}
/* 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))
DBUG_RETURN(0);
/* QQ: create and open should be done atomic ! */
/*
We don't log the statement, it will be logged later.
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.
TABLE, which is a wrong order. So we keep binary logging disabled when we
open_table().
*/
if (!(table=open_table(thd,db,name,name,(bool*) 0)))
tmp_disable_binlog(thd);
if (!mysql_create_table(thd,db,name,create_info,*extra_fields,*keys,0))
{
quick_rm_table(create_info->db_type,db,table_case_name(create_info,name));
DBUG_RETURN(0);
if (!(table=open_table(thd,db,name,name,(bool*) 0)))
quick_rm_table(create_info->db_type,db,table_case_name(create_info,name));
}
reenable_binlog(thd);
if (!table)
DBUG_RETURN(0);
table->reginfo.lock_type=TL_WRITE;
if (!((*lock)=mysql_lock_tables(thd,&table,1)))
{
......@@ -1925,14 +1936,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
else
create_info->data_file_name=create_info->index_file_name=0;
{
/*
We don't log the statement, it will be logged later. Using a block so
that disable_binlog is deleted when we leave it in either way.
*/
Disable_binlog disable_binlog(thd);
if ((error=mysql_create_table(thd, new_db, tmp_name,
create_info,
create_list,key_list,1)))
/* We don't log the statement, it will be logged later. */
tmp_disable_binlog(thd);
int error= mysql_create_table(thd, new_db, tmp_name,
create_info,create_list,key_list,1);
reenable_binlog(thd);
if (error)
DBUG_RETURN(error);
}
if (table->tmp_table)
......
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