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: freetds AT franklin.oit.unc.edu
  • Subject: Re: PHP crash on 2nd Select
  • Date: Mon, 16 Jul 2001 14:14:16 -0400



This is either a bug in PHP or simply unsupported behaviour. odbc_execute
makes a call to SQLFreeStmt() before attempting to execute the new
statement, however odbc_exec does not. A workaround is to add this code
(from odbc_execute)

/* Close cursor, needed for doing multiple selects */
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);

if (rc == SQL_ERROR) {
odbc_sql_error(result->conn_ptr, result->stmt,
"SQLFreeStmt");
}

just above the call to SQLExecDirect() in ext/odbc/php_odbc.c

I'll submit a bug and patch to the PHP folks, but I'm not sure this is
really something that is supposed work or not.

Brian

> 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