~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/t/truncate.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
18
--error 1146
 
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;
 
25
--error 1146
 
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
 
55
 
 
56
# Test for Bug#5507 "TRUNCATE should work with views"
 
57
#
 
58
# when it'll be fixed, the error should become 1347
 
59
# (test.v1' is not BASE TABLE)
 
60
#
 
61
 
 
62
create table t1 (s1 int); 
 
63
insert into t1 (s1) values (1), (2), (3), (4), (5);
 
64
create view v1 as select * from t1;
 
65
--error 1146
 
66
truncate table v1;
 
67
drop view v1;
 
68
drop table t1;
 
69
 
 
70
# End of 5.0 tests
 
71