| 276 | } |
| 277 | |
| 278 | static struct db_config *db_config_find(const struct db *db, const char *dsn) |
| 279 | { |
| 280 | size_t num_configs; |
| 281 | struct db_config **configs = autodata_get(db_backends, &num_configs); |
| 282 | const char *sep, *driver_name; |
| 283 | sep = strstr(dsn, "://"); |
| 284 | |
| 285 | if (!sep) |
| 286 | db_fatal(db, "%s doesn't look like a valid data-source name (missing \"://\" separator.", dsn); |
| 287 | |
| 288 | driver_name = tal_strndup(tmpctx, dsn, sep - dsn); |
| 289 | |
| 290 | for (size_t i=0; i<num_configs; i++) { |
| 291 | if (streq(driver_name, configs[i]->name)) { |
| 292 | tal_free(driver_name); |
| 293 | return configs[i]; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | tal_free(driver_name); |
| 298 | return NULL; |
| 299 | } |
| 300 | |
| 301 | static struct db_query_set *db_queries_find(const struct db_config *config) |
| 302 | { |