| 1475 | */ |
| 1476 | |
| 1477 | bool wait_while_table_is_used(THD *thd, TABLE *table, |
| 1478 | enum ha_extra_function function) |
| 1479 | { |
| 1480 | DBUG_ENTER("wait_while_table_is_used"); |
| 1481 | DBUG_ASSERT(!table->s->tmp_table); |
| 1482 | DBUG_PRINT("enter", ("table: '%s' share: %p db_stat: %u", |
| 1483 | table->s->table_name.str, table->s, |
| 1484 | table->db_stat)); |
| 1485 | |
| 1486 | if (thd->mdl_context.upgrade_shared_lock( |
| 1487 | table->mdl_ticket, MDL_EXCLUSIVE, |
| 1488 | thd->variables.lock_wait_timeout)) |
| 1489 | DBUG_RETURN(TRUE); |
| 1490 | |
| 1491 | table->s->tdc->flush(thd, true); |
| 1492 | /* extra() call must come only after all instances above are closed */ |
| 1493 | if (function != HA_EXTRA_NOT_USED) |
| 1494 | { |
| 1495 | int error= table->file->extra(function); |
| 1496 | if (error) |
| 1497 | table->file->print_error(error, MYF(0)); |
| 1498 | DBUG_RETURN(error); |
| 1499 | } |
| 1500 | DBUG_RETURN(FALSE); |
| 1501 | } |
| 1502 | |
| 1503 | |
| 1504 | /** |
no test coverage detected