60
plugin::Protocol *ListenOldLibdrizzle::protocolFactory(void) const
60
plugin::Client *ListenOldLibdrizzle::clientFactory(void) const
62
return new ProtocolOldLibdrizzle;
62
return new ClientOldLibdrizzle;
65
65
static void write_eof_packet(Session *session, NET *net,
66
66
uint32_t server_status, uint32_t total_warn_count);
68
bool ProtocolOldLibdrizzle::isConnected()
68
bool ClientOldLibdrizzle::isConnected()
70
70
return net.vio != 0;
73
void ProtocolOldLibdrizzle::setError(char error)
73
void ClientOldLibdrizzle::setError(char error)
78
bool ProtocolOldLibdrizzle::haveError(void)
78
bool ClientOldLibdrizzle::haveError(void)
80
80
return net.error || net.vio == 0;
83
bool ProtocolOldLibdrizzle::wasAborted(void)
83
bool ClientOldLibdrizzle::wasAborted(void)
85
85
return net.error && net.vio != 0;
88
bool ProtocolOldLibdrizzle::haveMoreData(void)
88
bool ClientOldLibdrizzle::haveMoreData(void)
90
90
return drizzleclient_net_more_data(&net);
93
bool ProtocolOldLibdrizzle::isReading(void)
93
bool ClientOldLibdrizzle::isReading(void)
95
95
return net.reading_or_writing == 1;
98
bool ProtocolOldLibdrizzle::isWriting(void)
98
bool ClientOldLibdrizzle::isWriting(void)
100
100
return net.reading_or_writing == 2;
103
bool ProtocolOldLibdrizzle::netStoreData(const unsigned char *from, size_t length)
103
bool ClientOldLibdrizzle::netStoreData(const unsigned char *from, size_t length)
105
105
size_t packet_length= packet->length();
127
127
- id : Stored in 1-9 bytes
128
128
- server_status : Copy of session->server_status; Can be used by client
129
129
to check if we are inside an transaction.
131
- warning_count : Stored in 2 bytes; New in 4.1 protocol
131
- warning_count : Stored in 2 bytes; New in 4.1 client
132
132
- message : Stored as packed length (1-9 bytes) + message.
133
133
Is not stored if no message.
138
138
@param message Message to send to the client (Used by mysql_status)
141
void ProtocolOldLibdrizzle::sendOK()
141
void ClientOldLibdrizzle::sendOK()
143
143
unsigned char buff[DRIZZLE_ERRMSG_SIZE+10],*pos;
144
144
const char *message= NULL;
196
196
The eof packet has the following structure:
198
198
- 254 (DRIZZLE_PROTOCOL_NO_MORE_DATA) : Marker (1 byte)
199
- warning_count : Stored in 2 bytes; New in 4.1 protocol
199
- warning_count : Stored in 2 bytes; New in 4.1 client
200
200
- status_flag : Stored in 2 bytes;
201
201
For flags like SERVER_MORE_RESULTS_EXISTS.
247
247
drizzleclient_net_write(net, buff, 5);
250
void ProtocolOldLibdrizzle::sendError(uint32_t sql_errno, const char *err)
250
void ClientOldLibdrizzle::sendError(uint32_t sql_errno, const char *err)
283
283
int2store(buff,sql_errno);
286
/* The first # is to make the protocol backward compatible */
286
/* The first # is to make the client backward compatible */
288
288
pos= (unsigned char*) strcpy((char*) buff+3, drizzle_errno_to_sqlstate(sql_errno));
289
289
pos+= strlen(drizzle_errno_to_sqlstate(sql_errno));
303
ProtocolOldLibdrizzle::ProtocolOldLibdrizzle()
303
ClientOldLibdrizzle::ClientOldLibdrizzle()
309
ProtocolOldLibdrizzle::~ProtocolOldLibdrizzle()
309
ClientOldLibdrizzle::~ClientOldLibdrizzle()
312
312
drizzleclient_vio_close(net.vio);
315
void ProtocolOldLibdrizzle::setSession(Session *session_arg)
315
void ClientOldLibdrizzle::setSession(Session *session_arg)
317
317
session= session_arg;
318
318
packet= &session->packet;
319
319
convert= &session->convert_buffer;
338
339
1 Error (Note that in this case the error is not sent to the
341
bool ProtocolOldLibdrizzle::sendFields(List<Item> *list)
342
bool ClientOldLibdrizzle::sendFields(List<Item> *list)
343
344
List_iterator_fast<Item> it(*list);
404
bool ProtocolOldLibdrizzle::write()
403
bool ClientOldLibdrizzle::flush()
406
return(drizzleclient_net_write(&net, (unsigned char*) packet->ptr(),
407
bool ret= drizzleclient_net_write(&net, (unsigned char*) packet->ptr(),
410
void ProtocolOldLibdrizzle::free()
413
void ClientOldLibdrizzle::free()
415
bool ProtocolOldLibdrizzle::setFileDescriptor(int fd)
418
bool ClientOldLibdrizzle::setFileDescriptor(int fd)
417
420
if (drizzleclient_net_init_sock(&net, fd, 0))
427
int ProtocolOldLibdrizzle::fileDescriptor(void)
430
int ClientOldLibdrizzle::getFileDescriptor(void)
429
432
return drizzleclient_net_get_sd(&net);
432
bool ProtocolOldLibdrizzle::authenticate()
435
bool ClientOldLibdrizzle::authenticate()
434
437
bool connection_is_valid;
456
bool ProtocolOldLibdrizzle::readCommand(char **l_packet, uint32_t *packet_length)
459
bool ClientOldLibdrizzle::readCommand(char **l_packet, uint32_t *packet_length)
459
462
This thread will do a blocking read from the client which
483
486
if (session->main_da.status() == Diagnostics_area::DA_ERROR)
484
487
sendError(session->main_da.sql_errno(), session->main_da.message());
486
session->protocol->sendOK();
488
491
if (net.error != 3)
489
492
return false; // We have to close it.
535
void ProtocolOldLibdrizzle::forceClose(void)
538
void ClientOldLibdrizzle::forceClose(void)
538
541
drizzleclient_vio_close(net.vio);
541
void ProtocolOldLibdrizzle::prepareForResend()
544
void ClientOldLibdrizzle::prepareForResend()
543
546
packet->length(0);
546
bool ProtocolOldLibdrizzle::store(void)
549
bool ClientOldLibdrizzle::store(void)
549
552
buff[0]= (char)251;
554
bool ProtocolOldLibdrizzle::store(const char *from, size_t length)
557
bool ClientOldLibdrizzle::store(const char *from, size_t length)
556
559
return netStoreData((const unsigned char *)from, length);
560
bool ProtocolOldLibdrizzle::store(int32_t from)
563
bool ClientOldLibdrizzle::store(int32_t from)
563
566
return netStoreData((unsigned char*) buff,
564
567
(size_t) (int10_to_str(from, buff, -10) - buff));
567
bool ProtocolOldLibdrizzle::store(uint32_t from)
570
bool ClientOldLibdrizzle::store(uint32_t from)
570
573
return netStoreData((unsigned char*) buff,
571
574
(size_t) (int10_to_str(from, buff, 10) - buff));
574
bool ProtocolOldLibdrizzle::store(int64_t from)
577
bool ClientOldLibdrizzle::store(int64_t from)
577
580
return netStoreData((unsigned char*) buff,
578
581
(size_t) (int64_t10_to_str(from, buff, -10) - buff));
581
bool ProtocolOldLibdrizzle::store(uint64_t from)
584
bool ClientOldLibdrizzle::store(uint64_t from)
584
587
return netStoreData((unsigned char*) buff,
589
bool ProtocolOldLibdrizzle::store(double from, uint32_t decimals, String *buffer)
592
bool ClientOldLibdrizzle::store(double from, uint32_t decimals, String *buffer)
591
594
buffer->set_real(from, decimals, session->charset());
592
595
return netStoreData((unsigned char*) buffer->ptr(), buffer->length());
596
bool ProtocolOldLibdrizzle::store(Field *from)
599
bool ClientOldLibdrizzle::store(Field *from)
598
601
if (from->is_null())
669
672
// TCP/IP connection
671
674
char ip[NI_MAXHOST];
673
if (drizzleclient_net_peer_addr(&net, ip, &session->peer_port, NI_MAXHOST))
677
if (drizzleclient_net_peer_addr(&net, ip, &port, NI_MAXHOST))
675
679
my_error(ER_BAD_HOST_ERROR, MYF(0), session->security_ctx.ip.c_str());
780
784
the size (1 byte) + string (not null-terminated). Hence in case of empty
781
785
password both send '\0'.
783
This strlen() can't be easily deleted without changing protocol.
787
This strlen() can't be easily deleted without changing client.
785
789
Cast *passwd to an unsigned char, so that it doesn't extend the sign for
786
790
*passwd > 127 and become 2**32-127+ after casting to uint.
789
793
(unsigned char)(*passwd++) : strlen(passwd);
790
794
l_db= client_capabilities & CLIENT_CONNECT_WITH_DB ? l_db + passwd_len + 1 : 0;
792
/* strlen() can't be easily deleted without changing protocol */
796
/* strlen() can't be easily deleted without changing client */
793
797
uint32_t db_len= l_db ? strlen(l_db) : 0;
795
799
if (passwd + passwd_len + db_len > (char *) net.read_pos + pkt_len)