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
8eb74b1f
Commit
8eb74b1f
authored
Jan 12, 2008
by
mhansson@lamia.dupka
Browse files
Options
Browse Files
Download
Plain Diff
Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into lamia.dupka:/home/mhansson/my50-bug31797-pushee
parents
baaf300d
e24109c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
1 deletion
+82
-1
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+36
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+44
-0
sql/item.cc
sql/item.cc
+2
-1
No files found.
mysql-test/r/group_by.result
View file @
8eb74b1f
...
@@ -1177,4 +1177,40 @@ id c1 c2
...
@@ -1177,4 +1177,40 @@ id c1 c2
4 2 3
4 2 3
1 5 1
1 5 1
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 ( a INT, b INT );
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c (SELECT a FROM t1 WHERE b = c)
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1
HAVING b = 10;
c (SELECT a FROM t1 WHERE b = c)
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
FROM t1
HAVING b = 10;
ERROR 42S22: Reference 'c' not supported (reference to group function)
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode='ONLY_FULL_GROUP_BY';
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c (SELECT a FROM t1 WHERE b = c)
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1
HAVING b = 10;
ERROR 42000: non-grouping field 'b' is used in HAVING clause
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
FROM t1
HAVING b = 10;
ERROR 42S22: Reference 'c' not supported (reference to group function)
INSERT INTO t1 VALUES (1, 1);
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c (SELECT a FROM t1 WHERE b = c)
1 1
INSERT INTO t1 VALUES (2, 1);
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/group_by.test
View file @
8eb74b1f
...
@@ -849,4 +849,48 @@ SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC;
...
@@ -849,4 +849,48 @@ SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
);
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
;
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
HAVING
b
=
10
;
--
error
ER_ILLEGAL_REFERENCE
SELECT
MAX
(
b
)
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
HAVING
b
=
10
;
SET
@
old_sql_mode
=
@@
sql_mode
;
SET
@@
sql_mode
=
'ONLY_FULL_GROUP_BY'
;
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
;
--
error
ER_NON_GROUPING_FIELD_USED
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
HAVING
b
=
10
;
--
error
ER_ILLEGAL_REFERENCE
SELECT
MAX
(
b
)
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
HAVING
b
=
10
;
INSERT
INTO
t1
VALUES
(
1
,
1
);
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
;
INSERT
INTO
t1
VALUES
(
2
,
1
);
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
b
c
,
(
SELECT
a
FROM
t1
WHERE
b
=
c
)
FROM
t1
;
DROP
TABLE
t1
;
SET
@@
sql_mode
=
@
old_sql_mode
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
sql/item.cc
View file @
8eb74b1f
...
@@ -3366,7 +3366,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
...
@@ -3366,7 +3366,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
resolve_ref_in_select_and_group()
resolve_ref_in_select_and_group()
thd current thread
thd current thread
ref column reference being resolved
ref column reference being resolved
select the s
ub-s
elect that ref is resolved against
select the select that ref is resolved against
DESCRIPTION
DESCRIPTION
Resolve a column reference (usually inside a HAVING clause) against the
Resolve a column reference (usually inside a HAVING clause) against the
...
@@ -3437,6 +3437,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
...
@@ -3437,6 +3437,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
}
}
if
(
thd
->
variables
.
sql_mode
&
MODE_ONLY_FULL_GROUP_BY
&&
if
(
thd
->
variables
.
sql_mode
&
MODE_ONLY_FULL_GROUP_BY
&&
select
->
having_fix_field
&&
select_ref
!=
not_found_item
&&
!
group_by_ref
)
select_ref
!=
not_found_item
&&
!
group_by_ref
)
{
{
/*
/*
...
...
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