Skip to content

Commit 57a551a

Browse files
author
Chaithra Gopalareddy
committed
Bug#36444257: `false' in operator at sql/sql_executor.cc
A const item that is part of group by and not found in select list is not added as a hidden item to the field's list post the fix for Bug#34951115. This is not taken into consideration while checking for replacements for expressions involving ROLLUP operation during temp table creation. So server fails a check. Fix is to check if the item that is not found in the field's list is a const item. If so, the same item will be used as a replacement. Change-Id: Ifca0618ef42930018def7a787f8c9aa3cd7d8be8
1 parent e219bf5 commit 57a551a

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

mysql-test/r/olap.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,3 +2365,10 @@ EXECUTE ps;
23652365
x
23662366
DROP PREPARE ps;
23672367
DROP TABLE t;
2368+
#
2369+
# Bug#36444257: `false' in operator at sql/sql_executor.cc
2370+
#
2371+
CREATE TABLE t1(f1 INTEGER);
2372+
SELECT SUM(TAN(0)) OVER() FROM t1 GROUP BY TAN(0) WITH ROLLUP;
2373+
SUM(TAN(0)) OVER()
2374+
DROP TABLE t1;

mysql-test/t/olap.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,3 +1303,11 @@ EXECUTE ps;
13031303
EXECUTE ps;
13041304
DROP PREPARE ps;
13051305
DROP TABLE t;
1306+
1307+
--echo #
1308+
--echo # Bug#36444257: `false' in operator at sql/sql_executor.cc
1309+
--echo #
1310+
1311+
CREATE TABLE t1(f1 INTEGER);
1312+
SELECT SUM(TAN(0)) OVER() FROM t1 GROUP BY TAN(0) WITH ROLLUP;
1313+
DROP TABLE t1;

sql/sql_executor.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,6 +4229,12 @@ static bool replace_embedded_rollup_references_with_tmp_fields(
42294229
return {ReplaceResult::REPLACE, item_field};
42304230
}
42314231
}
4232+
// A const item that is part of group by and not found in
4233+
// select list will not be found in "fields" (It's not added
4234+
// as a hidden item).
4235+
if (unwrap_rollup_group(sub_item)->const_item()) {
4236+
return {ReplaceResult::REPLACE, sub_item};
4237+
}
42324238
assert(false);
42334239
return {ReplaceResult::ERROR, nullptr};
42344240
};

0 commit comments

Comments
 (0)