~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

  • Committer: Monty Taylor
  • Date: 2008-07-16 19:10:24 UTC
  • mfrom: (51.1.127 remove-dbug)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: monty@inaugust.com-20080716191024-prjgoh7fbri7rx26
MergedĀ fromĀ remove-dbug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  uint count;
35
35
  MYISAM_SHARE *share=info->s;
36
36
  uint flag;
37
 
  DBUG_ENTER("mi_lock_database");
38
 
  DBUG_PRINT("enter",("lock_type: %d  old lock %d  r_locks: %u  w_locks: %u "
39
 
                      "global_changed:  %d  open_count: %u  name: '%s'",
40
 
                      lock_type, info->lock_type, share->r_locks,
41
 
                      share->w_locks,
42
 
                      share->global_changed, share->state.open_count,
43
 
                      share->index_file_name));
 
37
 
44
38
  if (share->options & HA_OPTION_READ_ONLY_DATA ||
45
39
      info->lock_type == lock_type)
46
 
    DBUG_RETURN(0);
 
40
    return(0);
47
41
  if (lock_type == F_EXTRA_LCK)                 /* Used by TMP tables */
48
42
  {
49
43
    ++share->w_locks;
50
44
    ++share->tot_locks;
51
45
    info->lock_type= lock_type;
52
46
    info->s->in_use= list_add(info->s->in_use, &info->in_use);
53
 
    DBUG_RETURN(0);
 
47
    return(0);
54
48
  }
55
49
 
56
50
  flag=error=0;
83
77
      }
84
78
      if (!count)
85
79
      {
86
 
        DBUG_PRINT("info",("changed: %u  w_locks: %u",
87
 
                           (uint) share->changed, share->w_locks));
88
80
        if (share->changed && !share->w_locks)
89
81
        {
90
82
#ifdef HAVE_MMAP
160
152
        if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
161
153
        {
162
154
          error=my_errno;
 
155
          break;
 
156
        }
 
157
        if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
 
158
        {
 
159
          error=my_errno;
163
160
          my_errno=error;
164
161
          break;
165
162
        }
231
228
  myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type),
232
229
                     error);
233
230
#endif
234
 
  DBUG_RETURN(error);
 
231
  return(error);
235
232
} /* mi_lock_database */
236
233
 
237
234
 
252
249
void mi_get_status(void* param, int concurrent_insert)
253
250
{
254
251
  MI_INFO *info=(MI_INFO*) param;
255
 
  DBUG_ENTER("mi_get_status");
256
 
  DBUG_PRINT("info",("key_file: %ld  data_file: %ld  concurrent_insert: %d",
257
 
                     (long) info->s->state.state.key_file_length,
258
 
                     (long) info->s->state.state.data_file_length,
259
 
                     concurrent_insert));
260
 
#ifndef DBUG_OFF
261
 
  if (info->state->key_file_length > info->s->state.state.key_file_length ||
262
 
      info->state->data_file_length > info->s->state.state.data_file_length)
263
 
    DBUG_PRINT("warning",("old info:  key_file: %ld  data_file: %ld",
264
 
                          (long) info->state->key_file_length,
265
 
                          (long) info->state->data_file_length));
266
 
#endif
 
252
 
267
253
  info->save_state=info->s->state.state;
268
254
  info->state= &info->save_state;
269
255
  info->append_insert_at_end= concurrent_insert;
270
 
  DBUG_VOID_RETURN;
 
256
  return;
271
257
}
272
258
 
273
259
 
282
268
  */
283
269
  if (info->state == &info->save_state)
284
270
  {
285
 
#ifndef DBUG_OFF
286
 
    DBUG_PRINT("info",("updating status:  key_file: %ld  data_file: %ld",
287
 
                       (long) info->state->key_file_length,
288
 
                       (long) info->state->data_file_length));
289
 
    if (info->state->key_file_length < info->s->state.state.key_file_length ||
290
 
        info->state->data_file_length < info->s->state.state.data_file_length)
291
 
      DBUG_PRINT("warning",("old info:  key_file: %ld  data_file: %ld",
292
 
                            (long) info->s->state.state.key_file_length,
293
 
                            (long) info->s->state.state.data_file_length));
294
 
#endif
295
271
    info->s->state.state= *info->state;
296
272
    info->state= &info->s->state.state;
297
273
  }
356
332
    external lock (in other words: w_locks == 1 means no other threads has
357
333
    a write lock)
358
334
  */
359
 
  DBUG_PRINT("info",("dellink: %ld  r_locks: %u  w_locks: %u",
360
 
                     (long) info->s->state.dellink, (uint) info->s->r_locks,
361
 
                     (uint) info->s->w_locks));
362
335
  return (my_bool) !(info->s->state.dellink == HA_OFFSET_ERROR ||
363
336
                     (myisam_concurrent_insert == 2 && info->s->r_locks &&
364
337
                      info->s->w_locks == 1));
371
344
 
372
345
int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer)
373
346
{
374
 
  DBUG_ENTER("_mi_readinfo");
375
 
 
376
347
  if (info->lock_type == F_UNLCK)
377
348
  {
378
349
    MYISAM_SHARE *share=info->s;
382
353
      {
383
354
        int error=my_errno ? my_errno : -1;
384
355
        my_errno=error;
385
 
        DBUG_RETURN(1);
 
356
        return(1);
386
357
      }
387
358
    }
388
359
    if (check_keybuffer)
392
363
  else if (lock_type == F_WRLCK && info->lock_type == F_RDLCK)
393
364
  {
394
365
    my_errno=EACCES;                            /* Not allowed to change */
395
 
    DBUG_RETURN(-1);                            /* when have read_lock() */
 
366
    return(-1);                         /* when have read_lock() */
396
367
  }
397
 
  DBUG_RETURN(0);
 
368
  return(0);
398
369
} /* _mi_readinfo */
399
370
 
400
371
 
407
378
{
408
379
  int error,olderror;
409
380
  MYISAM_SHARE *share=info->s;
410
 
  DBUG_ENTER("_mi_writeinfo");
411
 
  DBUG_PRINT("info",("operation: %u  tot_locks: %u", operation,
412
 
                     share->tot_locks));
413
381
 
414
382
  error=0;
415
383
  if (share->tot_locks == 0)
434
402
  }
435
403
  else if (operation)
436
404
    share->changed= 1;                  /* Mark keyfile changed */
437
 
  DBUG_RETURN(error);
 
405
  return(error);
438
406
} /* _mi_writeinfo */
439
407
 
440
408
 
448
416
      share->state.unique  != info->last_unique ||
449
417
      share->state.update_count != info->last_loop)
450
418
  {                                             /* Keyfile has changed */
451
 
    DBUG_PRINT("info",("index file changed"));
452
419
    if (share->state.process != share->this_process)
453
420
      VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE));
454
421
    share->last_process=share->state.process;
485
452
{
486
453
  uchar buff[3];
487
454
  register MYISAM_SHARE *share=info->s;
488
 
  DBUG_ENTER("_mi_mark_file_changed");
489
455
 
490
456
  if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed)
491
457
  {
500
466
    {
501
467
      mi_int2store(buff,share->state.open_count);
502
468
      buff[2]=1;                                /* Mark that it's changed */
503
 
      DBUG_RETURN(my_pwrite(share->kfile,buff,sizeof(buff),
 
469
      return(my_pwrite(share->kfile,buff,sizeof(buff),
504
470
                            sizeof(share->state.header),
505
471
                            MYF(MY_NABP)));
506
472
    }
507
473
  }
508
 
  DBUG_RETURN(0);
 
474
  return(0);
509
475
}
510
476
 
511
477