[TransWarp] Revised proposal: joinTxn -> outsideTxn
Phillip J. Eby
pje at telecommunity.com
Fri Mar 7 13:00:35 EST 2003
After a brief verbal consultation with Ty, I realized that there is another
use case for being able to refrain from a connection being in a
transaction, and that use case cannot be achieved safely using SQL
statements. Some databases (such as Sybase, again) do not allow DDL within
a transaction, including the creation of temporary tables. This means that
we need to be able to truly execute SQL outside of a transaction, in
certain cases.
Although Ty also suggested we reverse the 'joinTxn' flag to default to
True, I have decided instead to replace it with an 'outsideTxn' flag, since
this represents a state that you want, rather than an action from which you
wish to refrain. While 'joinTxn' caused one action to occur, the
'outsideTxn' flag will be consulted for every SQL statement executed by a
given cursor, and the cursor will ensure that the connection's state
matches the cursor's desired state. If an 'outsideTxn=True' cursor
executes a statement after an 'outsideTxn=False' cursor, a
'TransactionInProgress' error will be raised, even if the 'outsideTxn=True'
cursor was previously used successfully. In this way, it is safe to use
multiple open cursors with assured semantics regarding whether their
statements will be executed inside or outside a transaction.
The resulting syntax:
* is invisible in the common case
* is explicit and clear as to intent in the uncommon case, and
* never fails silently in either case, even with multiple cursors in use
I think we have a winner.
More information about the PEAK
mailing list