Skip to content

Commit

Permalink
MDEV-28095 crash in multi-update and implicit grouping
Browse files Browse the repository at this point in the history
disallow implicit grouping in multi-update.
explicit GROUP BY is not allowed by the grammar.
  • Loading branch information
vuvova committed Mar 17, 2022
1 parent 6a2d88c commit ecb6f9c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mysql-test/main/multi_update_innodb.result
Expand Up @@ -207,4 +207,19 @@ ERROR 23000: Duplicate entry '0000-00-00 00:00:00' for key 'f2k'
DROP VIEW v1;
DROP TABLE t3,t4;
SET @@sql_mode=@save_sql_mode;
#
# End of 10.2 tests
#
#
# MDEV-28095 crash in multi-update and implicit grouping
#
CREATE TABLE t1 (a int) engine=innodb;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (1),(2);
UPDATE t1 NATURAL JOIN t2 SET a = 1 ORDER BY AVG (a) ;
ERROR HY000: Invalid use of group function
DROP TABLE t1, t2;
#
# End of 10.3 tests
#
19 changes: 19 additions & 0 deletions mysql-test/main/multi_update_innodb.test
Expand Up @@ -243,4 +243,23 @@ DROP VIEW v1;
DROP TABLE t3,t4;
SET @@sql_mode=@save_sql_mode;

--echo #
--echo # End of 10.2 tests
--echo #

--echo #
--echo # MDEV-28095 crash in multi-update and implicit grouping
--echo #
CREATE TABLE t1 (a int) engine=innodb;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (1),(2);
--error ER_INVALID_GROUP_FUNC_USE
UPDATE t1 NATURAL JOIN t2 SET a = 1 ORDER BY AVG (a) ;
DROP TABLE t1, t2;


--echo #
--echo # End of 10.3 tests
--echo #

5 changes: 5 additions & 0 deletions sql/sql_update.cc
Expand Up @@ -2150,6 +2150,11 @@ multi_update::initialize_tables(JOIN *join)
if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) &&
error_if_full_join(join)))
DBUG_RETURN(1);
if (join->implicit_grouping)
{
my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0));
DBUG_RETURN(1);
}
main_table=join->join_tab->table;
table_to_update= 0;

Expand Down

0 comments on commit ecb6f9c

Please sign in to comment.