From:             joh at deworks dot net
Operating system: Linux
PHP version:      5CVS-2006-02-15 (snap)
PHP Bug Type:     PDO related
Bug description:  PDO_MYSQL prepared statements cause Out of memory or data 
corruption

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

Reply via email to