~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 05:57:49 UTC
  • Revision ID: brian@tangent.org-20081006055749-svg700gciuqi0zu1
Remove all of uchar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
static void write_eof_packet(THD *thd, NET *net,
30
30
                             uint server_status, uint total_warn_count);
31
31
 
32
 
bool Protocol::net_store_data(const uchar *from, size_t length)
 
32
bool Protocol::net_store_data(const unsigned char *from, size_t length)
33
33
{
34
34
  ulong packet_length=packet->length();
35
35
  /* 
39
39
  if (packet_length+9+length > packet->alloced_length() &&
40
40
      packet->realloc(packet_length+9+length))
41
41
    return 1;
42
 
  uchar *to= net_store_length((uchar*) packet->ptr()+packet_length, length);
 
42
  unsigned char *to= net_store_length((unsigned char*) packet->ptr()+packet_length, length);
43
43
  memcpy(to,from,length);
44
 
  packet->length((uint) (to+length-(uchar*) packet->ptr()));
 
44
  packet->length((uint) (to+length-(unsigned char*) packet->ptr()));
45
45
  return 0;
46
46
}
47
47
 
60
60
  because column, table, database names fit into this limit.
61
61
*/
62
62
 
63
 
bool Protocol::net_store_data(const uchar *from, size_t length,
 
63
bool Protocol::net_store_data(const unsigned char *from, size_t length,
64
64
                              const CHARSET_INFO * const from_cs,
65
65
                                                          const CHARSET_INFO * const to_cs)
66
66
{
82
82
    */
83
83
    return (convert->copy((const char*) from, length, from_cs,
84
84
                          to_cs, &dummy_errors) ||
85
 
            net_store_data((const uchar*) convert->ptr(), convert->length()));
 
85
            net_store_data((const unsigned char*) convert->ptr(), convert->length()));
86
86
  }
87
87
 
88
88
  ulong packet_length= packet->length();
97
97
  to+= copy_and_convert(to, conv_length, to_cs,
98
98
                        (const char*) from, length, from_cs, &dummy_errors);
99
99
 
100
 
  net_store_length((uchar*) length_pos, to - length_pos - 1);
 
100
  net_store_length((unsigned char*) length_pos, to - length_pos - 1);
101
101
  packet->length((uint) (to - packet->ptr()));
102
102
  return 0;
103
103
}
161
161
            ha_rows affected_rows, uint64_t id, const char *message)
162
162
{
163
163
  NET *net= &thd->net;
164
 
  uchar buff[DRIZZLE_ERRMSG_SIZE+10],*pos;
 
164
  unsigned char buff[DRIZZLE_ERRMSG_SIZE+10],*pos;
165
165
 
166
166
  if (! net->vio)       // hack for re-parsing queries
167
167
  {
183
183
  thd->main_da.can_overwrite_status= true;
184
184
 
185
185
  if (message && message[0])
186
 
    pos= net_store_data(pos, (uchar*) message, strlen(message));
 
186
    pos= net_store_data(pos, (unsigned char*) message, strlen(message));
187
187
  my_net_write(net, buff, (size_t) (pos-buff));
188
188
  net_flush(net);
189
189
 
233
233
                             uint server_status,
234
234
                             uint total_warn_count)
235
235
{
236
 
  uchar buff[5];
 
236
  unsigned char buff[5];
237
237
  /*
238
238
    Don't send warn count during SP execution, as the warn_list
239
239
    is cleared between substatements, and mysqltest gets confused
259
259
  /*
260
260
    buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + DRIZZLE_ERRMSG_SIZE:512
261
261
  */
262
 
  uchar buff[2+1+SQLSTATE_LENGTH+DRIZZLE_ERRMSG_SIZE], *pos;
 
262
  unsigned char buff[2+1+SQLSTATE_LENGTH+DRIZZLE_ERRMSG_SIZE], *pos;
263
263
 
264
264
  if (net->vio == 0)
265
265
  {
271
271
 
272
272
  /* The first # is to make the protocol backward compatible */
273
273
  buff[2]= '#';
274
 
  pos= (uchar*) my_stpcpy((char*) buff+3, drizzle_errno_to_sqlstate(sql_errno));
 
274
  pos= (unsigned char*) my_stpcpy((char*) buff+3, drizzle_errno_to_sqlstate(sql_errno));
275
275
 
276
276
  length= (uint) (strmake((char*) pos, err, DRIZZLE_ERRMSG_SIZE-1) -
277
277
                  (char*) buff);
278
278
  err= (char*) buff;
279
279
 
280
 
  net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err, length);
 
280
  net_write_command(net,(unsigned char) 255, (unsigned char*) "", 0, (unsigned char*) err, length);
281
281
  return;
282
282
}
283
283
 
293
293
  - uint64_t for bigger numbers.
294
294
*/
295
295
 
296
 
static uchar *net_store_length_fast(uchar *packet, uint length)
 
296
static unsigned char *net_store_length_fast(unsigned char *packet, uint length)
297
297
{
298
298
  if (length < 251)
299
299
  {
300
 
    *packet=(uchar) length;
 
300
    *packet=(unsigned char) length;
301
301
    return packet+1;
302
302
  }
303
303
  *packet++=252;
403
403
 
404
404
/* The following will only be used for short strings < 65K */
405
405
 
406
 
uchar *net_store_data(uchar *to, const uchar *from, size_t length)
 
406
unsigned char *net_store_data(unsigned char *to, const unsigned char *from, size_t length)
407
407
{
408
408
  to=net_store_length_fast(to,length);
409
409
  memcpy(to,from,length);
410
410
  return to+length;
411
411
}
412
412
 
413
 
uchar *net_store_data(uchar *to,int32_t from)
 
413
unsigned char *net_store_data(unsigned char *to,int32_t from)
414
414
{
415
415
  char buff[20];
416
416
  uint length=(uint) (int10_to_str(from,buff,10)-buff);
419
419
  return to+length;
420
420
}
421
421
 
422
 
uchar *net_store_data(uchar *to,int64_t from)
 
422
unsigned char *net_store_data(unsigned char *to,int64_t from)
423
423
{
424
424
  char buff[22];
425
425
  uint length=(uint) (int64_t10_to_str(from,buff,10)-buff);
480
480
{
481
481
  List_iterator_fast<Item> it(*list);
482
482
  Item *item;
483
 
  uchar buff[80];
 
483
  unsigned char buff[80];
484
484
  String tmp((char*) buff,sizeof(buff),&my_charset_bin);
485
485
  Protocol_text prot(thd);
486
486
  String *local_packet= prot.storage_packet();
488
488
 
489
489
  if (flags & SEND_NUM_ROWS)
490
490
  {                             // Packet with number of elements
491
 
    uchar *pos= net_store_length(buff, list->elements);
 
491
    unsigned char *pos= net_store_length(buff, list->elements);
492
492
    (void) my_net_write(&thd->net, buff, (size_t) (pos-buff));
493
493
  }
494
494
 
577
577
 
578
578
bool Protocol::write()
579
579
{
580
 
  return(my_net_write(&thd->net, (uchar*) packet->ptr(),
 
580
  return(my_net_write(&thd->net, (unsigned char*) packet->ptr(),
581
581
                           packet->length()));
582
582
}
583
583
 
665
665
      tocs != &my_charset_bin)
666
666
  {
667
667
    /* Store with conversion */
668
 
    return net_store_data((uchar*) from, length, fromcs, tocs);
 
668
    return net_store_data((unsigned char*) from, length, fromcs, tocs);
669
669
  }
670
670
  /* Store without conversion */
671
 
  return net_store_data((uchar*) from, length);
 
671
  return net_store_data((unsigned char*) from, length);
672
672
}
673
673
 
674
674
 
691
691
bool Protocol_text::store_tiny(int64_t from)
692
692
{
693
693
  char buff[20];
694
 
  return net_store_data((uchar*) buff,
 
694
  return net_store_data((unsigned char*) buff,
695
695
                        (size_t) (int10_to_str((int) from, buff, -10) - buff));
696
696
}
697
697
 
699
699
bool Protocol_text::store_short(int64_t from)
700
700
{
701
701
  char buff[20];
702
 
  return net_store_data((uchar*) buff,
 
702
  return net_store_data((unsigned char*) buff,
703
703
                        (size_t) (int10_to_str((int) from, buff, -10) -
704
704
                                  buff));
705
705
}
708
708
bool Protocol_text::store_long(int64_t from)
709
709
{
710
710
  char buff[20];
711
 
  return net_store_data((uchar*) buff,
 
711
  return net_store_data((unsigned char*) buff,
712
712
                        (size_t) (int10_to_str((long int)from, buff,
713
713
                                               (from <0)?-10:10)-buff));
714
714
}
717
717
bool Protocol_text::store_int64_t(int64_t from, bool unsigned_flag)
718
718
{
719
719
  char buff[22];
720
 
  return net_store_data((uchar*) buff,
 
720
  return net_store_data((unsigned char*) buff,
721
721
                        (size_t) (int64_t10_to_str(from,buff,
722
722
                                                    unsigned_flag ? 10 : -10)-
723
723
                                  buff));
729
729
  char buff[DECIMAL_MAX_STR_LENGTH];
730
730
  String str(buff, sizeof(buff), &my_charset_bin);
731
731
  (void) my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
732
 
  return net_store_data((uchar*) str.ptr(), str.length());
 
732
  return net_store_data((unsigned char*) str.ptr(), str.length());
733
733
}
734
734
 
735
735
 
736
736
bool Protocol_text::store(float from, uint32_t decimals, String *buffer)
737
737
{
738
738
  buffer->set_real((double) from, decimals, thd->charset());
739
 
  return net_store_data((uchar*) buffer->ptr(), buffer->length());
 
739
  return net_store_data((unsigned char*) buffer->ptr(), buffer->length());
740
740
}
741
741
 
742
742
 
743
743
bool Protocol_text::store(double from, uint32_t decimals, String *buffer)
744
744
{
745
745
  buffer->set_real(from, decimals, thd->charset());
746
 
  return net_store_data((uchar*) buffer->ptr(), buffer->length());
 
746
  return net_store_data((unsigned char*) buffer->ptr(), buffer->length());
747
747
}
748
748
 
749
749
 
781
781
  if (tm->second_part)
782
782
    length+= sprintf(buff+length, ".%06d",
783
783
                                     (int)tm->second_part);
784
 
  return net_store_data((uchar*) buff, length);
 
784
  return net_store_data((unsigned char*) buff, length);
785
785
}
786
786
 
787
787
 
789
789
{
790
790
  char buff[MAX_DATE_STRING_REP_LENGTH];
791
791
  size_t length= my_date_to_str(tm, buff);
792
 
  return net_store_data((uchar*) buff, length);
 
792
  return net_store_data((unsigned char*) buff, length);
793
793
}
794
794
 
795
795
 
811
811
                           (int) tm->second);
812
812
  if (tm->second_part)
813
813
    length+= sprintf(buff+length, ".%06d", (int)tm->second_part);
814
 
  return net_store_data((uchar*) buff, length);
 
814
  return net_store_data((unsigned char*) buff, length);
815
815
}
816
816