MCPcopy Create free account
hub / github.com/ElementsProject/lightning / db_prepare_v2_

Function db_prepare_v2_

db/utils.c:92–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92struct db_stmt *db_prepare_v2_(const char *location, struct db *db,
93 const char *query_id)
94{
95 size_t pos;
96
97 /* Normalize query_id paths, because unit tests are compiled with this
98 * prefix. */
99 if (strncmp(query_id, "./", 2) == 0)
100 query_id += 2;
101
102 if (!db->in_transaction)
103 db_fatal("Attempting to prepare a db_stmt outside of a "
104 "transaction: %s", location);
105
106 /* Look up the query by its ID */
107 pos = hash_djb2(query_id) % db->queries->query_table_size;
108 for (;;) {
109 if (!db->queries->query_table[pos].name)
110 db_fatal("Could not resolve query %s", query_id);
111 if (streq(query_id, db->queries->query_table[pos].name))
112 break;
113 pos = (pos + 1) % db->queries->query_table_size;
114 }
115
116 return db_prepare_core(db, location, &db->queries->query_table[pos]);
117}
118
119/* Provides replication and hook interface for raw SQL too */
120struct db_stmt *db_prepare_untranslated(struct db *db, const char *query)

Callers

nothing calls this directly

Calls 3

db_prepare_coreFunction · 0.85
hash_djb2Function · 0.70
db_fatalFunction · 0.50

Tested by

no test coverage detected