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
79073ea7
Commit
79073ea7
authored
Jul 22, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk@192.168.21.1:mysql-4.1-opt
into mysql.com:/home/hf/work/29494/my41-29494
parents
1a2d2117
72c6c789
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
mysql-test/r/having.result
mysql-test/r/having.result
+19
-0
mysql-test/t/having.test
mysql-test/t/having.test
+26
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/having.result
View file @
79073ea7
...
@@ -158,3 +158,22 @@ EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
...
@@ -158,3 +158,22 @@ EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
DROP table t1;
DROP table t1;
CREATE TABLE t1 (a int PRIMARY KEY);
CREATE TABLE t2 (b int PRIMARY KEY, a int);
CREATE TABLE t3 (b int, flag int);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1,1), (2,1), (3,1);
INSERT INTO t3(b,flag) VALUES (2, 1);
SELECT t1.a
FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
a
SELECT DISTINCT t1.a, MAX(t3.flag)
FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
a MAX(t3.flag)
SELECT DISTINCT t1.a
FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
a
DROP TABLE t1,t2,t3;
mysql-test/t/having.test
View file @
79073ea7
...
@@ -151,4 +151,30 @@ EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
...
@@ -151,4 +151,30 @@ EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
DROP
table
t1
;
DROP
table
t1
;
#
# Bug #29911: HAVING clause depending on constant table and evaluated to false
#
CREATE
TABLE
t1
(
a
int
PRIMARY
KEY
);
CREATE
TABLE
t2
(
b
int
PRIMARY
KEY
,
a
int
);
CREATE
TABLE
t3
(
b
int
,
flag
int
);
INSERT
INTO
t1
VALUES
(
1
);
INSERT
INTO
t2
VALUES
(
1
,
1
),
(
2
,
1
),
(
3
,
1
);
INSERT
INTO
t3
(
b
,
flag
)
VALUES
(
2
,
1
);
SELECT
t1
.
a
FROM
t1
INNER
JOIN
t2
ON
t1
.
a
=
t2
.
a
LEFT
JOIN
t3
ON
t2
.
b
=
t3
.
b
GROUP
BY
t1
.
a
,
t2
.
b
HAVING
MAX
(
t3
.
flag
)
=
0
;
SELECT
DISTINCT
t1
.
a
,
MAX
(
t3
.
flag
)
FROM
t1
INNER
JOIN
t2
ON
t1
.
a
=
t2
.
a
LEFT
JOIN
t3
ON
t2
.
b
=
t3
.
b
GROUP
BY
t1
.
a
,
t2
.
b
HAVING
MAX
(
t3
.
flag
)
=
0
;
SELECT
DISTINCT
t1
.
a
FROM
t1
INNER
JOIN
t2
ON
t1
.
a
=
t2
.
a
LEFT
JOIN
t3
ON
t2
.
b
=
t3
.
b
GROUP
BY
t1
.
a
,
t2
.
b
HAVING
MAX
(
t3
.
flag
)
=
0
;
DROP
TABLE
t1
,
t2
,
t3
;
# End of 4.1 tests
# End of 4.1 tests
sql/sql_select.cc
View file @
79073ea7
...
@@ -8118,7 +8118,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
...
@@ -8118,7 +8118,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
field_count
++
;
field_count
++
;
}
}
if
(
!
field_count
&&
!
(
join
->
select_options
&
OPTION_FOUND_ROWS
))
if
(
!
field_count
&&
!
(
join
->
select_options
&
OPTION_FOUND_ROWS
)
&&
!
having
)
{
// only const items with no OPTION_FOUND_ROWS
{
// only const items with no OPTION_FOUND_ROWS
join
->
unit
->
select_limit_cnt
=
1
;
// Only send first row
join
->
unit
->
select_limit_cnt
=
1
;
// Only send first row
DBUG_RETURN
(
0
);
DBUG_RETURN
(
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