Add missing pragma statement setting journal_mode on a fresh install.
More context here.
Differential D5292
[native/sqlite] set `journal_mode` on fresh install kamil on Oct 4 2022, 6:11 AM. Authored by Tags None Referenced Files
Details Add missing pragma statement setting journal_mode on a fresh install. More context here.
Diff Detail
Event TimelineComment Actions Questions inline, leaving as a comment so that the diff stays on other reviewers' queues
Comment Actions
I meant everything that happens in the if (current_user_version == 0) { block.
Can you link where it's handled?
Comment Actions According to docs (https://stackoverflow.com/questions/63099657/sqlite-pragma-journal-mode-statement-persistence) this pragma with WAL value is persisted so it is safe to set it only when creating fresh database. Comment Actions
Moved setting journal_mode only to fresh install logic.
One note: I was meaning handed, like pass on/forwarded like any other error thrown in SQLiteQueryExecutor - not handled. In general sqlite_orm performs sync_schema with simple CRUD operations which may throw std::system_error. But to answer, the code we talking about happens in the migrate() function which is called in the constructor of SQLiteQueryExecutor or in the method responsible for deleting the database.
Honestly, I don't feel it's a good idea. ORM will create tables using standard SQLite operations and according to SQLite docs "Any command that accesses the database (basically, any SQL command, except a few PRAGMA statements) will automatically start a transaction if one is not already in effect.". By doing that we will change that default behavior and make everything that sqlite_orm doing into one huge transaction, which will need to be handled separately but thong have a strong opinion what is better. Comment Actions I think we need to understand what's going on here better. It's clear from the discussion in ENG-1910 that our understanding is incomplete, and I'm concerned that we're simply not going deep enough here. I have two questions below. We probably don't need to block landing this diff on them, especially because the original issue is blocking releases. @kamil, maybe you can create a task for each question, and follow-up in the task with the answer?
Can you do a thorough analysis of all callsites please? I think you should be able to do this on your own, and @marcin can correct you if you're wrong :) Can you do a thorough analysis of how sqlite_orm handles sync_schema and whether it creates a transaction for everything within that? The fact that SQLite starts a transaction per query if one isn't already in effect doesn't seem relevant here. Comment Actions
@kamil and I discussed this in our 1:1 today.
Only follow-up on this one is to update sync_schema() to sync_schema(true), which can be done in a separate diff. Meanwhile, the earlier discussion about errors and safety can be continued in ENG-1974. |