Bug #76732 [NEW]: Unable to fetch text and varchar(max) when procedure returns more result sets
| From: | honza dot hink at gmail dot com | Date: | Sun, 12 Aug 2018 13:22:08 +0000 |
| Subject: | Bug #76732 [NEW]: Unable to fetch text and varchar(max) when procedure returns more result sets | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216733@lists.php.net to get a copy of this message | ||
From: honza dot hink at gmail dot com
Operating system: Windows 10
PHP version: 7.2.8
Package: MSSQL related
Bug Type: Bug
Bug description:Unable to fetch text and varchar(max) when procedure returns more result sets
Description:
------------
odbc_fetch_array() reports error: SQL error: [Microsoft][SQL Server
Native Client 11.0]Invalid Descriptor Index, SQL state S1002 in
SQLGetData in ...
It is related to Bug #73725, that has been partially solved, but it
remains by this circumstances:
This error occurs on reading result with two conditions at the same
time.
First condition:
- SQL syntax contains more than one command (select or execute)
OR
- SQL command contains anything extra, f.e. "set nocount on execute
..."
OR
- SQL command contains any comment, f.e. "/* any comment */ select ..."
OR
- SQL command calls a procedure that returns more than one result
Second condition:
- one of sql results contains column type text or not empty
varchar(max)
If one condition is not true, then it works OK.
There are differences between drivers "SQL Server" and "SQL Server
Native Client". One doesn't like text type if it is not the last column,
another driver doesn't like not empty varchar(max).
My example contains both features, so it gives an error regardless used
driver.
Test script:
---------------
<?php
header("Content-Type: text/html; charset=utf-8");
$con=odbc_connect("Local64bit","any_user","his_pwd");
$res1=odbc_do($con,"create procedure #p as
select convert(text,'text 1') converted_to_text, 1 i,
convert(varchar(max),'text 1') converted_to_varchar_max
select convert(text,'text 2') converted_to_text, 1 i,
convert(varchar(max),'text 2') converted_to_varchar_max
");
$res2=odbc_do($con,"execute #p");
while($r=odbc_fetch_array($res2))
print_r($r);
?>
Expected result:
----------------
Array
(
[converted_to_text] => text 1
[i] => 1
[converted_to_varchar_max] => text 1
)
Actual result:
--------------
<br />
<b>Warning</b>: odbc_fetch_array(): SQL error: [Microsoft][SQL Server
Native Client 11.0]Invalid Descriptor Index, SQL state S1002 in
SQLGetData in <b>F:\EclipseWorkspaces\Ramses\www\pokus.php</b> on line
<b>9</b><br />
--
Edit bug report at https://bugs.php.net/bug.php?id=76732&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76732&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76732&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76732&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76732&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76732&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76732&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76732&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76732&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76732&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76732&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76732&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76732&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76732&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76732&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76732&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76732&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76732&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76732&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76732&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76732&r=mysqlcfg