summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-08-25 23:57:12 +0200
committerGravatar GitHub2021-08-25 23:57:12 +0200
commit6176de4bbf388f8cdba842762e4f92f94ba151ab (patch)
treebe428a9aa4868c0e967e94fdeca5c9c1ef64ec84 /sqlite.zig
parentMerge pull request #42 from nektro/master (diff)
parentsqlite: expose c import, add 'shared_cache' to init flags (diff)
downloadzig-sqlite-6176de4bbf388f8cdba842762e4f92f94ba151ab.tar.gz
zig-sqlite-6176de4bbf388f8cdba842762e4f92f94ba151ab.tar.xz
zig-sqlite-6176de4bbf388f8cdba842762e4f92f94ba151ab.zip
Merge pull request #43 from lithdew/master
sqlite: expose c import, add 'shared_cache' to init flags
Diffstat (limited to '')
-rw-r--r--sqlite.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/sqlite.zig b/sqlite.zig
index abeea55..e88fb64 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -5,7 +5,7 @@ const io = std.io;
5const mem = std.mem; 5const mem = std.mem;
6const testing = std.testing; 6const testing = std.testing;
7 7
8const c = @cImport({ 8pub const c = @cImport({
9 @cInclude("sqlite3.h"); 9 @cInclude("sqlite3.h");
10}); 10});
11 11
@@ -233,6 +233,12 @@ pub const InitOptions = struct {
233 /// Defaults to Serialized. 233 /// Defaults to Serialized.
234 threading_mode: ThreadingMode = .Serialized, 234 threading_mode: ThreadingMode = .Serialized,
235 235
236 /// shared_cache controls whether or not concurrent SQLite
237 /// connections share the same cache.
238 ///
239 /// Defaults to false.
240 shared_cache: bool = false,
241
236 /// if provided, diags will be populated in case of failures. 242 /// if provided, diags will be populated in case of failures.
237 diags: ?*Diagnostics = null, 243 diags: ?*Diagnostics = null,
238}; 244};
@@ -327,6 +333,9 @@ pub const Db = struct {
327 if (options.open_flags.create) { 333 if (options.open_flags.create) {
328 flags |= c.SQLITE_OPEN_CREATE; 334 flags |= c.SQLITE_OPEN_CREATE;
329 } 335 }
336 if (options.shared_cache) {
337 flags |= c.SQLITE_OPEN_SHAREDCACHE;
338 }
330 switch (options.threading_mode) { 339 switch (options.threading_mode) {
331 .MultiThread => flags |= c.SQLITE_OPEN_NOMUTEX, 340 .MultiThread => flags |= c.SQLITE_OPEN_NOMUTEX,
332 .Serialized => flags |= c.SQLITE_OPEN_FULLMUTEX, 341 .Serialized => flags |= c.SQLITE_OPEN_FULLMUTEX,