| 1556 | } |
| 1557 | |
| 1558 | static int run_sql_command_thd(THD *thd, const char *query) |
| 1559 | { |
| 1560 | int ret= 0; |
| 1561 | |
| 1562 | thd->reset_for_next_command(); |
| 1563 | thd->set_query((char*)query, strlen(query)); |
| 1564 | |
| 1565 | Parser_state ps; |
| 1566 | if (ps.init(thd, thd->query(), thd->query_length())) |
| 1567 | { |
| 1568 | WSREP_ERROR("SST query: %s failed", query); |
| 1569 | ret= -1; |
| 1570 | } |
| 1571 | else |
| 1572 | { |
| 1573 | PSI_statement_locker *parent_locker= thd->m_statement_psi; |
| 1574 | thd->set_query_id(next_query_id()); |
| 1575 | |
| 1576 | mysql_parse(thd, thd->query(), thd->query_length(), &ps); |
| 1577 | if (thd->is_error()) |
| 1578 | { |
| 1579 | int const err= thd->get_stmt_da()->sql_errno(); |
| 1580 | if (err) |
| 1581 | { |
| 1582 | WSREP_WARN ("Error executing '%s': %d (%s)", |
| 1583 | query, err, thd->get_stmt_da()->message()); |
| 1584 | ret= err; |
| 1585 | } |
| 1586 | thd->clear_error(); |
| 1587 | } |
| 1588 | thd->m_statement_psi= parent_locker; |
| 1589 | thd->end_statement(); |
| 1590 | close_thread_tables(thd); |
| 1591 | delete_explain_query(thd->lex); |
| 1592 | } |
| 1593 | |
| 1594 | thd->reset_query(); |
| 1595 | thd->cleanup_after_query(); |
| 1596 | return ret; |
| 1597 | } |
| 1598 | |
| 1599 | |
| 1600 | #define SST_USER_PREFIX "wsrep.sst." |
no test coverage detected