198
198
@param message Message to send to the client (Used by mysql_status)
202
void ProtocolOldLibdrizzle::sendOK(uint32_t server_status,
203
uint32_t total_warn_count,
204
ha_rows affected_rows, uint64_t id, const char *message)
206
unsigned char buff[DRIZZLE_ERRMSG_SIZE+10],*pos;
208
if (!net->vio) // hack for re-parsing queries
213
buff[0]=0; // No fields
214
pos=drizzleclient_net_store_length(buff+1,affected_rows);
215
pos=drizzleclient_net_store_length(pos, id);
216
int2store(pos, server_status);
219
/* We can only return up to 65535 warnings in two bytes */
220
uint32_t tmp= cmin(total_warn_count, (uint32_t)65535);
224
session->main_da.can_overwrite_status= true;
226
if (message && message[0])
228
size_t length= strlen(message);
229
pos=drizzleclient_net_store_length(pos,length);
230
memcpy(pos,(unsigned char*) message,length);
233
drizzleclient_net_write(net, buff, (size_t) (pos-buff));
234
drizzleclient_net_flush(net);
236
session->main_da.can_overwrite_status= false;
239
201
void ProtocolOldLibdrizzle::sendOK()
241
203
unsigned char buff[DRIZZLE_ERRMSG_SIZE+10],*pos;
298
260
Note that the warning count will not be sent if 'no_flush' is set as
299
261
we don't want to report the warning count until all data is sent to the
302
@param session Thread handler
303
@param no_flush Set to 1 if there will be more data to the client,
304
like in send_fields().
308
void ProtocolOldLibdrizzle::sendEOF(uint32_t server_status, uint32_t total_warn_count)
310
/* Set to true if no active vio, to work well in case of --init-file */
313
session->main_da.can_overwrite_status= true;
314
write_eof_packet(session, net, server_status, total_warn_count);
315
drizzleclient_net_flush(net);
316
session->main_da.can_overwrite_status= false;
320
265
void ProtocolOldLibdrizzle::sendEOF()
322
267
/* Set to true if no active vio, to work well in case of --init-file */
459
404
unsigned char buff[80];
460
405
String tmp((char*) buff,sizeof(buff),&my_charset_bin);
461
406
String *local_packet= storage_packet();
462
const CHARSET_INFO * const session_charset= default_charset_info;
464
408
if (flags & SEND_NUM_ROWS)
465
409
{ // Packet with number of elements
477
421
prepare_for_resend();
480
if (store(STRING_WITH_LEN("def"), cs, session_charset) ||
481
store(field.db_name, (uint32_t) strlen(field.db_name),
482
cs, session_charset) ||
483
store(field.table_name, (uint32_t) strlen(field.table_name),
484
cs, session_charset) ||
485
store(field.org_table_name, (uint32_t) strlen(field.org_table_name),
486
cs, session_charset) ||
487
store(field.col_name, (uint32_t) strlen(field.col_name),
488
cs, session_charset) ||
489
store(field.org_col_name, (uint32_t) strlen(field.org_col_name),
490
cs, session_charset) ||
424
if (store(STRING_WITH_LEN("def"), cs) ||
425
store(field.db_name, cs) ||
426
store(field.table_name, cs) ||
427
store(field.org_table_name, cs) ||
428
store(field.col_name, cs) ||
429
store(field.org_col_name, cs) ||
491
430
local_packet->realloc(local_packet->length()+12))
494
433
/* Store fixed length fields */
495
434
pos= (char*) local_packet->ptr()+local_packet->length();
496
435
*pos++= 12; // Length of packed fields
497
if (item->collation.collation == &my_charset_bin || session_charset == NULL)
436
if (item->collation.collation == &my_charset_bin)
499
438
/* No conversion */
500
439
int2store(pos, field.charsetnr);
505
444
/* With conversion */
506
445
uint32_t max_char_len;
507
int2store(pos, session_charset->number);
446
int2store(pos, cs->number);
509
448
For TEXT/BLOB columns, field_length describes the maximum data
510
449
length in bytes. There is no limit to the number of characters
516
455
of characters here is limited by the column definition.
518
457
max_char_len= field.length / item->collation.collation->mbmaxlen;
519
int4store(pos+2, max_char_len * session_charset->mbmaxlen);
458
int4store(pos+2, max_char_len * cs->mbmaxlen);
521
460
pos[6]= field.type;
522
461
int2store(pos+7,field.flags);
556
495
packet->length()));
561
Send \\0 end terminated string.
563
@param from NULL or \\0 terminated string
566
In most cases one should use store(from, length) instead of this function
574
bool ProtocolOldLibdrizzle::store(const char *from, const CHARSET_INFO * const cs)
578
uint32_t length= strlen(from);
579
return store(from, length, cs);
584
Send a set of strings as one long string with ',' in between.
587
bool ProtocolOldLibdrizzle::store(I_List<i_string>* str_list)
590
String tmp(buf, sizeof(buf), &my_charset_bin);
592
I_List_iterator<i_string> it(*str_list);
601
if ((len= tmp.length()))
602
len--; // Remove last ','
603
return store((char*) tmp.ptr(), len, tmp.charset());
607
bool ProtocolOldLibdrizzle::store(String *str)
609
return store((char*) str->ptr(), str->length(), str->charset());
612
498
void ProtocolOldLibdrizzle::free()
776
662
bool ProtocolOldLibdrizzle::store(const char *from, size_t length,
777
const CHARSET_INFO * const fromcs,
778
const CHARSET_INFO * const tocs)
780
return storeStringAux(from, length, fromcs, tocs);
784
bool ProtocolOldLibdrizzle::store(const char *from, size_t length,
785
663
const CHARSET_INFO * const fromcs)
787
665
const CHARSET_INFO * const tocs= default_charset_info;
821
bool ProtocolOldLibdrizzle::store_decimal(const my_decimal *d)
823
char buff[DECIMAL_MAX_STR_LENGTH];
824
String str(buff, sizeof(buff), &my_charset_bin);
825
(void) my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
826
return netStoreData((unsigned char*) str.ptr(), str.length());
830
bool ProtocolOldLibdrizzle::store(float from, uint32_t decimals, String *buffer)
832
buffer->set_real((double) from, decimals, session->charset());
833
return netStoreData((unsigned char*) buffer->ptr(), buffer->length());
837
699
bool ProtocolOldLibdrizzle::store(double from, uint32_t decimals, String *buffer)
839
701
buffer->set_real(from, decimals, session->charset());
844
bool ProtocolOldLibdrizzle::store(Field *field)
706
bool ProtocolOldLibdrizzle::store(Field *from)
846
if (field->is_null())
848
710
char buff[MAX_FIELD_WIDTH];
849
711
String str(buff,sizeof(buff), &my_charset_bin);
850
712
const CHARSET_INFO * const tocs= default_charset_info;
852
field->val_str(&str);
854
716
return storeStringAux(str.ptr(), str.length(), str.charset(), tocs);