422
422
effect is desired.
425
void mysql_lock_remove(Session *session, DRIZZLE_LOCK *locked,Table *table,
425
void mysql_lock_remove(Session *session, Table *table)
428
if (always_unlock == true)
429
mysql_unlock_some_tables(session, &table, /* table count */ 1);
433
for (i=0; i < locked->table_count; i++)
435
if (locked->table[i] == table)
437
uint32_t j, removed_locks, old_tables;
439
uint32_t lock_data_end;
441
assert(table->lock_position == i);
443
/* Unlock if not yet unlocked */
444
if (always_unlock == false)
445
mysql_unlock_some_tables(session, &table, /* table count */ 1);
447
/* Decrement table_count in advance, making below expressions easier */
448
old_tables= --locked->table_count;
450
/* The table has 'removed_locks' lock data elements in locked->locks */
451
removed_locks= table->lock_count;
453
/* Move down all table pointers above 'i'. */
454
memmove((locked->table+i), (locked->table+i+1),
455
(old_tables - i) * sizeof(Table*));
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*));
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.
472
for (j= i ; j < old_tables; j++)
474
tbl= locked->table[j];
475
tbl->lock_position--;
476
assert(tbl->lock_position == j);
477
tbl->lock_data_start-= removed_locks;
480
/* Finally adjust lock_count. */
481
locked->lock_count-= removed_locks;
427
mysql_unlock_some_tables(session, &table, /* table count */ 1);