| 5791 | */ |
| 5792 | |
| 5793 | bool open_and_lock_tables(THD *thd, const DDL_options_st &options, |
| 5794 | TABLE_LIST *tables, |
| 5795 | bool derived, uint flags, |
| 5796 | Prelocking_strategy *prelocking_strategy) |
| 5797 | { |
| 5798 | uint counter; |
| 5799 | MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint(); |
| 5800 | DBUG_ENTER("open_and_lock_tables"); |
| 5801 | DBUG_PRINT("enter", ("derived handling: %d", derived)); |
| 5802 | |
| 5803 | if (open_tables(thd, options, &tables, &counter, flags, prelocking_strategy)) |
| 5804 | goto err; |
| 5805 | |
| 5806 | DBUG_EXECUTE_IF("sleep_open_and_lock_after_open", { |
| 5807 | const char *old_proc_info= thd->proc_info; |
| 5808 | thd->proc_info= "DBUG sleep"; |
| 5809 | my_sleep(6000000); |
| 5810 | thd->proc_info= old_proc_info;}); |
| 5811 | |
| 5812 | if (lock_tables(thd, tables, counter, flags)) |
| 5813 | goto err; |
| 5814 | |
| 5815 | /* Don't read statistics tables when opening internal tables */ |
| 5816 | if (!(flags & (MYSQL_OPEN_IGNORE_LOGGING_FORMAT | |
| 5817 | MYSQL_OPEN_IGNORE_ENGINE_STATS))) |
| 5818 | (void) read_statistics_for_tables_if_needed(thd, tables); |
| 5819 | |
| 5820 | if (derived) |
| 5821 | { |
| 5822 | if (mysql_handle_derived(thd->lex, DT_INIT)) |
| 5823 | goto err; |
| 5824 | if (thd->prepare_derived_at_open && |
| 5825 | (mysql_handle_derived(thd->lex, DT_PREPARE))) |
| 5826 | goto err; |
| 5827 | } |
| 5828 | |
| 5829 | DBUG_RETURN(FALSE); |
| 5830 | err: |
| 5831 | if (! thd->in_sub_stmt) |
| 5832 | trans_rollback_stmt(thd); /* Necessary if derived handling failed. */ |
| 5833 | close_thread_tables(thd); |
| 5834 | /* Don't keep locks for a failed statement. */ |
| 5835 | thd->mdl_context.rollback_to_savepoint(mdl_savepoint); |
| 5836 | DBUG_RETURN(TRUE); |
| 5837 | } |
| 5838 | |
| 5839 | |
| 5840 | /* |
no test coverage detected