| 558 | */ |
| 559 | |
| 560 | void Protocol::end_statement() |
| 561 | { |
| 562 | #ifdef WITH_WSREP |
| 563 | /* |
| 564 | Commented out: This sanity check does not hold in general. |
| 565 | Thd->LOCK_thd_data() must be unlocked before sending response |
| 566 | to client, so BF abort may sneak in here. |
| 567 | DBUG_ASSERT(!WSREP(thd) || thd->wsrep_conflict_state() == NO_CONFLICT); |
| 568 | */ |
| 569 | |
| 570 | /* |
| 571 | sanity check, don't send end statement while replaying |
| 572 | */ |
| 573 | DBUG_ASSERT(thd->wsrep_trx().state() != wsrep::transaction::s_replaying); |
| 574 | if (WSREP(thd) && thd->wsrep_trx().state() == |
| 575 | wsrep::transaction::s_replaying) |
| 576 | { |
| 577 | WSREP_ERROR("attempting net_end_statement while replaying"); |
| 578 | return; |
| 579 | } |
| 580 | #endif /* WITH_WSREP */ |
| 581 | |
| 582 | DBUG_ENTER("Protocol::end_statement"); |
| 583 | bool error= FALSE; |
| 584 | |
| 585 | /* This can set in the case of early result sent by select_send::send_eof() */ |
| 586 | if (thd->get_stmt_da()->is_sent()) |
| 587 | DBUG_VOID_RETURN; |
| 588 | |
| 589 | switch (thd->get_stmt_da()->status()) { |
| 590 | case Diagnostics_area::DA_ERROR: |
| 591 | thd->stop_collecting_unit_results(); |
| 592 | /* The query failed, send error to log and abort bootstrap. */ |
| 593 | error= send_error(thd->get_stmt_da()->sql_errno(), |
| 594 | thd->get_stmt_da()->message(), |
| 595 | thd->get_stmt_da()->get_sqlstate()); |
| 596 | break; |
| 597 | case Diagnostics_area::DA_EOF: |
| 598 | case Diagnostics_area::DA_EOF_BULK: |
| 599 | if (thd->need_report_unit_results()) { |
| 600 | // bulk returning result-set, like INSERT ... RETURNING |
| 601 | // result is already send, needs an EOF with MORE_RESULT_EXISTS |
| 602 | // before sending unit result-set |
| 603 | error= send_eof(thd->server_status | SERVER_MORE_RESULTS_EXISTS, |
| 604 | thd->get_stmt_da()->statement_warn_count()); |
| 605 | if (thd->report_collected_unit_results() && thd->is_error()) |
| 606 | error= send_error(thd->get_stmt_da()->sql_errno(), |
| 607 | thd->get_stmt_da()->message(), |
| 608 | thd->get_stmt_da()->get_sqlstate()); |
| 609 | else |
| 610 | error= send_eof(thd->server_status, |
| 611 | thd->get_stmt_da()->statement_warn_count()); |
| 612 | } |
| 613 | else |
| 614 | error= send_eof(thd->server_status, |
| 615 | thd->get_stmt_da()->statement_warn_count()); |
| 616 | break; |
| 617 | case Diagnostics_area::DA_OK: |