Prepare a statement (cached). If already prepared, reset+clear. */
| 198 | |
| 199 | /* Prepare a statement (cached). If already prepared, reset+clear. */ |
| 200 | static sqlite3_stmt *prepare_cached(cbm_store_t *s, sqlite3_stmt **slot, const char *sql) { |
| 201 | if (!s || !s->db) { |
| 202 | return NULL; |
| 203 | } |
| 204 | if (*slot) { |
| 205 | sqlite3_reset(*slot); |
| 206 | sqlite3_clear_bindings(*slot); |
| 207 | return *slot; |
| 208 | } |
| 209 | int rc = sqlite3_prepare_v2(s->db, sql, CBM_NOT_FOUND, slot, NULL); |
| 210 | if (rc != SQLITE_OK) { |
| 211 | store_set_error_sqlite(s, "prepare"); |
| 212 | return NULL; |
| 213 | } |
| 214 | return *slot; |
| 215 | } |
| 216 | |
| 217 | /* Get ISO-8601 timestamp. */ |
| 218 | static void iso_now(char *buf, size_t sz) { |
no test coverage detected