Rechercher dans le manuel MySQL
13.3.8.2 XA Transaction States
An XA transaction progresses through the following states:
Use
XA START
to start an XA transaction and put it in theACTIVE
state.For an
ACTIVE
XA transaction, issue the SQL statements that make up the transaction, and then issue anXA END
statement.XA END
puts the transaction in theIDLE
state.For an
IDLE
XA transaction, you can issue either anXA PREPARE
statement or anXA COMMIT ... ONE PHASE
statement:XA PREPARE
puts the transaction in thePREPARED
state. AnXA RECOVER
statement at this point will include the transaction'sxid
value in its output, becauseXA RECOVER
lists all XA transactions that are in thePREPARED
state.XA COMMIT ... ONE PHASE
prepares and commits the transaction. Thexid
value will not be listed byXA RECOVER
because the transaction terminates.
For a
PREPARED
XA transaction, you can issue anXA COMMIT
statement to commit and terminate the transaction, orXA ROLLBACK
to roll back and terminate the transaction.
Here is a simple XA transaction that inserts a row into a table as part of a global transaction:
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 1 row affected (0.04 sec)
- Query OK, 0 rows affected (0.00 sec)
- mysql> XA PREPARE 'xatest';
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
Within the context of a given client connection, XA transactions
and local (non-XA) transactions are mutually exclusive. For
example, if XA
START
has been issued to begin an XA transaction, a
local transaction cannot be started until the XA transaction has
been committed or rolled back. Conversely, if a local
transaction has been started with
START
TRANSACTION
, no XA statements can be used until the
transaction has been committed or rolled back.
If an XA transaction is in the ACTIVE
state,
you cannot issue any statements that cause an implicit commit.
That would violate the XA contract because you could not roll
back the XA transaction. You will receive the following error if
you try to execute such a statement:
ERROR 1399 (XAE07): XAER_RMFAIL: The command cannot be executed
when global transaction is in the ACTIVE state
Statements to which the preceding remark applies are listed at Section 13.3.3, “Statements That Cause an Implicit Commit”.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-xa-states.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.