mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
ircd::db: Implement interface for column dropping.
This commit is contained in:
parent
d02bdfe436
commit
d3e61abe7d
3 changed files with 37 additions and 5 deletions
|
@ -64,6 +64,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 int &level = -1, const compactor & = {});
|
||||
void sort(column &, const bool &blocking = false);
|
||||
void drop(column &); // danger
|
||||
}
|
||||
|
||||
/// Columns add the ability to run multiple LevelDB's in synchrony under the same
|
||||
|
|
27
ircd/db.cc
27
ircd/db.cc
|
@ -1331,14 +1331,32 @@ const noexcept
|
|||
void
|
||||
ircd::db::drop(database::column &c)
|
||||
{
|
||||
const ctx::uninterruptible ui;
|
||||
if(!c.handle)
|
||||
return;
|
||||
|
||||
database &d(c);
|
||||
const std::lock_guard<decltype(write_mutex)> lock{write_mutex};
|
||||
const ctx::uninterruptible::nothrow ui;
|
||||
log::debug
|
||||
{
|
||||
log, "'%s':'%s' @%lu DROPPING COLUMN",
|
||||
name(d),
|
||||
name(c),
|
||||
sequence(d)
|
||||
};
|
||||
|
||||
throw_on_error
|
||||
{
|
||||
c.d->d->DropColumnFamily(c.handle.get())
|
||||
};
|
||||
|
||||
log::notice
|
||||
{
|
||||
log, "'%s':'%s' @%lu DROPPED COLUMN",
|
||||
name(d),
|
||||
name(c),
|
||||
sequence(d)
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -7768,6 +7786,13 @@ ircd::db::files(const column &column)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::drop(column &column)
|
||||
{
|
||||
database::column &c(column);
|
||||
drop(c);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::sort(column &column,
|
||||
const bool &blocking)
|
||||
|
|
|
@ -2635,12 +2635,12 @@ try
|
|||
|
||||
const auto dbname
|
||||
{
|
||||
param.at(0)
|
||||
param.at("dbname")
|
||||
};
|
||||
|
||||
const auto colname
|
||||
{
|
||||
param.at(0)
|
||||
param.at("column")
|
||||
};
|
||||
|
||||
auto &database
|
||||
|
@ -2648,11 +2648,17 @@ try
|
|||
db::database::get(dbname)
|
||||
};
|
||||
|
||||
throw error
|
||||
db::column column
|
||||
{
|
||||
"TODO: please implement."
|
||||
database, colname
|
||||
};
|
||||
|
||||
db::drop(column);
|
||||
|
||||
out << "DROPPED COLUMN " << colname
|
||||
<< " FROM DATABASE " << dbname
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const std::out_of_range &e)
|
||||
|
|
Loading…
Reference in a new issue