#5043: Postgresql transaction error handling is different
----------------------------------------------+-----------------------------
Reporter:  Nis Jørgensen <[EMAIL PROTECTED]>  |       Owner:  adrian          
  Status:  new                                |   Component:  Database wrapper
 Version:  SVN                                |    Keywords:                  
   Stage:  Unreviewed                         |   Has_patch:  0               
----------------------------------------------+-----------------------------
 (Discussion is happening here): http://groups.google.com/group/django-
 users/browse_thread/thread/8004a40b3c607d08/7b7ed19d276033df
 
 Postgresql does error handling inside transactions differently than mySQL
 and sqlite. When using the latter two, you can do this inside a
 transaction:
 
 
 {{{
 class MyModel(Model):
     uniquefield = CharField(max_length=200,unique=True)
 
 MyModel.objects.create(uniquefield='Some non-unique value')
 try:
     MyModel.objects.create(uniquefield='Some non-unique value')
 except:
     MyModel.objects.create(uniquefield='A unique value')
 }}}
 
 while in postgres the last query will fail as well.
 
 Note that postgresql is by default inside a transaction - ticket #3460 is
 aimed at fixing this.
 
 I believe the solution is to wrap the "execute" method to generate
 savepoints when inside a transaction. Something like  the following
 (untested) pseudocode:
 
 {{{
 def myexecute(self, *args,**kwargs):
     if self.is_in_transaction:
         self.create_save_point(identifier)
         try:
             self.execute(*args,**kwargs)
         except DatabaseError,e:
             self.rollback(identifier)
             raise
     else:
         self.execute(*args,**kwargs)
 
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5043>
Django Code <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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to