~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;
21
create TEMPORARY TABLE t2 engine=heap select * from t1;
22
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap;
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
82
CREATE TABLE t1 (
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
# BUG#21096: locking issue ; temporary table conflicts.
121
#
122
# The problem was that on DROP TEMPORARY table name lock was acquired,
123
# which should not be done.
124
#
125
--disable_warnings
126
DROP TABLE IF EXISTS t1;
127
--enable_warnings
128
129
CREATE TABLE t1 (i INT);
130
131
LOCK TABLE t1 WRITE;
132
133
connect (conn1, localhost, root,,);
134
135
CREATE TEMPORARY TABLE t1 (i INT);
136
137
--echo The following command should not block
138
DROP TEMPORARY TABLE t1;
139
140
disconnect conn1;
141
connection default;
142
143
DROP TABLE t1;
144
145
#
146
# Check that it's not possible to drop a base table with
147
# DROP TEMPORARY statement.
148
#
149
CREATE TABLE t1 (i INT);
150
CREATE TEMPORARY TABLE t2 (i INT);
151
152
--error 1051
153
DROP TEMPORARY TABLE t2, t1;
154
155
# Table t2 should have been dropped.
156
--error 1146
157
SELECT * FROM t2;
158
# But table t1 should still be there.
159
SELECT * FROM t1;
160
161
DROP TABLE t1;
162
163
164
--echo End of 4.1 tests.
165
166
#
167
# Bug #24791: Union with AVG-groups generates wrong results
168
#
169
CREATE TABLE t1 ( c FLOAT( 20, 14 ) );
170
INSERT INTO t1 VALUES( 12139 );
171
172
CREATE TABLE t2 ( c FLOAT(30,18) );
173
INSERT INTO t2 VALUES( 123456 );
174
175
SELECT AVG( c ) FROM t1 UNION SELECT 1;
176
SELECT 1 UNION SELECT AVG( c ) FROM t1;
177
SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1;
178
SELECT c/1 FROM t1 UNION SELECT 1;
179
180
DROP TABLE t1, t2;
181
182
#
183
# Test truncate with temporary tables
184
#
185
186
create temporary table t1 (a int);
187
insert into t1 values (4711);
188
select * from t1;
189
truncate t1;
190
insert into t1 values (42);
191
select * from t1;
192
drop table t1;
193
194
#
195
# Bug #35392: Delete all statement does not execute properly after 
196
# few delete statements
197
#
198
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
199
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
200
DELETE FROM t1 WHERE a=1;
201
SELECT count(*) FROM t1;
202
DELETE FROM t1;
203
SELECT * FROM t1;
204
DROP TABLE t1;
205
206
--echo End of 5.1 tests