summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAditya A <aditya.a@oracle.com>2013-10-21 12:07:02 +0530
committerAditya A <aditya.a@oracle.com>2013-10-21 12:07:02 +0530
commitc5896384bda582ec6f43ceb3fe9e7530e0bf819d (patch)
treeb0a6f6d23ea3ddfd431b61063168456d40c383e1 /sql
parent7a524cee32e3a7d457fa6a0e86351ddac1c219fb (diff)
downloadmariadb-git-c5896384bda582ec6f43ceb3fe9e7530e0bf819d.tar.gz
Bug #16051817 GOT ERROR 124 FROM STORAGE ENGINE
ON DELETE FROM A PARTITIONED TABLE PROBLEM ------- The user first disables all the non unique indexes in the table and then rebuilds one partition. During rebuild the indexes on that particular partition are enabled. Now when we give a query the optimizer is unaware that on one partition indexes are enabled and if the optimizer selects that index,myisam thinks that the index is not active and gives an error. FIX --- Before rebuilding a partition check whether non unique indexes are disabled on the partitons. If they are disabled then after rebuild disable the index on the partition. [Approved by Mattiasj #rb3469]
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc23
-rw-r--r--sql/ha_partition.h3
2 files changed, 22 insertions, 4 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index c3f2af27282..507f202e349 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1337,7 +1337,8 @@ bool ha_partition::is_crashed() const
int ha_partition::prepare_new_partition(TABLE *tbl,
HA_CREATE_INFO *create_info,
handler *file, const char *part_name,
- partition_element *p_elem)
+ partition_element *p_elem,
+ uint disable_non_uniq_indexes)
{
int error;
DBUG_ENTER("prepare_new_partition");
@@ -1362,6 +1363,7 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
if ((error= file->ha_open(tbl, part_name, m_mode, m_open_test_lock)))
goto error_open;
DBUG_PRINT("info", ("partition %s opened", part_name));
+
/*
Note: if you plan to add another call that may return failure,
better to do it before external_lock() as cleanup_new_partition()
@@ -1372,6 +1374,9 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
goto error_external_lock;
DBUG_PRINT("info", ("partition %s external locked", part_name));
+ if (disable_non_uniq_indexes)
+ file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
+
DBUG_RETURN(0);
error_external_lock:
(void) file->close();
@@ -1649,6 +1654,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
on them to prepare them for copy phase and also for later close
calls
*/
+
+ /*
+ Before creating new partitions check whether indexes are disabled
+ in the partitions.
+ */
+
+ uint disable_non_uniq_indexes = indexes_are_disabled();
+
i= 0;
part_count= 0;
part_it.rewind();
@@ -1683,11 +1696,13 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
if ((error= prepare_new_partition(table, create_info,
new_file_array[part],
(const char *)part_name_buff,
- sub_elem)))
+ sub_elem,
+ disable_non_uniq_indexes)))
{
cleanup_new_partition(part_count);
DBUG_RETURN(error);
}
+
m_added_file[part_count++]= new_file_array[part];
} while (++j < num_subparts);
}
@@ -1700,11 +1715,13 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
if ((error= prepare_new_partition(table, create_info,
new_file_array[i],
(const char *)part_name_buff,
- part_elem)))
+ part_elem,
+ disable_non_uniq_indexes)))
{
cleanup_new_partition(part_count);
DBUG_RETURN(error);
}
+
m_added_file[part_count++]= new_file_array[i];
}
}
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index eef93e056ef..153e610d86f 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -270,7 +270,8 @@ private:
void cleanup_new_partition(uint part_count);
int prepare_new_partition(TABLE *table, HA_CREATE_INFO *create_info,
handler *file, const char *part_name,
- partition_element *p_elem);
+ partition_element *p_elem,
+ uint disable_non_uniq_indexes);
/*
delete_table, rename_table and create uses very similar logic which
is packed into this routine.