Re: updating before insert

"Eric S. Johansson" <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Dennis Lee Bieber wrote:
> On Fri, 10 Aug 2007 07:40:42 -0400, "Eric S. Johansson"
> <[email protected]> declaimed the following in
> gmane.comp.python.db.pysqlite.user:
> 
>> After all of Dijkstra's work with semaphores, one would think that the bright 
>> people that create SQL could have been a little smarter about locking.  This 
>> whole transaction/retries stuff is a tad fuzzy.
>>
> 	It's not really the realm of SQL -- each database engine implements
> its own methods; all that SQL has is the notion of a "transaction"...
> And that a transaction either completes successfully or is rolled-back
> on failure.

I think that's my point.  The whole concept of a transaction is kind of fuzzy. 
Like you say, you either complete successfully (which raises the question how 
can you tell) or you need to roll back.  But if you need to have the transaction 
succeeds, you need to retry repeatedly until you succeed.  Conceptually, it 
would've been easier to have a lock on a record.  But transaction does let 
design requests that have multiple updates or inserts which increases the 
probability of failure and increases the number of retries which means I'm 
feeling very confused about why anyone would do such a thing in the first place. 
  :-)

I could see something like a transaction with retries mechanism for resource 
locks which would let you control access and then do your work, and release but 
anyway, this is one of the things that escapes me with regards to SQL and I'll 
probably always considerate it a bad idea carried forward to the future as I 
wrap all of my SQL transactions with global locks external to SQL so I can 
guarantee I don't have to retry.

to bring it back on topic, how would one implements a generic transaction retry 
until success loop using the current automatic transaction mechanisms?  Can 
these transactions start with a successful select?  Reason I ask is that I have 
some code that I wouldn't want to fail just because there's a record collision.

---eric


-- 
Speech-recognition in use.  It makes mistakes, I correct some.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.