summaryrefslogtreecommitdiff
path: root/db/dbinc/xa.h
blob: 5768c58c9b933876f801722296bd43ffa43c2562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1998-2006
 *	Oracle Corporation.  All rights reserved.
 *
 * $Id: xa.h,v 12.4 2006/08/24 14:45:30 bostic Exp $
 */
/*
 * Start of xa.h header
 *
 * Define a symbol to prevent multiple inclusions of this header file
 */
#ifndef	_DB_XA_H_
#define	_DB_XA_H_

#if defined(__cplusplus)
extern "C" {
#endif

/*
 * Transaction branch identification: XID and NULLXID:
 */
#define	XIDDATASIZE	128		/* size in bytes */
#define	MAXGTRIDSIZE	 64		/* maximum size in bytes of gtrid */
#define	MAXBQUALSIZE	 64		/* maximum size in bytes of bqual */

struct xid_t {
	long formatID;			/* format identifier */
	long gtrid_length;		/* value from 1 through 64 */
	long bqual_length;		/* value from 1 through 64 */
	char data[XIDDATASIZE];
};
typedef	struct xid_t XID;
/*
 * A value of -1 in formatID means that the XID is null.
 */

/*
 * Declarations of routines by which RMs call TMs:
 */
extern int ax_reg __P((int, XID *, long));
extern int ax_unreg __P((int, long));

/*
 * XA Switch Data Structure
 */
#define	RMNAMESZ	32		/* length of resource manager name, */
					/* including the null terminator */
#define	MAXINFOSIZE	256		/* maximum size in bytes of xa_info */
					/* strings, including the null
					terminator */
struct xa_switch_t {
	char name[RMNAMESZ];		/* name of resource manager */
	long flags;			/* resource manager specific options */
	long version;			/* must be 0 */
	int (*xa_open_entry)		/* xa_open function pointer */
	    __P((char *, int, long));
	int (*xa_close_entry)		/* xa_close function pointer */
	    __P((char *, int, long));
	int (*xa_start_entry)		/* xa_start function pointer */
	    __P((XID *, int, long));
	int (*xa_end_entry)		/* xa_end function pointer */
	    __P((XID *, int, long));
	int (*xa_rollback_entry)	/* xa_rollback function pointer */
	    __P((XID *, int, long));
	int (*xa_prepare_entry)		/* xa_prepare function pointer */
	    __P((XID *, int, long));
	int (*xa_commit_entry)		/* xa_commit function pointer */
	    __P((XID *, int, long));
	int (*xa_recover_entry)		/* xa_recover function pointer */
	    __P((XID *, long, int, long));
	int (*xa_forget_entry)		/* xa_forget function pointer */
	    __P((XID *, int, long));
	int (*xa_complete_entry)	/* xa_complete function pointer */
	    __P((int *, int *, int, long));
};

/*
 * Flag definitions for the RM switch
 */
#define	TMNOFLAGS	0x00000000L	/* no resource manager features
					selected */
#define	TMREGISTER	0x00000001L	/* resource manager dynamically
					registers */
#define	TMNOMIGRATE	0x00000002L	/* resource manager does not support
					association migration */
#define	TMUSEASYNC	0x00000004L	/* resource manager supports
					asynchronous operations */
/*
 * Flag definitions for xa_ and ax_ routines
 */
/* use TMNOFLAGGS, defined above, when not specifying other flags */
#define	TMASYNC		0x80000000L	/* perform routine asynchronously */
#define	TMONEPHASE	0x40000000L	/* caller is using one-phase commit
					optimisation */
#define	TMFAIL		0x20000000L	/* dissociates caller and marks
					transaction branch rollback-only */
#define	TMNOWAIT	0x10000000L	/* return if blocking condition
					exists */
#define	TMRESUME	0x08000000L	/* caller is resuming association with
					suspended transaction branch */
#define	TMSUCCESS	0x04000000L	/* dissociate caller from transaction
					branch */
#define	TMSUSPEND	0x02000000L	/* caller is suspending, not ending,
					association */
#define	TMSTARTRSCAN	0x01000000L	/* start a recovery scan */
#define	TMENDRSCAN	0x00800000L	/* end a recovery scan */
#define	TMMULTIPLE	0x00400000L	/* wait for any asynchronous
					operation */
#define	TMJOIN		0x00200000L	/* caller is joining existing
					transaction branch */
#define	TMMIGRATE	0x00100000L	/* caller intends to perform
					migration */

/*
 * ax_() return codes (transaction manager reports to resource manager)
 */
#define	TM_JOIN		2		/* caller is joining existing
					transaction branch */
#define	TM_RESUME	1		/* caller is resuming association with
					suspended transaction branch */
#define	TM_OK		0		/* normal execution */
#define	TMER_TMERR	-1		/* an error occurred in the transaction
					manager */
#define	TMER_INVAL	-2		/* invalid arguments were given */
#define	TMER_PROTO	-3		/* routine invoked in an improper
					context */

/*
 * xa_() return codes (resource manager reports to transaction manager)
 */
#define	XA_RBBASE	100		/* The inclusive lower bound of the
					rollback codes */
#define	XA_RBROLLBACK	XA_RBBASE	/* The rollback was caused by an
					unspecified reason */
#define	XA_RBCOMMFAIL	XA_RBBASE+1	/* The rollback was caused by a
					communication failure */
#define	XA_RBDEADLOCK	XA_RBBASE+2	/* A deadlock was detected */
#define	XA_RBINTEGRITY	XA_RBBASE+3	/* A condition that violates the
					integrity of the resources was
					detected */
#define	XA_RBOTHER	XA_RBBASE+4	/* The resource manager rolled back the
					transaction branch for a reason not
					on this list */
#define	XA_RBPROTO	XA_RBBASE+5	/* A protocol error occurred in the
					resource manager */
#define	XA_RBTIMEOUT	XA_RBBASE+6	/* A transaction branch took too long */
#define	XA_RBTRANSIENT	XA_RBBASE+7	/* May retry the transaction branch */
#define	XA_RBEND	XA_RBTRANSIENT	/* The inclusive upper bound of the
					rollback codes */
#define	XA_NOMIGRATE	9		/* resumption must occur where
					suspension occurred */
#define	XA_HEURHAZ	8		/* the transaction branch may have
					been heuristically completed */
#define	XA_HEURCOM	7		/* the transaction branch has been
					heuristically committed */
#define	XA_HEURRB	6		/* the transaction branch has been
					heuristically rolled back */
#define	XA_HEURMIX	5		/* the transaction branch has been
					heuristically committed and rolled
					back */
#define	XA_RETRY	4		/* routine returned with no effect and
					may be re-issued */
#define	XA_RDONLY	3		/* the transaction branch was read-only
					and has been committed */
#define	XA_OK		0		/* normal execution */
#define	XAER_ASYNC	-2		/* asynchronous operation already
					outstanding */
#define	XAER_RMERR	-3		/* a resource manager error occurred in
					 the transaction branch */
#define	XAER_NOTA	-4		/* the XID is not valid */
#define	XAER_INVAL	-5		/* invalid arguments were given */
#define	XAER_PROTO	-6		/* routine invoked in an improper
					context */
#define	XAER_RMFAIL	-7		/* resource manager unavailable */
#define	XAER_DUPID	-8		/* the XID already exists */
#define	XAER_OUTSIDE	-9		/* resource manager doing work outside
					transaction */

#if defined(__cplusplus)
}
#endif
#endif /* !_DB_XA_H_ */