summaryrefslogtreecommitdiff
path: root/sql/ha_berkeley.cc
diff options
context:
space:
mode:
authorunknown <vva@eagle.mysql.r18.ru>2004-03-27 00:35:45 +0400
committerunknown <vva@eagle.mysql.r18.ru>2004-03-27 00:35:45 +0400
commitaab1e50e719f1f31629890fad650e9b0290cb906 (patch)
tree023a520ba94e415acedf48d976d399e523da8b05 /sql/ha_berkeley.cc
parent8a6ae8395d789c6b8ad0a0f99454e1c4b709074c (diff)
downloadmariadb-git-aab1e50e719f1f31629890fad650e9b0290cb906.tar.gz
fixed bug #2342
"Running ANALYZE TABLE on bdb table inside a transaction hangs server thread" 1. added new status HA_ADMIN_REJECT and processing of it in mysql_admin_table 2. got ha_berkley::analyze to return HA_ADMIN_REJECT if there are any transactions with the table.. mysql-test/r/bdb-crash.result: added test for bug #2342 "Running ANALYZE TABLE on bdb table inside a transaction hangs server thread" mysql-test/t/bdb-crash.test: added test for bug #2342 "Running ANALYZE TABLE on bdb table inside a transaction hangs server thread" sql/ha_berkeley.cc: fixed bug #2342 "Running ANALYZE TABLE on bdb table inside a transaction hangs server thread" we have to return new status "HA_ADMIN_REJECT" for ha_berkley::analyze if there are any transaction for this table so as bdb documentation says: "The DB->stat method cannot be transaction protected" sql/handler.h: added new status of table info "HA_ADMIN_REJECT" We have to return this status for bdb tables which have any active transactions so as bdb-documentation says: "The DB->stat method cannot be transaction-protected" sql/sql_table.cc: added processing of the new status HA_ADMIN_REJECT in mysql_admin_table (reason to add this status is explained in comment for commit on sql/handler.h)
Diffstat (limited to 'sql/ha_berkeley.cc')
-rw-r--r--sql/ha_berkeley.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 35e731f20da..d0ce8f1fdb2 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -2099,6 +2099,44 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt)
{
DB_BTREE_STAT *stat=0;
uint i;
+ DB_TXN_STAT *txn_stat_ptr= 0;
+
+ /*
+ If it's a merge conflict here (4.0->4.1), please ignore it!
+
+ The reason of the conflict is the difference between versions of bdb:
+ mysql-4.0 uses bdb 3.2.9
+ mysql-4.1 uses bdb 4.1.24
+ Older one has global functions txn_stat and txn_id but
+ newer one has DB_ENV->txn_stat and DB_TXN->id
+ */
+ if (!txn_stat(db_env, &txn_stat_ptr, 0) &&
+ txn_stat_ptr && txn_stat_ptr->st_nactive>=2)
+ {
+ DB_TXN_ACTIVE *atxn_stmt= 0, *atxn_all= 0;
+
+ DB_TXN *txn_all= (DB_TXN*) thd->transaction.all.bdb_tid;
+ u_int32_t all_id= txn_id(txn_all);
+
+ DB_TXN *txn_stmt= (DB_TXN*) thd->transaction.stmt.bdb_tid;
+ u_int32_t stmt_id= txn_id(txn_stmt);
+
+ DB_TXN_ACTIVE *cur= txn_stat_ptr->st_txnarray;
+ DB_TXN_ACTIVE *end= cur + txn_stat_ptr->st_nactive;
+ for (; cur!=end && (!atxn_stmt || !atxn_all); cur++)
+ {
+ if (cur->txnid==all_id) atxn_all= cur;
+ if (cur->txnid==stmt_id) atxn_stmt= cur;
+ }
+
+ if (atxn_stmt && atxn_all &&
+ log_compare(&atxn_stmt->lsn,&atxn_all->lsn))
+ {
+ free(txn_stat_ptr);
+ return HA_ADMIN_REJECT;
+ }
+ free(txn_stat_ptr);
+ }
for (i=0 ; i < table->keys ; i++)
{