SQLiteCpp icon indicating copy to clipboard operation
SQLiteCpp copied to clipboard

sqlite3_finalize not called if executeStep was not looped

Open IAmWebSA opened this issue 6 years ago • 2 comments

Calling

if( query.executeStep() == true )
{
//use only first result
}

Results on WAL mode not working, since the finalizes is not triggered,

changing it to

while ( query.executeStep() == true )
{
//use only first result
}

makes the WAL mode working again.

BUT shall the query.executeStep() not finalize if it goes out of Function Scope

like

{
       if( query.executeStep() == true )
       {
             //use only first result
       }

}
//Query has to be finalized

IAmWebSA avatar Jan 23 '19 13:01 IAmWebSA

Good catch! Thanks for reporting

Edit: Hmm, in fact the Statement already does finalizing when going out of scope. Not sure anything is missing...

SRombauts avatar Mar 02 '19 23:03 SRombauts

HI,

the problem I saw was if you have the

if( query.executeStep() == true )
{
//use only first result
}

but the SQL query returns multiple rows and you do not loop through them the getColumn() might still have a open references?!? (just an idea)

So if the scope is too large, multiple queries in same scope, I saw this issue.

Using smaller scopes seems to fix it, but maybe the getColumn Pointer copy is the issue? (just thinking about it)

IAmWebSA avatar Mar 04 '19 13:03 IAmWebSA