Skip to content

Commit

Permalink
MDEV-30118 exception in ha_maria::extra
Browse files Browse the repository at this point in the history
I have not been able to repeat the problem, but the stack trace indicates
that ha_maria::extra() is called with a null file pointer.

This indicates the table has either never been opened or opened and closed,
with file pointer set to NULL, but ha_maria::extra() is still called.

In JOIN::partial_cleanup() we are only checking of table->is_created(),
which will fail if table was created and later closed.

Fixed by clearing table->created if table is dropped.

I added an assert to is_created() to catch the case that the create
flag does not match 'file'.
  • Loading branch information
montywi committed Dec 15, 2022
1 parent 92ff7bb commit d0cd494
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20320,6 +20320,8 @@ free_tmp_table(THD *thd, TABLE *entry)
}
entry->file->ha_drop_table(entry->s->path.str);
delete entry->file;
entry->file= NULL;
entry->reset_created();
}

/* free blobs */
Expand Down
11 changes: 10 additions & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,11 @@ struct TABLE
}

/// Return true if table is instantiated, and false otherwise.
bool is_created() const { return created; }
bool is_created() const
{
DBUG_ASSERT(!created || file != 0);
return created;
}

/**
Set the table as "created", and enable flags in storage engine
Expand All @@ -1658,6 +1662,11 @@ struct TABLE
created= true;
}

void reset_created()
{
created= 0;
}

/*
Returns TRUE if the table is filled at execution phase (and so, the
optimizer must not do anything that depends on the contents of the table,
Expand Down

0 comments on commit d0cd494

Please sign in to comment.