SQLite Forum

Venting about inconvenient limitations, feel free to ignore
Login

Venting about inconvenient limitations, feel free to ignore

(1) By anonymous on 2021-12-06 00:47:36 [link] [source]

Apparently, a single active prepared statement for a simple select from a table in the temp database is enough to make it impossible to switch the main database into or out of WAL mode.

(2) By Simon Slavin (slavin) on 2021-12-06 22:34:28 in reply to 1 [link] [source]

Use either sqlite3_finalize() or sqlite3_reset() once you're done with your statement. Same advice we've always given.

Glad you found your bug.

(3) By anonymous on 2021-12-07 00:12:26 in reply to 2 [link] [source]

Use either sqlite3_finalize() or sqlite3_reset() once you're done with your statement.

Excellent advice, except that the temp table in question contains a list of pragmas to be applied to the main database, one by one.

(Actual solution: accumulate all the pragma statement texts in a string buffer and execute them in a second pass, after sqlite3_reset has been called.)

(4) By Ryan Smith (cuz) on 2021-12-07 00:41:27 in reply to 3 [link] [source]

...except that the temp table in question contains a list of pragmas to be applied to the main database, one by one.

I believe that is a most functional example of what people mean when they say "You can't have your cake and eat it". :)

(5) By Warren Young (wyoung) on 2021-12-07 00:44:29 in reply to 3 [source]

Doesn't that problem go away if you use two SQLite connections, one to the temp DB, one to the main DB?