~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# A field which is marked NOT NULL has no DEFAULT value should create an
# error.
CREATE TABLE t1 (A SERIAL);
INSERT INTO t1 VALUES (), (), ();
SELECT A from t1 ORDER BY A;
--error ER_INVALID_ALTER_TABLE_FOR_NOT_NULL
ALTER TABLE t1 ADD COLUMN b INT NOT NULL;
SELECT A from t1 ORDER BY A;
SHOW CREATE TABLE t1;
ALTER TABLE t1 ADD COLUMN b INT DEFAULT 1 NOT NULL;
SELECT A,B from t1 ORDER BY A;
DROP TABLE t1;

CREATE TABLE t1 (A SERIAL, b int);
INSERT INTO t1 VALUES (), (), ();
SELECT A,B from t1 ORDER BY A;
--error ER_WARN_DATA_TRUNCATED
ALTER TABLE t1 MODIFY COLUMN b int not null;
SELECT A,B from t1 ORDER BY A;
SHOW CREATE TABLE t1;
ALTER TABLE t1 MODIFY COLUMN b int DEFAULT 42 NOT NULL;
SELECT A,B from t1 ORDER BY A;
DROP TABLE t1;

CREATE TABLE t1 (col6 int not null);
INSERT INTO t1 VALUES (2);
SELECT * FROM t1;

alter table t1 modify column col6 int not null;

select * from t1;
drop table t1;