summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorvva@eagle.mysql.r18.ru <>2004-03-27 02:29:31 +0400
committervva@eagle.mysql.r18.ru <>2004-03-27 02:29:31 +0400
commit8a66c13b34ba4c8454a87a292fd1d7f9ea1ab6fd (patch)
tree1c5e253563e466214850e1257016a6fabab0a821 /sql
parentd1622a941d6dc6659b3930721f242e1ac51ad502 (diff)
downloadmariadb-git-8a66c13b34ba4c8454a87a292fd1d7f9ea1ab6fd.tar.gz
fixed bug #2342
"Running ANALYZE TABLE on bdb table inside a transaction hangs server thread"
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.cc29
-rw-r--r--sql/handler.h1
-rw-r--r--sql/sql_table.cc6
3 files changed, 36 insertions, 0 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 70ecc61bfb8..4a1ce43cf70 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -2125,6 +2125,35 @@ 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 (!db_env->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_all->id(txn_all);
+
+ DB_TXN *txn_stmt= (DB_TXN*) thd->transaction.stmt.bdb_tid;
+ u_int32_t stmt_id= txn_stmt->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++)
{
diff --git a/sql/handler.h b/sql/handler.h
index 35a93709e98..26fb762a9b5 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -41,6 +41,7 @@
#define HA_ADMIN_CORRUPT -3
#define HA_ADMIN_INTERNAL_ERROR -4
#define HA_ADMIN_INVALID -5
+#define HA_ADMIN_REJECT -6
/* Bits in table_flags() to show what database can do */
#define HA_READ_RND_SAME 1 /* Read RND-record to KEY-record
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index be3615c71ce..48007b44f43 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1666,6 +1666,12 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
protocol->store("Operation failed",16, system_charset_info);
break;
+ case HA_ADMIN_REJECT:
+ protocol->store("status", 6, system_charset_info);
+ protocol->store("Operation need committed state",30, system_charset_info);
+ open_for_modify= false;
+ break;
+
case HA_ADMIN_ALREADY_DONE:
protocol->store("status", 6, system_charset_info);
protocol->store("Table is already up to date", 27, system_charset_info);