| 3654 | */ |
| 3655 | |
| 3656 | handler *handler::clone(const char *name, MEM_ROOT *mem_root) |
| 3657 | { |
| 3658 | int error= 0; |
| 3659 | handler *new_handler= get_new_handler(table->s, mem_root, ht); |
| 3660 | |
| 3661 | if (!new_handler) |
| 3662 | return NULL; |
| 3663 | if (new_handler->set_ha_share_ref(ha_share)) |
| 3664 | { |
| 3665 | error= ER_OUT_OF_RESOURCES; |
| 3666 | goto err; |
| 3667 | } |
| 3668 | |
| 3669 | /* |
| 3670 | TODO: Implement a more efficient way to have more than one index open for |
| 3671 | the same table instance. The ha_open call is not cacheable for clone. |
| 3672 | |
| 3673 | This is not critical as the engines already have the table open |
| 3674 | and should be able to use the original instance of the table. |
| 3675 | */ |
| 3676 | if ((error= new_handler->ha_open(table, name, |
| 3677 | table->db_stat & HA_READ_ONLY ? |
| 3678 | O_RDONLY : O_RDWR, |
| 3679 | HA_OPEN_IGNORE_IF_LOCKED, mem_root))) |
| 3680 | goto err; |
| 3681 | |
| 3682 | new_handler->handler_stats= handler_stats; |
| 3683 | new_handler->set_optimizer_costs(ha_thd()); |
| 3684 | |
| 3685 | return new_handler; |
| 3686 | |
| 3687 | err: |
| 3688 | new_handler->print_error(error, MYF(0)); |
| 3689 | delete new_handler; |
| 3690 | return NULL; |
| 3691 | } |
| 3692 | |
| 3693 | |
| 3694 | /** |
nothing calls this directly
no test coverage detected