diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-08-31 15:55:58 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-08-31 15:55:58 -0600 |
commit | 09c35c69634c23765aee861639c111c34c1589e7 (patch) | |
tree | 24905e953ced32379d08a24a3520366534675f68 | |
parent | e19a292c56c3c613a798f612a73ff4b9e62eb911 (diff) | |
download | mariadb-git-09c35c69634c23765aee861639c111c34c1589e7.tar.gz |
replicated get_lock() properly
sql/item_func.cc:
log all lock releases to binary log for safe handling of get_lock()
in updates
-rw-r--r-- | mysql-test/r/rpl_get_lock.result | 4 | ||||
-rw-r--r-- | mysql-test/t/rpl_get_lock.test | 16 | ||||
-rw-r--r-- | sql/item_func.cc | 17 |
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/rpl_get_lock.result b/mysql-test/r/rpl_get_lock.result new file mode 100644 index 00000000000..c261ee2861b --- /dev/null +++ b/mysql-test/r/rpl_get_lock.result @@ -0,0 +1,4 @@ +get_lock("lock",3) +1 +n +1 diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test new file mode 100644 index 00000000000..45adf99ed21 --- /dev/null +++ b/mysql-test/t/rpl_get_lock.test @@ -0,0 +1,16 @@ +source include/master-slave.inc; +connection master; +create table t1(n int); +insert into t1 values(get_lock("lock",2)); +dirty_close master; +connection master1; +save_master_pos; +connection slave; +sync_with_master; +select get_lock("lock",3); +select * from t1; +connection master1; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/item_func.cc b/sql/item_func.cc index 989d7709513..47adb902107 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1399,6 +1399,23 @@ void item_user_lock_free(void) void item_user_lock_release(ULL *ull) { ull->locked=0; + if (mysql_bin_log.is_open()) + { + THD *thd = current_thd; + int save_errno; + char buf[256]; + String tmp(buf,sizeof(buf)); + tmp.length(0); + tmp.append("SELECT release_lock(\""); + tmp.append(ull->key,ull->key_length); + tmp.append("\")"); + save_errno=thd->net.last_errno; + thd->net.last_errno=0; + thd->query_length=tmp.length(); + Query_log_event qev(thd,tmp.ptr()); + mysql_bin_log.write(&qev); + thd->net.last_errno=save_errno; + } if (--ull->count) pthread_cond_signal(&ull->cond); else |