summaryrefslogtreecommitdiff
path: root/sql/rpl_injector.h
diff options
context:
space:
mode:
authorunknown <mats@mysql.com>2006-02-24 16:19:55 +0100
committerunknown <mats@mysql.com>2006-02-24 16:19:55 +0100
commit613fb54f95f440baa02ba31fbc317c2a880f3513 (patch)
treee45e91976dfa93a26c07b19e063f5073126ba2d2 /sql/rpl_injector.h
parent738a1ca08db810aa37069da149aa21590292caac (diff)
downloadmariadb-git-613fb54f95f440baa02ba31fbc317c2a880f3513.tar.gz
WL#3023 (RBR: Use locks in a statement-like manner):
Adaptions to make it work with NDB. mysql-test/extra/binlog_tests/binlog.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/blackhole.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/ctype_cp932.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/ctype_cp932_binlog.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/ctype_ucs_binlog.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/drop_temp_table.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/insert_select-binlog.test: Using replace_regex to remove table id. mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_flsh_tbls.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_log.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_multi_query.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_row_charset.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test: Using replace_regex to remove table id. mysql-test/extra/rpl_tests/rpl_stm_charset.test: Using replace_regex to remove table id. mysql-test/include/rpl_row_basic.inc: Removing sync with master on cleanup since there are engines that does not work in a "syncronized" fashion on dropping tables. mysql-test/r/binlog_row_binlog.result: Result change mysql-test/r/binlog_row_blackhole.result: Result change mysql-test/r/binlog_row_ctype_cp932.result: Result change mysql-test/r/binlog_row_ctype_ucs.result: Result change mysql-test/r/binlog_row_insert_select.result: Result change mysql-test/r/binlog_row_mix_innodb_myisam.result: Result change mysql-test/r/ctype_cp932_binlog_row.result: Result change mysql-test/r/rpl_row_basic_11bugs.result: Result change mysql-test/r/rpl_row_basic_2myisam.result: Result change mysql-test/r/rpl_row_basic_3innodb.result: Result change mysql-test/r/rpl_row_charset.result: Result change mysql-test/r/rpl_row_create_table.result: Result change mysql-test/r/rpl_row_delayed_ins.result: Result change mysql-test/r/rpl_row_log.result: Result change mysql-test/r/rpl_row_log_innodb.result: Result change mysql-test/r/rpl_row_max_relay_size.result: Result change mysql-test/r/rpl_row_sp008.result: Result change mysql-test/t/binlog_stm_binlog.test: Using replace_regex to remove table id. mysql-test/t/ndb_binlog_ddl_multi.test: Using replace_regex to remove table id. mysql-test/t/ndb_binlog_ignore_db.test: Using replace_regex to remove table id. mysql-test/t/rpl_heap.test: Using replace_regex to remove table id. mysql-test/t/rpl_loaddata_s.test: Using replace_regex to remove table id. mysql-test/t/rpl_ndb_blob.test: Using replace_regex to remove table id. mysql-test/t/rpl_ndb_disk.test: Using replace_regex to remove table id. mysql-test/t/rpl_row_basic_11bugs.test: Using replace_regex to remove table id. mysql-test/t/rpl_row_create_table.test: Using replace_regex to remove table id. mysql-test/t/rpl_row_drop.test: Using replace_regex to remove table id. mysql-test/t/rpl_row_sp008.test: Using replace_regex to remove table id. mysql-test/t/rpl_sp.test: Using replace_regex to remove table id. mysql-test/t/sp.test: Using replace_regex to remove table id. mysql-test/t/sp_notembedded.test: Using replace_regex to remove table id. mysql-test/t/user_var-binlog.test: Using replace_regex to remove table id. sql/ha_ndbcluster_binlog.cc: Assign_new_table_id() now takes table share. Removed gratuitous friend declaration of ndb_add_binlog_index(). Turning of binlogging during execution of ndb_add_binlog_index(). sql/handler.h: Removed gratuitous friend declaration of ndb_add_binlog_index(). sql/log.cc: Adding debug printout. sql/log_event.cc: Closing thread tables on dummy event. sql/rpl_injector.cc: Added support for new locking scheme. sql/rpl_injector.h: Added support for new locking scheme.
Diffstat (limited to 'sql/rpl_injector.h')
-rw-r--r--sql/rpl_injector.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h
index 32d3fdd1a78..50a0a56dd9b 100644
--- a/sql/rpl_injector.h
+++ b/sql/rpl_injector.h
@@ -160,6 +160,24 @@ public:
}
/*
+
+ DESCRIPTION
+
+ Register table for use within the transaction. All tables
+ that are going to be used need to be registered before being
+ used below. The member function will fail with an error if
+ use_table() is called after any *_row() function has been
+ called for the transaction.
+
+ RETURN VALUE
+
+ 0 All OK
+ >0 Failure
+
+ */
+ int use_table(server_id_type sid, table tbl);
+
+ /*
Add a 'write row' entry to the transaction.
*/
int write_row (server_id_type sid, table tbl,
@@ -219,6 +237,62 @@ public:
}
}
+ enum enum_state
+ {
+ START_STATE, /* Start state */
+ TABLE_STATE, /* At least one table has been registered */
+ ROW_STATE, /* At least one row has been registered */
+ STATE_COUNT /* State count and sink state */
+ } m_state;
+
+ /*
+ Check and update the state.
+
+ PARAMETER(S)
+
+ target_state
+ The state we are moving to: TABLE_STATE if we are
+ writing a table and ROW_STATE if we are writing a row.
+
+ DESCRIPTION
+
+ The internal state will be updated to the target state if
+ and only if it is a legal move. The only legal moves are:
+
+ START_STATE -> START_STATE
+ START_STATE -> TABLE_STATE
+ TABLE_STATE -> TABLE_STATE
+ TABLE_STATE -> ROW_STATE
+
+ That is:
+ - It is not possible to write any row before having written at
+ least one table
+ - It is not possible to write a table after at least one row
+ has been written
+
+ RETURN VALUE
+
+ 0 All OK
+ -1 Incorrect call sequence
+ */
+ int check_state(enum_state const target_state)
+ {
+ static char const *state_name[] = {
+ "START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT"
+ };
+
+ DBUG_ASSERT(0 <= target_state && target_state <= STATE_COUNT);
+ DBUG_PRINT("info", ("In state %s", state_name[m_state]));
+
+ if (m_state <= target_state && target_state <= m_state + 1 &&
+ m_state < STATE_COUNT)
+ m_state= target_state;
+ else
+ m_state= STATE_COUNT;
+ return m_state == STATE_COUNT ? 1 : 0;
+ }
+
+
binlog_pos m_start_pos;
THD *m_thd;
};