~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_dynrec.cc

Merge Stewart.

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
/*
17
17
  Functions to handle space-packed-records and blobs
142
142
size_t mi_mmap_pread(MI_INFO *info, unsigned char *Buffer,
143
143
                    size_t Count, internal::my_off_t offset, myf MyFlags)
144
144
{
 
145
  if (info->s->concurrent_insert)
 
146
    pthread_rwlock_rdlock(&info->s->mmap_lock);
 
147
 
145
148
  /*
146
149
    The following test may fail in the following cases:
147
150
    - We failed to remap a memory area (fragmented memory?)
152
155
  if (info->s->mmaped_length >= offset + Count)
153
156
  {
154
157
    memcpy(Buffer, info->s->file_map + offset, Count);
 
158
    if (info->s->concurrent_insert)
 
159
      pthread_rwlock_unlock(&info->s->mmap_lock);
155
160
    return 0;
156
161
  }
157
162
  else
158
163
  {
 
164
    if (info->s->concurrent_insert)
 
165
      pthread_rwlock_unlock(&info->s->mmap_lock);
159
166
    return my_pread(info->dfile, Buffer, Count, offset, MyFlags);
160
167
  }
161
168
}
189
196
size_t mi_mmap_pwrite(MI_INFO *info, const unsigned char *Buffer,
190
197
                      size_t Count, internal::my_off_t offset, myf MyFlags)
191
198
{
 
199
  if (info->s->concurrent_insert)
 
200
    pthread_rwlock_rdlock(&info->s->mmap_lock);
192
201
 
193
202
  /*
194
203
    The following test may fail in the following cases:
200
209
  if (info->s->mmaped_length >= offset + Count)
201
210
  {
202
211
    memcpy(info->s->file_map + offset, Buffer, Count);
 
212
    if (info->s->concurrent_insert)
 
213
      pthread_rwlock_unlock(&info->s->mmap_lock);
203
214
    return 0;
204
215
  }
205
216
  else
206
217
  {
207
218
    info->s->nonmmaped_inserts++;
 
219
    if (info->s->concurrent_insert)
 
220
      pthread_rwlock_unlock(&info->s->mmap_lock);
208
221
    return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags);
209
222
  }
210
223
 
997
1010
      }
998
1011
      else if (type == FIELD_VARCHAR)
999
1012
      {
1000
 
        uint32_t pack_length= ha_varchar_packlength(rec->length -1);
 
1013
        uint32_t pack_length= HA_VARCHAR_PACKLENGTH(rec->length -1);
1001
1014
        uint32_t tmp_length;
1002
1015
        if (pack_length == 1)
1003
1016
        {
1117
1130
      }
1118
1131
      else if (type == FIELD_VARCHAR)
1119
1132
      {
1120
 
        uint32_t pack_length= ha_varchar_packlength(rec->length -1);
 
1133
        uint32_t pack_length= HA_VARCHAR_PACKLENGTH(rec->length -1);
1121
1134
        uint32_t tmp_length;
1122
1135
        if (pack_length == 1)
1123
1136
        {
1190
1203
    {
1191
1204
      if (type == FIELD_VARCHAR)
1192
1205
      {
1193
 
        uint32_t pack_length= ha_varchar_packlength(rec_length-1);
 
1206
        uint32_t pack_length= HA_VARCHAR_PACKLENGTH(rec_length-1);
1194
1207
        if (pack_length == 1)
1195
1208
        {
1196
1209
          length= (uint) *(unsigned char*) from;