xa.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /****************************************************************************
  2. *
  3. * Licensed Materials - Property of IBM and/or HCL
  4. *
  5. * IBM Informix Client-SDK
  6. *
  7. * Copyright IBM Corporation 1997, 2008. All rights reserved.
  8. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  9. *
  10. * Title: xa.h
  11. * Description: Standard header file for XA.
  12. *
  13. * This comes from the X/OPEN XA spec and should not be modified unless
  14. * the standard changes.
  15. *
  16. ***************************************************************************
  17. */
  18. #ifndef XA_H
  19. #define XA_H
  20. /*
  21. * Global transaction identification: XID and NULLXID:
  22. */
  23. #define XIDDATASIZE 128 /* size in bytes */
  24. #define MAXGTRIDSIZE 64 /* maximum size in bytes of gtrid */
  25. #define MAXBQUALSIZE 64 /* maximum size in bytes of bqual */
  26. struct xid_t
  27. {
  28. long formatID; /* format identifier */
  29. long gtrid_length; /* value from 1 through 64 */
  30. long bqual_length; /* value from 1 through 64 */
  31. char data[XIDDATASIZE];
  32. };
  33. typedef struct xid_t XID;
  34. /*
  35. * A value of -1 in formatID means that the XID is null.
  36. */
  37. /*
  38. * Declarations of routines by which RMs call TMs:
  39. */
  40. /*
  41. * Informix never makes calls from the RM to the TM.
  42. *
  43. extern int ax_reg(int, XID *, long);
  44. extern int ax_unreg(int, long);
  45. */
  46. /*
  47. * XA Switch Data Structure
  48. */
  49. #define RMNAMESZ 32 /* length of resource manager name, */
  50. /* including the null terminator */
  51. #define MAXINFOSIZE 256 /* maximum size in bytes of xa_info strings, */
  52. /* including the null terminator */
  53. struct xa_switch_t
  54. {
  55. char name[RMNAMESZ]; /* name of resource manager */
  56. long flags; /* resource manager specific options */
  57. long version; /* must be 0 */
  58. int (*xa_open_entry)(char *, int, long);
  59. /* xa_open function pointer */
  60. int (*xa_close_entry)(char *, int, long);
  61. /* xa_close function pointer */
  62. int (*xa_start_entry)(XID *, int, long);
  63. /* xa_start function pointer */
  64. int (*xa_end_entry)(XID *, int, long);
  65. /* xa_end function pointer */
  66. int (*xa_rollback_entry)(XID *, int, long);
  67. /* xa_rollback function pointer */
  68. int (*xa_prepare_entry)(XID *, int, long);
  69. /* xa_prepare function pointer */
  70. int (*xa_commit_entry)(XID *, int, long);
  71. /* xa_commit function pointer */
  72. int (*xa_recover_entry)(XID *, long, int, long);
  73. /* xa_recover function pointer */
  74. int (*xa_forget_entry)(XID *, int, long);
  75. /* xa_forget function pointer */
  76. int (*xa_complete_entry)(int *, int *, int, long);
  77. /* xa_complete function pointer */
  78. };
  79. /*
  80. * Flag definitions for the RM switch.
  81. */
  82. #define TMNOFLAGS 0x00000000L /* no RM features selected */
  83. #define TMREGISTER 0x00000001L /* RM dynamically registers */
  84. #define TMNOMIGRATE 0x00000002L /* RM does not support
  85. association migration */
  86. #define TMUSEASYNC 0x00000004L /* RM supports async operations */
  87. /*
  88. * Flag definitions for xa_ and ax_ routines
  89. */
  90. /* use TMNOFLAGS, defined above, when not specifying other flags */
  91. #define TMASYNC 0x80000000L /* perform routine asynchronously */
  92. #define TMONEPHASE 0x40000000L /* caller is using one-phase commit
  93. optimisation */
  94. #define TMFAIL 0x20000000L /* dissociates caller and marks
  95. transaction branch rollback-only */
  96. #define TMNOWAIT 0x10000000L /* return if blocking condition
  97. exists */
  98. #define TMRESUME 0x08000000L /* caller is resuming association with
  99. suspended transaction branch */
  100. #define TMSUCCESS 0x04000000L /* dissociate caller from transaction
  101. branch */
  102. #define TMSUSPEND 0x02000000L /* caller is suspending, not ending,
  103. association */
  104. #define TMSTARTRSCAN 0x01000000L /* start a recovery scan */
  105. #define TMENDRSCAN 0x00800000L /* end a recovery scan */
  106. #define TMMULTIPLE 0x00400000L /* wait for any async operation */
  107. #define TMJOIN 0x00200000L /* caller is joining existing
  108. transaction branch */
  109. #define TMMIGRATE 0x00100000L /* caller intends to perform
  110. migration */
  111. /*
  112. * ax_() return codes (transaction manager reports to resource manager)
  113. */
  114. #define TM_JOIN 2 /* caller is joining existing transaction
  115. branch */
  116. #define TM_RESUME 1 /* caller is resuming assoc w/suspended
  117. transaction branch */
  118. #define TM_OK 0 /* normal execution */
  119. #define TMER_TMERR -1 /* an error occurred in trans. manager */
  120. #define TMER_INVAL -2 /* invalid arguments given */
  121. #define TMER_PROTO -3 /* routine invoked in improper context */
  122. /*
  123. * xa_() return codes (resource manager reports to transaction manager)
  124. */
  125. #define XA_RBBASE 100 /* The inclusive lower bound of the
  126. rollback codes */
  127. #define XA_RBROLLBACK XA_RBBASE /* The rollback was caused by an
  128. unspecified reason */
  129. #define XA_RBCOMMFAIL XA_RBBASE+1 /* The rollback was caused by a
  130. communication failure */
  131. #define XA_RBDEADLOCK XA_RBBASE+2 /* A deadlock was detected */
  132. #define XA_RBINTEGRITY XA_RBBASE+3 /* A condition that violates the
  133. integrity of the resources was
  134. detected */
  135. #define XA_RBOTHER XA_RBBASE+4 /* The RM rolled back the trans. branch
  136. for a reason not on this list */
  137. #define XA_RBPROTO XA_RBBASE+5 /* A protocol error occurred in the
  138. RM */
  139. #define XA_RBTIMEOUT XA_RBBASE+6 /* A transaction branch took too long */
  140. #define XA_RBTRANSIENT XA_RBBASE+7 /* May retry the transaction branch */
  141. #define XA_RBEND XA_RBTRANSIENT /* The inclusive upper bound of the
  142. rollback codes */
  143. #define XA_NOMIGRATE 9 /* resumption must occur where suspension
  144. occurred */
  145. #define XA_HEURHAZ 8 /* the transaction branch may have been
  146. heuristically completed */
  147. #define XA_HEURCOM 7 /* the transaction branch has been
  148. heuristically committed */
  149. #define XA_HEURRB 6 /* the transaction branch has been
  150. heuristically aborted */
  151. #define XA_HEURMIX 5 /* the transaction branch has been
  152. heuristically committed and aborted */
  153. #define XA_RETRY 4 /* routine returned with no effect and may
  154. be re-issued */
  155. #define XA_RDONLY 3 /* the trans was read-only and has been
  156. committed */
  157. #define XA_OK 0 /* normal execution */
  158. #define XAER_ASYNC -2 /* async. operation already outstanding */
  159. #define XAER_RMERR -3 /* an RM error occurred in the transaction
  160. branch */
  161. #define XAER_NOTA -4 /* the XID is not valid */
  162. #define XAER_INVAL -5 /* invalid arguments were given */
  163. #define XAER_PROTO -6 /* routine invoked in improper context */
  164. #define XAER_RMFAIL -7 /* RM unavailable */
  165. #define XAER_DUPID -8 /* the XID already exists */
  166. #define XAER_OUTSIDE -9 /* RM doing work outside global transaction */
  167. #endif /* XA_H */