~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/lock.cc

  • Committer: Brian Aker
  • Date: 2009-08-10 23:36:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1114.
  • Revision ID: brian@gaz-20090810233655-19olqn5iu8dhos6f
Dead code removal around LCOV finds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
 
163
163
 
164
164
DRIZZLE_LOCK *mysql_lock_tables(Session *session, Table **tables, uint32_t count,
165
 
                              uint32_t flags, bool *need_reopen)
 
165
                                uint32_t flags, bool *need_reopen)
166
166
{
167
167
  DRIZZLE_LOCK *sql_lock;
168
168
  Table *write_lock_used;
332
332
  This will work even if get_lock_data fails (next unlock will free all)
333
333
*/
334
334
 
335
 
void mysql_unlock_some_tables(Session *session, Table **table,uint32_t count)
 
335
void mysql_unlock_some_tables(Session *session, Table **table, uint32_t count)
336
336
{
337
337
  DRIZZLE_LOCK *sql_lock;
338
338
  Table *write_lock_used;
422
422
                          effect is desired.
423
423
*/
424
424
 
425
 
void mysql_lock_remove(Session *session, DRIZZLE_LOCK *locked,Table *table,
426
 
                       bool always_unlock)
 
425
void mysql_lock_remove(Session *session, Table *table)
427
426
{
428
 
  if (always_unlock == true)
429
 
    mysql_unlock_some_tables(session, &table, /* table count */ 1);
430
 
  if (locked)
431
 
  {
432
 
    register uint32_t i;
433
 
    for (i=0; i < locked->table_count; i++)
434
 
    {
435
 
      if (locked->table[i] == table)
436
 
      {
437
 
        uint32_t  j, removed_locks, old_tables;
438
 
        Table *tbl;
439
 
        uint32_t lock_data_end;
440
 
 
441
 
        assert(table->lock_position == i);
442
 
 
443
 
        /* Unlock if not yet unlocked */
444
 
        if (always_unlock == false)
445
 
          mysql_unlock_some_tables(session, &table, /* table count */ 1);
446
 
 
447
 
        /* Decrement table_count in advance, making below expressions easier */
448
 
        old_tables= --locked->table_count;
449
 
 
450
 
        /* The table has 'removed_locks' lock data elements in locked->locks */
451
 
        removed_locks= table->lock_count;
452
 
 
453
 
        /* Move down all table pointers above 'i'. */
454
 
        memmove((locked->table+i), (locked->table+i+1),
455
 
                (old_tables - i) * sizeof(Table*));
456
 
 
457
 
        lock_data_end= table->lock_data_start + table->lock_count;
458
 
        /* Move down all lock data pointers above 'table->lock_data_end-1' */
459
 
        memmove((locked->locks + table->lock_data_start),
460
 
                (locked->locks + lock_data_end),
461
 
                (locked->lock_count - lock_data_end) *
462
 
                sizeof(THR_LOCK_DATA*));
463
 
 
464
 
        /*
465
 
          Fix moved table elements.
466
 
          lock_position is the index in the 'locked->table' array,
467
 
          it must be fixed by one.
468
 
          table->lock_data_start is pointer to the lock data for this table
469
 
          in the 'locked->locks' array, they must be fixed by 'removed_locks',
470
 
          the lock data count of the removed table.
471
 
        */
472
 
        for (j= i ; j < old_tables; j++)
473
 
        {
474
 
          tbl= locked->table[j];
475
 
          tbl->lock_position--;
476
 
          assert(tbl->lock_position == j);
477
 
          tbl->lock_data_start-= removed_locks;
478
 
        }
479
 
 
480
 
        /* Finally adjust lock_count. */
481
 
        locked->lock_count-= removed_locks;
482
 
        break;
483
 
      }
484
 
    }
485
 
  }
 
427
  mysql_unlock_some_tables(session, &table, /* table count */ 1);
486
428
}
487
429
 
488
430