www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Setting SQLite compile time parameters from etc.c.sqlite3

reply data pulverizer <data.pulverizer gmail.com> writes:
Hello all,

I'm not sure how to set the compile time parameters in D's SQLite 
module particular the items that take multiple parameters, for 
example in the C API manual `SQLITE_CONFIG_MMAP_SIZE` takes two 
`sqlite3_int64`. How do I set these? Do I just write something 
like

```
enum SQLITE_CONFIG_MMAP_SIZE = [10_000_000_000, 30_000_000_000];
```
?

Writing this doesn't cause an error but I don't think it works 
because its supposed to speed up write times and I'm not 
observing any performance change.

Thanks in advance!
Mar 01 2022
next sibling parent data pulverizer <data.pulverizer gmail.com> writes:
On Tuesday, 1 March 2022 at 20:59:46 UTC, data pulverizer wrote:
 Hello all,

 I'm not sure how to set the compile time parameters in D's 
 SQLite module particular the items that take multiple 
 parameters, for example in the C API manual 
 `SQLITE_CONFIG_MMAP_SIZE` takes two `sqlite3_int64`. How do I 
 set these?
Okay it seems like you are supposed to use the function `sqlite3_config` to configure those elements, for example: ``` sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, 10_000_000_000, 30_000_000_000); ```
Mar 01 2022
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Mar 01, 2022 at 08:59:46PM +0000, data pulverizer via
Digitalmars-d-learn wrote:
 Hello all,
 
 I'm not sure how to set the compile time parameters in D's SQLite
 module particular the items that take multiple parameters, for example
 in the C API manual `SQLITE_CONFIG_MMAP_SIZE` takes two
 `sqlite3_int64`. How do I set these?
These are not compile-time parameters. According to SQLite's documentation, they are set at runtime using the sqlite3_config() API, which is a C-style variadic function, so you can just pass however many arguments are needed for that configuration item. I.e.: sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, 10_000_000_000, 30_000_000_000); Since sqlite3_config is not thread-safe (according to the docs), you must initialize it before any threads are started: shared static this() { sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, 10_000_000_000, 30_000_000_000); } T -- When solving a problem, take care that you do not become part of the problem.
Mar 01 2022