I added some code before my call to sqlite3_close recently, like so:

hstmt = NULL;
while (hstmt = sqlite3_next_stmt (db,hstmt)) {
  sql = sqlite3_sql (hstmt);
  if (!sql) sql = "-"
  fprintf (log,"Unfinalized statement handle found on database close for 
[%s]\n",sql);
  sqlite3_finalize (hstmt);
}

This was really just in case code.  And to my surprise, I found that the 9 
statements that rtreeSqlInit (called by rtreeInit called by rtree's xConnect) 
prepares hadn't been finailized.  On the other hand, the statement handle used 
by my own virtual table module (used in the same query) was finalized.  Looking 
at the code, it seems that rtree uses a busy count (set to 1 by xConnect or 
xCreate, incremented by xUpdate and xFilter and decremented by xDisconnect or 
xDestroy), and until it hits 0, the statement handles are not finalized.  When 
I 
traced the behavior in the debugger, I saw the statements get finalized swhen 
qlite3_close was called.  Is this the expected behavior?  I could see it as an 
optimization, although I don't see equivalent logic in the FTS code.

Best regards,

Peter Aronson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to