Test SQLITE_NOMEM result code on Linux (Memory : 8Gb)
Is there any way to test SQLITE_NOMEM result code on the following interfaces : 1. sqlite_open(:memory:) 2. sqlite_prepare_v2
I am using it in a library and have to simulate for test purpose.
Also please provide any pointers on how to use sqlite_test_control for limiting memory and fault injections.
Sqlite Version : 3.22
You can register your own memory allocator using the [sqlite3_config(SQLITE_CONFIG_MALLOC, ...)1 interface. This is what the various SQLite test harnesses do. Normally calls to the custom malloc fall through into system malloc, but it is possible to inject faults. There is an example of doing this in the CLI source code.
You might also set the PRAGMA hard_heap_limit to some small value in one connection, and then open a separate connection. The hard_heap_limit applies to the entire process, not to individual connections.