Skip to content

Commit

Permalink
libsql-sqlite: Document WAL API extension
Browse files Browse the repository at this point in the history
  • Loading branch information
penberg committed Oct 21, 2024
1 parent bd86b2b commit 22ded5e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libsql-sqlite3/doc/libsql_extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,30 @@ static sqlite3_module helloModule = {
.xPreparedSql = helloPreparedSql,
};
```
## WAL API
API functions:
* `libsql_wal_frame_count` -- Get the number of frames in the WAL.
* `libsql_wal_get_frame` -- Get a frame from the WAL.
* `libsql_wal_insert_begin` -- Begin WAL insertion.
* `libsql_wal_insert_frame` -- Insert a frame into the WAL.
* `libsql_wal_insert_end` -- End WAL insertion.
Example usage:
```c
static void sync_db(sqlite3 *db_primary, sqlite3 *db_backup){
unsigned int max_frame;
libsql_wal_frame_count(db_primary, &max_frame);
libsql_wal_begin_commit(db_backup);
for(int i=1; i<=max_frame; i++){
char frame[4096+24];
libsql_wal_get_frame(db_primary, i, frame, sizeof(frame));
libsql_wal_insert_frame(db_backup, i, frame, sizeof(frame));
}
libsql_wal_end_commit(db_backup);
}
```

0 comments on commit 22ded5e

Please sign in to comment.