xa.h 7.8 KB

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