On Mon, 16 Jan 2006 23:15:59 +0000 (UTC), Jeremy Nixon wrote:
> There are two
> ways to put a transaction into that mode: you can open a transaction and
> then "set transaction isolation level serializable", or you can open the
> transaction by doing "begin transaction isolation level serializable".
> 
> DBI won't let you do the latter at all, it just tells you to use DBI
> methods for transactions, and there is no DBI method for that.  You can't
> do the first option when AutoCommit is off, because you can't do "begin",
> but if you do the "set transaction" it tells you there is no transaction
> open.  So I have to turn AutoCommit on, open a transaction, then send
> the "set transaction" query.  Then I have to remember, for that particular
> database handle, to put AutoCommit back where it was before after a
> commit or rollback -- which means I have to keep state on each handle I
> have open.
> 
> I do so wish for an AutoCommit mode that tells DBI, "just let me handle
> it, ok thanks".  Pass-through mode.  Get-the-heck-out-of-my-way mode.
> I've honestly considered dropping DBI completely and just using the
> direct C library interface.

If you have AutoCommit on, there *is* a DBI method to explicitly start a
transaction, and you'll go back to normal at the next commit()/rollback():

  $dbh->begin_work;
  $dbh->do('set transaction isolation level serializable');

Or, if AutoCommit is off, you could force a transaction to start, then set
the isolation level:

  $dbh->do('select 1'); # Or an update which doesn't match anything
  $dbh->do('set transaction isolation level serializable');

Or, if you want this isolation level to apply to everything, say so when
you connect:

  $dbh->do("set default_transaction_isolation to 'serializable'");


I haven't tested any of these, since I haven't needed to change the isolation
level since the bad old days of Illustra, when "read uncommitted" was
necessary to even approach reasonable performance on our horrible system.

-- 
        Peter Haworth   [EMAIL PROTECTED]
"I am the Supreme Being, you know. I'm not entirely dim."
        -- God (in Time Bandits)

Reply via email to