summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-04-29 16:42:33 +0300
committerunknown <marko@hundin.mysql.fi>2004-04-29 16:42:33 +0300
commit57fc5263c4b95650f3c799574341ee7bf9c4c002 (patch)
tree5013e7c0279115014b75320a87795fe461ac1285 /sql/ha_innodb.cc
parentb3e55971ee5e6056a90500543076f089d7c7b84e (diff)
downloadmariadb-git-57fc5263c4b95650f3c799574341ee7bf9c4c002.tar.gz
InnoDB: implement LOCK TABLE (Bug #3299)
innobase/include/lock0lock.h: Add lock_table_unlock() and lock_release_tables_off_kernel() Add LOCK_TABLE_EXP innobase/include/row0mysql.h: Add row_unlock_table_for_mysql() and row_lock_table_for_mysql() innobase/include/trx0trx.h: Add n_tables_locked innobase/lock/lock0lock.c: Add LOCK_TABLE_EXP for explicit LOCK TABLE commands Add lock_table_unlock() Add lock_release_tables_off_kernel() innobase/row/row0mysql.c: Add row_unlock_table_for_mysql() and row_lock_table_for_mysql() innobase/trx/trx0trx.c: Add n_tables_locked mysql-test/r/innodb.result: Updated handling of auto_inc columns sql/ha_innodb.cc: Call row_lock_table_for_mysql() and row_unlock_table_for_mysql()
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 7a651fc12d9..de2a817a6cb 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -4494,12 +4494,11 @@ the SQL statement in case of an error. */
int
ha_innobase::external_lock(
/*=======================*/
- /* out: 0 or error code */
+ /* out: 0 */
THD* thd, /* in: handle to the user thread */
int lock_type) /* in: lock type */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- int error = 0;
trx_t* trx;
DBUG_ENTER("ha_innobase::external_lock");
@@ -4554,11 +4553,21 @@ ha_innobase::external_lock(
}
if (prebuilt->select_lock_type != LOCK_NONE) {
+ if (thd->in_lock_tables) {
+ ulint error;
+ error = row_lock_table_for_mysql(prebuilt);
+
+ if (error != DB_SUCCESS) {
+ error = convert_error_code_to_mysql(
+ error, user_thd);
+ DBUG_RETURN(error);
+ }
+ }
trx->mysql_n_tables_locked++;
}
- DBUG_RETURN(error);
+ DBUG_RETURN(0);
}
/* MySQL is releasing a table lock */
@@ -4566,6 +4575,9 @@ ha_innobase::external_lock(
trx->n_mysql_tables_in_use--;
prebuilt->mysql_has_locked = FALSE;
auto_inc_counter_for_this_stat = 0;
+ if (trx->n_tables_locked) {
+ row_unlock_table_for_mysql(trx);
+ }
/* If the MySQL lock count drops to zero we know that the current SQL
statement has ended */
@@ -4598,7 +4610,7 @@ ha_innobase::external_lock(
}
}
- DBUG_RETURN(error);
+ DBUG_RETURN(0);
}
/****************************************************************************