Bug #6175 server crash on insert of number into VARCHAR in UTF8 database
Submitted: 20 Oct 2004 10:05 Modified: 21 Mar 2005 22:18
Reporter: Paul Lewis Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.5/4.1.6 OS:Windows (WinXP (sp1 and sp2))
Assigned to: Jim Winstead CPU Architecture:Any

[20 Oct 2004 10:05] Paul Lewis
Description:
mysqld-max-nt server crashes on XP "Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)" when inserting a numeric literal into a string column, if - only if - the database is "utf8".  Initially found on XP (sp1) running 4.1.6 (the 'no installer' download binary); also reproduced on XP (sp2) running 4.1.5 (also the 'no installer' download binary).

Tried various constraints on the table definition and the problem occurs in all cases tried, including with or without BINARY and with or without DEFAULT NULL.  Note: the server was being run as a service via "mysqld-max-nt --install", then started service manually.  Problem also occurs if server is run standalone: "mysqld-max-nt --standalone".

Not clear as to whether this should be a SQL error (because of the type mismatch) or whether MySQL does automatic version (as implied by the fact this works on a  non-UTF8 database) - I need to read the MySQL manual.  Fairly certain that the server shouldn't shutdown though! :-(

How to repeat:
CREATE DATABASE foo1 CHARACTER SET utf8;

USE foo1;

CREATE TABLE crash_me(string_value VARCHAR(250) BINARY DEFAULT NULL);

INSERT INTO crash_me(string_value) VALUES (9.8);

Problem does NOT occur if "CREATE DATABASE foo1" is used (no CHARACTER SET utf8 statement).

Suggested fix:
None.

Work around: don't rely on automatic conversions when using a UTF database, do conversions explicitly (e.g. in server's client code).
[20 Oct 2004 12:42] MySQL Verification Team
I was able to repeat it only on Windows.
Works fine on Linux.
[26 Oct 2004 10:04] Victor Vagin
ChangeSet
  1.2046 04/10/26 17:45:46 vva@eagle.mysql.r18.ru +1 -0
  file sql/field.cc:
  changed field_length -> char_len
  in Field_str::store(double) 
  fixed 
  Bug #6175 "server crash on insert of number into VARCHAR in UTF8 database"
[21 Mar 2005 22:18] Jim Winstead
I wasn't able to repeat this with 4.1.11 (compiled from pre-release source), and I believe this may have already been fixed by other changes. The mysqltest script I used to confirm was:

# Bug #6175: server crash on insert of number into VARCHAR in utf8 database
create database mysqltest_1 character set utf8;
use mysqltest_1;
create table t1 (str varchar(250) binary default null);
show create table t1;
insert into t1 (str) values (9.8);

No crash, and the results are as expected. (I also tried with a shorter varchar field, and it had no trouble.)