summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2001-05-24 13:14:25 +0200
committerunknown <serg@serg.mysql.com>2001-05-24 13:14:25 +0200
commit1c8902e4ef6e57b648fcd9978bc1e20e917df40b (patch)
tree10377fbee77e1cf260ad739e99d78ff27c26e8d4 /sql
parent83e3058c3e6ebd1ec2ffa03854eaf1388bb4c484 (diff)
downloadmariadb-git-1c8902e4ef6e57b648fcd9978bc1e20e917df40b.tar.gz
ALTER TABLE ... DISABLE/ENABLE KEYS, code cleanup
myisam/ft_boolean_search.c: qsort_cmp -> qsort_cmp2 myisam/mi_extra.c: ALTER TABLE ... ENABLE/DISABLE KEYS mi_extra(HA_EXTRA_NO_KEYS) disables only only non-unique keys myisam/myisamlog.c: qsort_cmp -> qsort_cmp2 sql/ha_myisam.cc: ALTER TABLE ENABLE/DISABLE KEYS deactivate_non_unique_index(HA_POS_ERROR) to force deactivation sql/ha_myisam.h: ALTER TABLE ... DISABLE/ENABLE KEYS sql/sql_table.cc: ALTER TABLE ... DISABLE/ENABLE KEYS
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc19
-rw-r--r--sql/ha_myisam.h4
-rw-r--r--sql/sql_table.cc6
3 files changed, 22 insertions, 7 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 6409ec5d019..bec465a5c5c 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -637,8 +637,18 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
{
- if (!(specialflag & SPECIAL_SAFE_MODE))
- mi_disable_non_unique_index(file,rows);
+ MYISAM_SHARE* share = file->s;
+ if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
+ {
+ if (!(specialflag & SPECIAL_SAFE_MODE))
+ if (rows==HA_POS_ERROR)
+ mi_extra(file, HA_EXTRA_NO_KEYS);
+ else
+ mi_disable_non_unique_index(file,rows);
+ enable_activate_all_index=1;
+ }
+ else
+ enable_activate_all_index=0;
}
@@ -648,7 +658,8 @@ bool ha_myisam::activate_all_index(THD *thd)
MI_CHECK param;
MYISAM_SHARE* share = file->s;
DBUG_ENTER("activate_all_index");
- if (share->state.key_map != ((ulonglong) 1L << share->base.keys)-1)
+ if (enable_activate_all_index &&
+ share->state.key_map != ((ulonglong) 1L << share->base.keys)-1)
{
const char *save_proc_info=thd->proc_info;
thd->proc_info="Creating index";
@@ -663,6 +674,8 @@ bool ha_myisam::activate_all_index(THD *thd)
error=repair(thd,param,0) != HA_ADMIN_OK;
thd->proc_info=save_proc_info;
}
+ else
+ enable_activate_all_index=1;
DBUG_RETURN(error);
}
diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h
index 6451e2b80ee..21b7e5bbd39 100644
--- a/sql/ha_myisam.h
+++ b/sql/ha_myisam.h
@@ -37,11 +37,11 @@ extern ulong myisam_recover_options;
class ha_myisam: public handler
{
MI_INFO *file;
- uint int_option_flag;
+ uint int_option_flag,enable_activate_all_index;
int repair(THD *thd, MI_CHECK &param, bool optimize);
public:
- ha_myisam(TABLE *table): handler(table), file(0),
+ ha_myisam(TABLE *table): handler(table), file(0),enable_activate_all_index(1),
int_option_flag(HA_READ_NEXT | HA_READ_PREV | HA_READ_RND_SAME |
HA_KEYPOS_TO_RNDPOS | HA_READ_ORDER | HA_LASTKEY_ORDER |
HA_HAVE_KEY_READ_ONLY | HA_READ_NOT_EXACT_KEY |
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 89699655ab9..95f5d4da24d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1189,9 +1189,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
switch (keys_onoff)
{
case LEAVE_AS_IS: break;
- case ENABLE: error=table->file->activate_all_index(thd); break;
+ case ENABLE:
+ error=table->file->activate_all_index(thd);
+ break;
case DISABLE:
- table->file->deactivate_non_unique_index(table->file->records);
+ table->file->deactivate_non_unique_index(HA_POS_ERROR);
break;
}
}