MCPcopy Create free account
hub / github.com/MariaDB/server / net_write_command

Function net_write_command

sql/net_serv.cc:483–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481*/
482
483my_bool
484net_write_command(NET *net,uchar command,
485 const uchar *header, size_t head_len,
486 const uchar *packet, size_t len)
487{
488 size_t length=len+1+head_len; /* 1 extra byte for command */
489 uchar buff[NET_HEADER_SIZE+1];
490 uint header_size=NET_HEADER_SIZE+1;
491 my_bool rc;
492 DBUG_ENTER("net_write_command");
493 DBUG_PRINT("enter",("length: %lu", (ulong) len));
494
495#ifdef ENABLED_DEBUG_SYNC
496 DBUG_EXECUTE_IF("simulate_error_on_packet_write",
497 {
498 if (command == COM_BINLOG_DUMP)
499 {
500 net->last_errno = ER_NET_ERROR_ON_WRITE;
501 DBUG_ASSERT(!debug_sync_set_action(
502 (THD *)net->thd,
503 STRING_WITH_LEN("now SIGNAL parked WAIT_FOR continue")));
504 DBUG_RETURN(true);
505 }
506 };);
507#endif
508 MYSQL_NET_WRITE_START(length);
509
510 buff[4]=command; /* For first packet */
511
512 if (length >= MAX_PACKET_LENGTH)
513 {
514 /* Take into account that we have the command in the first header */
515 len= MAX_PACKET_LENGTH - 1 - head_len;
516 do
517 {
518 int3store(buff, MAX_PACKET_LENGTH);
519 buff[3]= (uchar) net->pkt_nr++;
520 if (net_write_buff(net, buff, header_size) ||
521 net_write_buff(net, header, head_len) ||
522 net_write_buff(net, packet, len))
523 {
524 MYSQL_NET_WRITE_DONE(1);
525 DBUG_RETURN(1);
526 }
527 packet+= len;
528 length-= MAX_PACKET_LENGTH;
529 len= MAX_PACKET_LENGTH;
530 head_len= 0;
531 header_size= NET_HEADER_SIZE;
532 } while (length >= MAX_PACKET_LENGTH);
533 len=length; /* Data left to be written */
534 }
535 int3store(buff,length);
536 buff[3]= (uchar) net->pkt_nr++;
537 rc= MY_TEST(net_write_buff(net, buff, header_size) ||
538 (head_len && net_write_buff(net, header, head_len)) ||
539 net_write_buff(net, packet, len) || net_flush(net));
540 MYSQL_NET_WRITE_DONE(rc);

Callers 8

cli_advanced_commandFunction · 0.85
net_send_error_packetMethod · 0.85
net_send_progress_packetFunction · 0.85
skip_load_data_infileFunction · 0.85
net_request_fileFunction · 0.85
safe_queryFunction · 0.85

Calls 4

int3storeFunction · 0.85
net_write_buffFunction · 0.85
net_flushFunction · 0.85
debug_sync_set_actionFunction · 0.70

Tested by 1

safe_queryFunction · 0.68