| 5859 | */ |
| 5860 | |
| 5861 | bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags, |
| 5862 | uint dt_phases) |
| 5863 | { |
| 5864 | DML_prelocking_strategy prelocking_strategy; |
| 5865 | uint counter; |
| 5866 | MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint(); |
| 5867 | DBUG_ENTER("open_normal_and_derived_tables"); |
| 5868 | if (open_tables(thd, &tables, &counter, flags, &prelocking_strategy)) |
| 5869 | goto end; |
| 5870 | |
| 5871 | // Process initialization phase if it is requested in dt_phases |
| 5872 | if ((dt_phases & DT_INIT) && mysql_handle_derived(thd->lex, DT_INIT)) |
| 5873 | goto end; |
| 5874 | |
| 5875 | thd->lex->resolve_optimizer_hints(); |
| 5876 | |
| 5877 | // Process all phases remaining after DT_INIT |
| 5878 | if (mysql_handle_derived(thd->lex, dt_phases & ~DT_INIT)) |
| 5879 | goto end; |
| 5880 | |
| 5881 | DBUG_RETURN(0); |
| 5882 | end: |
| 5883 | /* |
| 5884 | No need to commit/rollback the statement transaction: it's |
| 5885 | either not started or we're filling in an INFORMATION_SCHEMA |
| 5886 | table on the fly, and thus mustn't manipulate with the |
| 5887 | transaction of the enclosing statement. |
| 5888 | */ |
| 5889 | DBUG_ASSERT(thd->transaction->stmt.is_empty() || |
| 5890 | (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)); |
| 5891 | close_thread_tables(thd); |
| 5892 | /* Don't keep locks for a failed statement. */ |
| 5893 | thd->mdl_context.rollback_to_savepoint(mdl_savepoint); |
| 5894 | |
| 5895 | DBUG_RETURN(TRUE); /* purecov: inspected */ |
| 5896 | } |
| 5897 | |
| 5898 | |
| 5899 | /** |
no test coverage detected