| 242 | }; |
| 243 | |
| 244 | static int execute_SQL(THD* thd, const char* sql, uint length) { |
| 245 | DBUG_ENTER("Wsrep_schema::execute_SQL()"); |
| 246 | int err= 0; |
| 247 | |
| 248 | PSI_statement_locker *parent_locker= thd->m_statement_psi; |
| 249 | Parser_state parser_state; |
| 250 | |
| 251 | WSREP_DEBUG("SQL: %d %s thd: %lld", length, sql, (long long)thd->thread_id); |
| 252 | |
| 253 | if (parser_state.init(thd, (char*)sql, length) == 0) { |
| 254 | thd->reset_for_next_command(); |
| 255 | lex_start(thd); |
| 256 | |
| 257 | thd->m_statement_psi= NULL; |
| 258 | |
| 259 | thd->set_query((char*)sql, length); |
| 260 | thd->set_query_id(next_query_id()); |
| 261 | |
| 262 | mysql_parse(thd, (char*)sql, length, & parser_state); |
| 263 | |
| 264 | if (thd->is_error()) { |
| 265 | WSREP_WARN("Wsrep_schema::execute_sql() failed, %d %s\nSQL: %s", |
| 266 | thd->get_stmt_da()->sql_errno(), |
| 267 | thd->get_stmt_da()->message(), |
| 268 | sql); |
| 269 | err= 1; |
| 270 | } |
| 271 | thd->m_statement_psi= parent_locker; |
| 272 | thd->end_statement(); |
| 273 | thd->reset_query(); |
| 274 | close_thread_tables(thd); |
| 275 | delete_explain_query(thd->lex); |
| 276 | } |
| 277 | else { |
| 278 | WSREP_WARN("SR init failure"); |
| 279 | } |
| 280 | thd->cleanup_after_query(); |
| 281 | DBUG_RETURN(err); |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | Initialize thd for next "statement" |
no test coverage detected