Bug #34620 | item_row.cc:50: Item_row::illegal_method_call(const char*): Assertion `0' failed | ||
---|---|---|---|
Submitted: | 16 Feb 2008 17:16 | Modified: | 15 Mar 2008 8:41 |
Reporter: | Gleb Shchepa | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.0+, 5.0.58-BK | OS: | Any |
Assigned to: | Gleb Shchepa | CPU Architecture: | Any |
[16 Feb 2008 17:16]
Gleb Shchepa
[16 Feb 2008 19:36]
Valeriy Kravchuk
Thank you for a bug report. Verified just as described with latest 5.0.58-BK on Linux.
[22 Feb 2008 17:21]
Gleb Shchepa
If ROW item is a part of an expression that also has aggregate function calls (COUNT/SUM/AVG...), a "splitting" with a Item::split_sum_func2 function is applied to that ROW item. Current implementation of Item::split_sum_func2 a. calls Item_row::split_sum_func on this ROW item if its "columns" contain aggregate fuctions, otherwise b. replaces this Item_row with a newly created Item_aggregate_ref reference to it. (a) is ok, but (b) is an error, because Item_aggregate_ref is not suited for referencing multicolumn objects like ROW or multicolumn subselect. This error leads to several problems: 1. wrong result: SELECT ROW(a, 1) = (SELECT SUM(b), 10) FROM t1 GROUP BY a; This query returns 1 if t1 consists of the (1, 1) row, because Item_aggregate_ref::cols() always return 1 and comparison of 2nd "columns" (1 = 10) is always skipped; 2. failed assertion in debugging build: SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a; This query fails in the Item_row::illegal_method_call method after unexpected try to call Item_row::val_int (or another val_* method). It is because the IN expression evaluates with the aid of row cache, and row cache stores ROW item elements for further comparison reasons via sequential calls to the element_index method. This method is not overloaded for the Item_aggregate_ref class and it always returns 'this' pointer. So, instead of storing scalar values of ROW elements, row cache trying to obtain and store scalar value of a whole ROW. IMO replacement of ROW item with a Item_aggregate_ref reference item is unnecessary, and instead of overloading of Item_aggregate_ref::cols and Item_aggregate_ref::::element_index methods to route those calls to real item, I prefer to deal with ROW items like with [multicolumn] subselect items it the Item::split_sum_func2 method.
[27 Feb 2008 11:16]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43041 ChangeSet@1.2607, 2008-02-27 15:15:09+04:00, gshchepa@host.loc +3 -0 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.
[27 Feb 2008 17:52]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43094 ChangeSet@1.2607, 2008-02-27 21:51:23+04:00, gshchepa@host.loc +3 -0 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.
[27 Feb 2008 21:59]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43116 ChangeSet@1.2607, 2008-02-28 01:58:06+04:00, gshchepa@host.loc +3 -0 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.
[28 Feb 2008 17:55]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43165 ChangeSet@1.2607, 2008-02-28 21:52:16+04:00, gshchepa@host.loc +3 -0 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.
[28 Feb 2008 18:56]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43171 ChangeSet@1.2607, 2008-02-28 22:53:31+04:00, gshchepa@host.loc +3 -0 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.
[13 Mar 2008 19:26]
Bugs System
Pushed into 6.0.5-alpha
[13 Mar 2008 19:34]
Bugs System
Pushed into 5.1.24-rc
[13 Mar 2008 19:42]
Bugs System
Pushed into 5.0.60
[15 Mar 2008 8:41]
Jon Stephens
Documented bugfix in the 5.0.60, 5.1.24, and 6.0.5 changelogs as follows: Some subqueries using an expression that included an aggregate function could fail or in some cases lead to a crash of the server.
[2 Apr 2008 20:00]
Jon Stephens
Also noted in the 5.1.23-ndb-6.3.11 changelog.