| 283 | } |
| 284 | |
| 285 | static sqlite3_stmt *prepare_cached(cbm_store_t *s, sqlite3_stmt **slot, const char *sql) { |
| 286 | if (!s || !s->db) { |
| 287 | return NULL; |
| 288 | } |
| 289 | read_batch_renew(s); |
| 290 | if (*slot) { |
| 291 | sqlite3_reset(*slot); |
| 292 | sqlite3_clear_bindings(*slot); |
| 293 | return *slot; |
| 294 | } |
| 295 | int rc = sqlite3_prepare_v2(s->db, sql, CBM_NOT_FOUND, slot, NULL); |
| 296 | if (rc != SQLITE_OK) { |
| 297 | store_set_error_sqlite(s, "prepare"); |
| 298 | return NULL; |
| 299 | } |
| 300 | return *slot; |
| 301 | } |
| 302 | |
| 303 | /* Get ISO-8601 timestamp. */ |
| 304 | static void iso_now(char *buf, size_t sz) { |
no test coverage detected