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
6f6fe52a
Commit
6f6fe52a
authored
Nov 19, 2007
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into moonbone.local:/work/31048-bug-5.0-opt-mysql
parents
fedeec6c
67cae0d4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
1 deletion
+209
-1
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+104
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+96
-0
sql/item_subselect.cc
sql/item_subselect.cc
+3
-1
sql/opt_range.cc
sql/opt_range.cc
+6
-0
No files found.
mysql-test/r/subselect.result
View file @
6f6fe52a
...
@@ -4139,6 +4139,110 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
...
@@ -4139,6 +4139,110 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
(SELECT SUM(t1.a) FROM t2 WHERE a=1)
(SELECT SUM(t1.a) FROM t2 WHERE a=1)
3
3
DROP TABLE t1,t2;
DROP TABLE t1,t2;
create table t1(a int,b int,key(a),key(b));
insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
(6,7),(7,4),(5,3);
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
sum(a) a
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
ERROR HY000: Thread stack overrun detected
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 9 Using where; Using index
2 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
3 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
4 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
5 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
6 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
7 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
8 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
9 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
10 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
11 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
12 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
13 SUBQUERY t1 range a a 5 NULL 1 Using where; Using temporary; Using filesort
14 SUBQUERY t1 index NULL a 5 NULL 9 Using index
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
ERROR HY000: Thread stack overrun detected
drop table t1;
CREATE TABLE t1 (a1 INT, a2 INT);
CREATE TABLE t1 (a1 INT, a2 INT);
CREATE TABLE t2 (b1 INT, b2 INT);
CREATE TABLE t2 (b1 INT, b2 INT);
INSERT INTO t1 VALUES (100, 200);
INSERT INTO t1 VALUES (100, 200);
...
...
mysql-test/t/subselect.test
View file @
6f6fe52a
...
@@ -2987,6 +2987,102 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1;
...
@@ -2987,6 +2987,102 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1;
SELECT
(
SELECT
SUM
(
t1
.
a
)
FROM
t2
WHERE
a
=
1
)
FROM
t1
;
SELECT
(
SELECT
SUM
(
t1
.
a
)
FROM
t2
WHERE
a
=
1
)
FROM
t1
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug31048: Many nested subqueries may cause server crash.
#
create
table
t1
(
a
int
,
b
int
,
key
(
a
),
key
(
b
));
insert
into
t1
(
a
,
b
)
values
(
1
,
2
),(
2
,
1
),(
2
,
3
),(
3
,
4
),(
5
,
4
),(
5
,
5
),
(
6
,
7
),(
7
,
4
),(
5
,
3
);
# test for the stack overflow bug
select
sum
(
a
),
a
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
a
;
--
replace_regex
/
overrun
.*
$
/
overrun
detected
/
--
error
1436
select
sum
(
a
),
a
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
a
;
# test for the memory consumption & subquery slowness bug
explain
select
sum
(
a
),
a
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
a
;
--
replace_regex
/
overrun
.*
$
/
overrun
detected
/
--
error
1436
explain
select
sum
(
a
),
a
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
where
a
>
(
select
sum
(
a
)
from
t1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
b
limit
1
)
group
by
a
;
drop
table
t1
;
#
#
# Bug #31884: Assertion + crash in subquery in the SELECT clause.
# Bug #31884: Assertion + crash in subquery in the SELECT clause.
#
#
...
...
sql/item_subselect.cc
View file @
6f6fe52a
...
@@ -1800,7 +1800,9 @@ int subselect_single_select_engine::exec()
...
@@ -1800,7 +1800,9 @@ int subselect_single_select_engine::exec()
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
}
}
if
(
select_lex
->
uncacheable
&&
executed
)
if
(
select_lex
->
uncacheable
&&
select_lex
->
uncacheable
!=
UNCACHEABLE_EXPLAIN
&&
executed
)
{
{
if
(
join
->
reinit
())
if
(
join
->
reinit
())
{
{
...
...
sql/opt_range.cc
View file @
6f6fe52a
...
@@ -1978,12 +1978,18 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
...
@@ -1978,12 +1978,18 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
keys_to_use
.
intersect
(
head
->
keys_in_use_for_query
);
keys_to_use
.
intersect
(
head
->
keys_in_use_for_query
);
if
(
!
keys_to_use
.
is_clear_all
())
if
(
!
keys_to_use
.
is_clear_all
())
{
{
#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
char
buff
[
STACK_BUFF_ALLOC
];
#endif
MEM_ROOT
alloc
;
MEM_ROOT
alloc
;
SEL_TREE
*
tree
=
NULL
;
SEL_TREE
*
tree
=
NULL
;
KEY_PART
*
key_parts
;
KEY_PART
*
key_parts
;
KEY
*
key_info
;
KEY
*
key_info
;
PARAM
param
;
PARAM
param
;
if
(
check_stack_overrun
(
thd
,
STACK_MIN_SIZE
,
buff
))
DBUG_RETURN
(
0
);
// Fatal error flag is set
/* set up parameter that is passed to all functions */
/* set up parameter that is passed to all functions */
param
.
thd
=
thd
;
param
.
thd
=
thd
;
param
.
baseflag
=
head
->
file
->
table_flags
();
param
.
baseflag
=
head
->
file
->
table_flags
();
...
...
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