nemequ / sqlheavy

Automatically exported from code.google.com/p/sqlheavy
Other
5 stars 4 forks source link

SQLHeavy.Database.execute hangs after catching a CONSTRAINT error #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After recovering from a constraint violation, the next INSERT hangs.

1. Do a INSERT operation that tries to add a value to a UNIQUE field that is 
already present in the table.
2. Catch the SQLHeavy.Error. 
3. Do another INSERT.

Attached is a vala program that reproduces the problem. I compile it with 

  valac sqlheavy-hang.vala --pkg sqlheavy-0.1  --target-glib=2.36

It has a table with a field 'name' that is declared unique. The output of the 
program is:

Adding Steve...
Successfully added friend Steve.
Adding Steve...
Friend Steve already added.
Next call will hang:
Adding Larry...

And there it hangs. Expected behavior is to print "Successfully added friend 
Larry" and then quit. 

I'm running Ubuntu 13.04 and using the sqlheavy 0.1 available in the Ubuntu 
repository (package version 0.1.1-2). Vala is version 0.20 from the Vala Team 
PPA (package version 0.20.1-2~raring2). SQLite Ubuntu version is 
3.7.15.2-1ubuntu1.

Original issue reported on code.google.com by skagedal on 17 Jul 2013 at 5:55

Attachments:

GoogleCodeExporter commented 9 years ago
Here is a patch that fixes the issue.  QueryResult::next does not release the 
locks when there is an exception.

I suppose the problem appears with any exception that occurs during execute.

Don't know if this is your prefered way of doing this, actually I'm a bit 
confused about what the return value of "next" is supposed to be... "true on 
success, false if the query is finished executing", hmm? false on error, I 
suppose? 

Thank you for writing SQLHeavy, very useful!

Regards,
Simon Kågedal Reimer

Original comment by skagedal on 17 Jul 2013 at 7:37

GoogleCodeExporter commented 9 years ago
Hmm, what happened to the attachment? Let's try agian.

Original comment by skagedal on 17 Jul 2013 at 7:38

Attachments:

GoogleCodeExporter commented 9 years ago
Improved patch per feedback from Evan on irc.

Original comment by skagedal on 18 Jul 2013 at 3:14

Attachments: