summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-12-13 12:43:19 +0200
committerMonty <monty@mariadb.org>2022-12-15 19:36:30 +0200
commitd0cd49497fcaf919c1f9c7e929e3003252db8c62 (patch)
treeddce32cbe42e45956b3bbdc26408de418b27cd09
parent92ff7bb63fee54a932ca0b7d8092af5aac1ded57 (diff)
downloadmariadb-git-d0cd49497fcaf919c1f9c7e929e3003252db8c62.tar.gz
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'.
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/table.h11
2 files changed, 12 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b03763e0d17..89270430041 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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 */
diff --git a/sql/table.h b/sql/table.h
index 70198ed5fdc..d704f3ce05e 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1643,7 +1643,11 @@ public:
}
/// 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
@@ -1658,6 +1662,11 @@ public:
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,