#23682 [NEW]: sybase_query and multiple result sets: not returning first row set

From: Date: Sun, 18 May 2003 16:26:12 +0000
Subject: #23682 [NEW]: sybase_query and multiple result sets: not returning first row set
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39880@lists.php.net to get a copy of this message
From:             uk at dataway dot ch
Operating system: Linux 2.4.20
PHP version:      4.3.2RC2
PHP Bug Type:     Sybase-ct (ctlib) related
Bug description:  sybase_query and multiple result sets: not returning first row set

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 bug report at http://bugs.php.net/?id=23682&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=23682&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=23682&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=23682&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=23682&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=23682&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=23682&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=23682&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=23682&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=23682&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=23682&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23682&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=23682&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=23682&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=23682&r=gnused



Thread (8 messages)

« previous php.bugs (#39880) next »