diff options
| author | 2021-08-25 23:57:12 +0200 | |
|---|---|---|
| committer | 2021-08-25 23:57:12 +0200 | |
| commit | 6176de4bbf388f8cdba842762e4f92f94ba151ab (patch) | |
| tree | be428a9aa4868c0e967e94fdeca5c9c1ef64ec84 | |
| parent | Merge pull request #42 from nektro/master (diff) | |
| parent | sqlite: expose c import, add 'shared_cache' to init flags (diff) | |
| download | zig-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.zig | 11 |
1 files changed, 10 insertions, 1 deletions
| @@ -5,7 +5,7 @@ const io = std.io; | |||
| 5 | const mem = std.mem; | 5 | const mem = std.mem; |
| 6 | const testing = std.testing; | 6 | const testing = std.testing; |
| 7 | 7 | ||
| 8 | const c = @cImport({ | 8 | pub 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, |