summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc43
1 files changed, 21 insertions, 22 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 12d7ffb2f5e..a45419f95ca 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1931,12 +1931,28 @@ int ha_recover(HASH *commit_list)
so mysql_xa_recover does not filter XID's to ensure uniqueness.
It can be easily fixed later, if necessary.
*/
+
+static my_bool xa_recover_callback(XID_STATE *xs, Protocol *protocol)
+{
+ if (xs->xa_state == XA_PREPARED)
+ {
+ protocol->prepare_for_resend();
+ protocol->store_longlong((longlong) xs->xid.formatID, FALSE);
+ protocol->store_longlong((longlong) xs->xid.gtrid_length, FALSE);
+ protocol->store_longlong((longlong) xs->xid.bqual_length, FALSE);
+ protocol->store(xs->xid.data, xs->xid.gtrid_length + xs->xid.bqual_length,
+ &my_charset_bin);
+ if (protocol->write())
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
bool mysql_xa_recover(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
- int i=0;
- XID_STATE *xs;
DBUG_ENTER("mysql_xa_recover");
field_list.push_back(new Item_int("formatID", 0, MY_INT32_NUM_DECIMAL_DIGITS));
@@ -1948,26 +1964,9 @@ bool mysql_xa_recover(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
- mysql_mutex_lock(&LOCK_xid_cache);
- while ((xs= (XID_STATE*) my_hash_element(&xid_cache, i++)))
- {
- if (xs->xa_state==XA_PREPARED)
- {
- protocol->prepare_for_resend();
- protocol->store_longlong((longlong)xs->xid.formatID, FALSE);
- protocol->store_longlong((longlong)xs->xid.gtrid_length, FALSE);
- protocol->store_longlong((longlong)xs->xid.bqual_length, FALSE);
- protocol->store(xs->xid.data, xs->xid.gtrid_length+xs->xid.bqual_length,
- &my_charset_bin);
- if (protocol->write())
- {
- mysql_mutex_unlock(&LOCK_xid_cache);
- DBUG_RETURN(1);
- }
- }
- }
-
- mysql_mutex_unlock(&LOCK_xid_cache);
+ if (xid_cache_iterate(thd, (my_hash_walk_action) xa_recover_callback,
+ protocol))
+ DBUG_RETURN(1);
my_eof(thd);
DBUG_RETURN(0);
}