00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "myisam_priv.h"
00019 #include <sys/stat.h>
00020 #include <drizzled/error.h>
00021
00022 using namespace drizzled;
00023
00024
00025
00026 internal::my_off_t mi_position(MI_INFO *info)
00027 {
00028 return info->lastpos;
00029 }
00030
00031
00032
00033
00034
00035 int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint32_t flag)
00036 {
00037 struct stat state;
00038 MYISAM_SHARE *share=info->s;
00039
00040 x->recpos = info->lastpos;
00041 if (flag == HA_STATUS_POS)
00042 return(0);
00043 if (!(flag & HA_STATUS_NO_LOCK))
00044 {
00045 _mi_readinfo(info,F_RDLCK,0);
00046 fast_mi_writeinfo(info);
00047 }
00048 if (flag & HA_STATUS_VARIABLE)
00049 {
00050 x->records = info->state->records;
00051 x->deleted = info->state->del;
00052 x->delete_length = info->state->empty;
00053 x->data_file_length =info->state->data_file_length;
00054 x->index_file_length=info->state->key_file_length;
00055
00056 x->keys = share->state.header.keys;
00057 x->check_time = share->state.check_time;
00058 x->mean_reclength= x->records ?
00059 (uint32_t) ((x->data_file_length - x->delete_length) / x->records) :
00060 (uint32_t) share->min_pack_length;
00061 }
00062 if (flag & HA_STATUS_ERRKEY)
00063 {
00064 x->errkey = info->errkey;
00065 x->dupp_key_pos= info->dupp_key_pos;
00066 }
00067 if (flag & HA_STATUS_CONST)
00068 {
00069 x->reclength = share->base.reclength;
00070 x->max_data_file_length=share->base.max_data_file_length;
00071 x->max_index_file_length=info->s->base.max_key_file_length;
00072 x->filenr = info->dfile;
00073 x->options = share->options;
00074 x->create_time=share->state.create_time;
00075 x->reflength= mi_get_pointer_length(share->base.max_data_file_length, data_pointer_size);
00076 x->record_offset= ((share->options &
00077 (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ?
00078 0L : share->base.pack_reclength);
00079 x->sortkey= -1;
00080 x->rec_per_key = share->state.rec_per_key_part;
00081 x->key_map = share->state.key_map;
00082 x->data_file_name = share->data_file_name;
00083 x->index_file_name = share->index_file_name;
00084 }
00085 if ((flag & HA_STATUS_TIME) && !fstat(info->dfile,&state))
00086 x->update_time=state.st_mtime;
00087 else
00088 x->update_time=0;
00089 if (flag & HA_STATUS_AUTO)
00090 {
00091 x->auto_increment= share->state.auto_increment+1;
00092 if (!x->auto_increment)
00093 x->auto_increment= ~(uint64_t) 0;
00094 }
00095 return(0);
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 void mi_report_error(int errcode, const char *file_name)
00119 {
00120 mi_report_error(errcode, file_name);
00121 }
00122
00123 void mi_report_error(drizzled::error_t errcode, const char *file_name)
00124 {
00125 size_t lgt;
00126
00127 if ((lgt= strlen(file_name)) > 64)
00128 file_name+= lgt - 64;
00129 my_error(errcode, MYF(ME_NOREFRESH), file_name);
00130 }
00131