some more primitive specializations, counting rows, dropping tables, tests

This commit is contained in:
Blue 2022-09-17 15:31:58 +03:00
parent 047f96b54a
commit 2f34fa69e8
Signed by: blue
GPG key ID: 9B203B252A63EE38
22 changed files with 667 additions and 28 deletions

View file

@ -85,7 +85,7 @@ void DataBase::open()
bool DataBase::removeDirectory()
{
if (opened) {
throw Opened(name, "");
throw Opened(name, "remove database directory");
}
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
path += "/" + getName();
@ -108,3 +108,25 @@ bool DataBase::ready() const
return opened;
}
void DataBase::drop()
{
if (!opened) {
throw Closed("drop", name);
}
MDB_txn *txn;
int rc = mdb_txn_begin(environment, NULL, 0, &txn);
if (rc) {
throw Unknown(name, mdb_strerror(rc));
}
for (const std::pair<const std::string, _Table*>& pair : tables) {
rc = pair.second->drop(txn);
if (rc) {
throw Unknown(name, mdb_strerror(rc), pair.first);
}
}
mdb_txn_commit(txn);
}