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
27624ee4
Commit
27624ee4
authored
May 04, 2007
by
gkodinov/kgeorge@magare.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B27807-5.0-opt
parents
1a0cf6db
6badb08c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
8 deletions
+59
-8
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+7
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+8
-0
sql/item_subselect.cc
sql/item_subselect.cc
+15
-0
sql/sql_select.cc
sql/sql_select.cc
+28
-8
sql/sql_select.h
sql/sql_select.h
+1
-0
No files found.
mysql-test/r/subselect.result
View file @
27624ee4
...
@@ -4034,4 +4034,11 @@ SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
...
@@ -4034,4 +4034,11 @@ SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
FROM t1;
ERROR HY000: Invalid use of group function
ERROR HY000: Invalid use of group function
DROP TABLE t1,t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (a int, b int, KEY (a));
INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
End of 5.0 tests.
End of 5.0 tests.
mysql-test/t/subselect.test
View file @
27624ee4
...
@@ -2874,4 +2874,12 @@ FROM t1;
...
@@ -2874,4 +2874,12 @@ FROM t1;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug #27807: Server crash when executing subquery with EXPLAIN
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
KEY
(
a
));
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
1
);
EXPLAIN
SELECT
1
FROM
t1
WHERE
a
=
(
SELECT
COUNT
(
*
)
FROM
t1
GROUP
BY
b
);
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
.
--
echo
End
of
5.0
tests
.
sql/item_subselect.cc
View file @
27624ee4
...
@@ -1774,6 +1774,21 @@ int subselect_single_select_engine::exec()
...
@@ -1774,6 +1774,21 @@ int subselect_single_select_engine::exec()
thd
->
lex
->
current_select
=
save_select
;
thd
->
lex
->
current_select
=
save_select
;
DBUG_RETURN
(
join
->
error
?
join
->
error
:
1
);
DBUG_RETURN
(
join
->
error
?
join
->
error
:
1
);
}
}
if
(
!
select_lex
->
uncacheable
&&
thd
->
lex
->
describe
&&
!
(
join
->
select_options
&
SELECT_DESCRIBE
)
&&
join
->
need_tmp
&&
item
->
const_item
())
{
/*
Force join->join_tmp creation, because this subquery will be replaced
by a simple select from the materialization temp table by optimize()
called by EXPLAIN and we need to preserve the initial query structure
so we can display it.
*/
select_lex
->
uncacheable
|=
UNCACHEABLE_EXPLAIN
;
select_lex
->
master_unit
()
->
uncacheable
|=
UNCACHEABLE_EXPLAIN
;
if
(
join
->
init_save_join_tab
())
DBUG_RETURN
(
1
);
}
if
(
item
->
engine_changed
)
if
(
item
->
engine_changed
)
{
{
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
...
sql/sql_select.cc
View file @
27624ee4
...
@@ -1426,14 +1426,13 @@ JOIN::optimize()
...
@@ -1426,14 +1426,13 @@ JOIN::optimize()
}
}
}
}
if
(
select_lex
->
uncacheable
&&
!
is_top_level_join
())
/*
{
If this join belongs to an uncacheable subquery save
/* If this join belongs to an uncacheable subquery */
the original join
if
(
!
(
tmp_join
=
(
JOIN
*
)
thd
->
alloc
(
sizeof
(
JOIN
))))
*/
if
(
select_lex
->
uncacheable
&&
!
is_top_level_join
()
&&
init_save_join_tab
())
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
error
=
0
;
// Ensure that tmp_join.error= 0
restore_tmp
();
}
}
}
error
=
0
;
error
=
0
;
...
@@ -1495,6 +1494,27 @@ JOIN::reinit()
...
@@ -1495,6 +1494,27 @@ JOIN::reinit()
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
/**
@brief Save the original join layout
@details Saves the original join layout so it can be reused in
re-execution and for EXPLAIN.
@return Operation status
@retval 0 success.
@retval 1 error occurred.
*/
bool
JOIN
::
init_save_join_tab
()
{
if
(
!
(
tmp_join
=
(
JOIN
*
)
thd
->
alloc
(
sizeof
(
JOIN
))))
return
1
;
error
=
0
;
// Ensure that tmp_join.error= 0
restore_tmp
();
return
0
;
}
bool
bool
JOIN
::
save_join_tab
()
JOIN
::
save_join_tab
()
...
...
sql/sql_select.h
View file @
27624ee4
...
@@ -434,6 +434,7 @@ public:
...
@@ -434,6 +434,7 @@ public:
void
cleanup
(
bool
full
);
void
cleanup
(
bool
full
);
void
clear
();
void
clear
();
bool
save_join_tab
();
bool
save_join_tab
();
bool
init_save_join_tab
();
bool
send_row_on_empty_set
()
bool
send_row_on_empty_set
()
{
{
return
(
do_send_rows
&&
tmp_table_param
.
sum_func_count
!=
0
&&
return
(
do_send_rows
&&
tmp_table_param
.
sum_func_count
!=
0
&&
...
...
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