Bug #70869 [Opn]: mssql_fetch_batch tries to allocate 4GB memory

From: Date: Tue, 10 Nov 2015 09:13:53 +0000
Subject: Bug #70869 [Opn]: mssql_fetch_batch tries to allocate 4GB memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197151@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70869&edit=1

 ID:                 70869
 User updated by:    m dot subotovic at gmail dot com
 Reported by:        m dot subotovic at gmail dot com
 Summary:            mssql_fetch_batch tries to allocate 4GB memory
 Status:             Open
 Type:               Bug
 Package:            MSSQL related
 Operating System:   Linux
 PHP Version:        5.4.45
 Block user comment: N
 Private report:     N

 New Comment:

Yes, I have read this comment.
I use two different connections, not the same.

I use Microsoft SQL Server 2008 R2 (SP1) Standard Edition (64-bit) on Windows NT 6.1


Previous Comments:
------------------------------------------------------------------------
[2015-11-07 16:46:13] marcosptf at yahoo dot com dot br

have you read this comment on php doc?

http://php.net/manual/en/function.mssql-fetch-batch.php#111642

what version of sql server do you use?

Thanks

marcosptf
:D

------------------------------------------------------------------------
[2015-11-06 09:51:12] m dot subotovic at gmail dot com

Description:
------------
Fatal error: Allowed memory size of X bytes exhausted (tried to allocate 4294967296 bytes)

The error above is being shown when using mssql_fetch_batch on two different connections. Look at
the test script example.

Test script:
---------------
<?php

function fetchAssoc($link)
{
    $res = mssql_fetch_assoc($link);

    if ($res === false) {
        if (mssql_fetch_batch($link) > 0) {
            $res = mssql_fetch_assoc($link);
        }
    }
    return $res;
}

$link1 = mssql_connect('host', 'user', 'pwd');
mssql_select_db('db', $link1);

$link2 = mssql_connect('host', 'user', 'pwd');
mssql_select_db('db', $link2);

$result1 = mssql_query("SELECT TOP 2 * FROM table", $link1, 1);

while ($row1 = fetchAssoc($result1)) {
    echo "Row from 1 result\n";

    $result2 = mssql_query("SELECT TOP 2 * FROM table2", $link2);
    while ($row2 = fetchAssoc($result2)) {
        echo "Row from 2 result\n";
    }
}

echo "Done";

Expected result:
----------------
Row from 1 result
Row from 2 result
Row from 2 result
Row from 1 result
Row from 2 result
Row from 2 result
Done

Actual result:
--------------
Row from 1 result
Row from 2 result
Row from 2 result

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate 4294967296 bytes)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70869&edit=1


Thread (4 messages)

« previous php.bugs (#197151) next »