mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#34749: Server crash when using NAME_CONST() with an aggregate function
NAME_CONST('whatever', -1) * MAX(whatever) bombed since -1 was not seen as constant, but as FUNCTION_UNARY_MINUS(constant) while we are at the same time pretending it was a basic const item. This confused the aggregate handlers in exciting ways. We now make NAME_CONST() behave more consistently. mysql-test/r/func_misc.result: show that a combination of NAME_CONST('x', -y) and an aggregate no longer crashes the server. mysql-test/t/func_misc.test: show that a combination of NAME_CONST('x', -y) and an aggregate no longer crashes the server. sql/ha_ndbcluster_cond.cc: tell cluster about "new" function type NEG_FUNC. (this was previous identified as UNKNOWN_FUNC, so we just handle it the same way, that's all.) sql/ha_ndbcluster_cond.h: tell cluster about "new" function type NEG_FUNC. (this was previous identified as UNKNOWN_FUNC, so we just handle it the same way, that's all.) sql/item.cc: make NAME_CONST() transparent in that type() of -constant is that of constant, not that of unary minus (id est, FUNC_ITEM). sql/item.h: Move constructor to item.cc sql/item_func.h: Revert Bug#30832; we can apply the magic more narrowly (just for NAME_CONST() rather than all Item_func_neg). Introduce new function type "NEG_FUNC."
This commit is contained in:
@ -204,6 +204,24 @@ SELECT NAME_CONST('test', 1.0);
|
||||
SELECT NAME_CONST('test', -1.0);
|
||||
SELECT NAME_CONST('test', 'test');
|
||||
|
||||
#
|
||||
# Bug #34749: Server crash when using NAME_CONST() with an aggregate function
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2),(3);
|
||||
# NAME_CONST() + aggregate.
|
||||
SELECT NAME_CONST('flag',1) * MAX(a) FROM t1;
|
||||
SELECT NAME_CONST('flag',1.5) * MAX(a) FROM t1;
|
||||
# Now, wrap the INT_ITEM in Item_func_neg and watch the pretty explosions
|
||||
SELECT NAME_CONST('flag',-1) * MAX(a) FROM t1;
|
||||
SELECT NAME_CONST('flag',-1.5) * MAX(a) FROM t1;
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
SELECT NAME_CONST('flag', SQRT(4)) * MAX(a) FROM t1;
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
SELECT NAME_CONST('flag',-SQRT(4)) * MAX(a) FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #27545: erroneous usage of NAME_CONST with a name as the first parameter
|
||||
# resolved against a column name of a derived table hangs the client
|
||||
|
Reference in New Issue
Block a user