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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#-----------------------------------------------------------------------------
# csv_not_null.test - .test file for MySQL regression suite
# Purpose: To test the behavior of the CSV engine
# Bug#31473 resulted in strict enforcement of non-nullable
# columns in CSV engine.
# NOTE: Main functionality tested - NOT NULL restrictions on CSV tables
# CREATE, INSERT, and UPDATE statements
# ALTER statements in separate file due to BUG#33696
# Author pcrews
# Last modified: 2008-01-04
#-----------------------------------------------------------------------------
#############################################################################
# Testcase csv_not_null.1: CREATE TEMPORARY TABLE for CSV Engine requires explicit
# NOT NULL for each column
#############################################################################
-- echo # ===== csv_not_null.1 =====
DROP TABLE IF EXISTS t1, t2;
--echo # === Will fail -- no NOT NULL ===
--error ER_CHECK_NOT_IMPLEMENTED
CREATE TEMPORARY TABLE t1 (a int) ENGINE = CSV;
--echo # === Good CREATE ===
CREATE TEMPORARY TABLE t1 (a int NOT NULL) ENGINE = CSV;
--echo # === Will fail -- ALL columns need NOT NULL ==
--error ER_CHECK_NOT_IMPLEMENTED
CREATE TEMPORARY TABLE t2 (a int NOT NULL, b char(20)) ENGINE = CSV;
DROP TABLE t1;
##############################################################################
# Testcase csv_not_null.2: INSERT tests -- validating behavior of INSERT
# statements for CSV
##############################################################################
-- echo # ===== csv_not_null.2 =====
DROP TABLE IF EXISTS t1;
CREATE TEMPORARY 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;
--error 1364
INSERT INTO t1 VALUES();
SELECT * FROM t1;
# NOTE - Test disabled due to enum crash for this INSERT
# See Bug#33717 - INSERT...(default) fails for enum.
# Crashes CSV tables, loads spaces for MyISAM
#INSERT INTO t1 VALUES(default,default,default,default,default,default);
SELECT * FROM t1;
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31');
SELECT * FROM t1;
-- echo # === insert failures ===
--error ER_BAD_NULL_ERROR
INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01');
--error ER_NO_DEFAULT_FOR_FIELD
INSERT INTO t1 VALUES(default(a),default(b), default(c), default(d),
default(e), default(f));
DROP TABLE t1;
##############################################################################
# Testcase csv_not_null.3: UPDATE tests -- examining behavior of UPDATE
# statements for CSV
##############################################################################
-- echo # ===== csv_not_null.3 =====
DROP TABLE IF EXISTS t1;
CREATE TEMPORARY TABLE t1 (a int NOT NULL, b char(10) NOT NULL) ENGINE = CSV;
--error 1364
INSERT INTO t1 VALUES();
insert into t1 values (0,"");
SELECT * FROM t1;
UPDATE t1 set b = 'new_value' where a = 0;
SELECT * FROM t1;
--error ER_BAD_NULL_ERROR
UPDATE t1 set b = NULL where b = 'new_value';
SELECT * FROM t1;
DROP TABLE t1;
|