~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_page.cc

  • Committer: Mark Atwood
  • Date: 2011-09-14 03:30:42 UTC
  • mfrom: (2409.2.6 refactor7)
  • Revision ID: me@mark.atwood.name-20110914033042-2u0s8foaigvf62g2
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
        /* Fetch a key-page in memory */
23
23
 
24
 
unsigned char *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
25
 
                         internal::my_off_t page, int level,
26
 
                         unsigned char *buff, int return_buffer)
 
24
unsigned char *_mi_fetch_keypage(MI_INFO *info, MI_KEYDEF *keyinfo,
 
25
                         internal::my_off_t page, int, unsigned char *buff, int)
27
26
{
28
 
  unsigned char *tmp;
29
 
  uint32_t page_size;
30
 
 
31
 
  tmp=(unsigned char*) key_cache_read(info->s->getKeyCache(),
32
 
                             info->s->kfile, page, level, (unsigned char*) buff,
33
 
                             (uint) keyinfo->block_length,
34
 
                             (uint) keyinfo->block_length,
35
 
                             return_buffer);
36
 
  if (tmp == info->buff)
37
 
    info->buff_used=1;
38
 
  else if (!tmp)
 
27
  if (not pread(info->s->kfile, buff, keyinfo->block_length, page))
39
28
  {
40
29
    info->last_keypage=HA_OFFSET_ERROR;
41
30
    mi_print_error(info->s, HA_ERR_CRASHED);
42
31
    errno=HA_ERR_CRASHED;
43
32
    return(0);
44
33
  }
 
34
  unsigned char* tmp= buff;
 
35
  if (tmp == info->buff)
 
36
    info->buff_used=1;
45
37
  info->last_keypage=page;
46
 
  page_size=mi_getint(tmp);
 
38
  uint32_t page_size=mi_getint(tmp);
47
39
  if (page_size < 4 || page_size > keyinfo->block_length)
48
40
  {
49
41
    info->last_keypage = HA_OFFSET_ERROR;
57
49
 
58
50
        /* Write a key-page on disk */
59
51
 
60
 
int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
61
 
                      internal::my_off_t page, int level, unsigned char *buff)
 
52
int _mi_write_keypage(MI_INFO *info, MI_KEYDEF *keyinfo,
 
53
                      internal::my_off_t page, int, unsigned char *buff)
62
54
{
63
 
  register uint32_t length;
 
55
  uint32_t length;
64
56
 
65
57
#ifndef FAST                                    /* Safety check */
66
58
  if (page < info->s->base.keystart ||
82
74
    length=keyinfo->block_length;
83
75
  }
84
76
#endif
85
 
  return((key_cache_write(info->s->getKeyCache(),
86
 
                         info->s->kfile,page, level, (unsigned char*) buff,length,
87
 
                         (uint) keyinfo->block_length,
88
 
                         (int) ((info->lock_type != F_UNLCK) ||
89
 
                                info->s->delay_key_write))));
 
77
  return not pwrite(info->s->kfile, buff, length, page);
90
78
} /* mi_write_keypage */
91
79
 
92
80
 
93
81
        /* Remove page from disk */
94
82
 
95
 
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, internal::my_off_t pos,
96
 
                int level)
 
83
int _mi_dispose(MI_INFO *info, MI_KEYDEF *keyinfo, internal::my_off_t pos, int)
97
84
{
98
85
  internal::my_off_t old_link;
99
86
  unsigned char buff[8];
102
89
  info->s->state.key_del[keyinfo->block_size_index]= pos;
103
90
  mi_sizestore(buff,old_link);
104
91
  info->s->state.changed|= STATE_NOT_SORTED_PAGES;
105
 
  return(key_cache_write(info->s->getKeyCache(),
106
 
                              info->s->kfile, pos , level, buff,
107
 
                              sizeof(buff),
108
 
                              (uint) keyinfo->block_length,
109
 
                              (int) (info->lock_type != F_UNLCK)));
 
92
  return not pwrite(info->s->kfile, buff, sizeof(buff), pos);
110
93
} /* _mi_dispose */
111
94
 
112
95
 
113
96
        /* Make new page on disk */
114
97
 
115
 
internal::my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
 
98
internal::my_off_t _mi_new(MI_INFO *info, MI_KEYDEF *keyinfo, int)
116
99
{
117
100
  internal::my_off_t pos;
118
101
  unsigned char buff[8];
129
112
    pos=info->state->key_file_length;
130
113
    info->state->key_file_length+= keyinfo->block_length;
131
114
  }
 
115
  else if (pread(info->s->kfile, buff, sizeof(buff), pos))
 
116
    info->s->state.key_del[keyinfo->block_size_index]= mi_sizekorr(buff);
132
117
  else
133
 
  {
134
 
    if (!key_cache_read(info->s->getKeyCache(),
135
 
                        info->s->kfile, pos, level,
136
 
                        buff,
137
 
                        (uint) sizeof(buff),
138
 
                        (uint) keyinfo->block_length,0))
139
 
      pos= HA_OFFSET_ERROR;
140
 
    else
141
 
      info->s->state.key_del[keyinfo->block_size_index]= mi_sizekorr(buff);
142
 
  }
 
118
    pos= HA_OFFSET_ERROR;
143
119
  info->s->state.changed|= STATE_NOT_SORTED_PAGES;
144
120
  return(pos);
145
121
} /* _mi_new */