summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2011-08-23 15:13:17 +0200
committerMattias Jonsson <mattias.jonsson@oracle.com>2011-08-23 15:13:17 +0200
commit0fca2269425df6a1e2224bb3185a76d3a2608fbf (patch)
tree6daacdb9bfada33232e37ad4631034daad35fc5d /sql/ha_partition.cc
parent58cf757f0b28108884fd0c9f641ba31296dc6c45 (diff)
downloadmariadb-git-0fca2269425df6a1e2224bb3185a76d3a2608fbf.tar.gz
Bug#11766879/Bug#60106: DIFF BETWEEN # OF INDEXES IN MYSQL VS INNODB,
PARTITONING, ON INDEX CREATE If the first partition succeeded in adding a index, but a successive partition failed, then the first partition had still the new index. The fix reverts the added indexes from previous partitions on failure.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index cd5d7f201a7..7c7cf5a4302 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -6490,7 +6490,25 @@ int ha_partition::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys)
*/
for (file= m_file; *file; file++)
if ((ret= (*file)->add_index(table_arg, key_info, num_of_keys)))
- break;
+ goto err;
+ return ret;
+err:
+ if (file > m_file)
+ {
+ uint *key_numbers= (uint*) ha_thd()->alloc(sizeof(uint) * num_of_keys);
+ KEY *old_key_info= table_arg->key_info;
+ uint i;
+ /* Use the newly added key_info as table->key_info to remove them. */
+ for (i= 0; i < num_of_keys; i++)
+ key_numbers[i]= i;
+ table_arg->key_info= key_info;
+ while (--file >= m_file)
+ {
+ (void) (*file)->prepare_drop_index(table_arg, key_numbers, num_of_keys);
+ (void) (*file)->final_drop_index(table_arg);
+ }
+ table_arg->key_info= old_key_info;
+ }
return ret;
}