summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.intranet>2006-10-03 13:38:16 +0400
committerunknown <kroki/tomash@moonlight.intranet>2006-10-03 13:38:16 +0400
commit5f5029630b2fba0729218f18e3da91a62a4e5fe6 (patch)
tree27aed4f4fe18f8981e2f8a6f6b693ddca47cf40d /sql/sql_class.h
parent09c5c3e74945e166dee2c7625008ac558a42c7f6 (diff)
downloadmariadb-git-5f5029630b2fba0729218f18e3da91a62a4e5fe6.tar.gz
Fix for the patch for bug#21726: Incorrect result with multiple
invocations of LAST_INSERT_ID. Reding of LAST_INSERT_ID inside stored function wasn't noted by caller, and no LAST_INSERT_ID_EVENT was issued for binary log. The solution is to add THD::last_insert_id_used_bin_log, which is much like THD::last_insert_id_used, but is reset only for upper-level statements. This new variable is used to issue LAST_INSERT_ID_EVENT. mysql-test/r/rpl_insert_id.result: For bug#21726, add result for statement-based replication of function calls. mysql-test/t/rpl_insert_id.test: For bug#21726, add test case for statement-based replication of function calls. sql/item_func.cc: Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT. sql/log.cc: Issue LAST_INSERT_ID_EVENT if THD::last_insert_id_used_bin_log is set. sql/set_var.cc: Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT. sql/sql_class.cc: Initialize THD::last_insert_id_used_bin_log. Fix typo, add whitespace. sql/sql_class.h: Add THD::last_insert_id_used_bin_log. sql/sql_parse.cc: Reset THD::last_insert_id_used_bin_log for upper-level statements. sql/sql_select.cc: Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index ccc7a661446..d30797a605f 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1340,12 +1340,21 @@ public:
/*
last_insert_id_used is set when current statement calls
- LAST_INSERT_ID() or reads @@LAST_INSERT_ID, so that binary log
- LAST_INSERT_ID_EVENT be generated.
+ LAST_INSERT_ID() or reads @@LAST_INSERT_ID.
*/
bool last_insert_id_used;
/*
+ last_insert_id_used is set when current statement or any stored
+ function called from this statement calls LAST_INSERT_ID() or
+ reads @@LAST_INSERT_ID, so that binary log LAST_INSERT_ID_EVENT be
+ generated. Required for statement-based binary log for issuing
+ "SET LAST_INSERT_ID= #" before "SELECT func()", if func() reads
+ LAST_INSERT_ID.
+ */
+ bool last_insert_id_used_bin_log;
+
+ /*
insert_id_used is set when current statement updates
THD::last_insert_id, so that binary log INSERT_ID_EVENT be
generated.