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.
parent f41a5edf
......@@ -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;
......@@ -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();
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment