On 11/21/06, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
From: "Jay Savage" <[EMAIL PROTECTED]>
>
> That's not quite how it works. Transactions and table locking are two
> different things. Using transactions won't prevent someone else from
> updating the database or getting a read or write lock. It is still
> possible for the second query to fail. What transactions do, in part,
> is ensure that if the second query fails, the first does, too. And
> that's assuming that SELECT doesn't ignore  BEGIN TRANSACTION, which
> it probably does. Ask the SQLite folks, though, to be sure.

This is not exactly correct. At least not with the higher end
databases. You can add locking hints to the select to ask the server
to lock either the selected rows, the pages they are in or even the
whole table(s) until the end of the transaction. That way noone is
able to modify or delete the selected rows or even other rows in the
table(s) until you commit your transaction. Don't know if SQLite
supports this though.


I think you're confusing a couple of different ideas here.
Transactions ensure that queries grouped as transactions execute
atomically, and if one part fails, you can roll the entire transaction
back.

Locking, on the other hand, keeps other processes from updating--and
in some cases even reading--a tdatabase until you're done with it.
Most databases support locking entire tables; some support row, page,
and even column locking.

The important thing to remember, though, is that locks and
transactions aren't related, although they are often used in
conjunction. You can have transactions that don't lock anything, and
queries that lock tables but aren't grouped into transactions.

If you need a transaction, begin a transaction. If you need a lock,
obtain a lock.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to