content_image/745260.jpg
xid  values typically are generated by the Transaction Manager. Values generated by one TM must be different from values generated by other TMs. A given TM must be able to recognize its own xid  values in a list of values returned by the XA RECOVER  statement. 

XA START xid  starts an XA transaction with the given xid  value. Each XA transaction must have a unique xid  value, so the value must not currently be used by another XA transaction. Uniqueness is assessed using the gtrid  and bqual  values. All following XA statements for the XA transaction must be specified using the same xid  value as that given in the XA START  statement. If you use any of those statements but specify an xid  value that does not correspond to some existing XA transaction, an error occurs. 

One or more XA transactions can be part of the same global transaction. All XA transactions within a given global transaction must use the same gtrid  value in the xid  value. For this reason, gtrid  values must be globally unique so that there is no ambiguity about which global transaction a given XA transaction is part of. The bqual  part of the xid  value must be different for each XA transaction within a global transaction. (The requirement that bqual  values be different is a limitation of the current MySQL XA implementation. It is not part of the XA specification.) 

The XA RECOVER  statement returns information for those XA transactions on the MySQL server that are in the PREPARED  state. (See Section 13.3.8.2, “XA Transaction States” .) The output includes a row for each such XA transaction on the server, regardless of which client started it. 

XA RECOVER  requires the XA_RECOVER_ADMIN  privilege. This privilege requirement prevents users from discovering the XID values for outstanding prepared XA transactions other than their own. It does not affect normal commit or rollback of an XA transaction because the user who started it knows its XID. 

XA RECOVER  output rows look like this (for an example xid  value consisting of the parts ’abc’ , ’def’ , and 7 ): 

mysql> XA RECOVER; 

<img src='content_image/745260.jpg'>

The output columns have the following meanings: 

• formatID  is the formatID  part of the transaction xid 

• gtrid_length  is the length in bytes of the gtrid  part of the xid 

• bqual_length  is the length in bytes of the bqual  part of the xid 

• data  is the concatenation of the gtrid  and bqual  parts of the xid 

XID values may contain nonprintable characters. XA RECOVER  permits an optional CONVERT XID  clause so that clients can request XID values in hexadecimal. 

## 13.3.8.2 XA Transaction States 

An XA transaction progresses through the following states: 

1. Use XA START  to start an XA transaction and put it in the ACTIVE  state. 

2. For an ACTIVE  XA transaction, issue the SQL statements that make up the transaction, and then issue an XA END  statement. XA END  puts the transaction in the IDLE  state. 

