CUBRID Engine  latest
xa.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * xa.h - contains the public declarations of the XA+ Specification,
22  * Version 2 Snapshot, June 1994.
23  * derived from X/Open's "The XA+ Specification Version 2"
24  */
25 
26 #ifndef _XA_H_
27 #define _XA_H_
28 
29 #ident "$Id$"
30 
31 /*
32  * Transaction branch identification: XID and NULLXID:
33  */
34 #define XIDDATASIZE 128 /* size in bytes */
35 #define MAXGTRIDSIZE 64 /* maximum size in bytes of gtrid */
36 #define MAXBQUALSIZE 64 /* maximum size in bytes of bqual */
37 typedef struct xid_t XID;
38 struct xid_t
39 {
40  long formatID; /* format identifier */
41  long gtrid_length; /* value not to exceed 64 */
42  long bqual_length; /* value not to exceed 64 */
44 };
45 /*
46  * A value of -1 in formatID means that the XID is null.
47  */
48 
49 /*
50  * Declarations of functions by which RMs call TMs:
51  */
52 #ifdef __STDC__
53 extern int ax_reg (int, XID *, long);
54 extern int ax_unreg (int, long);
55 #else /* ifndef __STDC__ */
56 extern int ax_reg ();
57 extern int ax_unreg ();
58 #endif /* ifndef __STDC__ */
59 
60 /*
61  * XA Switch Data Structure
62  */
63 #define RMNAMESZ 32 /* length of resource manager name */
65 {
66  char name[RMNAMESZ]; /* name of resource manager */
67  long flags; /* resource manager specific options */
68  long version; /* must be 0 */
69 #ifdef __STDC__
70  int (*xa_open_entry) (char *, int, long); /* xa_open function pointer */
71  int (*xa_close_entry) (char *, int, long); /* xa_close function pointer */
72  int (*xa_start_entry) (XID *, int, long); /* xa_start function pointer */
73  int (*xa_end_entry) (XID *, int, long); /* xa_end function pointer */
74  int (*xa_rollback_entry) (XID *, int, long); /* xa_rollback function pointer */
75  int (*xa_prepare_entry) (XID *, int, long); /* xa_prepare function pointer */
76  int (*xa_commit_entry) (XID *, int, long); /* xa_commit function pointer */
77  int (*xa_recover_entry) (XID *, long, int, long);
78  /* xa_recover function pointer */
79  int (*xa_forget_entry) (XID *, int, long); /* xa_forget function pointer */
80  int (*xa_complete_entry) (int *, int *, int, long);
81  /* xa_complete function pointer */
82 #else /* ifndef __STDC__ */
83  int (*xa_open_entry) (); /* xa_open function pointer */
84  int (*xa_close_entry) (); /* xa_close function pointer */
85  int (*xa_start_entry) (); /* xa_start function pointer */
86  int (*xa_end_entry) (); /* xa_end function pointer */
87  int (*xa_rollback_entry) (); /* xa_rollback function pointer */
88  int (*xa_prepare_entry) (); /* xa_prepare function pointer */
89  int (*xa_commit_entry) (); /* xa_commit function pointer */
90  int (*xa_recover_entry) (); /* xa_recover function pointer */
91  int (*xa_forget_entry) (); /* xa_forget function pointer */
92  int (*xa_complete_entry) (); /* xa_complete function pointer */
93 #endif /* ifndef __STDC__ */
94 };
95 
96 /*
97  * Flag definition for the RM switch
98  */
99 #define TMNOFLAGS 0x00000000L /* no resource manager features selected */
100 #define TMREGISTER 0x00000001L /* resource manager dynamically registers */
101 #define TMNOMIGRATE 0x00000002L /* resource manager does not support association migration */
102 #define TMUSEASYNC 0x00000004L /* resource manager supports asynchronous operations */
103 
104 /*
105  * Flag definitions for xa_ and ax_ routines
106  */
107 /* Use TMNOFLAGS, defined above, when not specifying other flags */
108 #define TMASYNC 0x80000000L /* perform routine asynchronously */
109 #define TMONEPHASE 0x40000000L /* caller is using one-phase commit optimisation */
110 #define TMFAIL 0x20000000L /* dissociates caller and marks transaction branch rollback-only */
111 #define TMNOWAIT 0x10000000L /* return if blocking condition exists */
112 #define TMRESUME 0x08000000L /* caller is resuming association with suspended transaction branch */
113 #define TMSUCCESS 0x04000000L /* dissociate caller from transaction branch */
114 #define TMSUSPEND 0x02000000L /* caller is suspending, not ending, association */
115 #define TMSTARTRSCAN 0x01000000L /* start a recovery scan */
116 #define TMENDRSCAN 0x00800000L /* end a recovery scan */
117 #define TMMULTIPLE 0x00400000L /* wait for any asynchronous operation */
118 #define TMJOIN 0x00200000L /* caller is joining existing transaction branch */
119 #define TMMIGRATE 0x00100000L /* caller intends to perform migration */
120 
121 /*
122  * ax_() return codes (transaction manager reports to resource manager)
123  */
124 #define TM_JOIN 2 /* caller is joining existing transaction branch */
125 #define TM_RESUME 1 /* caller is resuming association with suspended transaction branch */
126 #define TM_OK 0 /* normal execution */
127 #define TMER_TMERR -1 /* an error occurred in the transaction manager */
128 #define TMER_INVAL -2 /* invalid arguments were given */
129 #define TMER_PROTO -3 /* routine invoked in an improper context */
130 
131 /*
132  * xa_() return codes (resource manager reports to transaction manager)
133  */
134 #define XA_RBBASE 100 /* The inclusive lower bound of the rollback codes */
135 #define XA_RBROLLBACK XA_RBBASE /* The rollback was caused by an unspecified reason */
136 #define XA_RBCOMMFAIL XA_RBBASE+1 /* The rollback was caused by a communication failure */
137 #define XA_RBDEADLOCK XA_RBBASE+2 /* A deadlock was detected */
138 #define XA_RBINTEGRITY XA_RBBASE+3 /* A condition that violates the integrity of the resources was detected */
139 #define XA_RBOTHER XA_RBBASE+4 /* The resource manager rolled back the transaction for a reason not on this
140  * list */
141 #define XA_RBPROTO XA_RBBASE+5 /* A protocal error occurred in the resource manager */
142 #define XA_RBTIMEOUT XA_RBBASE+6 /* A transaction branch took too long */
143 #define XA_RBTRANSIENT XA_RBBASE+7 /* May retry the transaction branch */
144 #define XA_RBEND XA_RBTRANSIENT /* The inclusive upper bound of the rollback codes */
145 
146 #define XA_NOMIGRATE 9 /* resumption must occur where suspension occurred */
147 #define XA_HEURHAZ 8 /* the transaction branch may have been heuristically completed */
148 #define XA_HEURCOM 7 /* the transaction branch has been heuristically comitted */
149 #define XA_HEURRB 6 /* the transaction branch has been heuristically rolled back */
150 #define XA_HEURMIX 5 /* the transaction branch has been heuristically committed and rolled back */
151 #define XA_RETRY 4 /* routine returned with no effect and may be re-issued */
152 #define XA_RDONLY 3 /* the transaction was read-only and has been committed */
153 #define XA_OK 0 /* normal execution */
154 #define XAER_ASYNC -2 /* asynchronous operation already outstanding */
155 #define XAER_RMERR -3 /* a resource manager error occurred in the transaction branch */
156 #define XAER_NOTA -4 /* the XID is not valid */
157 #define XAER_INVAL -5 /* invalid arguments were given */
158 #define XAER_PROTO -6 /* routine invoked in an improper context */
159 #define XAER_RMFAIL -7 /* resource manager unavailable */
160 #define XAER_DUPID -8 /* the XID already exists */
161 #define XAER_OUTSIDE -9 /* resource manager doing work */
162  /* outside global transaction */
163 
164 #endif /* _XA_H_ */
long gtrid_length
Definition: xa.h:41
long bqual_length
Definition: xa.h:42
Definition: xa.h:64
char data[XIDDATASIZE]
Definition: xa.h:43
#define XIDDATASIZE
Definition: xa.h:34
int ax_unreg()
int ax_reg()
long flags
Definition: xa.h:67
Definition: xa.h:38
long formatID
Definition: xa.h:40
#define RMNAMESZ
Definition: xa.h:63
long version
Definition: xa.h:68