On 2/2/17, x <tam118...@hotmail.com> wrote: > For a while I got away with this > > sqlite3_stmt *stmt; > > if (sqlite3_prepare16_v2(DB, L”sql statement”, -1, &stmt, NULL) != > SQLITE_OK) > throw exception(“.....”); > > // use stmt > > sqlite3_reset(stmt); > > > if (sqlite3_prepare16_v2(DB, L”different sql statement”, -1, &stmt, > NULL) != SQLITE_OK) > throw exception(“.....”);
This second prepare overwrites the "stmt" pointer with a pointer to a new object. The old statement was never finalized. This results in a statement object leak, which SQLite detects when you try to close the database connection. > > > // use stmt again > > sqlite3_finalize(stmt); > > (I’m using a c++ SQLite wrapper I wrote myself so hopefully I’ve written the > above out correctly). > > Anyway, on the latest attempt at using the above everything worked fine as > before. No error messages, stmt executed fine before and after SQL change > and was finalized without getting an errmsg. This time though I got an error > message when I tried to close the DB (something along the lines of “unable > to close db ... unfinalized stmts or ...”. > > The reused stmt was the only possible culprit so I’m wondering if it’s down > to the changed sql? > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- 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