| 2541 | */ |
| 2542 | |
| 2543 | inline Virtual_tmp_table * |
| 2544 | create_virtual_tmp_table(THD *thd, List<Spvar_definition> &field_list) |
| 2545 | { |
| 2546 | Virtual_tmp_table *table; |
| 2547 | if (!(table= new(thd) Virtual_tmp_table(thd))) |
| 2548 | return NULL; |
| 2549 | |
| 2550 | /* |
| 2551 | If "simulate_create_virtual_tmp_table_out_of_memory" debug option |
| 2552 | is enabled, we now enable "simulate_out_of_memory". This effectively |
| 2553 | makes table->init() fail on OOM inside multi_alloc_root(). |
| 2554 | This is done to test that ~Virtual_tmp_table() called from the "delete" |
| 2555 | below correctly handles OOM. |
| 2556 | */ |
| 2557 | DBUG_EXECUTE_IF("simulate_create_virtual_tmp_table_out_of_memory", |
| 2558 | DBUG_SET("+d,simulate_out_of_memory");); |
| 2559 | |
| 2560 | if (table->init(field_list.elements) || |
| 2561 | table->add(field_list) || |
| 2562 | table->open()) |
| 2563 | { |
| 2564 | delete table; |
| 2565 | return NULL; |
| 2566 | } |
| 2567 | return table; |
| 2568 | } |
| 2569 | |
| 2570 | |
| 2571 | /** |
no test coverage detected