Thanks. Now it's clear what's going on.
Thank you for this great piece of code.
Rolf
D. Richard Hipp wrote:
Rolf Schaeuble wrote:
Hello,
I've had a look at pager.c to understand what's going on in there.
While I think I understand most of it, there's one point I don't
understand:
The comment for pager_stmt_playback says:
** (2) In addition to playing back the statement journal, also
** playback all pages of the transaction journal beginning
** at offset pPager->stmtJSize.
I don't understand why it is not enough to just play back the
statement journal but also parts of the normal journal have to be
played back.
For me, the comment implies that changes could be done to the db that
only go into the normal journal, but not into the statement journal.
Otherwise, it should be enough to play back the statement journal,
right?
Now I don't understand which statements don't make it into the
statement journal, even if a statement is active.
I would be grateful I someone could enlighten me.
pPager->stmtJSize is the size of the normal rollback journal when
the statement is started. As new pages are added to the journals, they
are only written to the statement journal if they are already in the
normal journal. If a page is unchanged prior to the start of the
statement (if that page is not previously in the normal journal)
then the page is written to the normal journal only. This saves
a single write of the page and that can significantly enhance
performance.