summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-02-05 15:52:17 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-02-05 15:52:17 +0100
commit1ca7c51961f3e4840f1f054898eacbe39dfec058 (patch)
tree1305dc194ec8b02a56b3a927e76878558587d8bb /sql/sql_handler.cc
parent89269e5142322af414316c9e09f948da48adc1e0 (diff)
downloadmariadb-git-1ca7c51961f3e4840f1f054898eacbe39dfec058.tar.gz
Bug #50907 Assertion `hash_tables->table->next == __null' on
HANDLER OPEN The problem was a too restrictive assert in the code for HANDLER ... OPEN and HANDLER ... READ that checked table->next to verify that we didn't open views or merge tables. This pointer is also used to link temporary tables together (see thd->temporary_tables). In this case TABLE::next can be set even if we're trying to open a single table. This patch adjust the two asserts to also check for the presence of temporary tables. Test case added to handler_myisam.test.
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 4b22d5e8eec..d9c2a84d03e 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -322,8 +322,14 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
thd->mdl_context.set_needs_thr_lock_abort(TRUE);
}
- /* Assert that the above check prevent opening of views and merge tables. */
- DBUG_ASSERT(hash_tables->table->next == NULL);
+ /*
+ Assert that the above check prevents opening of views and merge tables.
+ For temporary tables, TABLE::next can be set even if only one table
+ was opened for HANDLER as it is used to link them together
+ (see thd->temporary_tables).
+ */
+ DBUG_ASSERT(hash_tables->table->next == NULL ||
+ hash_tables->table->s->tmp_table);
/*
If it's a temp table, don't reset table->query_id as the table is
being used by this handler. Otherwise, no meaning at all.
@@ -485,7 +491,8 @@ retry:
/* save open_tables state */
backup_open_tables= thd->open_tables;
/* Always a one-element list, see mysql_ha_open(). */
- DBUG_ASSERT(hash_tables->table->next == NULL);
+ DBUG_ASSERT(hash_tables->table->next == NULL ||
+ hash_tables->table->s->tmp_table);
/*
mysql_lock_tables() needs thd->open_tables to be set correctly to
be able to handle aborts properly.