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
503731d8
Commit
503731d8
authored
Apr 05, 2013
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-4371.
Avoid possible division by 0.
parent
daaa5834
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
1 deletion
+91
-1
mysql-test/r/selectivity.result
mysql-test/r/selectivity.result
+28
-0
mysql-test/r/selectivity_innodb.result
mysql-test/r/selectivity_innodb.result
+29
-0
mysql-test/t/selectivity.test
mysql-test/t/selectivity.test
+33
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/selectivity.result
View file @
503731d8
...
...
@@ -822,4 +822,32 @@ DROP TABLE t1;
set histogram_size=@save_histogram_size;
set histogram_type=@save_histogram_type;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4371: Join with condition supported by index on an empty table
# with optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a int, b int, INDEX(a));
CREATE TABLE t2 (c int);
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
test.t2 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN EXTENDED
SELECT * FROM t1, t2 WHERE a > 9;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select NULL AS `a`,NULL AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where 0
SELECT * FROM t1, t2 WHERE a > 9;
a b c
set optimizer_switch=@save_optimizer_switch;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
mysql-test/r/selectivity_innodb.result
View file @
503731d8
...
...
@@ -829,6 +829,35 @@ DROP TABLE t1;
set histogram_size=@save_histogram_size;
set histogram_type=@save_histogram_type;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4371: Join with condition supported by index on an empty table
# with optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a int, b int, INDEX(a));
CREATE TABLE t2 (c int);
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN EXTENDED
SELECT * FROM t1, t2 WHERE a > 9;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 1 0.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` > 9)
SELECT * FROM t1, t2 WHERE a > 9;
a b c
set optimizer_switch=@save_optimizer_switch;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
mysql-test/t/selectivity.test
View file @
503731d8
...
...
@@ -412,4 +412,37 @@ set histogram_size=@save_histogram_size;
set
histogram_type
=@
save_histogram_type
;
set
use_stat_tables
=@
save_use_stat_tables
;
--
echo
#
--
echo
# Bug mdev-4371: Join with condition supported by index on an empty table
--
echo
# with optimizer_use_condition_selectivity=3
--
echo
#
set
use_stat_tables
=
PREFERABLY
;
CREATE
TABLE
t1
(
a
int
,
b
int
,
INDEX
(
a
));
CREATE
TABLE
t2
(
c
int
);
INSERT
INTO
t2
VALUES
(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
);
ANALYZE
TABLE
t1
,
t2
;
FLUSH
TABLES
;
set
optimizer_use_condition_selectivity
=
3
;
set
@
save_optimizer_switch
=@@
optimizer_switch
;
set
optimizer_switch
=
'index_condition_pushdown=off'
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
,
t2
WHERE
a
>
9
;
SELECT
*
FROM
t1
,
t2
WHERE
a
>
9
;
set
optimizer_switch
=@
save_optimizer_switch
;
set
optimizer_use_condition_selectivity
=@
save_optimizer_use_condition_selectivity
;
DROP
TABLE
t1
,
t2
;
set
use_stat_tables
=@
save_use_stat_tables
;
set
use_stat_tables
=@
save_use_stat_tables
;
sql/sql_select.cc
View file @
503731d8
...
...
@@ -7030,7 +7030,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
/* Discount the selectivity of the access method used to join table s */
if
(
s
->
quick
&&
s
->
quick
->
index
!=
MAX_KEY
)
{
if
(
pos
->
key
==
0
)
if
(
pos
->
key
==
0
&&
table_records
>
0
)
{
sel
*=
table
->
quick_rows
[
s
->
quick
->
index
]
/
table_records
;
}
...
...
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