|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: msisolak at yahoo dot com
New email:
PHP Version: OS:


 [2004-12-16 21:26 UTC] msisolak at yahoo dot com
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 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) {
+	}
 	if ((num_fields = dbnumcols(mssql_ptr->link)) <= 0) {

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:


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


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-16 22:50 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Jul 03 18:03:33 2022 UTC