Thanks for the replies. I’ve amended the wrapper to finalize the stmt before any change to sql. Only required a one word change.
From: Richard Hipp<mailto:[email protected]> Sent: 02 February 2017 12:27 To: SQLite mailing list<mailto:[email protected]> Subject: Re: [sqlite] Can stmt SQL be changed? On 2/2/17, x <[email protected]> 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 > [email protected] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

