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
ec9bd00e
Commit
ec9bd00e
authored
Apr 22, 2011
by
Sergey Glukhov
Browse files
Options
Browse Files
Download
Plain Diff
5.1 -> 5.5 merge
parents
708df849
801b0ca2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletion
+85
-1
mysql-test/r/having.result
mysql-test/r/having.result
+22
-0
mysql-test/t/having.test
mysql-test/t/having.test
+26
-0
sql/sql_select.cc
sql/sql_select.cc
+37
-1
No files found.
mysql-test/r/having.result
View file @
ec9bd00e
...
@@ -547,4 +547,26 @@ FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
...
@@ -547,4 +547,26 @@ FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
HAVING field1 < 7;
HAVING field1 < 7;
field1
field1
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
#
CREATE TABLE t1 (f1 INT, f2 INT);
INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
CREATE TABLE t2 (f1 INT, f2 INT);
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
SELECT t1.f1
FROM t1
HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
DROP TABLE t1,t2;
End of 5.1 tests
End of 5.1 tests
mysql-test/t/having.test
View file @
ec9bd00e
...
@@ -564,4 +564,30 @@ HAVING field1 < 7;
...
@@ -564,4 +564,30 @@ HAVING field1 < 7;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
--
echo
#
CREATE
TABLE
t1
(
f1
INT
,
f2
INT
);
INSERT
INTO
t1
VALUES
(
1
,
0
),
(
2
,
1
),
(
3
,
2
);
CREATE
TABLE
t2
(
f1
INT
,
f2
INT
);
SELECT
t1
.
f1
FROM
t1
HAVING
(
3
,
2
)
IN
(
SELECT
f1
,
f2
FROM
t2
)
AND
t1
.
f1
>=
0
ORDER
BY
t1
.
f1
;
SELECT
t1
.
f1
FROM
t1
HAVING
(
3
,
2
)
IN
(
SELECT
4
,
2
)
AND
t1
.
f1
>=
0
ORDER
BY
t1
.
f1
;
SELECT
t1
.
f1
FROM
t1
HAVING
2
IN
(
SELECT
f2
FROM
t2
)
AND
t1
.
f1
>=
0
ORDER
BY
t1
.
f1
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.1
tests
--
echo
End
of
5.1
tests
sql/sql_select.cc
View file @
ec9bd00e
...
@@ -2263,7 +2263,7 @@ JOIN::exec()
...
@@ -2263,7 +2263,7 @@ JOIN::exec()
Item
*
sort_table_cond
=
make_cond_for_table
(
curr_join
->
tmp_having
,
Item
*
sort_table_cond
=
make_cond_for_table
(
curr_join
->
tmp_having
,
used_tables
,
used_tables
,
used_tables
);
(
table_map
)
0
);
if
(
sort_table_cond
)
if
(
sort_table_cond
)
{
{
if
(
!
curr_table
->
select
)
if
(
!
curr_table
->
select
)
...
@@ -13102,6 +13102,42 @@ static bool test_if_ref(Item_field *left_item,Item *right_item)
...
@@ -13102,6 +13102,42 @@ static bool test_if_ref(Item_field *left_item,Item *right_item)
return
0
;
// keep test
return
0
;
// keep test
}
}
/**
Extract a condition that can be checked after reading given table
@param cond Condition to analyze
@param tables Tables for which "current field values" are available
@param used_table Table that we're extracting the condition for (may
also include PSEUDO_TABLE_BITS, and may be zero)
@param exclude_expensive_cond Do not push expensive conditions
@retval <>NULL Generated condition
@retval =NULL Already checked, OR error
@details
Extract the condition that can be checked after reading the table
specified in 'used_table', given that current-field values for tables
specified in 'tables' bitmap are available.
If 'used_table' is 0
- extract conditions for all tables in 'tables'.
- extract conditions are unrelated to any tables
in the same query block/level(i.e. conditions
which have used_tables == 0).
The function assumes that
- Constant parts of the condition has already been checked.
- Condition that could be checked for tables in 'tables' has already
been checked.
The function takes into account that some parts of the condition are
guaranteed to be true by employed 'ref' access methods (the code that
does this is located at the end, search down for "EQ_FUNC").
@note
Make sure to keep the implementations of make_cond_for_table() and
make_cond_after_sjm() synchronized.
make_cond_for_info_schema() uses similar algorithm as well.
*/
static
COND
*
static
COND
*
make_cond_for_table
(
COND
*
cond
,
table_map
tables
,
table_map
used_table
)
make_cond_for_table
(
COND
*
cond
,
table_map
tables
,
table_map
used_table
)
...
...
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