~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/lock.cc

Merged uint fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
#define GET_LOCK_UNLOCK         1
87
87
#define GET_LOCK_STORE_LOCKS    2
88
88
 
89
 
static DRIZZLE_LOCK *get_lock_data(THD *thd, Table **table,uint count,
90
 
                                 uint flags, Table **write_locked);
91
 
static int lock_external(THD *thd, Table **table,uint count);
92
 
static int unlock_external(THD *thd, Table **table,uint count);
 
89
static DRIZZLE_LOCK *get_lock_data(THD *thd, Table **table,uint32_t count,
 
90
                                 uint32_t flags, Table **write_locked);
 
91
static int lock_external(THD *thd, Table **table,uint32_t count);
 
92
static int unlock_external(THD *thd, Table **table,uint32_t count);
93
93
static void print_lock_error(int error, const char *);
94
94
 
95
95
/*
160
160
}
161
161
 
162
162
 
163
 
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **tables, uint count,
164
 
                              uint flags, bool *need_reopen)
 
163
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **tables, uint32_t count,
 
164
                              uint32_t flags, bool *need_reopen)
165
165
{
166
166
  DRIZZLE_LOCK *sql_lock;
167
167
  Table *write_lock_used;
295
295
}
296
296
 
297
297
 
298
 
static int lock_external(THD *thd, Table **tables, uint count)
 
298
static int lock_external(THD *thd, Table **tables, uint32_t count)
299
299
{
300
 
  register uint i;
 
300
  register uint32_t i;
301
301
  int lock_type,error;
302
302
  for (i=1 ; i <= count ; i++, tables++)
303
303
  {
345
345
  This will work even if get_lock_data fails (next unlock will free all)
346
346
*/
347
347
 
348
 
void mysql_unlock_some_tables(THD *thd, Table **table,uint count)
 
348
void mysql_unlock_some_tables(THD *thd, Table **table,uint32_t count)
349
349
{
350
350
  DRIZZLE_LOCK *sql_lock;
351
351
  Table *write_lock_used;
361
361
 
362
362
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock)
363
363
{
364
 
  uint i,found;
 
364
  uint32_t i,found;
365
365
 
366
366
  /* Move all write locks first */
367
367
  THR_LOCK_DATA **lock=sql_lock->locks;
442
442
    mysql_unlock_some_tables(thd, &table, /* table count */ 1);
443
443
  if (locked)
444
444
  {
445
 
    register uint i;
 
445
    register uint32_t i;
446
446
    for (i=0; i < locked->table_count; i++)
447
447
    {
448
448
      if (locked->table[i] == table)
449
449
      {
450
 
        uint  j, removed_locks, old_tables;
 
450
        uint32_t  j, removed_locks, old_tables;
451
451
        Table *tbl;
452
 
        uint lock_data_end;
 
452
        uint32_t lock_data_end;
453
453
 
454
454
        assert(table->lock_position == i);
455
455
 
508
508
  if ((locked = get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK,
509
509
                              &write_lock_used)))
510
510
  {
511
 
    for (uint i=0; i < locked->lock_count; i++)
 
511
    for (uint32_t i=0; i < locked->lock_count; i++)
512
512
      thr_downgrade_write_lock(locked->locks[i], new_lock_type);
513
513
    free((unsigned char*) locked);
514
514
  }
525
525
  if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK,
526
526
                             &write_lock_used)))
527
527
  {
528
 
    for (uint i=0; i < locked->lock_count; i++)
 
528
    for (uint32_t i=0; i < locked->lock_count; i++)
529
529
      thr_abort_locks(locked->locks[i]->lock, upgrade_lock);
530
530
    free((unsigned char*) locked);
531
531
  }
554
554
  if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK,
555
555
                             &write_lock_used)))
556
556
  {
557
 
    for (uint i=0; i < locked->lock_count; i++)
 
557
    for (uint32_t i=0; i < locked->lock_count; i++)
558
558
    {
559
559
      if (thr_abort_locks_for_thread(locked->locks[i]->lock,
560
560
                                     table->in_use->thread_id))
710
710
 
711
711
/** Unlock a set of external. */
712
712
 
713
 
static int unlock_external(THD *thd, Table **table,uint count)
 
713
static int unlock_external(THD *thd, Table **table,uint32_t count)
714
714
{
715
715
  int error,error_code;
716
716
 
743
743
  @param write_lock_used   Store pointer to last table with WRITE_ALLOW_WRITE
744
744
*/
745
745
 
746
 
static DRIZZLE_LOCK *get_lock_data(THD *thd, Table **table_ptr, uint count,
747
 
                                 uint flags, Table **write_lock_used)
 
746
static DRIZZLE_LOCK *get_lock_data(THD *thd, Table **table_ptr, uint32_t count,
 
747
                                 uint32_t flags, Table **write_lock_used)
748
748
{
749
 
  uint i,tables,lock_count;
 
749
  uint32_t i,tables,lock_count;
750
750
  DRIZZLE_LOCK *sql_lock;
751
751
  THR_LOCK_DATA **locks, **locks_buf, **locks_start;
752
752
  Table **to, **table_buf;
910
910
  Table *table;
911
911
  char  key[MAX_DBKEY_LENGTH];
912
912
  char *db= table_list->db;
913
 
  uint  key_length;
 
913
  uint32_t  key_length;
914
914
  bool  found_locked_table= false;
915
915
  HASH_SEARCH_STATE state;
916
916
 
1114
1114
                                                TableList *table_list)
1115
1115
{
1116
1116
  char  key[MAX_DBKEY_LENGTH];
1117
 
  uint  key_length;
 
1117
  uint32_t  key_length;
1118
1118
 
1119
1119
  key_length= create_table_def_key(thd, key, table_list, 0);
1120
1120
 
1300
1300
 
1301
1301
****************************************************************************/
1302
1302
 
1303
 
volatile uint global_read_lock=0;
1304
 
volatile uint global_read_lock_blocks_commit=0;
1305
 
static volatile uint protect_against_global_read_lock=0;
1306
 
static volatile uint waiting_for_read_lock=0;
 
1303
volatile uint32_t global_read_lock=0;
 
1304
volatile uint32_t global_read_lock_blocks_commit=0;
 
1305
static volatile uint32_t protect_against_global_read_lock=0;
 
1306
static volatile uint32_t waiting_for_read_lock=0;
1307
1307
 
1308
1308
#define GOT_GLOBAL_READ_LOCK               1
1309
1309
#define MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT 2
1344
1344
 
1345
1345
void unlock_global_read_lock(THD *thd)
1346
1346
{
1347
 
  uint tmp;
 
1347
  uint32_t tmp;
1348
1348
 
1349
1349
  pthread_mutex_lock(&LOCK_global_read_lock);
1350
1350
  tmp= --global_read_lock;
1508
1508
 
1509
1509
int try_transactional_lock(THD *thd, TableList *table_list)
1510
1510
{
1511
 
  uint          dummy_counter;
 
1511
  uint32_t          dummy_counter;
1512
1512
  int           error;
1513
1513
  int           result= 0;
1514
1514