| 468 | } |
| 469 | |
| 470 | my_bool |
| 471 | cli_advanced_command(MYSQL *mysql, enum enum_server_command command, |
| 472 | const uchar *header, ulong header_length, |
| 473 | const uchar *arg, ulong arg_length, my_bool skip_check, |
| 474 | MYSQL_STMT *stmt) |
| 475 | { |
| 476 | NET *net= &mysql->net; |
| 477 | my_bool result= 1; |
| 478 | my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE; |
| 479 | DBUG_ENTER("cli_advanced_command"); |
| 480 | |
| 481 | if (mysql->net.vio == 0) |
| 482 | { /* Do reconnect if possible */ |
| 483 | if (mysql_reconnect(mysql) || stmt_skip) |
| 484 | DBUG_RETURN(1); |
| 485 | } |
| 486 | if (mysql->status != MYSQL_STATUS_READY || |
| 487 | mysql->server_status & SERVER_MORE_RESULTS_EXISTS) |
| 488 | { |
| 489 | DBUG_PRINT("error",("state: %d", mysql->status)); |
| 490 | set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); |
| 491 | DBUG_RETURN(1); |
| 492 | } |
| 493 | |
| 494 | net_clear_error(net); |
| 495 | mysql->info=0; |
| 496 | mysql->affected_rows= ~(my_ulonglong) 0; |
| 497 | /* |
| 498 | We don't want to clear the protocol buffer on COM_QUIT, because if |
| 499 | the previous command was a shutdown command, we may have the |
| 500 | response for the COM_QUIT already in the communication buffer |
| 501 | */ |
| 502 | net_clear(&mysql->net, (command != COM_QUIT)); |
| 503 | |
| 504 | if (net_write_command(net,(uchar) command, header, header_length, |
| 505 | arg, arg_length)) |
| 506 | { |
| 507 | DBUG_PRINT("error",("Can't send command to server. Error: %d", |
| 508 | socket_errno)); |
| 509 | if (net->last_errno == ER_NET_PACKET_TOO_LARGE) |
| 510 | { |
| 511 | set_mysql_error(mysql, CR_NET_PACKET_TOO_LARGE, unknown_sqlstate); |
| 512 | goto end; |
| 513 | } |
| 514 | if (net->last_errno == ER_NET_ERROR_ON_WRITE && command == COM_BINLOG_DUMP) |
| 515 | goto end; |
| 516 | end_server(mysql); |
| 517 | if (mysql_reconnect(mysql) || stmt_skip) |
| 518 | goto end; |
| 519 | if (net_write_command(net,(uchar) command, header, header_length, |
| 520 | arg, arg_length)) |
| 521 | { |
| 522 | set_mysql_error(mysql, CR_SERVER_GONE_ERROR, unknown_sqlstate); |
| 523 | goto end; |
| 524 | } |
| 525 | } |
| 526 | result=0; |
| 527 | if (!skip_check) |
nothing calls this directly
no test coverage detected