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
f7a47e13
Commit
f7a47e13
authored
Apr 18, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 5.3
parents
ed899ec8
13dc299a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
mysql-test/r/having.result
mysql-test/r/having.result
+29
-0
mysql-test/t/having.test
mysql-test/t/having.test
+36
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/having.result
View file @
f7a47e13
...
...
@@ -637,3 +637,32 @@ Note 1003 select min(`test`.`t1`.`f10`) AS `field1` from `test`.`t1` where <expr
set optimizer_switch=@save_optimizer_switch;
drop table t1,t2,t3;
End of 5.2 tests
#
# Bug mdev-6116: an equality in the conjunction of HAVING
# and IN subquery in WHERE
# (The bug is caused by the same problem as bug mdev-5927)
#
CREATE TABLE t1 (f_key varchar(1), f_nokey varchar(1), INDEX(f_key));
INSERT INTO t1 VALUES ('v','v'),('s','s');
CREATE TABLE t2 (f_int int, f_key varchar(1), INDEX(f_key));
INSERT INTO t2 VALUES
(4,'j'),(6,'v'),(3,'c'),(5,'m'),(3,'d'),(2,'d'),(2,'y'),
(9,'t'),(3,'d'),(8,'s'),(1,'r'),(8,'m'),(8,'b'),(5,'x');
SELECT t2.f_int FROM t1 INNER JOIN t2 ON (t2.f_key = t1.f_nokey)
WHERE t1.f_nokey IN (
SELECT t1.f_key FROM t1, t2 WHERE t1.f_key = t2.f_key
) HAVING t2.f_int >= 0 AND t2.f_int != 0;
f_int
6
8
DROP TABLE t1,t2;
#
# Bug mdev-5927: an equality in the conjunction of HAVING
# and an equality in WHERE
#
CREATE TABLE t1 (pk int PRIMARY KEY, f int NOT NULL, INDEX(f));
INSERT INTO t1 VALUES (1,0), (2,8);
SELECT * FROM t1 WHERE f = 2 HAVING ( pk IN ( SELECT 9 ) AND f != 0 );
pk f
DROP TABLE t1;
End of 5.3 tests
mysql-test/t/having.test
View file @
f7a47e13
...
...
@@ -657,3 +657,39 @@ set optimizer_switch=@save_optimizer_switch;
drop
table
t1
,
t2
,
t3
;
--
echo
End
of
5.2
tests
--
echo
#
--
echo
# Bug mdev-6116: an equality in the conjunction of HAVING
--
echo
# and IN subquery in WHERE
--
echo
# (The bug is caused by the same problem as bug mdev-5927)
--
echo
#
CREATE
TABLE
t1
(
f_key
varchar
(
1
),
f_nokey
varchar
(
1
),
INDEX
(
f_key
));
INSERT
INTO
t1
VALUES
(
'v'
,
'v'
),(
's'
,
's'
);
CREATE
TABLE
t2
(
f_int
int
,
f_key
varchar
(
1
),
INDEX
(
f_key
));
INSERT
INTO
t2
VALUES
(
4
,
'j'
),(
6
,
'v'
),(
3
,
'c'
),(
5
,
'm'
),(
3
,
'd'
),(
2
,
'd'
),(
2
,
'y'
),
(
9
,
't'
),(
3
,
'd'
),(
8
,
's'
),(
1
,
'r'
),(
8
,
'm'
),(
8
,
'b'
),(
5
,
'x'
);
SELECT
t2
.
f_int
FROM
t1
INNER
JOIN
t2
ON
(
t2
.
f_key
=
t1
.
f_nokey
)
WHERE
t1
.
f_nokey
IN
(
SELECT
t1
.
f_key
FROM
t1
,
t2
WHERE
t1
.
f_key
=
t2
.
f_key
)
HAVING
t2
.
f_int
>=
0
AND
t2
.
f_int
!=
0
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug mdev-5927: an equality in the conjunction of HAVING
--
echo
# and an equality in WHERE
--
echo
#
CREATE
TABLE
t1
(
pk
int
PRIMARY
KEY
,
f
int
NOT
NULL
,
INDEX
(
f
));
INSERT
INTO
t1
VALUES
(
1
,
0
),
(
2
,
8
);
SELECT
*
FROM
t1
WHERE
f
=
2
HAVING
(
pk
IN
(
SELECT
9
)
AND
f
!=
0
);
DROP
TABLE
t1
;
--
echo
End
of
5.3
tests
sql/sql_select.cc
View file @
f7a47e13
...
...
@@ -13608,7 +13608,7 @@ optimize_cond(JOIN *join, COND *conds,
conds
=
remove_eq_conds
(
thd
,
conds
,
cond_value
);
if
(
conds
&&
conds
->
type
()
==
Item
::
COND_ITEM
&&
((
Item_cond
*
)
conds
)
->
functype
()
==
Item_func
::
COND_AND_FUNC
)
join
->
cond_equal
=
&
((
Item_cond_and
*
)
conds
)
->
cond_equal
;
*
cond_equal
=
&
((
Item_cond_and
*
)
conds
)
->
cond_equal
;
DBUG_EXECUTE
(
"info"
,
print_where
(
conds
,
"after remove"
,
QT_ORDINARY
););
}
DBUG_RETURN
(
conds
);
...
...
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