Commit 91ee8176 authored by marko's avatar marko

branches/zip: Remove the error code DB_CANNOT_DROP_FOREIGN_INDEX.

It was only set by ha_innobase::prepare_drop_index(), which can return
the appropriate MySQL error code (HA_ERR_DROP_INDEX_FK) directly.

ha_innobase::add_index(): Correct the function comment.

ha_innobase::prepare_drop_index(): Correct the function comment.
Return MySQL error codes directly.

ha_innobase::final_drop_index(): Correct the function comment.
parent dddb6592
...@@ -667,9 +667,6 @@ convert_error_code_to_mysql( ...@@ -667,9 +667,6 @@ convert_error_code_to_mysql(
return(HA_ERR_LOCK_TABLE_FULL); return(HA_ERR_LOCK_TABLE_FULL);
case DB_CANNOT_DROP_FOREIGN_INDEX:
return(HA_ERR_DROP_INDEX_FK);
case DB_PRIMARY_KEY_IS_NULL: case DB_PRIMARY_KEY_IS_NULL:
return(ER_PRIMARY_CANT_HAVE_NULL); return(ER_PRIMARY_CANT_HAVE_NULL);
...@@ -8301,7 +8298,7 @@ innobase_create_temporary_tablename( ...@@ -8301,7 +8298,7 @@ innobase_create_temporary_tablename(
} }
/*********************************************************************** /***********************************************************************
Add a new index to a table */ Create indexes. */
int int
ha_innobase::add_index( ha_innobase::add_index(
...@@ -8591,7 +8588,7 @@ ha_innobase::add_index( ...@@ -8591,7 +8588,7 @@ ha_innobase::add_index(
} }
/*********************************************************************** /***********************************************************************
Drop a index from a table */ Prepare to drop some indexes of a table. */
int int
ha_innobase::prepare_drop_index( ha_innobase::prepare_drop_index(
...@@ -8603,7 +8600,8 @@ ha_innobase::prepare_drop_index( ...@@ -8603,7 +8600,8 @@ ha_innobase::prepare_drop_index(
{ {
trx_t* trx; trx_t* trx;
THD* thd; THD* thd;
ulint error = DB_SUCCESS; int err = 0;
uint n_key;
DBUG_ENTER("ha_innobase::prepare_drop_index"); DBUG_ENTER("ha_innobase::prepare_drop_index");
ut_ad(table && key_num && num_of_keys); ut_ad(table && key_num && num_of_keys);
...@@ -8628,8 +8626,8 @@ ha_innobase::prepare_drop_index( ...@@ -8628,8 +8626,8 @@ ha_innobase::prepare_drop_index(
row_mysql_lock_data_dictionary(trx); row_mysql_lock_data_dictionary(trx);
for (ulint n_key = 0; n_key < num_of_keys; n_key++) { for (n_key = 0; n_key < num_of_keys; n_key++) {
KEY* key; const KEY* key;
dict_index_t* index; dict_index_t* index;
key = table->key_info + key_num[n_key]; key = table->key_info + key_num[n_key];
...@@ -8645,11 +8643,11 @@ ha_innobase::prepare_drop_index( ...@@ -8645,11 +8643,11 @@ ha_innobase::prepare_drop_index(
if (!index) { if (!index) {
sql_print_error("InnoDB could not find key n:o %u " sql_print_error("InnoDB could not find key n:o %u "
"with name %s from dict cache for table %s", "with name %s in dict cache for table %s",
key_num[n_key], key ? key->name : "NULL", key_num[n_key], key ? key->name : "NULL",
prebuilt->table->name); prebuilt->table->name);
error = 1; err = HA_ERR_KEY_NOT_FOUND;
goto func_exit; goto func_exit;
} }
...@@ -8660,7 +8658,7 @@ ha_innobase::prepare_drop_index( ...@@ -8660,7 +8658,7 @@ ha_innobase::prepare_drop_index(
candidate indexes for deletion because when we check for an candidate indexes for deletion because when we check for an
equivalent foreign index we don't want to select an index that is equivalent foreign index we don't want to select an index that is
later deleted. */ later deleted. */
for (ulint n_key = 0; n_key < num_of_keys; n_key++) { for (n_key = 0; n_key < num_of_keys; n_key++) {
KEY* key; KEY* key;
dict_index_t* index; dict_index_t* index;
...@@ -8727,7 +8725,7 @@ ha_innobase::prepare_drop_index( ...@@ -8727,7 +8725,7 @@ ha_innobase::prepare_drop_index(
FILE* ef = dict_foreign_err_file; FILE* ef = dict_foreign_err_file;
error = DB_CANNOT_DROP_FOREIGN_INDEX; err = HA_ERR_DROP_INDEX_FK;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
rewind(ef); rewind(ef);
...@@ -8747,14 +8745,16 @@ ha_innobase::prepare_drop_index( ...@@ -8747,14 +8745,16 @@ ha_innobase::prepare_drop_index(
} }
func_exit: func_exit:
if (error != DB_SUCCESS) { if (err) {
/* Undo our changes since there was some sort of error */ /* Undo our changes since there was some sort of error */
for (ulint i = 0; i < num_of_keys; i++) { for (n_key = 0; n_key < num_of_keys; n_key++) {
KEY* key; const KEY* key;
dict_index_t* index; dict_index_t* index;
key = table->key_info + key_num[i]; key = table->key_info + key_num[n_key];
ut_a(key); if (!key) {
continue;
}
index = dict_table_get_index_on_name_and_min_id( index = dict_table_get_index_on_name_and_min_id(
prebuilt->table, key->name); prebuilt->table, key->name);
...@@ -8767,13 +8767,11 @@ ha_innobase::prepare_drop_index( ...@@ -8767,13 +8767,11 @@ ha_innobase::prepare_drop_index(
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
error = convert_error_code_to_mysql(error, thd); DBUG_RETURN(err);
DBUG_RETURN((int)error);
} }
/*********************************************************************** /***********************************************************************
Finalize a drop index */ Drop the indexes that were passed to a successful prepare_drop_index(). */
int int
ha_innobase::final_drop_index( ha_innobase::final_drop_index(
......
...@@ -66,10 +66,7 @@ Created 5/24/1996 Heikki Tuuri ...@@ -66,10 +66,7 @@ Created 5/24/1996 Heikki Tuuri
preconfigured undo slots, this can preconfigured undo slots, this can
only happen when there are too many only happen when there are too many
concurrent transactions */ concurrent transactions */
#define DB_CANNOT_DROP_FOREIGN_INDEX 48 /* we cannot drop an index because #define DB_PRIMARY_KEY_IS_NULL 48 /* a column in the PRIMARY KEY
it is needed on foreign key
constraint */
#define DB_PRIMARY_KEY_IS_NULL 49 /* a column in the PRIMARY KEY
was found to be NULL */ was found to be NULL */
/* The following are partial failure codes */ /* The following are partial failure codes */
......
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