php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51562 query timeout in mssql can not be changed per query
Submitted: 2010-04-15 15:57 UTC Modified: 2010-04-21 16:19 UTC
From: ejsmont dot artur at gmail dot com Assigned: felipe
Status: Closed Package: MSSQL related
PHP Version: 5.2.13 OS: linux debian lenny
Private report: No CVE-ID:
 [2010-04-15 15:57 UTC] ejsmont dot artur at gmail dot com
Description:
------------
im not sure if its a bug or missing functionality but i cant set query timeout per query. I want to be able to do ini_set('mssql.timeout', 6); before query to set its timeout to 6 seconds and then ini_set('mssql.timeout', 20); to set 20s timeout for following query.

This seems to be possible with patch i attach just one line needs to be added. but im not sure if this would not break anything (seems to work for me on lenny).



Test script:
---------------
        // connect
        $connection = mssql_connect($dbhost, $dbuser, $dbpass);
        mssql_select_db($dbname, $connection);

// does not have affect if called after connect
        ini_set('default_socket_timeout',   1);
        ini_set('mssql.connect_timeout',    1);
        ini_set('mssql.timeout',            3);
        
        // call sproc with results and no delay
        $start = microtime(true);
        $rid = mssql_query("exec timeout_test 0, 0, 'Y';");
        while ($rec = mssql_fetch_assoc($rid)) {
                $row[] = $rec;
        }        
        echo "=".print_r( $row, true )."= in ".(microtime(true)-$start)." with ".mssql_get_last_message()."\n";
        


Expected result:
----------------
i think it would be good if you could set query timeout at any time and it would affect the following queries (until you change the timeout value)

Actual result:
--------------
timeout set after connection is established does not have effect

Patches

mssql_timeout_per_query (last revision 2010-04-15 13:58 UTC) by ejsmont dot artur at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-21 16:19 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=298255
Log: - Fixed bug #51562 (query timeout in mssql can not be changed per query)
  Patch by: ejsmont dot artur at gmail dot com
 [2010-04-21 16:19 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-04-21 16:19 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 02:02:10 2014 UTC