~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/null.test

  • Committer: Prafulla Tekawade
  • Date: 2010-08-06 11:21:12 UTC
  • mto: (1711.1.21 build) (1725.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: prafulla_t@users.sourceforge.net-20100806112112-7w5u0s3nx9u67nzt
Fix for Bug 586051

1. test_if_ref method which checks whether predicate is already evaluated
   due to ref/eq_ref access or not was incorrectly removing a predicate 
   that was not implicitly evaluated due to ref access (due to presence of filesort ?)
   It was field=NULL predicate.
   Such predicate should be kept and execution engine will filter out rows
   correctly. Removal of such predicate led to returning of rows which had
   NULL for join/predicate columns.
2. field COMP_OP NULL will always false for all fields except when COMP_OP
   is NULL-safe equality operator. Modified range optimizer to return zero
   row count in such cases.
   Query now does not even run. It returns zero result. As such Fix(1) is not
   required but we might hit that case in some other query (I have not tried it
   yet)
3. Fixed Field::val_str to print "NULL" for literal NULL instead of "0". It
   added lot of confusion while debugging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
# Testing of NULL in a lot of different places
8
8
#
9
9
 
10
 
--error ER_DIVISION_BY_ZERO
11
10
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
12
 
--error ER_DIVISION_BY_ZERO
13
11
explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
14
12
select CONCAT(1, NULL),1+NULL,1-NULL;
15
13
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,CONCAT(IFNULL(NULL,1), 0);
67
65
 
68
66
# Test INSERT with NULL
69
67
 
70
 
--error ER_BAD_NULL_ERROR
 
68
--error 1048
71
69
INSERT INTO t1 (a) values (null);
72
 
--error ER_BAD_NULL_ERROR
 
70
--error 1048
73
71
INSERT INTO t1 (a) values (1/null);
74
 
--error ER_BAD_NULL_ERROR
 
72
--error 1048
75
73
INSERT INTO t1 (a) values (null),(null);
76
 
--error ER_BAD_NULL_ERROR
 
74
--error 1048
77
75
INSERT INTO t1 (b) values (null);
78
 
--error ER_BAD_NULL_ERROR
 
76
--error 1048
79
77
INSERT INTO t1 (b) values (1/null);
80
 
--error ER_BAD_NULL_ERROR
 
78
--error 1048
81
79
INSERT INTO t1 (b) values (null),(null);
82
 
--error ER_BAD_NULL_ERROR
 
80
--error 1048
83
81
INSERT INTO t1 (c) values (null);
84
 
--error ER_BAD_NULL_ERROR
 
82
--error 1048
85
83
INSERT INTO t1 (c) values (1/null);
86
 
--error ER_BAD_NULL_ERROR
 
84
--error 1048
87
85
INSERT INTO t1 (c) values (null),(null);
88
 
--error ER_BAD_NULL_ERROR
 
86
--error 1048
89
87
INSERT INTO t1 (d) values (null);
90
 
--error ER_BAD_NULL_ERROR
 
88
--error 1048
91
89
INSERT INTO t1 (d) values (1/null);
92
 
--error ER_BAD_NULL_ERROR
 
90
--error 1048
93
91
INSERT INTO t1 (d) values (null),(null);
94
92
 
95
93
# Test UPDATE with NULLs
101
99
# Insert a default row in order to test UPDATE to NULL error
102
100
INSERT INTO t1 VALUES ();
103
101
 
104
 
--error ER_BAD_NULL_ERROR
 
102
--error 1048
105
103
UPDATE t1 SET a=1/NULL;
106
 
--error ER_BAD_NULL_ERROR
 
104
--error 1048
107
105
UPDATE t1 SET a=NULL;
108
 
--error ER_BAD_NULL_ERROR
 
106
--error 1048
109
107
UPDATE t1 SET b=NULL;
110
 
--error ER_BAD_NULL_ERROR
 
108
--error 1048
111
109
UPDATE t1 SET c=NULL;
112
 
--error ER_BAD_NULL_ERROR
 
110
--error 1048
113
111
UPDATE t1 SET d=NULL;
114
112
 
115
113
truncate table t1;
119
117
# as 1048, only gives a "row" number.
120
118
# @TODO Is there really a reason for a separate error 
121
119
# just for LOAD DATA INFILE?
122
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
123
 
--error ER_WARN_NULL_TO_NOTNULL
124
 
eval LOAD DATA INFILE '$DRIZZLETEST_VARDIR/std_data_ln/null_test.txt' INTO TABLE t1 FIELDS ENCLOSED BY '"';
 
120
--error 1263
 
121
LOAD DATA INFILE '../std_data_ln/null_test.txt' INTO TABLE t1 FIELDS ENCLOSED BY '"';
125
122
 
126
123
drop table t1;
127
124
 
236
233
#create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ) engine=MyISAM;
237
234
 
238
235
# Invalid default value for 's'
239
 
#--error ER_INVALID_DEFAULT
 
236
#--error 1067
240
237
#create table bug19145setnotnulldefaultnull (e enum('a','b','c')          default null, s set('x', 'y', 'z') not null default null) engine=MyISAM;
241
238
 
242
239
# Invalid default value for 'e'
243
 
#--error ER_INVALID_DEFAULT
 
240
#--error 1067
244
241
#create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z')          default null) engine=MyISAM;
245
242
 
246
243
#alter table bug19145a alter column e set default null;
252
249
#alter table bug19145b add column (i int);
253
250
 
254
251
# Invalid default value for 'e'
255
 
#--error ER_INVALID_DEFAULT
 
252
#--error 1067
256
253
#alter table bug19145c alter column e set default null;
257
254
 
258
255
# Invalid default value for 's'
259
 
#--error ER_INVALID_DEFAULT
 
256
#--error 1067
260
257
#alter table bug19145c alter column s set default null;
261
258
#alter table bug19145c add column (i int);
262
259