Commit 6d3336f1 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1032

fix ha_tokudb::create for windows

git-svn-id: file:///svn/mysql/tokudb-engine/src@6790 c7de825b-a66e-492c-adef-691d508d4ae1
parent 14fdc85f
...@@ -4102,8 +4102,15 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -4102,8 +4102,15 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
TOKUDB_DBUG_ENTER("ha_tokudb::create"); TOKUDB_DBUG_ENTER("ha_tokudb::create");
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
int error; int error;
char dirname[get_name_length(name) + 32]; DB *status_block = NULL;
char newname[get_name_length(name) + 32]; bool dir_path_made = false;
char* dirname = NULL;
char* newname = NULL;
dirname = (char *)my_malloc(get_name_length(name) + 32,MYF(MY_WME));
if (dirname == NULL){ error = ENOMEM; goto cleanup;}
newname = (char *)my_malloc(get_name_length(name) + 32,MYF(MY_WME));
if (newname == NULL){ error = ENOMEM; goto cleanup;}
uint i; uint i;
// //
...@@ -4132,19 +4139,21 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -4132,19 +4139,21 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
make_name(dirname, name, 0); make_name(dirname, name, 0);
error = mkdirpath(dirname, 0777); error = mkdirpath(dirname, 0777);
if (error != 0) { if (error != 0) {
TOKUDB_DBUG_RETURN(errno); error = errno;
goto cleanup;
} }
dir_path_made = true;
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);
/* Create the main table that will hold the real rows */ /* Create the main table that will hold the real rows */
error = create_sub_table(name_buff, NULL, DB_BTREE, 0); error = create_sub_table(name_buff, NULL, DB_BTREE, 0);
if (tokudb_debug & TOKUDB_DEBUG_OPEN) if (tokudb_debug & TOKUDB_DEBUG_OPEN) {
TOKUDB_TRACE("create:%s:error=%d\n", newname, error); TOKUDB_TRACE("create:%s:error=%d\n", newname, error);
}
if (error) { if (error) {
rmall(dirname); goto cleanup;
TOKUDB_DBUG_RETURN(error);
} }
primary_key = form->s->primary_key; primary_key = form->s->primary_key;
...@@ -4157,18 +4166,17 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -4157,18 +4166,17 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
make_name(newname, name, part); make_name(newname, name, part);
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
error = create_sub_table(name_buff, NULL, DB_BTREE, DB_DUP + DB_DUPSORT); error = create_sub_table(name_buff, NULL, DB_BTREE, DB_DUP + DB_DUPSORT);
if (tokudb_debug & TOKUDB_DEBUG_OPEN) if (tokudb_debug & TOKUDB_DEBUG_OPEN) {
TOKUDB_TRACE("create:%s:flags=%ld:error=%d\n", newname, form->key_info[i].flags, error); TOKUDB_TRACE("create:%s:flags=%ld:error=%d\n", newname, form->key_info[i].flags, error);
}
if (error) { if (error) {
rmall(dirname); goto cleanup;
TOKUDB_DBUG_RETURN(error);
} }
} }
} }
/* Create status.tokudb and save relevant metadata */ /* Create status.tokudb and save relevant metadata */
DB *status_block = NULL;
if (!(error = (db_create(&status_block, db_env, 0)))) { if (!(error = (db_create(&status_block, db_env, 0)))) {
make_name(newname, name, "status"); make_name(newname, name, "status");
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
...@@ -4178,24 +4186,26 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -4178,24 +4186,26 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
uint capabilities = HA_TOKU_CAP; uint capabilities = HA_TOKU_CAP;
error = write_metadata(status_block, hatoku_version,&version,sizeof(version)); error = write_metadata(status_block, hatoku_version,&version,sizeof(version));
if (error) { goto quit_status; } if (error) { goto cleanup; }
error = write_metadata(status_block, hatoku_capabilities,&capabilities,sizeof(capabilities)); error = write_metadata(status_block, hatoku_capabilities,&capabilities,sizeof(capabilities));
if (error) { goto quit_status; } if (error) { goto cleanup; }
error = write_auto_inc_create(status_block, create_info->auto_increment_value); error = write_auto_inc_create(status_block, create_info->auto_increment_value);
if (error) { goto quit_status; } if (error) { goto cleanup; }
quit_status:
status_block->close(status_block, 0);
}
if (tokudb_debug & TOKUDB_DEBUG_OPEN) {
TOKUDB_TRACE("create:%s:error=%d\n", newname, error);
} }
} }
if (error) cleanup:
if (status_block != NULL) {
status_block->close(status_block, 0);
}
if (error && dir_path_made) {
rmall(dirname); rmall(dirname);
}
my_free(newname, MYF(MY_ALLOW_ZERO_PTR));
my_free(dirname, MYF(MY_ALLOW_ZERO_PTR));
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
......
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