summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/events.cc21
-rw-r--r--sql/sp.cc16
-rw-r--r--sql/sql_acl.cc45
-rw-r--r--sql/sql_class.cc9
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_delete.cc15
-rw-r--r--sql/sql_parse.cc27
-rw-r--r--sql/sql_rename.cc7
-rw-r--r--sql/sql_tablespace.cc6
-rw-r--r--sql/sql_trigger.cc9
-rw-r--r--sql/sql_udf.cc14
-rw-r--r--sql/sql_view.cc7
12 files changed, 27 insertions, 150 deletions
diff --git a/sql/events.cc b/sql/events.cc
index 7838972a5d6..2d1b3c59a4c 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -425,12 +425,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
event_queue->create_event(thd, new_element, &created);
/* Binlog the create event. */
DBUG_ASSERT(thd->query && thd->query_length);
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
}
pthread_mutex_unlock(&LOCK_event_metadata);
@@ -551,12 +546,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
new_element);
/* Binlog the alter event. */
DBUG_ASSERT(thd->query && thd->query_length);
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
}
pthread_mutex_unlock(&LOCK_event_metadata);
@@ -631,12 +621,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
event_queue->drop_event(thd, dbname, name);
/* Binlog the drop event. */
DBUG_ASSERT(thd->query && thd->query_length);
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
pthread_mutex_unlock(&LOCK_event_metadata);
DBUG_RETURN(ret);
diff --git a/sql/sp.cc b/sql/sp.cc
index 49e86f9d07e..0118169ff7c 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -650,13 +650,7 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
if (ret == SP_OK)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
-
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
sp_cache_invalidate();
}
@@ -723,13 +717,7 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
if (ret == SP_OK)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
-
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
sp_cache_invalidate();
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 59e3c0a7dd4..6d029ba87e4 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3142,12 +3142,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
if (!result) /* success */
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
rw_unlock(&LOCK_grant);
@@ -3314,12 +3309,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
pthread_mutex_unlock(&acl_cache->lock);
if (!result && !no_error)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
rw_unlock(&LOCK_grant);
@@ -3434,12 +3424,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
if (!result)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
rw_unlock(&LOCK_grant);
@@ -5468,11 +5453,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
@@ -5538,11 +5519,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
@@ -5621,11 +5598,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
@@ -5809,11 +5782,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 9dbc79344a9..5b9c9259434 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3028,15 +3028,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end)
}
-void THD::binlog_delete_pending_rows_event()
-{
- if (Rows_log_event *pending= binlog_get_pending_rows_event())
- {
- delete pending;
- binlog_set_pending_rows_event(0);
- }
-}
-
/*
Member function that will log query, either row-based or
statement-based depending on the value of the 'current_stmt_binlog_row_based'
diff --git a/sql/sql_class.h b/sql/sql_class.h
index de7aaafbe3b..1c719eb9734 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1096,7 +1096,6 @@ public:
Rows_log_event* binlog_get_pending_rows_event() const;
void binlog_set_pending_rows_event(Rows_log_event* ev);
int binlog_flush_pending_rows_event(bool stmt_end);
- void binlog_delete_pending_rows_event();
private:
uint binlog_table_maps; // Number of table maps currently in the binlog
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index fe54a12e4dc..8581803a9ad 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -975,16 +975,11 @@ end:
{
if (!error)
{
- if (mysql_bin_log.is_open())
- {
- /*
- TRUNCATE must always be statement-based binlogged (not row-based) so
- we don't test current_stmt_binlog_row_based.
- */
- thd->clear_error();
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ /*
+ TRUNCATE must always be statement-based binlogged (not row-based) so
+ we don't test current_stmt_binlog_row_based.
+ */
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
send_ok(thd); // This should return record count
}
VOID(pthread_mutex_lock(&LOCK_open));
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 411c26ea3c4..b0e6f351a6b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2504,12 +2504,7 @@ end_with_restore_list:
/*
Presumably, REPAIR and binlog writing doesn't require synchronization
*/
- if (mysql_bin_log.is_open())
- {
- thd->clear_error(); // No binlog error generated
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, 0, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
@@ -2539,12 +2534,7 @@ end_with_restore_list:
/*
Presumably, ANALYZE and binlog writing doesn't require synchronization
*/
- if (mysql_bin_log.is_open())
- {
- thd->clear_error(); // No binlog error generated
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, 0, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
@@ -2566,12 +2556,7 @@ end_with_restore_list:
/*
Presumably, OPTIMIZE and binlog writing doesn't require synchronization
*/
- if (mysql_bin_log.is_open())
- {
- thd->clear_error(); // No binlog error generated
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, 0, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
@@ -3471,11 +3456,7 @@ end_with_restore_list:
*/
if (!lex->no_write_to_binlog && write_to_binlog)
{
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, 0, FALSE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
}
send_ok(thd);
}
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index f34ec83b29c..866d82377c0 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -174,12 +174,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
/* Lets hope this doesn't fail as the result will be messy */
if (!silent && !error)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
send_ok(thd);
}
diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc
index b4a03a370ba..9fec0e3bc63 100644
--- a/sql/sql_tablespace.cc
+++ b/sql/sql_tablespace.cc
@@ -66,10 +66,6 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
ha_resolve_storage_engine_name(hton),
"TABLESPACE or LOGFILE GROUP");
}
- if (mysql_bin_log.is_open())
- {
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, TRUE);
- }
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
DBUG_RETURN(FALSE);
}
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index e15003ab243..6e8a40e68a2 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -306,14 +306,7 @@ end:
if (!result)
{
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
-
- /* Such a statement can always go directly to binlog, no trans cache. */
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- stmt_query.ptr(), stmt_query.length(), FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length());
}
VOID(pthread_mutex_unlock(&LOCK_open));
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 20ce614f361..8361fc64f33 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -493,12 +493,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
rw_unlock(&THR_LOCK_udf);
/* Binlog the create function. */
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
DBUG_RETURN(0);
@@ -569,12 +564,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
rw_unlock(&THR_LOCK_udf);
/* Binlog the drop function. */
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
DBUG_RETURN(0);
err:
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index c1e4006555f..ba13ac3520f 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1467,12 +1467,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
DBUG_RETURN(TRUE);
}
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query, thd->query_length, FALSE, FALSE);
- }
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
send_ok(thd);
VOID(pthread_mutex_unlock(&LOCK_open));