Implements the inner loop of nested-loops join within multi-DELETE execution. @param table The table from which to delete. @param ignore If used, all non fatal errors will be translated to warnings and we should not break the row-by-row iteration. @return Status code @retval 0 All ok. @retval 1 Triggers or handler reported error. @retval -1 End of file from handler. *
| 1625 | @retval -1 End of file from handler. |
| 1626 | */ |
| 1627 | int multi_delete::rowid_table_deletes(TABLE *table, bool ignore) |
| 1628 | { |
| 1629 | int local_error= 0; |
| 1630 | ha_rows last_deleted= deleted; |
| 1631 | DBUG_ENTER("rowid_table_deletes"); |
| 1632 | TABLE *err_table= nullptr; |
| 1633 | |
| 1634 | bool will_batch= !table->file->start_bulk_delete(); |
| 1635 | TABLE *tmp_table= tmp_tables[table_being_deleted->shared]; |
| 1636 | tmp_table->file->extra(HA_EXTRA_CACHE); // Change to read cache |
| 1637 | if (unlikely((local_error= table->file->ha_rnd_init(0)))) |
| 1638 | { |
| 1639 | err_table= table; |
| 1640 | goto err; |
| 1641 | } |
| 1642 | table->file->extra(HA_EXTRA_NO_CACHE); |
| 1643 | if (unlikely((local_error= tmp_table->file->ha_rnd_init(1)))) |
| 1644 | { |
| 1645 | err_table= tmp_table; |
| 1646 | goto err; |
| 1647 | } |
| 1648 | |
| 1649 | while (!thd->killed) |
| 1650 | { |
| 1651 | if (unlikely((local_error= |
| 1652 | tmp_table->file->ha_rnd_next(tmp_table->record[0])))) |
| 1653 | { |
| 1654 | if (local_error == HA_ERR_END_OF_FILE) |
| 1655 | { |
| 1656 | local_error= 0; |
| 1657 | break; |
| 1658 | } |
| 1659 | err_table= tmp_table; |
| 1660 | goto err; |
| 1661 | } |
| 1662 | |
| 1663 | DBUG_ASSERT(!tmp_table->field[0]->is_null()); |
| 1664 | String rowid; |
| 1665 | tmp_table->field[0]->val_str(&rowid); |
| 1666 | if (unlikely((local_error= table->file->ha_rnd_pos(table->record[0], |
| 1667 | (uchar*)rowid.ptr())))) |
| 1668 | { |
| 1669 | // Table aliased to itself had key deleted already |
| 1670 | continue; |
| 1671 | } |
| 1672 | |
| 1673 | bool trg_skip_row= false; |
| 1674 | |
| 1675 | if (table->triggers && |
| 1676 | unlikely(table->triggers->process_triggers(thd, TRG_EVENT_DELETE, |
| 1677 | TRG_ACTION_BEFORE, FALSE, |
| 1678 | &trg_skip_row))) |
| 1679 | { |
| 1680 | err_table= table; |
| 1681 | local_error= 1; |
| 1682 | break; |
| 1683 | } |
| 1684 |
nothing calls this directly
no test coverage detected