Bug #79163 [Opn]: SQL SELECT EXISTS fills up memory
| From: | cmb@php.net | Date: | Fri, 24 Jan 2020 09:47:04 +0000 |
| Subject: | Bug #79163 [Opn]: SQL SELECT EXISTS fills up memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225086@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79163&edit=1
ID: 79163
Updated by: cmb@php.net
Reported by: kinimodmeyer at gmail dot com
Summary: SQL SELECT EXISTS fills up memory
Status: Open
Type: Bug
Package: MySQLi related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I cannot reproduce with PHP 7.4.3-dev using mysqlnd.
Previous Comments:
------------------------------------------------------------------------
[2020-01-24 09:06:18] kinimodmeyer at gmail dot com
Description:
------------
SELECT EXISTS in the query fills up the memory. see test-script below.
Test script:
---------------
<?php
$start = microtime(true);
var_dump(memory_get_usage(true));
for ($i = 0;$i<100000;$i++) {
$sql = 'SELECT 1
FROM
article
WHERE a_nr =
"'.$mysqli->real_escape_string(bin2hex(random_bytes(10))).'"
LIMIT 1';
$mysqli->query($sql);
}
var_dump(microtime(true) - $start, memory_get_usage(true));
$start = microtime(true);
for ($i = 0;$i<100000;$i++) {
$sql = 'SELECT EXISTS
(
SELECT 1
FROM article
WHERE a_nr =
"'.$mysqli->real_escape_string(bin2hex(random_bytes(10))).'"
LIMIT 1
)';
$mysqli->query($sql);
}
var_dump(microtime(true) - $start, memory_get_usage(true));
Expected result:
----------------
memory1: int(4194304)
memory2: int(4194304)
momory3: int(28311552)
Actual result:
--------------
php memory fills up in the second query
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79163&edit=1