Skip to content

Commit b631ff1

Browse files
committed
Configure heap limits.
1 parent fdfaaa8 commit b631ff1

File tree

9 files changed

+448
-396
lines changed

9 files changed

+448
-396
lines changed

config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,17 @@ func autoVacuumCallback(ctx context.Context, mod api.Module, pApp, zSchema, nDbP
294294
schema := util.ReadString(mod, zSchema, _MAX_NAME)
295295
return uint32(fn(schema, uint(nDbPage), uint(nFreePage), uint(nBytePerPage)))
296296
}
297+
298+
// SoftHeapLimit imposes a soft limit on heap size.
299+
//
300+
// https://sqlite.org/c3ref/hard_heap_limit64.html
301+
func (c *Conn) SoftHeapLimit(n int64) int64 {
302+
return int64(c.call("sqlite3_soft_heap_limit64", uint64(n)))
303+
}
304+
305+
// SoftHeapLimit imposes a hard limit on heap size.
306+
//
307+
// https://sqlite.org/c3ref/hard_heap_limit64.html
308+
func (c *Conn) HardHeapLimit(n int64) int64 {
309+
return int64(c.call("sqlite3_hard_heap_limit64", uint64(n)))
310+
}

embed/bcw2/bcw2.wasm

222 Bytes
Binary file not shown.

embed/exports.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ sqlite3_finalize
7474
sqlite3_free
7575
sqlite3_get_autocommit
7676
sqlite3_get_auxdata
77+
sqlite3_hard_heap_limit64
7778
sqlite3_interrupt
7879
sqlite3_last_insert_rowid
7980
sqlite3_limit
@@ -100,6 +101,7 @@ sqlite3_rollback_hook_go
100101
sqlite3_set_authorizer_go
101102
sqlite3_set_auxdata_go
102103
sqlite3_set_last_insert_rowid
104+
sqlite3_soft_heap_limit64
103105
sqlite3_step
104106
sqlite3_stmt_busy
105107
sqlite3_stmt_readonly

embed/sqlite3.wasm

212 Bytes
Binary file not shown.

sqlite3/sqlite_opt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#define SQLITE_DQS 0
44
#define SQLITE_THREADSAFE 0
5-
#define SQLITE_DEFAULT_MEMSTATUS 0
65
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1
76
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS
87
#define SQLITE_MAX_EXPR_DEPTH 0
@@ -13,6 +12,7 @@
1312
#define SQLITE_OMIT_AUTOINIT
1413

1514
// We need these:
15+
// #define SQLITE_DEFAULT_MEMSTATUS 0
1616
// #define SQLITE_OMIT_DECLTYPE
1717
// #define SQLITE_OMIT_PROGRESS_CALLBACK
1818

0 commit comments

Comments
 (0)