|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesbatch-query-fix (last revision 2013-09-18 05:10 UTC by ken-phpbugs at norganna dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-09-18 05:47 UTC] ken-phpbugs at norganna dot com
[2013-09-19 00:41 UTC] ken-phpbugs at norganna dot com
[2016-10-15 23:18 UTC] kalle@php.net
-Status: Open
+Status: Wont fix
[2016-10-15 23:18 UTC] kalle@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 20:00:01 2025 UTC |
Description: ------------ When sending batch requests to the mssql server, the mssql result is having dbcancel() called prematurely on the handle (via the _free_mssql_result function). Because we are processing batches of the result set we need the query to stay open until we are finished fetching all the rows (not just the first batch). In a non-batch scenario, it is fine to cancel the query after the first batch is called, because all rows have been fetched. I have attached a patch, which "fixes" the problem, but probably not in the right way. I have no clue what the right way actually would be or what the repercussions of applying the patch are. It is meant for illustrative purposes only. Test script: --------------- <?php // Connect to MSSQL and select the database $link = mssql_connect('hostpath', 'user', 'pass'); mssql_select_db('db', $link); // Send a query to a table that has 12 rows print "Given a table with 12 rows:\n"; $result = mssql_query('SELECT * FROM tablename', $link, 5); do { while ($row = mssql_fetch_assoc($result)) { print "Row found\n"; } $remain = mssql_fetch_batch($res); print "Remainder $remain\n"; } while ($remain > 0); Expected result: ---------------- Given a table with 12 rows: Row found Row found Row found Row found Row found Remainder 5 Row found Row found Row found Row found Row found Remainder 2 Row found Row found Remainder 0 Actual result: -------------- Given a table with 12 rows: Row found Row found Row found Row found Row found Remainder 1 Row found Remainder 0