summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/csv/csv_not_null.result
blob: 57ba0b726a7bdad8ee9072c22e94da80aab04ec1 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ===== csv_not_null.1 =====
DROP TABLE IF EXISTS t1, t2;
# === Will fail -- no NOT NULL ===
CREATE TABLE t1 (a int) ENGINE = CSV;
ERROR 42000: The storage engine for the table doesn't support nullable columns
# === Good CREATE ===
CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV;
# === Will fail -- ALL columns need NOT NULL ==
CREATE TABLE t2 (a int NOT NULL, b char(20)) ENGINE = CSV;
ERROR 42000: The storage engine for the table doesn't support nullable columns
DROP TABLE t1;
# ===== csv_not_null.2 =====
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int NOT NULL, b blob NOT NULL, c CHAR(20) NOT NULL, 
d VARCHAR(20) NOT NULL, e enum('foo','bar') NOT NULL,f DATE NOT NULL) 
ENGINE = CSV;
# === should result in default for each datatype ===
INSERT IGNORE INTO t1 VALUES();
SELECT * FROM t1;
a	b	c	d	e	f
0				foo	0000-00-00
INSERT IGNORE INTO t1 VALUES(default,default,default,default,default,default);
SELECT * FROM t1;
a	b	c	d	e	f
0				foo	0000-00-00
0				foo	0000-00-00
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31');
SELECT * FROM t1;
a	b	c	d	e	f
0				foo	0000-00-00
0				foo	0000-00-00
0	abc	def	ghi	bar	1999-12-31
# === insert failures ===
INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01');
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 VALUES(default(a),default(b), default(c), default(d),
default(e), default(f));
ERROR HY000: Field 'a' doesn't have a default value
DROP TABLE t1;
# ===== csv_not_null.3 =====
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int NOT NULL, b char(10) NOT NULL) ENGINE = CSV;
INSERT IGNORE INTO t1 VALUES();
SELECT * FROM t1;
a	b
0	
UPDATE t1 set b = 'new_value' where a = 0;
SELECT * FROM t1;
a	b
0	new_value
UPDATE IGNORE t1 set b = NULL where b = 'new_value';
Warnings:
Warning	1048	Column 'b' cannot be null
SELECT * FROM t1;
a	b
0	
DROP TABLE t1;