Read-only connection holding one read snapshot (BEGIN + a schema read), or * NULL. A writer mid-commit is waited out; a database still locked after the * bound is an error, not an absent override. */
| 503 | * NULL. A writer mid-commit is waited out; a database still locked after the |
| 504 | * bound is an error, not an absent override. */ |
| 505 | static sqlite3 *settings_open_snapshot(const char *path, bool *hot_journal) { |
| 506 | *hot_journal = false; |
| 507 | sqlite3 *db = NULL; |
| 508 | if (sqlite3_open_v2(path, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) { |
| 509 | if (db) |
| 510 | sqlite3_close(db); |
| 511 | return NULL; |
| 512 | } |
| 513 | cbm_runtime_settings_wait_for_writers(db); |
| 514 | if (sqlite3_exec(db, "BEGIN; SELECT count(*) FROM sqlite_master", NULL, NULL, NULL) == |
| 515 | SQLITE_OK) |
| 516 | return db; |
| 517 | *hot_journal = sqlite3_extended_errcode(db) == SQLITE_READONLY_ROLLBACK; |
| 518 | sqlite3_close(db); |
| 519 | return NULL; |
| 520 | } |
| 521 | |
| 522 | static sqlite3 *settings_read_snapshot(const char *path) { |
| 523 | bool hot_journal = false; |
no test coverage detected