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
f5c9e634
Commit
f5c9e634
authored
Nov 01, 2007
by
gkodinov/kgeorge@magare.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge magare.gmz:/home/kgeorge/mysql/work/B31794-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B31794-5.1-opt
parents
e0e65472
92a5605d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+15
-0
mysql-test/t/func_group.test
mysql-test/t/func_group.test
+19
-0
sql/sql_select.cc
sql/sql_select.cc
+10
-2
No files found.
mysql-test/r/func_group.result
View file @
f5c9e634
...
...
@@ -1383,4 +1383,19 @@ SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01';
MIN(b)
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3),(4);
SET SQL_MODE=ONLY_FULL_GROUP_BY;
SELECT a FROM t1 HAVING COUNT(*)>2;
ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
SELECT COUNT(*), a FROM t1;
ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
SET SQL_MODE=DEFAULT;
SELECT a FROM t1 HAVING COUNT(*)>2;
a
1
SELECT COUNT(*), a FROM t1;
COUNT(*) a
4 1
DROP TABLE t1;
End of 5.0 tests
mysql-test/t/func_group.test
View file @
f5c9e634
...
...
@@ -889,5 +889,24 @@ CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b));
SELECT
MIN
(
b
)
FROM
t1
WHERE
a
=
1
AND
b
>
'2007-08-01'
;
DROP
TABLE
t1
;
#
# Bug #31794: no syntax error on SELECT id FROM t HAVING count(*)>2;
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
),(
2
),(
3
),(
4
);
SET
SQL_MODE
=
ONLY_FULL_GROUP_BY
;
--
error
ER_MIX_OF_GROUP_FUNC_AND_FIELDS
SELECT
a
FROM
t1
HAVING
COUNT
(
*
)
>
2
;
--
error
ER_MIX_OF_GROUP_FUNC_AND_FIELDS
SELECT
COUNT
(
*
),
a
FROM
t1
;
SET
SQL_MODE
=
DEFAULT
;
SELECT
a
FROM
t1
HAVING
COUNT
(
*
)
>
2
;
SELECT
COUNT
(
*
),
a
FROM
t1
;
DROP
TABLE
t1
;
###
--
echo
End
of
5.0
tests
sql/sql_select.cc
View file @
f5c9e634
...
...
@@ -571,11 +571,12 @@ JOIN::prepare(Item ***rref_pointer_array,
/*
Check if
one one uses a not constant column with group functions
a
nd no GROUP BY
.
Check if
there are references to un-aggregated columns when computing
a
ggregate functions with implicit grouping (there is no GROUP BY)
.
TODO: Add check of calculation of GROUP functions and fields:
SELECT COUNT(*)+table.col1 from table1;
*/
if
(
thd
->
variables
.
sql_mode
&
MODE_ONLY_FULL_GROUP_BY
)
{
if
(
!
group_list
)
{
...
...
@@ -589,6 +590,13 @@ JOIN::prepare(Item ***rref_pointer_array,
else
if
(
!
(
flag
&
2
)
&&
!
item
->
const_during_execution
())
flag
|=
2
;
}
if
(
having
)
{
if
(
having
->
with_sum_func
)
flag
|=
1
;
else
if
(
!
having
->
const_during_execution
())
flag
|=
2
;
}
if
(
flag
==
3
)
{
my_message
(
ER_MIX_OF_GROUP_FUNC_AND_FIELDS
,
...
...
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