Bug #96119 optimistic updates combined with collation-server may lead to erroneous updates
Submitted: 8 Jul 2019 9:13 Modified: 9 Jul 2019 12:57
Reporter: Nikos Voutsinas Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL for Windows: MySQL for Excel Severity:S2 (Serious)
Version:1.3.8 OS:Windows
Assigned to: CPU Architecture:Any

[8 Jul 2019 9:13] Nikos Voutsinas
Description:
A utf8mb4_unicode_ci collation-server setting when it is combined with the setting of optimistic updates in MySQL for Excel, leads to incorrect SQL updates and depending on the size of the column may end up to MySQL error.

In particular, optimistic updates setting leads to SQL update queries with redundant erroneous WHERE clauses. Disabling this setting helps you workaround the problems caused by the utf8mb4_unicode_ci collation-server setting. 

How to repeat:
1. Import the attached database (import_demo_db.sql)
2. Disable in MySQL For Excel the "Optimistic updates" setting (Options, Edit Sessions)
3. Perform via MySQL For Excel the following statements

 UPDATE `bug`.`v_vd_hrms` SET `extEmail`='asdfghjklzxcvb@gmail.com' WHERE `registrationID`='1001';
UPDATE `bug`.`v_vd_hrms` SET `employeeStatusDate`='20180102' WHERE `registrationID`='1001';
UPDATE `bug`.`v_vd_hrms` SET `extEmail`='asdfghjklzxcvbn@gmail.com' WHERE `registrationID`='1001';
UPDATE `bug`.`v_vd_hrms` SET `employeeStatusDate`='20180101' WHERE `registrationID`='1001';

4. Repeat the 1st step and import the attached database (import_demo_db.sql)
5. Enable in  MySQL For Excel the "Optimistic updates" setting (Options, Edit Sessions)
6. Repeat via MySQL For Excel the updates of the 3rd step. 

During the last step (6) notice the following:

Finding (a), by using the preview SQL statements setting, check the SQL syntax of the constructed updates.

Finding (b), when the value of the column extEmail (VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci) reaches a length of 25 (3rd update) the immediate next update on any other column fails with the error: 
"MySQL Error 1267: Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='"

Suggested fix:
You can workaround the above type of MySQL Errors if you either disable the optimistic update setting, or by removing the collation-server setting, if possible.

Even if you remove the collation-server utf8mb4_unicode_ci setting, the MySQL For Excel SQL statements preview, continues to show the same erroneous WHERE clauses. Haven't checked if this is the actual SQL query that is sent on the MySQL Server, though.
[9 Jul 2019 12:57] MySQL Verification Team
Hello Nikos Voutsinas,

Thank you for the report and steps.
Verified as described on Win 10 with MySQL for Windows: MySQL for Excel 1.3.8 and Excel 2019.

regards,
Umesh
[7 Apr 2020 5:02] MySQL Verification Team
Bug #99196 marked as duplicate of this one
[21 Sep 2020 18:16] Omer Barnir
Product under sustaining support