Bug #88221 Unique index identification error at create/alter table
Submitted: 25 Oct 2017 9:53 Modified: 27 Oct 2017 6:05
Reporter: Wei Zhao (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.7.17 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[25 Oct 2017 9:53] Wei Zhao
Description:
In function mysql_prepare_create_table() in file sql_table.cc , the way to regard an index as unique is incorrect, we need to check against the HA_NOSAME flag, as my attached patch shows.

This bug right now doesn't break anything, because the only place its computed 'unique_key' is used is a few lines below of the same function, but since HA_REQUIRE_PRIMARY_KEY is never set to a TABLE object's flag, that piece of code is never executed, so although the value of the variable 'unique_key' is wrong, no existing functionality is affected by it.

But it's still good practice to make things right, hence this patch.

How to repeat:
see above

Suggested fix:
see above and see my patch.
[25 Oct 2017 9:54] Wei Zhao
this patch fixes the bug

Attachment: mysql57_trivial_bug.diff (application/octet-stream, text), 631 bytes.

[27 Oct 2017 6:05] Umesh Shastry
Hello Wei Zhao,

Thank you for the bug report and supplying patch along with the report.
Imho, it would be always better if you attach contribution patches through "Contributions" tab. 

Thanks,
Umesh
[17 Nov 2017 2:01] Wei Zhao
adding the patch as contribution

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: mysql57_trivial_bug.diff (application/octet-stream, text), 631 bytes.