CFLOCK can be an unsung hero in these situations, as long as all of your table manipulation logic is in CF!
Roland -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert Sent: Wednesday, November 03, 2004 8:42 PM To: [EMAIL PROTECTED] Subject: Re: [CFCDev] Validation No, I was totally incorrect. I just got done drawing myself little pictures about how the transactions would work. If you don't rely on the unique key, you have to lock somewhere (CFLOCK or DB-based table locks), as the transaction won't do it. I was getting confused with phantom reads. You're not actually reading the usernames out of the table even though you're checking them, so they won't be locked as part of the transaction. If you selected all usernames and verified uniqueness on that result set (which would be idiotic), then the transaction would do it, assuming SERIALIZABLE isolation. Aside from demonstrating my idiocy, I have made a clear case for always leaving the DB constraints in (as i said earlier) even though you *think* your code doesn't depend on them. ; ) cheers, barneyb On Wed, 3 Nov 2004 17:15:13 -0800, Sean Corfield <[EMAIL PROTECTED]> wrote: > Two threads could ask for the same user name and both pass your > uniqueness test (because the user name is not yet in the database) and > then both store the username -> duplication! > > The only atomic way to do this is on the insert, and use a database > constraint on the username to cause an exception (which you catch and > translate to something useful, i.e., throw a known validation > exception). > > Or am I missing something subtle in your logic? > > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/blog/ I currently have 0 GMail invites for the taking ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
