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 16:59:11 -0400 (EDT)



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.

in src/odbc/odbc.c at the head of _SQLExecute (prior to tds_submit_query)
add the following:

/* if previous query wasn't read, clean up after it */
if (tds->state==TS_PENDING)
do {
marker = tds_get_byte(tds);
tds_process_default_tokens(tds, marker);
} while (!is_hard_end_token(marker));

recompile and the script should work. I'm going to try to find out for
certain what the defined behaviour is, before I commit this change.

Cheers,

Brian

On Fri, 13 Jul 2001, Dale Kortum wrote:

> We have gathered more information about the problem. It appears that the
> second select will work if we odbc_result_all for the first select prior
> to the second select. The script that does not function is listed below.
> We think the problem may lie in token.c:tds_submit_query. The state field
> in the TDS structure indicates TDS_PENDING, which generates the error.
> The original crash was caused in log_error attempting to do a string copy
> from a NULL pointer (not a pointer to NULL). We changed the function to
> check for a NULL to get by this problem. But we still have the error
> condition on the 2nd select. Thanks for any assistance you can provide.
>
> <?
> print "here at connection\n";
> $odbcConnectID = odbc_connect("DSNname", "UID", "PWD");
> if (! $odbcConnectID) {
> print "<BR><BR>Cannot connect.<BR><BR>";
> print "<BR><BR>";
> exit;
> }
> $query = "select * from CallPage";
> $result = odbc_exec($odbcConnectID, $query);
> print "set 1\n";
> $query = "select * from Location";
> $result = odbc_exec($odbcConnectID, $query);
> print "set 2\n";
> $query = "SELECT * from CallPage";
> $result = odbc_exec($odbcConnectID, $query);
> print "set 3\n";
> exit;
> ?>





Archive powered by MHonArc 2.6.24.

Top of Page