2003-10-14 15:33:00 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2004-10-25 14:38:23 +00:00
|
|
|
#include <errno.h>
|
2003-05-26 13:45:00 +00:00
|
|
|
|
2003-05-26 15:09:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2003-10-14 15:33:00 +00:00
|
|
|
#include "db.hh"
|
|
|
|
#include "util.hh"
|
|
|
|
#include "pathlocks.hh"
|
|
|
|
|
2003-05-26 13:45:00 +00:00
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
/* Wrapper class to ensure proper destruction. */
|
|
|
|
class DestroyDbc
|
2003-05-26 13:45:00 +00:00
|
|
|
{
|
2003-07-31 13:47:13 +00:00
|
|
|
Dbc * dbc;
|
2003-05-26 13:45:00 +00:00
|
|
|
public:
|
2003-07-31 13:47:13 +00:00
|
|
|
DestroyDbc(Dbc * _dbc) : dbc(_dbc) { }
|
|
|
|
~DestroyDbc() { dbc->close(); /* close() frees dbc */ }
|
2003-05-26 13:45:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
class DestroyDbEnv
|
|
|
|
{
|
|
|
|
DbEnv * dbenv;
|
|
|
|
public:
|
|
|
|
DestroyDbEnv(DbEnv * _dbenv) : dbenv(_dbenv) { }
|
|
|
|
~DestroyDbEnv() { if (dbenv) { dbenv->close(0); delete dbenv; } }
|
|
|
|
void release() { dbenv = 0; };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
static void rethrow(DbException & e)
|
|
|
|
{
|
|
|
|
throw Error(e.what());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Transaction::Transaction()
|
|
|
|
: txn(0)
|
2003-05-26 13:45:00 +00:00
|
|
|
{
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Transaction::Transaction(Database & db)
|
2005-02-09 14:37:24 +00:00
|
|
|
: txn(0)
|
2003-07-31 13:47:13 +00:00
|
|
|
{
|
2005-02-09 14:37:24 +00:00
|
|
|
begin(db);
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Transaction::~Transaction()
|
|
|
|
{
|
2003-07-31 16:05:35 +00:00
|
|
|
if (txn) abort();
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 14:37:24 +00:00
|
|
|
void Transaction::begin(Database & db)
|
|
|
|
{
|
|
|
|
assert(txn == 0);
|
|
|
|
db.requireEnv();
|
|
|
|
try {
|
|
|
|
db.env->txn_begin(0, &txn, 0);
|
|
|
|
} catch (DbException e) { rethrow(e); }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
void Transaction::commit()
|
|
|
|
{
|
|
|
|
if (!txn) throw Error("commit called on null transaction");
|
2003-07-31 16:05:35 +00:00
|
|
|
debug(format("committing transaction %1%") % (void *) txn);
|
|
|
|
DbTxn * txn2 = txn;
|
2003-07-31 13:47:13 +00:00
|
|
|
txn = 0;
|
2003-07-31 16:05:35 +00:00
|
|
|
try {
|
|
|
|
txn2->commit(0);
|
|
|
|
} catch (DbException e) { rethrow(e); }
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Transaction::abort()
|
2003-07-31 13:47:13 +00:00
|
|
|
{
|
2003-07-31 16:05:35 +00:00
|
|
|
if (!txn) throw Error("abort called on null transaction");
|
|
|
|
debug(format("aborting transaction %1%") % (void *) txn);
|
|
|
|
DbTxn * txn2 = txn;
|
|
|
|
txn = 0;
|
|
|
|
try {
|
|
|
|
txn2->abort();
|
|
|
|
} catch (DbException e) { rethrow(e); }
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
2003-05-26 13:45:00 +00:00
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
|
2003-10-15 12:42:39 +00:00
|
|
|
void Transaction::moveTo(Transaction & t)
|
|
|
|
{
|
|
|
|
if (t.txn) throw Error("target txn already exists");
|
|
|
|
t.txn = txn;
|
|
|
|
txn = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Database::requireEnv()
|
2003-07-31 13:47:13 +00:00
|
|
|
{
|
2004-01-15 20:23:55 +00:00
|
|
|
checkInterrupt();
|
2005-02-09 09:50:29 +00:00
|
|
|
if (!env) throw Error("database environment is not open "
|
2004-10-25 14:38:23 +00:00
|
|
|
"(maybe you don't have sufficient permission?)");
|
2003-07-31 16:05:35 +00:00
|
|
|
}
|
2003-07-31 13:47:13 +00:00
|
|
|
|
2003-05-26 13:45:00 +00:00
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
Db * Database::getDb(TableId table)
|
|
|
|
{
|
2004-10-25 14:38:23 +00:00
|
|
|
if (table == 0)
|
|
|
|
throw Error("database table is not open "
|
|
|
|
"(maybe you don't have sufficient permission?)");
|
2003-07-31 16:05:35 +00:00
|
|
|
map<TableId, Db *>::iterator i = tables.find(table);
|
|
|
|
if (i == tables.end())
|
|
|
|
throw Error("unknown table id");
|
|
|
|
return i->second;
|
2003-05-26 13:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
Database::Database()
|
|
|
|
: env(0)
|
2003-07-31 16:05:35 +00:00
|
|
|
, nextId(1)
|
2003-05-26 13:45:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
Database::~Database()
|
|
|
|
{
|
2003-10-14 15:33:00 +00:00
|
|
|
close();
|
|
|
|
}
|
2003-07-31 16:05:35 +00:00
|
|
|
|
|
|
|
|
2003-10-14 15:33:00 +00:00
|
|
|
int getAccessorCount(int fd)
|
|
|
|
{
|
|
|
|
if (lseek(fd, 0, SEEK_SET) == -1)
|
|
|
|
throw SysError("seeking accessor count");
|
|
|
|
char buf[128];
|
|
|
|
int len;
|
|
|
|
if ((len = read(fd, buf, sizeof(buf) - 1)) == -1)
|
|
|
|
throw SysError("reading accessor count");
|
|
|
|
buf[len] = 0;
|
|
|
|
int count;
|
|
|
|
if (sscanf(buf, "%d", &count) != 1) {
|
|
|
|
debug(format("accessor count is invalid: `%1%'") % buf);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
2003-07-31 16:05:35 +00:00
|
|
|
|
|
|
|
|
2003-10-14 15:33:00 +00:00
|
|
|
void setAccessorCount(int fd, int n)
|
|
|
|
{
|
|
|
|
if (lseek(fd, 0, SEEK_SET) == -1)
|
|
|
|
throw SysError("seeking accessor count");
|
|
|
|
string s = (format("%1%") % n).str();
|
|
|
|
const char * s2 = s.c_str();
|
|
|
|
if (write(fd, s2, strlen(s2)) != (ssize_t) strlen(s2) ||
|
|
|
|
ftruncate(fd, strlen(s2)) != 0)
|
|
|
|
throw SysError("writing accessor count");
|
|
|
|
}
|
2003-07-31 16:05:35 +00:00
|
|
|
|
2003-10-14 15:33:00 +00:00
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
void openEnv(DbEnv * & env, const string & path, u_int32_t flags)
|
2003-10-14 15:33:00 +00:00
|
|
|
{
|
2005-12-09 22:55:07 +00:00
|
|
|
try {
|
|
|
|
env->open(path.c_str(),
|
|
|
|
DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
|
|
|
|
DB_CREATE | flags,
|
|
|
|
0666);
|
|
|
|
} catch (DbException & e) {
|
|
|
|
printMsg(lvlError, format("environment open failed: %1%") % e.what());
|
|
|
|
throw;
|
|
|
|
}
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-21 07:36:01 +00:00
|
|
|
static int my_fsync(int fd)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
static void errorPrinter(const DbEnv * env, const char * errpfx, const char * msg)
|
|
|
|
{
|
|
|
|
printMsg(lvlError, format("Berkeley DB error: %1%") % msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void messagePrinter(const DbEnv * env, const char * msg)
|
|
|
|
{
|
|
|
|
printMsg(lvlError, format("Berkeley DB message: %1%") % msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
void Database::open2(const string & path, bool removeOldEnv)
|
2003-07-31 13:47:13 +00:00
|
|
|
{
|
2003-10-14 15:33:00 +00:00
|
|
|
if (env) throw Error(format("environment already open"));
|
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
debug(format("opening database environment"));
|
|
|
|
|
|
|
|
|
|
|
|
/* Create the database environment object. */
|
2005-12-09 22:55:07 +00:00
|
|
|
DbEnv * env = new DbEnv(0);
|
|
|
|
DestroyDbEnv deleteEnv(env);
|
|
|
|
|
|
|
|
env->set_errcall(errorPrinter);
|
|
|
|
env->set_msgcall(messagePrinter);
|
|
|
|
//env->set_verbose(DB_VERB_REGISTER, 1);
|
|
|
|
env->set_verbose(DB_VERB_RECOVERY, 1);
|
2005-05-09 15:25:47 +00:00
|
|
|
|
|
|
|
/* Smaller log files. */
|
|
|
|
env->set_lg_bsize(32 * 1024); /* default */
|
|
|
|
env->set_lg_max(256 * 1024); /* must be > 4 * lg_bsize */
|
|
|
|
|
|
|
|
/* Write the log, but don't sync. This protects transactions
|
|
|
|
against application crashes, but if the system crashes, some
|
|
|
|
transactions may be undone. An acceptable risk, I think. */
|
|
|
|
env->set_flags(DB_TXN_WRITE_NOSYNC | DB_LOG_AUTOREMOVE, 1);
|
|
|
|
|
|
|
|
/* Increase the locking limits. If you ever get `Dbc::get: Cannot
|
|
|
|
allocate memory' or similar, especially while running
|
|
|
|
`nix-store --verify', just increase the following number, then
|
|
|
|
run db_recover on the database to remove the existing DB
|
|
|
|
environment (since changes only take effect on new
|
|
|
|
environments). */
|
|
|
|
env->set_lk_max_locks(10000);
|
|
|
|
env->set_lk_max_lockers(10000);
|
|
|
|
env->set_lk_max_objects(10000);
|
|
|
|
env->set_lk_detect(DB_LOCK_DEFAULT);
|
|
|
|
|
|
|
|
/* Dangerous, probably, but from the docs it *seems* that BDB
|
|
|
|
shouldn't sync when DB_TXN_WRITE_NOSYNC is used, but it still
|
|
|
|
fsync()s sometimes. */
|
|
|
|
db_env_set_func_fsync(my_fsync);
|
2003-10-14 15:33:00 +00:00
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
if (removeOldEnv) {
|
|
|
|
printMsg(lvlError, "removing old Berkeley DB database environment...");
|
|
|
|
env->remove(path.c_str(), DB_FORCE);
|
|
|
|
return;
|
|
|
|
}
|
2003-10-14 15:33:00 +00:00
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
openEnv(env, path, DB_REGISTER | DB_RECOVER);
|
2003-10-14 15:33:00 +00:00
|
|
|
|
2005-12-09 22:55:07 +00:00
|
|
|
deleteEnv.release();
|
2005-05-09 15:25:47 +00:00
|
|
|
this->env = env;
|
2005-12-09 22:55:07 +00:00
|
|
|
}
|
2003-10-14 15:33:00 +00:00
|
|
|
|
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
void Database::open(const string & path)
|
|
|
|
{
|
|
|
|
try {
|
2003-10-14 15:33:00 +00:00
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
open2(path, false);
|
2004-01-13 12:36:43 +00:00
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
} catch (DbException e) {
|
|
|
|
|
|
|
|
if (e.get_errno() == DB_VERSION_MISMATCH) {
|
|
|
|
/* Remove the environment while we are holding the global
|
2005-12-12 18:24:42 +00:00
|
|
|
lock. If things go wrong there, we bail out.
|
|
|
|
!!! argh, we abolished the global lock :-( */
|
2005-05-09 15:25:47 +00:00
|
|
|
open2(path, true);
|
|
|
|
|
|
|
|
/* Try again. */
|
|
|
|
open2(path, false);
|
2005-12-06 15:00:04 +00:00
|
|
|
|
|
|
|
/* Force a checkpoint, as per the BDB docs. */
|
|
|
|
env->txn_checkpoint(DB_FORCE, 0, 0);
|
2005-05-09 15:25:47 +00:00
|
|
|
}
|
2005-12-09 22:55:07 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
else if (e.get_errno() == DB_RUNRECOVERY) {
|
|
|
|
/* If recovery is needed, do it. */
|
|
|
|
printMsg(lvlError, "running recovery...");
|
|
|
|
open2(path, false, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-05-09 15:25:47 +00:00
|
|
|
else
|
|
|
|
rethrow(e);
|
|
|
|
}
|
2003-10-14 15:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Database::close()
|
|
|
|
{
|
|
|
|
if (!env) return;
|
|
|
|
|
|
|
|
/* Close the database environment. */
|
|
|
|
debug(format("closing database environment"));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (map<TableId, Db *>::iterator i = tables.begin();
|
|
|
|
i != tables.end(); i++)
|
|
|
|
{
|
|
|
|
Db * db = i->second;
|
2003-10-16 08:52:44 +00:00
|
|
|
db->close(DB_NOSYNC);
|
2003-10-14 15:33:00 +00:00
|
|
|
delete db;
|
|
|
|
}
|
|
|
|
|
2004-01-13 13:37:25 +00:00
|
|
|
/* Do a checkpoint every 128 kilobytes, or every 5 minutes. */
|
|
|
|
env->txn_checkpoint(128, 5, 0);
|
|
|
|
|
2003-10-14 15:33:00 +00:00
|
|
|
env->close(0);
|
2003-07-31 14:28:49 +00:00
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
} catch (DbException e) { rethrow(e); }
|
2003-10-14 15:33:00 +00:00
|
|
|
|
|
|
|
delete env;
|
2003-07-31 13:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-12 18:24:42 +00:00
|
|
|
TableId Database::openTable(const string & tableName, bool sorted)
|
2003-05-26 13:45:00 +00:00
|
|
|
{
|
2003-07-31 16:05:35 +00:00
|
|
|
requireEnv();
|
|
|
|
TableId table = nextId++;
|
|
|
|
|
2003-05-26 13:45:00 +00:00
|
|
|
try {
|
2003-07-31 16:05:35 +00:00
|
|
|
|
|
|
|
Db * db = new Db(env, 0);
|
|
|
|
|
|
|
|
try {
|
2003-10-16 08:52:44 +00:00
|
|
|
db->open(0, tableName.c_str(), 0,
|
2005-12-12 18:24:42 +00:00
|
|
|
sorted ? DB_BTREE : DB_HASH,
|
|
|
|
DB_CREATE | DB_AUTO_COMMIT, 0666);
|
2003-07-31 16:05:35 +00:00
|
|
|
} catch (...) {
|
|
|
|
delete db;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
tables[table] = db;
|
|
|
|
|
2003-05-26 13:45:00 +00:00
|
|
|
} catch (DbException e) { rethrow(e); }
|
2003-07-31 16:05:35 +00:00
|
|
|
|
|
|
|
return table;
|
2003-05-26 13:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
bool Database::queryString(const Transaction & txn, TableId table,
|
2003-05-26 13:45:00 +00:00
|
|
|
const string & key, string & data)
|
|
|
|
{
|
2004-01-15 20:23:55 +00:00
|
|
|
checkInterrupt();
|
|
|
|
|
2003-05-26 13:45:00 +00:00
|
|
|
try {
|
2003-07-31 16:05:35 +00:00
|
|
|
Db * db = getDb(table);
|
2003-05-26 13:45:00 +00:00
|
|
|
|
|
|
|
Dbt kt((void *) key.c_str(), key.length());
|
|
|
|
Dbt dt;
|
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
int err = db->get(txn.txn, &kt, &dt, 0);
|
2003-05-26 13:45:00 +00:00
|
|
|
if (err) return false;
|
|
|
|
|
2003-07-16 20:00:51 +00:00
|
|
|
if (!dt.get_data())
|
|
|
|
data = "";
|
|
|
|
else
|
|
|
|
data = string((char *) dt.get_data(), dt.get_size());
|
2003-05-26 13:45:00 +00:00
|
|
|
|
|
|
|
} catch (DbException e) { rethrow(e); }
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
bool Database::queryStrings(const Transaction & txn, TableId table,
|
2003-07-07 09:25:26 +00:00
|
|
|
const string & key, Strings & data)
|
|
|
|
{
|
|
|
|
string d;
|
2003-07-31 13:47:13 +00:00
|
|
|
if (!queryString(txn, table, key, d))
|
2003-07-07 09:25:26 +00:00
|
|
|
return false;
|
2004-06-20 13:37:51 +00:00
|
|
|
data = unpackStrings(d);
|
2003-07-07 09:25:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Database::setString(const Transaction & txn, TableId table,
|
2003-05-26 13:45:00 +00:00
|
|
|
const string & key, const string & data)
|
|
|
|
{
|
2004-01-15 20:23:55 +00:00
|
|
|
checkInterrupt();
|
2003-05-26 13:45:00 +00:00
|
|
|
try {
|
2003-07-31 16:05:35 +00:00
|
|
|
Db * db = getDb(table);
|
2003-05-26 13:45:00 +00:00
|
|
|
Dbt kt((void *) key.c_str(), key.length());
|
|
|
|
Dbt dt((void *) data.c_str(), data.length());
|
2003-07-31 13:47:13 +00:00
|
|
|
db->put(txn.txn, &kt, &dt, 0);
|
2003-05-26 13:45:00 +00:00
|
|
|
} catch (DbException e) { rethrow(e); }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Database::setStrings(const Transaction & txn, TableId table,
|
2004-06-28 10:42:57 +00:00
|
|
|
const string & key, const Strings & data, bool deleteEmpty)
|
2003-07-07 09:25:26 +00:00
|
|
|
{
|
2004-06-28 10:42:57 +00:00
|
|
|
if (deleteEmpty && data.size() == 0)
|
|
|
|
delPair(txn, table, key);
|
|
|
|
else
|
|
|
|
setString(txn, table, key, packStrings(data));
|
2003-07-07 09:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Database::delPair(const Transaction & txn, TableId table,
|
2003-05-26 13:45:00 +00:00
|
|
|
const string & key)
|
|
|
|
{
|
2004-01-15 20:23:55 +00:00
|
|
|
checkInterrupt();
|
2003-05-26 13:45:00 +00:00
|
|
|
try {
|
2003-07-31 16:05:35 +00:00
|
|
|
Db * db = getDb(table);
|
2003-05-26 13:45:00 +00:00
|
|
|
Dbt kt((void *) key.c_str(), key.length());
|
2003-07-31 13:47:13 +00:00
|
|
|
db->del(txn.txn, &kt, 0);
|
2003-10-08 15:06:59 +00:00
|
|
|
/* Non-existence of a pair with the given key is not an
|
|
|
|
error. */
|
2003-05-26 13:45:00 +00:00
|
|
|
} catch (DbException e) { rethrow(e); }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 16:05:35 +00:00
|
|
|
void Database::enumTable(const Transaction & txn, TableId table,
|
2005-12-12 18:24:42 +00:00
|
|
|
Strings & keys, const string & keyPrefix)
|
2003-05-26 13:45:00 +00:00
|
|
|
{
|
|
|
|
try {
|
2003-07-31 16:05:35 +00:00
|
|
|
Db * db = getDb(table);
|
2003-05-26 13:45:00 +00:00
|
|
|
|
2003-07-31 13:47:13 +00:00
|
|
|
Dbc * dbc;
|
2003-07-31 16:05:35 +00:00
|
|
|
db->cursor(txn.txn, &dbc, 0);
|
2003-07-31 13:47:13 +00:00
|
|
|
DestroyDbc destroyDbc(dbc);
|
2003-05-26 13:45:00 +00:00
|
|
|
|
|
|
|
Dbt kt, dt;
|
2005-12-12 18:24:42 +00:00
|
|
|
u_int32_t flags = DB_NEXT;
|
|
|
|
|
|
|
|
if (!keyPrefix.empty()) {
|
|
|
|
flags = DB_SET_RANGE;
|
|
|
|
kt = Dbt((void *) keyPrefix.c_str(), keyPrefix.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
while (dbc->get(&kt, &dt, flags) != DB_NOTFOUND) {
|
2004-01-15 20:23:55 +00:00
|
|
|
checkInterrupt();
|
2005-12-12 18:24:42 +00:00
|
|
|
string data((char *) kt.get_data(), kt.get_size());
|
|
|
|
if (!keyPrefix.empty() &&
|
|
|
|
data.compare(0, keyPrefix.size(), keyPrefix) != 0)
|
|
|
|
break;
|
|
|
|
keys.push_back(data);
|
|
|
|
flags = DB_NEXT;
|
2004-01-15 20:23:55 +00:00
|
|
|
}
|
2003-05-26 13:45:00 +00:00
|
|
|
|
|
|
|
} catch (DbException e) { rethrow(e); }
|
|
|
|
}
|