15.13. Adding Support for DELETE to a Storage Engine
The MySQL server executes DELETE statements
using the same approach as for UPDATE
statements: It advances to the row to be deleted using the
rnd_next() function and then calls the
delete_row()
function to delete the row:
int ha_foo::delete_row(const byte *buf)
The *buf parameter contains the contents of the
row to be deleted. For non-indexed storage engines the parameter
can be ignored, but transactional storage engines may need to
store the deleted data for rollback purposes.
The following example is from the CSV storage
engine:
int ha_tina::delete_row(const byte * buf)
{
DBUG_ENTER("ha_tina::delete_row");
statistic_increment(table->in_use->status_var.ha_delete_count,
&LOCK_status);
if (chain_append())
DBUG_RETURN(-1);
--records;
DBUG_RETURN(0);
}
The steps of note in the preceding example are the update of the
delete_count statistic and the record count.