~drizzle-trunk/drizzle/development

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