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
de9cefaa
Commit
de9cefaa
authored
Jun 24, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-innodb-4.1
parents
62aeb886
d3efbb9d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
2 deletions
+33
-2
mysql-test/r/subselect_innodb.result
mysql-test/r/subselect_innodb.result
+10
-0
mysql-test/t/subselect_innodb.test
mysql-test/t/subselect_innodb.test
+10
-0
sql/item_subselect.cc
sql/item_subselect.cc
+5
-0
sql/sql_lex.cc
sql/sql_lex.cc
+1
-1
sql/sql_lex.h
sql/sql_lex.h
+5
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-1
No files found.
mysql-test/r/subselect_innodb.result
View file @
de9cefaa
...
@@ -96,3 +96,13 @@ id value (select t1.value from t1 where t1.id=t2.id)
...
@@ -96,3 +96,13 @@ id value (select t1.value from t1 where t1.id=t2.id)
1 z a
1 z a
2 x b
2 x b
drop table t1,t2;
drop table t1,t2;
create table t1 (a int, b int) engine=innodb;
insert into t1 values (1,2), (1,3), (2,3), (2,4), (2,5), (3,4), (4,5), (4,100);
create table t2 (a int) engine=innodb;
insert into t2 values (1),(2),(3),(4);
select a, sum(b) as b from t1 group by a having b > (select max(a) from t2);
a b
1 5
2 12
4 105
drop table t1, t2;
mysql-test/t/subselect_innodb.test
View file @
de9cefaa
...
@@ -101,3 +101,13 @@ insert into t2 values (1,'z'),(2,'x');
...
@@ -101,3 +101,13 @@ insert into t2 values (1,'z'),(2,'x');
select
t2
.
id
,
t2
.
value
,(
select
t1
.
value
from
t1
where
t1
.
id
=
t2
.
id
)
from
t2
;
select
t2
.
id
,
t2
.
value
,(
select
t1
.
value
from
t1
where
t1
.
id
=
t2
.
id
)
from
t2
;
select
t2
.
id
,
t2
.
value
,(
select
t1
.
value
from
t1
where
t1
.
id
=
t2
.
id
)
from
t2
;
select
t2
.
id
,
t2
.
value
,(
select
t1
.
value
from
t1
where
t1
.
id
=
t2
.
id
)
from
t2
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# unlocking tables with subqueries in HAVING
#
create
table
t1
(
a
int
,
b
int
)
engine
=
innodb
;
insert
into
t1
values
(
1
,
2
),
(
1
,
3
),
(
2
,
3
),
(
2
,
4
),
(
2
,
5
),
(
3
,
4
),
(
4
,
5
),
(
4
,
100
);
create
table
t2
(
a
int
)
engine
=
innodb
;
insert
into
t2
values
(
1
),(
2
),(
3
),(
4
);
select
a
,
sum
(
b
)
as
b
from
t1
group
by
a
having
b
>
(
select
max
(
a
)
from
t2
);
drop
table
t1
,
t2
;
sql/item_subselect.cc
View file @
de9cefaa
...
@@ -74,6 +74,11 @@ void Item_subselect::init(st_select_lex *select_lex,
...
@@ -74,6 +74,11 @@ void Item_subselect::init(st_select_lex *select_lex,
else
else
engine
=
new
subselect_single_select_engine
(
select_lex
,
result
,
this
);
engine
=
new
subselect_single_select_engine
(
select_lex
,
result
,
this
);
}
}
{
SELECT_LEX
*
upper
=
unit
->
outer_select
();
if
(
upper
->
parsing_place
==
SELECT_LEX_NODE
::
IN_HAVING
)
upper
->
subquery_in_having
=
1
;
}
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
...
sql/sql_lex.cc
View file @
de9cefaa
...
@@ -1008,7 +1008,7 @@ void st_select_lex::init_query()
...
@@ -1008,7 +1008,7 @@ void st_select_lex::init_query()
ref_pointer_array
=
0
;
ref_pointer_array
=
0
;
select_n_having_items
=
0
;
select_n_having_items
=
0
;
prep_where
=
0
;
prep_where
=
0
;
explicit_limit
=
0
;
subquery_in_having
=
explicit_limit
=
0
;
}
}
void
st_select_lex
::
init_select
()
void
st_select_lex
::
init_select
()
...
...
sql/sql_lex.h
View file @
de9cefaa
...
@@ -433,6 +433,11 @@ public:
...
@@ -433,6 +433,11 @@ public:
bool
having_fix_field
;
bool
having_fix_field
;
/* explicit LIMIT clause was used */
/* explicit LIMIT clause was used */
bool
explicit_limit
;
bool
explicit_limit
;
/*
there are subquery in HAVING clause => we can't close tables before
query processing end even if we use temporary table
*/
bool
subquery_in_having
;
/*
/*
SELECT for SELECT command st_select_lex. Used to privent scaning
SELECT for SELECT command st_select_lex. Used to privent scaning
...
...
sql/sql_select.cc
View file @
de9cefaa
...
@@ -3884,7 +3884,8 @@ JOIN::join_free(bool full)
...
@@ -3884,7 +3884,8 @@ JOIN::join_free(bool full)
*/
*/
if
((
full
||
!
select_lex
->
uncacheable
)
&&
if
((
full
||
!
select_lex
->
uncacheable
)
&&
lock
&&
thd
->
lock
&&
lock
&&
thd
->
lock
&&
!
(
select_options
&
SELECT_NO_UNLOCK
))
!
(
select_options
&
SELECT_NO_UNLOCK
)
&&
!
select_lex
->
subquery_in_having
)
{
{
mysql_unlock_read_tables
(
thd
,
lock
);
// Don't free join->lock
mysql_unlock_read_tables
(
thd
,
lock
);
// Don't free join->lock
lock
=
0
;
lock
=
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