~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-05-18 16:00:53 UTC
  • mto: (1552.1.1 new-staging)
  • mto: This revision was merged to the branch mainline in revision 1541.
  • Revision ID: brian@gaz-20100518160053-1e3huv6ofpvuf1y0
Merge of change to flip table instance to be share instance

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include "drizzled/transaction_services.h"
49
49
#include "drizzled/drizzled.h"
50
50
 
 
51
#include "drizzled/table_share_instance.h"
 
52
 
51
53
#include "plugin/myisam/myisam.h"
52
54
#include "drizzled/internal/iocache.h"
53
55
 
827
829
  free_items();
828
830
  /* Reset where. */
829
831
  where= Session::DEFAULT_WHERE;
 
832
 
 
833
  /* Reset the temporary shares we built */
 
834
  for (std::vector<TableShareInstance *>::iterator iter= temporary_shares.begin();
 
835
       iter != temporary_shares.end(); iter++)
 
836
  {
 
837
    delete *iter;
 
838
  }
 
839
  temporary_shares.clear();
830
840
}
831
841
 
832
842
/**
1837
1847
*/
1838
1848
void Session::close_thread_tables()
1839
1849
{
1840
 
  Table *table;
1841
 
 
1842
 
  /*
1843
 
    We are assuming here that session->derived_tables contains ONLY derived
1844
 
    tables for this substatement. i.e. instead of approach which uses
1845
 
    query_id matching for determining which of the derived tables belong
1846
 
    to this substatement we rely on the ability of substatements to
1847
 
    save/restore session->derived_tables during their execution.
1848
 
 
1849
 
    TODO: Probably even better approach is to simply associate list of
1850
 
          derived tables with (sub-)statement instead of thread and destroy
1851
 
          them at the end of its execution.
1852
 
  */
1853
1850
  if (derived_tables)
1854
 
  {
1855
 
    Table *next;
1856
 
    /*
1857
 
      Close all derived tables generated in queries like
1858
 
      SELECT * FROM (SELECT * FROM t1)
1859
 
    */
1860
 
    for (table= derived_tables ; table ; table= next)
1861
 
    {
1862
 
      next= table->next;
1863
 
      table->free_tmp_table(this);
1864
 
    }
1865
 
    derived_tables= 0;
1866
 
  }
 
1851
    derived_tables= NULL; // They should all be invalid by this point
1867
1852
 
1868
1853
  /*
1869
1854
    Mark all temporary tables used by this statement as free for reuse.
2090
2075
  return true;
2091
2076
}
2092
2077
 
 
2078
TableShareInstance *Session::getTemporaryShare()
 
2079
{
 
2080
  temporary_shares.push_back(new TableShareInstance()); // This will not go into the tableshare cache, so no key is used.
 
2081
 
 
2082
  TableShareInstance *tmp_share= temporary_shares.back();
 
2083
 
 
2084
  assert(tmp_share);
 
2085
 
 
2086
  return tmp_share;
 
2087
}
 
2088
 
 
2089
TableShareInstance *Session::getTemporaryShare(const char *tmpname_arg)
 
2090
{
 
2091
  assert(tmpname_arg);
 
2092
 
 
2093
  temporary_shares.push_back(new TableShareInstance(tmpname_arg)); // This will not go into the tableshare cache, so no key is used.
 
2094
 
 
2095
  TableShareInstance *tmp_share= temporary_shares.back();
 
2096
 
 
2097
  assert(tmp_share);
 
2098
 
 
2099
  return tmp_share;
 
2100
}
 
2101
 
2093
2102
} /* namespace drizzled */