Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002676 [Quercus] minor always 05-19-08 08:06 05-29-08 16:38
Reporter ferg View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.2.0 Product Version 3.1.6
  Product Build
Summary 0002676: mysql multibyte character-set problem
Description (rep by wesley)

PHP function mysql_query & mysql_fetch_xxxxx cannot handle myltibyte column data.

I've test for resin version 3.1.5/3.1.6 and 3.2.0 snapshot, also mysql 4.1.22/5.0.51b/5.1.23rc/6.0.4/alpha as well as mysql-connector-java-3.1.14/5.1.x.
This issue can be reproduced in every combination.

Test case:
============test.php============
<?PHP

//$db = mysql_connect("java:comp/env/jdbc/discuz"); // not ok either
$db = mysqli_connect('127.0.0.1', 'root', 'password', 'test');
mysqli_query($db, 'SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary;');
$query = mysqli_query($db, 'SELECT * FROM test');
while($test = mysqli_fetch_assoc($query)) {
echo $test['name']."\n";
}

$db = mysql_connect('localhost', 'root', 'password');
mysql_query('SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary;', $db);
mysql_select_db('test', $db);
$query = mysql_query('SELECT * FROM test', $db);
while($test = mysql_fetch_array($query, MYSQL_ASSOC)) {
echo $test['name']."\n";
}
?>
=================================

Output should be:
&20320;&22909;
&25105;&22909;
&20320;&22909;
&25105;&22909;


Output now was:
`}
}
`}
}

=============resin-web.xml===========
<web-app xmlns="http://caucho.com/ns/resin"> [^]
<database>
<jndi-name>jdbc/discuz</jndi-name>
<driver type="com.mysql.jdbc.Driver">
 <url>jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8</url> [^]
 <!-- not ok either
 <url>jdbc:mysql://localhost:3306/test</url> [^]
 -->
 <user>root</user>
 <password>password</password>
 <init-param characterEncoding="UTF-8" />
 <init-param useUnicode="true" />
</driver>
<max-connections>200</max-connections>
</database>

<servlet-mapping url-pattern="*.php"
                servlet-class="com.caucho.quercus.servlet.QuercusServlet">
<init>
 <database>java:comp/env/jdbc/discuz</database>
 <script-encoding>UTF-8</script-encoding>
 <compile>false</compile>
 <php-ini>
  <unicode.runtime_encoding>UTF-8</unicode.runtime_encoding>
  <unicode.output_encoding>UTF-8</unicode.output_encoding>
 </php-ini>
</init>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.php</welcome-file>
</welcome-file-list>
</web-app>
=================================


============mysql db script===========
-- MySQL dump 10.13 Distrib 5.1.24-rc, for Win32 (ia32)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.1.24-rc-community

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `test`
--

DROP TABLE IF EXISTS `test`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `test` (
`name` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `test`
--

LOCK TABLES `test` WRITE;
/*!40000 ALTER TABLE `test` DISABLE KEYS */;
INSERT INTO `test` VALUES (0xe4bda0e5a5bd);
INSERT INTO `test` VALUES (0xe68891e5a5bd);
/*!40000 ALTER TABLE `test` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

Steps To Reproduce
Additional Information
Attached Files

- Relationships

- Notes
(0003117)
ferg
05-29-08 16:38

php/1463
 

- Issue History
Date Modified Username Field Change
05-19-08 08:06 ferg New Issue
05-29-08 16:38 ferg Note Added: 0003117
05-29-08 16:38 ferg Assigned To  => ferg
05-29-08 16:38 ferg Status new => closed
05-29-08 16:38 ferg Resolution open => fixed
05-29-08 16:38 ferg Fixed in Version  => 3.2.0


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
31 total queries executed.
28 unique queries executed.
Powered by Mantis Bugtracker