ATTACH of in memory database to a database that uses custom VFS doesn't work
I beleive this is a bug in sqlite steps to reproduce:
- create an in memory database (i have used an uri as I need more than one in memory db)
- create any table in this memory db
- DO NOT CLOSE connection to in memory db
- open another connection to in memory db (i have used the same uri)
- make sure "SELECT sql FROM sqlite_master" returns expected create query for your table
- open a disk db via path/uri with a custom VFS (but add SQLITE_OPEN_URI flag or otherwise you won't be able to attach in memory db by uri)
- execute "ATTACH DATABASE '" + uri + "' AS xxx" for disk db connection
- execute "SELECT sql FROM xxx.sqlite_master" using connection to disk database
- both select return the same rows
- vfs parameter provided as part of uri for in-memory db is simply ignored (or SQLITE_MISUSE returned)
- in memory db attached to other db should simply work regardless of what vfs is used on the main db connection
- the second select(on disk db connection) immediatly returns SQLITE_DONE
- the main db's vfs is used for in memory db connection if no explicit vfs provided in uri
workaround - for ATTACH query add vfs parameter to the uri with the default vfs like "ATTACH DATABASE '" + uri + "&vfs=" + sqlite3_vfs_find(nullptr) "' AS xxx"
notes: as far as I can see during debug, if no explicit vfs is provided then sqlite assign to the attached db the same vfs as the main db uses. Then I didn't see any callbacks to the vfs regard in memory db (that is expected it is memory db after all). If the vfs for the in memory db is not the same as default vfs then no schema read from in memory db (didn't debug deeper why it happend). I just stoped debugging when I found workable workaround.
Ah, and there is a documentation bug, there is not specified in documnetation that if you want to attach a db via uri you have to open the main db with SQLITE_OPEN_URI bit set otherewise you will have SQLITE_MISUSE on attempt to attach a db via uri.