summaryrefslogtreecommitdiff
path: root/sql/ha_myisam.cc
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-04-06 21:35:26 +0200
committerunknown <serg@serg.mylan>2004-04-06 21:35:26 +0200
commitc62705434021f8ed7b7cfdf9dbba5b1751ebd6f2 (patch)
tree49936e67024c8911d22de045aa8314e5f88d506b /sql/ha_myisam.cc
parentf463848913ab86ec9d87cb24dd77d8c17a0e1deb (diff)
downloadmariadb-git-c62705434021f8ed7b7cfdf9dbba5b1751ebd6f2.tar.gz
::reset(), HA_FAST_KEY_READ, disable_indexes(), enable_indexes(), start_bulk_insert(), end_bulk_insert()
Field::val_str simplification, comment include/my_base.h: typos fixed mysql-test/r/myisam.result: alter table enable/disable keys mysql-test/t/help.test: cleanup mysql-test/t/myisam.test: alter table enable/disable keys sql/field.cc: Field::val_str() simplification sql/field.h: Field::val_str() simplification and comment sql/field_conv.cc: Field::val_str() simplification sql/ha_berkeley.cc: ::reset(), HA_FAST_KEY_READ sql/ha_berkeley.h: ::reset(), HA_FAST_KEY_READ sql/ha_heap.cc: ::reset(), HA_FAST_KEY_READ sql/ha_heap.h: ::reset(), HA_FAST_KEY_READ sql/ha_innodb.cc: ::reset(), HA_FAST_KEY_READ sql/ha_innodb.h: ::reset(), HA_FAST_KEY_READ sql/ha_isam.cc: ::reset(), HA_FAST_KEY_READ sql/ha_isam.h: ::reset(), HA_FAST_KEY_READ sql/ha_isammrg.cc: ::reset(), HA_FAST_KEY_READ sql/ha_isammrg.h: ::reset(), HA_FAST_KEY_READ sql/ha_myisam.cc: ::reset(), HA_FAST_KEY_READ, disable_indexes(), enable_indexes(), start_bulk_insert(), end_bulk_insert() sql/ha_myisam.h: ::reset(), HA_FAST_KEY_READ, disable_indexes(), enable_indexes(), start_bulk_insert(), end_bulk_insert() sql/ha_myisammrg.cc: ::reset(), HA_FAST_KEY_READ sql/ha_myisammrg.h: ::reset(), HA_FAST_KEY_READ sql/handler.h: ::reset(), HA_FAST_KEY_READ, disable_indexes(), enable_indexes(), start_bulk_insert(), end_bulk_insert() sql/item.cc: Field::val_str() simplification sql/item_sum.cc: Field::val_str() simplification sql/key.cc: Field::val_str() simplification sql/opt_range.cc: Field::val_str() simplification sql/protocol.cc: Field::val_str() simplification sql/records.cc: HA_FAST_KEY_READ sql/sql_acl.cc: Field::val_str() simplification sql/sql_base.cc: ::reset sql/sql_insert.cc: ::reset(), start_bulk_insert(), end_bulk_insert() sql/sql_load.cc: start_bulk_insert(), end_bulk_insert() sql/sql_show.cc: Field::val_str() simplification sql/sql_table.cc: disable_indexes(), enable_indexes(), start_bulk_insert(), end_bulk_insert() sql/table.cc: Field::val_str() simplification
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r--sql/ha_myisam.cc135
1 files changed, 68 insertions, 67 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 6ac3c52fe40..e78d2193c4b 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -810,82 +810,89 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
}
}
+/* disable indexes, making it persistent if requested
+ SYNOPSIS
+ disable_indexes(all, save)
+ all disable all indexes
+ if not set only non-unique indexes will be disabled
+ [all=1 is NOT IMPLEMENTED YET]
+ save save the disabled state, so that it will persist
+ between queries/threads/reboots
+ [save=0 is NOT IMPLEMENTED YET]
+*/
+int ha_myisam::disable_indexes(bool all, bool save)
+{
+ mi_extra(file, HA_EXTRA_NO_KEYS, 0);
+ info(HA_STATUS_CONST); // Read new key info
+ return 0;
+}
+
+int ha_myisam::enable_indexes()
+{
+ if (file->s->state.key_map == set_bits(ulonglong, file->s->base.keys))
+ return 0;
+
+ int error=0;
+ THD *thd=current_thd;
+ MI_CHECK param;
+ const char *save_proc_info=thd->proc_info;
+ thd->proc_info="Creating index";
+ myisamchk_init(&param);
+ param.op_name = (char*) "recreating_index";
+ param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
+ T_CREATE_MISSING_KEYS);
+ param.myf_rw&= ~MY_WAIT_IF_FULL;
+ param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
+ param.tmpdir=&mysql_tmpdir_list;
+ error=repair(thd,param,0) != HA_ADMIN_OK;
+ info(HA_STATUS_CONST);
+ thd->proc_info=save_proc_info;
+ return error;
+}
+
/*
- Deactive all not unique index that can be recreated fast
+ prepare for a many-rows insert operation
+ e.g. - disable indexes (if they can be recreated fast) or
+ activate special bulk-insert optimizations
SYNOPSIS
- deactivate_non_unique_index()
- rows Rows to be inserted
- 0 if we don't know
- HA_POS_ERROR if we want to force disabling
- and make it permanent (save on disk)
+ start_bulk_insert(rows)
+ rows Rows to be inserted
+ 0 if we don't know
*/
-void ha_myisam::deactivate_non_unique_index(ha_rows rows)
+void ha_myisam::start_bulk_insert(ha_rows rows)
{
- MYISAM_SHARE* share = file->s;
- if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
+ if (!(specialflag & SPECIAL_SAFE_MODE))
{
- if (!(specialflag & SPECIAL_SAFE_MODE))
+ can_enable_indexes= (file->s->state.key_map ==
+ set_bits(ulonglong, file->s->base.keys));
+
+ /*
+ Only disable old index if the table was empty and we are inserting
+ a lot of rows.
+ We should not do this for only a few rows as this is slower and
+ we don't want to update the key statistics based of only a few rows.
+ */
+ if (file->state->records == 0 && can_enable_indexes &&
+ (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
+ mi_disable_non_unique_index(file,rows);
+ else
+ if (!file->bulk_insert &&
+ (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
{
- if (rows == HA_POS_ERROR) // force disable and save it on disk!
- mi_extra(file, HA_EXTRA_NO_KEYS, 0);
- else
- {
- /*
- Only disable old index if the table was empty and we are inserting
- a lot of rows.
- We should not do this for only a few rows as this is slower and
- we don't want to update the key statistics based of only a few rows.
- */
- if (file->state->records == 0 &&
- (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
- mi_disable_non_unique_index(file,rows);
- else
- if (!file->bulk_insert &&
- (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
- {
- mi_init_bulk_insert(file,
- current_thd->variables.bulk_insert_buff_size,
- rows);
- }
- }
+ mi_init_bulk_insert(file,
+ current_thd->variables.bulk_insert_buff_size,
+ rows);
}
- enable_activate_all_index=1;
- info(HA_STATUS_CONST); // Read new key info
}
- else
- enable_activate_all_index=0;
}
-bool ha_myisam::activate_all_index(THD *thd)
+int ha_myisam::end_bulk_insert()
{
- int error=0;
- MI_CHECK param;
- MYISAM_SHARE* share = file->s;
- DBUG_ENTER("activate_all_index");
-
mi_end_bulk_insert(file);
- if (enable_activate_all_index &&
- share->state.key_map != set_bits(ulonglong, share->base.keys))
- {
- const char *save_proc_info=thd->proc_info;
- thd->proc_info="Creating index";
- myisamchk_init(&param);
- param.op_name = (char*) "recreating_index";
- param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
- T_CREATE_MISSING_KEYS);
- param.myf_rw&= ~MY_WAIT_IF_FULL;
- param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
- param.tmpdir=&mysql_tmpdir_list;
- error=repair(thd,param,0) != HA_ADMIN_OK;
- info(HA_STATUS_CONST);
- thd->proc_info=save_proc_info;
- }
- else
- enable_activate_all_index=1;
- DBUG_RETURN(error);
+ return can_enable_indexes ? enable_indexes() : 0;
}
@@ -1118,12 +1125,6 @@ int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size)
return mi_extra(file, operation, (void*) &cache_size);
}
-
-int ha_myisam::reset(void)
-{
- return mi_extra(file, HA_EXTRA_RESET, 0);
-}
-
int ha_myisam::delete_all_rows()
{
return mi_delete_all_rows(file);