~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

  • Committer: Monty Taylor
  • Date: 2009-02-08 11:11:30 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mordred@inaugust.com-20090208111130-futpwptxv5he3boe
Renamed non-prefixed things from libdrizzleclient to drizzleclient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
  size_t packet_length= packet->length();
38
38
  /*
39
39
     The +9 comes from that strings of length longer than 16M require
40
 
     9 bytes to be stored (see net_store_length).
 
40
     9 bytes to be stored (see drizzleclient_net_store_length).
41
41
  */
42
42
  if (packet_length+9+length > packet->alloced_length() &&
43
43
      packet->realloc(packet_length+9+length))
44
44
    return 1;
45
 
  unsigned char *to= net_store_length((unsigned char*) packet->ptr()+packet_length, length);
 
45
  unsigned char *to= drizzleclient_net_store_length((unsigned char*) packet->ptr()+packet_length, length);
46
46
  memcpy(to,from,length);
47
47
  packet->length((size_t) (to+length-(unsigned char*) packet->ptr()));
48
48
  return 0;
100
100
  to+= copy_and_convert(to, conv_length, to_cs,
101
101
                        (const char*) from, length, from_cs, &dummy_errors);
102
102
 
103
 
  net_store_length((unsigned char*) length_pos, to - length_pos - 1);
 
103
  drizzleclient_net_store_length((unsigned char*) length_pos, to - length_pos - 1);
104
104
  packet->length((uint) (to - packet->ptr()));
105
105
  return 0;
106
106
}
172
172
  }
173
173
 
174
174
  buff[0]=0;                                    // No fields
175
 
  pos=net_store_length(buff+1,affected_rows);
176
 
  pos=net_store_length(pos, id);
 
175
  pos=drizzleclient_net_store_length(buff+1,affected_rows);
 
176
  pos=drizzleclient_net_store_length(pos, id);
177
177
 
178
178
  int2store(pos, server_status);
179
179
  pos+=2;
188
188
  if (message && message[0])
189
189
    pos= net_store_data(pos, (unsigned char*) message, strlen(message));
190
190
  drizzleclient_net_write(net, buff, (size_t) (pos-buff));
191
 
  net_flush(net);
 
191
  drizzleclient_net_flush(net);
192
192
 
193
193
  session->main_da.can_overwrite_status= false;
194
194
}
221
221
  {
222
222
    session->main_da.can_overwrite_status= true;
223
223
    write_eof_packet(session, net, server_status, total_warn_count);
224
 
    net_flush(net);
 
224
    drizzleclient_net_flush(net);
225
225
    session->main_da.can_overwrite_status= false;
226
226
  }
227
227
}
283
283
  length= (uint32_t)(tmp-(char*)buff);
284
284
  err= (char*) buff;
285
285
 
286
 
  net_write_command(net,(unsigned char) 255, (unsigned char*) "", 0, (unsigned char*) err, length);
 
286
  drizzleclient_net_write_command(net,(unsigned char) 255, (unsigned char*) "", 0, (unsigned char*) err, length);
287
287
  return;
288
288
}
289
289
 
290
290
 
291
291
/**
292
 
  Faster net_store_length when we know that length is less than 65536.
 
292
  Faster drizzleclient_net_store_length when we know that length is less than 65536.
293
293
  We keep a separate version for that range because it's widely used in
294
294
  libmysql.
295
295
 
299
299
  - uint64_t for bigger numbers.
300
300
*/
301
301
 
302
 
static unsigned char *net_store_length_fast(unsigned char *packet, uint32_t length)
 
302
static unsigned char *drizzleclient_net_store_length_fast(unsigned char *packet, uint32_t length)
303
303
{
304
304
  if (length < 251)
305
305
  {
362
362
          Diagnostics_area::is_sent is set for debugging purposes only.
363
363
*/
364
364
 
365
 
void net_end_statement(Session *session)
 
365
void drizzleclient_net_end_statement(Session *session)
366
366
{
367
367
  assert(! session->main_da.is_sent);
368
368
 
413
413
 
414
414
unsigned char *net_store_data(unsigned char *to, const unsigned char *from, size_t length)
415
415
{
416
 
  to=net_store_length_fast(to,length);
 
416
  to=drizzleclient_net_store_length_fast(to,length);
417
417
  memcpy(to,from,length);
418
418
  return to+length;
419
419
}
422
422
{
423
423
  char buff[20];
424
424
  uint32_t length=(uint) (int10_to_str(from,buff,10)-buff);
425
 
  to=net_store_length_fast(to,length);
 
425
  to=drizzleclient_net_store_length_fast(to,length);
426
426
  memcpy(to,buff,length);
427
427
  return to+length;
428
428
}
431
431
{
432
432
  char buff[22];
433
433
  uint32_t length=(uint) (int64_t10_to_str(from,buff,10)-buff);
434
 
  to=net_store_length_fast(to,length);
 
434
  to=drizzleclient_net_store_length_fast(to,length);
435
435
  memcpy(to,buff,length);
436
436
  return to+length;
437
437
}
451
451
 
452
452
bool Protocol::flush()
453
453
{
454
 
  return net_flush(&session->net);
 
454
  return drizzleclient_net_flush(&session->net);
455
455
}
456
456
 
457
457
 
485
485
 
486
486
  if (flags & SEND_NUM_ROWS)
487
487
  {                             // Packet with number of elements
488
 
    unsigned char *pos= net_store_length(buff, list->elements);
 
488
    unsigned char *pos= drizzleclient_net_store_length(buff, list->elements);
489
489
    (void) drizzleclient_net_write(&session->net, buff, (size_t) (pos-buff));
490
490
  }
491
491