~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
27
27
/* Declared non-static only because of the embedded library. */
28
 
static void net_send_error_packet(THD *thd, uint sql_errno, const char *err);
 
28
static void net_send_error_packet(THD *thd, uint32_t sql_errno, const char *err);
29
29
static void write_eof_packet(THD *thd, NET *net,
30
 
                             uint server_status, uint total_warn_count);
 
30
                             uint32_t server_status, uint32_t total_warn_count);
31
31
 
32
32
bool Protocol::net_store_data(const unsigned char *from, size_t length)
33
33
{
64
64
                              const CHARSET_INFO * const from_cs,
65
65
                                                          const CHARSET_INFO * const to_cs)
66
66
{
67
 
  uint dummy_errors;
 
67
  uint32_t dummy_errors;
68
68
  /* Calculate maxumum possible result length */
69
 
  uint conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen;
 
69
  uint32_t conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen;
70
70
  if (conv_length > 250)
71
71
  {
72
72
    /*
115
115
  critical that every error that can be intercepted is issued in one
116
116
  place only, my_message_sql.
117
117
*/
118
 
void net_send_error(THD *thd, uint sql_errno, const char *err)
 
118
void net_send_error(THD *thd, uint32_t sql_errno, const char *err)
119
119
{
120
120
  assert(sql_errno);
121
121
  assert(err && err[0]);
157
157
 
158
158
static void
159
159
net_send_ok(THD *thd,
160
 
            uint server_status, uint total_warn_count,
 
160
            uint32_t server_status, uint32_t total_warn_count,
161
161
            ha_rows affected_rows, uint64_t id, const char *message)
162
162
{
163
163
  NET *net= &thd->net;
176
176
  pos+=2;
177
177
 
178
178
  /* We can only return up to 65535 warnings in two bytes */
179
 
  uint tmp= cmin(total_warn_count, (uint)65535);
 
179
  uint32_t tmp= cmin(total_warn_count, (uint)65535);
180
180
  int2store(pos, tmp);
181
181
  pos+= 2;
182
182
 
210
210
*/    
211
211
 
212
212
static void
213
 
net_send_eof(THD *thd, uint server_status, uint total_warn_count)
 
213
net_send_eof(THD *thd, uint32_t server_status, uint32_t total_warn_count)
214
214
{
215
215
  NET *net= &thd->net;
216
216
  /* Set to true if no active vio, to work well in case of --init-file */
230
230
*/
231
231
 
232
232
static void write_eof_packet(THD *thd, NET *net,
233
 
                             uint server_status,
234
 
                             uint total_warn_count)
 
233
                             uint32_t server_status,
 
234
                             uint32_t total_warn_count)
235
235
{
236
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
240
240
  */
241
 
  uint tmp= cmin(total_warn_count, (uint)65535);
 
241
  uint32_t tmp= cmin(total_warn_count, (uint)65535);
242
242
  buff[0]= DRIZZLE_PROTOCOL_NO_MORE_DATA;
243
243
  int2store(buff+1, tmp);
244
244
  /*
252
252
  my_net_write(net, buff, 5);
253
253
}
254
254
 
255
 
void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
 
255
void net_send_error_packet(THD *thd, uint32_t sql_errno, const char *err)
256
256
{
257
257
  NET *net= &thd->net;
258
 
  uint length;
 
258
  uint32_t length;
259
259
  /*
260
260
    buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + DRIZZLE_ERRMSG_SIZE:512
261
261
  */
287
287
  We keep a separate version for that range because it's widely used in
288
288
  libmysql.
289
289
 
290
 
  uint is used as agrument type because of MySQL type conventions:
291
 
  - uint for 0..65536
 
290
  uint32_t is used as agrument type because of MySQL type conventions:
 
291
  - uint32_t for 0..65536
292
292
  - ulong for 0..4294967296
293
293
  - uint64_t for bigger numbers.
294
294
*/
295
295
 
296
 
static unsigned char *net_store_length_fast(unsigned char *packet, uint length)
 
296
static unsigned char *net_store_length_fast(unsigned char *packet, uint32_t length)
297
297
{
298
298
  if (length < 251)
299
299
  {
413
413
unsigned char *net_store_data(unsigned char *to,int32_t from)
414
414
{
415
415
  char buff[20];
416
 
  uint length=(uint) (int10_to_str(from,buff,10)-buff);
 
416
  uint32_t length=(uint) (int10_to_str(from,buff,10)-buff);
417
417
  to=net_store_length_fast(to,length);
418
418
  memcpy(to,buff,length);
419
419
  return to+length;
422
422
unsigned char *net_store_data(unsigned char *to,int64_t from)
423
423
{
424
424
  char buff[22];
425
 
  uint length=(uint) (int64_t10_to_str(from,buff,10)-buff);
 
425
  uint32_t length=(uint) (int64_t10_to_str(from,buff,10)-buff);
426
426
  to=net_store_length_fast(to,length);
427
427
  memcpy(to,buff,length);
428
428
  return to+length;
476
476
    1   Error  (Note that in this case the error is not sent to the
477
477
    client)
478
478
*/
479
 
bool Protocol::send_fields(List<Item> *list, uint flags)
 
479
bool Protocol::send_fields(List<Item> *list, uint32_t flags)
480
480
{
481
481
  List_iterator_fast<Item> it(*list);
482
482
  Item *item;
528
528
    else
529
529
    {
530
530
      /* With conversion */
531
 
      uint max_char_len;
 
531
      uint32_t max_char_len;
532
532
      int2store(pos, thd_charset->number);
533
533
      /*
534
534
        For TEXT/BLOB columns, field_length describes the maximum data
600
600
{
601
601
  if (!from)
602
602
    return store_null();
603
 
  uint length= strlen(from);
 
603
  uint32_t length= strlen(from);
604
604
  return store(from, length, cs);
605
605
}
606
606
 
770
770
bool Protocol_text::store(DRIZZLE_TIME *tm)
771
771
{
772
772
  char buff[40];
773
 
  uint length;
 
773
  uint32_t length;
774
774
  length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
775
775
                           (int) tm->year,
776
776
                           (int) tm->month,
802
802
bool Protocol_text::store_time(DRIZZLE_TIME *tm)
803
803
{
804
804
  char buff[40];
805
 
  uint length;
806
 
  uint day= (tm->year || tm->month) ? 0 : tm->day;
 
805
  uint32_t length;
 
806
  uint32_t day= (tm->year || tm->month) ? 0 : tm->day;
807
807
  length= sprintf(buff, "%s%02ld:%02d:%02d",
808
808
                           tm->neg ? "-" : "",
809
809
                           (long) day*24L+(long) tm->hour,