mirror of
https://github.com/MariaDB/server.git
synced 2025-11-30 05:23:50 +03:00
Add deadlock exception. Addresses #215.
git-svn-id: file:///svn/tokudb@1310 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
@@ -64,13 +64,18 @@ void DbEnv::set_errpfx(const char *errpfx) {
|
|||||||
the_env->set_errpfx(the_env, errpfx);
|
the_env->set_errpfx(the_env, errpfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DbEnv::maybe_throw_error(int err) {
|
int DbEnv::maybe_throw_error(int err) throw (DbException) {
|
||||||
if (err==0) return 0;
|
if (err==0) return 0;
|
||||||
if (do_no_exceptions) return err;
|
if (do_no_exceptions) return err;
|
||||||
|
if (err==DB_LOCK_DEADLOCK) {
|
||||||
|
DbDeadlockException e(this);
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
DbException e(err);
|
DbException e(err);
|
||||||
e.set_env(this);
|
e.set_env(this);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void toku_db_env_err_vararg(const DB_ENV * env, int error, const char *fmt, va_list ap);
|
void toku_db_env_err_vararg(const DB_ENV * env, int error, const char *fmt, va_list ap);
|
||||||
|
|||||||
@@ -41,3 +41,9 @@ void DbException::set_env(DbEnv *new_env)
|
|||||||
{
|
{
|
||||||
the_env = new_env;
|
the_env = new_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DbDeadlockException::DbDeadlockException (DbEnv *env)
|
||||||
|
: DbException(DB_LOCK_DEADLOCK)
|
||||||
|
{
|
||||||
|
this->set_env(env);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,40 @@ class Dbt;
|
|||||||
class DbEnv;
|
class DbEnv;
|
||||||
class DbTxn;
|
class DbTxn;
|
||||||
class Dbc;
|
class Dbc;
|
||||||
|
class DbException;
|
||||||
|
|
||||||
|
class DbException : public std::exception
|
||||||
|
{
|
||||||
|
friend class DbEnv;
|
||||||
|
public:
|
||||||
|
~DbException() throw();
|
||||||
|
DbException(int err);
|
||||||
|
int get_errno() const;
|
||||||
|
const char *what() const throw();
|
||||||
|
DbEnv *get_env() const;
|
||||||
|
void set_env(DbEnv *);
|
||||||
|
private:
|
||||||
|
char *the_what;
|
||||||
|
int the_err;
|
||||||
|
DbEnv *the_env;
|
||||||
|
void FillTheWhat(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
class DbDeadlockException : public DbException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DbDeadlockException(DbEnv*);
|
||||||
|
};
|
||||||
|
|
||||||
|
class DbLockNotGrantedException
|
||||||
|
{
|
||||||
|
};
|
||||||
|
class DbMemoryException
|
||||||
|
{
|
||||||
|
};
|
||||||
|
class DbRunRecoveryException
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
// DBT and Dbt objects are the same pointers. So watch out if you use Dbt to make other classes (e.g., with subclassing).
|
// DBT and Dbt objects are the same pointers. So watch out if you use Dbt to make other classes (e.g., with subclassing).
|
||||||
class Dbt : private DBT
|
class Dbt : private DBT
|
||||||
@@ -107,7 +141,7 @@ class DbEnv {
|
|||||||
DB_ENV *the_env;
|
DB_ENV *the_env;
|
||||||
|
|
||||||
DbEnv(DB_ENV *, u_int32_t /*flags*/);
|
DbEnv(DB_ENV *, u_int32_t /*flags*/);
|
||||||
int maybe_throw_error(int /*err*/);
|
int maybe_throw_error(int /*err*/) throw (DbException);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -133,21 +167,3 @@ class Dbc : protected DBC
|
|||||||
int get(Dbt*, Dbt *, u_int32_t);
|
int get(Dbt*, Dbt *, u_int32_t);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DbException : public std::exception
|
|
||||||
{
|
|
||||||
friend class DbEnv;
|
|
||||||
public:
|
|
||||||
~DbException() throw();
|
|
||||||
DbException(int err);
|
|
||||||
int get_errno() const;
|
|
||||||
const char *what() const throw();
|
|
||||||
DbEnv *get_env() const;
|
|
||||||
private:
|
|
||||||
char *the_what;
|
|
||||||
int the_err;
|
|
||||||
DbEnv *the_env;
|
|
||||||
void FillTheWhat(void);
|
|
||||||
void set_env(DbEnv *);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user