On 7/13/17, Simon Slavin <slav...@bigfraud.org> wrote: > > Can I conclude that if "SELECT sql FROM STMT" returns no rows then closing > the connection should work properly and immediately ? >
You'll probably always get one row of result, which is the query itself. Yes, if you only get that one row, then it is certainly safe to close the connection. However, if you get multiple rows, that does not mean it is unsafe. Those extra entries might be prepared statements that have been cached by extensions (ex: FTS5) that will be released automatically when the connection is closed. The purpose of the STMT virtual table is to help users debug the case where sqlite3_close() returns SQLITE_BUSY. Using the STMT virtual tables, the developers can get a listing of unfinalized prepared statements and quickly see which ones where overlooked. While testing the STMT virtual table, we noticed that the cached prepared statements from FTS5 were using up a lot of lookaside memory. We had never noticed that before, and it is what prompted the SQLITE_PREPARE_PERSISTENT enhancement. So if the STMT table helped us core developers to notice a problem in our own SQLite code, we figured it would be good to publish it to perhaps help others notice subtle problems in their code. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users