70
70
counters.push_back(new drizzled::plugin::ListenCounter(new std::string("failed_connections"), &getCounters().failedConnections));
73
const std::string ListenMySQLProtocol::getHost(void) const
73
const std::string ListenMySQLProtocol::getHost() const
78
in_port_t ListenMySQLProtocol::getPort(void) const
78
in_port_t ListenMySQLProtocol::getPort() const
259
259
/* See comment above. */
260
260
/* Restore read timeout value */
261
drizzleclient_net_set_read_timeout(&net,
262
session->variables.net_read_timeout);
261
drizzleclient_net_set_read_timeout(&net, session->variables.net_read_timeout);
370
369
void ClientMySQLProtocol::sendError(drizzled::error_t sql_errno, const char *err)
374
buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + DRIZZLE_ERRMSG_SIZE:512
376
unsigned char buff[2+1+SQLSTATE_LENGTH+DRIZZLE_ERRMSG_SIZE], *pos;
371
// buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + DRIZZLE_ERRMSG_SIZE:512
372
unsigned char buff[2 + 1 + SQLSTATE_LENGTH + DRIZZLE_ERRMSG_SIZE];
378
374
assert(sql_errno != EE_OK);
379
375
assert(err && err[0]);
403
399
int2store(buff, static_cast<uint16_t>(sql_errno));
406
401
/* The first # is to make the client backward compatible */
408
pos= (unsigned char*) strcpy((char*) buff+3, error::convert_to_sqlstate(sql_errno));
403
unsigned char* pos= (unsigned char*) strcpy((char*) buff+3, error::convert_to_sqlstate(sql_errno));
409
404
pos+= strlen(error::convert_to_sqlstate(sql_errno));
411
406
char *tmp= strncpy((char*)pos, err, DRIZZLE_ERRMSG_SIZE-1);
412
407
tmp+= strlen((char*)pos);
414
length= (uint32_t)(tmp-(char*)buff);
416
net.write_command((unsigned char) 255, (unsigned char*) "", 0, (unsigned char*) err, length);
409
net.write_command(255, data_ref().clear(), data_ref(buff, tmp));
418
411
session->main_da().can_overwrite_status= false;
585
578
void ClientMySQLProtocol::store(int32_t from)
588
netStoreData(buff, (internal::int10_to_str(from, buff, -10) - buff));
581
netStoreData(buff, internal::int10_to_str(from, buff, -10) - buff);
591
584
void ClientMySQLProtocol::store(uint32_t from)
594
netStoreData(buff, (size_t) (internal::int10_to_str(from, buff, 10) - buff));
587
netStoreData(buff, internal::int10_to_str(from, buff, 10) - buff);
597
590
void ClientMySQLProtocol::store(int64_t from)
600
netStoreData(buff, (size_t) (internal::int64_t10_to_str(from, buff, -10) - buff));
593
netStoreData(buff, internal::int64_t10_to_str(from, buff, -10) - buff);
603
596
void ClientMySQLProtocol::store(uint64_t from)
606
netStoreData(buff, (size_t) (internal::int64_t10_to_str(from, buff, 10) - buff));
599
netStoreData(buff, internal::int64_t10_to_str(from, buff, 10) - buff);
609
602
void ClientMySQLProtocol::store(double from, uint32_t decimals, String *buffer)
690
683
*end++= 0; /* an empty byte for some reason */
692
685
/* At this point we write connection message and read reply */
693
if (net.write_command(
694
(unsigned char) PROTOCOL_VERSION
695
, (unsigned char*) ""
697
, (unsigned char*) buff
698
, (size_t) (end-buff))
699
|| (pkt_len= net.read()) == packet_error
686
if (net.write_command(PROTOCOL_VERSION, data_ref().clear(), data_ref(buff, end))
687
|| (pkt_len= net.read()) == packet_error
700
688
|| pkt_len < MIN_HANDSHAKE_SIZE)
702
690
my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
706
694
packet.alloc(buffer_length.get());
708
696
client_capabilities= uint2korr(net.read_pos);
709
if (!(client_capabilities & CLIENT_PROTOCOL_MYSQL41))
697
if (not (client_capabilities & CLIENT_PROTOCOL_MYSQL41))
711
699
my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
822
810
write it to the network output buffer.
825
void ClientMySQLProtocol::writeEOFPacket(uint32_t server_status,
826
uint32_t total_warn_count)
813
void ClientMySQLProtocol::writeEOFPacket(uint32_t server_status, uint32_t total_warn_count)
828
815
unsigned char buff[5];
860
847
unsigned char *ClientMySQLProtocol::storeLength(unsigned char *buffer, uint64_t length)
862
if (length < (uint64_t) 251LL)
864
*buffer=(unsigned char) length;
851
*buffer= (unsigned char) length;
867
854
/* 251 is reserved for NULL */
868
if (length < (uint64_t) 65536LL)
871
int2store(buffer,(uint32_t) length);
858
int2store(buffer, (uint32_t) length);
874
if (length < (uint64_t) 16777216LL)
861
if (length < 16777216)
877
int3store(buffer,(uint32_t) length);
864
int3store(buffer, (uint32_t) length);
881
int8store(buffer,length);
868
int8store(buffer, length);