Bug #71330 Item_insert_value type should be ITEM_INSERT_VALUE
Submitted: 9 Jan 2014 15:30 Modified: 9 Jan 2014 22:39
Reporter: richard prohaska Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.7.3, 5.6.15 OS:Any
Assigned to: CPU Architecture:Any

[9 Jan 2014 15:30] richard prohaska
Description:
In mysql 5.7.3 (and prior versions of mysql including 5.6 and perhaps
others), there is an item type ITEM_INSERT_VALUE, an Item_insert_value
class, but no Item class that implements a type() method that returns
ITEM_INSERT_VALUE.

In addition, the Item_insert_value::eq method queries an item's type()
for ITEM_INSERT_VALUE.

It seems like a bug that the Item_insert_value type is not ITEM_INSERT_VALUE.

How to repeat:
found via code inspection.

Suggested fix:
Add Item_insert_value::type() { return ITEM_INSERT_VALUE; }
[9 Jan 2014 22:39] Sveta Smirnova
Thank you for the report.

Verified as described.
[26 Jan 2018 5:20] Laurynas Biveinis
It appears to be fixed in 5.5.59 with

Bug #26881946: INCORRECT BEHAVIOR WITH "VALUES"
Issue:
------
VALUES doesn't have a type() function and is considered a
Item_field.

Solution for 5.7:
-----------------
Add a new type() function for Item_values_insert.

On 8.0 and trunk it was fixed by Mithun's Bug#19601973.

Solution for 5.6:
-----------------
Additionally Bug#17458914 is backported.

This will address the problem of using VALUES() in
INSERT ... ON DUPLICATE KEY UPDATE. Create a field object
only if it is in the UPDATE clause, else return a NULL
item.

This will also address the problems mentioned in
Bug#14789787 and Bug#16756402.

Solution for 5.5:
-----------------
As mentioned above Bug#17458914 is backported.

Additionally Bug#14786324 is also backported.

When VALUES() is detected outside its meaningful place,
it should be treated as NULL and is thus replaced with a
Field_null object, with the same name as the original
field.

Fields with type NULL are generally not handled well inside
the server (e.g Innodb will not accept them and it is
impossible to create them in regular tables). So create a
new const NULL item instead.