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
c84ff1fc
Commit
c84ff1fc
authored
Sep 22, 2010
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
61e96a75
f4503f39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
4 deletions
+64
-4
mysql-test/r/join_cache.result
mysql-test/r/join_cache.result
+28
-0
mysql-test/t/join_cache.test
mysql-test/t/join_cache.test
+28
-0
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+8
-4
No files found.
mysql-test/r/join_cache.result
100755 → 100644
View file @
c84ff1fc
...
@@ -5174,3 +5174,31 @@ a b
...
@@ -5174,3 +5174,31 @@ a b
set join_cache_level=default;
set join_cache_level=default;
drop table t1,t2,t3;
drop table t1,t2,t3;
set @@optimizer_switch=@save_optimizer_switch;
set @@optimizer_switch=@save_optimizer_switch;
#
# Bug #52394: using join buffer for 3 table join with ref access
# LP #623209: and no references to the columns of the middle table
#
set join_cache_level=6;
CREATE TABLE t1 (a int(11), b varchar(1));
INSERT INTO t1 VALUES (6,'r'),(27,'o');
CREATE TABLE t2(a int);
INSERT INTO t2 VALUES(1),(2),(3),(4),(5);
CREATE TABLE t3 (a int(11) primary key, b varchar(1));
INSERT INTO t3 VALUES
(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),
(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'o');
EXPLAIN
SELECT t3.a FROM t1,t2,t3 WHERE t1.a = t3.a AND t1.b = t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using join buffer
SELECT t3.a FROM t1,t2,t3 WHERE t1.a = t3.a AND t1.b = t3.b;
a
27
27
27
27
27
DROP TABLE t1,t2,t3;
set join_cache_level=default;
mysql-test/t/join_cache.test
View file @
c84ff1fc
...
@@ -1956,3 +1956,31 @@ set join_cache_level=default;
...
@@ -1956,3 +1956,31 @@ set join_cache_level=default;
drop
table
t1
,
t2
,
t3
;
drop
table
t1
,
t2
,
t3
;
set
@@
optimizer_switch
=@
save_optimizer_switch
;
set
@@
optimizer_switch
=@
save_optimizer_switch
;
--
echo
#
--
echo
# Bug #52394: using join buffer for 3 table join with ref access
--
echo
# LP #623209: and no references to the columns of the middle table
--
echo
#
set
join_cache_level
=
6
;
CREATE
TABLE
t1
(
a
int
(
11
),
b
varchar
(
1
));
INSERT
INTO
t1
VALUES
(
6
,
'r'
),(
27
,
'o'
);
CREATE
TABLE
t2
(
a
int
);
INSERT
INTO
t2
VALUES
(
1
),(
2
),(
3
),(
4
),(
5
);
CREATE
TABLE
t3
(
a
int
(
11
)
primary
key
,
b
varchar
(
1
));
INSERT
INTO
t3
VALUES
(
14
,
'd'
),(
15
,
'z'
),(
16
,
'e'
),(
17
,
'h'
),(
18
,
'b'
),(
19
,
's'
),(
20
,
'e'
),
(
21
,
'j'
),(
22
,
'e'
),(
23
,
'f'
),(
24
,
'v'
),(
25
,
'x'
),(
26
,
'm'
),(
27
,
'o'
);
EXPLAIN
SELECT
t3
.
a
FROM
t1
,
t2
,
t3
WHERE
t1
.
a
=
t3
.
a
AND
t1
.
b
=
t3
.
b
;
SELECT
t3
.
a
FROM
t1
,
t2
,
t3
WHERE
t1
.
a
=
t3
.
a
AND
t1
.
b
=
t3
.
b
;
DROP
TABLE
t1
,
t2
,
t3
;
set
join_cache_level
=
default
;
sql/sql_join_cache.cc
View file @
c84ff1fc
...
@@ -3391,8 +3391,12 @@ int JOIN_TAB_SCAN_MRR::next()
...
@@ -3391,8 +3391,12 @@ int JOIN_TAB_SCAN_MRR::next()
uint
rc
=
join_tab
->
table
->
file
->
multi_range_read_next
(
ptr
)
?
-
1
:
0
;
uint
rc
=
join_tab
->
table
->
file
->
multi_range_read_next
(
ptr
)
?
-
1
:
0
;
if
(
!
rc
)
if
(
!
rc
)
{
{
/*
If a record in in an incremental cache contains no fields then the
association for the last record in cache will be equal to cache->end_pos
*/
DBUG_ASSERT
(
cache
->
buff
<=
(
uchar
*
)
(
*
ptr
)
&&
DBUG_ASSERT
(
cache
->
buff
<=
(
uchar
*
)
(
*
ptr
)
&&
(
uchar
*
)
(
*
ptr
)
<
cache
->
end_pos
);
(
uchar
*
)
(
*
ptr
)
<
=
cache
->
end_pos
);
update_virtual_fields
(
join_tab
->
table
);
update_virtual_fields
(
join_tab
->
table
);
}
}
return
rc
;
return
rc
;
...
@@ -3728,12 +3732,12 @@ uint JOIN_CACHE_BKA::get_next_key(uchar ** key)
...
@@ -3728,12 +3732,12 @@ uint JOIN_CACHE_BKA::get_next_key(uchar ** key)
uchar
*
init_pos
;
uchar
*
init_pos
;
JOIN_CACHE
*
cache
;
JOIN_CACHE
*
cache
;
if
(
pos
>
last_rec_pos
||
!
records
)
return
0
;
/* Any record in a BKA cache is prepended with its length */
/* Any record in a BKA cache is prepended with its length */
DBUG_ASSERT
(
with_length
);
DBUG_ASSERT
(
with_length
);
if
((
pos
+
size_of_rec_len
)
>
last_rec_pos
||
!
records
)
return
0
;
/* Read the length of the record */
/* Read the length of the record */
rec_len
=
get_rec_length
(
pos
);
rec_len
=
get_rec_length
(
pos
);
pos
+=
size_of_rec_len
;
pos
+=
size_of_rec_len
;
...
...
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