~skinny.moey/drizzle/server_uuid_repl

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2011-04-21 21:09:08 UTC
  • mfrom: (2281.4.3 prune)
  • Revision ID: brian@tangent.org-20110421210908-qfoyfsfmqn6b1ocd
Merge in Olaf prune tree (with comment on set_db)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <drizzled/identifier.h>
37
37
#include <drizzled/internal/iocache.h>
38
38
#include <drizzled/internal/thread_var.h>
39
 
#include <drizzled/internal_error_handler.h>
40
39
#include <drizzled/item/cache.h>
41
40
#include <drizzled/item/empty_string.h>
42
41
#include <drizzled/item/float.h>
169
168
  }
170
169
 
171
170
  Diagnostics_area diagnostics;
 
171
  memory::Root mem_root;
 
172
 
172
173
  /**
173
174
    The lex to hold the parsed tree of conventional (non-prepared) queries.
174
175
    Whereas for prepared and stored procedure statements we use an own lex
191
192
 
192
193
Session::Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog_arg) :
193
194
  impl_(new impl_c(*this)),
194
 
  mem_root(&main_mem_root),
 
195
  mem_root(&impl_->mem_root),
195
196
  query(new std::string),
196
197
  scheduler(NULL),
197
198
  scheduler_arg(NULL),
249
250
    the destructor works OK in case of an error. The main_mem_root
250
251
    will be re-initialized in init_for_queries().
251
252
  */
252
 
  memory::init_sql_alloc(&main_mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
 
253
  memory::init_sql_alloc(mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
253
254
  cuted_fields= sent_row_count= row_count= 0L;
254
255
  // Must be reset to handle error with Session's created for init of mysqld
255
256
  lex().current_select= 0;
291
292
  lock_info.init(); /* safety: will be reset after start */
292
293
  thr_lock_owner_init(&main_lock_id, &lock_info);
293
294
 
294
 
  m_internal_handler= NULL;
295
 
 
296
295
  plugin::EventObserver::registerSessionEvents(*this);
297
296
}
298
297
 
368
367
  }
369
368
}
370
369
 
371
 
void Session::push_internal_handler(Internal_error_handler *handler)
372
 
{
373
 
  /*
374
 
    TODO: The current implementation is limited to 1 handler at a time only.
375
 
    Session and sp_rcontext need to be modified to use a common handler stack.
376
 
  */
377
 
  assert(m_internal_handler == NULL);
378
 
  m_internal_handler= handler;
379
 
}
380
 
 
381
 
bool Session::handle_error(drizzled::error_t sql_errno, const char *message,
382
 
                           DRIZZLE_ERROR::enum_warning_level level)
383
 
{
384
 
  if (m_internal_handler)
385
 
  {
386
 
    return m_internal_handler->handle_error(sql_errno, message, level, this);
387
 
  }
388
 
 
389
 
  return false;
390
 
}
391
 
 
392
370
void Session::setAbort(bool arg)
393
371
{
394
372
  mysys_var->abort= arg;
409
387
  }
410
388
}
411
389
 
412
 
void Session::pop_internal_handler()
413
 
{
414
 
  assert(m_internal_handler != NULL);
415
 
  m_internal_handler= NULL;
416
 
}
417
 
 
418
390
void Session::get_xid(DrizzleXid *xid)
419
391
{
420
392
  *xid = *(DrizzleXid *) &transaction.xid_state.xid;
424
396
 
425
397
void Session::cleanup()
426
398
{
427
 
  assert(cleanup_done == false);
 
399
  assert(not cleanup_done);
428
400
 
429
401
  setKilled(KILL_CONNECTION);
430
402
#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
442
414
    boost::checked_delete(iter.second);
443
415
  user_vars.clear();
444
416
 
445
 
 
446
417
  open_tables.close_temporary_tables();
447
418
 
448
419
  if (global_read_lock)
449
 
  {
450
420
    unlockGlobalReadLock();
451
 
  }
452
421
 
453
422
  cleanup_done= true;
454
423
}
477
446
    client= NULL;
478
447
  }
479
448
 
480
 
  if (cleanup_done == false)
 
449
  if (not cleanup_done)
481
450
    cleanup();
482
451
 
483
452
  plugin::StorageEngine::closeConnection(this);
486
455
  warn_root.free_root(MYF(0));
487
456
  mysys_var=0;                                  // Safety (shouldn't be needed)
488
457
 
489
 
  main_mem_root.free_root(MYF(0));
 
458
  impl_->mem_root.free_root(MYF(0));
490
459
  currentMemRoot().release();
491
460
  currentSession().release();
492
461
 
505
474
 
506
475
void Session::awake(Session::killed_state_t state_to_set)
507
476
{
508
 
  if ((state_to_set == Session::KILL_QUERY) and (command == COM_SLEEP))
 
477
  if (state_to_set == Session::KILL_QUERY && command == COM_SLEEP)
509
478
    return;
510
479
 
511
480
  setKilled(state_to_set);