~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Lee Bieber
  • Date: 2010-11-12 19:03:08 UTC
  • mfrom: (1923.1.4 trunk)
  • Revision ID: kalebral@gmail.com-20101112190308-lyejhhgpfaf9r8f3
Merge Brian - Encapsulate up the cache we use in Session for tracking table proto for temp tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1679
1679
  Close all temporary tables created by 'CREATE TEMPORARY TABLE' for thread
1680
1680
*/
1681
1681
 
1682
 
void Session::close_temporary_tables()
 
1682
void Open_tables_state::close_temporary_tables()
1683
1683
{
1684
1684
  Table *table;
1685
1685
  Table *tmp_next;
1699
1699
  unlink from session->temporary tables and close temporary table
1700
1700
*/
1701
1701
 
1702
 
void Session::close_temporary_table(Table *table)
 
1702
void Open_tables_state::close_temporary_table(Table *table)
1703
1703
{
1704
1704
  if (table->getPrev())
1705
1705
  {
1735
1735
  If this is needed, use close_temporary_table()
1736
1736
*/
1737
1737
 
1738
 
void Session::nukeTable(Table *table)
 
1738
void Open_tables_state::nukeTable(Table *table)
1739
1739
{
1740
1740
  plugin::StorageEngine *table_type= table->getShare()->db_type();
1741
1741
 
1809
1809
                              DERIVATION_IMPLICIT, false);
1810
1810
}
1811
1811
 
1812
 
void Session::mark_temp_tables_as_free_for_reuse()
 
1812
void Open_tables_state::mark_temp_tables_as_free_for_reuse()
1813
1813
{
1814
1814
  for (Table *table= temporary_tables ; table ; table= table->getNext())
1815
1815
  {
1816
 
    if (table->query_id == query_id)
 
1816
    if (table->query_id == getQueryId())
1817
1817
    {
1818
1818
      table->query_id= 0;
1819
1819
      table->cursor->ha_reset();
1825
1825
{
1826
1826
  for (; table ; table= table->getNext())
1827
1827
  {
1828
 
    if (table->query_id == query_id)
 
1828
    if (table->query_id == getQueryId())
1829
1829
    {
1830
1830
      table->query_id= 0;
1831
1831
      table->cursor->ha_reset();
1844
1844
*/
1845
1845
void Session::close_thread_tables()
1846
1846
{
1847
 
  if (derived_tables)
1848
 
    derived_tables= NULL; // They should all be invalid by this point
 
1847
  clearDerivedTables();
1849
1848
 
1850
1849
  /*
1851
1850
    Mark all temporary tables used by this statement as free for reuse.
1936
1935
  might be an issue (lame engines).
1937
1936
*/
1938
1937
 
1939
 
bool Session::rm_temporary_table(TableIdentifier &identifier, bool best_effort)
 
1938
bool Open_tables_state::rm_temporary_table(TableIdentifier &identifier, bool best_effort)
1940
1939
{
1941
 
  if (plugin::StorageEngine::dropTable(*this, identifier))
 
1940
  if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), identifier))
1942
1941
  {
1943
1942
    if (not best_effort)
1944
1943
    {
1952
1951
  return false;
1953
1952
}
1954
1953
 
1955
 
bool Session::rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier)
 
1954
bool Open_tables_state::rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier)
1956
1955
{
1957
1956
  assert(base);
1958
1957
 
1959
 
  if (plugin::StorageEngine::dropTable(*this, *base, identifier))
 
1958
  if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), *base, identifier))
1960
1959
  {
1961
1960
    errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),
1962
1961
                  identifier.getSQLPath().c_str(), errno);
1971
1970
  @note this will be removed, I am looking through Hudson to see if it is finding
1972
1971
  any tables that are missed during cleanup.
1973
1972
*/
1974
 
void Session::dumpTemporaryTableNames(const char *foo)
 
1973
void Open_tables_state::dumpTemporaryTableNames(const char *foo)
1975
1974
{
1976
1975
  Table *table;
1977
1976
 
1999
1998
  }
2000
1999
}
2001
2000
 
2002
 
bool Session::storeTableMessage(const TableIdentifier &identifier, message::Table &table_message)
 
2001
bool Session::TableMessages::storeTableMessage(const TableIdentifier &identifier, message::Table &table_message)
2003
2002
{
2004
2003
  table_message_cache.insert(make_pair(identifier.getPath(), table_message));
2005
2004
 
2006
2005
  return true;
2007
2006
}
2008
2007
 
2009
 
bool Session::removeTableMessage(const TableIdentifier &identifier)
 
2008
bool Session::TableMessages::removeTableMessage(const TableIdentifier &identifier)
2010
2009
{
2011
2010
  TableMessageCache::iterator iter;
2012
2011
 
2020
2019
  return true;
2021
2020
}
2022
2021
 
2023
 
bool Session::getTableMessage(const TableIdentifier &identifier, message::Table &table_message)
 
2022
bool Session::TableMessages::getTableMessage(const TableIdentifier &identifier, message::Table &table_message)
2024
2023
{
2025
2024
  TableMessageCache::iterator iter;
2026
2025
 
2034
2033
  return true;
2035
2034
}
2036
2035
 
2037
 
bool Session::doesTableMessageExist(const TableIdentifier &identifier)
 
2036
bool Session::TableMessages::doesTableMessageExist(const TableIdentifier &identifier)
2038
2037
{
2039
2038
  TableMessageCache::iterator iter;
2040
2039
 
2048
2047
  return true;
2049
2048
}
2050
2049
 
2051
 
bool Session::renameTableMessage(const TableIdentifier &from, const TableIdentifier &to)
 
2050
bool Session::TableMessages::renameTableMessage(const TableIdentifier &from, const TableIdentifier &to)
2052
2051
{
2053
2052
  TableMessageCache::iterator iter;
2054
2053