1
# ===== csv_not_null.1 =====
2
DROP TABLE IF EXISTS t1, t2;
3
# === Will fail -- no NOT NULL ===
4
CREATE TABLE t1 (a int) ENGINE = CSV;
5
ERROR 42000: The storage engine for the table doesn't support nullable columns
7
CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV;
8
# === Will fail -- ALL columns need NOT NULL ==
9
CREATE TABLE t2 (a int NOT NULL, b char(20)) ENGINE = CSV;
10
ERROR 42000: The storage engine for the table doesn't support nullable columns
12
# ===== csv_not_null.2 =====
13
DROP TABLE IF EXISTS t1;
14
CREATE TABLE t1 (a int NOT NULL, b blob NOT NULL, c CHAR(20) NOT NULL,
15
d VARCHAR(20) NOT NULL, e enum('foo','bar') NOT NULL,f DATE NOT NULL)
17
# === should result in default for each datatype ===
18
INSERT INTO t1 VALUES();
25
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31');
29
0 abc def ghi bar 1999-12-31
30
# === insert failures ===
31
INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01');
32
ERROR 23000: Column 'a' cannot be null
33
INSERT INTO t1 VALUES(default(a),default(b), default(c), default(d),
34
default(e), default(f));
35
ERROR HY000: Field 'a' doesn't have a default value
37
# ===== csv_not_null.3 =====
38
DROP TABLE IF EXISTS t1;
39
CREATE TABLE t1 (a int NOT NULL, b char(10) NOT NULL) ENGINE = CSV;
40
INSERT INTO t1 VALUES();
44
UPDATE t1 set b = 'new_value' where a = 0;
48
UPDATE t1 set b = NULL where b = 'new_value';
49
ERROR 23000: Column 'b' cannot be null