~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.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:
43
43
#include "drizzled/plugin_registry.h"
44
44
#include <drizzled/info_schema.h>
45
45
#include <drizzled/message/schema.pb.h>
 
46
#include <drizzled/plugin/client.h>
46
47
 
47
48
#include <string>
48
49
#include <iostream>
230
231
 
231
232
bool drizzled_show_create(Session *session, TableList *table_list)
232
233
{
233
 
  plugin::Protocol *protocol= session->protocol;
234
234
  char buff[2048];
235
235
  String buffer(buff, sizeof(buff), system_charset_info);
236
236
 
262
262
                                               max(buffer.length(),(uint32_t)1024)));
263
263
  }
264
264
 
265
 
  if (protocol->sendFields(&field_list))
 
265
  if (session->client->sendFields(&field_list))
266
266
    return true;
267
 
  protocol->prepareForResend();
268
267
  {
269
268
    if (table_list->schema_table)
270
 
      protocol->store(table_list->schema_table->getTableName().c_str());
 
269
      session->client->store(table_list->schema_table->getTableName().c_str());
271
270
    else
272
 
      protocol->store(table_list->table->alias);
 
271
      session->client->store(table_list->table->alias);
273
272
  }
274
273
 
275
 
  protocol->store(buffer.ptr(), buffer.length());
 
274
  session->client->store(buffer.ptr(), buffer.length());
276
275
 
277
 
  if (protocol->write())
 
276
  if (session->client->flush())
278
277
    return true;
279
278
 
280
279
  session->my_eof();
343
342
{
344
343
  char buff[2048];
345
344
  String buffer(buff, sizeof(buff), system_charset_info);
346
 
  plugin::Protocol *protocol=session->protocol;
347
345
 
348
346
  if (store_db_create_info(dbname, &buffer, if_not_exists))
349
347
  {
359
357
  field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN));
360
358
  field_list.push_back(new Item_empty_string("Create Database",1024));
361
359
 
362
 
  if (protocol->sendFields(&field_list))
 
360
  if (session->client->sendFields(&field_list))
363
361
    return true;
364
362
 
365
 
  protocol->prepareForResend();
366
 
  protocol->store(dbname, strlen(dbname));
367
 
  protocol->store(buffer.ptr(), buffer.length());
 
363
  session->client->store(dbname, strlen(dbname));
 
364
  session->client->store(buffer.ptr(), buffer.length());
368
365
 
369
 
  if (protocol->write())
 
366
  if (session->client->flush())
370
367
    return true;
371
368
  session->my_eof();
372
369
  return false;
848
845
  Item *field;
849
846
  List<Item> field_list;
850
847
  I_List<thread_info> thread_infos;
851
 
  plugin::Protocol *protocol= session->protocol;
852
848
 
853
849
  field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
854
850
  field_list.push_back(new Item_empty_string("User",16));
861
857
  field->maybe_null= true;
862
858
  field_list.push_back(field=new Item_empty_string("Info", PROCESS_LIST_WIDTH));
863
859
  field->maybe_null= true;
864
 
  if (protocol->sendFields(&field_list))
 
860
  if (session->client->sendFields(&field_list))
865
861
    return;
866
862
 
867
863
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
873
869
      tmp= *it;
874
870
      Security_context *tmp_sctx= &tmp->security_ctx;
875
871
      struct st_my_thread_var *mysys_var;
876
 
      if (tmp->protocol->isConnected() && (!user || (tmp_sctx->user.c_str() && !strcmp(tmp_sctx->user.c_str(), user))))
 
872
      if (tmp->client->isConnected() && (!user || (tmp_sctx->user.c_str() && !strcmp(tmp_sctx->user.c_str(), user))))
877
873
      {
878
874
        thread_info *session_info= new thread_info;
879
875
 
891
887
        else
892
888
          session_info->proc_info= command_name[session_info->command].str;
893
889
 
894
 
        session_info->state_info= (char*) (tmp->protocol->isWriting() ?
 
890
        session_info->state_info= (char*) (tmp->client->isWriting() ?
895
891
                                           "Writing to net" :
896
 
                                           tmp->protocol->isReading() ?
 
892
                                           tmp->client->isReading() ?
897
893
                                           (session_info->command == COM_SLEEP ?
898
894
                                            NULL : "Reading from net") :
899
895
                                       tmp->get_proc_info() ? tmp->get_proc_info() :
917
913
  time_t now= time(NULL);
918
914
  while ((session_info=thread_infos.get()))
919
915
  {
920
 
    protocol->prepareForResend();
921
 
    protocol->store((uint64_t) session_info->thread_id);
922
 
    protocol->store(session_info->user);
923
 
    protocol->store(session_info->host);
924
 
    protocol->store(session_info->db);
925
 
    protocol->store(session_info->proc_info);
 
916
    session->client->store((uint64_t) session_info->thread_id);
 
917
    session->client->store(session_info->user);
 
918
    session->client->store(session_info->host);
 
919
    session->client->store(session_info->db);
 
920
    session->client->store(session_info->proc_info);
926
921
 
927
922
    if (session_info->start_time)
928
 
      protocol->store((uint32_t) (now - session_info->start_time));
 
923
      session->client->store((uint32_t) (now - session_info->start_time));
929
924
    else
930
 
      protocol->store();
931
 
 
932
 
    protocol->store(session_info->state_info);
933
 
    protocol->store(session_info->query);
934
 
 
935
 
    if (protocol->write())
 
925
      session->client->store();
 
926
 
 
927
    session->client->store(session_info->state_info);
 
928
    session->client->store(session_info->query);
 
929
 
 
930
    if (session->client->flush())
936
931
      break; /* purecov: inspected */
937
932
  }
938
933
  session->my_eof();