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