summaryrefslogtreecommitdiff
path: root/mysql-test/suite/handler
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2016-06-10 16:19:59 -0400
committerNirbhay Choubey <nirbhay@mariadb.com>2016-06-10 18:39:43 -0400
commit7305be2f7e724e5e62961606794beab199d79045 (patch)
tree403bd132ee82a16946e3208f5d535de6e5945b80 /mysql-test/suite/handler
parent547511153fb1f59688752aa5524ae411b5960c92 (diff)
downloadmariadb-git-7305be2f7e724e5e62961606794beab199d79045.tar.gz
MDEV-5535: Cannot reopen temporary table
mysqld maintains a list of TABLE objects for all temporary tables created within a session in THD. Here each table is represented by a TABLE object. A query referencing a particular temporary table for more than once, however, failed with ER_CANT_REOPEN_TABLE error because a TABLE_SHARE was allocate together with the TABLE, so temporary tables always had only one TABLE per TABLE_SHARE. This patch lift this restriction by separating TABLE and TABLE_SHARE objects and storing TABLE_SHAREs for temporary tables in a list in THD, and TABLEs in a list within their respective TABLE_SHAREs.
Diffstat (limited to 'mysql-test/suite/handler')
-rw-r--r--mysql-test/suite/handler/aria.result22
-rw-r--r--mysql-test/suite/handler/handler.inc7
-rw-r--r--mysql-test/suite/handler/heap.result22
-rw-r--r--mysql-test/suite/handler/innodb.result22
-rw-r--r--mysql-test/suite/handler/myisam.result22
5 files changed, 77 insertions, 18 deletions
diff --git a/mysql-test/suite/handler/aria.result b/mysql-test/suite/handler/aria.result
index 43720eaa4bb..b8ed1fd98c8 100644
--- a/mysql-test/suite/handler/aria.result
+++ b/mysql-test/suite/handler/aria.result
@@ -632,7 +632,18 @@ handler a1 read a next;
a b
3 d
select a,b from t1;
-ERROR HY000: Can't reopen table: 'a1'
+a b
+0 a
+1 b
+2 c
+3 d
+4 e
+5 f
+6 g
+7 h
+8 i
+9 j
+9 k
handler a1 read a prev;
a b
2 c
@@ -745,7 +756,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
handler t2 close;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
handler t3 open;
-ERROR HY000: Can't reopen table: 't3'
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
# After UNLOCK TABLES handlers should be around and
# we should be able to continue reading through them.
unlock tables;
@@ -1396,7 +1407,12 @@ handler t2 read a next;
a b
3 NULL
select * from t2;
-ERROR HY000: Can't reopen table: 't2'
+a b
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
handler t2 read a next;
a b
4 NULL
diff --git a/mysql-test/suite/handler/handler.inc b/mysql-test/suite/handler/handler.inc
index b1e881f1bd8..a4ab5f1ed32 100644
--- a/mysql-test/suite/handler/handler.inc
+++ b/mysql-test/suite/handler/handler.inc
@@ -460,9 +460,6 @@ drop table t1;
#
# Bug#30882 Dropping a temporary table inside a stored function may cause a server crash
#
-# Test HANDLER statements in conjunction with temporary tables. While the temporary table
-# is open by a HANDLER, no other statement can access it.
-#
create temporary table t1 (a int, b char(1), key a using btree (a), key b using btree (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
@@ -472,7 +469,6 @@ handler t1 open as a1;
handler a1 read a=(1);
handler a1 read a next;
handler a1 read a next;
---error ER_CANT_REOPEN_TABLE
select a,b from t1;
handler a1 read a prev;
handler a1 read a prev;
@@ -564,7 +560,7 @@ handler t1 open;
handler t1 read next;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
handler t2 close;
---error ER_CANT_REOPEN_TABLE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
handler t3 open;
--echo # After UNLOCK TABLES handlers should be around and
--echo # we should be able to continue reading through them.
@@ -1182,7 +1178,6 @@ handler t1 read a next;
select * from t1;
--echo # Sic: the position is not lost
handler t2 read a next;
---error ER_CANT_REOPEN_TABLE
select * from t2;
handler t2 read a next;
drop table t1;
diff --git a/mysql-test/suite/handler/heap.result b/mysql-test/suite/handler/heap.result
index e558911e2e1..70dcefe4ff3 100644
--- a/mysql-test/suite/handler/heap.result
+++ b/mysql-test/suite/handler/heap.result
@@ -632,7 +632,18 @@ handler a1 read a next;
a b
3 d
select a,b from t1;
-ERROR HY000: Can't reopen table: 'a1'
+a b
+0 a
+1 b
+2 c
+3 d
+4 e
+5 f
+6 g
+7 h
+8 i
+9 j
+9 k
handler a1 read a prev;
a b
2 c
@@ -745,7 +756,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
handler t2 close;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
handler t3 open;
-ERROR HY000: Can't reopen table: 't3'
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
# After UNLOCK TABLES handlers should be around and
# we should be able to continue reading through them.
unlock tables;
@@ -1396,7 +1407,12 @@ handler t2 read a next;
a b
3 NULL
select * from t2;
-ERROR HY000: Can't reopen table: 't2'
+a b
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
handler t2 read a next;
a b
4 NULL
diff --git a/mysql-test/suite/handler/innodb.result b/mysql-test/suite/handler/innodb.result
index fc1089ee445..f3c0f798902 100644
--- a/mysql-test/suite/handler/innodb.result
+++ b/mysql-test/suite/handler/innodb.result
@@ -633,7 +633,18 @@ handler a1 read a next;
a b
3 d
select a,b from t1;
-ERROR HY000: Can't reopen table: 'a1'
+a b
+0 a
+1 b
+2 c
+3 d
+4 e
+5 f
+6 g
+7 h
+8 i
+9 j
+9 k
handler a1 read a prev;
a b
2 c
@@ -747,7 +758,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
handler t2 close;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
handler t3 open;
-ERROR HY000: Can't reopen table: 't3'
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
# After UNLOCK TABLES handlers should be around and
# we should be able to continue reading through them.
unlock tables;
@@ -1400,7 +1411,12 @@ handler t2 read a next;
a b
3 NULL
select * from t2;
-ERROR HY000: Can't reopen table: 't2'
+a b
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
handler t2 read a next;
a b
4 NULL
diff --git a/mysql-test/suite/handler/myisam.result b/mysql-test/suite/handler/myisam.result
index 84cd8bbd5d2..fca75f3b7a6 100644
--- a/mysql-test/suite/handler/myisam.result
+++ b/mysql-test/suite/handler/myisam.result
@@ -632,7 +632,18 @@ handler a1 read a next;
a b
3 d
select a,b from t1;
-ERROR HY000: Can't reopen table: 'a1'
+a b
+0 a
+1 b
+2 c
+3 d
+4 e
+5 f
+6 g
+7 h
+8 i
+9 j
+9 k
handler a1 read a prev;
a b
2 c
@@ -745,7 +756,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
handler t2 close;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
handler t3 open;
-ERROR HY000: Can't reopen table: 't3'
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
# After UNLOCK TABLES handlers should be around and
# we should be able to continue reading through them.
unlock tables;
@@ -1396,7 +1407,12 @@ handler t2 read a next;
a b
3 NULL
select * from t2;
-ERROR HY000: Can't reopen table: 't2'
+a b
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
handler t2 read a next;
a b
4 NULL