~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-03-27 04:12:14 UTC
  • mfrom: (1395.1.18 build)
  • Revision ID: brian@gaz-20100327041214-2pm5eay51312xjvq
Merge (fixes known issues in ALTER TABLE not resetting correctly DFE).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1760
1760
  Table *table;
1761
1761
  Table *tmp_next;
1762
1762
 
1763
 
  if (!temporary_tables)
 
1763
  if (not temporary_tables)
1764
1764
    return;
1765
1765
 
1766
1766
  for (table= temporary_tables; table; table= tmp_next)
1767
1767
  {
1768
1768
    tmp_next= table->next;
1769
 
    close_temporary(table);
 
1769
    nukeTable(table);
1770
1770
  }
1771
1771
  temporary_tables= NULL;
1772
1772
}
1796
1796
    if (temporary_tables)
1797
1797
      table->next->prev= NULL;
1798
1798
  }
1799
 
  close_temporary(table);
 
1799
  nukeTable(table);
1800
1800
}
1801
1801
 
1802
1802
/*
1803
 
  Close and delete a temporary table
 
1803
  Close and drop a temporary table
1804
1804
 
1805
1805
  NOTE
1806
1806
  This dosn't unlink table from session->temporary
1807
1807
  If this is needed, use close_temporary_table()
1808
1808
*/
1809
1809
 
1810
 
void Session::close_temporary(Table *table)
 
1810
void Session::nukeTable(Table *table)
1811
1811
{
1812
1812
  plugin::StorageEngine *table_type= table->s->db_type();
1813
1813
 
1814
1814
  table->free_io_cache();
1815
1815
  table->closefrm(false);
1816
1816
 
1817
 
  rm_temporary_table(table_type, table->s->path.str);
 
1817
  TableIdentifier identifier(table->s->getSchemaName(), table->s->table_name.str, table->s->path.str);
 
1818
  rm_temporary_table(table_type, identifier);
1818
1819
 
1819
1820
  table->s->free_table_share();
1820
1821
 
2033
2034
 
2034
2035
bool Session::rm_temporary_table(TableIdentifier &identifier)
2035
2036
{
2036
 
  if (not plugin::StorageEngine::dropTable(*this, identifier))
 
2037
  if (plugin::StorageEngine::dropTable(*this, identifier))
2037
2038
  {
2038
2039
    errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),
2039
 
                  identifier.getPath().c_str(), errno);
 
2040
                  identifier.getSQLPath().c_str(), errno);
 
2041
    dumpTemporaryTableNames("rm_temporary_table()");
2040
2042
 
2041
2043
    return true;
2042
2044
  }
2044
2046
  return false;
2045
2047
}
2046
2048
 
2047
 
bool Session::rm_temporary_table(plugin::StorageEngine *base, const char *path)
 
2049
bool Session::rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier)
2048
2050
{
2049
 
  bool error= false;
2050
 
  TableIdentifier dummy(path);
2051
 
 
2052
2051
  assert(base);
2053
2052
 
2054
 
  if (delete_table_proto_file(path))
2055
 
    error= true;
2056
 
 
2057
 
  if (base->doDropTable(*this, dummy))
 
2053
  if (plugin::StorageEngine::dropTable(*this, *base, identifier))
2058
2054
  {
2059
 
    error= true;
2060
2055
    errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),
2061
 
                  path, errno);
2062
 
  }
2063
 
  return error;
 
2056
                  identifier.getSQLPath().c_str(), errno);
 
2057
    dumpTemporaryTableNames("rm_temporary_table()");
 
2058
 
 
2059
    return true;
 
2060
  }
 
2061
 
 
2062
  return false;
 
2063
}
 
2064
 
 
2065
/**
 
2066
  @note this will be removed, I am looking through Hudson to see if it is finding
 
2067
  any tables that are missed during cleanup.
 
2068
*/
 
2069
void Session::dumpTemporaryTableNames(const char *foo)
 
2070
{
 
2071
  Table *table;
 
2072
 
 
2073
  if (not temporary_tables)
 
2074
    return;
 
2075
 
 
2076
  cerr << "Begin Run: " << foo << "\n";
 
2077
  for (table= temporary_tables; table; table= table->next)
 
2078
  {
 
2079
    bool have_proto= false;
 
2080
 
 
2081
    message::Table *proto= table->s->getTableProto();
 
2082
    if (table->s->getTableProto())
 
2083
      have_proto= true;
 
2084
 
 
2085
    const char *answer= have_proto ? "true" : "false";
 
2086
 
 
2087
    if (have_proto)
 
2088
    {
 
2089
      cerr << "\tTable Name " << table->s->getSchemaName() << "." << table->s->table_name.str << " : " << answer << "\n";
 
2090
      cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
 
2091
    }
 
2092
    else
 
2093
      cerr << "\tTabl;e Name " << table->s->getSchemaName() << "." << table->s->table_name.str << " : " << answer << "\n";
 
2094
  }
2064
2095
}
2065
2096
 
2066
2097
bool Session::storeTableMessage(TableIdentifier &identifier, message::Table &table_message)
2125
2156
    return false;
2126
2157
  }
2127
2158
 
2128
 
  to.copyToTableMessage((*iter).second);
2129
 
 
2130
 
  (void)removeTableMessage(from);
 
2159
  (*iter).second.set_schema(to.getSchemaName());
 
2160
  (*iter).second.set_name(to.getTableName());
2131
2161
 
2132
2162
  return true;
2133
2163
}