You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bernt M. Johnsen" <Be...@Sun.COM> on 2005/12/21 12:53:49 UTC

The values for XA_OK and XA_RDONLY

I find it strange (and poteontially dangerous) that

org.apache.derby.iapi.store.access.XATransactionController
defines (public) that XA_OK = 2 and XA_RDONLY = 1
while the XA spec, the JTA spec and javax.transaction.xa.XAException
defines XA_OK = 0 and XA_RDONLY = 3

does anyone have a reasonable explanation?
-- 
Bernt Marius Johnsen, Database Technology Group, 
Sun Microsystems, Trondheim, Norway

Re: The values for XA_OK and XA_RDONLY

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I think it is ok.  The code should not count on them having the same
values.  As Francois points out the caller should do the mapping from 
XATransactionController constants to XAResource constants.
Historically I believe the reason there is an "internal" and
"external" set of constants is one piece of code did not want to require
the XA interfaces to compile, while the the other piece could.  I could
be wrong, it was a long time ago.

I don't know if this still applies today.

Francois Orsini wrote:
> Well I see these as constants being defined as part of some interface(s) 
> (space), hence they should be de-referenced through the interface as it 
> is done within:
> 
> org.apache.derby.jdbc.EmbedXAConnection
> 
> [...]
>                 if (ret == XATransactionController.XA_OK) {
>                     tranState.isPrepared = true;
> 
>                     return XAResource.XA_OK;
>                 } else {
> 
>                     returnConnectionToResource(tranState, xid_im);
>                     return XAResource.XA_RDONLY;
>                 }
> [...]
> 
> Note the 2 returns which will get you what is defined in the specs. 
> hence no problem. It would be wrong to return 
> XATransactionController.XA_OK directly to the external caller above as 
> this last one depends on what's defined in XAResource as the public API. 
> If it is not done like above in other areas of the code, then we would 
> have a problem ;)
> 
> --francois
> 
> On 12/21/05, *Bernt M. Johnsen* <Bernt.Johnsen@sun.com 
> <ma...@sun.com>> wrote:
> 
>      >>>>>>>>>>>> Bernt M. Johnsen wrote (2005-12-21 12:53:49):
>      > I find it strange (and poteontially dangerous) that
>      >
>      > org.apache.derby.iapi.store.access.XATransactionController
>      > defines (public) that XA_OK = 2 and XA_RDONLY = 1
> 
>     The same does org.apache.derby.iapi.store.raw.Transaction
> 
>      > while the XA spec, the JTA spec and javax.transaction.xa.XAException
>      > defines XA_OK = 0 and XA_RDONLY = 3
>      >
>      > does anyone have a reasonable explanation?
>      > --
>      > Bernt Marius Johnsen, Database Technology Group,
>      > Sun Microsystems, Trondheim, Norway
> 
> 
> 
>     --
>     Bernt Marius Johnsen, Database Technology Group,
>     Sun Microsystems, Trondheim, Norway
> 
> 
> 


Re: The values for XA_OK and XA_RDONLY

Posted by Francois Orsini <fr...@gmail.com>.
Well I see these as constants being defined as part of some interface(s)
(space), hence they should be de-referenced through the interface as it is
done within:

org.apache.derby.jdbc.EmbedXAConnection

[...]
                if (ret == XATransactionController.XA_OK) {
                    tranState.isPrepared = true;

                    return XAResource.XA_OK;
                } else {

                    returnConnectionToResource(tranState, xid_im);
                    return XAResource.XA_RDONLY;
                }
[...]

Note the 2 returns which will get you what is defined in the specs. hence no
problem. It would be wrong to return XATransactionController.XA_OK directly
to the external caller above as this last one depends on what's defined in
XAResource as the public API. If it is not done like above in other areas of
the code, then we would have a problem ;)

--francois

On 12/21/05, Bernt M. Johnsen <Be...@sun.com> wrote:
>
> >>>>>>>>>>>> Bernt M. Johnsen wrote (2005-12-21 12:53:49):
> > I find it strange (and poteontially dangerous) that
> >
> > org.apache.derby.iapi.store.access.XATransactionController
> > defines (public) that XA_OK = 2 and XA_RDONLY = 1
>
> The same does org.apache.derby.iapi.store.raw.Transaction
>
> > while the XA spec, the JTA spec and javax.transaction.xa.XAException
> > defines XA_OK = 0 and XA_RDONLY = 3
> >
> > does anyone have a reasonable explanation?
> > --
> > Bernt Marius Johnsen, Database Technology Group,
> > Sun Microsystems, Trondheim, Norway
>
>
>
> --
> Bernt Marius Johnsen, Database Technology Group,
> Sun Microsystems, Trondheim, Norway
>
>
>

Re: The values for XA_OK and XA_RDONLY

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
>>>>>>>>>>>> Bernt M. Johnsen wrote (2005-12-21 12:53:49):
> I find it strange (and poteontially dangerous) that
> 
> org.apache.derby.iapi.store.access.XATransactionController
> defines (public) that XA_OK = 2 and XA_RDONLY = 1

The same does org.apache.derby.iapi.store.raw.Transaction

> while the XA spec, the JTA spec and javax.transaction.xa.XAException
> defines XA_OK = 0 and XA_RDONLY = 3
> 
> does anyone have a reasonable explanation?
> -- 
> Bernt Marius Johnsen, Database Technology Group, 
> Sun Microsystems, Trondheim, Norway



-- 
Bernt Marius Johnsen, Database Technology Group, 
Sun Microsystems, Trondheim, Norway