Bug #30985 Results from weight_string() not as in specification
Submitted: 12 Sep 2007 16:03 Modified: 20 Sep 2007 22:01
Reporter: Peter Gulutzan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:6.0.3-alpha-debug OS:Linux (SUSE 10 64-bit)
Assigned to: Assigned Account CPU Architecture:Any

[12 Sep 2007 16:03] Peter Gulutzan
Description:
Looking at WEIGHT_STRING and comparing it to the specification
for weight_string in worklog task WL#3716
http://forge.mysql.com/worklog/task.php?id=3716

If I say "LEVEL 0", I get level-1 weights. I expected an empty string.

If I say "select hex(weight_string(5));", I get NULL.
I expected:
"If it's something else, e.g. FLOAT or INT or DECIMAL    
or ENUM, then accept it and return the bytes of numbers
as big-endian. Generally, show what MySQL uses for filesort."

I can say "LEVEL 2,1". I expected a syntax error.

How to repeat:
mysql> SELECT hex(weight_string('a' level 0));
+---------------------------------+
| hex(weight_string('a' level 0)) |
+---------------------------------+
| 0041                            |
+---------------------------------+
1 row in set (0.01 sec)

mysql> SELECT hex(weight_string(5));
+-----------------------+
| hex(weight_string(5)) |
+-----------------------+
| NULL                  |
+-----------------------+
1 row in set (0.00 sec)

mysql> SELECT hex(weight_string('a' level 2,1));
+-----------------------------------+
| hex(weight_string('a' level 2,1)) |
+-----------------------------------+
| 0041                              |
+-----------------------------------+
1 row in set (0.00 sec)
[12 Sep 2007 16:20] MySQL Verification Team
Thank you for the bug report.
[16 Oct 2007 17:56] Paul DuBois
'If I say "LEVEL 0", I get level-1 weights. I expected an empty string.'

Why? The WL says:

"If any number is less than 1, it is treated as 1."

Which seems to imply that "LEVEL 0" is the same as "LEVEL 1".
[14 Jul 2008 17:58] Peter Gulutzan
Paul DuBois is correct, "0" should be read as "1".