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.
This commit is contained in:
Peter Eisentraut 2001-09-22 22:54:33 +00:00
parent 39ceaa19f0
commit 364a7ebe26
39 changed files with 605 additions and 656 deletions

933
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -567,8 +567,23 @@ fi
AC_MSG_CHECKING([whether to build the ODBC driver])
PGAC_ARG_BOOL(enable, odbc, no, [ --enable-odbc build the ODBC driver package])
AC_MSG_RESULT([$enable_odbc])
PGAC_ARG_BOOL(with, unixodbc, no, [ --with-unixodbc build ODBC driver for unixODBC])
PGAC_ARG_BOOL(with, iodbc, no, [ --with-iodbc build ODBC driver for iODBC])
if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
fi
if test "$with_unixodbc" = yes || test "$with_iodbc" = yes; then
enable_odbc=yes
fi
case $enable_odbc:$with_unixodbc:$with_iodbc in
yes:no:no) AC_MSG_RESULT([yes (stand-alone)]);;
yes:yes:no) AC_MSG_RESULT([yes (unixODBC)]); AC_DEFINE(WITH_UNIXODBC);;
yes:no:yes) AC_MSG_RESULT([yes (iODBC)]); AC_DEFINE(WITH_IODBC);;
no:*) AC_MSG_RESULT(no);;
esac
AC_SUBST([enable_odbc])
AC_SUBST([with_unixodbc])
AC_SUBST([with_iodbc])
# Allow for overriding the default location of the odbcinst.ini

View File

@ -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@

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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
{

View File

@ -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.

View File

@ -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

View File

@ -13,9 +13,7 @@
#include "connection.h"
#ifdef WIN32
#include <windows.h>
#include <windowsx.h>
#include <odbcinst.h>
#include "resource.h"
#endif

View File

@ -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"

View File

@ -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 *************/

View File

@ -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"

View File

@ -19,7 +19,7 @@
*-------
*/
#ifndef WIN32
#if !defined(WIN32) && !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
#include "gpps.h"

View File

@ -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"
{

View File

@ -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;

View File

@ -13,7 +13,7 @@
*/
#include "lobj.h"
#include "psqlodbc.h"
#include "connection.h"

View File

@ -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

View File

@ -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.

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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"

View File

@ -21,6 +21,7 @@
*/
#include "qresult.h"
#include "misc.h"
#include <stdio.h>
#include <string.h>

View File

@ -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"

View File

@ -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"

View File

@ -13,6 +13,7 @@
*/
#include "socket.h"
#include "connection.h"
#ifndef WIN32

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -18,6 +18,7 @@
*/
#include "tuple.h"
#include <string.h>
#include <stdlib.h>

View File

@ -14,6 +14,7 @@
*/
#include "tuplelist.h"
#include <stdlib.h>
#include "tuple.h"