diff --git a/include/ircd/db/column.h b/include/ircd/db/column.h index 08e5edf22..d55fb5bd7 100644 --- a/include/ircd/db/column.h +++ b/include/ircd/db/column.h @@ -70,6 +70,7 @@ namespace ircd::db void compact(column &, const std::pair &, const int &to_level = -1, const compactor & = {}); void compact(column &, const std::pair &level = {-1, -1}, const compactor & = {}); void sort(column &, const bool &blocking = false, const bool &now = false); + void check(column &); void drop(column &); // danger } diff --git a/ircd/db.cc b/ircd/db.cc index c6d8f1bb4..07ffe353a 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -5960,6 +5960,27 @@ ircd::db::drop(column &column) drop(c); } +void +ircd::db::check(column &column) +{ + database &d(column); + const auto &files + { + db::files(column) + }; + + for(const auto &file : files) + { + const auto &path + { + // remove false leading slash; the rest is relative to db. + lstrip(file, '/') + }; + + db::check(d, path); + } +} + void ircd::db::sort(column &column, const bool &blocking, diff --git a/modules/console.cc b/modules/console.cc index 43dd562e0..b3a3053d7 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -4399,9 +4399,19 @@ bool console_cmd__db__check(opt &out, const string_view &line) try { - const auto dbname + const params param{line, " ", { - token(line, ' ', 0) + "dbname", "column" + }}; + + const auto &dbname + { + param.at("dbname") + }; + + const auto &colname + { + param["column"] }; auto &database @@ -4409,6 +4419,20 @@ try db::database::get(dbname) }; + if(colname) + { + db::column column + { + database[colname] + }; + + check(column); + out << "Check of " << colname << " in " << dbname << " completed without error." + << std::endl; + + return true; + } + check(database); out << "Check of " << dbname << " completed without error." << std::endl;