~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Eric Day
  • Date: 2009-08-06 07:14:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1131.
  • Revision ID: eday@oddments.org-20090806071437-c3baqgtvsdxp1l1a
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <drizzled/item/empty_string.h>
36
36
#include <drizzled/show.h>
37
37
#include <drizzled/scheduling.h>
 
38
#include <drizzled/plugin/client.h>
38
39
 
39
40
#include <algorithm>
40
41
 
169
170
  session->row_count++;
170
171
}
171
172
 
172
 
Session::Session(plugin::Protocol *protocol_arg)
 
173
Session::Session(plugin::Client *client_arg)
173
174
  :
174
175
  Statement(&main_lex, &main_mem_root, /* statement id */ 0),
175
176
  Open_tables_state(refresh_version),
 
177
  client(client_arg),
176
178
  scheduler(NULL),
177
179
  scheduler_arg(NULL),
178
180
  lock_id(&main_lock_id),
194
196
  cached_table(0)
195
197
{
196
198
  memset(process_list_info, 0, PROCESS_LIST_WIDTH);
 
199
  client->setSession(this);
197
200
 
198
201
  /*
199
202
    Pass nominal parameters to init_alloc_root only to ensure that
225
228
  mysys_var= 0;
226
229
  dbug_sentry=Session_SENTRY_MAGIC;
227
230
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
228
 
  peer_port= 0;                                 // For SHOW PROCESSLIST
229
231
  transaction.on= 1;
230
232
  pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
231
233
 
264
266
            (hash_get_key) get_var_key,
265
267
            (hash_free_key) free_user_var, 0);
266
268
 
267
 
  protocol= protocol_arg;
268
 
  protocol->setSession(this);
269
 
 
270
269
  substitute_null_with_insert_id = false;
271
270
  thr_lock_info_init(&lock_info); /* safety: will be reset after start */
272
271
  thr_lock_owner_init(&main_lock_id, &lock_info);
381
380
  Session_CHECK_SENTRY(this);
382
381
  add_to_status(&global_status_var, &status_var);
383
382
 
384
 
  if (protocol->isConnected())
 
383
  if (client->isConnected())
385
384
  {
386
385
    if (global_system_variables.log_warnings)
387
386
        errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),my_progname,
392
391
  }
393
392
 
394
393
  /* Close connection */
395
 
  protocol->close();
396
 
  delete protocol;
 
394
  client->close();
 
395
  delete client;
397
396
 
398
397
  if (cleanup_done == false)
399
398
    cleanup();
590
589
 
591
590
  prepareForQueries();
592
591
 
593
 
  while (!protocol->haveError() && killed != KILL_CONNECTION)
 
592
  while (!client->haveError() && killed != KILL_CONNECTION)
594
593
  {
595
594
    if (!executeStatement())
596
595
      break;
626
625
    /* TODO replace will better error message */
627
626
    snprintf(error_message_buff, sizeof(error_message_buff),
628
627
             ER(ER_CANT_CREATE_THREAD), 1);
629
 
    protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
 
628
    client->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
630
629
    return true;
631
630
  }
632
631
 
636
635
bool Session::authenticate()
637
636
{
638
637
  lex_start(this);
639
 
  if (protocol->authenticate())
 
638
  if (client->authenticate())
640
639
    return false;
641
640
 
642
641
  statistic_increment(aborted_connects, &LOCK_status);
705
704
  */
706
705
  lex->current_select= 0;
707
706
 
708
 
  if (protocol->readCommand(&l_packet, &packet_length) == false)
 
707
  if (client->readCommand(&l_packet, &packet_length) == false)
709
708
    return false;
710
709
 
711
710
  if (packet_length == 0)
1789
1788
  plugin_sessionvar_cleanup(this);
1790
1789
 
1791
1790
  /* If necessary, log any aborted or unauthorized connections */
1792
 
  if (killed || protocol->wasAborted())
 
1791
  if (killed || client->wasAborted())
1793
1792
    statistic_increment(aborted_threads, &LOCK_status);
1794
1793
 
1795
 
  if (protocol->wasAborted())
 
1794
  if (client->wasAborted())
1796
1795
  {
1797
1796
    if (! killed && variables.log_warnings > 1)
1798
1797
    {
1811
1810
  if (should_lock)
1812
1811
    (void) pthread_mutex_lock(&LOCK_thread_count);
1813
1812
  killed= Session::KILL_CONNECTION;
1814
 
  if (protocol->isConnected())
 
1813
  if (client->isConnected())
1815
1814
  {
1816
1815
    if (errcode)
1817
1816
    {
1818
1817
      /*my_error(errcode, ER(errcode));*/
1819
 
      protocol->sendError(errcode, ER(errcode)); /* purecov: inspected */
 
1818
      client->sendError(errcode, ER(errcode)); /* purecov: inspected */
1820
1819
    }
1821
 
    protocol->close();
 
1820
    client->close();
1822
1821
  }
1823
1822
  if (should_lock)
1824
1823
    (void) pthread_mutex_unlock(&LOCK_thread_count);