Skip to content

Commit

Permalink
Configure heap limits.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Sep 13, 2024
1 parent fdfaaa8 commit b631ff1
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 396 deletions.
14 changes: 14 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,17 @@ func autoVacuumCallback(ctx context.Context, mod api.Module, pApp, zSchema, nDbP
schema := util.ReadString(mod, zSchema, _MAX_NAME)
return uint32(fn(schema, uint(nDbPage), uint(nFreePage), uint(nBytePerPage)))
}

// SoftHeapLimit imposes a soft limit on heap size.
//
// https://sqlite.org/c3ref/hard_heap_limit64.html
func (c *Conn) SoftHeapLimit(n int64) int64 {
return int64(c.call("sqlite3_soft_heap_limit64", uint64(n)))
}

// SoftHeapLimit imposes a hard limit on heap size.
//
// https://sqlite.org/c3ref/hard_heap_limit64.html
func (c *Conn) HardHeapLimit(n int64) int64 {
return int64(c.call("sqlite3_hard_heap_limit64", uint64(n)))
}
Binary file modified embed/bcw2/bcw2.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions embed/exports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ sqlite3_finalize
sqlite3_free
sqlite3_get_autocommit
sqlite3_get_auxdata
sqlite3_hard_heap_limit64
sqlite3_interrupt
sqlite3_last_insert_rowid
sqlite3_limit
Expand All @@ -100,6 +101,7 @@ sqlite3_rollback_hook_go
sqlite3_set_authorizer_go
sqlite3_set_auxdata_go
sqlite3_set_last_insert_rowid
sqlite3_soft_heap_limit64
sqlite3_step
sqlite3_stmt_busy
sqlite3_stmt_readonly
Expand Down
Binary file modified embed/sqlite3.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion sqlite3/sqlite_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#define SQLITE_DQS 0
#define SQLITE_THREADSAFE 0
#define SQLITE_DEFAULT_MEMSTATUS 0
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS
#define SQLITE_MAX_EXPR_DEPTH 0
Expand All @@ -13,6 +12,7 @@
#define SQLITE_OMIT_AUTOINIT

// We need these:
// #define SQLITE_DEFAULT_MEMSTATUS 0
// #define SQLITE_OMIT_DECLTYPE
// #define SQLITE_OMIT_PROGRESS_CALLBACK

Expand Down
Loading

0 comments on commit b631ff1

Please sign in to comment.