~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-09 15:32:03 UTC
  • mto: (2278.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2272.
  • Revision ID: olafvdspek@gmail.com-20110409153203-imb5oj47jvwk4mqf
Open Tables

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
  typedef session::PropertyMap properties_t;
155
155
  typedef std::map<std::string, plugin::EventObserverList*> schema_event_observers_t;
156
156
 
 
157
  impl_c(Session& session) :
 
158
    open_tables(session, g_refresh_version)
 
159
  {
 
160
  }
 
161
 
157
162
  Diagnostics_area diagnostics;
158
163
  /**
159
164
    The lex to hold the parsed tree of conventional (non-prepared) queries.
162
167
    the same lex. (@see mysql_parse for details).
163
168
  */
164
169
  LEX lex;
 
170
  Open_tables_state open_tables;
165
171
  properties_t properties;
166
172
  schema_event_observers_t schema_event_observers;
167
173
  system_status_var status_var;
172
178
};
173
179
 
174
180
Session::Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog_arg) :
175
 
  Open_tables_state(*this, g_refresh_version),
176
 
  impl_(new impl_c),
 
181
  impl_(new impl_c(*this)),
177
182
  mem_root(&main_mem_root),
178
183
  query(new std::string),
179
184
  scheduler(NULL),
193
198
  query_id(0),
194
199
  warn_query_id(0),
195
200
        transaction(impl_->transaction),
196
 
  open_tables(*this),
 
201
  open_tables(impl_->open_tables),
197
202
  first_successful_insert_id_in_prev_stmt(0),
198
203
  first_successful_insert_id_in_cur_stmt(0),
199
204
  limit_found_rows(0),
429
434
  user_vars.clear();
430
435
 
431
436
 
432
 
  close_temporary_tables();
 
437
  open_tables.close_temporary_tables();
433
438
 
434
439
  if (global_read_lock)
435
440
  {
580
585
  if (variables.max_join_size == HA_POS_ERROR)
581
586
    options |= OPTION_BIG_SELECTS;
582
587
 
583
 
  version= g_refresh_version;
 
588
  open_tables.version= g_refresh_version;
584
589
  set_proc_info(NULL);
585
590
  command= COM_SLEEP;
586
591
  set_time();
1862
1867
{
1863
1868
  for (Table *table= temporary_tables ; table ; table= table->getNext())
1864
1869
  {
1865
 
    if (table->query_id == getQueryId())
 
1870
    if (table->query_id == session_.getQueryId())
1866
1871
    {
1867
1872
      table->query_id= 0;
1868
1873
      table->cursor->ha_reset();
1893
1898
*/
1894
1899
void Session::close_thread_tables()
1895
1900
{
1896
 
  clearDerivedTables();
 
1901
  open_tables.clearDerivedTables();
1897
1902
 
1898
1903
  /*
1899
1904
    Mark all temporary tables used by this statement as free for reuse.
1900
1905
  */
1901
 
  mark_temp_tables_as_free_for_reuse();
 
1906
  open_tables.mark_temp_tables_as_free_for_reuse();
1902
1907
  /*
1903
1908
    Let us commit transaction for statement. Since in 5.0 we only have
1904
1909
    one statement transaction and don't allow several nested statement
1915
1920
    transaction.stmt.reset();
1916
1921
  }
1917
1922
 
1918
 
  if (lock)
 
1923
  if (open_tables.lock)
1919
1924
  {
1920
1925
    /*
1921
1926
      For RBR we flush the pending event just before we unlock all the
1926
1931
      handled either before writing a query log event (inside
1927
1932
      binlog_query()) or when preparing a pending event.
1928
1933
     */
1929
 
    unlockTables(lock);
1930
 
    lock= 0;
 
1934
    unlockTables(open_tables.lock);
 
1935
    open_tables.lock= 0;
1931
1936
  }
1932
1937
  /*
1933
1938
    Note that we need to hold table::Cache::singleton().mutex() while changing the
1936
1941
    Closing a MERGE child before the parent would be fatal if the
1937
1942
    other thread tries to abort the MERGE lock in between.
1938
1943
  */
1939
 
  if (open_tables_)
 
1944
  if (open_tables.open_tables_)
1940
1945
    close_open_tables();
1941
1946
}
1942
1947