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

Function db_prepare_v2_

db/utils.c:93–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

db_fatalFunction · 0.85
db_prepare_coreFunction · 0.85
hash_djb2Function · 0.70

Tested by

no test coverage detected