|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-17 19:32 UTC] mhe at ltcgroup dot de
Description: ------------ submit a prepared query to mysqli ext using method prepare(). if i use bind_result to bind a column to a variable php crashes with fatal error: memory limit, if the column in database is mediumtext. if you alter this to text, everything works fine. using mysqld 4.1.10 --output: php5 -v micronium:~/phpn# php5 -v PHP 5.0.3-1.dotdeb.0 (cli) (built: Dec 16 2004 13:08:20) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies -- mysql: CREATE TABLE tt ( ID_ITEM INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, TITLE VARCHAR(255) NULL, DESCRIPTION MEDIUMTEXT NULL, PRIMARY KEY(ID_ITEM) ); -- php: $query = " select DESCRIPTION from tt "; $stmt = $db->prepare($query); $stmt->execute(); $stmt->bind_result($DESCRIPTION); //-- this is line 63 -- output: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16777216 bytes) in /root/phpn/run.php on line 63 Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes) -- mysql: ALTER TABLE `tt` CHANGE `DESCRIPTION` `DESCRIPTION` TEXT -- php: $query = " select DESCRIPTION from tt "; $stmt = $db->prepare($query); $stmt->execute(); $stmt->bind_result($ID_ITEM); //-- this is line 63 -- output: ::: everything is ok, no crahs, can go on Reproduce code: --------------- try to bind a MEDIUM text column to a variable, and php will crash .. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
i wasnt able to test this under debian woody, but i downloaded the windows latest snapshot. now the memory limit is reached using fetch(), I added a "normal" query, so that you see, that the select using mysqli is possible on mediumtext, :: $query = " select DESCRIPTION, DESCRIPTION AS DD from tt order by ID_ITEM "; echo "init " . getMemUsage() . "\n"; $result = $db->query($query); echo "query " . getMemUsage() . "\n"; while($row = $result->fetch_assoc()) { echo " fetch " . getMemUsage() . "\n"; } $stmt = $db->prepare($query); echo "prepare " . getMemUsage() . "\n"; $stmt->execute(); echo " exec " . getMemUsage() . "\n"; $stmt->bind_result($DESCRIPTION, $DD); echo " bind " . getMemUsage() . "\n"; $stmt->fetch(); echo " fetch " . getMemUsage() . "\n"; $stmt->fetch(); echo " fetch " . getMemUsage() . "\n"; :: using function getMemUsage() from http://php.net/memory_get_usage these are the results: debain woody 5.0.3: init 48744 query 48864 fetch 49120 fetch 49296 prepare 49392 exec 49392 Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16777216 bytes) in /root/mysqli_prepared.php on line 73 Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes) line 73 ~ bind_result(), this is how 5.0.3 currently works, :: these are the results, using version "latest win32: (increased memory limit, for testing) init 7.772 K query 7.812 K fetch 7.812 K fetch 7.812 K prepare 7.824 K exec 7.832 K bind 7.844 K fetch 40.672 K fetch 40.672 K you can see, that the memory usage explode after the first fetch(), bin_result() seems to work. :: there were 2 items in database, DROP TABLE tt; CREATE TABLE tt ( ID_ITEM INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, TITLE VARCHAR(255) NULL, DESCRIPTION MEDIUMTEXT NULL, PRIMARY KEY(ID_ITEM) ); INSERT INTO tt (ID_ITEM, TITLE, DESCRIPTION) VALUES (1, 'fghfjkgfd', 'first description'); INSERT INTO tt (ID_ITEM, TITLE, DESCRIPTION) VALUES (2, 'second', 'second description'); ::