1
by brian
clean slate |
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 |
|
6 |
# === Good CREATE ===
|
|
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 |
|
11 |
DROP TABLE t1; |
|
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) |
|
16 |
ENGINE = CSV; |
|
17 |
# === should result in default for each datatype ===
|
|
18 |
INSERT INTO t1 VALUES(); |
|
19 |
SELECT * FROM t1; |
|
20 |
a b c d e f |
|
21 |
0 foo 0000-00-00 |
|
22 |
SELECT * FROM t1; |
|
23 |
a b c d e f |
|
24 |
0 foo 0000-00-00 |
|
25 |
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31'); |
|
26 |
SELECT * FROM t1; |
|
27 |
a b c d e f |
|
28 |
0 foo 0000-00-00 |
|
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 |
|
36 |
DROP TABLE t1; |
|
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(); |
|
41 |
SELECT * FROM t1; |
|
42 |
a b |
|
43 |
0
|
|
44 |
UPDATE t1 set b = 'new_value' where a = 0; |
|
45 |
SELECT * FROM t1; |
|
46 |
a b |
|
47 |
0 new_value |
|
48 |
UPDATE t1 set b = NULL where b = 'new_value'; |
|
49 |
ERROR 23000: Column 'b' cannot be null |
|
50 |
SELECT * FROM t1; |
|
51 |
a b |
|
52 |
0 new_value |
|
53 |
DROP TABLE t1; |