Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78665 invoked by uid 1010); 1 Dec 2003 02:19:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78641 invoked from network); 1 Dec 2003 02:19:42 -0000 Received: from unknown (HELO web13402.mail.yahoo.com) (216.136.175.60) by pb1.pair.com with SMTP; 1 Dec 2003 02:19:42 -0000 Message-ID: <20031201021941.69222.qmail@web13402.mail.yahoo.com> Received: from [24.215.130.244] by web13402.mail.yahoo.com via HTTP; Sun, 30 Nov 2003 18:19:41 PST Date: Sun, 30 Nov 2003 18:19:41 -0800 (PST) To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [FIX] Bug #25585: PHP crash if executed MSSQL-query with RAISERROR() call and error 515 From: msisolak@yahoo.com (Michael Sisolak) I believe the problem here is in how mssql_query handles result sets that have multiple results returned, but none with rows (such as in this bug where there are multiple commands executed and multiple errors returned). In the php_mssql.c for PHP 4.3.4 the block at line 1145 reads: while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue == SUCCEED) { retvalue = dbresults(mssql_ptr->link); } According to Microsoft (http://msdn.microsoft.com/library/en-us/dblibc/dbc_pdc04e_52sz.asp), however: "You must call dbresults until it returns NO_MORE_RESULTS, or any continued use of the DBPROCESS causes the DB-Library error 10038 'Results Pending'." As this code in php_mssql.c currently stands it stops looping the empty result sets too early becuase it's looking for SUCCEED instead of NO_MORE_RESULTS. Changing this code to: while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue != NO_MORE_RESULTS) { retvalue = dbresults(mssql_ptr->link); } causes both SQL Server error messages generated by the sample query in the bug report to be correctly displayed and eliminates the fault. Michael Sisolak msisolak@yahoo.com __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/