~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

Merge/fix in FAQ.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
*/
22
22
 
23
23
#include "myisamdef.h"
24
 
#include <mystrings/m_ctype.h>
25
 
#include <mysys/my_tree.h>
26
 
#include <mysys/queues.h>
 
24
#include <m_ctype.h>
 
25
#include <my_tree.h>
 
26
#include <queues.h>
 
27
#include <mysql/plugin.h>
27
28
 
28
29
        /* lock table by F_UNLCK, F_RDLCK or F_WRLCK */
29
30
 
30
31
int mi_lock_database(MI_INFO *info, int lock_type)
31
32
{
32
33
  int error;
33
 
  uint32_t count;
 
34
  uint count;
34
35
  MYISAM_SHARE *share=info->s;
35
 
  uint32_t flag;
 
36
  uint flag;
36
37
 
37
38
  if (share->options & HA_OPTION_READ_ONLY_DATA ||
38
39
      info->lock_type == lock_type)
160
161
          break;
161
162
        }
162
163
      }
163
 
      _mi_test_if_changed(info);
 
164
      VOID(_mi_test_if_changed(info));
164
165
      share->r_locks++;
165
166
      share->tot_locks++;
166
167
      info->lock_type=lock_type;
194
195
          }
195
196
        }
196
197
      }
197
 
      _mi_test_if_changed(info);
 
198
      VOID(_mi_test_if_changed(info));
198
199
        
199
200
      info->lock_type=lock_type;
200
201
      info->invalidator=info->s->invalidator;
224
225
  pthread_mutex_unlock(&share->intern_lock);
225
226
#if defined(FULL_LOG) || defined(_lint)
226
227
  lock_type|=(int) (flag << 8);         /* Set bit to set if real lock */
227
 
  myisam_log_command(MI_LOG_LOCK,info,(unsigned char*) &lock_type,sizeof(lock_type),
 
228
  myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type),
228
229
                     error);
229
230
#endif
230
231
  return(error);
331
332
    external lock (in other words: w_locks == 1 means no other threads has
332
333
    a write lock)
333
334
  */
334
 
  return (bool) !(info->s->state.dellink == HA_OFFSET_ERROR ||
 
335
  return (my_bool) !(info->s->state.dellink == HA_OFFSET_ERROR ||
335
336
                     (myisam_concurrent_insert == 2 && info->s->r_locks &&
336
337
                      info->s->w_locks == 1));
337
338
}
356
357
      }
357
358
    }
358
359
    if (check_keybuffer)
359
 
      _mi_test_if_changed(info);
 
360
      VOID(_mi_test_if_changed(info));
360
361
    info->invalidator=info->s->invalidator;
361
362
  }
362
363
  else if (lock_type == F_WRLCK && info->lock_type == F_RDLCK)
373
374
  request
374
375
*/
375
376
 
376
 
int _mi_writeinfo(register MI_INFO *info, uint32_t operation)
 
377
int _mi_writeinfo(register MI_INFO *info, uint operation)
377
378
{
378
379
  int error,olderror;
379
380
  MYISAM_SHARE *share=info->s;
416
417
      share->state.update_count != info->last_loop)
417
418
  {                                             /* Keyfile has changed */
418
419
    if (share->state.process != share->this_process)
419
 
      flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE);
 
420
      VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE));
420
421
    share->last_process=share->state.process;
421
422
    info->last_unique=  share->state.unique;
422
423
    info->last_loop=    share->state.update_count;
449
450
 
450
451
int _mi_mark_file_changed(MI_INFO *info)
451
452
{
452
 
  unsigned char buff[3];
 
453
  uchar buff[3];
453
454
  register MYISAM_SHARE *share=info->s;
454
455
 
455
456
  if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed)
481
482
 
482
483
int _mi_decrement_open_count(MI_INFO *info)
483
484
{
484
 
  unsigned char buff[2];
 
485
  uchar buff[2];
485
486
  register MYISAM_SHARE *share=info->s;
486
487
  int lock_error=0,write_error=0;
487
488
  if (share->global_changed)
488
489
  {
489
 
    uint32_t old_lock=info->lock_type;
 
490
    uint old_lock=info->lock_type;
490
491
    share->global_changed=0;
491
492
    lock_error=mi_lock_database(info,F_WRLCK);
492
493
    /* Its not fatal even if we couldn't get the lock ! */