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
2189c571
Commit
2189c571
authored
May 17, 2007
by
igor@olga.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug28337
parents
4ac1e986
8c34ae26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
1 deletion
+56
-1
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+30
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+24
-0
sql/item.cc
sql/item.cc
+2
-1
No files found.
mysql-test/r/subselect.result
View file @
2189c571
...
@@ -4041,4 +4041,34 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -4041,4 +4041,34 @@ 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
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
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
(3,'FL'), (2,'GA'), (4,'FL'), (1,'GA'), (5,'NY'), (7,'FL'), (6,'NY');
CREATE TABLE t2 (id int NOT NULL, INDEX idx(id));
INSERT INTO t2 VALUES (7), (5), (1), (3);
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
3 FL
1 GA
7 FL
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
id st
1 GA
3 FL
7 FL
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
2 GA
4 FL
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
id st
2 GA
4 FL
DROP TABLE t1,t2;
End of 5.0 tests.
End of 5.0 tests.
mysql-test/t/subselect.test
View file @
2189c571
...
@@ -2882,4 +2882,28 @@ INSERT INTO t1 VALUES (1,1),(2,1);
...
@@ -2882,4 +2882,28 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN
SELECT
1
FROM
t1
WHERE
a
=
(
SELECT
COUNT
(
*
)
FROM
t1
GROUP
BY
b
);
EXPLAIN
SELECT
1
FROM
t1
WHERE
a
=
(
SELECT
COUNT
(
*
)
FROM
t1
GROUP
BY
b
);
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug #28377: grouping query with a correlated subquery in WHERE condition
#
CREATE
TABLE
t1
(
id
int
NOT
NULL
,
st
CHAR
(
2
),
INDEX
idx
(
id
));
INSERT
INTO
t1
VALUES
(
3
,
'FL'
),
(
2
,
'GA'
),
(
4
,
'FL'
),
(
1
,
'GA'
),
(
5
,
'NY'
),
(
7
,
'FL'
),
(
6
,
'NY'
);
CREATE
TABLE
t2
(
id
int
NOT
NULL
,
INDEX
idx
(
id
));
INSERT
INTO
t2
VALUES
(
7
),
(
5
),
(
1
),
(
3
);
SELECT
id
,
st
FROM
t1
WHERE
st
IN
(
'GA'
,
'FL'
)
AND
EXISTS
(
SELECT
1
FROM
t2
WHERE
t2
.
id
=
t1
.
id
);
SELECT
id
,
st
FROM
t1
WHERE
st
IN
(
'GA'
,
'FL'
)
AND
EXISTS
(
SELECT
1
FROM
t2
WHERE
t2
.
id
=
t1
.
id
)
GROUP
BY
id
;
SELECT
id
,
st
FROM
t1
WHERE
st
IN
(
'GA'
,
'FL'
)
AND
NOT
EXISTS
(
SELECT
1
FROM
t2
WHERE
t2
.
id
=
t1
.
id
);
SELECT
id
,
st
FROM
t1
WHERE
st
IN
(
'GA'
,
'FL'
)
AND
NOT
EXISTS
(
SELECT
1
FROM
t2
WHERE
t2
.
id
=
t1
.
id
)
GROUP
BY
id
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
.
--
echo
End
of
5.0
tests
.
sql/item.cc
View file @
2189c571
...
@@ -3503,7 +3503,8 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
...
@@ -3503,7 +3503,8 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
prev_subselect_item
->
const_item_cache
=
0
;
prev_subselect_item
->
const_item_cache
=
0
;
set_field
(
*
from_field
);
set_field
(
*
from_field
);
if
(
!
last_checked_context
->
select_lex
->
having_fix_field
&&
if
(
!
last_checked_context
->
select_lex
->
having_fix_field
&&
select
->
group_list
.
elements
)
select
->
group_list
.
elements
&&
(
place
==
SELECT_LIST
||
place
==
IN_HAVING
))
{
{
Item_outer_ref
*
rf
;
Item_outer_ref
*
rf
;
/*
/*
...
...
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