Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2b165175
Commit
2b165175
authored
15 years ago
by
He Zhenxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport Bug#37148 to 5.1
parent
16471fec
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
472 additions
and
159 deletions
+472
-159
mysql-test/include/binlog_inject_error.inc
mysql-test/include/binlog_inject_error.inc
+22
-0
mysql-test/suite/binlog/r/binlog_write_error.result
mysql-test/suite/binlog/r/binlog_write_error.result
+108
-0
mysql-test/suite/binlog/t/binlog_write_error.test
mysql-test/suite/binlog/t/binlog_write_error.test
+101
-0
sql/events.cc
sql/events.cc
+3
-3
sql/log.cc
sql/log.cc
+2
-2
sql/log_event.cc
sql/log_event.cc
+3
-3
sql/log_event_old.cc
sql/log_event_old.cc
+12
-3
sql/mysql_priv.h
sql/mysql_priv.h
+2
-2
sql/rpl_injector.cc
sql/rpl_injector.cc
+24
-17
sql/sp.cc
sql/sp.cc
+8
-5
sql/sp_head.cc
sql/sp_head.cc
+1
-0
sql/sql_acl.cc
sql/sql_acl.cc
+14
-11
sql/sql_base.cc
sql/sql_base.cc
+13
-5
sql/sql_class.h
sql/sql_class.h
+1
-1
sql/sql_db.cc
sql/sql_db.cc
+26
-9
sql/sql_delete.cc
sql/sql_delete.cc
+7
-5
sql/sql_insert.cc
sql/sql_insert.cc
+31
-20
sql/sql_load.cc
sql/sql_load.cc
+18
-14
sql/sql_parse.cc
sql/sql_parse.cc
+9
-8
sql/sql_partition.cc
sql/sql_partition.cc
+3
-2
sql/sql_rename.cc
sql/sql_rename.cc
+5
-4
sql/sql_repl.cc
sql/sql_repl.cc
+8
-5
sql/sql_table.cc
sql/sql_table.cc
+35
-27
sql/sql_tablespace.cc
sql/sql_tablespace.cc
+2
-2
sql/sql_trigger.cc
sql/sql_trigger.cc
+1
-1
sql/sql_udf.cc
sql/sql_udf.cc
+4
-4
sql/sql_update.cc
sql/sql_update.cc
+4
-3
sql/sql_view.cc
sql/sql_view.cc
+5
-3
No files found.
mysql-test/include/binlog_inject_error.inc
0 → 100644
View file @
2b165175
#
# === Name
#
# binlog_inject_error.inc
#
# === Description
#
# Inject binlog write error when running the query, verifies that the
# query is ended with the proper error (ER_ERROR_ON_WRITE).
#
# === Usage
#
# let query= 'CREATE TABLE t1 (a INT)';
# source include/binlog_inject_error.inc;
#
SET
GLOBAL
debug
=
'd,injecting_fault_writing'
;
--
echo
$query
;
--
replace_regex
/
(
errno
:
.*
)
/
(
errno
:
#)/
--
error
ER_ERROR_ON_WRITE
--
eval
$query
SET
GLOBAL
debug
=
''
;
This diff is collapsed.
Click to expand it.
mysql-test/suite/binlog/r/binlog_write_error.result
0 → 100644
View file @
2b165175
#
# Initialization
#
DROP TABLE IF EXISTS t1, t2;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP PROCEDURE IF EXISTS p1;
DROP PROCEDURE IF EXISTS p2;
DROP TRIGGER IF EXISTS tr1;
DROP TRIGGER IF EXISTS tr2;
DROP VIEW IF EXISTS v1, v2;
#
# Test injecting binlog write error when executing queries
#
SET GLOBAL debug='d,injecting_fault_writing';
CREATE TABLE t1 (a INT);
CREATE TABLE t1 (a INT);
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
INSERT INTO t1 VALUES (1),(2),(3);
SET GLOBAL debug='d,injecting_fault_writing';
INSERT INTO t1 VALUES (4),(5),(6);
INSERT INTO t1 VALUES (4),(5),(6);
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
UPDATE t1 set a=a+1;
UPDATE t1 set a=a+1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DELETE FROM t1;
DELETE FROM t1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP TRIGGER tr1;
DROP TRIGGER tr1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
ALTER TABLE t1 ADD (b INT);
ALTER TABLE t1 ADD (b INT);
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
CREATE VIEW v1 AS SELECT a FROM t1;
CREATE VIEW v1 AS SELECT a FROM t1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP VIEW v1;
DROP VIEW v1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
CREATE PROCEDURE p1(OUT rows INT) SELECT count(*) INTO rows FROM t1;
CREATE PROCEDURE p1(OUT rows INT) SELECT count(*) INTO rows FROM t1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP PROCEDURE p1;
DROP PROCEDURE p1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP TABLE t1;
DROP TABLE t1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
CREATE FUNCTION f1() RETURNS INT return 1;
CREATE FUNCTION f1() RETURNS INT return 1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP FUNCTION f1;
DROP FUNCTION f1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
CREATE USER user1;
CREATE USER user1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
SET GLOBAL debug='d,injecting_fault_writing';
DROP USER user1;
DROP USER user1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
SET GLOBAL debug='';
#
# Cleanup
#
DROP TABLE IF EXISTS t1, t2;
DROP FUNCTION IF EXISTS f1;
DROP PROCEDURE IF EXISTS p1;
DROP TRIGGER IF EXISTS tr1;
DROP VIEW IF EXISTS v1, v2;
This diff is collapsed.
Click to expand it.
mysql-test/suite/binlog/t/binlog_write_error.test
0 → 100644
View file @
2b165175
#
# === Name ===
#
# binlog_write_error.test
#
# === Description ===
#
# This test case check if the error of writing binlog file is properly
# reported and handled when executing statements.
#
# === Related Bugs ===
#
# BUG#37148
#
source
include
/
have_log_bin
.
inc
;
source
include
/
have_debug
.
inc
;
--
echo
#
--
echo
# Initialization
--
echo
#
disable_warnings
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
DROP
FUNCTION
IF
EXISTS
f1
;
DROP
FUNCTION
IF
EXISTS
f2
;
DROP
PROCEDURE
IF
EXISTS
p1
;
DROP
PROCEDURE
IF
EXISTS
p2
;
DROP
TRIGGER
IF
EXISTS
tr1
;
DROP
TRIGGER
IF
EXISTS
tr2
;
DROP
VIEW
IF
EXISTS
v1
,
v2
;
enable_warnings
;
--
echo
#
--
echo
# Test injecting binlog write error when executing queries
--
echo
#
let
$query
=
CREATE
TABLE
t1
(
a
INT
);
source
include
/
binlog_inject_error
.
inc
;
INSERT
INTO
t1
VALUES
(
1
),(
2
),(
3
);
let
$query
=
INSERT
INTO
t1
VALUES
(
4
),(
5
),(
6
);
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
UPDATE
t1
set
a
=
a
+
1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DELETE
FROM
t1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
CREATE
TRIGGER
tr1
AFTER
INSERT
ON
t1
FOR
EACH
ROW
INSERT
INTO
t1
VALUES
(
new
.
a
+
100
);
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
TRIGGER
tr1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
ALTER
TABLE
t1
ADD
(
b
INT
);
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
CREATE
VIEW
v1
AS
SELECT
a
FROM
t1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
VIEW
v1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
CREATE
PROCEDURE
p1
(
OUT
rows
INT
)
SELECT
count
(
*
)
INTO
rows
FROM
t1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
PROCEDURE
p1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
TABLE
t1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
CREATE
FUNCTION
f1
()
RETURNS
INT
return
1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
FUNCTION
f1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
CREATE
USER
user1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
REVOKE
ALL
PRIVILEGES
,
GRANT
OPTION
FROM
user1
;
source
include
/
binlog_inject_error
.
inc
;
let
$query
=
DROP
USER
user1
;
source
include
/
binlog_inject_error
.
inc
;
--
echo
#
--
echo
# Cleanup
--
echo
#
disable_warnings
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
DROP
FUNCTION
IF
EXISTS
f1
;
DROP
PROCEDURE
IF
EXISTS
p1
;
DROP
TRIGGER
IF
EXISTS
tr1
;
DROP
VIEW
IF
EXISTS
v1
,
v2
;
enable_warnings
;
This diff is collapsed.
Click to expand it.
sql/events.cc
View file @
2b165175
...
...
@@ -476,7 +476,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
}
/* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER
will be written into the binary log as the definer for the SQL thread. */
write_bin_log
(
thd
,
TRUE
,
log_query
.
c_ptr
(),
log_query
.
length
());
ret
=
write_bin_log
(
thd
,
TRUE
,
log_query
.
c_ptr
(),
log_query
.
length
());
}
}
pthread_mutex_unlock
(
&
LOCK_event_metadata
);
...
...
@@ -598,7 +598,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
new_element
);
/* Binlog the alter event. */
DBUG_ASSERT
(
thd
->
query
()
&&
thd
->
query_length
());
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
ret
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
}
pthread_mutex_unlock
(
&
LOCK_event_metadata
);
...
...
@@ -673,7 +673,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
());
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
ret
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
pthread_mutex_unlock
(
&
LOCK_event_metadata
);
DBUG_RETURN
(
ret
);
...
...
This diff is collapsed.
Click to expand it.
sql/log.cc
View file @
2b165175
...
...
@@ -1464,7 +1464,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
if
(
all
||
!
(
thd
->
options
&
(
OPTION_BEGIN
|
OPTION_NOT_AUTOCOMMIT
)))
{
if
(
trx_data
->
has_incident
())
mysql_bin_log
.
write_incident
(
thd
,
TRUE
);
error
=
mysql_bin_log
.
write_incident
(
thd
,
TRUE
);
trx_data
->
reset
();
}
else
// ...statement
...
...
@@ -4710,7 +4710,7 @@ bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock)
Incident_log_event
ev
(
thd
,
incident
,
write_error_msg
);
if
(
lock
)
pthread_mutex_lock
(
&
LOCK_log
);
ev
.
write
(
&
log_file
);
e
rror
=
e
v
.
write
(
&
log_file
);
if
(
lock
)
{
if
(
!
error
&&
!
(
error
=
flush_and_sync
()))
...
...
This diff is collapsed.
Click to expand it.
sql/log_event.cc
View file @
2b165175
...
...
@@ -5864,7 +5864,7 @@ Slave_log_event::Slave_log_event(const char* buf, uint event_len)
int
Slave_log_event
::
do_apply_event
(
Relay_log_info
const
*
rli
)
{
if
(
mysql_bin_log
.
is_open
())
mysql_bin_log
.
write
(
this
);
return
mysql_bin_log
.
write
(
this
);
return
0
;
}
#endif
/* !MYSQL_CLIENT */
...
...
@@ -7611,7 +7611,7 @@ static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD * thd)
(assume the last master's transaction is ignored by the slave because of
replicate-ignore rules).
*/
thd
->
binlog_flush_pending_rows_event
(
true
);
error
=
thd
->
binlog_flush_pending_rows_event
(
true
);
/*
If this event is not in a transaction, the call below will, if some
...
...
@@ -7622,7 +7622,7 @@ static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD * thd)
are involved, commit the transaction and flush the pending event to the
binlog.
*/
error
=
ha_autocommit_or_rollback
(
thd
,
0
);
error
|=
ha_autocommit_or_rollback
(
thd
,
error
);
/*
Now what if this is not a transactional engine? we still need to
...
...
This diff is collapsed.
Click to expand it.
sql/log_event_old.cc
View file @
2b165175
...
...
@@ -1541,7 +1541,15 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
NOTE: For this new scheme there should be no pending event:
need to add code to assert that is the case.
*/
thd
->
binlog_flush_pending_rows_event
(
false
);
error
=
thd
->
binlog_flush_pending_rows_event
(
false
);
if
(
error
)
{
rli
->
report
(
ERROR_LEVEL
,
ER_SLAVE_FATAL_ERROR
,
ER
(
ER_SLAVE_FATAL_ERROR
),
"call to binlog_flush_pending_rows_event() failed"
);
thd
->
is_slave_error
=
1
;
DBUG_RETURN
(
error
);
}
TABLE_LIST
*
tables
=
rli
->
tables_to_lock
;
close_tables_for_reopen
(
thd
,
&
tables
);
...
...
@@ -1831,7 +1839,7 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
(assume the last master's transaction is ignored by the slave because of
replicate-ignore rules).
*/
thd
->
binlog_flush_pending_rows_event
(
true
);
int
binlog_error
=
thd
->
binlog_flush_pending_rows_event
(
true
);
/*
If this event is not in a transaction, the call below will, if some
...
...
@@ -1842,12 +1850,13 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
are involved, commit the transaction and flush the pending event to the
binlog.
*/
if
((
error
=
ha_autocommit_or_rollback
(
thd
,
0
)))
if
((
error
=
ha_autocommit_or_rollback
(
thd
,
binlog_error
)))
rli
->
report
(
ERROR_LEVEL
,
error
,
"Error in %s event: commit of row events failed, "
"table `%s`.`%s`"
,
get_type_str
(),
m_table
->
s
->
db
.
str
,
m_table
->
s
->
table_name
.
str
);
error
|=
binlog_error
;
/*
Now what if this is not a transactional engine? we still need to
...
...
This diff is collapsed.
Click to expand it.
sql/mysql_priv.h
View file @
2b165175
...
...
@@ -1036,8 +1036,8 @@ check_and_unset_inject_value(int value)
#endif
void
write_bin_log
(
THD
*
thd
,
bool
clear_error
,
char
const
*
query
,
ulong
query_length
);
int
write_bin_log
(
THD
*
thd
,
bool
clear_error
,
char
const
*
query
,
ulong
query_length
);
/* sql_connect.cc */
int
check_user
(
THD
*
thd
,
enum
enum_server_command
command
,
...
...
This diff is collapsed.
Click to expand it.
sql/rpl_injector.cc
View file @
2b165175
...
...
@@ -58,10 +58,14 @@ injector::transaction::~transaction()
my_free
(
the_memory
,
MYF
(
0
));
}
/**
@retval 0 transaction committed
@retval 1 transaction rolled back
*/
int
injector
::
transaction
::
commit
()
{
DBUG_ENTER
(
"injector::transaction::commit()"
);
m_thd
->
binlog_flush_pending_rows_event
(
true
);
int
error
=
m_thd
->
binlog_flush_pending_rows_event
(
true
);
/*
Cluster replication does not preserve statement or
transaction boundaries of the master. Instead, a new
...
...
@@ -81,9 +85,9 @@ int injector::transaction::commit()
is committed by committing the statement transaction
explicitly.
*/
ha_autocommit_or_rollback
(
m_thd
,
0
);
end_trans
(
m_thd
,
COMMIT
);
DBUG_RETURN
(
0
);
error
|=
ha_autocommit_or_rollback
(
m_thd
,
error
);
end_trans
(
m_thd
,
error
?
ROLLBACK
:
COMMIT
);
DBUG_RETURN
(
error
);
}
int
injector
::
transaction
::
use_table
(
server_id_type
sid
,
table
tbl
)
...
...
@@ -109,16 +113,17 @@ int injector::transaction::write_row (server_id_type sid, table tbl,
record_type
record
)
{
DBUG_ENTER
(
"injector::transaction::write_row(...)"
);
if
(
int
error
=
check_state
(
ROW_STATE
))
int
error
=
0
;
if
(
error
=
check_state
(
ROW_STATE
))
DBUG_RETURN
(
error
);
server_id_type
save_id
=
m_thd
->
server_id
;
m_thd
->
set_server_id
(
sid
);
m_thd
->
binlog_write_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
record
);
error
=
m_thd
->
binlog_write_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
record
);
m_thd
->
set_server_id
(
save_id
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
}
...
...
@@ -128,15 +133,16 @@ int injector::transaction::delete_row(server_id_type sid, table tbl,
{
DBUG_ENTER
(
"injector::transaction::delete_row(...)"
);
if
(
int
error
=
check_state
(
ROW_STATE
))
int
error
=
0
;
if
(
error
=
check_state
(
ROW_STATE
))
DBUG_RETURN
(
error
);
server_id_type
save_id
=
m_thd
->
server_id
;
m_thd
->
set_server_id
(
sid
);
m_thd
->
binlog_delete_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
record
);
error
=
m_thd
->
binlog_delete_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
record
);
m_thd
->
set_server_id
(
save_id
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
}
...
...
@@ -146,15 +152,16 @@ int injector::transaction::update_row(server_id_type sid, table tbl,
{
DBUG_ENTER
(
"injector::transaction::update_row(...)"
);
if
(
int
error
=
check_state
(
ROW_STATE
))
int
error
=
0
;
if
(
error
=
check_state
(
ROW_STATE
))
DBUG_RETURN
(
error
);
server_id_type
save_id
=
m_thd
->
server_id
;
m_thd
->
set_server_id
(
sid
);
m_thd
->
binlog_update_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
before
,
after
);
error
=
m_thd
->
binlog_update_row
(
tbl
.
get_table
(),
tbl
.
is_transactional
(),
cols
,
colcnt
,
before
,
after
);
m_thd
->
set_server_id
(
save_id
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
}
...
...
This diff is collapsed.
Click to expand it.
sql/sp.cc
View file @
2b165175
...
...
@@ -1105,9 +1105,10 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
/* restore sql_mode when binloging */
thd
->
variables
.
sql_mode
=
saved_mode
;
/* Such a statement can always go directly to binlog, no trans cache */
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
log_query
.
c_ptr
(),
log_query
.
length
(),
FALSE
,
FALSE
,
0
);
if
(
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
log_query
.
c_ptr
(),
log_query
.
length
(),
FALSE
,
FALSE
,
0
))
ret
=
SP_INTERNAL_ERROR
;
thd
->
variables
.
sql_mode
=
0
;
}
...
...
@@ -1166,7 +1167,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
if
(
ret
==
SP_OK
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
ret
=
SP_INTERNAL_ERROR
;
sp_cache_invalidate
();
}
...
...
@@ -1236,7 +1238,8 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
if
(
ret
==
SP_OK
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
ret
=
SP_INTERNAL_ERROR
;
sp_cache_invalidate
();
}
...
...
This diff is collapsed.
Click to expand it.
sql/sp_head.cc
View file @
2b165175
...
...
@@ -1790,6 +1790,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
push_warning
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_UNKNOWN_ERROR
,
"Invoked ROUTINE modified a transactional table but MySQL "
"failed to reflect this change in the binary log"
);
err_status
=
TRUE
;
}
reset_dynamic
(
&
thd
->
user_var_events
);
/* Forget those values, in case more function calls are binlogged: */
...
...
This diff is collapsed.
Click to expand it.
sql/sql_acl.cc
View file @
2b165175
...
...
@@ -1659,8 +1659,8 @@ bool change_password(THD *thd, const char *host, const char *user,
acl_user
->
host
.
hostname
?
acl_user
->
host
.
hostname
:
""
,
new_password
));
thd
->
clear_error
();
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
buff
,
query_length
,
FALSE
,
FALSE
,
0
);
result
=
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
buff
,
query_length
,
FALSE
,
FALSE
,
0
);
}
end:
close_thread_tables
(
thd
);
...
...
@@ -3217,7 +3217,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
if
(
!
result
)
/* success */
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
result
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
rw_unlock
(
&
LOCK_grant
);
...
...
@@ -3383,7 +3383,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
if
(
write_to_binlog
)
{
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
()))
result
=
TRUE
;
}
rw_unlock
(
&
LOCK_grant
);
...
...
@@ -3502,7 +3503,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
if
(
!
result
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
result
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
rw_unlock
(
&
LOCK_grant
);
...
...
@@ -5716,7 +5717,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
my_error
(
ER_CANNOT_USER
,
MYF
(
0
),
"CREATE USER"
,
wrong_users
.
c_ptr_safe
());
if
(
some_users_created
)
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
result
|=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
rw_unlock
(
&
LOCK_grant
);
close_thread_tables
(
thd
);
...
...
@@ -5789,7 +5790,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
my_error
(
ER_CANNOT_USER
,
MYF
(
0
),
"DROP USER"
,
wrong_users
.
c_ptr_safe
());
if
(
some_users_deleted
)
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
result
|=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
rw_unlock
(
&
LOCK_grant
);
close_thread_tables
(
thd
);
...
...
@@ -5874,7 +5875,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
my_error
(
ER_CANNOT_USER
,
MYF
(
0
),
"RENAME USER"
,
wrong_users
.
c_ptr_safe
());
if
(
some_users_renamed
&&
mysql_bin_log
.
is_open
())
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
result
|=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
rw_unlock
(
&
LOCK_grant
);
close_thread_tables
(
thd
);
...
...
@@ -6056,15 +6057,17 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
VOID
(
pthread_mutex_unlock
(
&
acl_cache
->
lock
));
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
int
binlog_error
=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
rw_unlock
(
&
LOCK_grant
);
close_thread_tables
(
thd
);
if
(
result
)
/* error for writing binary log has already been reported */
if
(
result
&&
!
binlog_error
)
my_message
(
ER_REVOKE_GRANTS
,
ER
(
ER_REVOKE_GRANTS
),
MYF
(
0
));
DBUG_RETURN
(
result
);
DBUG_RETURN
(
result
||
binlog_error
);
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_base.cc
View file @
2b165175
...
...
@@ -1336,7 +1336,7 @@ void close_thread_tables(THD *thd)
handled either before writing a query log event (inside
binlog_query()) or when preparing a pending event.
*/
thd
->
binlog_flush_pending_rows_event
(
TRUE
);
(
void
)
thd
->
binlog_flush_pending_rows_event
(
TRUE
);
mysql_unlock_tables
(
thd
,
thd
->
lock
);
thd
->
lock
=
0
;
}
...
...
@@ -1550,7 +1550,11 @@ void close_temporary_tables(THD *thd)
qinfo
.
db
=
db
.
ptr
();
qinfo
.
db_len
=
db
.
length
();
thd
->
variables
.
character_set_client
=
cs_save
;
mysql_bin_log
.
write
(
&
qinfo
);
if
(
mysql_bin_log
.
write
(
&
qinfo
))
{
push_warning
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
MYF
(
0
),
"Failed to write the DROP statement for temporary tables to binary log"
);
}
thd
->
variables
.
pseudo_thread_id
=
save_pseudo_thread_id
;
}
else
...
...
@@ -4031,9 +4035,13 @@ retry:
end
=
strxmov
(
strmov
(
query
,
"DELETE FROM `"
),
share
->
db
.
str
,
"`.`"
,
share
->
table_name
.
str
,
"`"
,
NullS
);
int
errcode
=
query_error_code
(
thd
,
TRUE
);
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
,
(
ulong
)(
end
-
query
),
FALSE
,
FALSE
,
errcode
);
if
(
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
,
(
ulong
)(
end
-
query
),
FALSE
,
FALSE
,
errcode
))
{
my_free
(
query
,
MYF
(
0
));
goto
err
;
}
my_free
(
query
,
MYF
(
0
));
}
else
...
...
This diff is collapsed.
Click to expand it.
sql/sql_class.h
View file @
2b165175
...
...
@@ -2621,7 +2621,7 @@ public:
{}
int
prepare
(
List
<
Item
>
&
list
,
SELECT_LEX_UNIT
*
u
);
void
binlog_show_create_table
(
TABLE
**
tables
,
uint
count
);
int
binlog_show_create_table
(
TABLE
**
tables
,
uint
count
);
void
store_values
(
List
<
Item
>
&
values
);
void
send_error
(
uint
errcode
,
const
char
*
err
);
bool
send_eof
();
...
...
This diff is collapsed.
Click to expand it.
sql/sql_db.cc
View file @
2b165175
...
...
@@ -178,13 +178,13 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length,
Helper function to write a query to binlog used by mysql_rm_db()
*/
static
inline
void
write_to_binlog
(
THD
*
thd
,
char
*
query
,
uint
q_len
,
char
*
db
,
uint
db_len
)
static
inline
int
write_to_binlog
(
THD
*
thd
,
char
*
query
,
uint
q_len
,
char
*
db
,
uint
db_len
)
{
Query_log_event
qinfo
(
thd
,
query
,
q_len
,
0
,
0
,
0
);
qinfo
.
db
=
db
;
qinfo
.
db_len
=
db_len
;
mysql_bin_log
.
write
(
&
qinfo
);
return
mysql_bin_log
.
write
(
&
qinfo
);
}
...
...
@@ -747,7 +747,11 @@ not_silent:
qinfo
.
db_len
=
strlen
(
db
);
/* These DDL methods and logging protected with LOCK_mysql_create_db */
mysql_bin_log
.
write
(
&
qinfo
);
if
(
mysql_bin_log
.
write
(
&
qinfo
))
{
error
=
-
1
;
goto
exit
;
}
}
my_ok
(
thd
,
result
);
}
...
...
@@ -824,7 +828,8 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
qinfo
.
db_len
=
strlen
(
db
);
/* These DDL methods and logging protected with LOCK_mysql_create_db */
mysql_bin_log
.
write
(
&
qinfo
);
if
(
error
=
mysql_bin_log
.
write
(
&
qinfo
))
goto
exit
;
}
my_ok
(
thd
,
result
);
...
...
@@ -974,7 +979,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
qinfo
.
db_len
=
strlen
(
db
);
/* These DDL methods and logging protected with LOCK_mysql_create_db */
mysql_bin_log
.
write
(
&
qinfo
);
if
(
mysql_bin_log
.
write
(
&
qinfo
))
{
error
=
-
1
;
goto
exit
;
}
}
thd
->
clear_error
();
thd
->
server_status
|=
SERVER_STATUS_DB_DROPPED
;
...
...
@@ -1002,7 +1011,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if
(
query_pos
+
tbl_name_len
+
1
>=
query_end
)
{
/* These DDL methods and logging protected with LOCK_mysql_create_db */
write_to_binlog
(
thd
,
query
,
query_pos
-
1
-
query
,
db
,
db_len
);
if
(
write_to_binlog
(
thd
,
query
,
query_pos
-
1
-
query
,
db
,
db_len
))
{
error
=
-
1
;
goto
exit
;
}
query_pos
=
query_data_start
;
}
...
...
@@ -1015,7 +1028,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if
(
query_pos
!=
query_data_start
)
{
/* These DDL methods and logging protected with LOCK_mysql_create_db */
write_to_binlog
(
thd
,
query
,
query_pos
-
1
-
query
,
db
,
db_len
);
if
(
write_to_binlog
(
thd
,
query
,
query_pos
-
1
-
query
,
db
,
db_len
))
{
error
=
-
1
;
goto
exit
;
}
}
}
...
...
@@ -1965,7 +1982,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
Query_log_event
qinfo
(
thd
,
thd
->
query
(),
thd
->
query_length
(),
0
,
TRUE
,
errcode
);
thd
->
clear_error
();
mysql_bin_log
.
write
(
&
qinfo
);
error
|=
mysql_bin_log
.
write
(
&
qinfo
);
}
/* Step9: Let's do "use newdb" if we renamed the current database */
...
...
This diff is collapsed.
Click to expand it.
sql/sql_delete.cc
View file @
2b165175
...
...
@@ -850,9 +850,10 @@ void multi_delete::abort()
if
(
mysql_bin_log
.
is_open
())
{
int
errcode
=
query_error_code
(
thd
,
thd
->
killed
==
THD
::
NOT_KILLED
);
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_tables
,
FALSE
,
errcode
);
/* possible error of writing binary log is ignored deliberately */
(
void
)
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_tables
,
FALSE
,
errcode
);
}
thd
->
transaction
.
all
.
modified_non_trans_table
=
true
;
}
...
...
@@ -1167,8 +1168,9 @@ end:
{
/* In RBR, the statement is not binlogged if the table is temporary. */
if
(
!
is_temporary_table
||
!
thd
->
current_stmt_binlog_row_based
)
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
my_ok
(
thd
);
// This should return record count
error
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
!
error
)
my_ok
(
thd
);
// This should return record count
}
VOID
(
pthread_mutex_lock
(
&
LOCK_open
));
unlock_table_name
(
thd
,
table_list
);
...
...
This diff is collapsed.
Click to expand it.
sql/sql_insert.cc
View file @
2b165175
...
...
@@ -2743,10 +2743,11 @@ bool Delayed_insert::handle_inserts(void)
will be binlogged together as one single Table_map event and one
single Rows event.
*/
thd
.
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
row
->
query
.
str
,
row
->
query
.
length
,
FALSE
,
FALSE
,
errcode
);
if
(
thd
.
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
row
->
query
.
str
,
row
->
query
.
length
,
FALSE
,
FALSE
,
errcode
))
goto
err
;
thd
.
time_zone_used
=
backup_time_zone_used
;
thd
.
variables
.
time_zone
=
backup_time_zone
;
}
...
...
@@ -2814,8 +2815,9 @@ bool Delayed_insert::handle_inserts(void)
TODO: Move the logging to last in the sequence of rows.
*/
if
(
thd
.
current_stmt_binlog_row_based
)
thd
.
binlog_flush_pending_rows_event
(
TRUE
);
if
(
thd
.
current_stmt_binlog_row_based
&&
thd
.
binlog_flush_pending_rows_event
(
TRUE
))
goto
err
;
if
((
error
=
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
)))
{
// This shouldn't happen
...
...
@@ -3267,16 +3269,21 @@ bool select_insert::send_eof()
events are in the transaction cache and will be written when
ha_autocommit_or_rollback() is issued below.
*/
if
(
mysql_bin_log
.
is_open
())
if
(
mysql_bin_log
.
is_open
()
&&
(
!
error
||
thd
->
transaction
.
stmt
.
modified_non_trans_table
))
{
int
errcode
=
0
;
if
(
!
error
)
thd
->
clear_error
();
else
errcode
=
query_error_code
(
thd
,
killed_status
==
THD
::
NOT_KILLED
);
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
if
(
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
trans_table
,
FALSE
,
errcode
);
trans_table
,
FALSE
,
errcode
))
{
table
->
file
->
ha_release_auto_increment
();
DBUG_RETURN
(
1
);
}
}
table
->
file
->
ha_release_auto_increment
();
...
...
@@ -3345,9 +3352,10 @@ void select_insert::abort() {
if
(
mysql_bin_log
.
is_open
())
{
int
errcode
=
query_error_code
(
thd
,
thd
->
killed
==
THD
::
NOT_KILLED
);
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_table
,
FALSE
,
errcode
);
/* error of writing binary log is ignored */
(
void
)
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_table
,
FALSE
,
errcode
);
}
if
(
!
thd
->
current_stmt_binlog_row_based
&&
!
can_rollback_data
())
thd
->
transaction
.
all
.
modified_non_trans_table
=
TRUE
;
...
...
@@ -3602,7 +3610,8 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
!
table
->
s
->
tmp_table
&&
!
ptr
->
get_create_info
()
->
table_existed
)
{
ptr
->
binlog_show_create_table
(
tables
,
count
);
if
(
int
error
=
ptr
->
binlog_show_create_table
(
tables
,
count
))
return
error
;
}
return
0
;
}
...
...
@@ -3709,7 +3718,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
DBUG_RETURN
(
0
);
}
void
int
select_create
::
binlog_show_create_table
(
TABLE
**
tables
,
uint
count
)
{
/*
...
...
@@ -3748,12 +3757,13 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
if
(
mysql_bin_log
.
is_open
())
{
int
errcode
=
query_error_code
(
thd
,
thd
->
killed
==
THD
::
NOT_KILLED
);
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
.
ptr
(),
query
.
length
(),
/* is_trans */
TRUE
,
/* suppress_use */
FALSE
,
errcode
);
result
=
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
.
ptr
(),
query
.
length
(),
/* is_trans */
TRUE
,
/* suppress_use */
FALSE
,
errcode
);
}
return
result
;
}
void
select_create
::
store_values
(
List
<
Item
>
&
values
)
...
...
@@ -3851,7 +3861,8 @@ void select_create::abort()
select_insert
::
abort
();
thd
->
transaction
.
stmt
.
modified_non_trans_table
=
FALSE
;
reenable_binlog
(
thd
);
thd
->
binlog_flush_pending_rows_event
(
TRUE
);
/* possible error of writing binary log is ignored deliberately */
(
void
)
thd
->
binlog_flush_pending_rows_event
(
TRUE
);
if
(
m_plock
)
{
...
...
This diff is collapsed.
Click to expand it.
sql/sql_load.cc
View file @
2b165175
...
...
@@ -122,7 +122,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
char
name
[
FN_REFLEN
];
File
file
;
TABLE
*
table
=
NULL
;
int
error
;
int
error
=
0
;
String
*
field_term
=
ex
->
field_term
,
*
escaped
=
ex
->
escaped
;
String
*
enclosed
=
ex
->
enclosed
;
bool
is_fifo
=
0
;
...
...
@@ -504,18 +504,20 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
int
errcode
=
query_error_code
(
thd
,
killed_status
==
THD
::
NOT_KILLED
);
/* since there is already an error, the possible error of
writing binary log will be ignored */
if
(
thd
->
transaction
.
stmt
.
modified_non_trans_table
)
write_execute_load_query_log_event
(
thd
,
ex
,
table_list
->
db
,
table_list
->
table_name
,
handle_duplicates
,
ignore
,
transactional_table
,
errcode
);
(
void
)
write_execute_load_query_log_event
(
thd
,
ex
,
table_list
->
db
,
table_list
->
table_name
,
handle_duplicates
,
ignore
,
transactional_table
,
errcode
);
else
{
Delete_file_log_event
d
(
thd
,
db
,
transactional_table
);
d
.
flags
|=
LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F
;
mysql_bin_log
.
write
(
&
d
);
(
void
)
mysql_bin_log
.
write
(
&
d
);
}
}
}
...
...
@@ -541,7 +543,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
after this point.
*/
if
(
thd
->
current_stmt_binlog_row_based
)
thd
->
binlog_flush_pending_rows_event
(
true
);
error
=
thd
->
binlog_flush_pending_rows_event
(
true
);
else
{
/*
...
...
@@ -553,13 +555,15 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if
(
lf_info
.
wrote_create_file
)
{
int
errcode
=
query_error_code
(
thd
,
killed_status
==
THD
::
NOT_KILLED
);
write_execute_load_query_log_event
(
thd
,
ex
,
table_list
->
db
,
table_list
->
table_name
,
handle_duplicates
,
ignore
,
transactional_table
,
errcode
);
error
=
write_execute_load_query_log_event
(
thd
,
ex
,
table_list
->
db
,
table_list
->
table_name
,
handle_duplicates
,
ignore
,
transactional_table
,
errcode
);
}
}
if
(
error
)
goto
err
;
}
#endif
/*!EMBEDDED_LIBRARY*/
...
...
This diff is collapsed.
Click to expand it.
sql/sql_parse.cc
View file @
2b165175
...
...
@@ -2987,7 +2987,7 @@ end_with_restore_list:
/*
Presumably, REPAIR and binlog writing doesn't require synchronization
*/
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
res
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
select_lex
->
table_list
.
first
=
(
uchar
*
)
first_table
;
lex
->
query_tables
=
all_tables
;
...
...
@@ -3019,7 +3019,7 @@ end_with_restore_list:
/*
Presumably, ANALYZE and binlog writing doesn't require synchronization
*/
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
res
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
select_lex
->
table_list
.
first
=
(
uchar
*
)
first_table
;
lex
->
query_tables
=
all_tables
;
...
...
@@ -3042,7 +3042,7 @@ end_with_restore_list:
/*
Presumably, OPTIMIZE and binlog writing doesn't require synchronization
*/
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
res
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
}
select_lex
->
table_list
.
first
=
(
uchar
*
)
first_table
;
lex
->
query_tables
=
all_tables
;
...
...
@@ -3159,7 +3159,7 @@ end_with_restore_list:
if
(
incident
)
{
Incident_log_event
ev
(
thd
,
incident
);
mysql_bin_log
.
write
(
&
ev
);
(
void
)
mysql_bin_log
.
write
(
&
ev
);
/* error is ignored */
mysql_bin_log
.
rotate_and_purge
(
RP_FORCE_ROTATE
);
}
DBUG_PRINT
(
"debug"
,
(
"Just after generate_incident()"
));
...
...
@@ -3988,7 +3988,8 @@ end_with_restore_list:
*/
if
(
!
lex
->
no_write_to_binlog
&&
write_to_binlog
)
{
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
if
(
res
=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
()))
break
;
}
my_ok
(
thd
);
}
...
...
@@ -4566,12 +4567,12 @@ create_sp_error:
case
SP_KEY_NOT_FOUND
:
if
(
lex
->
drop_if_exists
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
res
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_NOTE
,
ER_SP_DOES_NOT_EXIST
,
ER
(
ER_SP_DOES_NOT_EXIST
),
SP_COM_STRING
(
lex
),
lex
->
spname
->
m_name
.
str
);
res
=
FALSE
;
my_ok
(
thd
);
if
(
!
res
)
my_ok
(
thd
);
break
;
}
my_error
(
ER_SP_DOES_NOT_EXIST
,
MYF
(
0
),
...
...
This diff is collapsed.
Click to expand it.
sql/sql_partition.cc
View file @
2b165175
...
...
@@ -4113,8 +4113,9 @@ static int fast_end_partition(THD *thd, ulonglong copied,
}
if
((
!
is_empty
)
&&
(
!
written_bin_log
)
&&
(
!
thd
->
lex
->
no_write_to_binlog
))
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
(
!
thd
->
lex
->
no_write_to_binlog
)
&&
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
()))
DBUG_RETURN
(
TRUE
);
my_snprintf
(
tmp_name
,
sizeof
(
tmp_name
),
ER
(
ER_INSERT_INFO
),
(
ulong
)
(
copied
+
deleted
),
...
...
This diff is collapsed.
Click to expand it.
sql/sql_rename.cc
View file @
2b165175
...
...
@@ -34,6 +34,7 @@ static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list);
bool
mysql_rename_tables
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
bool
silent
)
{
bool
error
=
1
;
bool
binlog_error
=
0
;
TABLE_LIST
*
ren_table
=
0
;
int
to_table
;
char
*
rename_log_table
[
2
]
=
{
NULL
,
NULL
};
...
...
@@ -174,11 +175,11 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
*/
pthread_mutex_unlock
(
&
LOCK_open
);
/* Lets hope this doesn't fail as the result will be messy */
if
(
!
silent
&&
!
error
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
my_ok
(
thd
);
binlog_error
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
!
binlog_error
)
my_ok
(
thd
);
}
if
(
!
error
)
...
...
@@ -190,7 +191,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
err:
start_waiting_global_read_lock
(
thd
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
||
binlog_error
);
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_repl.cc
View file @
2b165175
...
...
@@ -1004,8 +1004,8 @@ int reset_slave(THD *thd, Master_info* mi)
MY_STAT
stat_area
;
char
fname
[
FN_REFLEN
];
int
thread_mask
=
0
,
error
=
0
;
uint
sql_errno
=
0
;
const
char
*
errmsg
=
0
;
uint
sql_errno
=
ER_UNKNOWN_ERROR
;
const
char
*
errmsg
=
"Unknown error occured while reseting slave"
;
DBUG_ENTER
(
"reset_slave"
);
lock_slave_threads
(
mi
);
...
...
@@ -1671,7 +1671,8 @@ err:
replication events along LOAD DATA processing.
@param file pointer to io-cache
@return 0
@retval 0 success
@retval 1 failure
*/
int
log_loaded_block
(
IO_CACHE
*
file
)
{
...
...
@@ -1698,7 +1699,8 @@ int log_loaded_block(IO_CACHE* file)
Append_block_log_event
a
(
lf_info
->
thd
,
lf_info
->
thd
->
db
,
buffer
,
min
(
block_len
,
max_event_size
),
lf_info
->
log_delayed
);
mysql_bin_log
.
write
(
&
a
);
if
(
mysql_bin_log
.
write
(
&
a
))
DBUG_RETURN
(
1
);
}
else
{
...
...
@@ -1706,7 +1708,8 @@ int log_loaded_block(IO_CACHE* file)
buffer
,
min
(
block_len
,
max_event_size
),
lf_info
->
log_delayed
);
mysql_bin_log
.
write
(
&
b
);
if
(
mysql_bin_log
.
write
(
&
b
))
DBUG_RETURN
(
1
);
lf_info
->
wrote_create_file
=
1
;
DBUG_SYNC_POINT
(
"debug_lock.created_file_event"
,
10
);
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_table.cc
View file @
2b165175
...
...
@@ -1748,9 +1748,10 @@ end:
file
*/
void
write_bin_log
(
THD
*
thd
,
bool
clear_error
,
char
const
*
query
,
ulong
query_length
)
int
write_bin_log
(
THD
*
thd
,
bool
clear_error
,
char
const
*
query
,
ulong
query_length
)
{
int
error
=
0
;
if
(
mysql_bin_log
.
is_open
())
{
int
errcode
=
0
;
...
...
@@ -1758,9 +1759,10 @@ void write_bin_log(THD *thd, bool clear_error,
thd
->
clear_error
();
else
errcode
=
query_error_code
(
thd
,
TRUE
);
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
,
query_length
,
FALSE
,
FALSE
,
errcode
);
error
=
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
query
,
query_length
,
FALSE
,
FALSE
,
errcode
);
}
return
error
;
}
...
...
@@ -2106,7 +2108,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
tables). In this case, we can write the original query into
the binary log.
*/
write_bin_log
(
thd
,
!
error
,
thd
->
query
(),
thd
->
query_length
());
error
|=
write_bin_log
(
thd
,
!
error
,
thd
->
query
(),
thd
->
query_length
());
}
else
if
(
thd
->
current_stmt_binlog_row_based
&&
tmp_table_deleted
)
...
...
@@ -2128,7 +2130,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
*/
built_query
.
chop
();
// Chop of the last comma
built_query
.
append
(
" /* generated by server */"
);
write_bin_log
(
thd
,
!
error
,
built_query
.
ptr
(),
built_query
.
length
());
error
|=
write_bin_log
(
thd
,
!
error
,
built_query
.
ptr
(),
built_query
.
length
());
}
/*
...
...
@@ -2147,7 +2149,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
*/
built_tmp_query
.
chop
();
// Chop of the last comma
built_tmp_query
.
append
(
" /* generated by server */"
);
write_bin_log
(
thd
,
!
error
,
built_tmp_query
.
ptr
(),
built_tmp_query
.
length
());
error
|=
write_bin_log
(
thd
,
!
error
,
built_tmp_query
.
ptr
(),
built_tmp_query
.
length
());
}
}
...
...
@@ -3556,9 +3558,9 @@ void sp_prepare_create_field(THD *thd, Create_field *sql_field)
RETURN VALUES
NONE
*/
static
inline
void
write_create_table_bin_log
(
THD
*
thd
,
const
HA_CREATE_INFO
*
create_info
,
bool
internal_tmp_table
)
static
inline
int
write_create_table_bin_log
(
THD
*
thd
,
const
HA_CREATE_INFO
*
create_info
,
bool
internal_tmp_table
)
{
/*
Don't write statement if:
...
...
@@ -3571,7 +3573,8 @@ static inline void write_create_table_bin_log(THD *thd,
(
!
thd
->
current_stmt_binlog_row_based
||
(
thd
->
current_stmt_binlog_row_based
&&
!
(
create_info
->
options
&
HA_LEX_CREATE_TMP_TABLE
))))
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
return
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
return
0
;
}
...
...
@@ -3837,8 +3840,7 @@ bool mysql_create_table_no_lock(THD *thd,
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_NOTE
,
ER_TABLE_EXISTS_ERROR
,
ER
(
ER_TABLE_EXISTS_ERROR
),
alias
);
error
=
0
;
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
error
=
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
goto
err
;
}
my_error
(
ER_TABLE_EXISTS_ERROR
,
MYF
(
0
),
alias
);
...
...
@@ -3959,8 +3961,7 @@ bool mysql_create_table_no_lock(THD *thd,
thd
->
thread_specific_used
=
TRUE
;
}
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
error
=
FALSE
;
error
=
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
unlock_and_end:
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
...
...
@@ -3975,7 +3976,7 @@ warn:
ER_TABLE_EXISTS_ERROR
,
ER
(
ER_TABLE_EXISTS_ERROR
),
alias
);
create_info
->
table_existed
=
1
;
// Mark that table existed
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
error
=
write_create_table_bin_log
(
thd
,
create_info
,
internal_tmp_table
);
goto
unlock_and_end
;
}
...
...
@@ -5448,18 +5449,20 @@ binlog:
create_info
,
FALSE
/* show_database */
);
DBUG_ASSERT
(
result
==
0
);
// store_create_info() always return 0
write_bin_log
(
thd
,
TRUE
,
query
.
ptr
(),
query
.
length
());
if
(
write_bin_log
(
thd
,
TRUE
,
query
.
ptr
(),
query
.
length
()))
goto
err
;
}
}
else
// Case 1
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
goto
err
;
}
/*
Case 3 and 4 does nothing under RBR
*/
}
else
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
())
;
else
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
goto
err
;
res
=
FALSE
;
...
...
@@ -5547,7 +5550,7 @@ mysql_discard_or_import_tablespace(THD *thd,
error
=
1
;
if
(
error
)
goto
err
;
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
error
=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
err:
ha_autocommit_or_rollback
(
thd
,
error
);
...
...
@@ -6558,11 +6561,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
thd
->
clear_error
();
Query_log_event
qinfo
(
thd
,
thd
->
query
(),
thd
->
query_length
(),
0
,
FALSE
,
0
);
mysql_bin_log
.
write
(
&
qinfo
);
if
(
error
=
mysql_bin_log
.
write
(
&
qinfo
))
goto
view_err_unlock
;
}
my_ok
(
thd
);
}
view_err_unlock:
unlock_table_names
(
thd
,
table_list
,
(
TABLE_LIST
*
)
0
);
view_err:
...
...
@@ -6810,8 +6815,9 @@ view_err:
if
(
!
error
)
{
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
my_ok
(
thd
);
error
=
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
!
error
)
my_ok
(
thd
);
}
else
if
(
error
>
0
)
{
...
...
@@ -7299,8 +7305,9 @@ view_err:
if
(
rename_temporary_table
(
thd
,
new_table
,
new_db
,
new_name
))
goto
err1
;
/* We don't replicate alter table statement on temporary tables */
if
(
!
thd
->
current_stmt_binlog_row_based
)
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
!
thd
->
current_stmt_binlog_row_based
&&
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
DBUG_RETURN
(
TRUE
);
goto
end_temporary
;
}
...
...
@@ -7463,7 +7470,8 @@ view_err:
DBUG_ASSERT
(
!
(
mysql_bin_log
.
is_open
()
&&
thd
->
current_stmt_binlog_row_based
&&
(
create_info
->
options
&
HA_LEX_CREATE_TMP_TABLE
)));
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
DBUG_RETURN
(
TRUE
);
if
(
ha_check_storage_engine_flag
(
old_db_type
,
HTON_FLUSH_AFTER_RENAME
))
{
...
...
This diff is collapsed.
Click to expand it.
sql/sql_tablespace.cc
View file @
2b165175
...
...
@@ -66,6 +66,6 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
ha_resolve_storage_engine_name
(
hton
),
"TABLESPACE or LOGFILE GROUP"
);
}
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
DBUG_RETURN
(
FALSE
);
error
=
write_bin_log
(
thd
,
FALSE
,
thd
->
query
(),
thd
->
query_length
());
DBUG_RETURN
(
error
);
}
This diff is collapsed.
Click to expand it.
sql/sql_trigger.cc
View file @
2b165175
...
...
@@ -507,7 +507,7 @@ end:
if
(
!
result
)
{
write_bin_log
(
thd
,
TRUE
,
stmt_query
.
ptr
(),
stmt_query
.
length
());
result
=
write_bin_log
(
thd
,
TRUE
,
stmt_query
.
ptr
(),
stmt_query
.
length
());
}
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
...
...
This diff is collapsed.
Click to expand it.
sql/sql_udf.cc
View file @
2b165175
...
...
@@ -506,8 +506,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
rw_unlock
(
&
THR_LOCK_udf
);
/* Binlog the create function. */
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
0
);
err:
...
...
@@ -581,8 +581,8 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
rw_unlock
(
&
THR_LOCK_udf
);
/* Binlog the drop function. */
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
TRUE
,
thd
->
query
(),
thd
->
query_length
()))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
0
);
err:
rw_unlock
(
&
THR_LOCK_udf
);
...
...
This diff is collapsed.
Click to expand it.
sql/sql_update.cc
View file @
2b165175
...
...
@@ -1868,9 +1868,10 @@ void multi_update::abort()
into repl event.
*/
int
errcode
=
query_error_code
(
thd
,
thd
->
killed
==
THD
::
NOT_KILLED
);
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_tables
,
FALSE
,
errcode
);
/* the error of binary logging is ignored */
(
void
)
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
(),
thd
->
query_length
(),
transactional_tables
,
FALSE
,
errcode
);
}
thd
->
transaction
.
all
.
modified_non_trans_table
=
TRUE
;
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_view.cc
View file @
2b165175
...
...
@@ -662,8 +662,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
buff
.
append
(
views
->
source
.
str
,
views
->
source
.
length
);
int
errcode
=
query_error_code
(
thd
,
TRUE
);
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
buff
.
ptr
(),
buff
.
length
(),
FALSE
,
FALSE
,
errcode
);
if
(
thd
->
binlog_query
(
THD
::
STMT_QUERY_TYPE
,
buff
.
ptr
(),
buff
.
length
(),
FALSE
,
FALSE
,
errcode
))
res
=
TRUE
;
}
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
...
...
@@ -1652,7 +1653,8 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
/* if something goes wrong, bin-log with possible error code,
otherwise bin-log with error code cleared.
*/
write_bin_log
(
thd
,
!
something_wrong
,
thd
->
query
(),
thd
->
query_length
());
if
(
write_bin_log
(
thd
,
!
something_wrong
,
thd
->
query
(),
thd
->
query_length
()))
something_wrong
=
1
;
}
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment