Skip to content

Commit 364a7eb

Browse files
committed
Provide some initial support for building the ODBC driver for
an already installed iODBC or unixODBC driver manager. In particular, use the include files provided by the driver manager over our own, and use the odbcinst library of the driver manager rather than gpps.c. Migrate portability sections common to several files into psqlodbc.h.
1 parent 39ceaa1 commit 364a7eb

39 files changed

+605
-656
lines changed

configure

Lines changed: 497 additions & 436 deletions
Large diffs are not rendered by default.

configure.in

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,23 @@ fi
567567

568568
AC_MSG_CHECKING([whether to build the ODBC driver])
569569
PGAC_ARG_BOOL(enable, odbc, no, [ --enable-odbc build the ODBC driver package])
570-
AC_MSG_RESULT([$enable_odbc])
570+
PGAC_ARG_BOOL(with, unixodbc, no, [ --with-unixodbc build ODBC driver for unixODBC])
571+
PGAC_ARG_BOOL(with, iodbc, no, [ --with-iodbc build ODBC driver for iODBC])
572+
if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
573+
AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
574+
fi
575+
if test "$with_unixodbc" = yes || test "$with_iodbc" = yes; then
576+
enable_odbc=yes
577+
fi
578+
case $enable_odbc:$with_unixodbc:$with_iodbc in
579+
yes:no:no) AC_MSG_RESULT([yes (stand-alone)]);;
580+
yes:yes:no) AC_MSG_RESULT([yes (unixODBC)]); AC_DEFINE(WITH_UNIXODBC);;
581+
yes:no:yes) AC_MSG_RESULT([yes (iODBC)]); AC_DEFINE(WITH_IODBC);;
582+
no:*) AC_MSG_RESULT(no);;
583+
esac
571584
AC_SUBST([enable_odbc])
585+
AC_SUBST([with_unixodbc])
586+
AC_SUBST([with_iodbc])
572587

573588

574589
# Allow for overriding the default location of the odbcinst.ini

src/Makefile.global.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.138 2001/09/17 23:00:27 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.139 2001/09/22 22:54:32 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -127,6 +127,8 @@ with_tcl = @with_tcl@
127127
enable_pltcl_unknown = @enable_pltcl_unknown@
128128
with_tk = @with_tk@
129129
enable_odbc = @enable_odbc@
130+
with_iodbc = @with_iodbc@
131+
with_unixodbc = @with_unixodbc@
130132
MULTIBYTE = @MULTIBYTE@
131133
enable_shared = @enable_shared@
132134
enable_rpath = @enable_rpath@

src/Makefile.shlib

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1998, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.53 2001/09/11 23:20:41 petere Exp $
9+
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.54 2001/09/22 22:54:32 petere Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -263,6 +263,7 @@ ifeq ($(PORTNAME), beos)
263263
SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
264264
endif
265265

266+
SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
266267
ifeq ($(enable_rpath), yes)
267268
SHLIB_LINK += $(rpath)
268269
endif

src/include/pg_config.h.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
99
* changes will be overwritten the next time you run configure.
1010
*
11-
* $Id: pg_config.h.in,v 1.6 2001/09/14 10:36:52 ishii Exp $
11+
* $Id: pg_config.h.in,v 1.7 2001/09/22 22:54:32 petere Exp $
1212
*/
1313

1414
#ifndef PG_CONFIG_H
@@ -98,6 +98,13 @@
9898
/* location of locale files */
9999
#undef LOCALEDIR
100100

101+
/* Define to build the ODBC driver for unixODBC */
102+
#undef WITH_UNIXODBC
103+
104+
/* Define to build the ODBC driver for iODBC */
105+
#undef WITH_IODBC
106+
107+
101108
/*
102109
*------------------------------------------------------------------------
103110
* Part 2: feature symbols and limits that are user-configurable, but

src/interfaces/libpq/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.58 2001/09/21 20:31:48 tgl Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.59 2001/09/22 22:54:32 petere Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -30,7 +30,7 @@ endif
3030
# Add libraries that libpq depends (or might depend) on into the
3131
# shared library link. (The order in which you list them here doesn't
3232
# matter.)
33-
SHLIB_LINK += $(filter -L%, $(LDFLAGS)) $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS))
33+
SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS))
3434

3535

3636
all: all-lib

src/interfaces/odbc/GNUmakefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# GNUMakefile for psqlodbc (Postgres ODBC driver)
44
#
5-
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.19 2001/09/11 23:27:10 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.20 2001/09/22 22:54:32 petere Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -11,23 +11,36 @@ top_builddir = ../../..
1111
include $(top_builddir)/src/Makefile.global
1212

1313
# Shared library parameters
14+
ifeq ($(with_unixodbc),yes)
15+
NAME = odbcpsql
16+
else
1417
NAME = psqlodbc
18+
endif
1519
SO_MAJOR_VERSION = 0
1620
SO_MINOR_VERSION = 27
1721

18-
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DHAVE_CONFIG_H -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
22+
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
1923

2024

2125
OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
2226
environ.o execute.o lobj.o misc.o options.o \
2327
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
24-
gpps.o tuple.o tuplelist.o dlg_specific.o odbcapi.o $(OBJX)
28+
tuple.o tuplelist.o dlg_specific.o odbcapi.o
2529

2630
ifdef MULTIBYTE
2731
OBJS += multibyte.o
2832
endif
2933

30-
SHLIB_LINK = $(filter -lm -lnsl -lsocket, $(LIBS))
34+
SHLIB_LINK += $(filter -lm -lnsl -lsocket, $(LIBS))
35+
ifeq ($(with_unixodbc),yes)
36+
SHLIB_LINK += -lodbcinst
37+
endif
38+
ifeq ($(with_iodbc),yes)
39+
SHLIB_LINK += -liodbcinst
40+
endif
41+
ifeq ($(with_unixodbc)$(with_iodbc),nono)
42+
OBJS += gpps.o
43+
endif
3144

3245
all: all-lib
3346

src/interfaces/odbc/bind.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@
2222
#include <stdlib.h>
2323
#include <string.h>
2424

25-
#ifndef WIN32
26-
#include "iodbc.h"
27-
#include "isql.h"
28-
#include "isqlext.h"
29-
#else
30-
#include "sql.h"
31-
#include "sqlext.h"
32-
#endif
3325
#include "pgapifunc.h"
3426

3527

src/interfaces/odbc/connection.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
*/
1515
/* Multibyte support Eiji Tokuya 2001-03-15 */
1616

17+
#include "connection.h"
18+
1719
#include <stdio.h>
1820
#include <string.h>
1921
#include <ctype.h>
2022

21-
#include "connection.h"
22-
2323
#include "environ.h"
2424
#include "socket.h"
2525
#include "statement.h"
@@ -31,9 +31,6 @@
3131
#include "multibyte.h"
3232
#endif
3333

34-
#ifdef WIN32
35-
#include <odbcinst.h>
36-
#endif
3734
#include "pgapifunc.h"
3835

3936
#define STMT_INCREMENT 16 /* how many statement holders to allocate

src/interfaces/odbc/connection.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@
1414
#include <stdlib.h>
1515
#include <string.h>
1616

17-
#ifndef WIN32
18-
#include "iodbc.h"
19-
#include "isql.h"
20-
#include "isqlext.h"
21-
#else
22-
#include <windows.h>
23-
#include <sql.h>
24-
#include <sqlext.h>
25-
#endif
26-
2717

2818
typedef enum
2919
{

0 commit comments

Comments
 (0)