16
16
/* Functions to handle fixed-length-records */
18
#include "myisam_priv.h"
20
using namespace drizzled;
22
int _mi_write_static_record(MI_INFO *info, const unsigned char *record)
18
#include "myisamdef.h"
20
int _mi_write_static_record(MI_INFO *info, const uchar *record)
24
unsigned char temp[8]; /* max pointer length */
22
uchar temp[8]; /* max pointer length */
25
23
if (info->s->state.dellink != HA_OFFSET_ERROR &&
26
24
!info->append_insert_at_end)
28
internal::my_off_t filepos=info->s->state.dellink;
26
my_off_t filepos=info->s->state.dellink;
29
27
info->rec_cache.seek_not_done=1; /* We have done a seek */
30
28
if (info->s->file_read(info, &temp[0],info->s->base.rec_reflength,
31
29
info->s->state.dellink+1,
44
42
if (info->state->data_file_length > info->s->base.max_data_file_length-
45
43
info->s->base.pack_reclength)
47
errno=HA_ERR_RECORD_FILE_FULL;
45
my_errno=HA_ERR_RECORD_FILE_FULL;
50
48
if (info->opt_flag & WRITE_CACHE_USED)
55
53
if (info->s->base.pack_reclength != info->s->base.reclength)
57
uint32_t length=info->s->base.pack_reclength - info->s->base.reclength;
55
uint length=info->s->base.pack_reclength - info->s->base.reclength;
58
56
memset(temp, 0, length);
59
57
if (my_b_write(&info->rec_cache, temp,length))
70
68
if (info->s->base.pack_reclength != info->s->base.reclength)
72
uint32_t length=info->s->base.pack_reclength - info->s->base.reclength;
70
uint length=info->s->base.pack_reclength - info->s->base.reclength;
73
71
memset(temp, 0, length);
74
72
if (info->s->file_write(info, temp,length,
75
73
info->state->data_file_length+
89
int _mi_update_static_record(MI_INFO *info, internal::my_off_t pos, const unsigned char *record)
87
int _mi_update_static_record(MI_INFO *info, my_off_t pos, const uchar *record)
91
89
info->rec_cache.seek_not_done=1; /* We have done a seek */
92
90
return (info->s->file_write(info,
106
104
_mi_dpointer(info,temp+1,info->s->state.dellink);
107
105
info->s->state.dellink = info->lastpos;
108
106
info->rec_cache.seek_not_done=1;
109
return (info->s->file_write(info,(unsigned char*) temp, 1+info->s->rec_reflength,
107
return (info->s->file_write(info,(uchar*) temp, 1+info->s->rec_reflength,
110
108
info->lastpos, MYF(MY_NABP)) != 0);
114
int _mi_cmp_static_record(register MI_INFO *info, register const unsigned char *old)
112
int _mi_cmp_static_record(register MI_INFO *info, register const uchar *old)
116
114
if (info->opt_flag & WRITE_CACHE_USED)
132
130
if (memcmp(info->rec_buff, old,
133
131
(uint) info->s->base.reclength))
135
errno=HA_ERR_RECORD_CHANGED; /* Record have changed */
133
my_errno=HA_ERR_RECORD_CHANGED; /* Record have changed */
143
141
int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def,
144
const unsigned char *record, internal::my_off_t pos)
142
const uchar *record, my_off_t pos)
146
144
info->rec_cache.seek_not_done=1; /* We have done a seek */
147
145
if (info->s->file_read(info, info->rec_buff, info->s->base.reclength,
157
155
/* 1 if record is deleted */
158
156
/* MY_FILE_ERROR on read-error or locking-error */
160
int _mi_read_static_record(register MI_INFO *info, register internal::my_off_t pos,
161
register unsigned char *record)
158
int _mi_read_static_record(register MI_INFO *info, register my_off_t pos,
159
register uchar *record)
194
int _mi_read_rnd_static_record(MI_INFO *info, unsigned char *buf,
195
register internal::my_off_t filepos,
192
int _mi_read_rnd_static_record(MI_INFO *info, uchar *buf,
193
register my_off_t filepos,
196
194
bool skip_deleted_blocks)
198
196
int locked,error,cache_read;
199
uint32_t cache_length;
200
198
MYISAM_SHARE *share=info->s;
204
202
if (info->opt_flag & WRITE_CACHE_USED &&
205
203
(info->rec_cache.pos_in_file <= filepos || skip_deleted_blocks) &&
206
204
flush_io_cache(&info->rec_cache))
208
206
if (info->opt_flag & READ_CACHE_USED)
209
207
{ /* Cache in use */
210
208
if (filepos == my_b_tell(&info->rec_cache) &&
247
245
if ((error=_mi_read_static_record(info,filepos,buf)))
250
error=errno=HA_ERR_RECORD_DELETED;
248
error=my_errno=HA_ERR_RECORD_DELETED;
257
255
/* Read record with cacheing */
258
error=my_b_read(&info->rec_cache,(unsigned char*) buf,share->base.reclength);
256
error=my_b_read(&info->rec_cache,(uchar*) buf,share->base.reclength);
259
257
if (info->s->base.pack_reclength != info->s->base.reclength && !error)
261
259
char tmp[8]; /* Skill fill bytes */
262
error=my_b_read(&info->rec_cache,(unsigned char*) tmp,
260
error=my_b_read(&info->rec_cache,(uchar*) tmp,
263
261
info->s->base.pack_reclength - info->s->base.reclength);
266
_mi_writeinfo(info,0); /* Unlock keyfile */
264
VOID(_mi_writeinfo(info,0)); /* Unlock keyfile */
270
268
{ /* Record is removed */
271
return(errno=HA_ERR_RECORD_DELETED);
269
return(my_errno=HA_ERR_RECORD_DELETED);
273
271
/* Found and may be updated */
274
272
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
277
/* errno should be set if rec_cache.error == -1 */
278
if (info->rec_cache.error != -1 || errno == 0)
279
errno=HA_ERR_WRONG_IN_RECORD;
280
return(errno); /* Something wrong (EOF?) */
275
/* my_errno should be set if rec_cache.error == -1 */
276
if (info->rec_cache.error != -1 || my_errno == 0)
277
my_errno=HA_ERR_WRONG_IN_RECORD;
278
return(my_errno); /* Something wrong (EOF?) */