1
# mysqltest should be fixed
2
-- source include/not_embedded.inc
4
# Test of temporary tables
8
drop table if exists t1,t2;
9
drop view if exists v1;
12
CREATE TABLE t1 (c int not null, d char (10) not null);
13
insert into t1 values(1,""),(2,"a"),(3,"b");
14
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
15
insert into t1 values(4,"e"),(5,"f"),(6,"g");
16
alter table t1 rename t2;
19
CREATE TABLE t2 (x int not null, y int not null);
20
alter table t2 rename t1;
22
create TEMPORARY TABLE t2 engine=heap select * from t1;
23
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap;
25
# This should give errors
27
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
29
ALTER TABLE t1 RENAME t2;
32
alter table t2 add primary key (a,b);
36
create temporary table t1 select *,2 as "e" from t1;
42
# Test CONCAT_WS with temporary tables
45
CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
46
INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
47
SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
49
create temporary table t1 select 1 as 'x';
51
CREATE TABLE t1 (x INT);
52
INSERT INTO t1 VALUES (1), (2), (3);
53
CREATE TEMPORARY TABLE tmp SELECT *, NULL FROM t1;
59
create temporary table t1 (id int(10) not null unique);
60
create temporary table t2 (id int(10) not null primary key,
61
val int(10) not null);
63
# put in some initial values
64
insert into t1 values (1),(2),(4);
65
insert into t2 values (1,1),(2,1),(3,1),(4,2);
67
# do a query using ELT, a join and an ORDER BY.
68
select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
72
# Test of failed ALTER TABLE on temporary table
74
create temporary table t1 (a int not null);
75
insert into t1 values (1),(1);
77
alter table t1 add primary key (a);
81
# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
82
# temporary table when a memory based one would be good enough.
85
d datetime default NULL
89
INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
92
select * from t1 group by d;
93
show status like "created_tmp%tables";
96
# Fix for BUG#8921: Check that temporary table is ingored by view commands.
97
create temporary table v1 as select 'This is temp. table' A;
98
create view v1 as select 'This is view' A;
100
show create table v1;
104
create view v1 as select 'This is view again' A;
110
# Bug #8497: tmpdir with extra slashes would cause failures
112
create table t1 (a int, b int, index(a), index(b));
113
create table t2 (c int auto_increment, d varchar(255), primary key (c));
114
insert into t1 values (3,1),(3,2);
115
insert into t2 values (NULL, 'foo'), (NULL, 'bar');
116
select d, c from t1 left join t2 on b = c where a = 3 order by d;
121
# BUG#21096: locking issue ; temporary table conflicts.
123
# The problem was that on DROP TEMPORARY table name lock was acquired,
124
# which should not be done.
127
DROP TABLE IF EXISTS t1;
130
CREATE TABLE t1 (i INT);
134
connect (conn1, localhost, root,,);
136
CREATE TEMPORARY TABLE t1 (i INT);
138
--echo The following command should not block
139
DROP TEMPORARY TABLE t1;
147
# Check that it's not possible to drop a base table with
148
# DROP TEMPORARY statement.
150
CREATE TABLE t1 (i INT);
151
CREATE TEMPORARY TABLE t2 (i INT);
154
DROP TEMPORARY TABLE t2, t1;
156
# Table t2 should have been dropped.
159
# But table t1 should still be there.
165
--echo End of 4.1 tests.
168
# Bug #24791: Union with AVG-groups generates wrong results
170
CREATE TABLE t1 ( c FLOAT( 20, 14 ) );
171
INSERT INTO t1 VALUES( 12139 );
173
CREATE TABLE t2 ( c FLOAT(30,18) );
174
INSERT INTO t2 VALUES( 123456 );
176
SELECT AVG( c ) FROM t1 UNION SELECT 1;
177
SELECT 1 UNION SELECT AVG( c ) FROM t1;
178
SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1;
179
SELECT c/1 FROM t1 UNION SELECT 1;
184
# Test truncate with temporary tables
187
create temporary table t1 (a int);
188
insert into t1 values (4711);
191
insert into t1 values (42);
196
# Bug #35392: Delete all statement does not execute properly after
197
# few delete statements
199
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
200
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
201
DELETE FROM t1 WHERE a=1;
202
SELECT count(*) FROM t1;
207
--echo End of 5.1 tests