diff options
author | cbell/Chuck@mysql_cab_desk. <> | 2007-02-26 14:06:10 -0500 |
---|---|---|
committer | cbell/Chuck@mysql_cab_desk. <> | 2007-02-26 14:06:10 -0500 |
commit | d7e4de9937c401a079c1cb310d2a1f7b80db5a01 (patch) | |
tree | c33e6e251593ed3bedfe71baaf8f187058829aed /sql/sp_head.cc | |
parent | 54b04ff5c80f3e56d900fc68750ef7b78b11d61d (diff) | |
download | mariadb-git-d7e4de9937c401a079c1cb310d2a1f7b80db5a01.tar.gz |
BUG#20141 "User-defined variables are not replicated properly for
SF/Triggers in SBR mode."
BUG#14914 "SP: Uses of session variables in routines are not always replicated"
BUG#25167 "Dupl. usage of user-variables in trigger/function is not replicated
correctly"
User-defined variables used inside of stored functions/triggers in
statements which did not update tables directly were not replicated.
We also had problems with replication of user-defined variables which
were used in triggers (or stored functions called from table-updating
statements) more than once.
This patch addresses the first issue by enabling logging of all
references to user-defined variables in triggers/stored functions
and not only references from table-updating statements.
The second issue stemmed from the fact that for user-defined
variables used from triggers or stored functions called from
table-updating statements we were writing binlog events for each
reference instead of only one event for the first reference.
This problem is already solved for stored functions called from
non-updating statements with help of "event unioning" mechanism.
So the patch simply extends this mechanism to the case affected.
It also fixes small problem in this mechanism which caused wrong
logging of references to user-variables in cases when non-updating
statement called several stored functions which used the same
variable and some of these function calls were omitted from binlog
as they were not updating any tables.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 7c110185a95..7405ea37314 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1485,8 +1485,24 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, if (need_binlog_call) { + query_id_t q; reset_dynamic(&thd->user_var_events); - mysql_bin_log.start_union_events(thd); + /* + In case of artificially constructed events for function calls + we have separate union for each such event and hence can't use + query_id of real calling statement as the start of all these + unions (this will break logic of replication of user-defined + variables). So we use artifical value which is guaranteed to + be greater than all query_id's of all statements belonging + to previous events/unions. + Possible alternative to this is logging of all function invocations + as one select and not resetting THD::user_var_events before + each invocation. + */ + VOID(pthread_mutex_lock(&LOCK_thread_count)); + q= ::query_id; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); + mysql_bin_log.start_union_events(thd, q + 1); binlog_save_options= thd->options; thd->options&= ~OPTION_BIN_LOG; } |