summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
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
commit37b5cbdc300e0444a3eac5e3c6c056e8cd18741f (patch)
tree27aed4f4fe18f8981e2f8a6f6b693ddca47cf40d /sql/sql_class.cc
parentbe929087ec9a5b4e161591fcebab9687472779eb (diff)
downloadmariadb-git-37b5cbdc300e0444a3eac5e3c6c056e8cd18741f.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.cc')
-rw-r--r--sql/sql_class.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 4d47ec338c0..645ac6e28f3 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -179,9 +179,9 @@ THD::THD()
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
rand_used(0), time_zone_used(0),
- last_insert_id_used(0), insert_id_used(0), clear_next_insert_id(0),
- in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE),
- spcont(NULL)
+ last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
+ clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
+ derived_tables_processing(FALSE), spcont(NULL)
{
stmt_arena= this;
thread_stack= 0;
@@ -560,7 +560,7 @@ bool THD::store_globals()
THD::cleanup_after_query()
DESCRIPTION
- This function is used to reset thread data to it's default state.
+ This function is used to reset thread data to its default state.
NOTE
This function is not suitable for setting thread data to some
@@ -568,6 +568,7 @@ bool THD::store_globals()
different master threads may overwrite data of each other on
slave.
*/
+
void THD::cleanup_after_query()
{
last_insert_id_used= FALSE;
@@ -582,6 +583,7 @@ void THD::cleanup_after_query()
where= THD::DEFAULT_WHERE;
}
+
/*
Convert a string to another character set