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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d57b127f
Commit
d57b127f
authored
Mar 12, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
ed1ed75a
17aba82e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
1 deletion
+70
-1
mysql-test/r/join.result
mysql-test/r/join.result
+35
-0
mysql-test/t/join.test
mysql-test/t/join.test
+33
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+2
-1
No files found.
mysql-test/r/join.result
View file @
d57b127f
...
@@ -1285,3 +1285,38 @@ a b a a b
...
@@ -1285,3 +1285,38 @@ a b a a b
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
drop table t1,t2,t3;
drop table t1,t2,t3;
#
# BUG#729067/730466: unexpected 'Range checked for each record'
# for queries with OR in WHERE clause
#
CREATE TABLE t1 (f1 int, f2 int) ;
INSERT INTO t1 VALUES (4,0),(5,1);
CREATE TABLE t2 (f1 int, f2 int, KEY (f2)) ;
INSERT INTO t2 VALUES (5,7), (8,9);
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t2 ALL f2 NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
f1 f2 f1 f2
5 1 5 7
DROP TABLE t1,t2;
CREATE TABLE t1(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t1 VALUES (9,4), (10,9);
CREATE TABLE t2(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t2 VALUES (9,4), (10,9);
EXPLAIN
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where
1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
2 SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using index
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
f1 f2 f1 f2
9 4 10 9
DROP TABLE t1,t2;
mysql-test/t/join.test
View file @
d57b127f
...
@@ -964,3 +964,36 @@ where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
...
@@ -964,3 +964,36 @@ where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
drop
table
t1
,
t2
,
t3
;
drop
table
t1
,
t2
,
t3
;
--
echo
#
--
echo
# BUG#729067/730466: unexpected 'Range checked for each record'
--
echo
# for queries with OR in WHERE clause
--
echo
#
CREATE
TABLE
t1
(
f1
int
,
f2
int
)
;
INSERT
INTO
t1
VALUES
(
4
,
0
),(
5
,
1
);
CREATE
TABLE
t2
(
f1
int
,
f2
int
,
KEY
(
f2
))
;
INSERT
INTO
t2
VALUES
(
5
,
7
),
(
8
,
9
);
EXPLAIN
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
ON
t2
.
f1
=
t1
.
f1
WHERE
t1
.
f1
<>
0
OR
t1
.
f2
<>
0
AND
t1
.
f1
=
t2
.
f2
;
SELECT
*
FROM
t1
STRAIGHT_JOIN
t2
ON
t2
.
f1
=
t1
.
f1
WHERE
t1
.
f1
<>
0
OR
t1
.
f2
<>
0
AND
t1
.
f1
=
t2
.
f2
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
f1
int
PRIMARY
KEY
,
f2
int
)
;
INSERT
INTO
t1
VALUES
(
9
,
4
),
(
10
,
9
);
CREATE
TABLE
t2
(
f1
int
PRIMARY
KEY
,
f2
int
)
;
INSERT
INTO
t2
VALUES
(
9
,
4
),
(
10
,
9
);
EXPLAIN
SELECT
STRAIGHT_JOIN
*
FROM
t1
JOIN
t2
ON
t2
.
f2
=
t1
.
f1
WHERE
t1
.
f1
IN
(
SELECT
f1
FROM
t1
)
AND
t1
.
f1
=
t2
.
f1
OR
t1
.
f1
=
9
;
SELECT
STRAIGHT_JOIN
*
FROM
t1
JOIN
t2
ON
t2
.
f2
=
t1
.
f1
WHERE
t1
.
f1
IN
(
SELECT
f1
FROM
t1
)
AND
t1
.
f1
=
t2
.
f1
OR
t1
.
f1
=
9
;
DROP
TABLE
t1
,
t2
;
sql/item_cmpfunc.cc
View file @
d57b127f
...
@@ -5727,7 +5727,8 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
...
@@ -5727,7 +5727,8 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
not_null_tables_cache
|=
tmp_table_map
;
not_null_tables_cache
|=
tmp_table_map
;
if
(
item
->
maybe_null
)
if
(
item
->
maybe_null
)
maybe_null
=
1
;
maybe_null
=
1
;
item
->
item_equal
=
this
;
if
(
!
item
->
item_equal
)
item
->
item_equal
=
this
;
}
}
fix_length_and_dec
();
fix_length_and_dec
();
fixed
=
1
;
fixed
=
1
;
...
...
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