19 #include "myisamdef.h"
21 int mi_delete_all_rows(
MI_INFO *info)
26 DBUG_ENTER(
"mi_delete_all_rows");
28 if (share->options & HA_OPTION_READ_ONLY_DATA)
30 DBUG_RETURN(my_errno=EACCES);
32 if (_mi_readinfo(info,F_WRLCK,1))
33 DBUG_RETURN(my_errno);
34 if (_mi_mark_file_changed(info))
37 info->state->records=info->state->del=state->split=0;
38 state->dellink = HA_OFFSET_ERROR;
39 state->sortkey= (ushort) ~0;
40 info->state->key_file_length=share->base.keystart;
41 info->state->data_file_length=0;
42 info->state->empty=info->state->key_empty=0;
43 info->state->checksum=0;
45 for (i=share->base.max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; )
46 state->key_del[
i]= HA_OFFSET_ERROR;
47 for (i=0 ; i < share->base.keys ; i++)
48 state->key_root[i]= HA_OFFSET_ERROR;
50 myisam_log_command(MI_LOG_DELETE_ALL,info,(uchar*) 0,0,0);
55 flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
63 (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
68 int save_errno=my_errno;
69 (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
70 info->update|=HA_STATE_WRITTEN;
71 DBUG_RETURN(my_errno=save_errno);