Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
e81337d8
Commit
e81337d8
authored
Jul 15, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rburnett@bk-internal.mysql.com:/home/bk/mysql-4.1
into linux.site:/home/reggie/bk/bug7403
parents
0589559e
0f41fb42
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
mysql-test/r/select.result
mysql-test/r/select.result
+11
-0
mysql-test/t/select.test
mysql-test/t/select.test
+11
-0
sql/sql_select.cc
sql/sql_select.cc
+19
-1
No files found.
mysql-test/r/select.result
View file @
e81337d8
...
...
@@ -2559,3 +2559,14 @@ WHERE
COUNT(*)
4
drop table t1,t2,t3;
create table t1 (f1 int);
insert into t1 values (1),(NULL);
create table t2 (f2 int, f3 int, f4 int);
create index idx1 on t2 (f4);
insert into t2 values (1,2,3),(2,4,6);
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
from t2 C where A.f4 = C.f4) or A.f3 IS NULL;
f2
1
NULL
drop table t1,t2;
mysql-test/t/select.test
View file @
e81337d8
...
...
@@ -2116,3 +2116,14 @@ WHERE
drop
table
t1
,
t2
,
t3
;
#
# Bug #11482 4.1.12 produces different resultset for a complex query
# than in previous 4.1.x
create
table
t1
(
f1
int
);
insert
into
t1
values
(
1
),(
NULL
);
create
table
t2
(
f2
int
,
f3
int
,
f4
int
);
create
index
idx1
on
t2
(
f4
);
insert
into
t2
values
(
1
,
2
,
3
),(
2
,
4
,
6
);
select
A
.
f2
from
t1
left
join
t2
A
on
A
.
f2
=
f1
where
A
.
f3
=
(
select
min
(
f3
)
from
t2
C
where
A
.
f4
=
C
.
f4
)
or
A
.
f3
IS
NULL
;
drop
table
t1
,
t2
;
sql/sql_select.cc
View file @
e81337d8
...
...
@@ -3509,6 +3509,22 @@ inline void add_cond_and_fix(Item **e1, Item *e2)
and add them to conditions on correspoding tables (othertbl in this
example).
Exception from that is the case when referred_tab->join != join.
I.e. don't add NOT NULL constraints from any embedded subquery.
Consider this query:
SELECT A.f2 FROM t1 LEFT JOIN t2 A ON A.f2 = f1
WHERE A.f3=(SELECT MIN(f3) FROM t2 C WHERE A.f4 = C.f4) OR A.f3 IS NULL;
Here condition A.f3 IS NOT NULL is going to be added to the WHERE
condition of the embedding query.
Another example:
SELECT * FROM t10, t11 WHERE (t10.a < 10 OR t10.a IS NULL)
AND t11.b <=> t10.b AND (t11.a = (SELECT MAX(a) FROM t12
WHERE t12.b = t10.a ));
Here condition t10.a IS NOT NULL is going to be added.
In both cases addition of NOT NULL condition will erroneously reject
some rows of the result set.
referred_tab->join != join constraint would disallow such additions.
This optimization doesn't affect the choices that ref, range, or join
optimizer make. This was intentional because this was added after 4.1
was GA.
...
...
@@ -3539,6 +3555,8 @@ static void add_not_null_conds(JOIN *join)
DBUG_ASSERT
(
item
->
type
()
==
Item
::
FIELD_ITEM
);
Item_field
*
not_null_item
=
(
Item_field
*
)
item
;
JOIN_TAB
*
referred_tab
=
not_null_item
->
field
->
table
->
reginfo
.
join_tab
;
if
(
referred_tab
->
join
!=
join
)
continue
;
Item
*
notnull
;
if
(
!
(
notnull
=
new
Item_func_isnotnull
(
not_null_item
)))
DBUG_VOID_RETURN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment