mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user