| 1208 | /* ── Bulk write ─────────────────────────────────────────────────── */ |
| 1209 | |
| 1210 | int cbm_store_begin_bulk(cbm_store_t *s) { |
| 1211 | /* Stay in WAL mode throughout. Switching to MEMORY journal mode would |
| 1212 | * make the database unrecoverable if the process crashes mid-write, |
| 1213 | * because the in-memory rollback journal is lost on crash. |
| 1214 | * WAL mode is crash-safe: uncommitted WAL entries are simply discarded |
| 1215 | * on the next open. Performance is preserved via synchronous=OFF and a |
| 1216 | * larger cache, which are safe with WAL. */ |
| 1217 | int rc = exec_sql(s, "PRAGMA synchronous = OFF;"); |
| 1218 | if (rc != CBM_STORE_OK) { |
| 1219 | return rc; |
| 1220 | } |
| 1221 | return exec_sql(s, "PRAGMA cache_size = -65536;"); /* CBM_SZ_64 MB */ |
| 1222 | } |
| 1223 | |
| 1224 | int cbm_store_end_bulk(cbm_store_t *s) { |
| 1225 | int rc = exec_sql(s, "PRAGMA synchronous = NORMAL;"); |
no test coverage detected