Hi, Sanja!
On Nov 28, sanja@xxxxxxxxxxx wrote:
revision-id: 26f48fa6c110efc62e17e1edfe6569445387e11d
parent(s): d0d6284cab70af148269d95744f615454cac24bb
committer: Oleksandr Byelkin
branch nick: work-maria-10.1-MDEV-6997-real
timestamp: 2014-11-28 13:52:59 +0100
message:
MDEV-6997: SET STATEMENT last_insert_id FOR ... does not affect the value written to the binlog
Problem was in reinitialization of first_successful_insert_id_in_prev_stmt_for_binlog after setting variables.
---
mysql-test/r/set_statement.result | 2 --
mysql-test/r/set_statement_notembedded_binlog.result | 8 ++++++++
mysql-test/t/set_statement.test | 2 --
mysql-test/t/set_statement_notembedded_binlog.test | 15 +++++++++++++++
sql/sql_parse.cc | 4 ++++
sql/sys_vars.cc | 2 +-
6 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/mysql-test/r/set_statement_notembedded_binlog.result b/mysql-test/r/set_statement_notembedded_binlog.result
new file mode 100644
index 0000000..bd50832
--- /dev/null
+++ b/mysql-test/r/set_statement_notembedded_binlog.result
@@ -0,0 +1,8 @@
+drop table if exists t1;
+drop view if exists t1;
+PURGE BINARY LOGS before now();
why not reset master?
+set statement last_insert_id = 112 for create table t1 as select last_insert_id();
+show binlog events limit 4,1;
+Log_name Pos Event_type Server_id End_log_pos Info
+x x x x x use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */
Ehm, and what does this test shows?
+drop table t1;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 5af700b..54abfd0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2728,6 +2728,10 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
my_error(ER_WRONG_ARGUMENTS, MYF(0), "SET");
goto error;
}
+ if (!thd->in_sub_stmt) /* stored functions and triggers are a special case */
+ {
+ thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
+ }
Hmm. What does this fix?
I'd think that stmt_depends_on_first_successful_insert_id_in_prev_stmt
is already 0 here.
Anyway, without a working test it's difficult to see whether your fix is
doing anything.