~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Lee Bieber
  • Date: 2011-03-13 16:37:38 UTC
  • mfrom: (2227.4.18 session2)
  • Revision ID: kalebral@gmail.com-20110313163738-7ti21zk40o2xi3ew
Merge Olaf - Refactor Session

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
#include <drizzled/util/find_ptr.h>
70
70
#include <plugin/myisam/myisam.h>
71
71
#include <drizzled/item/subselect.h>
 
72
#include <drizzled/statement.h>
72
73
 
73
74
#include <algorithm>
74
75
#include <climits>
141
142
  return session->options & test_options;
142
143
}
143
144
 
 
145
class Session::impl_c
 
146
{
 
147
};
 
148
 
144
149
Session::Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog_arg) :
145
150
  Open_tables_state(refresh_version),
146
151
  mem_root(&main_mem_root),
147
 
  xa_id(0),
148
152
  query(new std::string),
149
153
  _schema(new std::string),
150
154
  client(client_arg),
164
168
  ha_data(plugin::num_trx_monitored_objects),
165
169
  query_id(0),
166
170
  warn_query_id(0),
167
 
  concurrent_execute_allowed(true),
168
 
  arg_of_last_insert_id_function(false),
169
171
  first_successful_insert_id_in_prev_stmt(0),
170
172
  first_successful_insert_id_in_cur_stmt(0),
171
173
  limit_found_rows(0),
189
191
  is_fatal_error(false),
190
192
  transaction_rollback_request(false),
191
193
  is_fatal_sub_stmt_error(0),
192
 
  tablespace_op(false),
193
194
  derived_tables_processing(false),
194
195
  m_lip(NULL),
195
196
  cached_table(0),
 
197
  arg_of_last_insert_id_function(false),
 
198
  _catalog(catalog_arg),
196
199
  transaction_message(NULL),
197
200
  statement_message(NULL),
198
201
  session_event_observers(NULL),
199
 
  _catalog(catalog_arg),
 
202
  xa_id(0),
 
203
  concurrent_execute_allowed(true),
 
204
  tablespace_op(false),
200
205
  use_usage(false)
201
206
{
202
207
  client->setSession(this);
209
214
  memory::init_sql_alloc(&main_mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
210
215
  cuted_fields= sent_row_count= row_count= 0L;
211
216
  // Must be reset to handle error with Session's created for init of mysqld
212
 
  getLex()->current_select= 0;
 
217
  lex().current_select= 0;
213
218
  memset(&variables, 0, sizeof(variables));
214
219
  scoreboard_index= -1;
215
220
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
256
261
 
257
262
void statement::Statement::set_command(enum_sql_command v)
258
263
{
259
 
        session().getLex()->sql_command= v;
 
264
        session().lex().sql_command= v;
260
265
}
261
266
 
262
267
LEX& statement::Statement::lex()
263
268
{
264
 
        return *session().getLex();
 
269
        return session().lex();
265
270
}
266
271
 
267
272
session::Transactions& statement::Statement::transaction()
269
274
        return session().transaction;
270
275
}
271
276
 
 
277
bool Session::add_item_to_list(Item *item)
 
278
{
 
279
  return lex().current_select->add_item_to_list(this, item);
 
280
}
 
281
 
 
282
bool Session::add_value_to_list(Item *value)
 
283
{
 
284
  return lex().value_list.push_back(value);
 
285
}
 
286
 
 
287
bool Session::add_order_to_list(Item *item, bool asc)
 
288
{
 
289
  return lex().current_select->add_order_to_list(this, item, asc);
 
290
}
 
291
 
 
292
bool Session::add_group_to_list(Item *item, bool asc)
 
293
{
 
294
  return lex().current_select->add_group_to_list(this, item, asc);
 
295
}
 
296
 
272
297
void Session::free_items()
273
298
{
274
299
  Item *next;
692
717
    indicator of uninitialized lex => normal flow of errors handling
693
718
    (see my_message_sql)
694
719
  */
695
 
  getLex()->current_select= 0;
 
720
  lex().current_select= 0;
696
721
  clear_error();
697
722
  main_da.reset_diagnostics_area();
698
723
 
932
957
  item->maybe_null=1;
933
958
  field_list.push_back(item= new Item_return_int("rows", 10,
934
959
                                                 DRIZZLE_TYPE_LONGLONG));
935
 
  if (getLex()->describe & DESCRIBE_EXTENDED)
 
960
  if (lex().describe & DESCRIBE_EXTENDED)
936
961
  {
937
962
    field_list.push_back(item= new Item_float("filtered", 0.1234, 2, 4));
938
963
    item->maybe_null=1;
1555
1580
void Session::end_statement()
1556
1581
{
1557
1582
  /* Cleanup SQL processing state to reuse this statement in next query. */
1558
 
  getLex()->end();
 
1583
  lex().end();
1559
1584
  query_cache_key= ""; // reset the cache key
1560
1585
  resetResultsetMessage();
1561
1586
}
1922
1947
    If table list consists only from tables from prelocking set, table list
1923
1948
    for new attempt should be empty, so we have to update list's root pointer.
1924
1949
  */
1925
 
  if (getLex()->first_not_own_table() == *tables)
 
1950
  if (lex().first_not_own_table() == *tables)
1926
1951
    *tables= 0;
1927
 
  getLex()->chop_off_not_own_tables();
 
1952
  lex().chop_off_not_own_tables();
1928
1953
  for (TableList *tmp= *tables; tmp; tmp= tmp->next_global)
1929
1954
    tmp->table= 0;
1930
1955
  close_thread_tables();
1949
1974
    close_tables_for_reopen(&tables);
1950
1975
  }
1951
1976
 
1952
 
  if ((handle_derived(getLex(), &derived_prepare) || (handle_derived(getLex(), &derived_filling))))
1953
 
    return true;
1954
 
 
1955
 
  return false;
 
1977
  return handle_derived(&lex(), &derived_prepare) || handle_derived(&lex(), &derived_filling);
1956
1978
}
1957
1979
 
1958
1980
/*