summaryrefslogtreecommitdiff
path: root/sql/rpl_injector.cc
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2006-01-12 19:51:02 +0100
committerunknown <tomas@poseidon.ndb.mysql.com>2006-01-12 19:51:02 +0100
commit4c798b42d37d0df05c49bb6be3e105fae891dd23 (patch)
tree5f26130f48df39314474782dafb7b845ebffb2ff /sql/rpl_injector.cc
parent5872e5aeb9424ae9c0472885bfd22fad53febd84 (diff)
downloadmariadb-git-4c798b42d37d0df05c49bb6be3e105fae891dd23.tar.gz
wl2325 wl2324
mysql-test/include/have_ndb_extra.inc: New BitKeeper file ``mysql-test/include/have_ndb_extra.inc'' mysql-test/include/not_ndb.inc: New BitKeeper file ``mysql-test/include/not_ndb.inc'' mysql-test/r/have_ndb_extra.require: New BitKeeper file ``mysql-test/r/have_ndb_extra.require'' mysql-test/r/ndb_alter_table_row.result: New BitKeeper file ``mysql-test/r/ndb_alter_table_row.result'' mysql-test/r/ndb_alter_table_stm.result: New BitKeeper file ``mysql-test/r/ndb_alter_table_stm.result'' mysql-test/r/ndb_binlog_basic.result: New BitKeeper file ``mysql-test/r/ndb_binlog_basic.result'' mysql-test/r/ndb_binlog_multi.result: New BitKeeper file ``mysql-test/r/ndb_binlog_multi.result'' mysql-test/r/ndb_multi_row.result: New BitKeeper file ``mysql-test/r/ndb_multi_row.result'' mysql-test/r/not_ndb.require: New BitKeeper file ``mysql-test/r/not_ndb.require'' mysql-test/r/rpl_ndb_bank.result: New BitKeeper file ``mysql-test/r/rpl_ndb_bank.result'' mysql-test/r/rpl_ndb_basic.result: New BitKeeper file ``mysql-test/r/rpl_ndb_basic.result'' mysql-test/r/rpl_ndb_disk.result: New BitKeeper file ``mysql-test/r/rpl_ndb_disk.result'' mysql-test/r/rpl_ndb_idempotent.result: New BitKeeper file ``mysql-test/r/rpl_ndb_idempotent.result'' mysql-test/r/rpl_ndb_load.result: New BitKeeper file ``mysql-test/r/rpl_ndb_load.result'' mysql-test/r/rpl_ndb_multi.result: New BitKeeper file ``mysql-test/r/rpl_ndb_multi.result'' mysql-test/r/rpl_ndb_sync.result: New BitKeeper file ``mysql-test/r/rpl_ndb_sync.result'' mysql-test/r/rpl_row_basic_7ndb.result: New BitKeeper file ``mysql-test/r/rpl_row_basic_7ndb.result'' mysql-test/t/ndb_alter_table_row.test: New BitKeeper file ``mysql-test/t/ndb_alter_table_row.test'' mysql-test/t/ndb_alter_table_stm.test: New BitKeeper file ``mysql-test/t/ndb_alter_table_stm.test'' mysql-test/t/ndb_binlog_basic.test: New BitKeeper file ``mysql-test/t/ndb_binlog_basic.test'' mysql-test/t/ndb_binlog_multi.test: New BitKeeper file ``mysql-test/t/ndb_binlog_multi.test'' mysql-test/t/ndb_multi_row.test: New BitKeeper file ``mysql-test/t/ndb_multi_row.test'' mysql-test/t/rpl_ndb_bank.test: New BitKeeper file ``mysql-test/t/rpl_ndb_bank.test'' mysql-test/t/rpl_ndb_basic.test: New BitKeeper file ``mysql-test/t/rpl_ndb_basic.test'' mysql-test/t/rpl_ndb_disk.test: New BitKeeper file ``mysql-test/t/rpl_ndb_disk.test'' mysql-test/t/rpl_ndb_idempotent.test: New BitKeeper file ``mysql-test/t/rpl_ndb_idempotent.test'' mysql-test/t/rpl_ndb_load.test: New BitKeeper file ``mysql-test/t/rpl_ndb_load.test'' mysql-test/t/rpl_ndb_multi.test: New BitKeeper file ``mysql-test/t/rpl_ndb_multi.test'' mysql-test/t/rpl_ndb_sync.test: New BitKeeper file ``mysql-test/t/rpl_ndb_sync.test'' mysql-test/t/rpl_row_basic_7ndb.test: New BitKeeper file ``mysql-test/t/rpl_row_basic_7ndb.test'' sql/ha_ndbcluster_binlog.cc: New BitKeeper file ``sql/ha_ndbcluster_binlog.cc'' sql/ha_ndbcluster_binlog.h: New BitKeeper file ``sql/ha_ndbcluster_binlog.h'' sql/ha_ndbcluster_tables.h: New BitKeeper file ``sql/ha_ndbcluster_tables.h'' sql/rpl_injector.cc: New BitKeeper file ``sql/rpl_injector.cc'' sql/rpl_injector.h: New BitKeeper file ``sql/rpl_injector.h'' storage/ndb/include/kernel/signaldata/DihFragCount.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/DihFragCount.hpp''
Diffstat (limited to 'sql/rpl_injector.cc')
-rw-r--r--sql/rpl_injector.cc153
1 files changed, 153 insertions, 0 deletions
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
new file mode 100644
index 00000000000..a69dea9a158
--- /dev/null
+++ b/sql/rpl_injector.cc
@@ -0,0 +1,153 @@
+/*
+ Copyright (C) 2005 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "mysql_priv.h"
+#include "rpl_injector.h"
+#ifdef HAVE_ROW_BASED_REPLICATION
+
+/*
+ injector::transaction - member definitions
+*/
+
+/* inline since it's called below */
+inline
+injector::transaction::transaction(MYSQL_LOG *log, THD *thd)
+ : m_thd(thd)
+{
+ /*
+ Default initialization of m_start_pos (which initializes it to garbage).
+ We need to fill it in using the code below.
+ */
+ LOG_INFO log_info;
+ log->get_current_log(&log_info);
+ /* !!! binlog_pos does not follow RAII !!! */
+ m_start_pos.m_file_name= my_strdup(log_info.log_file_name, MYF(0));
+ m_start_pos.m_file_pos= log_info.pos;
+
+ begin_trans(m_thd);
+}
+
+injector::transaction::~transaction()
+{
+ /* Needed since my_free expects a 'char*' (instead of 'void*'). */
+ char* const the_memory= const_cast<char*>(m_start_pos.m_file_name);
+
+ /*
+ We set the first character to null just to give all the copies of the
+ start position a (minimal) chance of seening that the memory is lost.
+ All assuming the my_free does not step over the memory, of course.
+ */
+ *the_memory= '\0';
+
+ my_free(the_memory, MYF(0));
+}
+
+int injector::transaction::commit()
+{
+ DBUG_ENTER("injector::transaction::commit()");
+ m_thd->binlog_flush_pending_rows_event(true);
+ end_trans(m_thd, COMMIT);
+ DBUG_RETURN(0);
+}
+
+
+int injector::transaction::write_row (server_id_type sid, table tbl,
+ MY_BITMAP const* cols, size_t colcnt,
+ record_type record)
+{
+ DBUG_ENTER("injector::transaction::write_row(...)");
+ m_thd->set_server_id(sid);
+ m_thd->binlog_write_row(tbl.get_table(), tbl.is_transactional(),
+ cols, colcnt, record);
+ DBUG_RETURN(0);
+}
+
+
+int injector::transaction::delete_row(server_id_type sid, table tbl,
+ MY_BITMAP const* cols, size_t colcnt,
+ record_type record)
+{
+ DBUG_ENTER("injector::transaction::delete_row(...)");
+ m_thd->set_server_id(sid);
+ m_thd->binlog_delete_row(tbl.get_table(), tbl.is_transactional(),
+ cols, colcnt, record);
+ DBUG_RETURN(0);
+}
+
+
+int injector::transaction::update_row(server_id_type sid, table tbl,
+ MY_BITMAP const* cols, size_t colcnt,
+ record_type before, record_type after)
+{
+ DBUG_ENTER("injector::transaction::update_row(...)");
+ m_thd->set_server_id(sid);
+ m_thd->binlog_update_row(tbl.get_table(), tbl.is_transactional(),
+ cols, colcnt, before, after);
+ DBUG_RETURN(0);
+}
+
+
+injector::transaction::binlog_pos injector::transaction::start_pos() const
+{
+ return m_start_pos;
+}
+
+
+/*
+ injector - member definitions
+*/
+
+/* This constructor is called below */
+inline injector::injector()
+{
+}
+
+static injector *s_injector= 0;
+injector *injector::instance()
+{
+ if (s_injector == 0)
+ s_injector= new injector;
+ /* "There can be only one [instance]" */
+ return s_injector;
+}
+
+
+
+injector::transaction injector::new_trans(THD *thd)
+{
+ DBUG_ENTER("injector::new_trans(THD*)");
+ /*
+ Currently, there is no alternative to using 'mysql_bin_log' since that
+ is hardcoded into the way the handler is using the binary log.
+ */
+ DBUG_RETURN(transaction(&mysql_bin_log, thd));
+}
+
+void injector::new_trans(THD *thd, injector::transaction *ptr)
+{
+ DBUG_ENTER("injector::new_trans(THD *, transaction *)");
+ /*
+ Currently, there is no alternative to using 'mysql_bin_log' since that
+ is hardcoded into the way the handler is using the binary log.
+ */
+ transaction trans(&mysql_bin_log, thd);
+ ptr->swap(trans);
+
+ DBUG_VOID_RETURN;
+}
+
+#endif