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
a853c7dd
Commit
a853c7dd
authored
Jun 28, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
78fa331e
31edda66
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
8 deletions
+97
-8
mysql-test/r/join_cache.result
mysql-test/r/join_cache.result
+36
-0
mysql-test/r/subselect_mat_cost_bugs.result
mysql-test/r/subselect_mat_cost_bugs.result
+3
-3
mysql-test/t/join_cache.test
mysql-test/t/join_cache.test
+35
-0
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+22
-5
sql/sql_join_cache.h
sql/sql_join_cache.h
+1
-0
No files found.
mysql-test/r/join_cache.result
View file @
a853c7dd
...
@@ -4964,4 +4964,40 @@ a
...
@@ -4964,4 +4964,40 @@ a
SET SESSION join_cache_level = DEFAULT;
SET SESSION join_cache_level = DEFAULT;
SET SESSION join_buffer_size = DEFAULT;
SET SESSION join_buffer_size = DEFAULT;
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# Bug #802860: crash on join cache + derived + duplicate_weedout
#
SET SESSION optimizer_switch=
'semijoin=on,materialization=off,firstmatch=off,loosescan=off';
CREATE TABLE t1 (a int) ;
INSERT IGNORE INTO t1 VALUES (0), (1), (0);
CREATE TABLE t2 (a int) ;
INSERT IGNORE INTO t2 VALUES (0), (3), (0), (2);
SET SESSION join_cache_level = 0;
EXPLAIN
SELECT * FROM (SELECT DISTINCT * FROM t1) t
WHERE t.a IN (SELECT t2.a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; Start temporary
1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 End temporary
2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary
SELECT * FROM (SELECT DISTINCT * FROM t1) t
WHERE t.a IN (SELECT t2.a FROM t2);
a
0
SET SESSION join_cache_level = 1;
EXPLAIN
SELECT * FROM (SELECT DISTINCT * FROM t1) t
WHERE t.a IN (SELECT t2.a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL key0 NULL NULL NULL 3 Start temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary
SELECT * FROM (SELECT DISTINCT * FROM t1) t
WHERE t.a IN (SELECT t2.a FROM t2);
a
0
SET SESSION join_cache_level = DEFAULT;
DROP TABLE t1, t2;
SET SESSION optimizer_switch=default;
set @@optimizer_switch=@save_optimizer_switch;
set @@optimizer_switch=@save_optimizer_switch;
mysql-test/r/subselect_mat_cost_bugs.result
View file @
a853c7dd
...
@@ -308,9 +308,9 @@ EXPLAIN
...
@@ -308,9 +308,9 @@ EXPLAIN
SELECT * FROM t1
SELECT * FROM t1
WHERE (f1) IN (SELECT f1 FROM t2)
WHERE (f1) IN (SELECT f1 FROM t2)
LIMIT 0;
LIMIT 0;
id
select_type table type possible_keys key key_len ref rows
Extra
id
select_type table type possible_keys key key_len ref rows
Extra
1
PRIMARY NULL NULL NULL NULL NULL NULL NULL
Impossible WHERE
1
PRIMARY NULL NULL NULL NULL NULL NULL NULL
Impossible WHERE
2
DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
Using where
2
DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
Using where
SELECT * FROM t1
SELECT * FROM t1
WHERE (f1) IN (SELECT f1 FROM t2)
WHERE (f1) IN (SELECT f1 FROM t2)
LIMIT 0;
LIMIT 0;
...
...
mysql-test/t/join_cache.test
View file @
a853c7dd
...
@@ -3100,5 +3100,40 @@ SET SESSION join_buffer_size = DEFAULT;
...
@@ -3100,5 +3100,40 @@ SET SESSION join_buffer_size = DEFAULT;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug #802860: crash on join cache + derived + duplicate_weedout
--
echo
#
SET
SESSION
optimizer_switch
=
'semijoin=on,materialization=off,firstmatch=off,loosescan=off'
;
CREATE
TABLE
t1
(
a
int
)
;
INSERT
IGNORE
INTO
t1
VALUES
(
0
),
(
1
),
(
0
);
CREATE
TABLE
t2
(
a
int
)
;
INSERT
IGNORE
INTO
t2
VALUES
(
0
),
(
3
),
(
0
),
(
2
);
SET
SESSION
join_cache_level
=
0
;
EXPLAIN
SELECT
*
FROM
(
SELECT
DISTINCT
*
FROM
t1
)
t
WHERE
t
.
a
IN
(
SELECT
t2
.
a
FROM
t2
);
SELECT
*
FROM
(
SELECT
DISTINCT
*
FROM
t1
)
t
WHERE
t
.
a
IN
(
SELECT
t2
.
a
FROM
t2
);
SET
SESSION
join_cache_level
=
1
;
EXPLAIN
SELECT
*
FROM
(
SELECT
DISTINCT
*
FROM
t1
)
t
WHERE
t
.
a
IN
(
SELECT
t2
.
a
FROM
t2
);
SELECT
*
FROM
(
SELECT
DISTINCT
*
FROM
t1
)
t
WHERE
t
.
a
IN
(
SELECT
t2
.
a
FROM
t2
);
SET
SESSION
join_cache_level
=
DEFAULT
;
DROP
TABLE
t1
,
t2
;
SET
SESSION
optimizer_switch
=
default
;
# this must be the last command in the file
# this must be the last command in the file
set
@@
optimizer_switch
=@
save_optimizer_switch
;
set
@@
optimizer_switch
=@
save_optimizer_switch
;
sql/sql_join_cache.cc
View file @
a853c7dd
...
@@ -609,8 +609,15 @@ void JOIN_CACHE::create_remaining_fields()
...
@@ -609,8 +609,15 @@ void JOIN_CACHE::create_remaining_fields()
if
(
tab
->
keep_current_rowid
)
if
(
tab
->
keep_current_rowid
)
{
{
copy
->
str
=
table
->
file
->
ref
;
copy
->
str
=
table
->
file
->
ref
;
copy
->
length
=
table
->
file
->
ref_length
;
if
(
copy
->
str
)
copy
->
type
=
0
;
copy
->
length
=
table
->
file
->
ref_length
;
else
{
/* This may happen only for materialized derived tables and views */
copy
->
length
=
0
;
copy
->
str
=
(
uchar
*
)
table
;
}
copy
->
type
=
CACHE_ROWID
;
copy
->
field
=
0
;
copy
->
field
=
0
;
copy
->
referenced_field_no
=
0
;
copy
->
referenced_field_no
=
0
;
length
+=
copy
->
length
;
length
+=
copy
->
length
;
...
@@ -1325,8 +1332,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
...
@@ -1325,8 +1332,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
{
{
Field
*
field
=
copy
->
field
;
Field
*
field
=
copy
->
field
;
if
(
field
&&
field
->
maybe_null
()
&&
field
->
is_null
())
if
(
field
&&
field
->
maybe_null
()
&&
field
->
is_null
())
{
{
/* Do not copy a field if its value is null */
if
(
copy
->
referenced_field_no
)
if
(
copy
->
referenced_field_no
)
copy
->
offset
=
0
;
copy
->
offset
=
0
;
continue
;
continue
;
...
@@ -1386,6 +1392,18 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
...
@@ -1386,6 +1392,18 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
cp
+=
len
+
2
;
cp
+=
len
+
2
;
break
;
break
;
}
}
case
CACHE_ROWID
:
if
(
!
copy
->
length
)
{
/*
This may happen only for ROWID fields of materialized
derived tables and views.
*/
TABLE
*
table
=
(
TABLE
*
)
copy
->
str
;
copy
->
str
=
table
->
file
->
ref
;
copy
->
length
=
table
->
file
->
ref_length
;
}
/* fall through */
default:
default:
/* Copy the entire image of the field from the record buffer */
/* Copy the entire image of the field from the record buffer */
memcpy
(
cp
,
copy
->
str
,
copy
->
length
);
memcpy
(
cp
,
copy
->
str
,
copy
->
length
);
...
@@ -1455,7 +1473,6 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
...
@@ -1455,7 +1473,6 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
RETURN VALUE
RETURN VALUE
none
none
*/
*/
void
JOIN_CACHE
::
reset
(
bool
for_writing
)
void
JOIN_CACHE
::
reset
(
bool
for_writing
)
{
{
pos
=
buff
;
pos
=
buff
;
...
...
sql/sql_join_cache.h
View file @
a853c7dd
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define CACHE_STRIPPED 2
/* field stripped of trailing spaces */
#define CACHE_STRIPPED 2
/* field stripped of trailing spaces */
#define CACHE_VARSTR1 3
/* short string value (length takes 1 byte) */
#define CACHE_VARSTR1 3
/* short string value (length takes 1 byte) */
#define CACHE_VARSTR2 4
/* long string value (length takes 2 bytes) */
#define CACHE_VARSTR2 4
/* long string value (length takes 2 bytes) */
#define CACHE_ROWID 5
/* ROWID field */
/*
/*
The CACHE_FIELD structure used to describe fields of records that
The CACHE_FIELD structure used to describe fields of records that
...
...
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