Skip to content

Commit 5968a23

Browse files
committed
Bug#20034943 Assertion failed: argument_count() > 0
A refactoring removed an apparently irrelevant if test and an indentation level from SELECT_LEX::change_group_ref(), but this bug proves that the if test had a mission. Fixed by calling Item::arguments() only inside the loop, hence eliminating the call when arg_count is zero.
1 parent 2613719 commit 5968a23

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

mysql-test/r/olap.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,3 +744,12 @@ f1
744744
11:11:11
745745
DROP TABLE t1;
746746
End of 5.5 tests
747+
# Bug#20034943 Assertion failed: argument_count() > 0
748+
CREATE TABLE t1(a INTEGER) engine=innodb;
749+
SELECT NOW() FROM t1 GROUP BY (select 1) WITH ROLLUP;
750+
NOW()
751+
DROP TABLE t1;
752+
CREATE TABLE t1(a INTEGER) engine=innodb;
753+
SELECT RELEASE_ALL_LOCKS() FROM t1 GROUP BY a WITH ROLLUP;
754+
RELEASE_ALL_LOCKS()
755+
DROP TABLE t1;

mysql-test/t/olap.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,13 @@ DROP TABLE t1;
455455
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
456456

457457
--echo End of 5.5 tests
458+
459+
--echo # Bug#20034943 Assertion failed: argument_count() > 0
460+
461+
CREATE TABLE t1(a INTEGER) engine=innodb;
462+
SELECT NOW() FROM t1 GROUP BY (select 1) WITH ROLLUP;
463+
DROP TABLE t1;
464+
465+
CREATE TABLE t1(a INTEGER) engine=innodb;
466+
SELECT RELEASE_ALL_LOCKS() FROM t1 GROUP BY a WITH ROLLUP;
467+
DROP TABLE t1;

sql/sql_resolver.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,12 +3363,10 @@ bool SELECT_LEX::setup_group(THD *thd)
33633363

33643364
bool SELECT_LEX::change_group_ref(THD *thd, Item_func *expr, bool *changed)
33653365
{
3366-
Item **arg,**arg_end;
33673366
bool arg_changed= false;
3368-
for (arg= expr->arguments(),
3369-
arg_end= expr->arguments()+expr->arg_count;
3370-
arg != arg_end; arg++)
3367+
for (uint i= 0; i < expr->arg_count; i++)
33713368
{
3369+
Item **arg= expr->arguments() + i;
33723370
Item *const item= *arg;
33733371
if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM)
33743372
{

0 commit comments

Comments
 (0)