~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Olaf van der Spek
  • Date: 2011-05-04 07:49:55 UTC
  • mfrom: (2300 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2301.
  • Revision ID: olafvdspek@gmail.com-20110504074955-q0mp7zhhuaxs70gz
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
  move one table to free list
281
281
*/
282
282
 
283
 
bool Session::free_cached_table(boost::mutex::scoped_lock &scopedLock)
 
283
bool Open_tables_state::free_cached_table()
284
284
{
285
 
  bool found_old_table= false;
286
 
 
287
 
  (void)scopedLock;
288
 
 
289
 
  table::Concurrent *table= static_cast<table::Concurrent *>(open_tables.open_tables_);
 
285
  table::Concurrent *table= static_cast<table::Concurrent *>(open_tables_);
290
286
 
291
287
  safe_mutex_assert_owner(table::Cache::mutex().native_handle());
292
288
  assert(table->key_read == 0);
293
 
  assert(!table->cursor || table->cursor->inited == Cursor::NONE);
 
289
  assert(not table->cursor || table->cursor->inited == Cursor::NONE);
294
290
 
295
 
  open_tables.open_tables_= table->getNext();
 
291
  open_tables_= table->getNext();
296
292
 
297
293
  if (table->needs_reopen_or_name_lock() ||
298
 
      open_tables.version != g_refresh_version || !table->db_stat)
 
294
      version != g_refresh_version || !table->db_stat)
299
295
  {
300
296
    table::remove_table(table);
301
 
    found_old_table= true;
302
 
  }
303
 
  else
304
 
  {
305
 
    /*
306
 
      Open placeholders have Table::db_stat set to 0, so they should be
307
 
      handled by the first alternative.
308
 
    */
309
 
    assert(not table->open_placeholder);
310
 
 
311
 
    /* Free memory and reset for next loop */
312
 
    table->cursor->ha_reset();
313
 
    table->in_use= NULL;
314
 
 
315
 
    table::getUnused().link(table);
316
 
  }
317
 
 
318
 
  return found_old_table;
 
297
    return true;
 
298
  }
 
299
  /*
 
300
    Open placeholders have Table::db_stat set to 0, so they should be
 
301
    handled by the first alternative.
 
302
  */
 
303
  assert(not table->open_placeholder);
 
304
 
 
305
  /* Free memory and reset for next loop */
 
306
  table->cursor->ha_reset();
 
307
  table->in_use= NULL;
 
308
 
 
309
  table::getUnused().link(table);
 
310
  return false;
319
311
}
320
312
 
321
313
 
327
319
  @remark It should not ordinarily be called directly.
328
320
*/
329
321
 
330
 
void Session::close_open_tables()
 
322
void Open_tables_state::close_open_tables()
331
323
{
332
324
  bool found_old_table= false;
333
325
 
335
327
 
336
328
  boost::mutex::scoped_lock scoped_lock(table::Cache::mutex()); /* Close all open tables on Session */
337
329
 
338
 
  while (open_tables.open_tables_)
 
330
  while (open_tables_)
339
331
  {
340
 
    found_old_table|= free_cached_table(scoped_lock);
 
332
    found_old_table|= free_cached_table();
341
333
  }
342
 
 
343
334
  if (found_old_table)
344
335
  {
345
336
    /* Tell threads waiting for refresh that something has happened */