From: | "Ross Thomas" <ross(at)grinfinity(dot)com> |
---|---|
To: | <pgsql-patches(at)postgresql(dot)org> |
Subject: | Patch for ODBC driver (look for odbc.ini in more than one location) |
Date: | 2001-12-09 19:11:42 |
Message-ID: | 001201c180e5$5695ab80$0264a8c0@home.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Since most ODBC drivers and driver managers look for odbc.ini in several
locations on UNIX systems, it would seem sensible to have the PostgreSQL
driver do the same thing. (This idea occurred to me after five hours of
trying to figure out what libpsqlodbc didn't like about my /etc/odbc.ini,
but that's another story.)
iODBC, for example, does the following:
1) Checks $ODBCINI
2) Checks $HOME/.odbc.ini
3) Checks ~/.odbc.ini (where ~ is obtained from struct passwd)
4) Checks system-wide odbc.ini (in /etc by default)
This is essentially backwards-compatible with the old behaviour, unless
$ODBCINI is defined (in which case, arguably, the DBA knows what he's doing
anyway...). It resembles the Windows approach of allowing both user and
system data sources.
The attached patch implements this search path in 7.1.3's
GetPrivateProfileString(). It patches the following files:
configure.in
src/Makefile.global.in
src/interfaces/odbc/GNUmakefile
src/interfaces/odbc/dlg_specific.h
src/interfaces/odbc/gpps.c
It works for me (GNU/Linux i686). Possible issues include:
- Security. Since this library could (unwisely) be called from a setuid
binary, this is very important. How sensible is it to incorporate the
contents of an environment variable directly into the first argument to
fopen()? All relevant calls to fopen() are read-only (PG_BINARY_R).
- Portability. The new code shouldn't be any less portable than the 7.1.3
code, but I might have missed something.
- Consistency. Is the configure script option (--with-odbc=DIR) properly
named? I followed the convention set by --with-odbcinst, but the name I
chose could conceivably be confused with --enable-odbc. It might be more
appropriate (albeit less consistent) to call it --with-odbc-ini.
- Should one obtain the current user's home directory from /etc/passwd by
doing getpwuid(getuid()) or getpwuid(geteuid())? Currently I - like the
7.1.3 version of GetPrivateProfileString() - use the former, but it's
something worth thinking about.
- While I think I understand the somewhat convoluted code I replaced in
GetPrivateProfileString(), I am occasionally wrong. ;)
Feedback on these and any other issues would be very much appreciated.
Regards,
Ross Thomas
Attachment | Content-Type | Size |
---|---|---|
ini-search-patch | application/octet-stream | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Karel Zak | 2001-12-10 10:09:04 | Re: date formatting and tab-complete patch |
Previous Message | Weiping He | 2001-12-09 13:10:00 | NLS (zh_CN) for pg_dump |