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
fcf2b139
Commit
fcf2b139
authored
Jan 15, 2007
by
gkodinov/kgeorge@rakia.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into rakia.gmz:/home/kgeorge/mysql/autopush/B20420-5.0-opt
parents
9f918b01
134e9493
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletion
+84
-1
mysql-test/r/func_in.result
mysql-test/r/func_in.result
+43
-0
mysql-test/t/func_in.test
mysql-test/t/func_in.test
+36
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+5
-1
No files found.
mysql-test/r/func_in.result
View file @
fcf2b139
...
...
@@ -351,4 +351,47 @@ some_id
1
2
drop table t1;
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1);
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
INSERT INTO t2 VALUES (3,2),(4,2);
CREATE TABLE t3 (a int PRIMARY KEY);
INSERT INTO t3 VALUES (1),(2),(3),(4);
CREATE TABLE t4 (a int PRIMARY KEY);
INSERT INTO t4 VALUES (1),(2);
EXPLAIN SELECT STRAIGHT_JOIN * FROM t3
JOIN t1 ON t3.a=t1.a
JOIN t2 ON t3.a=t2.a
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1)
SELECT STRAIGHT_JOIN * FROM t3
JOIN t1 ON t3.a=t1.a
JOIN t2 ON t3.a=t2.a
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
a a b a b a
3 3 1 3 2 1
3 3 1 3 2 2
4 4 1 4 2 1
4 4 1 4 2 2
EXPLAIN SELECT STRAIGHT_JOIN
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
FROM t3, t1, t2
WHERE t3.a=t1.a AND t3.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 4 Using index
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
2 DEPENDENT SUBQUERY t4 index NULL PRIMARY 4 NULL 2 Using where; Using index
SELECT STRAIGHT_JOIN
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
FROM t3, t1, t2
WHERE t3.a=t1.a AND t3.a=t2.a;
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
3
3
DROP TABLE t1,t2,t3,t4;
End of 5.0 tests
mysql-test/t/func_in.test
View file @
fcf2b139
...
...
@@ -254,5 +254,41 @@ select some_id from t1 where some_id not in(-4,-1,-4);
select
some_id
from
t1
where
some_id
not
in
(
-
4
,
-
1
,
3423534
,
2342342
);
drop
table
t1
;
#
# BUG#20420: optimizer reports wrong keys on left join with IN
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
PRIMARY
KEY
(
a
));
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
1
),(
3
,
1
),(
4
,
1
),(
5
,
1
),(
6
,
1
);
CREATE
TABLE
t2
(
a
int
,
b
int
,
PRIMARY
KEY
(
a
));
INSERT
INTO
t2
VALUES
(
3
,
2
),(
4
,
2
);
CREATE
TABLE
t3
(
a
int
PRIMARY
KEY
);
INSERT
INTO
t3
VALUES
(
1
),(
2
),(
3
),(
4
);
CREATE
TABLE
t4
(
a
int
PRIMARY
KEY
);
INSERT
INTO
t4
VALUES
(
1
),(
2
);
EXPLAIN
SELECT
STRAIGHT_JOIN
*
FROM
t3
JOIN
t1
ON
t3
.
a
=
t1
.
a
JOIN
t2
ON
t3
.
a
=
t2
.
a
JOIN
t4
WHERE
t4
.
a
IN
(
t1
.
b
,
t2
.
b
);
SELECT
STRAIGHT_JOIN
*
FROM
t3
JOIN
t1
ON
t3
.
a
=
t1
.
a
JOIN
t2
ON
t3
.
a
=
t2
.
a
JOIN
t4
WHERE
t4
.
a
IN
(
t1
.
b
,
t2
.
b
);
EXPLAIN
SELECT
STRAIGHT_JOIN
(
SELECT
SUM
(
t4
.
a
)
FROM
t4
WHERE
t4
.
a
IN
(
t1
.
b
,
t2
.
b
))
FROM
t3
,
t1
,
t2
WHERE
t3
.
a
=
t1
.
a
AND
t3
.
a
=
t2
.
a
;
SELECT
STRAIGHT_JOIN
(
SELECT
SUM
(
t4
.
a
)
FROM
t4
WHERE
t4
.
a
IN
(
t1
.
b
,
t2
.
b
))
FROM
t3
,
t1
,
t2
WHERE
t3
.
a
=
t1
.
a
AND
t3
.
a
=
t2
.
a
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
;
--
echo
End
of
5.0
tests
sql/item_cmpfunc.h
View file @
fcf2b139
...
...
@@ -965,6 +965,10 @@ class Item_func_in :public Item_func_opt_neg
{
public:
Item_result
cmp_type
;
/*
an array of values when the right hand arguments of IN
are all SQL constant and there are no nulls
*/
in_vector
*
array
;
cmp_item
*
in_item
;
bool
have_null
;
...
...
@@ -990,7 +994,7 @@ public:
DBUG_VOID_RETURN
;
}
optimize_type
select_optimize
()
const
{
return
array
?
OPTIMIZE_KEY
:
OPTIMIZE_NONE
;
}
{
return
OPTIMIZE_KEY
;
}
void
print
(
String
*
str
);
enum
Functype
functype
()
const
{
return
IN_FUNC
;
}
const
char
*
func_name
()
const
{
return
" IN "
;
}
...
...
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