~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Lee Bieber
  • Date: 2011-03-23 23:16:25 UTC
  • mfrom: (2247.1.2 build)
  • Revision ID: kalebral@gmail.com-20110323231625-61k77qbh7n1iu776
Merge Olaf - Use BOOST_FOREACH
Merge Olaf - Remove std::nothrow from new()

Show diffs side-by-side

added added

removed removed

Lines of Context:
421
421
    transaction_services.rollbackTransaction(*this, true);
422
422
  }
423
423
 
424
 
  for (UserVars::iterator iter= user_vars.begin();
425
 
       iter != user_vars.end();
426
 
       iter++)
427
 
  {
428
 
    user_var_entry *entry= iter->second;
429
 
    boost::checked_delete(entry);
430
 
  }
 
424
  BOOST_FOREACH(UserVars::reference iter, user_vars)
 
425
    boost::checked_delete(iter.second);
431
426
  user_vars.clear();
432
427
 
433
428
 
1798
1793
 
1799
1794
void Open_tables_state::nukeTable(Table *table)
1800
1795
{
1801
 
  plugin::StorageEngine *table_type= table->getShare()->db_type();
1802
 
 
 
1796
  plugin::StorageEngine& table_type= *table->getShare()->db_type();
1803
1797
  table->free_io_cache();
1804
1798
  table->delete_table();
1805
 
 
1806
 
  identifier::Table identifier(table->getShare()->getSchemaName(), table->getShare()->getTableName(), table->getShare()->getPath());
1807
 
  rm_temporary_table(table_type, identifier);
1808
 
 
 
1799
  rm_temporary_table(table_type, identifier::Table(table->getShare()->getSchemaName(), table->getShare()->getTableName(), table->getShare()->getPath()));
1809
1800
  boost::checked_delete(table->getMutableShare());
1810
 
 
1811
1801
  boost::checked_delete(table);
1812
1802
}
1813
1803
 
1840
1830
  if (not create_if_not_exists)
1841
1831
    return NULL;
1842
1832
 
1843
 
  user_var_entry *entry= NULL;
1844
 
  entry= new (nothrow) user_var_entry(name.c_str(), query_id);
1845
 
 
1846
 
  if (entry == NULL)
1847
 
    return NULL;
 
1833
  user_var_entry *entry= new user_var_entry(name.c_str(), query_id);
1848
1834
 
1849
1835
  std::pair<UserVars::iterator, bool> returnable= user_vars.insert(make_pair(name, entry));
1850
1836
 
1995
1981
 
1996
1982
bool Open_tables_state::rm_temporary_table(const identifier::Table &identifier, bool best_effort)
1997
1983
{
1998
 
  if (not plugin::StorageEngine::dropTable(*static_cast<Session *>(this), identifier))
1999
 
  {
2000
 
    if (not best_effort)
2001
 
    {
2002
 
      std::string path;
2003
 
      identifier.getSQLPath(path);
2004
 
      errmsg_printf(error::WARN, _("Could not remove temporary table: '%s', error: %d"),
2005
 
                    path.c_str(), errno);
2006
 
    }
2007
 
 
2008
 
    return true;
2009
 
  }
2010
 
 
2011
 
  return false;
 
1984
  if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), identifier))
 
1985
                return false;
 
1986
  if (not best_effort)
 
1987
    errmsg_printf(error::WARN, _("Could not remove temporary table: '%s', error: %d"), identifier.getSQLPath().c_str(), errno);
 
1988
  return true;
2012
1989
}
2013
1990
 
2014
 
bool Open_tables_state::rm_temporary_table(plugin::StorageEngine *base, const identifier::Table &identifier)
 
1991
bool Open_tables_state::rm_temporary_table(plugin::StorageEngine& base, const identifier::Table &identifier)
2015
1992
{
2016
1993
  drizzled::error_t error;
2017
 
  assert(base);
2018
 
 
2019
 
  if (not plugin::StorageEngine::dropTable(*static_cast<Session *>(this), *base, identifier, error))
2020
 
  {
2021
 
    std::string path;
2022
 
    identifier.getSQLPath(path);
2023
 
    errmsg_printf(error::WARN, _("Could not remove temporary table: '%s', error: %d"),
2024
 
                  path.c_str(), error);
2025
 
 
2026
 
    return true;
2027
 
  }
2028
 
 
2029
 
  return false;
2030
 
}
2031
 
 
2032
 
/**
2033
 
  @note this will be removed, I am looking through Hudson to see if it is finding
2034
 
  any tables that are missed during cleanup.
2035
 
*/
2036
 
void Open_tables_state::dumpTemporaryTableNames(const char *foo)
2037
 
{
2038
 
  Table *table;
2039
 
 
2040
 
  if (not temporary_tables)
2041
 
    return;
2042
 
 
2043
 
  cerr << "Begin Run: " << foo << "\n";
2044
 
  for (table= temporary_tables; table; table= table->getNext())
2045
 
  {
2046
 
    bool have_proto= false;
2047
 
 
2048
 
    message::Table *proto= table->getShare()->getTableMessage();
2049
 
    if (table->getShare()->getTableMessage())
2050
 
      have_proto= true;
2051
 
 
2052
 
    const char *answer= have_proto ? "true" : "false";
2053
 
 
2054
 
    if (have_proto)
2055
 
    {
2056
 
      cerr << "\tTable Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n";
2057
 
      cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
2058
 
    }
2059
 
    else
2060
 
    {
2061
 
      cerr << "\tTabl;e Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n";
2062
 
    }
2063
 
  }
 
1994
  if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), base, identifier, error))
 
1995
                return false;
 
1996
  errmsg_printf(error::WARN, _("Could not remove temporary table: '%s', error: %d"), identifier.getSQLPath().c_str(), error);
 
1997
  return true;
2064
1998
}
2065
1999
 
2066
2000
table::Singular& Session::getInstanceTable()