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
0f3b8ef2
Commit
0f3b8ef2
authored
Mar 13, 2012
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
6f06cef0
c1f5e25c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
7 deletions
+81
-7
mysql-test/r/derived_view.result
mysql-test/r/derived_view.result
+37
-1
mysql-test/t/derived_view.test
mysql-test/t/derived_view.test
+34
-1
sql/sql_derived.cc
sql/sql_derived.cc
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+9
-5
No files found.
mysql-test/r/derived_view.result
View file @
0f3b8ef2
...
...
@@ -1960,6 +1960,42 @@ ON ( COLUMNS.TABLE_SCHEMA = UNIQUES.TABLE_SCHEMA);
COUNT(*) > 0
1
DROP TABLE t1;
set SESSION optimizer_switch= @save_optimizer_switch;
SET SESSION optimizer_switch= @save_optimizer_switch;
#
# LP BUG#953649: crash when estimating the cost of a look-up
# into a derived table to be materialized
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (132);
CREATE TABLE t2 (b int, c varchar(256));
INSERT INTO t2 VALUES (132,'test1'), (120,'text2'), (132,'text3');
CREATE VIEW v AS
SELECT b, GROUP_CONCAT(c) AS gc FROM t2 GROUP BY b;
SET @save_optimizer_switch=@@optimizer_switch;
SET SESSION optimizer_switch='derived_merge=off';
SET SESSION optimizer_switch='derived_with_keys=off';
EXPLAIN
SELECT * FROM t1, v WHERE a = b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where
2 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
SELECT * FROM t1, v WHERE a = b;
a b gc
132 132 test1,text3
SET SESSION optimizer_switch='derived_merge=on';
SET SESSION optimizer_switch='derived_with_keys=on';
EXPLAIN
SELECT * FROM t1, v WHERE a = b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY <derived2> ref key0 key0 5 const 0
2 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
SELECT * FROM t1, v WHERE a = b;
a b gc
132 132 test1,text3
SET SESSION optimizer_switch= @save_optimizer_switch;
DROP VIEW v;
DROP TABLE t1,t2;
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;
mysql-test/t/derived_view.test
View file @
0f3b8ef2
...
...
@@ -1345,7 +1345,40 @@ SELECT COUNT(*) > 0
DROP
TABLE
t1
;
set
SESSION
optimizer_switch
=
@
save_optimizer_switch
;
SET
SESSION
optimizer_switch
=
@
save_optimizer_switch
;
--
echo
#
--
echo
# LP BUG#953649: crash when estimating the cost of a look-up
--
echo
# into a derived table to be materialized
--
echo
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
132
);
CREATE
TABLE
t2
(
b
int
,
c
varchar
(
256
));
INSERT
INTO
t2
VALUES
(
132
,
'test1'
),
(
120
,
'text2'
),
(
132
,
'text3'
);
CREATE
VIEW
v
AS
SELECT
b
,
GROUP_CONCAT
(
c
)
AS
gc
FROM
t2
GROUP
BY
b
;
SET
@
save_optimizer_switch
=@@
optimizer_switch
;
SET
SESSION
optimizer_switch
=
'derived_merge=off'
;
SET
SESSION
optimizer_switch
=
'derived_with_keys=off'
;
EXPLAIN
SELECT
*
FROM
t1
,
v
WHERE
a
=
b
;
SELECT
*
FROM
t1
,
v
WHERE
a
=
b
;
SET
SESSION
optimizer_switch
=
'derived_merge=on'
;
SET
SESSION
optimizer_switch
=
'derived_with_keys=on'
;
EXPLAIN
SELECT
*
FROM
t1
,
v
WHERE
a
=
b
;
SELECT
*
FROM
t1
,
v
WHERE
a
=
b
;
SET
SESSION
optimizer_switch
=
@
save_optimizer_switch
;
DROP
VIEW
v
;
DROP
TABLE
t1
,
t2
;
# The following command must be the last one the file
set
optimizer_switch
=@
exit_optimizer_switch
;
...
...
sql/sql_derived.cc
View file @
0f3b8ef2
...
...
@@ -811,6 +811,7 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
select_union
*
result
=
(
select_union
*
)
unit
->
result
;
if
(
table
->
s
->
db_type
()
==
TMP_ENGINE_HTON
)
{
result
->
tmp_table_param
.
keyinfo
=
table
->
s
->
key_info
;
if
(
create_internal_tmp_table
(
table
,
result
->
tmp_table_param
.
keyinfo
,
result
->
tmp_table_param
.
start_recinfo
,
&
result
->
tmp_table_param
.
recinfo
,
...
...
sql/sql_select.cc
View file @
0f3b8ef2
...
...
@@ -3513,12 +3513,16 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
Perform range analysis if there are keys it could use (1).
Don't do range analysis if we're on the inner side of an outer join (2).
Do range analysis if we're on the inner side of a semi-join (3).
Don't do range analysis for materialized subqueries (4).
Don't do range analysis for materialized derived tables (5)
*/
if
(
!
s
->
const_keys
.
is_clear_all
()
&&
// (1)
(
!
s
->
table
->
pos_in_table_list
->
embedding
||
// (2)
(
s
->
table
->
pos_in_table_list
->
embedding
&&
// (3)
s
->
table
->
pos_in_table_list
->
embedding
->
sj_on_expr
))
&&
// (3)
!
s
->
table
->
is_filled_at_execution
())
if
(
!
s
->
const_keys
.
is_clear_all
()
&&
// (1)
(
!
s
->
table
->
pos_in_table_list
->
embedding
||
// (2)
(
s
->
table
->
pos_in_table_list
->
embedding
&&
// (3)
s
->
table
->
pos_in_table_list
->
embedding
->
sj_on_expr
))
&&
// (3)
!
s
->
table
->
is_filled_at_execution
()
&&
// (4)
!
(
s
->
table
->
pos_in_table_list
->
derived
&&
// (5)
s
->
table
->
pos_in_table_list
->
is_materialized_derived
()))
// (5)
{
ha_rows
records
;
SQL_SELECT
*
select
;
...
...
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