diff options
Diffstat (limited to 'myisam/mi_extra.c')
-rw-r--r-- | myisam/mi_extra.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index cf075512ac4..21cd9919ada 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -34,6 +34,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) int error=0; MYISAM_SHARE *share=info->s; DBUG_ENTER("mi_extra"); + DBUG_PRINT("enter",("function: %d",(int) function)); switch (function) { case HA_EXTRA_RESET: @@ -50,7 +51,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) if (info->opt_flag & MEMMAP_USED) madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); #endif - info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); + info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); info->quick_mode=0; /* Fall through */ @@ -219,9 +220,17 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) } if (share->state.key_map) { - share->state.key_map=0; - info->state->key_file_length=share->state.state.key_file_length= - share->base.keystart; + MI_KEYDEF *key=share->keyinfo; + uint i; + for (i=0 ; i < share->base.keys ; i++,key++) + { + if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1) + { + share->state.key_map&= ~ ((ulonglong) 1 << i); + info->update|= HA_STATE_CHANGED; + } + } + if (!share->changed) { share->state.changed|= STATE_CHANGED | STATE_NOT_ANALYZED; @@ -237,12 +246,15 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) } break; case HA_EXTRA_FORCE_REOPEN: + case HA_EXTRA_PREPARE_FOR_DELETE: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); - if (flush_key_blocks(share->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(share->kfile, + (function == HA_EXTRA_FORCE_REOPEN ? + FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { error=my_errno; share->changed=1; @@ -328,6 +340,24 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) case HA_EXTRA_QUICK: info->quick_mode=1; break; + case HA_EXTRA_BULK_INSERT_BEGIN: + error=_mi_init_bulk_insert(info); + break; + case HA_EXTRA_BULK_INSERT_END: + if (info->bulk_insert) + { + uint i; + for (i=0 ; i < share->base.keys ; i++) + { + if (is_tree_inited(& info->bulk_insert[i])) + { + delete_tree(& info->bulk_insert[i]); + } + } + my_free((void *)info->bulk_insert, MYF(0)); + info->bulk_insert=0; + } + break; case HA_EXTRA_NO_ROWS: if (!share->state.header.uniques) info->opt_flag|= OPT_NO_ROWS; |