MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / stmt_cache_requeue_old_entry

Function stmt_cache_requeue_old_entry

db/sql_stmt_cache.c:104–132  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

102 * done running stmt and by add_stmt_table() after it allocates the new entry.
103 */
104int 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
134static void stmt_cache_free_entry(stmt_cache_entry_t *entry)
135{

Callers 3

execute_verify_indexesFunction · 0.85
stmt_cache_add_new_entryFunction · 0.85
stmt_cache_put_intFunction · 0.85

Calls 6

sqlite3_resetFunction · 0.85
hash_findFunction · 0.85
hash_addFunction · 0.85
sqlite3_clear_bindingsFunction · 0.85
listc_atlFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected