~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/mysql_protocol.cc

  • Committer: Olaf van der Spek
  • Date: 2011-02-28 14:09:50 UTC
  • mfrom: (2207 bootstrap)
  • mto: (2209.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2210.
  • Revision ID: olafvdspek@gmail.com-20110228140950-2nu0hyzhuww3wssx
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
#include <drizzled/gettext.h>
22
22
#include <drizzled/error.h>
23
23
#include <drizzled/query_id.h>
24
24
#include <drizzled/error/sql_state.h>
25
25
#include <drizzled/session.h>
26
 
#include "drizzled/internal/m_string.h"
 
26
#include <drizzled/internal/m_string.h>
27
27
#include <algorithm>
28
28
#include <boost/program_options.hpp>
29
29
#include <drizzled/module/option_map.h>
30
 
#include "drizzled/util/tokenize.h"
 
30
#include <drizzled/util/tokenize.h>
31
31
#include "errmsg.h"
32
32
#include "mysql_protocol.h"
33
33
#include "mysql_password.h"
34
34
#include "options.h"
35
 
 
36
 
#include "drizzled/identifier.h"
 
35
#include <drizzled/identifier.h>
 
36
#include <drizzled/plugin/function.h>
 
37
#include <libdrizzle/constants.h>
37
38
 
38
39
#define PROTOCOL_VERSION 10
39
40
 
95
96
ClientMySQLProtocol::ClientMySQLProtocol(int fd, bool using_mysql41_protocol, ProtocolCounters *set_counters):
96
97
  is_admin_connection(false),
97
98
  _using_mysql41_protocol(using_mysql41_protocol),
 
99
  _is_interactive(false),
98
100
  counters(set_counters)
99
101
{
100
102
  
154
156
    drizzleclient_net_close(&net);
155
157
    drizzleclient_net_end(&net);
156
158
    if (is_admin_connection)
 
159
    {
157
160
      counters->adminConnected.decrement();
 
161
    }
158
162
    else
 
163
    {
159
164
      counters->connected.decrement();
 
165
    }
160
166
  }
161
167
}
162
168
 
273
279
      (*l_packet)[0]= (unsigned char) COM_SHUTDOWN;
274
280
      break;
275
281
 
 
282
    case 12: /* KILL */
 
283
      (*l_packet)[0]= (unsigned char) COM_KILL;
 
284
      break;
 
285
 
276
286
    case 14: /* PING */
277
287
      (*l_packet)[0]= (unsigned char) COM_PING;
278
288
      break;
476
486
*/
477
487
bool ClientMySQLProtocol::sendFields(List<Item> *list)
478
488
{
479
 
  List_iterator_fast<Item> it(*list);
 
489
  List<Item>::iterator it(list->begin());
480
490
  Item *item;
481
491
  unsigned char buff[80];
482
492
  String tmp((char*) buff,sizeof(buff),&my_charset_bin);
483
493
 
484
 
  unsigned char *row_pos= storeLength(buff, list->elements);
 
494
  unsigned char *row_pos= storeLength(buff, list->size());
485
495
  (void) drizzleclient_net_write(&net, buff, (size_t) (row_pos-buff));
486
496
 
487
497
  while ((item=it++))
514
524
      switch (field.type)
515
525
      {
516
526
      case DRIZZLE_TYPE_LONG:
517
 
        pos[6]= 3;
 
527
        pos[6]= DRIZZLE_COLUMN_TYPE_LONG;
518
528
        break;
519
529
 
520
530
      case DRIZZLE_TYPE_DOUBLE:
521
 
        pos[6]= 5;
 
531
        pos[6]= DRIZZLE_COLUMN_TYPE_DOUBLE;
522
532
        break;
523
533
 
524
534
      case DRIZZLE_TYPE_NULL:
525
 
        pos[6]= 6;
 
535
        pos[6]= DRIZZLE_COLUMN_TYPE_NULL;
526
536
        break;
527
537
 
528
538
      case DRIZZLE_TYPE_TIMESTAMP:
529
 
        pos[6]= 7;
 
539
        pos[6]= DRIZZLE_COLUMN_TYPE_TIMESTAMP;
530
540
        break;
531
541
 
532
542
      case DRIZZLE_TYPE_LONGLONG:
533
 
        pos[6]= 8;
 
543
        pos[6]= DRIZZLE_COLUMN_TYPE_LONGLONG;
534
544
        break;
535
545
 
536
546
      case DRIZZLE_TYPE_DATETIME:
537
 
        pos[6]= 12;
 
547
        pos[6]= DRIZZLE_COLUMN_TYPE_DATETIME;
538
548
        break;
539
549
 
540
550
      case DRIZZLE_TYPE_TIME:
541
 
        pos[6]= 13;
 
551
        pos[6]= DRIZZLE_COLUMN_TYPE_TIME;
542
552
        break;
543
553
 
544
554
      case DRIZZLE_TYPE_DATE:
545
 
        pos[6]= 14;
 
555
        pos[6]= DRIZZLE_COLUMN_TYPE_DATE;
546
556
        break;
547
557
 
548
558
      case DRIZZLE_TYPE_VARCHAR:
549
 
        pos[6]= 15;
 
559
        pos[6]= DRIZZLE_COLUMN_TYPE_VARCHAR;
550
560
        break;
551
561
 
552
562
      case DRIZZLE_TYPE_MICROTIME:
553
 
        pos[6]= 15;
 
563
        pos[6]= DRIZZLE_COLUMN_TYPE_VARCHAR;
554
564
        break;
555
565
 
556
566
      case DRIZZLE_TYPE_UUID:
557
 
        pos[6]= 15;
 
567
        pos[6]= DRIZZLE_COLUMN_TYPE_VARCHAR;
558
568
        break;
559
569
 
560
570
      case DRIZZLE_TYPE_BOOLEAN:
561
 
        pos[6]= 15;
 
571
        pos[6]= DRIZZLE_COLUMN_TYPE_TINY;
562
572
        break;
563
573
 
564
574
      case DRIZZLE_TYPE_DECIMAL:
565
 
        pos[6]= (char)246;
 
575
        pos[6]= (char)DRIZZLE_COLUMN_TYPE_NEWDECIMAL;
566
576
        break;
567
577
 
568
578
      case DRIZZLE_TYPE_ENUM:
569
 
        pos[6]= (char)247;
 
579
        pos[6]= (char)DRIZZLE_COLUMN_TYPE_ENUM;
570
580
        break;
571
581
 
572
582
      case DRIZZLE_TYPE_BLOB:
573
 
        pos[6]= (char)252;
 
583
        pos[6]= (char)DRIZZLE_COLUMN_TYPE_BLOB;
574
584
        break;
575
585
      }
576
586
    }
609
619
{
610
620
  if (from->is_null())
611
621
    return store();
 
622
  if (from->type() == DRIZZLE_TYPE_BOOLEAN)
 
623
  {
 
624
    return store(from->val_int());
 
625
  }
 
626
 
612
627
  char buff[MAX_FIELD_WIDTH];
613
628
  String str(buff,sizeof(buff), &my_charset_bin);
614
629
 
852
867
    }
853
868
  }
854
869
 
 
870
  if (client_capabilities & CLIENT_INTERACTIVE)
 
871
  {
 
872
    _is_interactive= true;
 
873
  }
 
874
 
855
875
  user_identifier->setUser(user);
856
876
  session->setUser(user_identifier);
857
877