aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2001-09-22 22:54:33 +0000
committerPeter Eisentraut <peter_e@gmx.net>2001-09-22 22:54:33 +0000
commit364a7ebe26a20625f7c0b27a59ebbbdb8378587f (patch)
tree954b9ab0a58c727478022e277ca4d0a006b4c153 /src
parent39ceaa19f03faa11fbcab6bc050e3b494258afe0 (diff)
downloadpostgresql-364a7ebe26a20625f7c0b27a59ebbbdb8378587f.tar.gz
postgresql-364a7ebe26a20625f7c0b27a59ebbbdb8378587f.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.global.in4
-rw-r--r--src/Makefile.shlib3
-rw-r--r--src/include/pg_config.h.in9
-rw-r--r--src/interfaces/libpq/Makefile4
-rw-r--r--src/interfaces/odbc/GNUmakefile21
-rw-r--r--src/interfaces/odbc/bind.c8
-rw-r--r--src/interfaces/odbc/connection.c7
-rw-r--r--src/interfaces/odbc/connection.h10
-rw-r--r--src/interfaces/odbc/convert.c25
-rw-r--r--src/interfaces/odbc/dlg_specific.c14
-rw-r--r--src/interfaces/odbc/dlg_specific.h2
-rw-r--r--src/interfaces/odbc/drvconn.c8
-rw-r--r--src/interfaces/odbc/environ.h10
-rw-r--r--src/interfaces/odbc/execute.c9
-rw-r--r--src/interfaces/odbc/gpps.c2
-rw-r--r--src/interfaces/odbc/gpps.h4
-rw-r--r--src/interfaces/odbc/info.c11
-rw-r--r--src/interfaces/odbc/lobj.c2
-rw-r--r--src/interfaces/odbc/misc.c15
-rw-r--r--src/interfaces/odbc/misc.h5
-rw-r--r--src/interfaces/odbc/odbcapi.c7
-rw-r--r--src/interfaces/odbc/odbcapi30.c7
-rw-r--r--src/interfaces/odbc/options.c10
-rw-r--r--src/interfaces/odbc/parse.c7
-rw-r--r--src/interfaces/odbc/pgapifunc.h7
-rw-r--r--src/interfaces/odbc/pgtypes.c10
-rw-r--r--src/interfaces/odbc/psqlodbc.c9
-rw-r--r--src/interfaces/odbc/psqlodbc.h42
-rw-r--r--src/interfaces/odbc/qresult.c1
-rw-r--r--src/interfaces/odbc/results.c7
-rw-r--r--src/interfaces/odbc/setup.c3
-rw-r--r--src/interfaces/odbc/socket.c1
-rw-r--r--src/interfaces/odbc/socket.h2
-rw-r--r--src/interfaces/odbc/statement.c14
-rw-r--r--src/interfaces/odbc/statement.h9
-rw-r--r--src/interfaces/odbc/tuple.c1
-rw-r--r--src/interfaces/odbc/tuplelist.c1
37 files changed, 92 insertions, 219 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 9af54765418..d5123abb235 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
# -*-makefile-*-
-# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.138 2001/09/17 23:00:27 petere Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.139 2001/09/22 22:54:32 petere Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -127,6 +127,8 @@ with_tcl = @with_tcl@
enable_pltcl_unknown = @enable_pltcl_unknown@
with_tk = @with_tk@
enable_odbc = @enable_odbc@
+with_iodbc = @with_iodbc@
+with_unixodbc = @with_unixodbc@
MULTIBYTE = @MULTIBYTE@
enable_shared = @enable_shared@
enable_rpath = @enable_rpath@
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 0635049d064..4b89aa49279 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.53 2001/09/11 23:20:41 petere Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.54 2001/09/22 22:54:32 petere Exp $
#
#-------------------------------------------------------------------------
@@ -263,6 +263,7 @@ ifeq ($(PORTNAME), beos)
SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
endif
+SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
ifeq ($(enable_rpath), yes)
SHLIB_LINK += $(rpath)
endif
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 3944e1c9396..c8bee9bc5d2 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure.
*
- * $Id: pg_config.h.in,v 1.6 2001/09/14 10:36:52 ishii Exp $
+ * $Id: pg_config.h.in,v 1.7 2001/09/22 22:54:32 petere Exp $
*/
#ifndef PG_CONFIG_H
@@ -98,6 +98,13 @@
/* location of locale files */
#undef LOCALEDIR
+/* Define to build the ODBC driver for unixODBC */
+#undef WITH_UNIXODBC
+
+/* Define to build the ODBC driver for iODBC */
+#undef WITH_IODBC
+
+
/*
*------------------------------------------------------------------------
* Part 2: feature symbols and limits that are user-configurable, but
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index c603a2b6a83..8b8f3c91d1d 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.58 2001/09/21 20:31:48 tgl Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.59 2001/09/22 22:54:32 petere Exp $
#
#-------------------------------------------------------------------------
@@ -30,7 +30,7 @@ endif
# Add libraries that libpq depends (or might depend) on into the
# shared library link. (The order in which you list them here doesn't
# matter.)
-SHLIB_LINK += $(filter -L%, $(LDFLAGS)) $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS))
+SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS))
all: all-lib
diff --git a/src/interfaces/odbc/GNUmakefile b/src/interfaces/odbc/GNUmakefile
index 2d442efe1ac..8585f57cfef 100644
--- a/src/interfaces/odbc/GNUmakefile
+++ b/src/interfaces/odbc/GNUmakefile
@@ -2,7 +2,7 @@
#
# GNUMakefile for psqlodbc (Postgres ODBC driver)
#
-# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.19 2001/09/11 23:27:10 petere Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.20 2001/09/22 22:54:32 petere Exp $
#
#-------------------------------------------------------------------------
@@ -11,23 +11,36 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
# Shared library parameters
+ifeq ($(with_unixodbc),yes)
+NAME = odbcpsql
+else
NAME = psqlodbc
+endif
SO_MAJOR_VERSION = 0
SO_MINOR_VERSION = 27
-override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DHAVE_CONFIG_H -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
+override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
environ.o execute.o lobj.o misc.o options.o \
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
- gpps.o tuple.o tuplelist.o dlg_specific.o odbcapi.o $(OBJX)
+ tuple.o tuplelist.o dlg_specific.o odbcapi.o
ifdef MULTIBYTE
OBJS += multibyte.o
endif
-SHLIB_LINK = $(filter -lm -lnsl -lsocket, $(LIBS))
+SHLIB_LINK += $(filter -lm -lnsl -lsocket, $(LIBS))
+ifeq ($(with_unixodbc),yes)
+SHLIB_LINK += -lodbcinst
+endif
+ifeq ($(with_iodbc),yes)
+SHLIB_LINK += -liodbcinst
+endif
+ifeq ($(with_unixodbc)$(with_iodbc),nono)
+OBJS += gpps.o
+endif
all: all-lib
diff --git a/src/interfaces/odbc/bind.c b/src/interfaces/odbc/bind.c
index ce172365486..062632df480 100644
--- a/src/interfaces/odbc/bind.c
+++ b/src/interfaces/odbc/bind.c
@@ -22,14 +22,6 @@
#include <stdlib.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include "sql.h"
-#include "sqlext.h"
-#endif
#include "pgapifunc.h"
diff --git a/src/interfaces/odbc/connection.c b/src/interfaces/odbc/connection.c
index 7dc3fde0b25..70c7b782309 100644
--- a/src/interfaces/odbc/connection.c
+++ b/src/interfaces/odbc/connection.c
@@ -14,12 +14,12 @@
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
+#include "connection.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include "connection.h"
-
#include "environ.h"
#include "socket.h"
#include "statement.h"
@@ -31,9 +31,6 @@
#include "multibyte.h"
#endif
-#ifdef WIN32
-#include <odbcinst.h>
-#endif
#include "pgapifunc.h"
#define STMT_INCREMENT 16 /* how many statement holders to allocate
diff --git a/src/interfaces/odbc/connection.h b/src/interfaces/odbc/connection.h
index fc3560d3522..505325ad682 100644
--- a/src/interfaces/odbc/connection.h
+++ b/src/interfaces/odbc/connection.h
@@ -14,16 +14,6 @@
#include <stdlib.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
typedef enum
{
diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c
index f39a34f4c15..03d1b0817bc 100644
--- a/src/interfaces/odbc/convert.c
+++ b/src/interfaces/odbc/convert.c
@@ -17,26 +17,16 @@
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
+#include "convert.h"
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include "psqlodbc.h"
#ifdef MULTIBYTE
#include "multibyte.h"
#endif
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
-#include "convert.h"
#include <time.h>
#include <math.h>
#include <stdlib.h>
@@ -48,17 +38,6 @@
#include "connection.h"
#include "pgapifunc.h"
-#ifndef WIN32
-#ifndef HAVE_STRICMP
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
-#endif
-#ifndef SCHAR
-typedef signed char SCHAR;
-
-#endif
-#endif
-
/*
* How to map ODBC scalar functions {fn func(args)} to Postgres.
diff --git a/src/interfaces/odbc/dlg_specific.c b/src/interfaces/odbc/dlg_specific.c
index c02f633fdb3..e67a1dc020d 100644
--- a/src/interfaces/odbc/dlg_specific.c
+++ b/src/interfaces/odbc/dlg_specific.c
@@ -17,20 +17,8 @@
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
-#include "psqlodbc.h"
-
-#ifndef WIN32
-#include <string.h>
-#include "gpps.h"
-#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f)
-#define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d)
-#ifndef HAVE_STRICMP
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
-#endif
-#endif
-
#include "dlg_specific.h"
+
#include "convert.h"
#ifdef MULTIBYTE
diff --git a/src/interfaces/odbc/dlg_specific.h b/src/interfaces/odbc/dlg_specific.h
index 6fc04ad2fb9..16a159c3d1a 100644
--- a/src/interfaces/odbc/dlg_specific.h
+++ b/src/interfaces/odbc/dlg_specific.h
@@ -13,9 +13,7 @@
#include "connection.h"
#ifdef WIN32
-#include <windows.h>
#include <windowsx.h>
-#include <odbcinst.h>
#include "resource.h"
#endif
diff --git a/src/interfaces/odbc/drvconn.c b/src/interfaces/odbc/drvconn.c
index 781bdd54903..f2d5dab08c7 100644
--- a/src/interfaces/odbc/drvconn.c
+++ b/src/interfaces/odbc/drvconn.c
@@ -25,18 +25,12 @@
#define NEAR
#else
#include <winsock.h>
-#include <sqlext.h>
#endif
#include <string.h>
-#ifndef WIN32
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
-#else
-#include <windows.h>
+#ifdef WIN32
#include <windowsx.h>
-#include <odbcinst.h>
#include "resource.h"
#endif
#include "pgapifunc.h"
diff --git a/src/interfaces/odbc/environ.h b/src/interfaces/odbc/environ.h
index 6d50fa6b48f..7b463b3e744 100644
--- a/src/interfaces/odbc/environ.h
+++ b/src/interfaces/odbc/environ.h
@@ -11,16 +11,6 @@
#include "psqlodbc.h"
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
#define ENV_ALLOC_ERROR 1
/********** Environment Handle *************/
diff --git a/src/interfaces/odbc/execute.c b/src/interfaces/odbc/execute.c
index d13a37e8eff..991407975e7 100644
--- a/src/interfaces/odbc/execute.c
+++ b/src/interfaces/odbc/execute.c
@@ -14,17 +14,10 @@
*/
#include "psqlodbc.h"
+
#include <stdio.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
-
#include "connection.h"
#include "statement.h"
#include "qresult.h"
diff --git a/src/interfaces/odbc/gpps.c b/src/interfaces/odbc/gpps.c
index 450f0b1e505..3f013bc5d2e 100644
--- a/src/interfaces/odbc/gpps.c
+++ b/src/interfaces/odbc/gpps.c
@@ -19,7 +19,7 @@
*-------
*/
-#ifndef WIN32
+#if !defined(WIN32) && !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
#include "gpps.h"
diff --git a/src/interfaces/odbc/gpps.h b/src/interfaces/odbc/gpps.h
index c0b6a20796c..48b6722573d 100644
--- a/src/interfaces/odbc/gpps.h
+++ b/src/interfaces/odbc/gpps.h
@@ -8,9 +8,11 @@
#ifndef WIN32
#include <sys/types.h>
-#include "iodbc.h"
#endif
+#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f)
+#define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d)
+
#ifdef __cplusplus
extern "C"
{
diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c
index 6ff0d0b12e4..5f4059bd2d8 100644
--- a/src/interfaces/odbc/info.c
+++ b/src/interfaces/odbc/info.c
@@ -22,16 +22,7 @@
#include <stdio.h>
#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
#include <ctype.h>
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-
-#include <odbcinst.h>
#endif
#include "tuple.h"
@@ -2060,7 +2051,7 @@ PGAPI_Statistics(
char column_name[MAX_INFO_STRING],
relhasrules[MAX_INFO_STRING];
char **column_names = 0;
- Int4 column_name_len;
+ SQLINTEGER column_name_len;
int total_columns = 0;
char error = TRUE;
ConnInfo *ci;
diff --git a/src/interfaces/odbc/lobj.c b/src/interfaces/odbc/lobj.c
index 16d592eafd2..6b55b82d54e 100644
--- a/src/interfaces/odbc/lobj.c
+++ b/src/interfaces/odbc/lobj.c
@@ -13,7 +13,7 @@
*/
#include "lobj.h"
-#include "psqlodbc.h"
+
#include "connection.h"
diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c
index 87a4ee01ff5..b17c45e3110 100644
--- a/src/interfaces/odbc/misc.c
+++ b/src/interfaces/odbc/misc.c
@@ -143,21 +143,6 @@ qlog(char *fmt,...)
#endif
-/* Undefine these because windows.h will redefine and cause a warning */
-
-#ifdef WIN32
-#undef va_start
-#undef va_end
-#endif
-
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#endif
-
/*
* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied
diff --git a/src/interfaces/odbc/misc.h b/src/interfaces/odbc/misc.h
index 016b4b7a5e9..5cedd4c147e 100644
--- a/src/interfaces/odbc/misc.h
+++ b/src/interfaces/odbc/misc.h
@@ -11,11 +11,6 @@
#include "psqlodbc.h"
-#ifndef WIN32
-#include "gpps.h"
-#define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f)
-#endif
-
#include <stdio.h>
/* Uncomment MY_LOG define to compile in the mylog() statements.
diff --git a/src/interfaces/odbc/odbcapi.c b/src/interfaces/odbc/odbcapi.c
index dbb3142401f..9718aa9ff3a 100644
--- a/src/interfaces/odbc/odbcapi.c
+++ b/src/interfaces/odbc/odbcapi.c
@@ -34,13 +34,6 @@
#include <stdio.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
#include "pgapifunc.h"
#include "connection.h"
#include "statement.h"
diff --git a/src/interfaces/odbc/odbcapi30.c b/src/interfaces/odbc/odbcapi30.c
index e657595c031..24688583efd 100644
--- a/src/interfaces/odbc/odbcapi30.c
+++ b/src/interfaces/odbc/odbcapi30.c
@@ -24,13 +24,6 @@
#include <stdio.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
#include "environ.h"
#include "connection.h"
#include "statement.h"
diff --git a/src/interfaces/odbc/options.c b/src/interfaces/odbc/options.c
index a9a0a287fbd..bc221186baa 100644
--- a/src/interfaces/odbc/options.c
+++ b/src/interfaces/odbc/options.c
@@ -16,16 +16,6 @@
#include "psqlodbc.h"
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
#include "environ.h"
#include "connection.h"
#include "statement.h"
diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c
index 0f0aff6e04e..4fa7fffea5e 100644
--- a/src/interfaces/odbc/parse.c
+++ b/src/interfaces/odbc/parse.c
@@ -38,13 +38,6 @@
#include "multibyte.h"
#endif
-#ifndef WIN32
-#ifndef HAVE_STRICMP
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
-#endif
-#endif
-
#define FLD_INCR 32
#define TAB_INCR 8
#define COL_INCR 16
diff --git a/src/interfaces/odbc/pgapifunc.h b/src/interfaces/odbc/pgapifunc.h
index a4aca5f323d..72a5286e9f4 100644
--- a/src/interfaces/odbc/pgapifunc.h
+++ b/src/interfaces/odbc/pgapifunc.h
@@ -10,13 +10,6 @@
#include <stdio.h>
#include <string.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle,
HDBC FAR *ConnectionHandle);
diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c
index dd242d7bdcd..0af96536e8f 100644
--- a/src/interfaces/odbc/pgtypes.c
+++ b/src/interfaces/odbc/pgtypes.c
@@ -23,16 +23,6 @@
#include "connection.h"
#include "qresult.h"
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#include <sqlext.h>
-#endif
-
Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
diff --git a/src/interfaces/odbc/psqlodbc.c b/src/interfaces/odbc/psqlodbc.c
index ad156379d0a..3c8ff2a53ff 100644
--- a/src/interfaces/odbc/psqlodbc.c
+++ b/src/interfaces/odbc/psqlodbc.c
@@ -16,15 +16,8 @@
#include "psqlodbc.h"
#include "dlg_specific.h"
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#include "isqlext.h"
-#else
+#ifdef WIN32
#include <winsock.h>
-#include <windows.h>
-#include <sql.h>
-#include <odbcinst.h>
#endif
GLOBAL_VALUES globals;
diff --git a/src/interfaces/odbc/psqlodbc.h b/src/interfaces/odbc/psqlodbc.h
index 98fd47205f9..94b9c76701e 100644
--- a/src/interfaces/odbc/psqlodbc.h
+++ b/src/interfaces/odbc/psqlodbc.h
@@ -5,26 +5,58 @@
*
* Comments: See "notice.txt" for copyright and license information.
*
- * $Id: psqlodbc.h,v 1.48 2001/09/08 16:20:16 inoue Exp $
+ * $Id: psqlodbc.h,v 1.49 2001/09/22 22:54:33 petere Exp $
*
*/
#ifndef __PSQLODBC_H__
#define __PSQLODBC_H__
-#ifdef HAVE_CONFIG_H
+#ifndef WIN32
#include "pg_config.h"
+#else
+#include <windows.h>
#endif
#include <stdio.h> /* for FILE* pointers: see GLOBAL_VALUES */
+/* Must come before sql.h */
+#define ODBCVER 0x0250
+
+
+#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
+
+#if defined(WIN32)
+#include <odbcinst.h>
+#elif defined(WITH_UNIXODBC)
+#include <odbcinst.h>
+#elif defined(WITH_IODBC)
+#include <iodbcinst.h>
+#else
+#include "gpps.h"
+#endif
+
#ifndef WIN32
#define Int4 long int
#define UInt4 unsigned int
#define Int2 short
#define UInt2 unsigned short
+
+#if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
typedef float SFLOAT;
typedef double SDOUBLE;
+#endif
+
+#ifndef CALLBACK
+#define CALLBACK
+#endif
#else
#define Int4 int
@@ -35,8 +67,12 @@ typedef double SDOUBLE;
typedef UInt4 Oid;
+#ifndef WIN32
+#define stricmp strcasecmp
+#define strnicmp strncasecmp
+#endif
+
/* Driver stuff */
-#define ODBCVER 0x0250
#define DRIVER_ODBC_VER "02.50"
#define DRIVERNAME "PostgreSQL ODBC"
diff --git a/src/interfaces/odbc/qresult.c b/src/interfaces/odbc/qresult.c
index 103b299ed36..b3c8f6fcc09 100644
--- a/src/interfaces/odbc/qresult.c
+++ b/src/interfaces/odbc/qresult.c
@@ -21,6 +21,7 @@
*/
#include "qresult.h"
+
#include "misc.h"
#include <stdio.h>
#include <string.h>
diff --git a/src/interfaces/odbc/results.c b/src/interfaces/odbc/results.c
index 2475eeef9e3..c5652ff984d 100644
--- a/src/interfaces/odbc/results.c
+++ b/src/interfaces/odbc/results.c
@@ -29,13 +29,6 @@
#include <stdio.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isqlext.h"
-#else
-#include <windows.h>
-#include <sqlext.h>
-#endif
#include "pgapifunc.h"
diff --git a/src/interfaces/odbc/setup.c b/src/interfaces/odbc/setup.c
index 65f3423cf15..6b75840d98e 100644
--- a/src/interfaces/odbc/setup.c
+++ b/src/interfaces/odbc/setup.c
@@ -14,10 +14,9 @@
*/
#include "psqlodbc.h"
+
#include "connection.h"
-#include <windows.h>
#include <windowsx.h>
-#include <odbcinst.h>
#include <string.h>
#include <stdlib.h>
#include "resource.h"
diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c
index fbfb5ca9297..28a7af22bb5 100644
--- a/src/interfaces/odbc/socket.c
+++ b/src/interfaces/odbc/socket.c
@@ -13,6 +13,7 @@
*/
#include "socket.h"
+
#include "connection.h"
#ifndef WIN32
diff --git a/src/interfaces/odbc/socket.h b/src/interfaces/odbc/socket.h
index f4c7b9e4e43..b49bebea9bb 100644
--- a/src/interfaces/odbc/socket.h
+++ b/src/interfaces/odbc/socket.h
@@ -36,8 +36,6 @@ typedef unsigned int in_addr_t;
#define SOCKETFD SOCKET
#endif
-#include "psqlodbc.h"
-
#define SOCKET_ALREADY_CONNECTED 1
#define SOCKET_HOST_NOT_FOUND 2
#define SOCKET_COULD_NOT_CREATE_SOCKET 3
diff --git a/src/interfaces/odbc/statement.c b/src/interfaces/odbc/statement.c
index 9efd4fb52c8..ea296ea7b3a 100644
--- a/src/interfaces/odbc/statement.c
+++ b/src/interfaces/odbc/statement.c
@@ -13,6 +13,7 @@
*/
#include "statement.h"
+
#include "bind.h"
#include "connection.h"
#include "qresult.h"
@@ -23,22 +24,9 @@
#include <string.h>
#include <ctype.h>
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#endif
#include "pgapifunc.h"
-#ifndef WIN32
-#ifndef HAVE_STRICMP
-#define stricmp(s1,s2) strcasecmp(s1,s2)
-#define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
-#endif
-#endif
#define PRN_NULLCHECK
diff --git a/src/interfaces/odbc/statement.h b/src/interfaces/odbc/statement.h
index 834eb005b3d..c1a2152b0c0 100644
--- a/src/interfaces/odbc/statement.h
+++ b/src/interfaces/odbc/statement.h
@@ -10,15 +10,8 @@
#define __STATEMENT_H__
#include "psqlodbc.h"
-#include "bind.h"
-#ifndef WIN32
-#include "iodbc.h"
-#include "isql.h"
-#else
-#include <windows.h>
-#include <sql.h>
-#endif
+#include "bind.h"
#ifndef FALSE
diff --git a/src/interfaces/odbc/tuple.c b/src/interfaces/odbc/tuple.c
index 658b7a75ec7..512f36d2b23 100644
--- a/src/interfaces/odbc/tuple.c
+++ b/src/interfaces/odbc/tuple.c
@@ -18,6 +18,7 @@
*/
#include "tuple.h"
+
#include <string.h>
#include <stdlib.h>
diff --git a/src/interfaces/odbc/tuplelist.c b/src/interfaces/odbc/tuplelist.c
index 284ee8ed440..5f3871600d6 100644
--- a/src/interfaces/odbc/tuplelist.c
+++ b/src/interfaces/odbc/tuplelist.c
@@ -14,6 +14,7 @@
*/
#include "tuplelist.h"
+
#include <stdlib.h>
#include "tuple.h"