Hello,

I would like more details about the functions sqlite3_backup_*.

I am trying to use them in a very specific use case. I have a database with
real and temporary tables. For a very specific work, I must load (for a 
while)
the real tables only in memory because it must not affect the other users.

For that, I use two sqlite3 handles. The first is on the file, the second is
on a ":memory:" database. Then I copy all tables (main + temp) in the
":memory:" database. I switch the handle then the software continues as
usual. After the work, I must switch on the real sqlite3 handle. But I must
copy the temporary tables from :memory: in the real handle.

I use sqlite3_backup_* because there are many data and it must be fast.


db1 is the file "base.db"
db2 is ":memory:" db

1. base.db has the real tables (main) and the temporary tables (temp)
2. I create a new database with the name ":memory:"
3. I use sqlite3_backup_* in this way :
    sqlite3_backup_init (db2, "main", db1, "main");
    /* blabla */
    sqlite3_backup_init (db2, "temp", db1, "temp");
    /* blabla */
4. I create my triggers, busy handler, etc.. on db2 (like for db1 at the 
beginning).
4. I work with the db2 handle instead of db1 because when the main 
tables are
    changed here it must not affect the other users.
5. When the work is done, I must return to the db1 database. But the changes
    in the temp tables must be kept. The I use:
sqlite3_backup_init (db1, "temp", db2, "temp");

And here.. I've many very strange things.. memory corruptions but not 
always at
the same place and in the code which is not related to sqlite...

I think that the problem is only
sqlite3_backup_init (db1, "temp", db2, "temp");

Because (maybe) the temporary triggers on db1 are now broken... ? I must
drop all temporary things in db1 before sqlite3_backup_init() in the case
where the tables already exist? And what about my queries? I must finalized
them before, and re-prepare.. ?


Thank you for your help and sorry for my bad english.


Regards,

Mathieu Schroeter
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to