~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#-----------------------------------------------------------------------------
2
# csv_not_null.test - .test file for MySQL regression suite
3
# Purpose:  To test the behavior of the CSV engine
4
#           Bug#31473 resulted in strict enforcement of non-nullable
5
#           columns in CSV engine.
6
# NOTE:     Main functionality tested - NOT NULL restrictions on CSV tables
7
#           CREATE, INSERT, and UPDATE statements 
8
#           ALTER statements in separate file due to BUG#33696 
9
# Author pcrews
10
# Last modified:  2008-01-04
11
#-----------------------------------------------------------------------------
12
13
--source include/have_csv.inc
14
15
#############################################################################
16
# Testcase csv_not_null.1:  CREATE TABLE for CSV Engine requires explicit
17
#                           NOT NULL for each column
18
#############################################################################
19
-- echo # ===== csv_not_null.1 =====
20
-- disable_warnings
21
DROP TABLE IF EXISTS t1, t2;
22
-- enable_warnings
23
24
25
--echo # === Will fail -- no NOT NULL ===
26
--error ER_CHECK_NOT_IMPLEMENTED
27
CREATE TABLE t1 (a int) ENGINE = CSV;
28
29
--echo # === Good CREATE ===
30
CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV;
31
32
--echo # === Will fail -- ALL columns need NOT NULL ==
33
--error ER_CHECK_NOT_IMPLEMENTED
34
CREATE TABLE t2 (a int NOT NULL, b char(20)) ENGINE = CSV;
35
36
37
DROP TABLE t1;
38
##############################################################################
39
# Testcase csv_not_null.2:  INSERT tests -- validating behavior of INSERT
40
#                           statements for CSV
41
##############################################################################
42
-- echo # ===== csv_not_null.2 =====
43
-- disable_warnings
44
DROP TABLE IF EXISTS t1;
45
--enable_warnings
46
47
48
CREATE TABLE t1 (a int NOT NULL, b blob NOT NULL, c CHAR(20) NOT NULL, 
49
d VARCHAR(20) NOT NULL, e enum('foo','bar') NOT NULL,f DATE NOT NULL) 
50
ENGINE = CSV;
51
-- echo # === should result in default for each datatype ===
52
-- disable_warnings
53
INSERT INTO t1 VALUES();
54
-- enable_warnings
55
SELECT * FROM t1;
56
57
-- disable_warnings
58
# NOTE - Test disabled due to enum crash for this INSERT
59
# See Bug#33717 - INSERT...(default) fails for enum. 
60
# Crashes CSV tables, loads spaces for MyISAM
61
#INSERT INTO t1 VALUES(default,default,default,default,default,default);
62
-- enable_warnings
63
64
SELECT * FROM t1;
65
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31');
66
SELECT * FROM t1;
67
-- echo # === insert failures ===
68
--error ER_BAD_NULL_ERROR
69
INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01');
70
--error ER_NO_DEFAULT_FOR_FIELD
71
INSERT INTO t1 VALUES(default(a),default(b), default(c), default(d),
72
                      default(e), default(f));
73
74
75
DROP TABLE t1;
76
77
##############################################################################
78
# Testcase csv_not_null.3:  UPDATE tests -- examining behavior of UPDATE
79
#                           statements for CSV
80
##############################################################################
81
-- echo # ===== csv_not_null.3 =====
82
-- disable_warnings
83
DROP TABLE IF EXISTS t1;
84
--enable_warnings
85
86
87
CREATE TABLE t1 (a int NOT NULL, b char(10) NOT NULL) ENGINE = CSV;
88
--disable_warnings
89
INSERT INTO t1 VALUES();
90
--enable_warnings
91
SELECT * FROM t1;
92
--disable_warnings
93
UPDATE t1 set b = 'new_value' where a = 0;
94
--enable_warnings
95
SELECT * FROM t1;
96
--error ER_BAD_NULL_ERROR
97
UPDATE t1 set b = NULL where b = 'new_value';
98
SELECT * FROM t1;
99
100
DROP TABLE t1;