#2705: [patch] Add optional FOR UPDATE clause to QuerySets ---------------------------------------------------+------------------------ Reporter: Hawkeye | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Accepted | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 1 | ---------------------------------------------------+------------------------ Comment (by anih):
Replying to [comment:41 liangent]: > Replying to [comment:37 anih]: > (note: 1. 'key 1' is the primary key; 2. i'm using mysql: 5.0.67-0ubuntu6) > > i think it has nothing to do with the models. > > as i know, django try to SELECT a row when we're going to .save() to know if the row exists. however, because i used SELECT FOR UPDATE, mysql locked the row, and django cannot find it with SELECT, so django decides to INSERT. since the field 'id' in object 't' has been set and value is assigned to an existing row ('t' was got from a SELECT FOR UPDATE), an IntegrityError is raised. problem is how mysql treats rows select with for update statment: http://www.mysqlperformanceblog.com/2006/08/06/select-lock-in-share-mode- and-for-update/ -- Ticket URL: <http://code.djangoproject.com/ticket/2705#comment:43> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---