mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Fixed bug #34620: item_row.cc:50: Item_row::illegal_method_call(const char*):
Assertion `0' failed If ROW item is a part of an expression that also has aggregate function calls (COUNT/SUM/AVG...), a "splitting" with an Item::split_sum_func2 function is applied to that ROW item. Current implementation of Item::split_sum_func2 replaces this Item_row with a newly created Item_aggregate_ref reference to it. Then the row cache tries to work with the Item_aggregate_ref object as with the Item_row object: row cache calls row-emulation methods such as cols and element_index. Item_aggregate_ref (like it's parent Item_ref) inherits dummy implementations of those methods from the hierarchy root Item, and call to them leads to failed assertions and wrong data output. Row-emulation virtual functions (cols, element_index, addr, check_cols, null_inside and bring_value) of Item_ref have been overloaded to forward calls to an underlying item reference. mysql-test/r/row.result: Added test case for bug #34620. mysql-test/t/row.test: Added test case for bug #34620. sql/item.h: Fixed bug #34620. Row-emulation virtual functions (cols, element_index, addr, check_cols, null_inside and bring_value) of Item_ref have been overloaded to forward calls to an underlying item reference.
This commit is contained in:
parent
c4fc5b096e
commit
d40ca16156
3 changed files with 51 additions and 0 deletions
|
@ -434,3 +434,12 @@ SELECT @x;
|
|||
@x
|
||||
99
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
|
||||
ROW(a, 1) IN (SELECT SUM(b), 1)
|
||||
1
|
||||
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
|
||||
ROW(a, 1) IN (SELECT SUM(b), 3)
|
||||
0
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -224,3 +224,16 @@ SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7));
|
|||
SELECT @x;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #34620: item_row.cc:50: Item_row::illegal_method_call(const char*):
|
||||
# Assertion `0' failed
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
|
||||
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
|
||||
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
|
29
sql/item.h
29
sql/item.h
|
@ -1990,6 +1990,35 @@ public:
|
|||
Item_field *filed_for_view_update()
|
||||
{ return (*ref)->filed_for_view_update(); }
|
||||
virtual Ref_Type ref_type() { return REF; }
|
||||
|
||||
// Row emulation: forwarding of ROW-related calls to ref
|
||||
uint cols()
|
||||
{
|
||||
return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
|
||||
}
|
||||
Item* element_index(uint i)
|
||||
{
|
||||
return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
|
||||
}
|
||||
Item** addr(uint i)
|
||||
{
|
||||
return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
|
||||
}
|
||||
bool check_cols(uint c)
|
||||
{
|
||||
return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c)
|
||||
: Item::check_cols(c);
|
||||
}
|
||||
bool null_inside()
|
||||
{
|
||||
return ref && result_type() == ROW_RESULT ? (*ref)->null_inside() : 0;
|
||||
}
|
||||
void bring_value()
|
||||
{
|
||||
if (ref && result_type() == ROW_RESULT)
|
||||
(*ref)->bring_value();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue