~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_statrec.c

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-07 20:12:20 UTC
  • mto: (934.3.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 938.
  • Revision ID: osullivan.padraig@gmail.com-20090307201220-u9r93y0knyyb8ggy
Cleaning up my function object a little bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
        /* Functions to handle fixed-length-records */
17
17
 
18
 
#include "myisam_priv.h"
19
 
 
20
 
using namespace drizzled;
 
18
#include "myisamdef.h"
21
19
 
22
20
int _mi_write_static_record(MI_INFO *info, const unsigned char *record)
23
21
{
25
23
  if (info->s->state.dellink != HA_OFFSET_ERROR &&
26
24
      !info->append_insert_at_end)
27
25
  {
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)
46
44
    {
47
 
      errno=HA_ERR_RECORD_FILE_FULL;
 
45
      my_errno=HA_ERR_RECORD_FILE_FULL;
48
46
      return(2);
49
47
    }
50
48
    if (info->opt_flag & WRITE_CACHE_USED)
86
84
  return 1;
87
85
}
88
86
 
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 unsigned char *record)
90
88
{
91
89
  info->rec_cache.seek_not_done=1;              /* We have done a seek */
92
90
  return (info->s->file_write(info,
132
130
    if (memcmp(info->rec_buff, old,
133
131
               (uint) info->s->base.reclength))
134
132
    {
135
 
      errno=HA_ERR_RECORD_CHANGED;              /* Record have changed */
 
133
      my_errno=HA_ERR_RECORD_CHANGED;           /* Record have changed */
136
134
      return(1);
137
135
    }
138
136
  }
141
139
 
142
140
 
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 unsigned char *record, my_off_t pos)
145
143
{
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 */
159
157
 
160
 
int _mi_read_static_record(register MI_INFO *info, register internal::my_off_t pos,
 
158
int _mi_read_static_record(register MI_INFO *info, register my_off_t pos,
161
159
                           register unsigned char *record)
162
160
{
163
161
  int error;
177
175
    {
178
176
      if (!*record)
179
177
      {
180
 
        errno=HA_ERR_RECORD_DELETED;
 
178
        my_errno=HA_ERR_RECORD_DELETED;
181
179
        return(1);                              /* Record is deleted */
182
180
      }
183
181
      info->update|= HA_STATE_AKTIV;            /* Record is read */
192
190
 
193
191
 
194
192
int _mi_read_rnd_static_record(MI_INFO *info, unsigned char *buf,
195
 
                               register internal::my_off_t filepos,
 
193
                               register my_off_t filepos,
196
194
                               bool skip_deleted_blocks)
197
195
{
198
196
  int locked,error,cache_read;
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))
207
 
    return(errno);
 
205
    return(my_errno);
208
206
  if (info->opt_flag & READ_CACHE_USED)
209
207
  {                                             /* Cache in use */
210
208
    if (filepos == my_b_tell(&info->rec_cache) &&
222
220
    if (filepos >= info->state->data_file_length)
223
221
    {                                           /* Test if new records */
224
222
      if (_mi_readinfo(info,F_RDLCK,0))
225
 
        return(errno);
 
223
        return(my_errno);
226
224
      locked=1;
227
225
    }
228
226
    else
237
235
  if (filepos >= info->state->data_file_length)
238
236
  {
239
237
    fast_mi_writeinfo(info);
240
 
    return(errno=HA_ERR_END_OF_FILE);
 
238
    return(my_errno=HA_ERR_END_OF_FILE);
241
239
  }
242
240
  info->lastpos= filepos;
243
241
  info->nextpos= filepos+share->base.pack_reclength;
247
245
    if ((error=_mi_read_static_record(info,filepos,buf)))
248
246
    {
249
247
      if (error > 0)
250
 
        error=errno=HA_ERR_RECORD_DELETED;
 
248
        error=my_errno=HA_ERR_RECORD_DELETED;
251
249
      else
252
 
        error=errno;
 
250
        error=my_errno;
253
251
    }
254
252
    return(error);
255
253
  }
268
266
  {
269
267
    if (!buf[0])
270
268
    {                                           /* Record is removed */
271
 
      return(errno=HA_ERR_RECORD_DELETED);
 
269
      return(my_errno=HA_ERR_RECORD_DELETED);
272
270
    }
273
271
                                                /* Found and may be updated */
274
272
    info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
275
273
    return(0);
276
274
  }
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?) */
281
279
}