some more primitive specializations, counting rows, dropping tables, tests
This commit is contained in:
parent
047f96b54a
commit
2f34fa69e8
22 changed files with 667 additions and 28 deletions
24
database.cpp
24
database.cpp
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue