1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-30 05:23:50 +03:00

add Db::set_errpfx. closes #272

git-svn-id: file:///svn/tokudb@1654 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
Rich Prohaska
2008-01-14 21:30:00 +00:00
parent 24a344be36
commit 0ac7cfc8e4
2 changed files with 7 additions and 1 deletions

View File

@@ -167,6 +167,10 @@ int Db::associate(DbTxn *txnid, Db *secondary, int (*callback)(Db *secondary, co
return the_Env->maybe_throw_error(ret); return the_Env->maybe_throw_error(ret);
} }
void Db::set_errpfx(const char *errpfx) {
the_Env->set_errpfx(errpfx);
}
void Db::set_error_stream(std::ostream *new_error_stream) { void Db::set_error_stream(std::ostream *new_error_stream) {
the_Env->set_error_stream(new_error_stream); the_Env->set_error_stream(new_error_stream);
} }

View File

@@ -13,13 +13,15 @@ int test_error_stream(const char *dbfile) {
r = creat(dbfile, 0777); assert(r >= 0); close(r); r = creat(dbfile, 0777); assert(r >= 0); close(r);
DbEnv env(DB_CXX_NO_EXCEPTIONS); DbEnv env(DB_CXX_NO_EXCEPTIONS);
env.set_errpfx("my_test_error_stream"); env.set_errpfx("my_env_error_stream");
env.set_error_stream(&std::cerr); env.set_error_stream(&std::cerr);
r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == EINVAL); r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == EINVAL);
Db db(&env, 0); Db db(&env, 0);
db.set_errpfx("my_db_error_stream");
db.set_error_stream(&std::cerr);
r = db.open(0, dbfile, 0, DB_BTREE, DB_CREATE, 0777); assert(r != 0); r = db.open(0, dbfile, 0, DB_BTREE, DB_CREATE, 0777); assert(r != 0);
r = db.close(0); assert(r == 0); r = db.close(0); assert(r == 0);
r = db.close(0); assert(r == EINVAL); r = db.close(0); assert(r == EINVAL);