php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11475 stored procedure processing
Submitted: 2001-06-13 18:22 UTC Modified: 2002-10-26 01:00 UTC
Votes:13
Avg. Score:5.0 ± 0.0
Reproduced:13 of 13 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (15.4%)
From: dean dot bennett at home dot com Assigned:
Status: No Feedback Package: Sybase-ct (ctlib) related
PHP Version: 4.0 Latest CVS (2001-06-13) OS: All
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dean dot bennett at home dot com
New email:
PHP Version: OS:

 

 [2001-06-13 18:22 UTC] dean dot bennett at home dot com
We have some Sybase stored procedures that don't work with php - they return 1 instead of a result set.  Stepping through the code, I found that the proc was returning an empty status result before the real results, which confuses the php code that loops through the Sybase results, as it expects to see a result set first.

I've made the following change to that code (diff -u format)that processes all of the results, and doesn't treat a status result in the same way as a real result.

--- php_sybase_ct.c.orig	Mon Jun 11 17:17:22 2001
+++ php_sybase_ct.c	Mon Jun 11 17:17:31 2001
@@ -1079,36 +1079,32 @@
 		 * properly read or cancel them or the connection will become
 		 * unusable.
 		 */
-		if (ct_results(sybase_ptr->cmd, &restype)!=CS_SUCCEED) {
-			ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
-			sybase_ptr->dead = 1;
-			RETURN_FALSE;
-		}
+		while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
 
-		switch ((int) restype) {
+		    switch ((int) restype) {
 			case CS_CMD_FAIL:
 			default:
 				status = Q_FAILURE;
 				break;
 			case CS_CMD_SUCCEED:
 			case CS_CMD_DONE: {
-					CS_INT row_count;
-					if (ct_res_info(sybase_ptr->cmd, CS_ROW_COUNT, &row_count, CS_UNUSED, NULL)==CS_SUCCEED) {
-						sybase_ptr->affected_rows = (long)row_count;
-					}
+				CS_INT row_count;
+				if (ct_res_info(sybase_ptr->cmd, CS_ROW_COUNT, &row_count, CS_UNUSED, NULL)==CS_SUCCEED) {
+					sybase_ptr->affected_rows = (long)row_count;
 				}
+			}
 				/* Fall through */
 			case CS_COMPUTEFMT_RESULT:
 			case CS_ROWFMT_RESULT:
 			case CS_DESCRIBE_RESULT:
 			case CS_MSG_RESULT:
-				status = Q_SUCCESS;
+				if (status != Q_RESULT)	/* if we don't already have a result */
+					status = Q_SUCCESS;
 				break;
 			case CS_COMPUTE_RESULT:
 			case CS_CURSOR_RESULT:
 			case CS_PARAM_RESULT:
 			case CS_ROW_RESULT:
-			case CS_STATUS_RESULT:
 				result = php_sybase_fetch_result_set(sybase_ptr);
 				if (result == NULL) {
 					ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
@@ -1117,41 +1113,11 @@
 				}
 				status = Q_RESULT;
 				break;
-		}
-
-		/* The only restype we should get now is CS_CMD_DONE, possibly
-		 * followed by a CS_STATUS_RESULT/CS_CMD_SUCCEED/CS_CMD_DONE
-		 * sequence if the command was a stored procedure call.  But we
-		 * still need to read and discard unexpected results.  We might
-		 * want to return a failure in this case because the application
-		 * won't be getting all the results it asked for.
-		 */
-		while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
-			switch ((int) restype) {
-				case CS_CMD_SUCCEED:
-				case CS_CMD_DONE:
-					break;
-
-				case CS_CMD_FAIL:
-					status = Q_FAILURE;
-					break;
-			
-				case CS_COMPUTE_RESULT:
-				case CS_CURSOR_RESULT:
-				case CS_PARAM_RESULT:
-				case CS_ROW_RESULT:
-					/* Unexpected results, cancel them. */
-				case CS_STATUS_RESULT:
-					ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
-					break;
-			
-				default:
-					status = Q_FAILURE;
-					break;
-			}
-			if (status == Q_FAILURE) {
-				ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
-			}
+			/* nothing to read for STATUS_RESULT */
+			case CS_STATUS_RESULT:
+				ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
+				break;
+		    }
 		}
 
 		switch (retcode) {



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-10 23:03 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-10-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC