#32106 [Opn->Bgs]: Error in handling UTF-8 on INSERT
| From: | sniper@php.net | Date: | Fri, 25 Feb 2005 13:25:38 +0000 |
| Subject: | #32106 [Opn->Bgs]: Error in handling UTF-8 on INSERT | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74565@lists.php.net to get a copy of this message | ||
ID: 32106
Updated by: sniper@php.net
Reported By: vdmfun at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: Windows 2003 Server
PHP Version: 5.0.2
New Comment:
Mysql bug -> bogus.
Previous Comments:
------------------------------------------------------------------------
[2005-02-25 13:32:43] 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 12:23:35] 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¦Źo robi+ą 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');
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32106&edit=1