php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75201 0-column rowsets not identified
Submitted: 2017-09-13 08:22 UTC Modified: 2017-10-06 09:17 UTC
From: fandrieu at gmail dot com Assigned:
Status: Not a bug Package: PDO DBlib
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 9 = ?
Subscribe to this entry?

 
 [2017-09-13 08:22 UTC] fandrieu at gmail dot com
Description:
------------
This is a follow up to the bug #69592 about skipping 0-column rowsets

I've been using the suggested "if ($statement->columnCount())" workaround to avoid this problem, but it doesn't work after a non empty rowset: columnCount is not set correctly and reports the column count of the previous rowset.

Test script:
---------------
$pdo = new PDO("dblib:host=<host>;dbname=<dbname>", "username", "password");

$stmt = $pdo->query("
	SET NOCOUNT ON

	SELECT 1

	SET NOCOUNT ON

	SELECT 1
");

do
{
	echo "columns: " . $stmt->columnCount() . "\n";
	print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
}
while ($stmt->nextRowset());

Expected result:
----------------
[with bug #69592]

columns: 0
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)
columns: 0
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)


Actual result:
--------------
columns: 0
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)
columns: 1
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-05 20:31 UTC] adambaratz@php.net
-Status: Open +Status: Not a bug
 [2017-10-05 20:31 UTC] adambaratz@php.net
I was able to reproduce this issue. But stepping through the example in gdb, I didn't see pdo_dblib doing anything wrong. When it calls dbnumcols() in pdo_dblib_stmt_next_rowset_no_cancel(), it simply gets the unexpected value back. I don't think this is a strange MSSQL nuance. My guess is that it's an issue with FreeTDS.

I'd suggest filing an issue with that team:
https://github.com/FreeTDS/freetds/issues

If you don't get feedback, try reaching out on their mail list:
https://lists.ibiblio.org/mailman/listinfo/freetds

Hope this helps!
 [2017-10-06 09:17 UTC] fandrieu at gmail dot com
Thanks for taking the time to investigate this.

Actually the underlying issue to #69592 has just been reported to FreeTDS github: https://github.com/FreeTDS/freetds/issues/156
 [2017-10-10 08:29 UTC] fandrieu at gmail dot com
This particular issue has just been fixed upstream:
https://github.com/FreeTDS/freetds/commit/965a3a9a67373e3159c86ec26cc17a5e72b4eb0f

Bug #69592 is still present but now we get the expected result here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC