Prepare, execute and clean-up a statement. @param query - query text @param length - query text length @param dynamic_open_cursor - if `OPEN c FOR 'SELECT ..'` is running @param result_arg - the result @param cursor_arg - the cursor @param &instrs_set_placeholder - the slice of sp_head::m_instr containing sp_instr_set_ps_placeholder instances for
| 5509 | Note, if some error happened during execution, it still returns "false". |
| 5510 | */ |
| 5511 | bool |
| 5512 | Prepared_statement::execute_immediate(const char *query, uint query_len, |
| 5513 | bool dynamic_open_cursor, |
| 5514 | select_result *result_arg, |
| 5515 | Server_side_cursor **cursor_arg, |
| 5516 | const InstrSlice &instrs_set_placeholder) |
| 5517 | { |
| 5518 | DBUG_ENTER("Prepared_statement::execute_immediate"); |
| 5519 | DBUG_ASSERT(result_arg); |
| 5520 | DBUG_ASSERT(cursor_arg); |
| 5521 | String expanded_query; |
| 5522 | static LEX_CSTRING execute_immediate_stmt_name= |
| 5523 | {STRING_WITH_LEN("(immediate)") }; |
| 5524 | |
| 5525 | set_sql_prepare(); |
| 5526 | name= execute_immediate_stmt_name; // for DBUG_PRINT etc |
| 5527 | |
| 5528 | m_prepared_stmt= MYSQL_CREATE_PS(this, id, thd->m_statement_psi, |
| 5529 | name.str, name.length); |
| 5530 | |
| 5531 | if (prepare(query, query_len)) |
| 5532 | DBUG_RETURN(true); |
| 5533 | |
| 5534 | if (dynamic_open_cursor ? |
| 5535 | (param_count != instrs_set_placeholder.count()) : |
| 5536 | (param_count != thd->lex->prepared_stmt.param_count())) |
| 5537 | { |
| 5538 | my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE"); |
| 5539 | deallocate_immediate(); |
| 5540 | DBUG_RETURN(true); |
| 5541 | } |
| 5542 | |
| 5543 | MYSQL_EXECUTE_PS(thd->m_statement_psi, m_prepared_stmt); |
| 5544 | bool rc= execute_loop(&expanded_query, dynamic_open_cursor, |
| 5545 | result_arg, cursor_arg, |
| 5546 | instrs_set_placeholder, |
| 5547 | NULL, NULL); |
| 5548 | deallocate_immediate(); |
| 5549 | DBUG_RETURN(rc); |
| 5550 | } |
| 5551 | |
| 5552 | |
| 5553 | /** |
no test coverage detected