Requeue a stmt that was previously removed from the queues by calling * stmt_cache_remove_entry(). Called by put_prepared_stmt_int() after we are * done running stmt and by add_stmt_table() after it allocates the new entry. */
| 102 | * done running stmt and by add_stmt_table() after it allocates the new entry. |
| 103 | */ |
| 104 | int stmt_cache_requeue_old_entry(stmt_cache_t *stmt_cache, stmt_cache_entry_t *entry) |
| 105 | { |
| 106 | int rc = sqlite3_reset(entry->stmt); // reset vdbe when adding to hash tbl |
| 107 | if (rc != SQLITE_OK) { |
| 108 | /* sqlite_step -> sql_tick -> EPIPE -> sqlite_reset returns SQLITE_ABORT */ |
| 109 | return -1; |
| 110 | } |
| 111 | |
| 112 | if (hash_find(stmt_cache->hash, entry->sql) != NULL) { |
| 113 | return -1; // already there, don't add again |
| 114 | } |
| 115 | |
| 116 | if (hash_add(stmt_cache->hash, entry) != 0) { |
| 117 | return -1; |
| 118 | } |
| 119 | |
| 120 | rc = sqlite3_clear_bindings(entry->stmt); |
| 121 | assert(rc == SQLITE_OK); |
| 122 | if (rc != SQLITE_OK) { |
| 123 | logmsg(LOGMSG_ERROR, |
| 124 | "%s:%d sqlite3_clear_bindings(%p) error, rc = %d\n", __func__, |
| 125 | __LINE__, entry->stmt, rc); |
| 126 | } |
| 127 | |
| 128 | void *list = GET_STMT_LIST(stmt_cache, entry->stmt); |
| 129 | listc_atl(list, entry); |
| 130 | |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | static void stmt_cache_free_entry(stmt_cache_entry_t *entry) |
| 135 | { |
no test coverage detected