php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63498 Wrong order of options in sqlsrv_query can throw "Invalid cursor state" error
Submitted: 2012-11-12 19:26 UTC Modified: 2012-11-12 21:33 UTC
From: oleg at mastak dot fi Assigned:
Status: Open Package: sqlsrv (PECL)
PHP Version: 5.4.8 OS: Windows 7
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-11-12 19:26 UTC] oleg at mastak dot fi
Description:
------------
In sqlsrv_query function, fourth parameter is array that can contain following three options with corresponding keys :  QueryTimeout, SendStreamParamsAtExec	, Scrollable

You would assume that you can specify options in any order, however, this is not true.

If you run following script, you will hit unspecified error "[Microsoft][ODBC Driver Manager] Invalid cursor state"

However, if you change order to:
$config = array(
    'Scrollable'    => SQLSRV_CURSOR_KEYSET,
    'QueryTimeout'  => 2,
);

then everything works OK.

As this is illogical, I think this is bug and should be fixed.


Test script:
---------------
$link = sqlsrv_connect ( 'serverName\sqlexpress', $connectionInfo );

$config = array(
    'QueryTimeout'  => 2,
    'Scrollable'    => SQLSRV_CURSOR_KEYSET,
);

$query  = "CREATE TABLE #MY_TABLE([var1] [bigint] NOT NULL);";
$result = sqlsrv_query($link,$query,array(),$config) or die("ERROR ". print_r(sqlsrv_errors(),true));


Expected result:
----------------
OK

Actual result:
--------------
ERROR Array ( [0] => Array ( [0] => 24000 [SQLSTATE] => 24000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Invalid cursor state [message] => [Microsoft][ODBC Driver Manager] Invalid cursor state ) )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-12 21:11 UTC] pajoye@php.net
-Package: MSSQL related +Package: sqlsrv
 [2012-11-12 21:11 UTC] pajoye@php.net
Assigned to the right extension
 [2012-11-12 21:33 UTC] jkint@php.net
Thanks for reporting this.  We will look into it.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 12:01:52 2014 UTC