summaryrefslogtreecommitdiff
path: root/myisam/mi_open.c
diff options
context:
space:
mode:
authorunknown <andrey@example.com>2006-11-28 18:27:32 +0100
committerunknown <andrey@example.com>2006-11-28 18:27:32 +0100
commita9173ec999a04f8dc7aa4e6e373d776c6ddd3f0f (patch)
tree25bc5c7d9259f809a26de7f675ef558b19424f34 /myisam/mi_open.c
parent4d2665f01e50623d7ccc2535267c26759dcc4d0d (diff)
downloadmariadb-git-a9173ec999a04f8dc7aa4e6e373d776c6ddd3f0f.tar.gz
Fix for bug#24395:
ALTER TABLE DISABLE KEYS doesn't work when modifying the table ENABLE|DISABLE KEYS combined with another ALTER TABLE option, different than RENAME TO did nothing. Also, if the table had disabled keys and was ALTER-ed then the end table was with enabled keys. Fixed by checking whether the table had disabled keys and enabling them in the copied table. myisam/mi_open.c: Extend mi_indexes_are_disabled to implement return value 2 - Non-unique indexes are disabled mysql-test/r/alter_table.result: update result mysql-test/t/alter_table.test: update test sql/sql_table.cc: When ENABLE|DISABLE index is combined with another option different than RENAME TO, we should ENABLE|DISABLE the keys of the modified table. Also when modifying we should preserve the previous state of the indices. (This problem exists in 5.0 and 5.1 but since the codebase has diverged, this fix won't automerge, but the fix will be quite similar).
Diffstat (limited to 'myisam/mi_open.c')
-rw-r--r--myisam/mi_open.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 4f298397615..db15f39c84a 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -1233,13 +1233,30 @@ int mi_enable_indexes(MI_INFO *info)
RETURN
0 indexes are not disabled
1 all indexes are disabled
- [2 non-unique indexes are disabled - NOT YET IMPLEMENTED]
+ 2 non-unique indexes are disabled
*/
int mi_indexes_are_disabled(MI_INFO *info)
{
MYISAM_SHARE *share= info->s;
- return (! share->state.key_map && share->base.keys);
+ /*
+ No keys or all are enabled. keys is the number of keys. Left shifted
+ gives us only one bit set. When decreased by one, gives us all all bits
+ up to this one set and it gets unset.
+ */
+ if (!share->base.keys ||
+ (share->state.key_map == (ULL(1) << share->base.keys) - ULL(1)))
+ return 0;
+
+ /* All are disabled */
+ if (!share->state.key_map)
+ return 1;
+
+ /*
+ We have keys. Some enabled, some disabled.
+ Don't check for any non-unique disabled but return directly 2
+ */
+ return 2;
}