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
947f0d76
Commit
947f0d76
authored
Feb 19, 2010
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
LPBUG#523593: Merge
parents
ab06236c
e2322dc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
2 deletions
+107
-2
mysql-test/r/table_elim.result
mysql-test/r/table_elim.result
+46
-0
mysql-test/t/table_elim.test
mysql-test/t/table_elim.test
+51
-0
sql/opt_table_elimination.cc
sql/opt_table_elimination.cc
+10
-2
No files found.
mysql-test/r/table_elim.result
View file @
947f0d76
...
...
@@ -418,3 +418,49 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where
drop table t1, t2;
#
# LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
#
CREATE TABLE t1 (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_nokey` int(11) DEFAULT NULL,
`col_int_key` int(11) DEFAULT NULL,
`col_date_key` date DEFAULT NULL,
`col_date_nokey` date DEFAULT NULL,
`col_time_key` time DEFAULT NULL,
`col_time_nokey` time DEFAULT NULL,
`col_datetime_key` datetime DEFAULT NULL,
`col_datetime_nokey` datetime DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_int_key` (`col_int_key`),
KEY `col_date_key` (`col_date_key`),
KEY `col_time_key` (`col_time_key`),
KEY `col_datetime_key` (`col_datetime_key`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
);
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 VALUES
(10,7,8,NULL,NULL,'01:27:35','01:27:35','2002-02-26 06:14:37','2002-02-26 06:14:37','v','v'),
(11,1,9,'2006-06-14','2006-06-14','19:48:31','19:48:31','1900-01-01 00:00:00','1900-01-01 00:00:00','r','r');
INSERT INTO t2 SELECT * FROM t1;
SELECT table2.col_int_key AS field1
FROM (
t2 AS table1
RIGHT OUTER JOIN
(
( t1 AS table2 STRAIGHT_JOIN
t1 AS table3 ON (
(table3.col_varchar_nokey = table2.col_varchar_key ) AND
(table3.pk = table2.col_int_key))
)
) ON
(
(table3.col_varchar_key = table2.col_varchar_key) OR
(table3.col_int_key = table2.pk)
)
)
HAVING field1 < 216;
field1
DROP TABLE t1, t2;
mysql-test/t/table_elim.test
View file @
947f0d76
...
...
@@ -336,3 +336,54 @@ select t1.*
from
t1
left
join
t2
on
(
t2
.
pk
=
3
and
t2
.
b
=
3
)
or
(
t2
.
pk
=
4
and
t2
.
b
=
3
);
drop
table
t1
,
t2
;
--
echo
#
--
echo
# LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
--
echo
#
CREATE
TABLE
t1
(
`pk`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`col_int_nokey`
int
(
11
)
DEFAULT
NULL
,
`col_int_key`
int
(
11
)
DEFAULT
NULL
,
`col_date_key`
date
DEFAULT
NULL
,
`col_date_nokey`
date
DEFAULT
NULL
,
`col_time_key`
time
DEFAULT
NULL
,
`col_time_nokey`
time
DEFAULT
NULL
,
`col_datetime_key`
datetime
DEFAULT
NULL
,
`col_datetime_nokey`
datetime
DEFAULT
NULL
,
`col_varchar_key`
varchar
(
1
)
DEFAULT
NULL
,
`col_varchar_nokey`
varchar
(
1
)
DEFAULT
NULL
,
PRIMARY
KEY
(
`pk`
),
KEY
`col_int_key`
(
`col_int_key`
),
KEY
`col_date_key`
(
`col_date_key`
),
KEY
`col_time_key`
(
`col_time_key`
),
KEY
`col_datetime_key`
(
`col_datetime_key`
),
KEY
`col_varchar_key`
(
`col_varchar_key`
,
`col_int_key`
)
);
CREATE
TABLE
t2
LIKE
t1
;
INSERT
INTO
t1
VALUES
(
10
,
7
,
8
,
NULL
,
NULL
,
'01:27:35'
,
'01:27:35'
,
'2002-02-26 06:14:37'
,
'2002-02-26 06:14:37'
,
'v'
,
'v'
),
(
11
,
1
,
9
,
'2006-06-14'
,
'2006-06-14'
,
'19:48:31'
,
'19:48:31'
,
'1900-01-01 00:00:00'
,
'1900-01-01 00:00:00'
,
'r'
,
'r'
);
INSERT
INTO
t2
SELECT
*
FROM
t1
;
SELECT
table2
.
col_int_key
AS
field1
FROM
(
t2
AS
table1
RIGHT
OUTER
JOIN
(
(
t1
AS
table2
STRAIGHT_JOIN
t1
AS
table3
ON
(
(
table3
.
col_varchar_nokey
=
table2
.
col_varchar_key
)
AND
(
table3
.
pk
=
table2
.
col_int_key
))
)
)
ON
(
(
table3
.
col_varchar_key
=
table2
.
col_varchar_key
)
OR
(
table3
.
col_int_key
=
table2
.
pk
)
)
)
HAVING
field1
<
216
;
DROP
TABLE
t1
,
t2
;
sql/opt_table_elimination.cc
View file @
947f0d76
...
...
@@ -1220,8 +1220,16 @@ void build_eq_mods_for_cond(Dep_analysis_context *ctx,
bound_item
=
item
;
}
}
exchange_sort
<
Dep_value_field
>
(
fvl
,
compare_field_values
,
NULL
);
add_module_expr
(
ctx
,
eq_mod
,
*
and_level
,
NULL
,
bound_item
,
fvl
);
/*
Multiple equality is only useful if it includes at least one field from
the table that we could potentially eliminate:
*/
if
(
fvl
->
elements
)
{
exchange_sort
<
Dep_value_field
>
(
fvl
,
compare_field_values
,
NULL
);
add_module_expr
(
ctx
,
eq_mod
,
*
and_level
,
NULL
,
bound_item
,
fvl
);
}
break
;
}
default:
...
...
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