mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::db: Fix valid condition bugs and minor cleanup.
This commit is contained in:
parent
4013c301e5
commit
0ca1ebba61
3 changed files with 12 additions and 5 deletions
|
@ -49,7 +49,7 @@ namespace ircd::db
|
|||
}
|
||||
|
||||
struct ircd::db::database
|
||||
:std::enable_shared_from_this<struct database>
|
||||
:std::enable_shared_from_this<database>
|
||||
{
|
||||
struct descriptor;
|
||||
struct options;
|
||||
|
@ -60,7 +60,7 @@ struct ircd::db::database
|
|||
struct snapshot;
|
||||
struct comparator;
|
||||
struct column;
|
||||
using description = std::initializer_list<struct descriptor>;
|
||||
using description = std::initializer_list<descriptor>;
|
||||
|
||||
// central collection of open databases for iteration (non-owning)
|
||||
static std::map<string_view, database *> dbs;
|
||||
|
@ -113,7 +113,6 @@ namespace ircd::db
|
|||
std::shared_ptr<const database::column> shared_from(const database::column &);
|
||||
std::shared_ptr<database::column> shared_from(database::column &);
|
||||
const std::string &name(const database::column &);
|
||||
uint64_t sequence(const database::snapshot &); // Sequence of a snapshot
|
||||
uint32_t id(const database::column &);
|
||||
void drop(database::column &); // Request to erase column from db
|
||||
}
|
||||
|
@ -188,4 +187,6 @@ struct ircd::db::database::snapshot
|
|||
explicit snapshot(database &);
|
||||
snapshot() = default;
|
||||
~snapshot() noexcept;
|
||||
|
||||
friend uint64_t sequence(const snapshot &); // Sequence of a snapshot
|
||||
};
|
||||
|
|
|
@ -38,6 +38,9 @@ namespace ircd::db
|
|||
// will all return the same index value across the whole `row`. To get the names
|
||||
// of the columns themselves to build ex. the key name of a JSON key-value pair,
|
||||
// use `cell::col()`, which will be different for each `cell` across the `row`.
|
||||
//
|
||||
// The db::row::iterator iterates over the cells in a row; to iterate over
|
||||
// multiple rows use the db::cursor
|
||||
struct ircd::db::row
|
||||
{
|
||||
struct delta;
|
||||
|
|
|
@ -1397,7 +1397,7 @@ ircd::db::cell::compare_exchange(string_view &expected,
|
|||
ircd::db::cell &
|
||||
ircd::db::cell::operator=(const string_view &s)
|
||||
{
|
||||
write(c, index, s);
|
||||
write(c, key(), s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -1458,7 +1458,7 @@ bool
|
|||
ircd::db::cell::valid()
|
||||
const
|
||||
{
|
||||
return it && valid_equal(*it, index);
|
||||
return it && (index.empty() || valid_equal(*it, index));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2935,4 +2935,7 @@ ircd::db::value_required(const op &op)
|
|||
case op::SINGLE_DELETE:
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue