Thread: v07.03.0200: Make errors if configured --with-odbcver=0x0100

v07.03.0200: Make errors if configured --with-odbcver=0x0100

From
Justin Cranford
Date:
I want to use unixODBC with default ODBC version = 1.0 on Redhat 9. Configure produces code that does not compile when I specify this combination.

Make fails to compile info.c when I specify --with-odbcver=0x0100 plus one or both of unixODBC or iODBC. These combinations of configure parameters produce code that does not compile:

configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --with-odbcver=0x0100 --with-unixodbc --with-iodbc
configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --with-odbcver=0x0100 --with-unixodbc --without-iodbc
configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --with-odbcver=0x0100 --without-unixodbc --with-iodbc

The only way to avoid the compile errors is to exclude both unixODBC and iODBC when specifying --with-odbcver=0x0100, or leave out the --with-odbcver parameter. These combinations of configure parameters produce code that compiles ok on Redhat 9:

configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --without-unixodbc --with-iodbc
configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --with-unixodbc --without-iodbc
configure -q --prefix=/sandbox/psqlodbc --enable-pthreads --without-unixodbc --without-iodbc --with-odbcver=0x0100



The problem seems to be with compiler preprocessor directives because info.c fails to include these missing definitions from isqlext.h.

gcc -DHAVE_CONFIG_H -I. -I/tmp/psqlodbc-07.03.0200 -MT info.lo -MD -MP -MF .deps/info.Tpo -c /tmp/psqlodbc-07.03.0200/info.c  -fPIC -DPIC -o info.lo
/tmp/psqlodbc-07.03.0200/info.c: In function `PGAPI_GetInfo':
/tmp/psqlodbc-07.03.0200/info.c:103: `SQL_AT_ADD_COLUMN' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:103: (Each undeclared identifier is reported only once
/tmp/psqlodbc-07.03.0200/info.c:103: for each function it appears in.)
/tmp/psqlodbc-07.03.0200/info.c:105: `SQL_AT_DROP_COLUMN' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:499: `SQL_OJ_CAPABILITIES' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:504: `SQL_OJ_LEFT' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:505: `SQL_OJ_RIGHT' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:506: `SQL_OJ_FULL' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:507: `SQL_OJ_NESTED' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:508: `SQL_OJ_NOT_ORDERED' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:509: `SQL_OJ_INNER' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:510: `SQL_OJ_ALL_COMPARISON_OPS' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c: In function `PGAPI_ForeignKeys':
/tmp/psqlodbc-07.03.0200/info.c:3849: `SQL_NO_ACTION' undeclared (first use in this function)
/tmp/psqlodbc-07.03.0200/info.c:3853: `SQL_SET_DEFAULT' undeclared (first use in this function)
make[1]: *** [info.lo] Error 1


The file psqlodbc.h included by info.c contains the following lines...

#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
#include <sql.h>
#include <sqlext.h>
#else
#include "iodbc.h"
#include "isql.h"
#include "isqlext.h"
#endif

The missing definitions are in isqlext.h with is excluded if unixODBC or iODBC are used with ODBCVER=1.0. However, if ODBCVER is not overridden the definitions are included ok. This implies the problem lies in sql.h or sqlext.h which probably include isqlext.h indirectly.