Bug #114538 Item_ref replaced by new item in Item_ref::transform lead to wrong result
Submitted: 3 Apr 2024 7:13 Modified: 3 Apr 2024 10:34
Reporter: Xinhao Zhao Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[3 Apr 2024 7:13] Xinhao Zhao
Description:
 8437 /**
 8438   Transform an Item_ref object with a transformer callback function.
 8439
 8440   The function first applies the transform function to the item
 8441   referenced by this Item_ref object. If this replaces the item with a
 8442   new one, this item object is returned as the result of the
 8443   transform. Otherwise the transform function is applied to the
 8444   Item_ref object itself.
 8445 */
 8446
 8447 Item *Item_ref::transform(Item_transformer transformer, uchar *arg) {
 8448   assert(ref_item() != nullptr);
 8449
 8450   /* Transform the object we are referencing. */
 8451   Item *new_item = ref_item()->transform(transformer, arg);
 8452   if (new_item == nullptr) return nullptr;
 8453
 8454   /*
 8455     If the object is transformed into a new object, discard the Item_ref
 8456     object and return the new object as result.
 8457   */
 8458   if (new_item != ref_item()) return new_item;
 8459
 8460   /* Transform the item ref object. */
 8461   Item *transformed_item = (this->*transformer)(arg);
 8462   // assert(transformed_item == this);
 8463   return transformed_item;
 8464 }

How to repeat:
-
[3 Apr 2024 10:34] MySQL Verification Team
Hi Mr. Zhao,

Thank you for your bug report.

However, let us inform you that this is a forum for the reports with a FULLY repeatable test cases. These test cases should consist of the set of SQL statements that always lead to the error that shows the bug.

Also, replacement of on Item class with another Item from the same hierarchy is practiced very often in our optimiser. This all works very well to the satisfaction of our customers and users.

Can't repeat.