~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/default.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 already fixed bugs
 
3
#
 
4
--disable_warnings
 
5
drop table if exists t1,t2,t3,t4,t5,t6;
 
6
drop database if exists mysqltest;
 
7
 
 
8
#
 
9
# Bug 10838
 
10
# Insert causes warnings for no default values and corrupts tables
 
11
#
 
12
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
 
13
                 b varchar(1) binary NOT NULL DEFAULT ' ',
 
14
                 c varchar(4) binary NOT NULL DEFAULT '0000',
 
15
                 d tinyblob NULL,
 
16
                 e tinyblob NULL,
 
17
                 f tinyblob NULL,
 
18
                 g tinyblob NULL,
 
19
                 h tinyblob NULL,
 
20
                 i tinyblob NULL,
 
21
                 j tinyblob NULL,
 
22
                 k tinyblob NULL,
 
23
                 l tinyblob NULL,
 
24
                 m tinyblob NULL,
 
25
                 n tinyblob NULL,
 
26
                 o tinyblob NULL,
 
27
                 p tinyblob NULL,
 
28
                 q varchar(30) binary NOT NULL DEFAULT ' ',
 
29
                 r varchar(30) binary NOT NULL DEFAULT ' ',
 
30
                 s tinyblob NULL,
 
31
                 t varchar(4) binary NOT NULL DEFAULT ' ',
 
32
                 u varchar(1) binary NOT NULL DEFAULT ' ',
 
33
                 v varchar(30) binary NOT NULL DEFAULT ' ',
 
34
                 w varchar(30) binary NOT NULL DEFAULT ' ',
 
35
                 x tinyblob NULL,
 
36
                 y varchar(5) binary NOT NULL DEFAULT ' ',
 
37
                 z varchar(20) binary NOT NULL DEFAULT ' ',
 
38
                 a1 varchar(30) binary NOT NULL DEFAULT ' ',
 
39
                 b1 tinyblob NULL)
 
40
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
 
41
--enable_warnings
 
42
 
 
43
INSERT into t1 (b) values ('1');
 
44
SHOW WARNINGS;
 
45
SELECT * from t1;
 
46
 
 
47
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
 
48
                 b varchar(1) binary NOT NULL DEFAULT ' ',
 
49
                 c varchar(4) binary NOT NULL DEFAULT '0000',
 
50
                 d tinyblob NULL,
 
51
                 e tinyblob NULL,
 
52
                 f tinyblob NULL,
 
53
                 g tinyblob NULL,
 
54
                 h tinyblob NULL,
 
55
                 i tinyblob NULL,
 
56
                 j tinyblob NULL,
 
57
                 k tinyblob NULL,
 
58
                 l tinyblob NULL,
 
59
                 m tinyblob NULL,
 
60
                 n tinyblob NULL,
 
61
                 o tinyblob NULL,
 
62
                 p tinyblob NULL,
 
63
                 q varchar(30) binary NOT NULL DEFAULT ' ',
 
64
                 r varchar(30) binary NOT NULL DEFAULT ' ',
 
65
                 s tinyblob NULL,
 
66
                 t varchar(4) binary NOT NULL DEFAULT ' ',
 
67
                 u varchar(1) binary NOT NULL DEFAULT ' ',
 
68
                 v varchar(30) binary NOT NULL DEFAULT ' ',
 
69
                 w varchar(30) binary NOT NULL DEFAULT ' ',
 
70
                 x tinyblob NULL,
 
71
                 y varchar(5) binary NOT NULL DEFAULT ' ',
 
72
                 z varchar(20) binary NOT NULL DEFAULT ' ',
 
73
                 a1 varchar(30) binary NOT NULL DEFAULT ' ',
 
74
                 b1 tinyblob NULL)
 
75
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
 
76
 
 
77
SHOW CREATE TABLE t2;
 
78
INSERT into t2 (b) values ('1');
 
79
SHOW WARNINGS;
 
80
SELECT * from t2;
 
81
 
 
82
drop table t1;
 
83
drop table t2;
 
84
 
 
85
 
 
86
#
 
87
# Bug#20691: DATETIME col (NOT NULL, NO DEFAULT) may insert garbage when specifying DEFAULT
 
88
#
 
89
# From the docs:
 
90
#  If the column can take NULL as a value, the column is defined with an
 
91
#  explicit DEFAULT NULL clause. This is the same as before 5.0.2.
 
92
#
 
93
#  If the column cannot take NULL as the value, MySQL defines the column with
 
94
#  no explicit DEFAULT clause. For data entry, if an INSERT or REPLACE
 
95
#  statement includes no value for the column, MySQL handles the column
 
96
#  according to the SQL mode in effect at the time:
 
97
#
 
98
#    * If strict SQL mode is not enabled, MySQL sets the column to the
 
99
#      implicit default value for the column data type.
 
100
#
 
101
#    * If strict mode is enabled, an error occurs for transactional tables and
 
102
#      the statement is rolled back. For non-transactional tables, an error
 
103
#      occurs, but if this happens for the second or subsequent row of a
 
104
#      multiple-row statement, the preceding rows will have been inserted.
 
105
#
 
106
create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00');
 
107
insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT);
 
108
insert into bug20691 (i) values (2);
 
109
desc bug20691;
 
110
insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
 
111
insert into bug20691 (i) values (4);
 
112
insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT);
 
113
SET sql_mode = 'ALLOW_INVALID_DATES';
 
114
insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT);
 
115
SET sql_mode = 'STRICT_ALL_TABLES';
 
116
--error 1364
 
117
insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT);
 
118
select * from bug20691 order by i asc;
 
119
drop table bug20691;
 
120
 
 
121
SET sql_mode = '';
 
122
create table bug20691 (
 
123
  a set('one', 'two', 'three') not null,
 
124
  b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null,
 
125
  c time not null,
 
126
  d date not null,
 
127
  e int not null,
 
128
  f long not null,
 
129
  g blob not null,
 
130
  h datetime not null,
 
131
  i decimal not null,
 
132
  x int);
 
133
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1);
 
134
insert into bug20691 (x) values (2);
 
135
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3);
 
136
insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4);
 
137
select * from bug20691 order by x asc;
 
138
drop table bug20691;
 
139
 
 
140
create table t1 (id int not null);
 
141
insert into t1 values(default);
 
142
 
 
143
create view v1 (c) as select id from t1;
 
144
insert into t1 values(default);
 
145
drop view v1;
 
146
drop table t1;
 
147
 
 
148
--echo End of 5.0 tests.
 
149