walCheckpoint

Executes a WAL (Write-Ahead Log) checkpoint operation.

A checkpoint is the process of transferring content from the WAL file back into the main database file. This pragma is only effective when the database is in WAL mode (journalMode = WAL).

The behavior of the checkpoint can be controlled by the optional checkpoint mode:

  • WALCheckpoint.PASSIVE: (Default) Checkpoints as much as possible without blocking any other database connections. It will not wait for any existing transactions to complete.

  • WALCheckpoint.FULL: Waits for all other connections to finish their read transactions before running the checkpoint. This ensures the entire WAL is checkpointed but can block other connections.

  • WALCheckpoint.RESTART: Similar to FULL, but it also ensures that the WAL is reset to zero bytes after the checkpoint completes, which can reduce the WAL file size.

  • WALCheckpoint.TRUNCATE: Similar to RESTART, but it truncates the WAL file to zero bytes after the checkpoint, which is a more aggressive reset.

The pragma returns a cursor with a single row containing three integer columns:

  • busy: 1 if the checkpoint was blocked by another connection, 0 otherwise.

  • log: The total number of frames in the WAL file.

  • checkpointed: The number of frames that were successfully moved from the WAL to the database.

Return

A KQLiteCursor containing the status of the checkpoint operation.

Author

MOHAMMAD AZIM ANSARI

Parameters

checkpoint

The checkpoint mode to use. If null (the default), a PASSIVE checkpoint is performed.