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: 2020-02-07 14:51 UTC
Votes:5
Avg. Score:2.4 ± 0.8
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: oleg at mastak dot fi Assigned: cmb (profile)
Status: Closed Package: sqlsrv (PECL)
PHP Version: 5.4.8 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oleg at mastak dot fi
New email:
PHP Version: OS:

 

 [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

Pull Requests

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.
 [2020-02-07 14:51 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-02-07 14:51 UTC] cmb@php.net
If you still experience this issue, please file a bug report at
<https://github.com/Microsoft/msphpsql/issues>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC