pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedIs the linking with -lodbc necessary? (--with-odbc)
8+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2013-11-14 b4ea88d28b Stop linking lib(i)odbc library because the library is unnecessary and rather harmful. Per report from Pavel Raiskup(http://www.postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com).
* Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-11 17:50 Pavel Raiskup <praiskup@redhat.com>
0 siblings, 2 replies; 8+ messages in thread
From: Pavel Raiskup @ 2013-11-11 17:50 UTC (permalink / raw)
To: pgsql-odbc; +Cc: hhorak@redhat.com
Hello all!
Long story short: Is there a need to link psqlodbcw.so plugin against
libodbc.so? Principal problem: That library provides ABI for applications
- not for plugins; at least it seem to be like that.
I tried to remove this linking by following tweak:
| diff --git a/configure.ac b/configure.ac
| index 5fb401e..5d75db3 100644
| --- a/configure.ac
| +++ b/configure.ac
| @@ -65,7 +65,7 @@ fi
| # ODBC include and library
| #
|
| -if test "$ODBC_CONFIG" != ""; then
| +if false; then
| if test "$with_iodbc" != no; then
| ODBC_INCLUDE=`${ODBC_CONFIG} --cflags`
| CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}"
And both unixODBC and psqlodbcw.so communicates with each other correctly
at the first sight.
---------------------------------------------------------------------------
And now the long story.
The real problem comes now for 'isql' from unixODBC (and most probably
also for others) on s390x architecture in Linux.
As you know, unixODBC (== libodbc.so) uses lt_dlopen() (which just wraps
dlopen() in described scenario) for opening plugins. And also, the 'isql'
tool is linked against libodbc.so library.
And now. Lets look at one example API function now, e.g.
SQLAllocConnect() (but the same problem may be with any other API
function). This function is called directly from 'isql' somewhere
- and on that place, there desired to call the SQLAllocConnect() function
provided by libodbc.so.
The 'isql' loads plugins through libodbc.so.
The psqlodbcw.so plugin does not provide SQLAllocConnect(). But during
loading of any plugin, libodbc.so tries to search for possible existence
of that function inside the plugin. According to documented dlsym()
behavior - if the SQLAllocConntect() function is not defined in the
plugin, it tries to look more deeply in plugin's dependencies.. and it is
successful ~> because one of the dependencies is: "libodbc.so". But
because libodbc.so don't wan't to use that "internal" method - only if the
method was defined in plugin directly, unixODBC guys prepared very ugly
workaround for that situation - they try to "blacklist" addresses of
internal methods into template_func[] array for later comparison with
return of lt_dlsym() output.
Now we have the problem: That template_func array is initialized (at
least) on s390x differently than on other platforms - the
template_func[0].dm_func is *CORRECTLY* initialized to the "internal"
SQLAllocConntect() function address. But note! It is different address
than also *CORRECT* address returned from lt_dlsym() call later - so
detecting based on template_func[] is not successful (actually, the
function is located in memory at least twice). You can look into unixODBC
into the file DriverManager/SQLConnect.c:
582 /*
583 * structure to contain the loaded lib entry points
584 */
585
586 static struct driver_func template_func[] =
587 {
588 /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect", (void*)SQLAllocConnect },
That part of template_func[0] is initialized to the same SQLAllocConnect
address as it is in 'isql'. Actually, if there was _no_ direct call to
SQLAllocConnect in 'isql' code, linker on s390 would assign to that place
the expected address (the same which would be later returned by dlsym()).
----
I don't know yet whether the linker behavior is correct or not (whether
such linker behavioral expectations are ok), I'll observe it in next few
days and file a bug against s390x linker. Also, I'll try to ask for
better unixODBC api later, probably.
But firstly asking here: is that linkage against libodbc.so needed? I
can see that the blacklisting ugly hack in unixODBC is there just because
of plugins which are linked back against unixODBC.
Pavel
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-12 09:02 Inoue, Hiroshi <inoue@tpf.co.jp>
parent: Pavel Raiskup <praiskup@redhat.com>
1 sibling, 1 reply; 8+ messages in thread
From: Inoue, Hiroshi @ 2013-11-12 09:02 UTC (permalink / raw)
To: Pavel Raiskup <praiskup@redhat.com>; pgsql-odbc; +Cc: hhorak@redhat.com
Hi Pavel,
(2013/11/12 2:50), Pavel Raiskup wrote:
> Hello all!
>
> Long story short: Is there a need to link psqlodbcw.so plugin against
> libodbc.so? Principal problem: That library provides ABI for applications
> - not for plugins; at least it seem to be like that.
>
> I tried to remove this linking by following tweak:
>
> | diff --git a/configure.ac b/configure.ac
> | index 5fb401e..5d75db3 100644
> | --- a/configure.ac
> | +++ b/configure.ac
> | @@ -65,7 +65,7 @@ fi
> | # ODBC include and library
> | #
> |
> | -if test "$ODBC_CONFIG" != ""; then
> | +if false; then
> | if test "$with_iodbc" != no; then
> | ODBC_INCLUDE=`${ODBC_CONFIG} --cflags`
> | CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}"
>
> And both unixODBC and psqlodbcw.so communicates with each other correctly
> at the first sight.
Seems -lodbcinst is really necessary not -lodbc.
Could you please try the attached patch for the current git?
regards,
Hiroshi Inoue
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
configac.patch (text/x-patch, 686B) download
diff --git a/configure.ac b/configure.ac
index 5fb401e..86003b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,13 +71,14 @@ if test "$ODBC_CONFIG" != ""; then
CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}"
ODBC_LIBS=`${ODBC_CONFIG} --libs`
LIBS="$LIBS ${ODBC_LIBS}"
+ AC_MSG_NOTICE([using $ODBC_INCLUDE $ODBC_LIBS])
else
ODBC_INCLUDE=`${ODBC_CONFIG} --include-prefix`
CPPFLAGS="$CPPFLAGS -I${ODBC_INCLUDE}"
- ODBC_LIBS=`${ODBC_CONFIG} --libs`
- LIBS="$LIBS ${ODBC_LIBS}"
+ ODBC_LIBDIR=`${ODBC_CONFIG} --lib-prefix`
+ LDFLAGS="$LDFLAGS -L${ODBC_LIBDIR}"
+ AC_MSG_NOTICE([using $ODBC_INCLUDE $ODBC_LIBDIR])
fi
- AC_MSG_NOTICE([using $ODBC_INCLUDE $ODBC_LIBS])
fi
#
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-12 13:14 Pavel Raiskup <praiskup@redhat.com>
parent: Inoue, Hiroshi <inoue@tpf.co.jp>
0 siblings, 1 reply; 8+ messages in thread
From: Pavel Raiskup @ 2013-11-12 13:14 UTC (permalink / raw)
To: pgsql-odbc; +Cc: Inoue, Hiroshi <inoue@tpf.co.jp>; hhorak@redhat.com
> Seems -lodbcinst is really necessary not -lodbc.
> Could you please try the attached patch for the current git?
Hi, thanks a lot for looking at it! The patch works (I have lost access
to s390x for a moment, but testing on that arch is not needed iiuic).
That means hand testing via 'isql' works OK on x86_64. Also ldd is fine:
$ ldd ./.libs/psqlodbcw.so | grep libodbc
libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007fbf039b3000)
But looking at configure.ac - we should probably fix the iodbc case.. but
I'm not sure about that.
Just a little update to this issue: I tried other architectures I am able
to test and the problematic architectures seem to be at least armv7hl,
s390x, s390.
Thanks, Pavel
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-12 17:54 Pavel Raiskup <praiskup@redhat.com>
parent: Pavel Raiskup <praiskup@redhat.com>
0 siblings, 0 replies; 8+ messages in thread
From: Pavel Raiskup @ 2013-11-12 17:54 UTC (permalink / raw)
To: pgsql-odbc; +Cc: Inoue, Hiroshi <inoue@tpf.co.jp>; hhorak@redhat.com
> But looking at configure.ac - we should probably fix the iodbc case.. but
> I'm not sure about that.
Please scratch that ^^ sentence. I have looked badly at the code - your
patch should fix also iodbc case - so it is OK from my POV, thanks.
(Tested also on s390x).
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-13 10:41 Pavel Raiskup <praiskup@redhat.com>
parent: Pavel Raiskup <praiskup@redhat.com>
1 sibling, 3 replies; 8+ messages in thread
From: Pavel Raiskup @ 2013-11-13 10:41 UTC (permalink / raw)
To: pgsql-odbc; +Cc: hhorak@redhat.com, Nick Gorham <nick@lurcher.org>; unixodbc-dev@mailman.unixodbc.org
[+cc back psqlodbc]
[+cc unixODBC]
On Tuesday, November 12, 2013 11:46:39 Nick Gorham wrote:
> On 11/11/13 17:50, Pavel Raiskup wrote:
> > Hello all!
> >
> > Long story short: Is there a need to link psqlodbcw.so plugin against
> > libodbc.so? Principal problem: That library provides ABI for applications
> > - not for plugins; at least it seem to be like that.
> >
> > I tried to remove this linking by following tweak:
>
> Hi,
>
> As you have noticed, there is code in the DM to try and avoid what you
> describe. But AFAIK, a driver would normally link against -lodbcinst to
> gain access to the ini functions SQLGetPrivateProfileString and so on,
> no need to link to the driver manager (-lodbc) that is for application
> land use.
Hello Nick, thanks for looking at the problem from unixODBC perspective!
Would not there be better rather block loading badly linked plugins rather
than just try to expect that the linking is done the same way on all arches?
I attached possible solution.
Pavel
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
0001-DM-Don-t-load-plugins-linked-back-against-libodbc.so.patch (text/x-patch, 20.2K) download
From 8353fe74b3c79e23f645d9c76826dbc0bf3db3d8 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 13 Nov 2013 10:37:30 +0100
Subject: [PATCH] DM: don't load plugins linked back against libodbc.so
Previously, DM tried to load and work with such plugins. This
could result on some arm and s390 architectures (linux) to
problems with resolving API symbols.
As a solution we should not try to load such moudules and rather
fail with proper explanation. This should force plugin developers
to not link against libodbc.so as there should not be any real
need.
For more info look at:
http://www.postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com
---
DriverManager/DriverManager.exp | 1 +
DriverManager/Makefile.am | 9 +-
DriverManager/SQLConnect.c | 228 ++++++++++++++++------------------------
DriverManager/drivermanager.h | 16 ++-
configure.in | 2 +
odbcinst/Makefile.am | 2 +-
6 files changed, 108 insertions(+), 150 deletions(-)
diff --git a/DriverManager/DriverManager.exp b/DriverManager/DriverManager.exp
index bb09bdb..39b801f 100644
--- a/DriverManager/DriverManager.exp
+++ b/DriverManager/DriverManager.exp
@@ -159,3 +159,4 @@ uodbc_get_stats
uodbc_stats_error
ODBCSetTryWaitValue
ODBCGetTryWaitValue
+__UNIXODBC_PLUGIN_GUARD
diff --git a/DriverManager/Makefile.am b/DriverManager/Makefile.am
index d5d7421..d7162d9 100644
--- a/DriverManager/Makefile.am
+++ b/DriverManager/Makefile.am
@@ -18,16 +18,17 @@ libodbc_la_LIBADD = \
$(LIBICONV)
libodbc_la_LDFLAGS = \
- -version-info @LIB_VERSION@ \
+ -version-info @LIBINST_VERSION@ \
-no-undefined \
-export-dynamic \
-export-symbols @srcdir@/DriverManager.exp
libodbc_la_DEPENDENCIES = $(LTDLDEPS) \
../lst/liblstlc.la \
- ../log/libloglc.la \
- ../ini/libinilc.la \
- ../odbcinst/libodbcinstlc.la
+ ../log/libloglc.la \
+ ../ini/libinilc.la \
+ ../odbcinst/libodbcinstlc.la \
+ DriverManager.exp
libodbc_la_SOURCES = \
SQLAllocConnect.c \
diff --git a/DriverManager/SQLConnect.c b/DriverManager/SQLConnect.c
index 306e951..d3cc13d 100644
--- a/DriverManager/SQLConnect.c
+++ b/DriverManager/SQLConnect.c
@@ -614,122 +614,85 @@ static char const rcsid[]= "$RCSfile: SQLConnect.c,v $ $Revision: 1.66 $";
static struct driver_func template_func[] =
{
- /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect", (void*)SQLAllocConnect },
- /* 01 */ { SQL_API_SQLALLOCENV, "SQLAllocEnv", (void*)SQLAllocEnv },
- /* 02 */ { SQL_API_SQLALLOCHANDLE, "SQLAllocHandle", (void*)SQLAllocHandle },
- /* 03 */ { SQL_API_SQLALLOCSTMT, "SQLAllocStmt", (void*)SQLAllocStmt },
- /* 04 */ { SQL_API_SQLALLOCHANDLESTD, "SQLAllocHandleStd", (void*)SQLAllocHandleStd },
- /* 05 */ { SQL_API_SQLBINDCOL, "SQLBindCol", (void*)SQLBindCol },
- /* 06 */ { SQL_API_SQLBINDPARAM, "SQLBindParam", (void*)SQLBindParam },
- /* 07 */ { SQL_API_SQLBINDPARAMETER, "SQLBindParameter", (void*)SQLBindParameter },
- /* 08 */ { SQL_API_SQLBROWSECONNECT, "SQLBrowseConnect",
- (void*)SQLBrowseConnect, (void*)SQLBrowseConnectW },
- /* 09 */ { SQL_API_SQLBULKOPERATIONS, "SQLBulkOperations", (void*)SQLBulkOperations },
- /* 10 */ { SQL_API_SQLCANCEL, "SQLCancel", (void*)SQLCancel },
- /* 11 */ { SQL_API_SQLCLOSECURSOR, "SQLCloseCursor", (void*)SQLCloseCursor },
- /* 12 */ { SQL_API_SQLCOLATTRIBUTE, "SQLColAttribute",
- (void*)SQLColAttribute, (void*)SQLColAttributeW },
- /* 13 */ { SQL_API_SQLCOLATTRIBUTES, "SQLColAttributes",
- (void*)SQLColAttributes, (void*)SQLColAttributesW },
- /* 14 */ { SQL_API_SQLCOLUMNPRIVILEGES, "SQLColumnPrivileges",
- (void*)SQLColumnPrivileges, (void*)SQLColumnPrivilegesW },
- /* 15 */ { SQL_API_SQLCOLUMNS, "SQLColumns",
- (void*)SQLColumns, (void*)SQLColumnsW },
- /* 16 */ { SQL_API_SQLCONNECT, "SQLConnect",
- (void*)SQLConnect, (void*)SQLConnectW },
- /* 17 */ { SQL_API_SQLCOPYDESC, "SQLCopyDesc", (void*)SQLCopyDesc },
- /* 18 */ { SQL_API_SQLDATASOURCES, "SQLDataSources",
- (void*)SQLDataSources, (void*)SQLDataSourcesW },
- /* 19 */ { SQL_API_SQLDESCRIBECOL, "SQLDescribeCol",
- (void*)SQLDescribeCol, (void*)SQLDescribeColW },
- /* 20 */ { SQL_API_SQLDESCRIBEPARAM, "SQLDescribeParam", (void*)SQLDescribeParam },
- /* 21 */ { SQL_API_SQLDISCONNECT, "SQLDisconnect", (void*)SQLDisconnect },
- /* 22 */ { SQL_API_SQLDRIVERCONNECT, "SQLDriverConnect",
- (void*)SQLDriverConnect, (void*)SQLDriverConnectW },
- /* 23 */ { SQL_API_SQLDRIVERS, "SQLDrivers",
- (void*)SQLDrivers, (void*)SQLDriversW },
- /* 24 */ { SQL_API_SQLENDTRAN, "SQLEndTran", (void*)SQLEndTran },
- /* 25 */ { SQL_API_SQLERROR, "SQLError",
- (void*)SQLError, (void*)SQLErrorW },
- /* 26 */ { SQL_API_SQLEXECDIRECT, "SQLExecDirect",
- (void*)SQLExecDirect, (void*)SQLExecDirectW },
- /* 27 */ { SQL_API_SQLEXECUTE, "SQLExecute", (void*)SQLExecute },
- /* 28 */ { SQL_API_SQLEXTENDEDFETCH, "SQLExtendedFetch", (void*)SQLExtendedFetch },
- /* 29 */ { SQL_API_SQLFETCH, "SQLFetch", (void*)SQLFetch },
- /* 30 */ { SQL_API_SQLFETCHSCROLL, "SQLFetchScroll", (void*)SQLFetchScroll },
- /* 31 */ { SQL_API_SQLFOREIGNKEYS, "SQLForeignKeys",
- (void*)SQLForeignKeys, (void*)SQLForeignKeysW },
- /* 32 */ { SQL_API_SQLFREEENV, "SQLFreeEnv", (void*)SQLFreeEnv },
- /* 33 */ { SQL_API_SQLFREEHANDLE, "SQLFreeHandle", (void*)SQLFreeHandle },
- /* 34 */ { SQL_API_SQLFREESTMT, "SQLFreeStmt", (void*)SQLFreeStmt },
- /* 35 */ { SQL_API_SQLFREECONNECT, "SQLFreeConnect", (void*)SQLFreeConnect },
- /* 36 */ { SQL_API_SQLGETCONNECTATTR, "SQLGetConnectAttr",
- (void*)SQLGetConnectAttr, (void*)SQLGetConnectAttrW },
- /* 37 */ { SQL_API_SQLGETCONNECTOPTION, "SQLGetConnectOption",
- (void*)SQLGetConnectOption, (void*)SQLGetConnectOptionW },
- /* 38 */ { SQL_API_SQLGETCURSORNAME, "SQLGetCursorName",
- (void*)SQLGetCursorName, (void*)SQLGetCursorNameW },
- /* 39 */ { SQL_API_SQLGETDATA, "SQLGetData", (void*)SQLGetData },
- /* 40 */ { SQL_API_SQLGETDESCFIELD, "SQLGetDescField",
- (void*)SQLGetDescField, (void*)SQLGetDescFieldW },
- /* 41 */ { SQL_API_SQLGETDESCREC, "SQLGetDescRec",
- (void*)SQLGetDescRec, (void*)SQLGetDescRecW },
- /* 42 */ { SQL_API_SQLGETDIAGFIELD, "SQLGetDiagField",
- (void*)SQLGetDiagField, (void*)SQLGetDiagFieldW },
- /* 43 */ { SQL_API_SQLGETENVATTR, "SQLGetEnvAttr", (void*)SQLGetEnvAttr },
- /* 44 */ { SQL_API_SQLGETFUNCTIONS, "SQLGetFunctions", (void*)SQLGetFunctions },
- /* 45 */ { SQL_API_SQLGETINFO, "SQLGetInfo",
- (void*)SQLGetInfo, (void*)SQLGetInfoW },
- /* 46 */ { SQL_API_SQLGETSTMTATTR, "SQLGetStmtAttr",
- (void*)SQLGetStmtAttr, (void*)SQLGetStmtAttrW },
- /* 47 */ { SQL_API_SQLGETSTMTOPTION, "SQLGetStmtOption", (void*)SQLGetStmtOption },
- /* 48 */ { SQL_API_SQLGETTYPEINFO, "SQLGetTypeInfo",
- (void*)SQLGetTypeInfo, (void*)SQLGetTypeInfoW },
- /* 49 */ { SQL_API_SQLMORERESULTS, "SQLMoreResults", (void*)SQLMoreResults },
- /* 50 */ { SQL_API_SQLNATIVESQL, "SQLNativeSql",
- (void*)SQLNativeSql, (void*)SQLNativeSqlW },
- /* 51 */ { SQL_API_SQLNUMPARAMS, "SQLNumParams", (void*)SQLNumParams },
- /* 52 */ { SQL_API_SQLNUMRESULTCOLS, "SQLNumResultCols", (void*)SQLNumResultCols },
- /* 53 */ { SQL_API_SQLPARAMDATA, "SQLParamData", (void*)SQLParamData },
- /* 54 */ { SQL_API_SQLPARAMOPTIONS, "SQLParamOptions", (void*)SQLParamOptions },
- /* 55 */ { SQL_API_SQLPREPARE, "SQLPrepare",
- (void*)SQLPrepare, (void*)SQLPrepareW },
- /* 56 */ { SQL_API_SQLPRIMARYKEYS, "SQLPrimaryKeys",
- (void*)SQLPrimaryKeys, (void*)SQLPrimaryKeysW },
- /* 57 */ { SQL_API_SQLPROCEDURECOLUMNS, "SQLProcedureColumns",
- (void*)SQLProcedureColumns, (void*)SQLProcedureColumnsW },
- /* 58 */ { SQL_API_SQLPROCEDURES, "SQLProcedures",
- (void*)SQLProcedures, (void*)SQLProceduresW },
- /* 59 */ { SQL_API_SQLPUTDATA, "SQLPutData", (void*)SQLPutData },
- /* 60 */ { SQL_API_SQLROWCOUNT, "SQLRowCount", (void*)SQLRowCount },
- /* 61 */ { SQL_API_SQLSETCONNECTATTR, "SQLSetConnectAttr",
- (void*)SQLSetConnectAttr, (void*)SQLSetConnectAttrW },
- /* 62 */ { SQL_API_SQLSETCONNECTOPTION, "SQLSetConnectOption",
- (void*)SQLSetConnectOption, (void*)SQLSetConnectOptionW },
- /* 63 */ { SQL_API_SQLSETCURSORNAME, "SQLSetCursorName",
- (void*)SQLSetCursorName, (void*)SQLSetCursorNameW },
- /* 64 */ { SQL_API_SQLSETDESCFIELD, "SQLSetDescField",
- (void*)SQLSetDescField, (void*)SQLSetDescFieldW },
- /* 65 */ { SQL_API_SQLSETDESCREC, "SQLSetDescRec", (void*)SQLSetDescRec },
- /* 66 */ { SQL_API_SQLSETENVATTR, "SQLSetEnvAttr", (void*)SQLSetEnvAttr },
- /* 67 */ { SQL_API_SQLSETPARAM, "SQLSetParam", (void*)SQLSetParam },
- /* 68 */ { SQL_API_SQLSETPOS, "SQLSetPos", (void*)SQLSetPos },
- /* 69 */ { SQL_API_SQLSETSCROLLOPTIONS, "SQLSetScrollOptions", (void*)SQLSetScrollOptions },
- /* 70 */ { SQL_API_SQLSETSTMTATTR, "SQLSetStmtAttr",
- (void*)SQLSetStmtAttr, (void*)SQLSetStmtAttrW },
- /* 71 */ { SQL_API_SQLSETSTMTOPTION, "SQLSetStmtOption", (void*)SQLSetStmtOption },
- /* 72 */ { SQL_API_SQLSPECIALCOLUMNS, "SQLSpecialColumns",
- (void*)SQLSpecialColumns, (void*)SQLSpecialColumnsW },
- /* 73 */ { SQL_API_SQLSTATISTICS, "SQLStatistics",
- (void*)SQLStatistics, (void*)SQLStatisticsW },
- /* 74 */ { SQL_API_SQLTABLEPRIVILEGES, "SQLTablePrivileges",
- (void*)SQLTablePrivileges, (void*)SQLTablePrivilegesW },
- /* 75 */ { SQL_API_SQLTABLES, "SQLTables",
- (void*)SQLTables, (void*)SQLTablesW },
- /* 76 */ { SQL_API_SQLTRANSACT, "SQLTransact", (void*)SQLTransact },
- /* 77 */ { SQL_API_SQLGETDIAGREC, "SQLGetDiagRec",
- (void*)SQLGetDiagRec, (void*)SQLGetDiagRecW },
- /* 78 */ { SQL_API_SQLCANCELHANDLE, "SQLCancelHandle", (void*)SQLCancelHandle },
+ /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect" },
+ /* 01 */ { SQL_API_SQLALLOCENV, "SQLAllocEnv" },
+ /* 02 */ { SQL_API_SQLALLOCHANDLE, "SQLAllocHandle" },
+ /* 03 */ { SQL_API_SQLALLOCSTMT, "SQLAllocStmt" },
+ /* 04 */ { SQL_API_SQLALLOCHANDLESTD, "SQLAllocHandleStd" },
+ /* 05 */ { SQL_API_SQLBINDCOL, "SQLBindCol" },
+ /* 06 */ { SQL_API_SQLBINDPARAM, "SQLBindParam" },
+ /* 07 */ { SQL_API_SQLBINDPARAMETER, "SQLBindParameter" },
+ /* 08 */ { SQL_API_SQLBROWSECONNECT, "SQLBrowseConnect", },
+ /* 09 */ { SQL_API_SQLBULKOPERATIONS, "SQLBulkOperations" },
+ /* 10 */ { SQL_API_SQLCANCEL, "SQLCancel" },
+ /* 11 */ { SQL_API_SQLCLOSECURSOR, "SQLCloseCursor" },
+ /* 12 */ { SQL_API_SQLCOLATTRIBUTE, "SQLColAttribute", TRUE },
+ /* 13 */ { SQL_API_SQLCOLATTRIBUTES, "SQLColAttributes", TRUE },
+ /* 14 */ { SQL_API_SQLCOLUMNPRIVILEGES, "SQLColumnPrivileges", TRUE },
+ /* 15 */ { SQL_API_SQLCOLUMNS, "SQLColumns", TRUE },
+ /* 16 */ { SQL_API_SQLCONNECT, "SQLConnect", TRUE },
+ /* 17 */ { SQL_API_SQLCOPYDESC, "SQLCopyDesc" },
+ /* 18 */ { SQL_API_SQLDATASOURCES, "SQLDataSources", TRUE },
+ /* 19 */ { SQL_API_SQLDESCRIBECOL, "SQLDescribeCol", TRUE },
+ /* 20 */ { SQL_API_SQLDESCRIBEPARAM, "SQLDescribeParam" },
+ /* 21 */ { SQL_API_SQLDISCONNECT, "SQLDisconnect" },
+ /* 22 */ { SQL_API_SQLDRIVERCONNECT, "SQLDriverConnect", TRUE },
+ /* 23 */ { SQL_API_SQLDRIVERS, "SQLDrivers", TRUE },
+ /* 24 */ { SQL_API_SQLENDTRAN, "SQLEndTran", TRUE },
+ /* 25 */ { SQL_API_SQLERROR, "SQLError", TRUE },
+ /* 26 */ { SQL_API_SQLEXECDIRECT, "SQLExecDirect", TRUE },
+ /* 27 */ { SQL_API_SQLEXECUTE, "SQLExecute" },
+ /* 28 */ { SQL_API_SQLEXTENDEDFETCH, "SQLExtendedFetch" },
+ /* 29 */ { SQL_API_SQLFETCH, "SQLFetch" },
+ /* 30 */ { SQL_API_SQLFETCHSCROLL, "SQLFetchScroll" },
+ /* 31 */ { SQL_API_SQLFOREIGNKEYS, "SQLForeignKeys", TRUE },
+ /* 32 */ { SQL_API_SQLFREEENV, "SQLFreeEnv" },
+ /* 33 */ { SQL_API_SQLFREEHANDLE, "SQLFreeHandle" },
+ /* 34 */ { SQL_API_SQLFREESTMT, "SQLFreeStmt" },
+ /* 35 */ { SQL_API_SQLFREECONNECT, "SQLFreeConnect" },
+ /* 36 */ { SQL_API_SQLGETCONNECTATTR, "SQLGetConnectAttr", TRUE },
+ /* 37 */ { SQL_API_SQLGETCONNECTOPTION, "SQLGetConnectOption", TRUE },
+ /* 38 */ { SQL_API_SQLGETCURSORNAME, "SQLGetCursorName", TRUE },
+ /* 39 */ { SQL_API_SQLGETDATA, "SQLGetData" },
+ /* 40 */ { SQL_API_SQLGETDESCFIELD, "SQLGetDescField", TRUE },
+ /* 41 */ { SQL_API_SQLGETDESCREC, "SQLGetDescRec", TRUE },
+ /* 42 */ { SQL_API_SQLGETDIAGFIELD, "SQLGetDiagField", TRUE },
+ /* 43 */ { SQL_API_SQLGETENVATTR, "SQLGetEnvAttr" },
+ /* 44 */ { SQL_API_SQLGETFUNCTIONS, "SQLGetFunctions" },
+ /* 45 */ { SQL_API_SQLGETINFO, "SQLGetInfo", TRUE },
+ /* 46 */ { SQL_API_SQLGETSTMTATTR, "SQLGetStmtAttr", TRUE },
+ /* 47 */ { SQL_API_SQLGETSTMTOPTION, "SQLGetStmtOption" },
+ /* 48 */ { SQL_API_SQLGETTYPEINFO, "SQLGetTypeInfo", TRUE },
+ /* 49 */ { SQL_API_SQLMORERESULTS, "SQLMoreResults" },
+ /* 50 */ { SQL_API_SQLNATIVESQL, "SQLNativeSql", TRUE },
+ /* 51 */ { SQL_API_SQLNUMPARAMS, "SQLNumParams" },
+ /* 52 */ { SQL_API_SQLNUMRESULTCOLS, "SQLNumResultCols" },
+ /* 53 */ { SQL_API_SQLPARAMDATA, "SQLParamData" },
+ /* 54 */ { SQL_API_SQLPARAMOPTIONS, "SQLParamOptions" },
+ /* 55 */ { SQL_API_SQLPREPARE, "SQLPrepare", TRUE },
+ /* 56 */ { SQL_API_SQLPRIMARYKEYS, "SQLPrimaryKeys", TRUE },
+ /* 57 */ { SQL_API_SQLPROCEDURECOLUMNS, "SQLProcedureColumns", TRUE },
+ /* 58 */ { SQL_API_SQLPROCEDURES, "SQLProcedures", TRUE },
+ /* 59 */ { SQL_API_SQLPUTDATA, "SQLPutData" },
+ /* 60 */ { SQL_API_SQLROWCOUNT, "SQLRowCount" },
+ /* 61 */ { SQL_API_SQLSETCONNECTATTR, "SQLSetConnectAttr", TRUE },
+ /* 62 */ { SQL_API_SQLSETCONNECTOPTION, "SQLSetConnectOption", TRUE },
+ /* 63 */ { SQL_API_SQLSETCURSORNAME, "SQLSetCursorName", TRUE },
+ /* 64 */ { SQL_API_SQLSETDESCFIELD, "SQLSetDescField", TRUE },
+ /* 65 */ { SQL_API_SQLSETDESCREC, "SQLSetDescRec" },
+ /* 66 */ { SQL_API_SQLSETENVATTR, "SQLSetEnvAttr" },
+ /* 67 */ { SQL_API_SQLSETPARAM, "SQLSetParam" },
+ /* 68 */ { SQL_API_SQLSETPOS, "SQLSetPos" },
+ /* 69 */ { SQL_API_SQLSETSCROLLOPTIONS, "SQLSetScrollOptions" },
+ /* 70 */ { SQL_API_SQLSETSTMTATTR, "SQLSetStmtAttr", TRUE },
+ /* 71 */ { SQL_API_SQLSETSTMTOPTION, "SQLSetStmtOption" },
+ /* 72 */ { SQL_API_SQLSPECIALCOLUMNS, "SQLSpecialColumns", TRUE },
+ /* 73 */ { SQL_API_SQLSTATISTICS, "SQLStatistics", TRUE },
+ /* 74 */ { SQL_API_SQLTABLEPRIVILEGES, "SQLTablePrivileges", TRUE },
+ /* 75 */ { SQL_API_SQLTABLES, "SQLTables", TRUE },
+ /* 76 */ { SQL_API_SQLTRANSACT, "SQLTransact" },
+ /* 77 */ { SQL_API_SQLGETDIAGREC, "SQLGetDiagRec", TRUE },
+ /* 78 */ { SQL_API_SQLCANCELHANDLE, "SQLCancelHandle" },
};
/*
@@ -841,10 +804,18 @@ static void *odbc_dlopen( char *libname, char **err )
if ( hand )
{
+ if ( lt_dlsym( hand, "__UNIXODBC_PLUGIN_GUARD" ))
+ {
+ lt_dlclose( hand );
+ *err = "Plugin is linked back against libodbc.so";
+ mutex_lib_exit();
+ return NULL;
+ }
+
/*
* If only one, then use the static space
*/
-
+
if ( lib_list == NULL )
{
list = &single_lib_count;
@@ -1238,29 +1209,6 @@ int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name,
connection -> functions[ i ].funcA =
connection -> functions[ i ].funcW = NULL;
}
-
- /*
- * blank out ones that are in the DM to fix a big
- * with glib 2.0.6
- */
-
- if ( connection -> functions[ i ].func &&
- (void*)connection -> functions[ i ].func ==
- (void*)connection -> functions[ i ].dm_func )
- {
- connection -> functions[ i ].func = NULL;
- }
-
- if ( connection -> functions[ i ].funcW &&
- (void*)connection -> functions[ i ].funcW ==
- (void*)connection -> functions[ i ].dm_funcW )
- {
- connection -> functions[ i ].funcW = NULL;
- }
-
- connection -> functions[ i ].can_supply =
- ( connection -> functions[ i ].func != NULL ) ||
- ( connection -> functions[ i ].funcW != NULL );
}
/*
diff --git a/DriverManager/drivermanager.h b/DriverManager/drivermanager.h
index 8aa64f9..9ed8014 100644
--- a/DriverManager/drivermanager.h
+++ b/DriverManager/drivermanager.h
@@ -124,6 +124,16 @@
#define STATE_D1e 2
/*
+ * We wan't disallow linking moudules back against the libodbc.so. When this
+ * symbol is found in driver (plugin) corresponding driver is back linked
+ * against libodbc.so; and it is an mistake. Back story:
+ *
+ * http://www.postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com
+ */
+
+SQLINTEGER __UNIXODBC_PLUGIN_GUARD;
+
+/*
* structure to contain the loaded lib entry points
*/
@@ -131,11 +141,7 @@ struct driver_func
{
int ordinal;
char *name;
- void *dm_func; /* this is to fix what seems a bug in */
- /* some dlopen implemnations where dlsym */
- /* will return the driver manager func */
- /* not the driver one */
- void *dm_funcW;
+ int dm_funcW;
SQLRETURN (*func)();
SQLRETURN (*funcW)(); /* function with a unicode W */
SQLRETURN (*funcA)(); /* function with a unicode A */
diff --git a/configure.in b/configure.in
index e1ce44f..24a02e4 100644
--- a/configure.in
+++ b/configure.in
@@ -498,6 +498,8 @@ AC_DEFINE([UNIXODBC_SOURCE],[],[We are building inside the unixODBC source tree]
LIB_VERSION="2:0:0"
AC_SUBST(LIB_VERSION)
+LIBINST_VERSION="3:0:0"
+AC_SUBST(LIBINST_VERSION)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_HEADERS(unixodbc_conf.h)
diff --git a/odbcinst/Makefile.am b/odbcinst/Makefile.am
index dde0ed5..fb5d9da 100644
--- a/odbcinst/Makefile.am
+++ b/odbcinst/Makefile.am
@@ -8,7 +8,7 @@ EXTRA_DIST = \
libodbcinst_la_LDFLAGS = \
-no-undefined \
- -version-info @LIB_VERSION@ \
+ -version-info @LIBINST_VERSION@ \
-export-dynamic \
-export-symbols @srcdir@/odbcinst.exp
--
1.8.4.2
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-13 10:53 Pavel Raiskup <praiskup@redhat.com>
parent: Pavel Raiskup <praiskup@redhat.com>
2 siblings, 0 replies; 8+ messages in thread
From: Pavel Raiskup @ 2013-11-13 10:53 UTC (permalink / raw)
To: pgsql-odbc; +Cc: hhorak@redhat.com, Nick Gorham <nick@lurcher.org>; unixodbc-dev@mailman.unixodbc.org
> I attached possible solution.
I removed too much code in the previous patch. Attached once again.
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
0001-DM-Don-t-load-plugins-linked-back-against-libodbc.so.patch (text/x-patch, 20.1K) download
From ae88c2c28534699f1620d2cae6bb01c9f100f4ba Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 13 Nov 2013 10:37:30 +0100
Subject: [PATCH] DM: don't load plugins linked back against libodbc.so
Previously, DM tried to load and work with such plugins. This
could result on some arm and s390 architectures (linux) to
problems with resolving API symbols.
As a solution we should not try to load such moudules and rather
fail with proper explanation. This should force plugin developers
to not link against libodbc.so as there should not be any real
need.
For more info look at:
http://www.postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com
---
DriverManager/DriverManager.exp | 1 +
DriverManager/Makefile.am | 9 +-
DriverManager/SQLConnect.c | 224 ++++++++++++++++------------------------
DriverManager/drivermanager.h | 16 ++-
configure.in | 2 +
odbcinst/Makefile.am | 2 +-
6 files changed, 108 insertions(+), 146 deletions(-)
diff --git a/DriverManager/DriverManager.exp b/DriverManager/DriverManager.exp
index bb09bdb..39b801f 100644
--- a/DriverManager/DriverManager.exp
+++ b/DriverManager/DriverManager.exp
@@ -159,3 +159,4 @@ uodbc_get_stats
uodbc_stats_error
ODBCSetTryWaitValue
ODBCGetTryWaitValue
+__UNIXODBC_PLUGIN_GUARD
diff --git a/DriverManager/Makefile.am b/DriverManager/Makefile.am
index d5d7421..d7162d9 100644
--- a/DriverManager/Makefile.am
+++ b/DriverManager/Makefile.am
@@ -18,16 +18,17 @@ libodbc_la_LIBADD = \
$(LIBICONV)
libodbc_la_LDFLAGS = \
- -version-info @LIB_VERSION@ \
+ -version-info @LIBINST_VERSION@ \
-no-undefined \
-export-dynamic \
-export-symbols @srcdir@/DriverManager.exp
libodbc_la_DEPENDENCIES = $(LTDLDEPS) \
../lst/liblstlc.la \
- ../log/libloglc.la \
- ../ini/libinilc.la \
- ../odbcinst/libodbcinstlc.la
+ ../log/libloglc.la \
+ ../ini/libinilc.la \
+ ../odbcinst/libodbcinstlc.la \
+ DriverManager.exp
libodbc_la_SOURCES = \
SQLAllocConnect.c \
diff --git a/DriverManager/SQLConnect.c b/DriverManager/SQLConnect.c
index 306e951..a107792 100644
--- a/DriverManager/SQLConnect.c
+++ b/DriverManager/SQLConnect.c
@@ -614,122 +614,85 @@ static char const rcsid[]= "$RCSfile: SQLConnect.c,v $ $Revision: 1.66 $";
static struct driver_func template_func[] =
{
- /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect", (void*)SQLAllocConnect },
- /* 01 */ { SQL_API_SQLALLOCENV, "SQLAllocEnv", (void*)SQLAllocEnv },
- /* 02 */ { SQL_API_SQLALLOCHANDLE, "SQLAllocHandle", (void*)SQLAllocHandle },
- /* 03 */ { SQL_API_SQLALLOCSTMT, "SQLAllocStmt", (void*)SQLAllocStmt },
- /* 04 */ { SQL_API_SQLALLOCHANDLESTD, "SQLAllocHandleStd", (void*)SQLAllocHandleStd },
- /* 05 */ { SQL_API_SQLBINDCOL, "SQLBindCol", (void*)SQLBindCol },
- /* 06 */ { SQL_API_SQLBINDPARAM, "SQLBindParam", (void*)SQLBindParam },
- /* 07 */ { SQL_API_SQLBINDPARAMETER, "SQLBindParameter", (void*)SQLBindParameter },
- /* 08 */ { SQL_API_SQLBROWSECONNECT, "SQLBrowseConnect",
- (void*)SQLBrowseConnect, (void*)SQLBrowseConnectW },
- /* 09 */ { SQL_API_SQLBULKOPERATIONS, "SQLBulkOperations", (void*)SQLBulkOperations },
- /* 10 */ { SQL_API_SQLCANCEL, "SQLCancel", (void*)SQLCancel },
- /* 11 */ { SQL_API_SQLCLOSECURSOR, "SQLCloseCursor", (void*)SQLCloseCursor },
- /* 12 */ { SQL_API_SQLCOLATTRIBUTE, "SQLColAttribute",
- (void*)SQLColAttribute, (void*)SQLColAttributeW },
- /* 13 */ { SQL_API_SQLCOLATTRIBUTES, "SQLColAttributes",
- (void*)SQLColAttributes, (void*)SQLColAttributesW },
- /* 14 */ { SQL_API_SQLCOLUMNPRIVILEGES, "SQLColumnPrivileges",
- (void*)SQLColumnPrivileges, (void*)SQLColumnPrivilegesW },
- /* 15 */ { SQL_API_SQLCOLUMNS, "SQLColumns",
- (void*)SQLColumns, (void*)SQLColumnsW },
- /* 16 */ { SQL_API_SQLCONNECT, "SQLConnect",
- (void*)SQLConnect, (void*)SQLConnectW },
- /* 17 */ { SQL_API_SQLCOPYDESC, "SQLCopyDesc", (void*)SQLCopyDesc },
- /* 18 */ { SQL_API_SQLDATASOURCES, "SQLDataSources",
- (void*)SQLDataSources, (void*)SQLDataSourcesW },
- /* 19 */ { SQL_API_SQLDESCRIBECOL, "SQLDescribeCol",
- (void*)SQLDescribeCol, (void*)SQLDescribeColW },
- /* 20 */ { SQL_API_SQLDESCRIBEPARAM, "SQLDescribeParam", (void*)SQLDescribeParam },
- /* 21 */ { SQL_API_SQLDISCONNECT, "SQLDisconnect", (void*)SQLDisconnect },
- /* 22 */ { SQL_API_SQLDRIVERCONNECT, "SQLDriverConnect",
- (void*)SQLDriverConnect, (void*)SQLDriverConnectW },
- /* 23 */ { SQL_API_SQLDRIVERS, "SQLDrivers",
- (void*)SQLDrivers, (void*)SQLDriversW },
- /* 24 */ { SQL_API_SQLENDTRAN, "SQLEndTran", (void*)SQLEndTran },
- /* 25 */ { SQL_API_SQLERROR, "SQLError",
- (void*)SQLError, (void*)SQLErrorW },
- /* 26 */ { SQL_API_SQLEXECDIRECT, "SQLExecDirect",
- (void*)SQLExecDirect, (void*)SQLExecDirectW },
- /* 27 */ { SQL_API_SQLEXECUTE, "SQLExecute", (void*)SQLExecute },
- /* 28 */ { SQL_API_SQLEXTENDEDFETCH, "SQLExtendedFetch", (void*)SQLExtendedFetch },
- /* 29 */ { SQL_API_SQLFETCH, "SQLFetch", (void*)SQLFetch },
- /* 30 */ { SQL_API_SQLFETCHSCROLL, "SQLFetchScroll", (void*)SQLFetchScroll },
- /* 31 */ { SQL_API_SQLFOREIGNKEYS, "SQLForeignKeys",
- (void*)SQLForeignKeys, (void*)SQLForeignKeysW },
- /* 32 */ { SQL_API_SQLFREEENV, "SQLFreeEnv", (void*)SQLFreeEnv },
- /* 33 */ { SQL_API_SQLFREEHANDLE, "SQLFreeHandle", (void*)SQLFreeHandle },
- /* 34 */ { SQL_API_SQLFREESTMT, "SQLFreeStmt", (void*)SQLFreeStmt },
- /* 35 */ { SQL_API_SQLFREECONNECT, "SQLFreeConnect", (void*)SQLFreeConnect },
- /* 36 */ { SQL_API_SQLGETCONNECTATTR, "SQLGetConnectAttr",
- (void*)SQLGetConnectAttr, (void*)SQLGetConnectAttrW },
- /* 37 */ { SQL_API_SQLGETCONNECTOPTION, "SQLGetConnectOption",
- (void*)SQLGetConnectOption, (void*)SQLGetConnectOptionW },
- /* 38 */ { SQL_API_SQLGETCURSORNAME, "SQLGetCursorName",
- (void*)SQLGetCursorName, (void*)SQLGetCursorNameW },
- /* 39 */ { SQL_API_SQLGETDATA, "SQLGetData", (void*)SQLGetData },
- /* 40 */ { SQL_API_SQLGETDESCFIELD, "SQLGetDescField",
- (void*)SQLGetDescField, (void*)SQLGetDescFieldW },
- /* 41 */ { SQL_API_SQLGETDESCREC, "SQLGetDescRec",
- (void*)SQLGetDescRec, (void*)SQLGetDescRecW },
- /* 42 */ { SQL_API_SQLGETDIAGFIELD, "SQLGetDiagField",
- (void*)SQLGetDiagField, (void*)SQLGetDiagFieldW },
- /* 43 */ { SQL_API_SQLGETENVATTR, "SQLGetEnvAttr", (void*)SQLGetEnvAttr },
- /* 44 */ { SQL_API_SQLGETFUNCTIONS, "SQLGetFunctions", (void*)SQLGetFunctions },
- /* 45 */ { SQL_API_SQLGETINFO, "SQLGetInfo",
- (void*)SQLGetInfo, (void*)SQLGetInfoW },
- /* 46 */ { SQL_API_SQLGETSTMTATTR, "SQLGetStmtAttr",
- (void*)SQLGetStmtAttr, (void*)SQLGetStmtAttrW },
- /* 47 */ { SQL_API_SQLGETSTMTOPTION, "SQLGetStmtOption", (void*)SQLGetStmtOption },
- /* 48 */ { SQL_API_SQLGETTYPEINFO, "SQLGetTypeInfo",
- (void*)SQLGetTypeInfo, (void*)SQLGetTypeInfoW },
- /* 49 */ { SQL_API_SQLMORERESULTS, "SQLMoreResults", (void*)SQLMoreResults },
- /* 50 */ { SQL_API_SQLNATIVESQL, "SQLNativeSql",
- (void*)SQLNativeSql, (void*)SQLNativeSqlW },
- /* 51 */ { SQL_API_SQLNUMPARAMS, "SQLNumParams", (void*)SQLNumParams },
- /* 52 */ { SQL_API_SQLNUMRESULTCOLS, "SQLNumResultCols", (void*)SQLNumResultCols },
- /* 53 */ { SQL_API_SQLPARAMDATA, "SQLParamData", (void*)SQLParamData },
- /* 54 */ { SQL_API_SQLPARAMOPTIONS, "SQLParamOptions", (void*)SQLParamOptions },
- /* 55 */ { SQL_API_SQLPREPARE, "SQLPrepare",
- (void*)SQLPrepare, (void*)SQLPrepareW },
- /* 56 */ { SQL_API_SQLPRIMARYKEYS, "SQLPrimaryKeys",
- (void*)SQLPrimaryKeys, (void*)SQLPrimaryKeysW },
- /* 57 */ { SQL_API_SQLPROCEDURECOLUMNS, "SQLProcedureColumns",
- (void*)SQLProcedureColumns, (void*)SQLProcedureColumnsW },
- /* 58 */ { SQL_API_SQLPROCEDURES, "SQLProcedures",
- (void*)SQLProcedures, (void*)SQLProceduresW },
- /* 59 */ { SQL_API_SQLPUTDATA, "SQLPutData", (void*)SQLPutData },
- /* 60 */ { SQL_API_SQLROWCOUNT, "SQLRowCount", (void*)SQLRowCount },
- /* 61 */ { SQL_API_SQLSETCONNECTATTR, "SQLSetConnectAttr",
- (void*)SQLSetConnectAttr, (void*)SQLSetConnectAttrW },
- /* 62 */ { SQL_API_SQLSETCONNECTOPTION, "SQLSetConnectOption",
- (void*)SQLSetConnectOption, (void*)SQLSetConnectOptionW },
- /* 63 */ { SQL_API_SQLSETCURSORNAME, "SQLSetCursorName",
- (void*)SQLSetCursorName, (void*)SQLSetCursorNameW },
- /* 64 */ { SQL_API_SQLSETDESCFIELD, "SQLSetDescField",
- (void*)SQLSetDescField, (void*)SQLSetDescFieldW },
- /* 65 */ { SQL_API_SQLSETDESCREC, "SQLSetDescRec", (void*)SQLSetDescRec },
- /* 66 */ { SQL_API_SQLSETENVATTR, "SQLSetEnvAttr", (void*)SQLSetEnvAttr },
- /* 67 */ { SQL_API_SQLSETPARAM, "SQLSetParam", (void*)SQLSetParam },
- /* 68 */ { SQL_API_SQLSETPOS, "SQLSetPos", (void*)SQLSetPos },
- /* 69 */ { SQL_API_SQLSETSCROLLOPTIONS, "SQLSetScrollOptions", (void*)SQLSetScrollOptions },
- /* 70 */ { SQL_API_SQLSETSTMTATTR, "SQLSetStmtAttr",
- (void*)SQLSetStmtAttr, (void*)SQLSetStmtAttrW },
- /* 71 */ { SQL_API_SQLSETSTMTOPTION, "SQLSetStmtOption", (void*)SQLSetStmtOption },
- /* 72 */ { SQL_API_SQLSPECIALCOLUMNS, "SQLSpecialColumns",
- (void*)SQLSpecialColumns, (void*)SQLSpecialColumnsW },
- /* 73 */ { SQL_API_SQLSTATISTICS, "SQLStatistics",
- (void*)SQLStatistics, (void*)SQLStatisticsW },
- /* 74 */ { SQL_API_SQLTABLEPRIVILEGES, "SQLTablePrivileges",
- (void*)SQLTablePrivileges, (void*)SQLTablePrivilegesW },
- /* 75 */ { SQL_API_SQLTABLES, "SQLTables",
- (void*)SQLTables, (void*)SQLTablesW },
- /* 76 */ { SQL_API_SQLTRANSACT, "SQLTransact", (void*)SQLTransact },
- /* 77 */ { SQL_API_SQLGETDIAGREC, "SQLGetDiagRec",
- (void*)SQLGetDiagRec, (void*)SQLGetDiagRecW },
- /* 78 */ { SQL_API_SQLCANCELHANDLE, "SQLCancelHandle", (void*)SQLCancelHandle },
+ /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect" },
+ /* 01 */ { SQL_API_SQLALLOCENV, "SQLAllocEnv" },
+ /* 02 */ { SQL_API_SQLALLOCHANDLE, "SQLAllocHandle" },
+ /* 03 */ { SQL_API_SQLALLOCSTMT, "SQLAllocStmt" },
+ /* 04 */ { SQL_API_SQLALLOCHANDLESTD, "SQLAllocHandleStd" },
+ /* 05 */ { SQL_API_SQLBINDCOL, "SQLBindCol" },
+ /* 06 */ { SQL_API_SQLBINDPARAM, "SQLBindParam" },
+ /* 07 */ { SQL_API_SQLBINDPARAMETER, "SQLBindParameter" },
+ /* 08 */ { SQL_API_SQLBROWSECONNECT, "SQLBrowseConnect", },
+ /* 09 */ { SQL_API_SQLBULKOPERATIONS, "SQLBulkOperations" },
+ /* 10 */ { SQL_API_SQLCANCEL, "SQLCancel" },
+ /* 11 */ { SQL_API_SQLCLOSECURSOR, "SQLCloseCursor" },
+ /* 12 */ { SQL_API_SQLCOLATTRIBUTE, "SQLColAttribute", TRUE },
+ /* 13 */ { SQL_API_SQLCOLATTRIBUTES, "SQLColAttributes", TRUE },
+ /* 14 */ { SQL_API_SQLCOLUMNPRIVILEGES, "SQLColumnPrivileges", TRUE },
+ /* 15 */ { SQL_API_SQLCOLUMNS, "SQLColumns", TRUE },
+ /* 16 */ { SQL_API_SQLCONNECT, "SQLConnect", TRUE },
+ /* 17 */ { SQL_API_SQLCOPYDESC, "SQLCopyDesc" },
+ /* 18 */ { SQL_API_SQLDATASOURCES, "SQLDataSources", TRUE },
+ /* 19 */ { SQL_API_SQLDESCRIBECOL, "SQLDescribeCol", TRUE },
+ /* 20 */ { SQL_API_SQLDESCRIBEPARAM, "SQLDescribeParam" },
+ /* 21 */ { SQL_API_SQLDISCONNECT, "SQLDisconnect" },
+ /* 22 */ { SQL_API_SQLDRIVERCONNECT, "SQLDriverConnect", TRUE },
+ /* 23 */ { SQL_API_SQLDRIVERS, "SQLDrivers", TRUE },
+ /* 24 */ { SQL_API_SQLENDTRAN, "SQLEndTran", TRUE },
+ /* 25 */ { SQL_API_SQLERROR, "SQLError", TRUE },
+ /* 26 */ { SQL_API_SQLEXECDIRECT, "SQLExecDirect", TRUE },
+ /* 27 */ { SQL_API_SQLEXECUTE, "SQLExecute" },
+ /* 28 */ { SQL_API_SQLEXTENDEDFETCH, "SQLExtendedFetch" },
+ /* 29 */ { SQL_API_SQLFETCH, "SQLFetch" },
+ /* 30 */ { SQL_API_SQLFETCHSCROLL, "SQLFetchScroll" },
+ /* 31 */ { SQL_API_SQLFOREIGNKEYS, "SQLForeignKeys", TRUE },
+ /* 32 */ { SQL_API_SQLFREEENV, "SQLFreeEnv" },
+ /* 33 */ { SQL_API_SQLFREEHANDLE, "SQLFreeHandle" },
+ /* 34 */ { SQL_API_SQLFREESTMT, "SQLFreeStmt" },
+ /* 35 */ { SQL_API_SQLFREECONNECT, "SQLFreeConnect" },
+ /* 36 */ { SQL_API_SQLGETCONNECTATTR, "SQLGetConnectAttr", TRUE },
+ /* 37 */ { SQL_API_SQLGETCONNECTOPTION, "SQLGetConnectOption", TRUE },
+ /* 38 */ { SQL_API_SQLGETCURSORNAME, "SQLGetCursorName", TRUE },
+ /* 39 */ { SQL_API_SQLGETDATA, "SQLGetData" },
+ /* 40 */ { SQL_API_SQLGETDESCFIELD, "SQLGetDescField", TRUE },
+ /* 41 */ { SQL_API_SQLGETDESCREC, "SQLGetDescRec", TRUE },
+ /* 42 */ { SQL_API_SQLGETDIAGFIELD, "SQLGetDiagField", TRUE },
+ /* 43 */ { SQL_API_SQLGETENVATTR, "SQLGetEnvAttr" },
+ /* 44 */ { SQL_API_SQLGETFUNCTIONS, "SQLGetFunctions" },
+ /* 45 */ { SQL_API_SQLGETINFO, "SQLGetInfo", TRUE },
+ /* 46 */ { SQL_API_SQLGETSTMTATTR, "SQLGetStmtAttr", TRUE },
+ /* 47 */ { SQL_API_SQLGETSTMTOPTION, "SQLGetStmtOption" },
+ /* 48 */ { SQL_API_SQLGETTYPEINFO, "SQLGetTypeInfo", TRUE },
+ /* 49 */ { SQL_API_SQLMORERESULTS, "SQLMoreResults" },
+ /* 50 */ { SQL_API_SQLNATIVESQL, "SQLNativeSql", TRUE },
+ /* 51 */ { SQL_API_SQLNUMPARAMS, "SQLNumParams" },
+ /* 52 */ { SQL_API_SQLNUMRESULTCOLS, "SQLNumResultCols" },
+ /* 53 */ { SQL_API_SQLPARAMDATA, "SQLParamData" },
+ /* 54 */ { SQL_API_SQLPARAMOPTIONS, "SQLParamOptions" },
+ /* 55 */ { SQL_API_SQLPREPARE, "SQLPrepare", TRUE },
+ /* 56 */ { SQL_API_SQLPRIMARYKEYS, "SQLPrimaryKeys", TRUE },
+ /* 57 */ { SQL_API_SQLPROCEDURECOLUMNS, "SQLProcedureColumns", TRUE },
+ /* 58 */ { SQL_API_SQLPROCEDURES, "SQLProcedures", TRUE },
+ /* 59 */ { SQL_API_SQLPUTDATA, "SQLPutData" },
+ /* 60 */ { SQL_API_SQLROWCOUNT, "SQLRowCount" },
+ /* 61 */ { SQL_API_SQLSETCONNECTATTR, "SQLSetConnectAttr", TRUE },
+ /* 62 */ { SQL_API_SQLSETCONNECTOPTION, "SQLSetConnectOption", TRUE },
+ /* 63 */ { SQL_API_SQLSETCURSORNAME, "SQLSetCursorName", TRUE },
+ /* 64 */ { SQL_API_SQLSETDESCFIELD, "SQLSetDescField", TRUE },
+ /* 65 */ { SQL_API_SQLSETDESCREC, "SQLSetDescRec" },
+ /* 66 */ { SQL_API_SQLSETENVATTR, "SQLSetEnvAttr" },
+ /* 67 */ { SQL_API_SQLSETPARAM, "SQLSetParam" },
+ /* 68 */ { SQL_API_SQLSETPOS, "SQLSetPos" },
+ /* 69 */ { SQL_API_SQLSETSCROLLOPTIONS, "SQLSetScrollOptions" },
+ /* 70 */ { SQL_API_SQLSETSTMTATTR, "SQLSetStmtAttr", TRUE },
+ /* 71 */ { SQL_API_SQLSETSTMTOPTION, "SQLSetStmtOption" },
+ /* 72 */ { SQL_API_SQLSPECIALCOLUMNS, "SQLSpecialColumns", TRUE },
+ /* 73 */ { SQL_API_SQLSTATISTICS, "SQLStatistics", TRUE },
+ /* 74 */ { SQL_API_SQLTABLEPRIVILEGES, "SQLTablePrivileges", TRUE },
+ /* 75 */ { SQL_API_SQLTABLES, "SQLTables", TRUE },
+ /* 76 */ { SQL_API_SQLTRANSACT, "SQLTransact" },
+ /* 77 */ { SQL_API_SQLGETDIAGREC, "SQLGetDiagRec", TRUE },
+ /* 78 */ { SQL_API_SQLCANCELHANDLE, "SQLCancelHandle" },
};
/*
@@ -841,10 +804,18 @@ static void *odbc_dlopen( char *libname, char **err )
if ( hand )
{
+ if ( lt_dlsym( hand, "__UNIXODBC_PLUGIN_GUARD" ))
+ {
+ lt_dlclose( hand );
+ *err = "Plugin is linked back against libodbc.so";
+ mutex_lib_exit();
+ return NULL;
+ }
+
/*
* If only one, then use the static space
*/
-
+
if ( lib_list == NULL )
{
list = &single_lib_count;
@@ -1239,25 +1210,6 @@ int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name,
connection -> functions[ i ].funcW = NULL;
}
- /*
- * blank out ones that are in the DM to fix a big
- * with glib 2.0.6
- */
-
- if ( connection -> functions[ i ].func &&
- (void*)connection -> functions[ i ].func ==
- (void*)connection -> functions[ i ].dm_func )
- {
- connection -> functions[ i ].func = NULL;
- }
-
- if ( connection -> functions[ i ].funcW &&
- (void*)connection -> functions[ i ].funcW ==
- (void*)connection -> functions[ i ].dm_funcW )
- {
- connection -> functions[ i ].funcW = NULL;
- }
-
connection -> functions[ i ].can_supply =
( connection -> functions[ i ].func != NULL ) ||
( connection -> functions[ i ].funcW != NULL );
diff --git a/DriverManager/drivermanager.h b/DriverManager/drivermanager.h
index 8aa64f9..9ed8014 100644
--- a/DriverManager/drivermanager.h
+++ b/DriverManager/drivermanager.h
@@ -124,6 +124,16 @@
#define STATE_D1e 2
/*
+ * We wan't disallow linking moudules back against the libodbc.so. When this
+ * symbol is found in driver (plugin) corresponding driver is back linked
+ * against libodbc.so; and it is an mistake. Back story:
+ *
+ * http://www.postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com
+ */
+
+SQLINTEGER __UNIXODBC_PLUGIN_GUARD;
+
+/*
* structure to contain the loaded lib entry points
*/
@@ -131,11 +141,7 @@ struct driver_func
{
int ordinal;
char *name;
- void *dm_func; /* this is to fix what seems a bug in */
- /* some dlopen implemnations where dlsym */
- /* will return the driver manager func */
- /* not the driver one */
- void *dm_funcW;
+ int dm_funcW;
SQLRETURN (*func)();
SQLRETURN (*funcW)(); /* function with a unicode W */
SQLRETURN (*funcA)(); /* function with a unicode A */
diff --git a/configure.in b/configure.in
index e1ce44f..24a02e4 100644
--- a/configure.in
+++ b/configure.in
@@ -498,6 +498,8 @@ AC_DEFINE([UNIXODBC_SOURCE],[],[We are building inside the unixODBC source tree]
LIB_VERSION="2:0:0"
AC_SUBST(LIB_VERSION)
+LIBINST_VERSION="3:0:0"
+AC_SUBST(LIBINST_VERSION)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_HEADERS(unixodbc_conf.h)
diff --git a/odbcinst/Makefile.am b/odbcinst/Makefile.am
index dde0ed5..fb5d9da 100644
--- a/odbcinst/Makefile.am
+++ b/odbcinst/Makefile.am
@@ -8,7 +8,7 @@ EXTRA_DIST = \
libodbcinst_la_LDFLAGS = \
-no-undefined \
- -version-info @LIB_VERSION@ \
+ -version-info @LIBINST_VERSION@ \
-export-dynamic \
-export-symbols @srcdir@/odbcinst.exp
--
1.8.4.2
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-13 11:12 Nick Gorham <nick@lurcher.org>
parent: Pavel Raiskup <praiskup@redhat.com>
2 siblings, 0 replies; 8+ messages in thread
From: Nick Gorham @ 2013-11-13 11:12 UTC (permalink / raw)
To: Pavel Raiskup <praiskup@redhat.com>; +Cc: pgsql-odbc; hhorak@redhat.com; unixodbc-dev@mailman.unixodbc.org
On 13/11/13 10:41, Pavel Raiskup wrote:
> [+cc back psqlodbc]
> [+cc unixODBC]
>
> On Tuesday, November 12, 2013 11:46:39 Nick Gorham wrote:
>> On 11/11/13 17:50, Pavel Raiskup wrote:
>>> Hello all!
>>>
>>> Long story short: Is there a need to link psqlodbcw.so plugin against
>>> libodbc.so? Principal problem: That library provides ABI for applications
>>> - not for plugins; at least it seem to be like that.
>>>
>>> I tried to remove this linking by following tweak:
>> Hi,
>>
>> As you have noticed, there is code in the DM to try and avoid what you
>> describe. But AFAIK, a driver would normally link against -lodbcinst to
>> gain access to the ini functions SQLGetPrivateProfileString and so on,
>> no need to link to the driver manager (-lodbc) that is for application
>> land use.
> Hello Nick, thanks for looking at the problem from unixODBC perspective!
>
> Would not there be better rather block loading badly linked plugins rather
> than just try to expect that the linking is done the same way on all arches?
> I attached possible solution.
>
> Pavel
Yes, I see your solution. Possible though that the driver is linked
against libiodbc.so or other non unixODBC version of ODBC driver manager
and so has entry point for SQLAllocStmt (for example) that is not in the
driver (as in this case).
There are also situations I have seen where a driver decides to call
itself (say SQLAllocStmt() in the driver makes a call to
SQLAllocHandle() expecting the driver version) but finds the driver
manager entry point.
Anyway you have the good solution for your driver in linking against
libodbcinst
--
Nick Gorham
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is the linking with -lodbc necessary? (--with-odbc)
@ 2013-11-13 11:12 Nick Gorham <nick@lurcher.org>
parent: Pavel Raiskup <praiskup@redhat.com>
2 siblings, 0 replies; 8+ messages in thread
From: Nick Gorham @ 2013-11-13 11:12 UTC (permalink / raw)
To: Pavel Raiskup <praiskup@redhat.com>; +Cc: pgsql-odbc; hhorak@redhat.com
On 13/11/13 10:41, Pavel Raiskup wrote:
> [+cc back psqlodbc]
> [+cc unixODBC]
>
> On Tuesday, November 12, 2013 11:46:39 Nick Gorham wrote:
>> On 11/11/13 17:50, Pavel Raiskup wrote:
>>> Hello all!
>>>
>>> Long story short: Is there a need to link psqlodbcw.so plugin against
>>> libodbc.so? Principal problem: That library provides ABI for applications
>>> - not for plugins; at least it seem to be like that.
>>>
>>> I tried to remove this linking by following tweak:
>> Hi,
>>
>> As you have noticed, there is code in the DM to try and avoid what you
>> describe. But AFAIK, a driver would normally link against -lodbcinst to
>> gain access to the ini functions SQLGetPrivateProfileString and so on,
>> no need to link to the driver manager (-lodbc) that is for application
>> land use.
> Hello Nick, thanks for looking at the problem from unixODBC perspective!
>
> Would not there be better rather block loading badly linked plugins rather
> than just try to expect that the linking is done the same way on all arches?
> I attached possible solution.
>
> Pavel
Yes, I see your solution. Possible though that the driver is linked
against libiodbc.so or other non unixODBC version of ODBC driver manager
and so has entry point for SQLAllocStmt (for example) that is not in the
driver (as in this case).
There are also situations I have seen where a driver decides to call
itself (say SQLAllocStmt() in the driver makes a call to
SQLAllocHandle() expecting the driver version) but finds the driver
manager entry point.
Anyway you have the good solution for your driver in linking against
libodbcinst
--
Nick Gorham
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2013-11-13 11:12 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-11-11 17:50 Is the linking with -lodbc necessary? (--with-odbc) Pavel Raiskup <praiskup@redhat.com>
2013-11-12 09:02 ` Inoue, Hiroshi <inoue@tpf.co.jp>
2013-11-12 13:14 ` Pavel Raiskup <praiskup@redhat.com>
2013-11-12 17:54 ` Pavel Raiskup <praiskup@redhat.com>
2013-11-13 10:41 ` Pavel Raiskup <praiskup@redhat.com>
2013-11-13 10:53 ` Pavel Raiskup <praiskup@redhat.com>
2013-11-13 11:12 ` Nick Gorham <nick@lurcher.org>
2013-11-13 11:12 ` Nick Gorham <nick@lurcher.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox