From:             vdmfun at hotmail dot com
Operating system: Windows 2003 Server
PHP version:      5.0.2
PHP Bug Type:     MySQL related
Bug description:  Error in handling UTF-8 on INSERT

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');

-- 
Edit bug report at http://bugs.php.net/?id=32106&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32106&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32106&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32106&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32106&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32106&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32106&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32106&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32106&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32106&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32106&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32106&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32106&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32106&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32106&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32106&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32106&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32106&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32106&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32106&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32106&r=mysqlcfg

Reply via email to