| 947 | } |
| 948 | |
| 949 | static struct command_result *default_list_done(struct command *cmd, |
| 950 | const char *method, |
| 951 | const char *buf, |
| 952 | const jsmntok_t *result, |
| 953 | struct db_query *dbq) |
| 954 | { |
| 955 | struct sql *sql = sql_of(cmd->plugin); |
| 956 | struct table_desc *td = dbq->tables[0]; |
| 957 | struct command_result *ret; |
| 958 | int err; |
| 959 | char *errmsg; |
| 960 | |
| 961 | /* FIXME: this is where a wait / pagination API is useful! */ |
| 962 | err = sqlite3_exec(sql->db, tal_fmt(tmpctx, "DELETE FROM %s;", td->name), |
| 963 | NULL, NULL, &errmsg); |
| 964 | if (err != SQLITE_OK) { |
| 965 | return command_fail(cmd, LIGHTNINGD, "cleaning '%s' failed: %s", |
| 966 | td->name, errmsg); |
| 967 | } |
| 968 | |
| 969 | ret = process_json_result(cmd, buf, result, td, false, |
| 970 | &td->last_created_index, &td->last_updated_index, NULL); |
| 971 | if (ret) |
| 972 | return ret; |
| 973 | |
| 974 | return one_refresh_done(cmd, dbq, false); |
| 975 | } |
| 976 | |
| 977 | static struct command_result *default_refresh(struct command *cmd, |
| 978 | struct table_desc *td, |
nothing calls this directly
no test coverage detected