#11475 [Opn->Fbk]: stored procedure processing
| From: | iliaa@php.net | Date: | Fri, 11 Oct 2002 04:03:50 +0000 |
| Subject: | #11475 [Opn->Fbk]: stored procedure processing | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-22135@lists.php.net to get a copy of this message | ||
ID: 11475
Updated by: iliaa@php.net
Reported By: dean.bennett@home.com
-Status: Open
+Status: Feedback
Bug Type: Sybase-ct (ctlib) related
Operating System: All
PHP Version: 4.0 Latest CVS (2001-06-13)
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2001-06-13 18:22:09] dean.bennett@home.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) {
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11475&edit=1