~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2009-09-22 07:35:28 UTC
  • mfrom: (971.6.10 eday-dev)
  • Revision ID: brian@gaz-20090922073528-xgm634aomuflqxl3
MergeĀ Eric

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <drizzled/item/empty_string.h>
38
38
#include <drizzled/show.h>
39
39
#include <drizzled/scheduling.h>
 
40
#include <drizzled/plugin/client.h>
40
41
 
41
42
#include <algorithm>
42
43
 
171
172
  session->row_count++;
172
173
}
173
174
 
174
 
Session::Session(plugin::Protocol *protocol_arg)
 
175
Session::Session(plugin::Client *client_arg)
175
176
  :
176
177
  Open_tables_state(refresh_version),
177
178
  mem_root(&main_mem_root),
178
179
  lex(&main_lex),
179
180
  db(NULL),
 
181
  client(client_arg),
180
182
  scheduler(NULL),
181
183
  scheduler_arg(NULL),
182
184
  lock_id(&main_lock_id),
198
200
  cached_table(0)
199
201
{
200
202
  memset(process_list_info, 0, PROCESS_LIST_WIDTH);
 
203
  client->setSession(this);
201
204
 
202
205
  /*
203
206
    Pass nominal parameters to init_alloc_root only to ensure that
229
232
  mysys_var= 0;
230
233
  dbug_sentry=Session_SENTRY_MAGIC;
231
234
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
232
 
  peer_port= 0;                                 // For SHOW PROCESSLIST
233
235
  transaction.on= 1;
234
236
  pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
235
237
 
268
270
            (hash_get_key) get_var_key,
269
271
            (hash_free_key) free_user_var, 0);
270
272
 
271
 
  protocol= protocol_arg;
272
 
  protocol->setSession(this);
273
 
 
274
273
  substitute_null_with_insert_id = false;
275
274
  thr_lock_info_init(&lock_info); /* safety: will be reset after start */
276
275
  thr_lock_owner_init(&main_lock_id, &lock_info);
385
384
  Session_CHECK_SENTRY(this);
386
385
  add_to_status(&global_status_var, &status_var);
387
386
 
388
 
  if (protocol->isConnected())
 
387
  if (client->isConnected())
389
388
  {
390
389
    if (global_system_variables.log_warnings)
391
390
        errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),my_progname,
396
395
  }
397
396
 
398
397
  /* Close connection */
399
 
  protocol->close();
400
 
  delete protocol;
 
398
  client->close();
 
399
  delete client;
401
400
 
402
401
  if (cleanup_done == false)
403
402
    cleanup();
594
593
 
595
594
  prepareForQueries();
596
595
 
597
 
  while (! protocol->haveError() && killed != KILL_CONNECTION)
 
596
  while (! client->haveError() && killed != KILL_CONNECTION)
598
597
  {
599
598
    if (! executeStatement())
600
599
      break;
630
629
    /* TODO replace will better error message */
631
630
    snprintf(error_message_buff, sizeof(error_message_buff),
632
631
             ER(ER_CANT_CREATE_THREAD), 1);
633
 
    protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
 
632
    client->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
634
633
    return true;
635
634
  }
636
635
 
640
639
bool Session::authenticate()
641
640
{
642
641
  lex_start(this);
643
 
  if (protocol->authenticate())
 
642
  if (client->authenticate())
644
643
    return false;
645
644
 
646
645
  statistic_increment(aborted_connects, &LOCK_status);
708
707
    (see my_message_sql)
709
708
  */
710
709
  lex->current_select= 0;
 
710
  clear_error();
 
711
  main_da.reset_diagnostics_area();
711
712
 
712
 
  if (protocol->readCommand(&l_packet, &packet_length) == false)
 
713
  if (client->readCommand(&l_packet, &packet_length) == false)
713
714
    return false;
714
715
 
715
716
  if (packet_length == 0)
1793
1794
  plugin_sessionvar_cleanup(this);
1794
1795
 
1795
1796
  /* If necessary, log any aborted or unauthorized connections */
1796
 
  if (killed || protocol->wasAborted())
 
1797
  if (killed || client->wasAborted())
1797
1798
    statistic_increment(aborted_threads, &LOCK_status);
1798
1799
 
1799
 
  if (protocol->wasAborted())
 
1800
  if (client->wasAborted())
1800
1801
  {
1801
1802
    if (! killed && variables.log_warnings > 1)
1802
1803
    {
1815
1816
  if (should_lock)
1816
1817
    (void) pthread_mutex_lock(&LOCK_thread_count);
1817
1818
  killed= Session::KILL_CONNECTION;
1818
 
  if (protocol->isConnected())
 
1819
  if (client->isConnected())
1819
1820
  {
1820
1821
    if (errcode)
1821
1822
    {
1822
1823
      /*my_error(errcode, ER(errcode));*/
1823
 
      protocol->sendError(errcode, ER(errcode)); /* purecov: inspected */
 
1824
      client->sendError(errcode, ER(errcode)); /* purecov: inspected */
1824
1825
    }
1825
 
    protocol->close();
 
1826
    client->close();
1826
1827
  }
1827
1828
  if (should_lock)
1828
1829
    (void) pthread_mutex_unlock(&LOCK_thread_count);