~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Test of truncate
3
#
4
--disable_warnings
5
drop table if exists t1;
6
--enable_warnings
7
8
create table t1 (a integer, b integer,c1 CHAR(10));
9
insert into t1 (a) values (1),(2);
10
truncate table t1;
11
select count(*) from t1;
12
insert into t1 values(1,2,"test");
13
select count(*) from t1;
14
delete from t1;
15
select * from t1;
16
drop table t1;
17
# The following should fail
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
18
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
19
select count(*) from t1;
20
create temporary table t1 (n int);
21
insert into t1 values (1),(2),(3);
22
truncate table t1;
23
select * from t1;
24
drop table t1;
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
25
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
26
truncate non_existing_table;
27
28
#
29
# test autoincrement with TRUNCATE; verifying difference with DELETE
30
#
31
32
create table t1 (a integer auto_increment primary key);
33
insert into t1 (a) values (NULL),(NULL);
34
truncate table t1;
35
insert into t1 (a) values (NULL),(NULL);
36
SELECT * from t1;
37
delete from t1;
38
insert into t1 (a) values (NULL),(NULL);
39
SELECT * from t1;
40
drop table t1;
41
42
# Verifying that temp tables are handled the same way
43
44
create temporary table t1 (a integer auto_increment primary key);
45
insert into t1 (a) values (NULL),(NULL);
46
truncate table t1;
47
insert into t1 (a) values (NULL),(NULL);
48
SELECT * from t1;
49
delete from t1;
50
insert into t1 (a) values (NULL),(NULL);
51
SELECT * from t1;
52
drop table t1;
53
54
# End of 4.1 tests