New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying storage_t causes all subsequent operations to fail with "no such table" SQL logic error #517
Comments
It is ok until you specify empty storage path. Empty storage path tells SQLite that you want a memory database. Memory database drops all data on destruction and shares data with no one. Try to specify real file path (doesn't matter existing or not) and it will work. This is not a but cause SQLite3 works this way. |
If you need to copy data from one database to another (you actually have two databases in your case) please use backup API created for it: |
@mrkline is the issue actual? |
closing due to inactivity |
Sorry for the delay.
The concern is with the semantics here - if I understand that a memory database is a special case, but it still seems like surprising behavior. |
No, copy ctor makes a copy of sqlite3 db handle. Different in-memory handles mean different databases. It is documented in SQLite docs so disabling it in |
Consider the following snippet:
If the code is built with
-DCOPIED
(i.e., the storage object is moved or copied out ofopenAndSync()
, the insert (and any other operations) fail with:Interestingly, if
sync_schema()
is called on the returned copy, everything works again - it's as if copying the storage object forgets that it was synchronized.This behavior seems new to v1.4 and v1.5; 1.3 works fine when built either way.
If we're not meant to copy
storage_t
, its copy constructor should be disabled.The text was updated successfully, but these errors were encountered: