| 91 | } |
| 92 | |
| 93 | struct 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 */ |
| 121 | struct db_stmt *db_prepare_untranslated(struct db *db, const char *query) |
nothing calls this directly
no test coverage detected