sqlite/notes/notes1.txt

56 lines
1.6 KiB
Plaintext

unlocked -> read
1. If the journal file exists
A. Open the journal file for exclusive access
i) return SQLITE_BUSY
B. Get a write lock on the database
i) close the journal file
ii) return SQLITE_PROTOCOL_ERROR
C. playback the journal
D. close and delete the journal file
E. drop the write lock on the database
2. Get a read lock on the database file.
A. return SQLITE_BUSY
3. return SQLITE_OK
read -> unlocked
1. Drop the read lock on the database file
2. Invalidate all pages in the cache
3. return SQLITE_OK
read -> write
1. Create the journal file and open for exclusive access
A. return SQLITE_BUSY
2. Drop the read lock on the database
3. Get a write lock on the database
A. Get a read lock on the database
i) return SQLITE_PROTOCOL_ERROR
B. Delete the journal
C. return SQLITE_BUSY
4. return SQLITE_OK
write -> read (commit)
1. Sync the journal
2. Write all dirty pages
A. playback journal
B. Reload or invalidate all pages in cache
3. Sync the database
4. Drop the write lock on the database
5. Get a read lock on the database
A. return SQLITE_PROTOCOL_ERROR
6. Delete the journal
7. return SQLITE_OK
write -> read (rollback)
1. Playback the journal
2. Drop the write lock on the database
3. Get a read lock on the database
A. return SQLITE_PROTOCOL_ERROR
4. Delete the journal
5. Reload or invalidate all pages in cache
6. SQLITE_FULL