Skip to content

Commit

Permalink
handler: ensure that nobody makes a row operation not from table->file
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarrior committed May 8, 2023
1 parent 266aa7a commit f221bc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Expand Up @@ -7749,6 +7749,7 @@ ha_innobase::write_row(
bool auto_inc_used = false;

DBUG_ENTER("ha_innobase::write_row");
DBUG_ASSERT(table->file == this || dynamic_cast<ha_innobase*>(table->file) == NULL);

trx_t* trx = thd_to_trx(m_user_thd);

Expand Down Expand Up @@ -8479,6 +8480,7 @@ ha_innobase::update_row(

DBUG_ENTER("ha_innobase::update_row");

DBUG_ASSERT(table->file == this || dynamic_cast<ha_innobase*>(table->file) == NULL);
if (is_read_only()) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
} else if (!trx_is_started(trx)) {
Expand Down Expand Up @@ -8653,6 +8655,8 @@ ha_innobase::delete_row(

DBUG_ENTER("ha_innobase::delete_row");

DBUG_ASSERT(table->file == this || dynamic_cast<ha_innobase*>(table->file) == NULL);

if (is_read_only()) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
} else if (!trx_is_started(trx)) {
Expand Down
6 changes: 6 additions & 0 deletions storage/myisam/ha_myisam.cc
Expand Up @@ -983,6 +983,8 @@ int ha_myisam::close(void)

int ha_myisam::write_row(const uchar *buf)
{

DBUG_ASSERT(table->file == this || dynamic_cast<ha_myisam*>(table->file) == NULL);
/*
If we have an auto_increment column and we are writing a changed row
or a new row, then update the auto_increment value in the record.
Expand Down Expand Up @@ -1957,11 +1959,15 @@ bool ha_myisam::is_crashed() const

int ha_myisam::update_row(const uchar *old_data, const uchar *new_data)
{

DBUG_ASSERT(table->file == this || dynamic_cast<ha_myisam*>(table->file) == NULL);
return mi_update(file,old_data,new_data);
}

int ha_myisam::delete_row(const uchar *buf)
{

DBUG_ASSERT(table->file == this || dynamic_cast<ha_myisam*>(table->file) == NULL);
return mi_delete(file,buf);
}

Expand Down

0 comments on commit f221bc4

Please sign in to comment.