Bug #82346 STRCMP() does not respect PADSPACE
Submitted: 26 Jul 2016 11:40 Modified: 26 Jul 2016 11:58
Reporter: Alan Egerton Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:All OS:Any
Assigned to: CPU Architecture:Any

[26 Jul 2016 11:40] Alan Egerton
The manual states that "STRCMP() performs the comparison using the collation of the arguments."[1]

The manual also  states that "All MySQL collations are of type PADSPACE."[2]

It is therefore inferred that STRCMP() will, like the `=` operator, pad the shorter string to the length of the longer before performing the comparison.  However, one does not observe this behaviour in practice.

[1]: https://dev.mysql.com/doc/en/string-comparison-functions.html#function_strcmp
[2]: https://dev.mysql.com/doc/en/char.html

How to repeat:
mysql> SELECT 'ab' = 'ab ', STRCMP('ab','ab ');
| 'ab' = 'ab ' | STRCMP('ab','ab ') |
|            1 |                  0 |
1 row in set (0.00 sec)

Suggested fix:
Either the documentation needs to clarify that STRCMP() ignores the collation's PADSPACE characteristic, or else the implementation should be corrected.
[26 Jul 2016 11:58] Alan Egerton
Apologies, this was an idiotic bug report—a return value of 0 from STRCMP() is means equality, the same as a return value of 1 from the `=` operator.