mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
ircd::db: Add interface to checksum files per column.
modules/console: Add column params to db check cmd.
This commit is contained in:
parent
ffcc49b9e5
commit
cdfdde3334
3 changed files with 48 additions and 2 deletions
|
@ -70,6 +70,7 @@ namespace ircd::db
|
||||||
void compact(column &, const std::pair<string_view, string_view> &, const int &to_level = -1, const compactor & = {});
|
void compact(column &, const std::pair<string_view, string_view> &, const int &to_level = -1, const compactor & = {});
|
||||||
void compact(column &, const std::pair<int, int> &level = {-1, -1}, const compactor & = {});
|
void compact(column &, const std::pair<int, int> &level = {-1, -1}, const compactor & = {});
|
||||||
void sort(column &, const bool &blocking = false, const bool &now = false);
|
void sort(column &, const bool &blocking = false, const bool &now = false);
|
||||||
|
void check(column &);
|
||||||
void drop(column &); // danger
|
void drop(column &); // danger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
ircd/db.cc
21
ircd/db.cc
|
@ -5960,6 +5960,27 @@ ircd::db::drop(column &column)
|
||||||
drop(c);
|
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
|
void
|
||||||
ircd::db::sort(column &column,
|
ircd::db::sort(column &column,
|
||||||
const bool &blocking,
|
const bool &blocking,
|
||||||
|
|
|
@ -4399,9 +4399,19 @@ bool
|
||||||
console_cmd__db__check(opt &out, const string_view &line)
|
console_cmd__db__check(opt &out, const string_view &line)
|
||||||
try
|
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
|
auto &database
|
||||||
|
@ -4409,6 +4419,20 @@ try
|
||||||
db::database::get(dbname)
|
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);
|
check(database);
|
||||||
out << "Check of " << dbname << " completed without error."
|
out << "Check of " << dbname << " completed without error."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
Loading…
Reference in a new issue