php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9272 odbc_close issues warning on persistent connection (includes patch)
Submitted: 2001-02-15 05:35 UTC Modified: 2001-03-27 09:22 UTC
From: marc at guidance dot nl Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.4pl1 OS: WinNT4sp6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marc at guidance dot nl
New email:
PHP Version: OS:

 

 [2001-02-15 05:35 UTC] marc at guidance dot nl
If I open a persistent odbc connection and close it later I
get a warning even though the function works correctly.

The following script reproduces this:
  $odbchandle = odbc_pconnect($dbname, "", "");
  echo odbc_tables($odbchandle) . "<br>";
  echo odbc_close($odbchandle) . "<br>";
result:
  Warning: Supplied resource is not a valid ODBC-Link
  resource in f:\home\dbx\html\dbx.php on line XXX

If I use odbc_connect in the same script it all works ok.

In the odbc source code I traced this to the following lines from php_odbc.c, in PHP_FUNCTION(odbc_close):

  conn = (odbc_connection *) zend_fetch_resource(pv_conn,
         -1, "ODBC-Link", NULL, 1, le_conn);
  if(!conn){
    ZEND_FETCH_RESOURCE(conn, odbc_connection *, pv_conn,
         -1, "ODBC-Link", le_pconn);
    is_pconn = 1;
  }

As you can see the first line will issue the warning, and if it fails it detects that it might be a persistent connection and continues correctly.

A replacement patch for these lines might be

  int found_resource_type = le_conn;
  conn = (odbc_connection *) zend_fetch_resource(pv_conn,
         -1, "ODBC-Link", &found_resource_type, 
         2, le_conn, le_pconn);
  if (found_resource_type==le_pconn) {
    is_pconn = 1;
  }

but I don't know how to submit a patch/diff so here it is.

Cheerio, Marc.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-27 09:22 UTC] kalowsky@php.net
patch applied... 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Mar 03 13:01:29 2025 UTC