~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
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
25
--error ER_TABLE_EXISTS_ERROR
1 by brian
clean slate
26
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
27
--error ER_TABLE_EXISTS_ERROR
1 by brian
clean slate
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;
1273.16.1 by Brian Aker
More removal of show code.
91
--replace_column 2 #
1 by brian
clean slate
92
show status like "created_tmp%tables";
93
drop table t1;
94
95
# 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
96
# Commenting this out since we don't support views
97
#create temporary table v1 as select 'This is temp. table' A;
98
#create view v1 as select 'This is view' A;
99
#select * from v1;
100
#show create table v1;
101
#show create view v1;
102
#drop view v1;
103
#select * from v1;
104
#create view v1 as select 'This is view again' A;
105
#select * from v1;
106
#drop table v1;
107
#select * from v1;
108
#drop view v1;
1 by brian
clean slate
109
110
# Bug #8497: tmpdir with extra slashes would cause failures
111
#
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;
117
drop table t1, t2;
118
119
120
#
121
# Check that it's not possible to drop a base table with
122
# DROP TEMPORARY statement.
123
#
124
CREATE TABLE t1 (i INT);
125
CREATE TEMPORARY TABLE t2 (i INT);
126
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
127
--error ER_BAD_TABLE_ERROR
1 by brian
clean slate
128
DROP TEMPORARY TABLE t2, t1;
129
130
# Table t2 should have been dropped.
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
131
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
132
SELECT * FROM t2;
133
# But table t1 should still be there.
134
SELECT * FROM t1;
135
136
DROP TABLE t1;
137
138
139
--echo End of 4.1 tests.
140
141
#
142
# Bug #24791: Union with AVG-groups generates wrong results
143
#
144
CREATE TABLE t1 ( c FLOAT( 20, 14 ) );
145
INSERT INTO t1 VALUES( 12139 );
146
147
CREATE TABLE t2 ( c FLOAT(30,18) );
148
INSERT INTO t2 VALUES( 123456 );
149
150
SELECT AVG( c ) FROM t1 UNION SELECT 1;
151
SELECT 1 UNION SELECT AVG( c ) FROM t1;
152
SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1;
153
SELECT c/1 FROM t1 UNION SELECT 1;
154
155
DROP TABLE t1, t2;
156
157
#
158
# Test truncate with temporary tables
159
#
160
161
create temporary table t1 (a int);
162
insert into t1 values (4711);
163
select * from t1;
164
truncate t1;
165
insert into t1 values (42);
166
select * from t1;
167
drop table t1;
168
169
#
170
# Bug #35392: Delete all statement does not execute properly after 
171
# few delete statements
172
#
173
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
174
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
175
DELETE FROM t1 WHERE a=1;
176
SELECT count(*) FROM t1;
177
DELETE FROM t1;
178
SELECT * FROM t1;
179
DROP TABLE t1;
180
181
--echo End of 5.1 tests