diff options
author | monty@tik.mysql.fi <> | 2001-09-08 01:02:41 +0300 |
---|---|---|
committer | monty@tik.mysql.fi <> | 2001-09-08 01:02:41 +0300 |
commit | e508ad16f875f054b0facf07b23d6343165d2cd9 (patch) | |
tree | ae2efc76e4b2f8a70ac53298ce1e9d609e907a21 /sql | |
parent | 5b4d5d50dbafd7cf216099425c7fa9e5b7a5a20e (diff) | |
download | mariadb-git-e508ad16f875f054b0facf07b23d6343165d2cd9.tar.gz |
Fix for LOCK TABLES and BDB tables
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_berkeley.cc | 13 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 |
3 files changed, 20 insertions, 6 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 25f8148e52f..7ee72803dd9 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1658,12 +1658,15 @@ int ha_berkeley::external_lock(THD *thd, int lock_type) { if (!thd->transaction.bdb_lock_count++) { + changed_rows=0; /* First table lock, start transaction */ - if ((thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)) && + if ((thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN | + OPTION_TABLE_LOCK)) && !thd->transaction.all.bdb_tid) { + DBUG_ASSERT(thd->transaction.stmt.bdb_tid != 0); /* We have to start a master transaction */ - DBUG_PRINT("trans",("starting transaction")); + DBUG_PRINT("trans",("starting transaction all")); if ((error=txn_begin(db_env, 0, (DB_TXN**) &thd->transaction.all.bdb_tid, 0))) @@ -1671,8 +1674,10 @@ int ha_berkeley::external_lock(THD *thd, int lock_type) thd->transaction.bdb_lock_count--; // We didn't get the lock /* purecov: inspected */ DBUG_RETURN(error); /* purecov: inspected */ } + if (thd->in_lock_tables) + DBUG_RETURN(0); // Don't create stmt trans } - DBUG_PRINT("trans",("starting transaction for statement")); + DBUG_PRINT("trans",("starting transaction stmt")); if ((error=txn_begin(db_env, (DB_TXN*) thd->transaction.all.bdb_tid, (DB_TXN**) &thd->transaction.stmt.bdb_tid, @@ -1684,7 +1689,6 @@ int ha_berkeley::external_lock(THD *thd, int lock_type) } } transaction= (DB_TXN*) thd->transaction.stmt.bdb_tid; - changed_rows=0; } else { @@ -1722,6 +1726,7 @@ int ha_berkeley::start_stmt(THD *thd) DBUG_ENTER("ha_berkeley::start_stmt"); if (!thd->transaction.stmt.bdb_tid) { + DBUG_PRINT("trans",("starting transaction stmt")); error=txn_begin(db_env, (DB_TXN*) thd->transaction.all.bdb_tid, (DB_TXN**) &thd->transaction.stmt.bdb_tid, 0); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 06d0b1528f4..841d76928e1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -163,7 +163,8 @@ void kill_one_thread(THD *thd, ulong id); #define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2 #define OPTION_NOT_AUTO_COMMIT OPTION_BIN_LOG*2 #define OPTION_BEGIN OPTION_NOT_AUTO_COMMIT*2 -#define OPTION_QUICK OPTION_BEGIN*2 +#define OPTION_TABLE_LOCK OPTION_BEGIN*2 +#define OPTION_QUICK OPTION_TABLE_LOCK*2 #define OPTION_QUOTE_SHOW_CREATE OPTION_QUICK*2 #define OPTION_INTERNAL_SUBTRANSACTIONS OPTION_QUOTE_SHOW_CREATE*2 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 417484b2ef7..18ab3c45359 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -81,7 +81,8 @@ static void init_signals(void) inline bool end_active_trans(THD *thd) { int error=0; - if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)) + if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN | + OPTION_TABLE_LOCK)) { thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->server_status&= ~SERVER_STATUS_IN_TRANS; @@ -1825,7 +1826,11 @@ mysql_execute_command(void) { thd->lock=thd->locked_tables; thd->locked_tables=0; // Will be automaticly closed + } + if (thd->options & OPTION_TABLE_LOCK) + { end_active_trans(thd); + thd->options&= ~(ulong) (OPTION_TABLE_LOCK); } if (thd->global_read_lock) { @@ -1847,12 +1852,15 @@ mysql_execute_command(void) if (check_db_used(thd,tables) || end_active_trans(thd)) goto error; thd->in_lock_tables=1; + thd->options|= OPTION_TABLE_LOCK; if (!(res=open_and_lock_tables(thd,tables))) { thd->locked_tables=thd->lock; thd->lock=0; send_ok(&thd->net); } + else + thd->options&= ~(ulong) (OPTION_TABLE_LOCK); thd->in_lock_tables=0; break; case SQLCOM_CREATE_DB: |