Re: PHP and ODBC leaving lots of files open

Mike Prudence <[email protected]> Tue, 22 Jan 2013 17:18:50 +0000
Newsgroups gmane.comp.db.mdb-tools.devel
Message-ID <[email protected]>
Hi guys,

Chris - thanks again for the ideas, sadly didn't cut it....

.....because I discovered something else...

Having got to the point of tracing the UnixODBC calls, I could see that 
SQLConnect was being called followed by SQLDisconnect.

What I then discovered is that in odbc.c, SQLConnect calls 
mdb_sql_open() as you'd expect..... but the corresponding SQLDisconnect 
didn't do anything - most especially, it didn't call mdb_sql_close()!!

So, anyway, I submit a change to odbc.c for your pleasure:-

SQLRETURN SQL_API SQLDisconnect(
     SQLHDBC            hdbc)
{
    struct _hdbc *dbc = (struct _hdbc *) hdbc;
    struct _henv *env = (struct _henv *) dbc->henv;

    TRACE("SQLDisconnect");

    mdb_sql_close(env->sql);

    return SQL_SUCCESS;
}


Fixing the code and recompiling causes my issue to go away.  Quite why 
this hasn't been noticed before is a bit of a mystery (me included!) but 
I hope this discovery helps someone out there.

-- 

Cheers,

Mike

[email protected]                                 http://www.filmsat59.com
Films at 59 Ltd, 59 Cotham Hill, Bristol. BS6 6JR ENGLAND +44 117 906 4300

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d