| 343 | #endif |
| 344 | |
| 345 | static bool open_only_one_table(THD* thd, TABLE_LIST* table, |
| 346 | bool repair_table_use_frm, |
| 347 | bool is_view_operator_func) |
| 348 | { |
| 349 | LEX *lex= thd->lex; |
| 350 | SELECT_LEX *select= lex->first_select_lex(); |
| 351 | TABLE_LIST *save_next_global, *save_next_local; |
| 352 | bool open_error; |
| 353 | save_next_global= table->next_global; |
| 354 | table->next_global= 0; |
| 355 | save_next_local= table->next_local; |
| 356 | table->next_local= 0; |
| 357 | select->table_list.first= table; |
| 358 | /* |
| 359 | Time zone tables and SP tables can be add to lex->query_tables list, |
| 360 | so it have to be prepared. |
| 361 | TODO: Investigate if we can put extra tables into argument instead of |
| 362 | using lex->query_tables |
| 363 | */ |
| 364 | lex->query_tables= table; |
| 365 | lex->query_tables_last= &table->next_global; |
| 366 | lex->query_tables_own_last= 0; |
| 367 | |
| 368 | DBUG_EXECUTE_IF("fail_2call_open_only_one_table", { |
| 369 | if (debug_fail_counter) |
| 370 | { |
| 371 | open_error= TRUE; |
| 372 | goto dbug_err; |
| 373 | } |
| 374 | else |
| 375 | debug_fail_counter++; |
| 376 | }); |
| 377 | |
| 378 | /* |
| 379 | CHECK TABLE command is allowed for views as well. Check on alter flags |
| 380 | to differentiate from ALTER TABLE...CHECK PARTITION on which view is not |
| 381 | allowed. |
| 382 | */ |
| 383 | if (lex->alter_info.partition_flags & ALTER_PARTITION_ADMIN || |
| 384 | !is_view_operator_func) |
| 385 | { |
| 386 | table->required_type= TABLE_TYPE_NORMAL; |
| 387 | DBUG_ASSERT(lex->table_type != TABLE_TYPE_VIEW); |
| 388 | } |
| 389 | else if (lex->table_type == TABLE_TYPE_VIEW) |
| 390 | { |
| 391 | table->required_type= lex->table_type; |
| 392 | } |
| 393 | else if ((lex->table_type != TABLE_TYPE_VIEW) && |
| 394 | lex->sql_command == SQLCOM_REPAIR) |
| 395 | { |
| 396 | table->required_type= TABLE_TYPE_NORMAL; |
| 397 | } |
| 398 | |
| 399 | if (lex->sql_command == SQLCOM_CHECK || |
| 400 | lex->sql_command == SQLCOM_REPAIR || |
| 401 | lex->sql_command == SQLCOM_ANALYZE || |
| 402 | lex->sql_command == SQLCOM_OPTIMIZE) |
no test coverage detected