ID: 36402
User updated by: joh at deworks dot net
Reported By: joh at deworks dot net
Status: Open
Bug Type: PDO related
Operating System: Linux
PHP Version: 5CVS-2006-02-15 (snap)
New Comment:
Forgot to mention that I'm running MySQL 4.1.12
Previous Comments:
------------------------------------------------------------------------
[2006-02-15 15:02:29] joh at deworks dot net
Description:
------------
PDO_MYSQL prepared statement INSERTs either result in corrupt data or
SQLSTATE[HY000]: General error: 5 Out of memory (Needed 4261477896
bytes)
This works perfectly with PDO_SQLITE.
Reproduce code:
---------------
CREATE TABLE test (id INT PRIMARY KEY AUTO_INCREMENT, col1
VARCHAR(255), col2 VARCHAR(255), col3 VARCHAR(255), col4 VARCHAR(255),
col5 VARCHAR(255));
$dbh = new PDO('mysql:host=localhost;dbname=...', '...', '...');
$sql = 'INSERT INTO test(col1, col2, col3, col4, col5) VALUES(:col1,
:col2, :col3, :col4, :col5)';
$stmt = DB::$dbh->prepare($sql);
$col1 = 'TestCol1';
$col2 = 'TestCol2';
$col3 = 'TestCol3';
$col4 = 'TestCol4';
$col5 = 'TestCol5';
$stmt->bindParam(':col1', $col1);
$stmt->bindParam(':col2', $col2);
$stmt->bindParam(':col3', $col3);
$stmt->bindParam(':col4', $col4);
$stmt->bindParam(':col5', $col5);
$stmt->execute();
Expected result:
----------------
No outupt, mysql table test contains rows according to the query.
Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server
during query' in file.php:125
Stack trace:
#0 file.php(125): PDOStatement->execute()
#1 {main}
thrown in file.php on line 125
Decreasing the number of parameters to 4 (col1, col2, col3, col4)
results in:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 5 Out of memory (Needed 4261477896
bytes)' in file.php:141
Stack trace:
#0 file.php(141): PDOStatement->execute()
#1 {main}
thrown in file.php on line 141
Decreasing the number of parameters to 3 or less (here: col1, col2,
col3) results in a successfull query, but corrupt inserted data:
mysql> SELECT * FROM test;
+----+------+------+------+------+------+
| id | col1 | col2 | col3 | col4 | col5 |
+----+------+------+------+------+------+
| 2 | | \uffff | | NULL | NULL |
+----+------+------+------+------+------+
1 row in set (0.00 sec)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36402&edit=1