priitj / whitedb

WhiteDB memory database
http://whitedb.org/
GNU General Public License v3.0
608 stars 78 forks source link

DB names #58

Open Rozhdestvenskii opened 3 years ago

Rozhdestvenskii commented 3 years ago

I'm using logged whitedb, creating several databases with names like 111, 112, 211, 212, etc. And found strange thing - if database name started with any number, apart from 1, then there is no journal files created. Also I have feeling that this databases intercects with the ones, who's names started with one.

priitj commented 3 years ago

Hello, thanks for reporting! I was unable to reproduce the bug from command line, how are you creating the database?

(The command parser itself has a bug though, which will be fixed ASAP)

Rozhdestvenskii commented 3 years ago

Hi. I was using code like this:

`#include <whitedb/dbapi.h>

ifdef __cplusplus

extern "C" {

endif

include <whitedb/indexapi.h>

ifdef __cplusplus

}

endif

include

include

class WhiteBDWrapper { public: WhiteBDWrapper(const uint64_t& v1, const uint64_t& v2, const uint64_t& v3) {
m_dbname = std::to_string(v1) + std::to_string(v2) + std::to_string(v3);

    int err = wg_delete_database((char*)m_dbname.c_str());
    m_db = wg_attach_logged_database((char*)m_dbname.c_str(),50*1024*1024);
};

~WhiteBDWrapper() {
    int err = wg_delete_database((char*)m_dbname.c_str());
}

std::string m_dbname;
void* m_db = nullptr;

};

class SomeClass { public: SomeClass(std::unique_ptr db) : dataBase(std::move(db)) { };

std::unique_ptr<WhiteBDWrapper> dataBase;

};

int main(int argc, char **argv) { SomeClass a(std::make_unique(1,1,1)); SomeClass b(std::make_unique(2,1,1)); }`

But now I couldn't repeat this error. I checked in my main project - DB's with names line 312 or 532 created with no problems. May be it was some bug in my code, dunno.