My application makes heavy use of virtual tables to access datastores outside of SQLite, one of them being Faircom CTree ISAM files. Some of these files are partitioned by date so that removing outdated records is accomplished by deleting a whole file instead of single records. This keeps the indices well structured and balanced. Each file is accessible as a separate virtual table in SQLite.
A second virtual table implementation is used to pretend that the collection of CTree virtual tables is a single table. Operations against this parent table are converted into operations against the member tables by running SQL statements against one, some or all the member tables as appropriate. Some operations on the parent table are best implemented by calling methods of the member table, so there is a hidden column that returns the sqlite_vtab pointer. This pointer may also be saved in the context of a higher level virtual table. There is a multithreaded server for running requests that come from the GUI, each thread has its own connection to the SQLite database. Most of the time this works very well. But about once a week the server crashes with a SEGV. Analysing the core dump reveals that the sqlite_vtab structure has been clobbered. What I believe is happening is that one thread does something (i.e. executes a statement) that causes the schema to be reloaded. This moves the virtual table connections to the "disconnect list" of the respective sqlite3 objects. When the next statement is prepared (e.g. the next partition is queried), the xDisconnect method gets called and the stored sqlite3_vtab pointer (the one describing the first member table) is invalidated. Then the freed memory is reused... -------------------------------------------------------------------------- Gunter Hick Software Engineer Scientific Games International GmbH Klitschgasse 2 – 4, A - 1130 Vienna, Austria FN 157284 a, HG Wien Tel: +43 1 80100 0 E-Mail: h...@scigames.at This e-mail is confidential and may well also be legally privileged. If you have received it in error, you are on notice as to its status and accordingly please notify us immediately by reply e-mail and then delete this message from your system. Please do not copy it or use it for any purposes, or disclose its contents to any person as to do so could be a breach of confidence. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users