php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31135 Executing stored procedure with no result set returns incorrect FALSE response
Submitted: 2004-12-16 21:26 UTC Modified: 2004-12-16 22:50 UTC
From: msisolak at yahoo dot com Assigned: fmk (profile)
Status: Closed Package: MSSQL related
PHP Version: 5.0.3 OS: Windows 2000
Private report: No CVE-ID: None
 [2004-12-16 21:26 UTC] msisolak at yahoo dot com
Description:
------------
As of PHP 5.0.3 calling a SQL Server stored procedure that returns no result set incorrectly returns FALSE (to indicate an error condition) when it should return TRUE.

I believe the problem was introduced with patch 1.137.2.3 to ext/mssql/php_mssql.c with this change:

@@ -1184,6 +1196,9 @@ PHP_FUNCTION(mssql_query)
 	while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue == SUCCEED) {
 		retvalue = dbresults(mssql_ptr->link);
 	}
+	if (retvalue != SUCCEED) {
+		RETURN_FALSE;
+	}
 	if ((num_fields = dbnumcols(mssql_ptr->link)) <= 0) {
 		RETURN_TRUE;
 	}

In the case of a stored procedure that returns no result set retvalue == NO_MORE_RESULTS.  This change now equates NO_MORE_RESULTS with a FALSE result, but that is incorrect.  It should return TRUE as it does in PHP 5.0.2 to indicate a successful execution.

Reproduce code:
---------------
- Create an empty stored procedure.

- Reproduce code:

<?php

$link = mssql_connect("localhost", "sa", "<<password>>");
mssql_select_db("<<database>>", $link);
echo mssql_query("EXEC <<storedproc>>") ? "true" : "false";
mssql_close($link);

?>

Expected result:
----------------
true

Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-16 22:50 UTC] fmk@php.net
This bug has been fixed in CVS.

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-2022 The PHP Group
All rights reserved.
Last updated: Wed May 18 17:05:45 2022 UTC