summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorunknown <mats@mysql.com>2006-02-24 16:31:38 +0100
committerunknown <mats@mysql.com>2006-02-24 16:31:38 +0100
commitd11aa8345db0801c62fcf966bfce6c4d7eda63f8 (patch)
tree6b2f92caee2aae47cbd2a4f203c4b2a8af20ab61 /sql/handler.cc
parentd6aea04c5b45fd8444d14872c08751746f1eba8b (diff)
parent613fb54f95f440baa02ba31fbc317c2a880f3513 (diff)
downloadmariadb-git-d11aa8345db0801c62fcf966bfce6c4d7eda63f8.tar.gz
Merge mysqldev@production.mysql.com:my/mysql-5.1-release
into mysql.com:/home/bk/w3023-mysql-5.1-new mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Auto merged mysql-test/extra/rpl_tests/rpl_log.test: Auto merged mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test: Auto merged mysql-test/r/binlog_row_insert_select.result: Auto merged mysql-test/r/rpl_row_delayed_ins.result: Auto merged mysql-test/t/rpl_sp.test: Auto merged mysql-test/t/sp.test: Auto merged sql/ha_ndbcluster_binlog.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged mysql-test/t/rpl_ndb_dd_basic.test: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_range.cc: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_table.cc: Auto merged sql/table.h: Auto merged mysql-test/r/binlog_row_mix_innodb_myisam.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_basic_11bugs.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_basic_2myisam.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_basic_3innodb.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_create_table.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_log.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_log_innodb.result: Merge with 5.1.7 release clone. mysql-test/r/rpl_row_sp008.result: Merge with 5.1.7 release clone. mysql-test/t/rpl_row_basic_11bugs.test: Merge with 5.1.7 release clone. mysql-test/t/rpl_row_sp008.test: Merge with 5.1.7 release clone.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc71
1 files changed, 56 insertions, 15 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 68ca3855158..25cec431395 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3200,40 +3200,81 @@ template int binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const
#endif /* HAVE_ROW_BASED_REPLICATION */
-int handler::ha_write_row(byte *buf)
+int handler::ha_external_lock(THD *thd, int lock_type)
{
+ DBUG_ENTER("handler::ha_external_lock");
int error;
- if (likely(!(error= write_row(buf))))
+ if (unlikely(error= external_lock(thd, lock_type)))
+ DBUG_RETURN(error);
+#ifdef HAVE_ROW_BASED_REPLICATION
+ if (table->file->is_injective())
+ DBUG_RETURN(0);
+
+ /*
+ There is a number of statements that are logged statement-based
+ but call external lock. For these, we do not need to generate a
+ table map.
+
+ TODO: The need for this switch is an indication that the model for
+ locking combined with row-based replication needs to be looked
+ over. Ideally, no such special handling should be needed.
+ */
+ switch (thd->lex->sql_command)
+ {
+ case SQLCOM_TRUNCATE:
+ case SQLCOM_ALTER_TABLE:
+ DBUG_RETURN(0);
+ }
+
+ /*
+ If we are locking a table for writing, we generate a table map.
+ For all other kinds of locks, we don't do anything.
+ */
+ if (lock_type == F_WRLCK && check_table_binlog_row_based(thd, table))
{
+ int const has_trans= table->file->has_transactions();
+ error= thd->binlog_write_table_map(table, has_trans);
+ if (unlikely(error))
+ DBUG_RETURN(error);
+ }
+#endif
+ DBUG_RETURN(0);
+}
+
+int handler::ha_write_row(byte *buf)
+{
+ int error;
+ if (unlikely(error= write_row(buf)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Write_rows_log_event>(table, 0, buf);
+ if (unlikely(error= binlog_log_row<Write_rows_log_event>(table, 0, buf)))
+ return error;
#endif
- }
- return error;
+ return 0;
}
int handler::ha_update_row(const byte *old_data, byte *new_data)
{
int error;
- if (likely(!(error= update_row(old_data, new_data))))
- {
+ if (unlikely(error= update_row(old_data, new_data)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data);
+ if (unlikely(error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data)))
+ return error;
#endif
- }
- return error;
+ return 0;
}
int handler::ha_delete_row(const byte *buf)
{
int error;
- if (likely(!(error= delete_row(buf))))
- {
+ if (unlikely(error= delete_row(buf)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Delete_rows_log_event>(table, buf, 0);
+ if (unlikely(error= binlog_log_row<Delete_rows_log_event>(table, buf, 0)))
+ return error;
#endif
- }
- return error;
+ return 0;
}