[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#509240: libmdbodbc: can't close database connection



Package: libmdbodbc
Version: 0.5.99.0.6pre1.0.20051109-4
Severity: important
Tags: patch

When used with libmdbodbc, no unixODBC based disconnection function will actually close a database connection. This means the following PHP code (supported by a well-configured odbc.ini etc.) will return rows instead of dying with an error:


$db = odbc_connect('Northwind', null, null);

odbc_close($db);

$sql = "SELECT CompanyName, PostalCode, Country FROM Suppliers";
$result=odbc_exec($db, $sql) or die('ERROR: Cannot execute query!');


This bug is less terrible when libmdbodbc is used with scripts that reliably terminate, but by watching lsof I found that it led apache2 to spawn abnormally long-lived children and thus constituted a memory leak. Yes, I run an apache based site that talks to an Access database.

Besides the poor design decisions I have to support, this bug warrants attention as Zend itself recommends that libmdbodbc be used.

The following patch has solved the problem for me:

--- odbc.c      2008-12-15 13:35:35.280274615 -0800
+++ odbc.c      2008-12-15 13:37:19.415771536 -0800
@@ -711,7 +711,10 @@
 SQLRETURN SQL_API SQLDisconnect(
     SQLHDBC            hdbc)
 {
-       TRACE("SQLDisconnect");
+       struct _hdbc *dbc = (struct _hdbc *) hdbc;
+       struct _henv *env = (struct _henv *) dbc->henv;
+       mdb_sql_close(env->sql);
+
        return SQL_SUCCESS;
 }

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.24-etchnhalf.1-486
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libmdbodbc depends on:
ii  libc6        2.7-15                      GNU C Library: Shared libraries
ii  libglib2.0-0 2.16.6-1                    The GLib library of C routines
ii  libmdbtools  0.5.99.0.6pre1.0.20051109-4 mdbtools libraries
ii  odbcinst1deb 2.2.11-16                   Support library and helper program

libmdbodbc recommends no packages.

libmdbodbc suggests no packages.

-- no debconf information

Reply to: