~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Mark Atwood
  • Date: 2011-06-22 20:04:22 UTC
  • mfrom: (2318.6.39 rf)
  • Revision ID: me@mark.atwood.name-20110622200422-609npl456o0e5p32
mergeĀ lp:~olafvdspek/drizzle/refactor13

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
 
193
193
Session::Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog_arg) :
194
194
  impl_(new impl_c(*this)),
 
195
  mem(impl_->mem_root),
195
196
  mem_root(&impl_->mem_root),
196
197
  query(new std::string),
197
198
  scheduler(NULL),
246
247
  client->setSession(this);
247
248
 
248
249
  /*
249
 
    Pass nominal parameters to init_alloc_root only to ensure that
 
250
    Pass nominal parameters to init only to ensure that
250
251
    the destructor works OK in case of an error. The main_mem_root
251
252
    will be re-initialized in init_for_queries().
252
253
  */
253
 
  memory::init_sql_alloc(mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
 
254
  mem.init(memory::ROOT_MIN_BLOCK_SIZE);
254
255
  cuted_fields= sent_row_count= row_count= 0L;
255
256
  // Must be reset to handle error with Session's created for init of mysqld
256
257
  lex().current_select= 0;
288
289
  memset(&status_var, 0, sizeof(status_var));
289
290
 
290
291
  /* Initialize sub structures */
291
 
  memory::init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
 
292
  warn_root.init(WARN_ALLOC_BLOCK_SIZE);
292
293
 
293
294
  substitute_null_with_insert_id = false;
294
295
  lock_info.init(); /* safety: will be reset after start */
337
338
        return session().transaction;
338
339
}
339
340
 
340
 
bool Session::add_item_to_list(Item *item)
 
341
void Session::add_item_to_list(Item *item)
341
342
{
342
 
  return lex().current_select->add_item_to_list(this, item);
 
343
  lex().current_select->add_item_to_list(this, item);
343
344
}
344
345
 
345
 
bool Session::add_value_to_list(Item *value)
 
346
void Session::add_value_to_list(Item *value)
346
347
{
347
348
        lex().value_list.push_back(value);
348
 
  return false;
349
 
}
350
 
 
351
 
bool Session::add_order_to_list(Item *item, bool asc)
352
 
{
353
 
  return lex().current_select->add_order_to_list(this, item, asc);
354
 
}
355
 
 
356
 
bool Session::add_group_to_list(Item *item, bool asc)
357
 
{
358
 
  return lex().current_select->add_group_to_list(this, item, asc);
 
349
}
 
350
 
 
351
void Session::add_order_to_list(Item *item, bool asc)
 
352
{
 
353
  lex().current_select->add_order_to_list(this, item, asc);
 
354
}
 
355
 
 
356
void Session::add_group_to_list(Item *item, bool asc)
 
357
{
 
358
  lex().current_select->add_group_to_list(this, item, asc);
359
359
}
360
360
 
361
361
void Session::free_items()
362
362
{
363
 
  Item *next;
364
363
  /* This works because items are allocated with memory::sql_alloc() */
365
 
  for (; free_list; free_list= next)
 
364
  for (Item* next; free_list; free_list= next)
366
365
  {
367
366
    next= free_list->next;
368
367
    free_list->delete_self();
458
457
  mysys_var=0;                                  // Safety (shouldn't be needed)
459
458
 
460
459
  impl_->mem_root.free_root(MYF(0));
461
 
  currentMemRoot().release();
462
 
  currentSession().release();
 
460
  setCurrentMemRoot(NULL);
 
461
  setCurrentSession(NULL);
463
462
 
464
463
  plugin::Logging::postEndDo(this);
465
464
  plugin::EventObserver::deregisterSessionEvents(session_event_observers); 
530
529
    to track stack overrun.
531
530
  */
532
531
  assert(thread_stack);
533
 
  currentSession().reset(this);
534
 
  currentMemRoot().reset(&mem_root);
 
532
  setCurrentSession(this);
 
533
  setCurrentMemRoot(&mem);
535
534
 
536
535
  mysys_var= my_thread_var;
537
536
 
564
563
  command= COM_SLEEP;
565
564
  times.set_time();
566
565
 
567
 
  mem_root->reset_root_defaults(variables.query_alloc_block_size,
568
 
                                variables.query_prealloc_size);
 
566
  mem.reset_defaults(variables.query_alloc_block_size, variables.query_prealloc_size);
569
567
  transaction.xid_state.xid.set_null();
570
568
  transaction.xid_state.in_session=1;
571
569
  if (use_usage)
889
887
                                     bool allocate_lex_string)
890
888
{
891
889
  if (allocate_lex_string)
892
 
    lex_str= (LEX_STRING *)getMemRoot()->allocate(sizeof(LEX_STRING));
893
 
  lex_str->str= mem_root->strmake_root(str, length);
 
890
    lex_str= (LEX_STRING *)getMemRoot()->alloc(sizeof(LEX_STRING));
 
891
  lex_str->str= mem_root->strmake(str, length);
894
892
  lex_str->length= length;
895
893
  return lex_str;
896
894
}
1557
1555
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
1558
1556
    return true;
1559
1557
  }
1560
 
  *p_db= strmake(impl_->schema->c_str(), impl_->schema->size());
 
1558
  *p_db= mem.strmake(*impl_->schema);
1561
1559
  *p_db_length= impl_->schema->size();
1562
1560
  return false;
1563
1561
}