blob: 9dcd519743fff3c9a2f202821169be1f05717264 [file] [log] [blame]
Tang Cheng31b95252014-10-23 09:22:35 +08001/* Copyright (c) 1992, 2006, Oracle. All rights reserved. */
2
3/*
4 NAME
5 xa.h - <one-line expansion of the name>
6 DESCRIPTION
7 <short description of component this file declares/defines>
8 PUBLIC FUNCTION(S)
9 <list of external functions declared/defined - with one-line descriptions>
10 PRIVATE FUNCTION(S)
11 <list of static functions defined in .c file - with one-line descriptions>
12 RETURNS
13 <function return values, for .c file with single function>
14 NOTES
15 <other useful comments, qualifications, etc.>
16
17 This is the public XA .h file
18
19 MODIFIED (MM/DD/YY)
20 yohu 08/27/06 - XA/RAC project changes: XAER_AFFINITY
21 dmukhin 06/29/05 - ANSI prototypes; miscellaneous cleanup
22 whe 09/01/99 - 976457:check __cplusplus for C++ code
23 ntang 10/20/98 - Remove TMCACHE & TMFORCL
24 abhide 08/04/97 - implement xaoforcl
25 abhide 07/23/97 - XA OTS project changes
26 schandra 02/20/96 - lint
27 abhide 04/07/94 - merge changes from branch 1.1.710.1
28 abhide 02/14/94 - Creation
29 abhide 02/10/94 - Creation
30 abhide 02/10/94 - Creation
31*/
32/*
33 * xa.h header
34 * Typed in from X/Open doc of March 13, 1990
35 * Updated to Parsippany II draft, March, 1991
36 * Updated to Co Review draft, 19 Sep 1991
37 */
38
39#ifndef XA_H
40#define XA_H
41
42
43/*
44 * Transaction branch identification: XID and NULLXID:
45 */
46
47
48#define XIDDATASIZE 128 /* size in bytes */
49#define MAXGTRIDSIZE 64 /* maximum size in bytes of gtrid */
50#define MAXBQUALSIZE 64 /* maximum size in bytes of bqual */
51struct xid_t {
52 long formatID; /* format identifier */
53 long gtrid_length; /* value from 1 through 64 */
54 long bqual_length; /* value from 1 through 64 */
55 char data[XIDDATASIZE];
56};
57typedef struct xid_t XID;
58
59/*
60 * A value of -1 in formatID means that the XID is null.
61 */
62/*
63 * Declarations of routines by which RMs call TMs:
64 */
65
66int ax_reg(int, XID *, long);
67int ax_unreg(int, long);
68/*
69 * XA Switch Data Structure
70 */
71#define RMNAMESZ 32 /* length of resource manager name, */
72 /* including the null terminator */
73#define MAXINFOSIZE 256 /* maximum size in bytes of xa_info strings, */
74 /* including the null terminator */
75struct xa_switch_t {
76 char name[RMNAMESZ]; /* name of resource manager */
77 long flags; /* resource manager specific options */
78 long version; /* must be 0 */
79
80 int (*xa_open_entry)(char *, int, long); /*xa_open function pointer*/
81 int (*xa_close_entry)(char *, int, long); /*xa_close function pointer*/
82 int (*xa_start_entry)(XID *, int, long); /*xa_start function pointer*/
83 int (*xa_end_entry)(XID *, int, long); /*xa_end function pointer*/
84 int (*xa_rollback_entry)(XID *, int, long);
85 /*xa_rollback function pointer*/
86 int (*xa_prepare_entry)(XID *, int, long); /*xa_prepare function pointer*/
87 int (*xa_commit_entry)(XID *, int, long); /*xa_commit function pointer*/
88 int (*xa_recover_entry)(XID *, long, int, long);
89 /*xa_recover function pointer*/
90 int (*xa_forget_entry)(XID *, int, long); /*xa_forget function pointer*/
91 int (*xa_complete_entry)(int *, int *, int, long);
92};
93
94/*
95 * Flag definition for the RM switch
96 */
97#define TMNOFLAGS 0x00000000L /* no resource manager features
98 selected */
99#define TMREGISTER 0x00000001L /* resource manager dynamically
100 registers */
101#define TMNOMIGRATE 0x00000002L /* resource manager does not support
102 association migration */
103#define TMUSEASYNC 0x00000004L /* resource manager supports
104 asynchronous operations */
105/*
106 * Flag definitions for xa_ and ax_ routines
107 */
108/* Use TMNOFLAGS, defined above, when not specifying other flags */
109#define TMASYNC 0x80000000L /* perform routine asynchronously */
110#define TMONEPHASE 0x40000000L /* caller is using one-phase commit
111 optimisation */
112#define TMFAIL 0x20000000L /* dissociates caller and marks
113 transaction branch rollback-only */
114#define TMNOWAIT 0x10000000L /* return if blocking condition
115 exists */
116#define TMRESUME 0x08000000L /* caller is resuming association
117 with suspended transaction branch */
118#define TMSUCCESS 0x04000000L /* dissociate caller from transaction
119 branch */
120#define TMSUSPEND 0x02000000L /* caller is suspending, not ending,
121 association */
122#define TMSTARTRSCAN 0x01000000L /* start a recovery scan */
123#define TMENDRSCAN 0x00800000L /* end a recovery scan */
124#define TMMULTIPLE 0x00400000L /* wait for any asynchronous
125 operation */
126#define TMJOIN 0x00200000L /* caller is joining existing
127 transaction branch */
128#define TMMIGRATE 0x00100000L /* caller intends to perform
129 migration */
130
131/*
132 * ax_() return codes (transaction manager reports to resource manager)
133 */
134#define TM_JOIN 2 /* caller is joining existing transaction
135 branch */
136#define TM_RESUME 1 /* caller is resuming association with
137 suspended transaction branch */
138#define TM_OK 0 /* normal execution */
139#define TMER_TMERR -1 /* an error occurred in the transaction
140 manager */
141#define TMER_INVAL -2 /* invalid arguments were given */
142#define TMER_PROTO -3 /* routine invoked in an improper context */
143
144/*
145 * xa_() return codes (resource manager reports to transaction manager)
146 */
147#define XA_RBBASE 100 /* The inclusive lower bound of the
148 rollback codes */
149#define XA_RBROLLBACK XA_RBBASE /* The rollback was caused by an
150 unspecified reason */
151#define XA_RBCOMMFAIL XA_RBBASE+1 /* The rollback was caused by a
152 communication failure */
153#define XA_RBDEADLOCK XA_RBBASE+2 /* A deadlock was detected */
154#define XA_RBINTEGRITY XA_RBBASE+3 /* A condition that violates the
155 integrity of the resources was
156 detected */
157#define XA_RBOTHER XA_RBBASE+4 /* The resource manager rolled back the
158 transaction for a reason not on this
159 list */
160#define XA_RBPROTO XA_RBBASE+5 /* A protocal error occurred in the
161 resource manager */
162#define XA_RBTIMEOUT XA_RBBASE+6 /* A transaction branch took too long*/
163#define XA_RBTRANSIENT XA_RBBASE+7 /* May retry the transaction branch */
164#define XA_RBEND XA_RBTRANSIENT /* The inclusive upper bound of the
165 rollback codes */
166
167#define XA_NOMIGRATE 9 /* resumption must occur where
168 suspension occurred */
169#define XA_HEURHAZ 8 /* the transaction branch may have been
170 heuristically completed */
171#define XA_HEURCOM 7 /* the transaction branch has been
172 heuristically comitted */
173#define XA_HEURRB 6 /* the transaction branch has been
174 heuristically rolled back */
175#define XA_HEURMIX 5 /* the transaction branch has been
176 heuristically committed and rolled
177 back */
178#define XA_RETRY 4 /* routine returned with no effect
179 and may be re-issued */
180#define XA_RDONLY 3 /* the transaction was read-only
181 and has been committed */
182#define XA_OK 0 /* normal execution */
183#define XAER_ASYNC -2 /* asynchronous operation already
184 outstanding */
185#define XAER_RMERR -3 /* a resource manager error occurred
186 in the transaction branch */
187#define XAER_NOTA -4 /* the XID is not valid */
188#define XAER_INVAL -5 /* invalid arguments were given */
189#define XAER_PROTO -6 /* routine invoked in an improper
190 context */
191#define XAER_RMFAIL -7 /* resource manager unavailable */
192#define XAER_DUPID -8 /* the XID already exists */
193#define XAER_OUTSIDE -9 /* resource manager doing work */
194 /* outside global transaction */
195
196#define XAER_AFFINITY -10 /* XA on RAC: resumption must occur on
197 RAC instance where the transaction
198 branch was created */
199
200#endif /* ifndef XA_H */