Skip to content

Commit d0cd494

Browse files
committed
MDEV-30118 exception in ha_maria::extra
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'.
1 parent 92ff7bb commit d0cd494

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sql/sql_select.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20320,6 +20320,8 @@ free_tmp_table(THD *thd, TABLE *entry)
2032020320
}
2032120321
entry->file->ha_drop_table(entry->s->path.str);
2032220322
delete entry->file;
20323+
entry->file= NULL;
20324+
entry->reset_created();
2032320325
}
2032420326

2032520327
/* free blobs */

sql/table.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,11 @@ struct TABLE
16431643
}
16441644

16451645
/// Return true if table is instantiated, and false otherwise.
1646-
bool is_created() const { return created; }
1646+
bool is_created() const
1647+
{
1648+
DBUG_ASSERT(!created || file != 0);
1649+
return created;
1650+
}
16471651

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

1665+
void reset_created()
1666+
{
1667+
created= 0;
1668+
}
1669+
16611670
/*
16621671
Returns TRUE if the table is filled at execution phase (and so, the
16631672
optimizer must not do anything that depends on the contents of the table,

0 commit comments

Comments
 (0)