~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/lock.cc

  • Committer: Brian Aker
  • Date: 2010-10-19 04:37:10 UTC
  • mto: (1861.1.2 build) (1864.2.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1862.
  • Revision ID: brian@tangent.org-20101019043710-anbhydvze74xvesn
A few cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
      This is followed by a call to thr_multi_lock() for all tables.
35
35
 
36
36
  - When statement is done, we call mysql_unlock_tables().
37
 
    This will call thr_multi_unlock() followed by
 
37
    This will call DrizzleLock::unlock() followed by
38
38
    table_handler->external_lock(session, F_UNLCK) for each table.
39
39
 
40
40
  - Note that mysql_unlock_tables() may be called several times as
164
164
static void reset_lock_data_and_free(DrizzleLock **mysql_lock)
165
165
{
166
166
  DrizzleLock *sql_lock= *mysql_lock;
167
 
  THR_LOCK_DATA **ldata, **ldata_end;
168
 
 
169
 
  /* Clear the lock type of all lock data to avoid reusage. */
170
 
  for (ldata= sql_lock->getLocks(), ldata_end= ldata + sql_lock->lock_count;
171
 
       ldata < ldata_end;
172
 
       ldata++)
173
 
  {
174
 
    /* Reset lock type. */
175
 
    (*ldata)->type= TL_UNLOCK;
176
 
  }
 
167
  sql_lock->reset();
177
168
  delete sql_lock;
178
169
  *mysql_lock= 0;
179
170
}
180
171
 
 
172
void DrizzleLock::reset(void)
 
173
{
 
174
  for (std::vector<THR_LOCK_DATA *>::iterator iter= locks.begin(); iter != locks.end(); iter++)
 
175
  {
 
176
    (*iter)->type= TL_UNLOCK;
 
177
  }
 
178
}
 
179
 
181
180
 
182
181
DrizzleLock *mysql_lock_tables(Session *session, Table **tables, uint32_t count,
183
182
                                uint32_t flags, bool *need_reopen)
296
295
 
297
296
    /* going to retry, unlock all tables */
298
297
    if (sql_lock->lock_count)
299
 
        thr_multi_unlock(sql_lock->getLocks(), sql_lock->lock_count);
 
298
        sql_lock->unlock(sql_lock->lock_count);
300
299
 
301
300
    if (sql_lock->table_count)
302
301
      unlock_external(session, sql_lock->getTable(), sql_lock->table_count);
375
374
void mysql_unlock_tables(Session *session, DrizzleLock *sql_lock)
376
375
{
377
376
  if (sql_lock->lock_count)
378
 
    thr_multi_unlock(sql_lock->getLocks(), sql_lock->lock_count);
 
377
    sql_lock->unlock(sql_lock->lock_count);
379
378
  if (sql_lock->table_count)
380
379
    unlock_external(session, sql_lock->getTable(), sql_lock->table_count);
381
380
  delete sql_lock;
419
418
  /* unlock the read locked tables */
420
419
  if (i != found)
421
420
  {
422
 
    thr_multi_unlock(lock,i-found);
 
421
    sql_lock->unlock(i - found);
423
422
    sql_lock->lock_count= found;
424
423
  }
425
424