summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorLuis Soares <luis.soares@oracle.com>2010-12-16 19:11:08 +0000
committerLuis Soares <luis.soares@oracle.com>2010-12-16 19:11:08 +0000
commit2d9080ff2941d916ba047f652b2e7165899da6c4 (patch)
treea6edecd2cb28ff7a9782664037a67ee1290074f4 /sql/sql_parse.cc
parent338e0d5cac3a772efe2b4ac451f4defd28c4a4ce (diff)
parentffc16a2d06deb125f7ead5c4a9f6eb1fb3b48379 (diff)
downloadmariadb-git-2d9080ff2941d916ba047f652b2e7165899da6c4.tar.gz
BUG#46166
Merging to latest mysql-5.1-bugteam.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index abfc2ec26b3..8225ea64fc0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1474,7 +1474,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
case COM_REFRESH:
{
- bool not_used;
+ int not_used;
status_var_increment(thd->status_var.com_stat[SQLCOM_FLUSH]);
ulong options= (ulong) (uchar) packet[0];
if (check_global_access(thd,RELOAD_ACL))
@@ -3227,7 +3227,11 @@ end_with_restore_list:
{
Incident_log_event ev(thd, incident);
(void) mysql_bin_log.write(&ev); /* error is ignored */
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
+ if (mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE))
+ {
+ res= 1;
+ break;
+ }
}
DBUG_PRINT("debug", ("Just after generate_incident()"));
}
@@ -4051,7 +4055,7 @@ end_with_restore_list:
lex->no_write_to_binlog= 1;
case SQLCOM_FLUSH:
{
- bool write_to_binlog;
+ int write_to_binlog;
if (check_global_access(thd,RELOAD_ACL))
goto error;
@@ -4068,12 +4072,22 @@ end_with_restore_list:
/*
Presumably, RESET and binlog writing doesn't require synchronization
*/
- if (!lex->no_write_to_binlog && write_to_binlog)
+
+ if (write_to_binlog > 0) // we should write
+ {
+ if (!lex->no_write_to_binlog)
+ res= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
+ } else if (write_to_binlog < 0)
{
- if ((res= write_bin_log(thd, FALSE, thd->query(), thd->query_length())))
- break;
- }
- my_ok(thd);
+ /*
+ We should not write, but rather report error because
+ reload_acl_and_cache binlog interactions failed
+ */
+ res= 1;
+ }
+
+ if (!res)
+ my_ok(thd);
}
break;
@@ -6855,7 +6869,10 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List<String> *using_fields,
@param thd Thread handler (can be NULL!)
@param options What should be reset/reloaded (tables, privileges, slave...)
@param tables Tables to flush (if any)
- @param write_to_binlog True if we can write to the binlog.
+ @param write_to_binlog < 0 if there was an error while interacting with the binary log inside
+ reload_acl_and_cache,
+ 0 if we should not write to the binary log,
+ > 0 if we can write to the binlog.
@note Depending on 'options', it may be very bad to write the
query to the binlog (e.g. FLUSH SLAVE); this is a
@@ -6869,11 +6886,11 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List<String> *using_fields,
*/
bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
- bool *write_to_binlog)
+ int *write_to_binlog)
{
bool result=0;
select_errors=0; /* Write if more errors */
- bool tmp_write_to_binlog= 1;
+ int tmp_write_to_binlog= *write_to_binlog= 1;
DBUG_ASSERT(!thd || !thd->in_sub_stmt);
@@ -6936,12 +6953,16 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
tmp_write_to_binlog= 0;
if( mysql_bin_log.is_open() )
{
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
+ if (mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE))
+ *write_to_binlog= -1;
}
#ifdef HAVE_REPLICATION
+ int rotate_error= 0;
pthread_mutex_lock(&LOCK_active_mi);
- rotate_relay_log(active_mi);
+ rotate_error= rotate_relay_log(active_mi);
pthread_mutex_unlock(&LOCK_active_mi);
+ if (rotate_error)
+ *write_to_binlog= -1;
#endif
/* flush slow and general logs */
@@ -7052,7 +7073,8 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
#endif
if (options & REFRESH_USER_RESOURCES)
reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */
- *write_to_binlog= tmp_write_to_binlog;
+ if (*write_to_binlog != -1)
+ *write_to_binlog= tmp_write_to_binlog;
/*
If the query was killed then this function must fail.
*/