| 5221 | */ |
| 5222 | |
| 5223 | bool Prepared_statement::execute(String *expanded_query, bool open_cursor, |
| 5224 | select_result *result_arg, |
| 5225 | Server_side_cursor **cursor_arg) |
| 5226 | { |
| 5227 | DBUG_ASSERT(result_arg); |
| 5228 | DBUG_ASSERT(cursor_arg); |
| 5229 | Statement stmt_backup; |
| 5230 | Query_arena *old_stmt_arena; |
| 5231 | bool error= TRUE; |
| 5232 | bool qc_executed= FALSE; |
| 5233 | char saved_db_buf[SAFE_NAME_LEN+1]; |
| 5234 | LEX_STRING saved_db= { saved_db_buf, sizeof(saved_db_buf) }; |
| 5235 | bool cur_db_changed; |
| 5236 | LEX_CSTRING stmt_db_name= db; |
| 5237 | |
| 5238 | if (check_charset_collation_map_version(thd, thd->m_reprepare_observer)) |
| 5239 | return true; |
| 5240 | |
| 5241 | status_var_increment(thd->status_var.com_stmt_execute); |
| 5242 | |
| 5243 | if (flags & (uint) IS_IN_USE) |
| 5244 | { |
| 5245 | my_error(ER_PS_NO_RECURSION, MYF(0)); |
| 5246 | return TRUE; |
| 5247 | } |
| 5248 | |
| 5249 | /* |
| 5250 | For SHOW VARIABLES lex->result is NULL, as it's a non-SELECT |
| 5251 | command. For such queries we don't return an error and don't |
| 5252 | open a cursor -- the client library will recognize this case and |
| 5253 | materialize the result set. |
| 5254 | For SELECT statements lex->result is created in |
| 5255 | check_prepared_statement. lex->result->simple_select() is FALSE |
| 5256 | in INSERT ... SELECT and similar commands. |
| 5257 | */ |
| 5258 | |
| 5259 | if (open_cursor && lex->result && lex->result->check_simple_select()) |
| 5260 | { |
| 5261 | DBUG_PRINT("info",("Cursor asked for not SELECT stmt")); |
| 5262 | return TRUE; |
| 5263 | } |
| 5264 | |
| 5265 | /* In case the command has a call to SP which re-uses this statement name */ |
| 5266 | flags|= IS_IN_USE; |
| 5267 | |
| 5268 | close_cursor(); |
| 5269 | |
| 5270 | /* |
| 5271 | If the free_list is not empty, we'll wrongly free some externally |
| 5272 | allocated items when cleaning up after execution of this statement. |
| 5273 | */ |
| 5274 | DBUG_ASSERT(thd->Item_change_list::is_empty()); |
| 5275 | |
| 5276 | /* |
| 5277 | The only case where we should have items in the thd->free_list is |
| 5278 | after stmt->set_params_from_vars(), which may in some cases create |
| 5279 | Item_null objects. |
| 5280 | */ |
nothing calls this directly
no test coverage detected