Commit 01921df6 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

more changes to get the storage engine working without transactions. addresses #460

git-svn-id: file:///svn/mysql/tokudb-engine/src@3526 c7de825b-a66e-492c-adef-691d508d4ae1
parent a7d40ecb
...@@ -452,6 +452,7 @@ bool tokudb_flush_logs(handlerton * hton) { ...@@ -452,6 +452,7 @@ bool tokudb_flush_logs(handlerton * hton) {
TOKUDB_DBUG_ENTER("tokudb_flush_logs"); TOKUDB_DBUG_ENTER("tokudb_flush_logs");
int error; int error;
bool result = 0; bool result = 0;
if (tokudb_init_flags & DB_INIT_LOG) {
if ((error = db_env->log_flush(db_env, 0))) { if ((error = db_env->log_flush(db_env, 0))) {
my_error(ER_ERROR_DURING_FLUSH_LOGS, MYF(0), error); my_error(ER_ERROR_DURING_FLUSH_LOGS, MYF(0), error);
result = 1; result = 1;
...@@ -460,6 +461,7 @@ bool tokudb_flush_logs(handlerton * hton) { ...@@ -460,6 +461,7 @@ bool tokudb_flush_logs(handlerton * hton) {
my_error(ER_ERROR_DURING_CHECKPOINT, MYF(0), error); my_error(ER_ERROR_DURING_CHECKPOINT, MYF(0), error);
result = 1; result = 1;
} }
}
TOKUDB_DBUG_RETURN(result); TOKUDB_DBUG_RETURN(result);
} }
...@@ -941,6 +943,9 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -941,6 +943,9 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
uint max_key_length; uint max_key_length;
int error; int error;
if (tokudb_init_flags & DB_INIT_TXN)
open_flags += DB_AUTO_COMMIT;
/* Open primary key */ /* Open primary key */
hidden_primary_key = 0; hidden_primary_key = 0;
if ((primary_key = table_share->primary_key) >= MAX_KEY) { if ((primary_key = table_share->primary_key) >= MAX_KEY) {
...@@ -1015,7 +1020,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1015,7 +1020,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
char newname[strlen(name) + 32]; char newname[strlen(name) + 32];
make_name(newname, name, "main"); make_name(newname, name, "main");
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
if ((error = file->open(file, 0, name_buff, NULL, DB_BTREE, open_flags + DB_AUTO_COMMIT, 0))) { if ((error = file->open(file, 0, name_buff, NULL, DB_BTREE, open_flags, 0))) {
free_share(share, table, hidden_primary_key, 1); free_share(share, table, hidden_primary_key, 1);
my_free((char *) rec_buff, MYF(0)); my_free((char *) rec_buff, MYF(0));
my_free(alloc_ptr, MYF(0)); my_free(alloc_ptr, MYF(0));
...@@ -1062,7 +1067,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1062,7 +1067,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
(*ptr)->api_internal = file->app_private; (*ptr)->api_internal = file->app_private;
(*ptr)->set_dup_compare(*ptr, hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_primary_key); (*ptr)->set_dup_compare(*ptr, hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_primary_key);
} }
if ((error = (*ptr)->open(*ptr, 0, name_buff, NULL, DB_BTREE, open_flags + DB_AUTO_COMMIT, 0))) { if ((error = (*ptr)->open(*ptr, 0, name_buff, NULL, DB_BTREE, open_flags, 0))) {
__close(1); __close(1);
my_errno = error; my_errno = error;
TOKUDB_DBUG_RETURN(1); TOKUDB_DBUG_RETURN(1);
...@@ -1337,7 +1342,7 @@ DBT *ha_tokudb::pack_key(DBT * key, uint keynr, uchar * buff, const uchar * key_ ...@@ -1337,7 +1342,7 @@ DBT *ha_tokudb::pack_key(DBT * key, uint keynr, uchar * buff, const uchar * key_
int ha_tokudb::read_last() { int ha_tokudb::read_last() {
int do_commit = 0; int do_commit = 0;
if (transaction == NULL) { if (transaction == NULL && (tokudb_init_flags & DB_INIT_TXN)) {
int r = db_env->txn_begin(db_env, 0, &transaction, 0); int r = db_env->txn_begin(db_env, 0, &transaction, 0);
assert(r == 0); assert(r == 0);
do_commit = 1; do_commit = 1;
...@@ -1401,7 +1406,9 @@ void ha_tokudb::get_status() { ...@@ -1401,7 +1406,9 @@ void ha_tokudb::get_status() {
if (!(share->status & STATUS_ROW_COUNT_INIT) && share->status_block) { if (!(share->status & STATUS_ROW_COUNT_INIT) && share->status_block) {
share->org_rows = share->rows = table_share->max_rows ? table_share->max_rows : HA_TOKUDB_MAX_ROWS; share->org_rows = share->rows = table_share->max_rows ? table_share->max_rows : HA_TOKUDB_MAX_ROWS;
DB_TXN *transaction = NULL; DB_TXN *transaction = NULL;
int r = db_env->txn_begin(db_env, 0, &transaction, 0); int r = 0;
if (tokudb_init_flags & DB_INIT_TXN)
r = db_env->txn_begin(db_env, 0, &transaction, 0);
if (r == 0) { if (r == 0) {
r = share->status_block->cursor(share->status_block, transaction, &cursor, 0); r = share->status_block->cursor(share->status_block, transaction, &cursor, 0);
if (r == 0) { if (r == 0) {
...@@ -1424,7 +1431,9 @@ void ha_tokudb::get_status() { ...@@ -1424,7 +1431,9 @@ void ha_tokudb::get_status() {
} }
cursor->c_close(cursor); cursor->c_close(cursor);
} }
if (transaction) {
r = transaction->commit(transaction, 0); r = transaction->commit(transaction, 0);
}
transaction = NULL; transaction = NULL;
} }
cursor = NULL; cursor = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment