~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Test of temporary tables
3
#
4
5
--disable_warnings
6
drop table if exists t1,t2;
642.1.36 by Lee
enable temp_table, timezone and timezone4 tests, timezone currently fails due to bug 309403
7
# we don't support views
8
#drop view if exists v1;
1 by brian
clean slate
9
--enable_warnings
10
11
CREATE TABLE t1 (c int not null, d char (10) not null);
12
insert into t1 values(1,""),(2,"a"),(3,"b");
13
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
14
insert into t1 values(4,"e"),(5,"f"),(6,"g");
15
alter table t1 rename t2;
16
select * from t1;
17
select * from t2;
18
CREATE TABLE t2 (x int not null, y int not null);
19
alter table t2 rename t1;
20
select * from t1;
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
21
create TEMPORARY TABLE t2 engine=MEMORY select * from t1;
22
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=MEMORY;
1 by brian
clean slate
23
24
# This should give errors
25
--error 1050
26
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
27
--error 1050
28
ALTER TABLE t1 RENAME t2;
29
30
select * from t2;
31
alter table t2 add primary key (a,b);
32
drop table t1,t2;
33
select * from t1;
34
drop table t2;
35
create temporary table t1 select *,2 as "e" from t1;
36
select * from t1;
37
drop table t1;
38
drop table t1;
39
40
#
41
# Test CONCAT_WS with temporary tables
42
#
43
44
CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
45
INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
46
SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
47
drop table t1;
48
create temporary table t1 select 1 as 'x';
49
drop table t1;
50
CREATE TABLE t1 (x INT);
51
INSERT INTO t1 VALUES (1), (2), (3);
52
CREATE TEMPORARY TABLE tmp SELECT *, NULL FROM t1;
53
drop table t1;
54
55
#
56
# Problem with ELT
57
#
642.1.36 by Lee
enable temp_table, timezone and timezone4 tests, timezone currently fails due to bug 309403
58
create temporary table t1 (id int not null unique);
59
create temporary table t2 (id int not null primary key, val int not null);
1 by brian
clean slate
60
61
# put in some initial values
62
insert into t1 values (1),(2),(4);
63
insert into t2 values (1,1),(2,1),(3,1),(4,2);
64
65
# do a query using ELT, a join and an ORDER BY.
66
select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
67
drop table t1,t2;
68
69
#
70
# Test of failed ALTER TABLE on temporary table
71
#
72
create temporary table t1 (a int not null);
73
insert into t1 values (1),(1);
74
-- error ER_DUP_ENTRY
75
alter table t1 add primary key (a);
76
drop table t1;
77
78
#
79
# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
80
# temporary table when a memory based one would be good enough.
81
1063.9.40 by Stewart Smith
temp_table.test for myisam as temp table.
82
CREATE TEMPORARY TABLE t1 (
1 by brian
clean slate
83
  d datetime default NULL
84
) ENGINE=MyISAM;
85
86
87
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');
88
89
flush status;
90
select * from t1 group by d;
91
show status like "created_tmp%tables";
92
drop table t1;
93
94
# Fix for BUG#8921: Check that temporary table is ingored by view commands.
642.1.36 by Lee
enable temp_table, timezone and timezone4 tests, timezone currently fails due to bug 309403
95
# Commenting this out since we don't support views
96
#create temporary table v1 as select 'This is temp. table' A;
97
#create view v1 as select 'This is view' A;
98
#select * from v1;
99
#show create table v1;
100
#show create view v1;
101
#drop view v1;
102
#select * from v1;
103
#create view v1 as select 'This is view again' A;
104
#select * from v1;
105
#drop table v1;
106
#select * from v1;
107
#drop view v1;
1 by brian
clean slate
108
109
# Bug #8497: tmpdir with extra slashes would cause failures
110
#
111
create table t1 (a int, b int, index(a), index(b));
112
create table t2 (c int auto_increment, d varchar(255), primary key (c));
113
insert into t1 values (3,1),(3,2);
114
insert into t2 values (NULL, 'foo'), (NULL, 'bar');
115
select d, c from t1 left join t2 on b = c where a = 3 order by d;
116
drop table t1, t2;
117
118
119
#
120
# Check that it's not possible to drop a base table with
121
# DROP TEMPORARY statement.
122
#
123
CREATE TABLE t1 (i INT);
124
CREATE TEMPORARY TABLE t2 (i INT);
125
126
--error 1051
127
DROP TEMPORARY TABLE t2, t1;
128
129
# Table t2 should have been dropped.
130
--error 1146
131
SELECT * FROM t2;
132
# But table t1 should still be there.
133
SELECT * FROM t1;
134
135
DROP TABLE t1;
136
137
138
--echo End of 4.1 tests.
139
140
#
141
# Bug #24791: Union with AVG-groups generates wrong results
142
#
143
CREATE TABLE t1 ( c FLOAT( 20, 14 ) );
144
INSERT INTO t1 VALUES( 12139 );
145
146
CREATE TABLE t2 ( c FLOAT(30,18) );
147
INSERT INTO t2 VALUES( 123456 );
148
149
SELECT AVG( c ) FROM t1 UNION SELECT 1;
150
SELECT 1 UNION SELECT AVG( c ) FROM t1;
151
SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1;
152
SELECT c/1 FROM t1 UNION SELECT 1;
153
154
DROP TABLE t1, t2;
155
156
#
157
# Test truncate with temporary tables
158
#
159
160
create temporary table t1 (a int);
161
insert into t1 values (4711);
162
select * from t1;
163
truncate t1;
164
insert into t1 values (42);
165
select * from t1;
166
drop table t1;
167
168
#
169
# Bug #35392: Delete all statement does not execute properly after 
170
# few delete statements
171
#
172
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
173
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
174
DELETE FROM t1 WHERE a=1;
175
SELECT count(*) FROM t1;
176
DELETE FROM t1;
177
SELECT * FROM t1;
178
DROP TABLE t1;
179
180
--echo End of 5.1 tests