Skip to content

Commit 65d4c84

Browse files
author
monty@hundin.mysql.fi
committed
Fixed problem with t1 LEFT_JOIN t2 ... WHERE t2.date_column IS NULL when date_column is declared as NOT NULL.
1 parent 8cd4c23 commit 65d4c84

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

.bzrignore

+2
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,5 @@ support-files/mysql.server
303303
support-files/mysql.spec
304304
tags
305305
tmp/*
306+
bdb/include/db_ext.h
307+
bdb/include/mutex_ext.h

BUILD/SETUP.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer"
4848
# this is one is for someone who thinks 1% speedup is worth not being
4949
# able to backtrace
5050
reckless_cflags="-O3 -fomit-frame-pointer "
51-
debug_cflags="-DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DSAFE_MUTEX -O0"
51+
debug_cflags="-DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DSAFE_MUTEX -O1"
5252

5353
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
5454

Docs/manual.texi

+3
Original file line numberDiff line numberDiff line change
@@ -46844,6 +46844,9 @@ not yet 100% confident in this code.
4684446844
@appendixsubsec Changes in release 3.23.45
4684546845
@itemize @bullet
4684646846
@item
46847+
Fixed problem with @code{t1 LEFT_JOIN t2 ... WHERE t2.date_column IS NULL} when
46848+
date_column was declared as @code{NOT NULL}.
46849+
@item
4684746850
Fixed bug with BDB tables and keys on @code{BLOB}'s.
4684846851
@item
4684946852
Fixed bug in @code{MERGE} tables on OS with 32 bit file pointers.

mysql-test/r/join.result

+5
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ a
2222
2
2323
a a b
2424
2 2 3
25+
d d
26+
2001-08-01 NULL
27+
0000-00-00 NULL
28+
d
29+
0000-00-00

mysql-test/t/join.test

+11-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,17 @@ INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
106106
CREATE TABLE t2 (
107107
a int(11) default NULL
108108
) TYPE=MyISAM;
109-
110109
INSERT INTO t2 VALUES (2),(3);
111-
112110
SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3;
113-
114111
DROP TABLE t1, t2;
112+
113+
#
114+
# TEST LEFT JOIN with DATE columns
115+
#
116+
117+
CREATE TABLE t1 (d DATE NOT NULL);
118+
CREATE TABLE t2 (d DATE NOT NULL);
119+
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
120+
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
121+
SELECT * from t1 WHERE t1.d IS NULL;
122+
DROP TABLE t1,t2;

sql/sql_select.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3101,7 +3101,8 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
31013101
/* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */
31023102
else if (((field->type() == FIELD_TYPE_DATE) ||
31033103
(field->type() == FIELD_TYPE_DATETIME)) &&
3104-
(field->flags & NOT_NULL_FLAG))
3104+
(field->flags & NOT_NULL_FLAG) &&
3105+
!field->table->maybe_null)
31053106
{
31063107
COND *new_cond;
31073108
if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2))))

0 commit comments

Comments
 (0)