| 25 | |
| 26 | extern "C" { |
| 27 | void sql_alloc_error_handler(void) |
| 28 | { |
| 29 | THD *thd= current_thd; |
| 30 | if (likely(thd)) |
| 31 | { |
| 32 | if (! thd->is_error()) |
| 33 | { |
| 34 | /* |
| 35 | This thread is Out Of Memory. |
| 36 | An OOM condition is a fatal error. |
| 37 | It should not be caught by error handlers in stored procedures. |
| 38 | Also, recording that SQL condition in the condition area could |
| 39 | cause more memory allocations, which in turn could raise more |
| 40 | OOM conditions, causing recursion in the error handling code itself. |
| 41 | As a result, my_error() should not be invoked, and the |
| 42 | thread diagnostics area is set to an error status directly. |
| 43 | Note that Diagnostics_area::set_error_status() is safe, |
| 44 | since it does not call any memory allocation routines. |
| 45 | The visible result for a client application will be: |
| 46 | - a query fails with an ER_OUT_OF_RESOURCES error, |
| 47 | returned in the error packet. |
| 48 | - SHOW ERROR/SHOW WARNINGS may be empty. |
| 49 | */ |
| 50 | thd->get_stmt_da()->set_error_status(ER_OUT_OF_RESOURCES); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* Skip writing to the error log to avoid mtr complaints */ |
| 55 | DBUG_EXECUTE_IF("simulate_out_of_memory", return;); |
| 56 | |
| 57 | sql_print_error("%s", ER_DEFAULT(ER_OUT_OF_RESOURCES)); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | void init_sql_alloc(PSI_memory_key key, MEM_ROOT *mem_root, uint block_size, |
nothing calls this directly
no test coverage detected