|Subject:||prepared statement not finalized in sqlite_st_finish|
Hello, I have an SQLite program that manages about 256 Sqlite databases. Now, I tried to close them with disconnect but that didn't work. I went to the proc filesystem and noticed that the number of file handles was growing! So, I went to the source and found out that sqlite3_close was returning a "5" and the sqlite3.h file noted that it was probably because a prepared handle wasn't being finalized. That rang a bell since I was using prepared statements! So I checked the source and, as far as I could tell, if you use "prepare" and don't fetch all the rows, then the prepared statement isn't finalized in sqlite_st_finish. That rang a bell too since I was bailing out after I found the row I wanted! So I hacked the code a bit and added a DBIc_ACTIVE_on(imp_sth) in the sqlite_st_prepare function. My problems went away. I haven't analyzed the code enough to know if this is a bad thing, somehow... This is the change I made to dbdimp.c (I added only one line): DBIc_ACTIVE_on(imp_sth); DBIc_NUM_PARAMS(imp_sth) = sqlite3_bind_parameter_count(imp_sth->stmt); DBIc_NUM_FIELDS(imp_sth) = sqlite3_column_count(imp_sth->stmt); DBIc_IMPSET_on(imp_sth); I hope you find this useful! I attached my modified dbdimp.c file.
Message body is not shown because it is too large.