#23682 [Fbk->Opn]: sybase_query and multiple result sets: not returning first row set
| From: | uk at dataway dot ch | Date: | Sun, 18 May 2003 16:55:57 +0000 |
| Subject: | #23682 [Fbk->Opn]: sybase_query and multiple result sets: not returning first row set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-39889@lists.php.net to get a copy of this message | ||
ID: 23682
User updated by: uk at dataway dot ch
Reported By: uk at dataway dot ch
-Status: Feedback
+Status: Open
Bug Type: Sybase-ct (ctlib) related
Operating System: Linux 2.4.20
PHP Version: 4.3.2RC2
New Comment:
Here (with a slight correction, CS_STATUS_RESULT
doesn't return a result set)
--- ext/sybase_ct/php_sybase_ct.c.orig Sun May 18 17:49:26 2003
+++ ext/sybase_ct/php_sybase_ct.c Sun May 18 18:37:11 2003
@@ -1386,8 +1386,22 @@
case CS_CURSOR_RESULT:
case CS_PARAM_RESULT:
case CS_ROW_RESULT:
- /* Unexpected results, cancel them. */
+ if (status != Q_RESULT) {
+ result = php_sybase_fetch_result_set(sybase_ptr, buffered,
store);
+ if (result == NULL) {
+ ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
+ sybase_ptr->dead = 1;
+ RETURN_FALSE;
+ }
+ status = Q_RESULT;
+ }
+ else {
+ /* Unexpected results, cancel them. */
+ ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
+ }
+ break;
case CS_STATUS_RESULT:
+ /* Unexpected results, cancel them. */
ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
break;
Previous Comments:
------------------------------------------------------------------------
[2003-05-18 11:44:29] sniper@php.net
Provide that patch in unified form (diff -u).
------------------------------------------------------------------------
[2003-05-18 11:26:12] uk at dataway dot ch
Between php 4.3.0 and php 4.3.2RC2, the behaviour of sybase_query was
changed; now, it only looks at the very first result from the server,
whereas before it returned the first result set which contained any
data.
<p>
I know that similar issues have come up before, and that you comment in
the source code that applications shouldn't be doing stuff that returns
multiple result sets. The problem is that we have many stored
procedures which, although they only return one *data* result set
(CS_ROW_RESULT), this is preceded by several dummy results
(CS_CMD_SUCCEED or CS_CMD_DONE) due to other commands in the stored
procedure.
<p>
I would like to submit that the correct behaviour is in fact the one
exhibited by php 4.3.0: if several result sets are returned from the
server, then sybase_query should return the first one which actually
contains data.
I urge you to consider this, as I can't imagine anyone being more
interested in a CS_CMD_DONE than in a following CS_ROW_RESULT.
<p>
Anyway this is the patch I used to get everything working again:
<p>
<pre>
*** php_sybase_ct.c.orig Sun May 18 17:49:26 2003
--- php_sybase_ct.c Sun May 18 17:58:02 2003
***************
*** 1386,1394 ****
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:
--- 1386,1405 ----
case CS_CURSOR_RESULT:
case CS_PARAM_RESULT:
case CS_ROW_RESULT:
case CS_STATUS_RESULT:
! if (status != Q_RESULT) {
! result = php_sybase_fetch_result_set(sybase_ptr, buffered,
store);
! if (result == NULL) {
! ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
! sybase_ptr->dead = 1;
! RETURN_FALSE;
! }
! status = Q_RESULT;
! }
! else {
! /* Unexpected results, cancel them. */
! ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
! }
break;
default:
</pre>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23682&edit=1