Commit a89c10fd authored by unknown's avatar unknown

WL#3023 (RBR: Use locks in a statment-like manner):

  Interface changes pushed early.
  Separation of public and implementation interface for external_lock()
  in preparation for implementation.


sql/handler.cc:
  Separating public virtual external_lock() into public non-virtual
  ha_external_lock() and private virtual external_lock().  Some minor
  changes to ha_*_row() function.
sql/handler.h:
  Separating public virtual external_lock() into public non-virtual
  ha_external_lock() and private virtual external_lock().
sql/lock.cc:
  Using new public ha_external_lock instead of internal external_lock.
sql/opt_range.cc:
  Using new public ha_external_lock instead of internal external_lock.
sql/sql_table.cc:
  Using new public ha_external_lock instead of internal external_lock.
parent 4bd027d0
......@@ -3014,40 +3014,48 @@ template int binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const
#endif /* HAVE_ROW_BASED_REPLICATION */
int handler::ha_external_lock(THD *thd, int lock_type)
{
int error;
if (unlikely(error= external_lock(thd, lock_type)))
return error;
return 0;
}
int handler::ha_write_row(byte *buf)
{
int error;
if (likely(!(error= write_row(buf))))
{
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;
}
......
......@@ -1237,6 +1237,7 @@ public:
interface, see the (private) functions write_row(), update_row(),
and delete_row() below.
*/
int ha_external_lock(THD *thd, int lock_type);
int ha_write_row(byte * buf);
int ha_update_row(const byte * old_data, byte * new_data);
int ha_delete_row(const byte * buf);
......@@ -1378,7 +1379,6 @@ public:
{ return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
{ return extra(operation); }
virtual int external_lock(THD *thd, int lock_type) { return 0; }
/*
In an UPDATE or DELETE, if the row under the cursor was locked by another
transaction, and the engine used an optimistic read of the last
......@@ -1626,6 +1626,12 @@ private:
overridden by the storage engine class. To call these methods, use
the corresponding 'ha_*' method above.
*/
virtual int external_lock(THD *thd __attribute__((unused)),
int lock_type __attribute__((unused)))
{
return 0;
}
virtual int write_row(byte *buf __attribute__((unused)))
{
return HA_ERR_WRONG_COMMAND;
......
......@@ -229,12 +229,12 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
((*tables)->reginfo.lock_type >= TL_READ &&
(*tables)->reginfo.lock_type <= TL_READ_NO_INSERT))
lock_type=F_RDLCK;
if ((error=(*tables)->file->external_lock(thd,lock_type)))
if ((error=(*tables)->file->ha_external_lock(thd,lock_type)))
{
print_lock_error(error, (*tables)->file->table_type());
for (; i-- ; tables--)
{
(*tables)->file->external_lock(thd, F_UNLCK);
(*tables)->file->ha_external_lock(thd, F_UNLCK);
(*tables)->current_lock=F_UNLCK;
}
DBUG_RETURN(error);
......@@ -562,7 +562,7 @@ static int unlock_external(THD *thd, TABLE **table,uint count)
if ((*table)->current_lock != F_UNLCK)
{
(*table)->current_lock = F_UNLCK;
if ((error=(*table)->file->external_lock(thd, F_UNLCK)))
if ((error=(*table)->file->ha_external_lock(thd, F_UNLCK)))
{
error_code=error;
print_lock_error(error_code, (*table)->file->table_type());
......
......@@ -844,7 +844,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file,
free_file));
file->ha_reset();
file->external_lock(current_thd, F_UNLCK);
file->ha_external_lock(current_thd, F_UNLCK);
file->close();
delete file;
}
......@@ -1008,14 +1008,14 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
/* Caller will free the memory */
goto failure;
}
if (file->external_lock(thd, F_RDLCK))
if (file->ha_external_lock(thd, F_RDLCK))
goto failure;
if (file->extra(HA_EXTRA_KEYREAD) ||
file->ha_retrieve_all_pk() ||
init() || reset())
{
file->external_lock(thd, F_UNLCK);
file->ha_external_lock(thd, F_UNLCK);
file->close();
goto failure;
}
......
......@@ -5254,7 +5254,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (!(copy= new Copy_field[to->s->fields]))
DBUG_RETURN(-1); /* purecov: inspected */
if (to->file->external_lock(thd, F_WRLCK))
if (to->file->ha_external_lock(thd, F_WRLCK))
DBUG_RETURN(-1);
/* We can abort alter table for any table type */
......@@ -5394,7 +5394,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
free_io_cache(from);
*copied= found_count;
*deleted=delete_count;
if (to->file->external_lock(thd,F_UNLCK))
if (to->file->ha_external_lock(thd,F_UNLCK))
error=1;
DBUG_RETURN(error > 0 ? -1 : 0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment