Commit a26ce129 authored by Rich Prohaska's avatar Rich Prohaska

fix the mysqld crash when a create index fails. closes #334

git-svn-id: file:///svn/mysql/tokudb-engine-test2/src@2100 c7de825b-a66e-492c-adef-691d508d4ae1
parent d5802f4b
...@@ -701,8 +701,7 @@ tokudb_cmp_packed_key(DB *file, const DBT *new_key, const DBT *saved_key) ...@@ -701,8 +701,7 @@ tokudb_cmp_packed_key(DB *file, const DBT *new_key, const DBT *saved_key)
if (!*new_key_ptr++) if (!*new_key_ptr++)
continue; continue;
} }
if (key->table->insert_or_update != 1) if (0) printf("%s:%d:insert_or_update=%d\n", __FILE__, __LINE__, key->table->insert_or_update);
printf("%s:%d:insert_or_update=%d\n", key->table->insert_or_update);
if ((cmp= key_part->field->pack_cmp(new_key_ptr,saved_key_ptr, if ((cmp= key_part->field->pack_cmp(new_key_ptr,saved_key_ptr,
key_part->length, key_part->length,
key->table->insert_or_update))) key->table->insert_or_update)))
...@@ -857,7 +856,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) ...@@ -857,7 +856,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked)
{ {
if ((error=db_create(ptr, db_env, 0))) if ((error=db_create(ptr, db_env, 0)))
{ {
close(); __close(1);
my_errno=error; my_errno=error;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -867,8 +866,8 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) ...@@ -867,8 +866,8 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked)
(*ptr)->app_private= (void*) (table->key_info+i); (*ptr)->app_private= (void*) (table->key_info+i);
if (!(table->key_info[i].flags & HA_NOSAME)) if (!(table->key_info[i].flags & HA_NOSAME))
{ {
DBUG_PRINT("info",("Setting DB_DUP for key %u", i)); DBUG_PRINT("info",("Setting DB_DUP+DB_DUPSORT for key %u", i));
(*ptr)->set_flags(*ptr, DB_DUP); (*ptr)->set_flags(*ptr, DB_DUP+DB_DUPSORT);
} }
if ((error= db_env->txn_begin(db_env, NULL, (DB_TXN**) &transaction, if ((error= db_env->txn_begin(db_env, NULL, (DB_TXN**) &transaction,
0)) || 0)) ||
...@@ -876,7 +875,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) ...@@ -876,7 +875,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked)
open_mode, 0))) || open_mode, 0))) ||
(error= transaction->commit(transaction, 0))) (error= transaction->commit(transaction, 0)))
{ {
close(); __close(1);
my_errno=error; my_errno=error;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -917,6 +916,12 @@ int ha_tokudb::close(void) ...@@ -917,6 +916,12 @@ int ha_tokudb::close(void)
{ {
DBUG_ENTER("ha_tokudb::close"); DBUG_ENTER("ha_tokudb::close");
TOKUDB_CLOSE(); TOKUDB_CLOSE();
DBUG_RETURN(__close(0));
}
int ha_tokudb::__close(int mutex_is_locked)
{
DBUG_ENTER("ha_tokudb::__close");
printf("%s:%d:close:%p\n", __FILE__, __LINE__, this); printf("%s:%d:close:%p\n", __FILE__, __LINE__, this);
if (file->app_private == table->key_info + table_share->primary_key) { if (file->app_private == table->key_info + table_share->primary_key) {
printf("%s:%d:reset app_private\n", __FILE__, __LINE__); printf("%s:%d:reset app_private\n", __FILE__, __LINE__);
...@@ -925,7 +930,7 @@ int ha_tokudb::close(void) ...@@ -925,7 +930,7 @@ int ha_tokudb::close(void)
my_free(rec_buff,MYF(MY_ALLOW_ZERO_PTR)); my_free(rec_buff,MYF(MY_ALLOW_ZERO_PTR));
my_free(alloc_ptr,MYF(MY_ALLOW_ZERO_PTR)); my_free(alloc_ptr,MYF(MY_ALLOW_ZERO_PTR));
ha_tokudb::reset(); // current_row buffer ha_tokudb::reset(); // current_row buffer
DBUG_RETURN(free_share(share,table, hidden_primary_key,0)); DBUG_RETURN(free_share(share, table, hidden_primary_key, mutex_is_locked));
} }
/* Reallocate buffer if needed */ /* Reallocate buffer if needed */
...@@ -2403,7 +2408,7 @@ static int create_sub_table(const char *table_name, const char *sub_name, ...@@ -2403,7 +2408,7 @@ static int create_sub_table(const char *table_name, const char *sub_name,
} }
else else
{ {
DBUG_PRINT("error",("Got error: %d when creting table",error)); DBUG_PRINT("error",("Got error: %d when creating table",error));
} }
if (error) if (error)
my_errno=error; my_errno=error;
...@@ -2435,7 +2440,7 @@ int ha_tokudb::create(const char *name, TABLE *form, ...@@ -2435,7 +2440,7 @@ int ha_tokudb::create(const char *name, TABLE *form,
sprintf(part,"key%02d",index++); sprintf(part,"key%02d",index++);
if ((error= create_sub_table(name_buff, part, DB_BTREE, if ((error= create_sub_table(name_buff, part, DB_BTREE,
(form->key_info[i].flags & HA_NOSAME) ? 0 : (form->key_info[i].flags & HA_NOSAME) ? 0 :
DB_DUP))) DB_DUP+DB_DUPSORT)))
DBUG_RETURN(error); DBUG_RETURN(error);
} }
} }
......
...@@ -146,6 +146,8 @@ public: ...@@ -146,6 +146,8 @@ public:
int cmp_ref(const uchar *ref1, const uchar *ref2); int cmp_ref(const uchar *ref1, const uchar *ref2);
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
private:
int __close(int mutex_is_locked);
}; };
#ifdef UNDEF #ifdef UNDEF
......
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