Am 27.01.2011 08:40, schrieb Henning Basold:
> Hi,
>
> I recently ran into a problem with prepared statements in SQLite3.
>
> I use a prepared statement with long life time because it's very 
> complex and not executed concurrently. But after execution no 
> modifying statements could be executed in that database because it was 
> locked.
>
> After some investigation I found 
> http://www.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked . So 
> sqlite3_reset has to be called on the statement. As the library has no 
> knowledge about the point in time the statement is no longer needed 
> (multi-row sets etc.), I thought something like an explicit reset is 
> needed.
>
> I attached a patch which introduces a reset method on statements. It 
> has a no-op implementation for all backends except SQLite. The patch 
> also contains a test case which does not run without the reset. It 
> leads to the error "SOCIERROR: sqlite3_statement_backend::loadOne: 
> database is locked".
>
> All this is tested on Windows XP and Ubuntu 10.10 with SQLite 3.7.2.
>
> Best Regards
> Henning

Hi,

as there was no response I retry my request for the integration of the 
patch. The main problem I had was explained in my last mail.

But I must admit that my statement "the library has no knowledge about 
the point in time the statement is no longer needed" was made a bit 
fast. Attached is a revised patch. It is an extension of the last. The 
"reset" methods are preserved as the backend really does not know when 
to reset the statement. But a call to it is added to the destructor of 
the "statement" class. So if one uses a prepared statement she is 
encouraged to make a copy of the statement. This is some kind of "guard" 
which can do the reset automatically.

Also a bug was fixed (call on a deleted backend) and "reset" should not 
throw any longer because it is called inside a destructor.

Finally I have updated the docs.

Hopefully this patch gets applied as I can not reuse the prepared 
statement in my application.

Best regards
Henning

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to