[unixODBC-dev] Right way to read odbc.ini file.
ZIGLIO, Frediano, VF-IT
Frediano.Ziglio at vodafone.com
Fri Sep 10 16:19:51 BST 2004
> Martin J. Evans wrote:
> > I could be wrong and Nick might remember but I think
> DontDLClose attribute was
> > invented because of some drivers use of atexit or _fini - Nick?
> > <snipped test code>
> Yes, this test code demonstrated perfectly the reason dontdlclose was
> added. Drivers registered atexit functions, and the atexit list was
> maintained in the process. then after the driver manager had done a
> dlclose (releasing the driver code from the processes memory), the
> atexit function was being called on process termination,
> resulting in a
> seg fault due to attempting to execute code outside the programs code
This it's the reason I asked how to read odbc.ini from driver. odbc.ini
contains some settings for driver however when SQLConnect it's used DM
just call driver's SQLConnect so driver has to read odbc.ini on it's
own... however it's not that easy to know the exact position of odbc.ini
(or .odbc.ini ??) so I used odbcinst library. A fix should be to never
use SQLConnect and use SQLDriverConnect instead (DM should convert calls
to SQLConnect to SQLDriverConnect) however this break compatibility...
another fix should be to find a way to implement a library atexit (this
it's the reason I suggest the configure script). I checked PostgreSQL
driver (distributed with unixODBC) and it use the same static library
used by libodbc (unixODBC DM)... so every driver should duplicate the
code just to read odbc.ini ?? Why not using the same shared library
(libodbcinst) for DM and drivers ?? So you use only a single cache.
In my current environment (I must admit quite weird..)
[freddy at obot602l PostgreSQL]$ which odbcinst
[freddy at obot602l PostgreSQL]$ odbcinst -j
SYSTEM DATA SOURCES: /home/freddy/install/etc/odbc.ini
USER DATA SOURCES..: /home/freddy/.odbc.ini
[freddy at obot602l PostgreSQL]$ ldd /usr/bin/odbcinst
libodbcinst.so.1 => /home/freddy/install/lib/libodbcinst.so.1
libltdl.so.3 => /usr/lib/libltdl.so.3 (0x44a05000)
libdl.so.2 => /lib/libdl.so.2 (0x4d339000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x4d464000)
libc.so.6 => /lib/i686/libc.so.6 (0x4d1d8000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x4d1c0000)
[freddy at obot602l PostgreSQL]$ echo $LD_LIBRARY_PATH
note that I called odbcinst command installed on my system (2.2.8) and
this read configuration using my personal libraries (2.2.10).. how to
solve all these problems ??
> It may be if you have a version that doesn't do this, that
> someone has
> decided to fix this problem in the libc, making atexit know about
> dynamic loading. But its certainly not portable.
I used Fedora Code 2 (quite recent)...
> I dislike the global that the ini cacheing requires, but I
> can't see a
> simple way out. The ini cacheing can be disabled at build time though.
IMHO if this cause a memory leak it should be disabled by default...
More information about the unixODBC-dev