Bug #14146 CHAR(...USING ...) and CONVERT(CHAR(...) USING...) produce different results
Submitted: 19 Oct 2005 15:57 Modified: 2 Dec 2005 20:41
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.15/5.0.16 BK source OS:Linux (Linux)
Assigned to: Alexander Barkov CPU Architecture:Any

[19 Oct 2005 15:57] Paul DuBois
Description:
Recent changes to CHAR() (in 5.0.15) result in the following behavior
for CHAR(0xff USING utf8):

- Not strict mode: CHAR() returns 0xff, plus a warning (code 1300)
- Strict mode: CHAR() returns NULL, plus a warning (code 1300)

However, that behavior differs from CONVERT(CHAR(0xff) USING utf8)
in strict mode, though logically they should be equivalent.

mysql> set sql_mode='traditional';
Query OK, 0 rows affected (0.00 sec)

mysql> select char(0xff using utf8);
+-----------------------+
| char(0xff using utf8) |
+-----------------------+
| NULL                  |
+-----------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select convert(char(0xff) using utf8);
+--------------------------------+
| convert(char(0xff) using utf8) |
+--------------------------------+
| ?                              |
+--------------------------------+
1 row in set (0.00 sec)

Shouldn't CONVERT() complain at least a little, and return NULL
when it cannot perform a legal conversion?

How to repeat:
See above.
[7 Nov 2005 8:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/32032
[28 Nov 2005 14:38] Alexander Barkov
Reviewed by Ingo.
Pushed into 5.0.17
[28 Nov 2005 14:39] Alexander Barkov
Sorry, Reviewed by Jim actually.
[2 Dec 2005 20:41] Paul DuBois
Noted in 5.0.17 changelog.
[20 Dec 2006 10:21] Vladimir Shebordaev
See also bug #5929