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

Function init_indices

plugins/sql.c:532–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532static void init_indices(struct plugin *plugin, const struct table_desc *td)
533{
534 struct sql *sql = sql_of(plugin);
535
536 for (size_t i = 0; i < ARRAY_SIZE(indices); i++) {
537 char *errmsg, *cmd;
538 int err;
539
540 if (!streq(indices[i].tablename, td->name))
541 continue;
542
543 cmd = tal_fmt(tmpctx, "CREATE INDEX %s_%zu_idx ON %s (%s",
544 indices[i].tablename, i,
545 indices[i].tablename,
546 indices[i].fields[0]);
547 if (indices[i].fields[1])
548 tal_append_fmt(&cmd, ", %s", indices[i].fields[1]);
549 tal_append_fmt(&cmd, ");");
550 err = sqlite3_exec(sql->db, cmd, NULL, NULL, &errmsg);
551 if (err != SQLITE_OK)
552 plugin_err(plugin, "Failed '%s': %s", cmd, errmsg);
553 }
554}
555
556/* Recursion */
557static struct command_result *refresh_tables(struct command *cmd,

Callers 1

one_refresh_doneFunction · 0.85

Calls 3

sql_ofFunction · 0.85
tal_append_fmtFunction · 0.85
plugin_errFunction · 0.70

Tested by

no test coverage detected