Skip to Content.
Sympa Menu

freetds - Re: PHP crash on 2nd Select

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: PHP crash on 2nd Select
  • Date: Fri, 13 Jul 2001 19:22:31 -0400 (EDT)


Thanks Bob,

SQLCloseCursor is rigged in the DriverManager to call
SQLFreeStmt(). Anyway, after some digging, PHP appears not to call it
anyway, but instead calls SQLFreeStmt() with the SQL_CLOSE
option. FreeStmt() in turn issues a cancel on the previous query if the
state is TDS_PENDING and cleans up...So, logically it appears we already
do this but obviously something is not working.

Oh well, this is going to take more than the 5 minutes I have right now.

Brian

On Fri, 13 Jul 2001, Bob Kline wrote:

> On Fri, 13 Jul 2001, Brian Bruns wrote:
>
> > In the native APIs (dblib/ctlib) the appropriate behaviour in a case
> > like this is to generate an error (though obviously core dumping is
> > not the right response ;-) that is a bug). Anyway the client issues
> > an error like 'Attempt to initiate new query with results pending'.
> >
> > I'm assuming here that odbc isn't suppose to act this way. Can
> > anyone provide pointer to this from the ODBC documentation? But in
> > any event, fixing this is simple.
>
> This is a state transition error, for which the driver is supposed to
> return SQLSTATE 24000 (Invalid cursor state).
>
> See the "State Transitions" section of chapter 4: "If an application
> calls a function out of order, the function returns a state transition
> error."[1] See also Chapter 10: "Until the application closes the
> cursor, the statement on which the cursor is opened cannot be used for
> most other operations, such as executing another SQL statement."[2]
>
> When the application does close the cursor (SQLCloseCursor(hstmt)), the
> driver is responsible for doing whatever is necessary (e.g., discarding
> any unfetched results) to enable a new SQL statement to be executed
> using the statement handle.
>
> Also, take a look at the state transition tables in the appendices.[3]
> These tables specify the exact error return for each illegal state
> transition.
>
> [1]
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcstate_transitions.asp
> [2]
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcclosing_the_cursor.asp
> [3]
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_state_transition_tables.asp
>
>





Archive powered by MHonArc 2.6.24.

Top of Page