php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32106 Error in handling UTF-8 on INSERT
Submitted: 2005-02-25 12:23 UTC Modified: 2005-02-25 14:25 UTC
From: vdmfun at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.0.2 OS: Windows 2003 Server
Private report: No CVE-ID: None
 [2005-02-25 12:23 UTC] vdmfun at hotmail dot com
Description:
------------
Sometimes the UTF-8 string is not INSERTed into MySQL correctly, but truncated. The query takes 40 seconds at 100% CPU load while the windoze is frozen (it feels like some execution thread has elevated thread priority and goes on full throttle).

It seems only a bit like:
http://bugs.mysql.com/bug.php?id=6527
but there is no 0x0401 and solution on that page provided by "[15 Nov 2004 6:47pm] Alexander Valyalkin" doesn't work.

More info's with syntax highlight:

http://vdm.no-ip.org/40seconds_bug/

Reproduce code:
---------------
<?php
$db_host="localhost";
$db_user="test";
$db_password="";

$cn=mysql_connect($db_host,$db_user,$db_password);
$sql="SET NAMES 'utf8'";
$rs=mysql_db_query("test",$sql,$cn);

$sql="DROP TABLE IF EXISTS sentences";
$rs=mysql_db_query("test",$sql,$cn);

$sql="CREATE TABLE sentences (id INT UNSIGNED NOT NULL AUTO_INCREMENT, sentence_id INT NOT NULL, lang_code VARCHAR(10) NOT NULL, text_id INT UNSIGNED NOT NULL, sentence LONGTEXT, PRIMARY KEY (id), KEY(sentence_id, lang_code, text_id), FULLTEXT(sentence)) ENGINE=MYISAM CHARACTER SET utf8;";
$rs=mysql_db_query("test",$sql,$cn);

$sentence_id=1;
$lang_code="sk";
$text_id=1;
$sentence="Ako nie".chr(0xA6).chr(0x8F)."o robi+".chr(0xB9)." slovami";
$sql="INSERT INTO sentences VALUES(NULL,\"$sentence_id\",\"$lang_code\",\"$text_id\",_utf8'".addslashes($sentence)."')";
echo "SQL Query: ".$sql."\n";
$now=time();
$rs=mysql_db_query("test",$sql,$cn);
echo "Query took strange ".(time()-$now)." seconds...\n";
?>

Expected result:
----------------
Expected result:

To INSERT this string:

Ako nie?&#377;o robi+&#261; slovami

(not truncated one) and not to take 40 seconds of execution of query.

Actual result:
--------------
Actual result:

String in table is truncated, dump od phpMyAdmin (abridged):

-- 
-- Dumping data for table `sentences`
-- 

INSERT INTO `sentences` VALUES (1, 1, 'sk', 1, 'Ako nie');

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-25 13:32 UTC] vdmfun at hotmail dot com
Hello me again.

Upgrade of MySQL from 4.1.7 -> latest 4.1.10 solved the problem. Ouch, but those headaches...

Please, close this topic.

Thanx.

Have a nice code :-)
 [2005-02-25 14:25 UTC] sniper@php.net
Mysql bug -> bogus.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Aug 14 08:01:27 2024 UTC