Skip to Content.
Sympa Menu

freetds - PHP: losing client/server sync after error (cvs, Sybase ASA)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: <lbayuk AT mindspring.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: PHP: losing client/server sync after error (cvs, Sybase ASA)
  • Date: Sat, 31 Aug 2002 20:21:03 -0400 (EDT)


This is a follow-on to my previous message about problems with error
handling in PHP-4.2.2 talking to a Sybase ASA 6 database using recent CVS
versions of FreeTDS. After an error is returned from a bad query (like
"INSERT INTO nosuchtable VALUES (1)"), the server and client are out of
step: the client sends a query, and sees the reply from the previous query.

The trouble seems to start with PHP calling ct_cancel() after an error
reply. I think something is missing in the protocol here. With
FreeTDS-0.53, I used to get "Unknown marker 0!!" in Apache's error log
after each DBMS error reply. But client and server stayed in sync. Later
revisions to FreeTDS seemed to fix that - no more Unknown marker messages,
but now I realize it probably wasn't fixed, just masked.

I think it is getting messed up in tds_process_cancel(). I added some more
tracing, and it thinks it is seeing a 0 byte (the same as FreeTDS 0.53),
but now it takes that as a Cancel and returns without getting the DONE
message. But the server isn't done, and still sends a DONE message. I
think that's what's going on, because the DONE message that FreeTDS thinks
belongs to the next query actually has the "cancelled" flag bit set.

I used a TCP socket tracing program to look more closely (because the TDS
dump file doesn't show this). I don't understand the reply from the server
to CANCEL. Here's the client sending CANCEL (type=06):
06 01 00 08 00 00 00 00
Here's the server reply:
0f 03 00 08 00 00 00 00
04 01 00 11 00 00 00 00 fd 20 00 01 00 00 00 00 00
The second reply line is a Response (04), Result Set DONE (fd) with Cancel
bit (20). But what the heck is that first reply line? tds_read_packet() is
returning 0 when it reads that, because no data follows the 8-byte header;
then tds_process_cancel() takes that 0 as the end of the cancel reply,
leaving the real DONE+Cancelled message unread until the next query.

I've tried this on 2 different ASA-6 servers (different minor versions and
platforms) and they both do it. What's going on?



  • PHP: losing client/server sync after error (cvs, Sybase ASA), lbayuk, 08/31/2002

Archive powered by MHonArc 2.6.24.

Top of Page