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