Remove all traces of the ODBC driver, which is now on GBorg as the psqlodbc

project ...
This commit is contained in:
Marc G. Fournier 2002-08-22 22:43:14 +00:00
parent 03a7625a3a
commit 5a303f878e
87 changed files with 11 additions and 40007 deletions

View File

@ -1,7 +1,7 @@
#
# PostgreSQL top level makefile
#
# $Header: /cvsroot/pgsql/GNUmakefile.in,v 1.25 2002/08/22 00:15:04 scrappy Exp $
# $Header: /cvsroot/pgsql/GNUmakefile.in,v 1.26 2002/08/22 22:43:08 scrappy Exp $
#
subdir =
@ -72,7 +72,7 @@ $(distdir).tar: distdir
opt_files := src/backend/utils/mb contrib/retep/build.xml \
src/tools src/corba src/data src/tutorial \
$(addprefix src/bin/, pgaccess pgtclsh pg_encoding) \
$(addprefix src/interfaces/, odbc libpgtcl perl5 python jdbc) \
$(addprefix src/interfaces/, libpgtcl perl5 python jdbc) \
$(addprefix src/pl/, plperl tcl)
docs_files := doc/postgres.tar.gz doc/src doc/TODO.detail

33
INSTALL
View File

@ -321,10 +321,6 @@ Installation Procedure
the only good reason to select a non-default value is if you
intend to run multiple PostgreSQL servers on the same machine.
--with-CXX
Build the C++ interface library.
--with-perl
Build the Perl interface module. The Perl interface will be
@ -362,35 +358,6 @@ Installation Procedure
use a different version of Tcl or Tk you can specify the directory
in which to find them.
--enable-odbc
Build the ODBC driver. By default, the driver will be independent
of a driver manager. To work better with a driver manager already
installed on your system, use one of the following options in
addition to this one. More information can be found in the
Programmer's Guide.
--with-iodbc
Build the ODBC driver for use with iODBC.
--with-unixodbc
Build the ODBC driver for use with unixODBC.
--with-odbcinst=DIRECTORY
Specifies the directory where the ODBC driver will expect its
"odbcinst.ini" configuration file. The default is
"/usr/local/pgsql/etc" or whatever you specified as
"--sysconfdir". It should be arranged that the driver reads the
same file as the driver manager.
If either the option "--with-iodbc" or the option
"--with-unixodbc" is used, this option will be ignored because in
that case the driver manager handles the location of the
configuration file.
--with-java
Build the JDBC driver and associated Java packages. This option

7
README
View File

@ -8,8 +8,11 @@ PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions. This distribution also contains several language
bindings, including C, C++, Perl, Python, and Tcl, as well as drivers
for JDBC and ODBC.
bindings, including C, Perl, Python, and Tcl, as well as drivers
for JDBC.
As of v7.3, the ODBC and C++ interfaces have been moved over to the
PostgreSQL Projects WebSite @ http://gborg.postgresql.org.
See the file INSTALL for instructions on how to build and install
PostgreSQL. That file also lists supported operating systems and

164
configure vendored
View File

@ -845,7 +845,6 @@ Optional Features:
--enable-debug build with debugging symbols (-g)
--enable-depend turn on automatic dependency tracking
--enable-cassert enable assertion checks (for debugging)
--enable-odbc build the ODBC driver package
--disable-largefile omit support for large files
Optional Packages:
@ -871,9 +870,6 @@ Optional Packages:
--with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]
--without-readline do not use Readline
--without-zlib do not use Zlib
--with-unixodbc build ODBC driver for unixODBC
--with-iodbc build ODBC driver for iODBC
--with-odbcinst=DIR default directory for odbcinst.ini sysconfdir
--with-gnu-ld assume the C compiler uses GNU ld default=no
Some influential environment variables:
@ -3476,162 +3472,6 @@ fi;
#
# Optionally enable the building of the ODBC driver
#
# Old option name
if test "${with_odbc+set}" = set && test "${enable_odbc+set}" != set; then
enable_odbc=$with_odbc
fi
echo "$as_me:$LINENO: checking whether to build the ODBC driver" >&5
echo $ECHO_N "checking whether to build the ODBC driver... $ECHO_C" >&6
# Check whether --enable-odbc or --disable-odbc was given.
if test "${enable_odbc+set}" = set; then
enableval="$enable_odbc"
case $enableval in
yes)
:
;;
no)
:
;;
*)
{ { echo "$as_me:$LINENO: error: no argument expected for --enable-odbc option" >&5
echo "$as_me: error: no argument expected for --enable-odbc option" >&2;}
{ (exit 1); exit 1; }; }
;;
esac
else
enable_odbc=no
fi;
# Check whether --with-unixodbc or --without-unixodbc was given.
if test "${with_unixodbc+set}" = set; then
withval="$with_unixodbc"
case $withval in
yes)
:
;;
no)
:
;;
*)
{ { echo "$as_me:$LINENO: error: no argument expected for --with-unixodbc option" >&5
echo "$as_me: error: no argument expected for --with-unixodbc option" >&2;}
{ (exit 1); exit 1; }; }
;;
esac
else
with_unixodbc=no
fi;
# Check whether --with-iodbc or --without-iodbc was given.
if test "${with_iodbc+set}" = set; then
withval="$with_iodbc"
case $withval in
yes)
:
;;
no)
:
;;
*)
{ { echo "$as_me:$LINENO: error: no argument expected for --with-iodbc option" >&5
echo "$as_me: error: no argument expected for --with-iodbc option" >&2;}
{ (exit 1); exit 1; }; }
;;
esac
else
with_iodbc=no
fi;
if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
{ { echo "$as_me:$LINENO: error: ODBC driver cannot be built for both unixODBC and iODBC" >&5
echo "$as_me: error: ODBC driver cannot be built for both unixODBC and iODBC" >&2;}
{ (exit 1); exit 1; }; }
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) echo "$as_me:$LINENO: result: yes (stand-alone)" >&5
echo "${ECHO_T}yes (stand-alone)" >&6;;
yes:yes:no) echo "$as_me:$LINENO: result: yes (unixODBC)" >&5
echo "${ECHO_T}yes (unixODBC)" >&6
cat >>confdefs.h <<\_ACEOF
#define WITH_UNIXODBC 1
_ACEOF
;;
yes:no:yes) echo "$as_me:$LINENO: result: yes (iODBC)" >&5
echo "${ECHO_T}yes (iODBC)" >&6
cat >>confdefs.h <<\_ACEOF
#define WITH_IODBC 1
_ACEOF
;;
no:*) echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6;;
esac
# Allow for overriding the default location of the odbcinst.ini
# file which is normally ${sysconfdir} (i.e., ${prefix}/etc).
# Check whether --with-odbcinst or --without-odbcinst was given.
if test "${with_odbcinst+set}" = set; then
withval="$with_odbcinst"
case $withval in
yes)
{ { echo "$as_me:$LINENO: error: argument required for --with-odbcinst option" >&5
echo "$as_me: error: argument required for --with-odbcinst option" >&2;}
{ (exit 1); exit 1; }; }
;;
no)
{ { echo "$as_me:$LINENO: error: argument required for --with-odbcinst option" >&5
echo "$as_me: error: argument required for --with-odbcinst option" >&2;}
{ (exit 1); exit 1; }; }
;;
*)
odbcinst_ini_dir=$withval
;;
esac
else
odbcinst_ini_dir="\${sysconfdir}"
fi;
# Assume system is ELF if it predefines __ELF__ as 1,
# otherwise believe host_os based default.
case $host_os in
@ -16459,10 +16299,6 @@ s,@with_krb5@,$with_krb5,;t t
s,@krb_srvtab@,$krb_srvtab,;t t
s,@with_pam@,$with_pam,;t t
s,@with_openssl@,$with_openssl,;t t
s,@enable_odbc@,$enable_odbc,;t t
s,@with_unixodbc@,$with_unixodbc,;t t
s,@with_iodbc@,$with_iodbc,;t t
s,@odbcinst_ini_dir@,$odbcinst_ini_dir,;t t
s,@ELF_SYS@,$ELF_SYS,;t t
s,@AWK@,$AWK,;t t
s,@FLEX@,$FLEX,;t t

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.196 2002/08/22 00:15:06 scrappy Exp $
dnl $Header: /cvsroot/pgsql/configure.in,v 1.197 2002/08/22 22:43:08 scrappy Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -511,50 +511,6 @@ PGAC_ARG_BOOL(with, zlib, yes,
#
# Optionally enable the building of the ODBC driver
#
# Old option name
if test "${with_odbc+set}" = set && test "${enable_odbc+set}" != set; then
enable_odbc=$with_odbc
fi
AC_MSG_CHECKING([whether to build the ODBC driver])
PGAC_ARG_BOOL(enable, odbc, no, [ --enable-odbc build the ODBC driver package])
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, 1, [Define to 1 to build with unixODBC support (--with-unixodbc)])
;;
yes:no:yes) AC_MSG_RESULT([yes (iODBC)])
AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support (--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
# file which is normally ${sysconfdir} (i.e., ${prefix}/etc).
PGAC_ARG_REQ(with, odbcinst,
[ --with-odbcinst=DIR default directory for odbcinst.ini [sysconfdir]],
[odbcinst_ini_dir=$withval],
[odbcinst_ini_dir="\${sysconfdir}"])
AC_SUBST([odbcinst_ini_dir])
# Assume system is ELF if it predefines __ELF__ as 1,
# otherwise believe host_os based default.
case $host_os in

View File

@ -1,5 +1,5 @@
# -*-makefile-*-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.152 2002/07/27 20:10:04 petere Exp $
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.153 2002/08/22 22:43:10 scrappy Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
@ -111,8 +111,6 @@ override docdir := $(docdir)/postgresql
endif
endif
odbcinst_ini_dir = @odbcinst_ini_dir@
javadir := $(DESTDIR)$(datadir)/java
localedir := @localedir@
@ -129,9 +127,6 @@ with_perl = @with_perl@
with_python = @with_python@
with_tcl = @with_tcl@
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

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.46 2002/08/22 00:15:10 scrappy Exp $
# $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.47 2002/08/22 22:43:11 scrappy Exp $
#
#-------------------------------------------------------------------------
@ -14,11 +14,7 @@ include $(top_builddir)/src/Makefile.global
DIRS := libpq ecpg libpgeasy
ALLDIRS := $(DIRS) odbc libpgtcl perl5 python jdbc
ifeq ($(enable_odbc), yes)
DIRS += odbc
endif
ALLDIRS := $(DIRS) libpgtcl perl5 python jdbc
ifeq ($(with_tcl), yes)
DIRS += libpgtcl

View File

@ -1,72 +0,0 @@
#-------------------------------------------------------------------------
#
# GNUMakefile for psqlodbc (Postgres ODBC driver)
#
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.23 2001/11/12 00:54:28 inoue Exp $
#
#-------------------------------------------------------------------------
subdir = src/interfaces/odbc
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) -DFRONTEND -DMD5_ODBC
OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
environ.o execute.o lobj.o md5.o misc.o options.o \
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
tuple.o tuplelist.o dlg_specific.o odbcapi.o
ifdef MULTIBYTE
OBJS += multibyte.o
endif
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
override CPPFLAGS += -DODBCINSTDIR='"$(odbcinst_ini_dir)"'
endif
all: all-lib odbc-drop.sql
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib
# Symbols must be resolved to the version in the shared library because
# the driver manager (e.g., iodbc) provides some symbols with the same
# names and we don't want those. (This issue is probably ELF specific.)
LINK.shared += $(shlib_symbolic)
odbc-drop.sql: odbc.sql
sed -n '/^CREATE OR REPLACE FUNCTION/s/CREATE OR REPLACE FUNCTION \([^ (][^ (]*([^)]*)\).*/DROP FUNCTION \1;/p' $< >$@
install: all installdirs
$(INSTALL_DATA) $(srcdir)/odbc.sql $(DESTDIR)$(datadir)/odbc.sql
$(INSTALL_DATA) odbc-drop.sql $(DESTDIR)$(datadir)/odbc-drop.sql
$(MAKE) install-lib
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(datadir)
uninstall: uninstall-lib
rm -f $(DESTDIR)$(datadir)/odbc.sql $(DESTDIR)$(datadir)/odbc-drop.sql
clean distclean maintainer-clean: clean-lib
rm -f $(OBJS)
rm -f odbc-drop.sql

View File

@ -1,638 +0,0 @@
/*-------
* Module: bind.c
*
* Description: This module contains routines related to binding
* columns and parameters.
*
* Classes: BindInfoClass, ParameterInfoClass
*
* API functions: SQLBindParameter, SQLBindCol, SQLDescribeParam, SQLNumParams,
* SQLParamOptions
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "bind.h"
#include "environ.h"
#include "statement.h"
#include "descriptor.h"
#include "qresult.h"
#include "pgtypes.h"
#include <stdlib.h>
#include <string.h>
#include "pgapifunc.h"
/* Bind parameters on a statement handle */
RETCODE SQL_API
PGAPI_BindParameter(
HSTMT hstmt,
UWORD ipar,
SWORD fParamType,
SWORD fCType,
SWORD fSqlType,
UDWORD cbColDef,
SWORD ibScale,
PTR rgbValue,
SDWORD cbValueMax,
SDWORD FAR * pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_BindParameter";
APDFields *opts;
mylog("%s: entering...\n", func);
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
SC_clear_error(stmt);
opts = SC_get_APD(stmt);
if (opts->allocated < ipar)
extend_parameter_bindings(opts, ipar);
/* use zero based column numbers for the below part */
ipar--;
/* store the given info */
opts->parameters[ipar].buflen = cbValueMax;
opts->parameters[ipar].buffer = rgbValue;
opts->parameters[ipar].used = pcbValue;
opts->parameters[ipar].paramType = fParamType;
opts->parameters[ipar].CType = fCType;
opts->parameters[ipar].SQLType = fSqlType;
opts->parameters[ipar].column_size = cbColDef;
opts->parameters[ipar].decimal_digits = ibScale;
opts->parameters[ipar].precision = 0;
opts->parameters[ipar].scale = 0;
#if (ODBCVER >= 0x0300)
switch (fCType)
{
case SQL_C_NUMERIC:
if (cbColDef > 0)
opts->parameters[ipar].precision = (UInt2) cbColDef;
if (ibScale > 0)
opts->parameters[ipar].scale = ibScale;
break;
case SQL_C_TYPE_TIMESTAMP:
if (ibScale > 0)
opts->parameters[ipar].precision = ibScale;
break;
}
#endif /* ODBCVER */
/*
* If rebinding a parameter that had data-at-exec stuff in it, then
* free that stuff
*/
if (opts->parameters[ipar].EXEC_used)
{
free(opts->parameters[ipar].EXEC_used);
opts->parameters[ipar].EXEC_used = NULL;
}
if (opts->parameters[ipar].EXEC_buffer)
{
if (opts->parameters[ipar].SQLType != SQL_LONGVARBINARY)
free(opts->parameters[ipar].EXEC_buffer);
opts->parameters[ipar].EXEC_buffer = NULL;
}
if (pcbValue && opts->param_offset_ptr)
pcbValue += (*opts->param_offset_ptr >> 2);
/* Data at exec macro only valid for C char/binary data */
if (pcbValue && (*pcbValue == SQL_DATA_AT_EXEC ||
*pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET))
opts->parameters[ipar].data_at_exec = TRUE;
else
opts->parameters[ipar].data_at_exec = FALSE;
/* Clear premature result */
if (stmt->status == STMT_PREMATURE)
SC_recycle_statement(stmt);
mylog("PGAPI_BindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue = %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue : -777, opts->parameters[ipar].data_at_exec);
return SQL_SUCCESS;
}
/* Associate a user-supplied buffer with a database column. */
RETCODE SQL_API
PGAPI_BindCol(
HSTMT hstmt,
UWORD icol,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
SDWORD FAR * pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_BindCol";
ARDFields *opts;
mylog("%s: entering...\n", func);
mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n", stmt, icol);
mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue);
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
opts = SC_get_ARD(stmt);
if (stmt->status == STMT_EXECUTING)
{
stmt->errormsg = "Can't bind columns while statement is still executing.";
stmt->errornumber = STMT_SEQUENCE_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
SC_clear_error(stmt);
/* If the bookmark column is being bound, then just save it */
if (icol == 0)
{
if (rgbValue == NULL)
{
opts->bookmark->buffer = NULL;
opts->bookmark->used = NULL;
}
else
{
/* Make sure it is the bookmark data type */
if (fCType == SQL_C_BOOKMARK)
switch (fCType)
{
case SQL_C_BOOKMARK:
#if (ODBCVER >= 0x0300)
case SQL_C_VARBOOKMARK:
#endif /* ODBCVER */
break;
default:
stmt->errormsg = "Column 0 is not of type SQL_C_BOOKMARK";
inolog("Column 0 is type %d not of type SQL_C_BOOKMARK", fCType);
stmt->errornumber = STMT_PROGRAM_TYPE_OUT_OF_RANGE;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
opts->bookmark->buffer = rgbValue;
opts->bookmark->used = pcbValue;
}
return SQL_SUCCESS;
}
/*
* Allocate enough bindings if not already done. Most likely,
* execution of a statement would have setup the necessary bindings.
* But some apps call BindCol before any statement is executed.
*/
if (icol > opts->allocated)
extend_column_bindings(opts, icol);
/* check to see if the bindings were allocated */
if (!opts->bindings)
{
stmt->errormsg = "Could not allocate memory for bindings.";
stmt->errornumber = STMT_NO_MEMORY_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
/* use zero based col numbers from here out */
icol--;
/* Reset for SQLGetData */
opts->bindings[icol].data_left = -1;
if (rgbValue == NULL)
{
/* we have to unbind the column */
opts->bindings[icol].buflen = 0;
opts->bindings[icol].buffer = NULL;
opts->bindings[icol].used = NULL;
opts->bindings[icol].returntype = SQL_C_CHAR;
if (opts->bindings[icol].ttlbuf)
free(opts->bindings[icol].ttlbuf);
opts->bindings[icol].ttlbuf = NULL;
opts->bindings[icol].ttlbuflen = 0;
opts->bindings[icol].precision = 0;
opts->bindings[icol].scale = 0;
}
else
{
/* ok, bind that column */
opts->bindings[icol].buflen = cbValueMax;
opts->bindings[icol].buffer = rgbValue;
opts->bindings[icol].used = pcbValue;
opts->bindings[icol].returntype = fCType;
#if (ODBCVER >= 0x0300)
if (SQL_C_NUMERIC == fCType)
opts->bindings[icol].precision = 32;
else
#endif /* ODBCVER */
opts->bindings[icol].precision = 0;
opts->bindings[icol].scale = 0;
mylog(" bound buffer[%d] = %u\n", icol, opts->bindings[icol].buffer);
}
return SQL_SUCCESS;
}
/*
* Returns the description of a parameter marker.
* This function is listed as not being supported by SQLGetFunctions() because it is
* used to describe "parameter markers" (not bound parameters), in which case,
* the dbms should return info on the markers. Since Postgres doesn't support that,
* it is best to say this function is not supported and let the application assume a
* data type (most likely varchar).
*/
RETCODE SQL_API
PGAPI_DescribeParam(
HSTMT hstmt,
UWORD ipar,
SWORD FAR * pfSqlType,
UDWORD FAR * pcbColDef,
SWORD FAR * pibScale,
SWORD FAR * pfNullable)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char *func = "PGAPI_DescribeParam";
APDFields *opts;
mylog("%s: entering...\n", func);
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
SC_clear_error(stmt);
opts = SC_get_APD(stmt);
if ((ipar < 1) || (ipar > opts->allocated))
{
stmt->errormsg = "Invalid parameter number for PGAPI_DescribeParam.";
stmt->errornumber = STMT_BAD_PARAMETER_NUMBER_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
ipar--;
/*
* This implementation is not very good, since it is supposed to
* describe
*/
/* parameter markers, not bound parameters. */
if (pfSqlType)
*pfSqlType = opts->parameters[ipar].SQLType;
if (pcbColDef)
*pcbColDef = opts->parameters[ipar].column_size;
if (pibScale)
*pibScale = opts->parameters[ipar].decimal_digits;
if (pfNullable)
*pfNullable = pgtype_nullable(stmt, opts->parameters[ipar].paramType);
return SQL_SUCCESS;
}
/* Sets multiple values (arrays) for the set of parameter markers. */
RETCODE SQL_API
PGAPI_ParamOptions(
HSTMT hstmt,
UDWORD crow,
UDWORD FAR * pirow)
{
static char *func = "PGAPI_ParamOptions";
StatementClass *stmt = (StatementClass *) hstmt;
APDFields *opts;
mylog("%s: entering... %d %x\n", func, crow, pirow);
opts = SC_get_APD(stmt);
opts->paramset_size = crow;
SC_get_IPD(stmt)->param_processed_ptr = (UInt4 *) pirow;
return SQL_SUCCESS;
}
/*
* This function should really talk to the dbms to determine the number of
* "parameter markers" (not bound parameters) in the statement. But, since
* Postgres doesn't support that, the driver should just count the number of markers
* and return that. The reason the driver just can't say this function is unsupported
* like it does for SQLDescribeParam is that some applications don't care and try
* to call it anyway.
* If the statement does not have parameters, it should just return 0.
*/
RETCODE SQL_API
PGAPI_NumParams(
HSTMT hstmt,
SWORD FAR * pcpar)
{
StatementClass *stmt = (StatementClass *) hstmt;
char in_quote = FALSE;
unsigned int i;
static char *func = "PGAPI_NumParams";
mylog("%s: entering...\n", func);
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
SC_clear_error(stmt);
if (pcpar)
*pcpar = 0;
else
{
SC_log_error(func, "pcpar was null", stmt);
return SQL_ERROR;
}
if (!stmt->statement)
{
/* no statement has been allocated */
stmt->errormsg = "PGAPI_NumParams called with no statement ready.";
stmt->errornumber = STMT_SEQUENCE_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
else
{
for (i = 0; i < strlen(stmt->statement); i++)
{
if (stmt->statement[i] == '?' && !in_quote)
(*pcpar)++;
else
{
if (stmt->statement[i] == '\'')
in_quote = (in_quote ? FALSE : TRUE);
}
}
return SQL_SUCCESS;
}
}
/*
* Bindings Implementation
*/
BindInfoClass *
create_empty_bindings(int num_columns)
{
BindInfoClass *new_bindings;
int i;
new_bindings = (BindInfoClass *) malloc(num_columns * sizeof(BindInfoClass));
if (!new_bindings)
return 0;
for (i = 0; i < num_columns; i++)
{
new_bindings[i].buflen = 0;
new_bindings[i].buffer = NULL;
new_bindings[i].used = NULL;
new_bindings[i].data_left = -1;
new_bindings[i].ttlbuf = NULL;
new_bindings[i].ttlbuflen = 0;
}
return new_bindings;
}
void
extend_parameter_bindings(APDFields *self, int num_params)
{
static char *func = "extend_parameter_bindings";
ParameterInfoClass *new_bindings;
mylog("%s: entering ... self=%u, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params);
/*
* if we have too few, allocate room for more, and copy the old
* entries into the new structure
*/
if (self->allocated < num_params)
{
new_bindings = (ParameterInfoClass *) realloc(self->parameters, sizeof(ParameterInfoClass) * num_params);
if (!new_bindings)
{
mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_params, self->allocated);
self->parameters = NULL;
self->allocated = 0;
return;
}
memset(&new_bindings[self->allocated], 0,
sizeof(ParameterInfoClass) * (num_params - self->allocated));
self->parameters = new_bindings;
self->allocated = num_params;
}
mylog("exit extend_parameter_bindings\n");
}
void
reset_a_parameter_binding(APDFields *self, int ipar)
{
static char *func = "reset_a_parameter_binding";
mylog("%s: entering ... self=%u, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar);
if (ipar < 1 || ipar > self->allocated)
return;
ipar--;
self->parameters[ipar].buflen = 0;
self->parameters[ipar].buffer = 0;
self->parameters[ipar].used = 0;
self->parameters[ipar].paramType = 0;
self->parameters[ipar].CType = 0;
if (self->parameters[ipar].EXEC_used)
{
free(self->parameters[ipar].EXEC_used);
self->parameters[ipar].EXEC_used = NULL;
}
if (self->parameters[ipar].EXEC_buffer)
{
if (self->parameters[ipar].SQLType != SQL_LONGVARBINARY)
free(self->parameters[ipar].EXEC_buffer);
self->parameters[ipar].EXEC_buffer = NULL;
}
self->parameters[ipar].SQLType = 0;
self->parameters[ipar].column_size = 0;
self->parameters[ipar].decimal_digits = 0;
self->parameters[ipar].precision = 0;
self->parameters[ipar].scale = 0;
self->parameters[ipar].data_at_exec = FALSE;
self->parameters[ipar].lobj_oid = 0;
}
/*
* Free parameters and free the memory.
*/
void
APD_free_params(APDFields *self, char option)
{
int i;
mylog("APD_free_params: ENTER, self=%d\n", self);
if (!self->parameters)
return;
for (i = 0; i < self->allocated; i++)
{
if (self->parameters[i].data_at_exec)
{
if (self->parameters[i].EXEC_used)
{
free(self->parameters[i].EXEC_used);
self->parameters[i].EXEC_used = NULL;
}
if (self->parameters[i].EXEC_buffer)
{
if (self->parameters[i].SQLType != SQL_LONGVARBINARY)
free(self->parameters[i].EXEC_buffer);
self->parameters[i].EXEC_buffer = NULL;
}
}
}
if (option == STMT_FREE_PARAMS_ALL)
{
if (self->parameters);
free(self->parameters);
self->parameters = NULL;
self->allocated = 0;
}
mylog("APD_free_params: EXIT\n");
}
void
extend_column_bindings(ARDFields *self, int num_columns)
{
static char *func = "extend_column_bindings";
BindInfoClass *new_bindings;
int i;
mylog("%s: entering ... self=%u, bindings_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns);
/*
* if we have too few, allocate room for more, and copy the old
* entries into the new structure
*/
if (self->allocated < num_columns)
{
new_bindings = create_empty_bindings(num_columns);
if (!new_bindings)
{
mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_columns, self->allocated);
if (self->bindings)
{
free(self->bindings);
self->bindings = NULL;
}
self->allocated = 0;
return;
}
if (self->bindings)
{
for (i = 0; i < self->allocated; i++)
new_bindings[i] = self->bindings[i];
free(self->bindings);
}
self->bindings = new_bindings;
self->allocated = num_columns;
}
/*
* There is no reason to zero out extra bindings if there are more
* than needed. If an app has allocated extra bindings, let it worry
* about it by unbinding those columns.
*/
/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
/* SQLExecDirect(...) # returns 5 cols */
/* SQLExecDirect(...) # returns 10 cols (now OK) */
mylog("exit extend_column_bindings\n");
}
void
reset_a_column_binding(ARDFields *self, int icol)
{
static char *func = "reset_a_column_binding";
mylog("%s: entering ... self=%u, bindings_allocated=%d, icol=%d\n", func, self, self->allocated, icol);
if (icol > self->allocated)
return;
/* use zero based col numbers from here out */
if (0 == icol)
{
self->bookmark->buffer = NULL;
self->bookmark->used = NULL;
}
else
{
icol--;
/* we have to unbind the column */
self->bindings[icol].buflen = 0;
self->bindings[icol].buffer = NULL;
self->bindings[icol].used = NULL;
self->bindings[icol].data_left = -1;
self->bindings[icol].returntype = SQL_C_CHAR;
if (self->bindings[icol].ttlbuf)
free(self->bindings[icol].ttlbuf);
self->bindings[icol].ttlbuf = NULL;
self->bindings[icol].ttlbuflen = 0;
}
}
void ARD_unbind_cols(ARDFields *self, BOOL freeall)
{
Int2 lf;
for (lf = 1; lf <= self->allocated; lf++)
reset_a_column_binding(self, lf);
if (freeall)
{
if (self->bindings)
free(self->bindings);
self->bindings = NULL;
self->allocated = 0;
}
}

View File

@ -1,62 +0,0 @@
/* File: bind.h
*
* Description: See "bind.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __BIND_H__
#define __BIND_H__
#include "psqlodbc.h"
/*
* BindInfoClass -- stores information about a bound column
*/
struct BindInfoClass_
{
Int4 buflen; /* size of buffer */
Int4 data_left; /* amount of data left to read
* (SQLGetData) */
char *buffer; /* pointer to the buffer */
Int4 *used; /* used space in the buffer (for strings
* not counting the '\0') */
char *ttlbuf; /* to save the large result */
Int4 ttlbuflen; /* the buffer length */
Int2 returntype; /* kind of conversion to be applied when
* returning (SQL_C_DEFAULT,
* SQL_C_CHAR...) */
Int2 precision; /* the precision for numeric or timestamp type */
Int2 scale; /* the scale for numeric type */
};
/*
* ParameterInfoClass -- stores information about a bound parameter
*/
struct ParameterInfoClass_
{
Int4 buflen;
char *buffer;
Int4 *used;
Int2 paramType;
Int2 CType;
Int2 SQLType;
Int2 decimal_digits;
UInt4 column_size;
Oid lobj_oid;
Int4 *EXEC_used; /* amount of data OR the oid of the large
* object */
char *EXEC_buffer; /* the data or the FD of the large object */
Int2 precision; /* the precision for numeric or timestamp type */
Int2 scale; /* the scale for numeric type */
char data_at_exec;
};
BindInfoClass *create_empty_bindings(int num_columns);
void extend_column_bindings(ARDFields *opts, int num_columns);
void reset_a_column_binding(ARDFields *opts, int icol);
void extend_parameter_bindings(APDFields *opts, int num_columns);
void reset_a_parameter_binding(APDFields *opts, int ipar);
#endif

View File

@ -1,191 +0,0 @@
/*-------
* Module: columninfo.c
*
* Description: This module contains routines related to
* reading and storing the field information from a query.
*
* Classes: ColumnInfoClass (Functions prefix: "CI_")
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "pgtypes.h"
#include "columninfo.h"
#include "connection.h"
#include "socket.h"
#include <stdlib.h>
#include <string.h>
#include "pgapifunc.h"
ColumnInfoClass *
CI_Constructor()
{
ColumnInfoClass *rv;
rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass));
if (rv)
{
rv->num_fields = 0;
rv->name = NULL;
rv->adtid = NULL;
rv->adtsize = NULL;
rv->display_size = NULL;
rv->atttypmod = NULL;
}
return rv;
}
void
CI_Destructor(ColumnInfoClass *self)
{
CI_free_memory(self);
free(self);
}
/*
* Read in field descriptions.
* If self is not null, then also store the information.
* If self is null, then just read, don't store.
*/
char
CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
{
Int2 lf;
int new_num_fields;
Oid new_adtid;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
/* MAX_COLUMN_LEN may be sufficient but for safety */
char new_field_name[2 * MAX_COLUMN_LEN + 1];
SocketClass *sock;
ConnInfo *ci;
sock = CC_get_socket(conn);
ci = &conn->connInfo;
/* at first read in the number of fields that are in the query */
new_num_fields = (Int2) SOCK_get_int(sock, sizeof(Int2));
mylog("num_fields = %d\n", new_num_fields);
if (self)
/* according to that allocate memory */
CI_set_num_fields(self, new_num_fields);
/* now read in the descriptions */
for (lf = 0; lf < new_num_fields; lf++)
{
SOCK_get_string(sock, new_field_name, 2 * MAX_COLUMN_LEN);
new_adtid = (Oid) SOCK_get_int(sock, 4);
new_adtsize = (Int2) SOCK_get_int(sock, 2);
/* If 6.4 protocol, then read the atttypmod field */
if (PG_VERSION_GE(conn, 6.4))
{
mylog("READING ATTTYPMOD\n");
new_atttypmod = (Int4) SOCK_get_int(sock, 4);
/* Subtract the header length */
switch (new_adtid)
{
case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP_NO_TMZONE:
case PG_TYPE_TIME:
case PG_TYPE_TIME_WITH_TMZONE:
break;
default:
new_atttypmod -= 4;
}
if (new_atttypmod < 0)
new_atttypmod = -1;
}
mylog("CI_read_fields: fieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d\n", new_field_name, new_adtid, new_adtsize, new_atttypmod);
if (self)
CI_set_field_info(self, lf, new_field_name, new_adtid, new_adtsize, new_atttypmod);
}
return (SOCK_get_errcode(sock) == 0);
}
void
CI_free_memory(ColumnInfoClass *self)
{
register Int2 lf;
int num_fields = self->num_fields;
for (lf = 0; lf < num_fields; lf++)
{
if (self->name[lf])
{
free(self->name[lf]);
self->name[lf] = NULL;
}
}
/* Safe to call even if null */
self->num_fields = 0;
if (self->name)
free(self->name);
self->name = NULL;
if (self->adtid)
free(self->adtid);
self->adtid = NULL;
if (self->adtsize)
free(self->adtsize);
self->adtsize = NULL;
if (self->display_size)
free(self->display_size);
self->display_size = NULL;
if (self->atttypmod)
free(self->atttypmod);
self->atttypmod = NULL;
}
void
CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
{
CI_free_memory(self); /* always safe to call */
self->num_fields = new_num_fields;
self->name = (char **) malloc(sizeof(char *) * self->num_fields);
memset(self->name, 0, sizeof(char *) * self->num_fields);
self->adtid = (Oid *) malloc(sizeof(Oid) * self->num_fields);
self->adtsize = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->display_size = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->atttypmod = (Int4 *) malloc(sizeof(Int4) * self->num_fields);
}
void
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{
/* check bounds */
if ((field_num < 0) || (field_num >= self->num_fields))
return;
/* store the info */
self->name[field_num] = strdup(new_name);
self->adtid[field_num] = new_adtid;
self->adtsize[field_num] = new_adtsize;
self->atttypmod[field_num] = new_atttypmod;
self->display_size[field_num] = 0;
}

View File

@ -1,42 +0,0 @@
/* File: columninfo.h
*
* Description: See "columninfo.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __COLUMNINFO_H__
#define __COLUMNINFO_H__
#include "psqlodbc.h"
struct ColumnInfoClass_
{
Int2 num_fields;
char **name; /* list of type names */
Oid *adtid; /* list of type ids */
Int2 *adtsize; /* list type sizes */
Int2 *display_size; /* the display size (longest row) */
Int4 *atttypmod; /* the length of bpchar/varchar */
};
#define CI_get_num_fields(self) (self->num_fields)
#define CI_get_oid(self, col) (self->adtid[col])
#define CI_get_fieldname(self, col) (self->name[col])
#define CI_get_fieldsize(self, col) (self->adtsize[col])
#define CI_get_display_size(self, col) (self->display_size[col])
#define CI_get_atttypmod(self, col) (self->atttypmod[col])
ColumnInfoClass *CI_Constructor(void);
void CI_Destructor(ColumnInfoClass *self);
void CI_free_memory(ColumnInfoClass *self);
char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn);
/* functions for setting up the fields from within the program, */
/* without reading from a socket */
void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields);
void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 atttypmod);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,359 +0,0 @@
/* File: connection.h
*
* Description: See "connection.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __CONNECTION_H__
#define __CONNECTION_H__
#include "psqlodbc.h"
#include <stdlib.h>
#include <string.h>
#include "descriptor.h"
typedef enum
{
CONN_NOT_CONNECTED, /* Connection has not been established */
CONN_CONNECTED, /* Connection is up and has been
* established */
CONN_DOWN, /* Connection is broken */
CONN_EXECUTING /* the connection is currently executing a
* statement */
} CONN_Status;
/* These errors have general sql error state */
#define CONNECTION_SERVER_NOT_REACHED 101
#define CONNECTION_MSG_TOO_LONG 103
#define CONNECTION_COULD_NOT_SEND 104
#define CONNECTION_NO_SUCH_DATABASE 105
#define CONNECTION_BACKEND_CRAZY 106
#define CONNECTION_NO_RESPONSE 107
#define CONNECTION_SERVER_REPORTED_ERROR 108
#define CONNECTION_COULD_NOT_RECEIVE 109
#define CONNECTION_SERVER_REPORTED_WARNING 110
#define CONNECTION_NEED_PASSWORD 112
/* These errors correspond to specific SQL states */
#define CONN_INIREAD_ERROR 201
#define CONN_OPENDB_ERROR 202
#define CONN_STMT_ALLOC_ERROR 203
#define CONN_IN_USE 204
#define CONN_UNSUPPORTED_OPTION 205
/* Used by SetConnectoption to indicate unsupported options */
#define CONN_INVALID_ARGUMENT_NO 206
/* SetConnectOption: corresponds to ODBC--"S1009" */
#define CONN_TRANSACT_IN_PROGRES 207
#define CONN_NO_MEMORY_ERROR 208
#define CONN_NOT_IMPLEMENTED_ERROR 209
#define CONN_INVALID_AUTHENTICATION 210
#define CONN_AUTH_TYPE_UNSUPPORTED 211
#define CONN_UNABLE_TO_LOAD_DLL 212
#define CONN_OPTION_VALUE_CHANGED 213
#define CONN_VALUE_OUT_OF_RANGE 214
#define CONN_TRUNCATED 215
/* Conn_status defines */
#define CONN_IN_AUTOCOMMIT 0x01
#define CONN_IN_TRANSACTION 0x02
/* AutoCommit functions */
#define CC_set_autocommit_off(x) (x->transact_status &= ~CONN_IN_AUTOCOMMIT)
#define CC_set_autocommit_on(x) (x->transact_status |= CONN_IN_AUTOCOMMIT)
#define CC_is_in_autocommit(x) (x->transact_status & CONN_IN_AUTOCOMMIT)
/* Transaction in/not functions */
#define CC_set_in_trans(x) (x->transact_status |= CONN_IN_TRANSACTION)
#define CC_set_no_trans(x) (x->transact_status &= ~CONN_IN_TRANSACTION)
#define CC_is_in_trans(x) (x->transact_status & CONN_IN_TRANSACTION)
/* Authentication types */
#define AUTH_REQ_OK 0
#define AUTH_REQ_KRB4 1
#define AUTH_REQ_KRB5 2
#define AUTH_REQ_PASSWORD 3
#define AUTH_REQ_CRYPT 4
#define AUTH_REQ_MD5 5
#define AUTH_REQ_SCM_CREDS 6
/* Startup Packet sizes */
#define SM_DATABASE 64
#define SM_USER 32
#define SM_OPTIONS 64
#define SM_UNUSED 64
#define SM_TTY 64
/* Old 6.2 protocol defines */
#define NO_AUTHENTICATION 7
#define PATH_SIZE 64
#define ARGV_SIZE 64
#define USRNAMEDATALEN 16
typedef unsigned int ProtocolVersion;
#define PG_PROTOCOL(major, minor) (((major) << 16) | (minor))
#define PG_PROTOCOL_LATEST PG_PROTOCOL(2, 0)
#define PG_PROTOCOL_63 PG_PROTOCOL(1, 0)
#define PG_PROTOCOL_62 PG_PROTOCOL(0, 0)
/* This startup packet is to support latest Postgres protocol (6.4, 6.3) */
typedef struct _StartupPacket
{
ProtocolVersion protoVersion;
char database[SM_DATABASE];
char user[SM_USER];
char options[SM_OPTIONS];
char unused[SM_UNUSED];
char tty[SM_TTY];
} StartupPacket;
/* This startup packet is to support pre-Postgres 6.3 protocol */
typedef struct _StartupPacket6_2
{
unsigned int authtype;
char database[PATH_SIZE];
char user[USRNAMEDATALEN];
char options[ARGV_SIZE];
char execfile[ARGV_SIZE];
char tty[PATH_SIZE];
} StartupPacket6_2;
/* Transferred from pqcomm.h: */
typedef ProtocolVersion MsgType;
#define PG_PROTOCOL(m,n) (((m) << 16) | (n))
#define CANCEL_REQUEST_CODE PG_PROTOCOL(1234,5678)
typedef struct CancelRequestPacket
{
/* Note that each field is stored in network byte order! */
MsgType cancelRequestCode; /* code to identify a cancel request */
unsigned int backendPID; /* PID of client's backend */
unsigned int cancelAuthCode; /* secret key to authorize cancel */
} CancelRequestPacket;
/* Structure to hold all the connection attributes for a specific
connection (used for both registry and file, DSN and DRIVER)
*/
typedef struct
{
char dsn[MEDIUM_REGISTRY_LEN];
char desc[MEDIUM_REGISTRY_LEN];
char driver[MEDIUM_REGISTRY_LEN];
char server[MEDIUM_REGISTRY_LEN];
char database[MEDIUM_REGISTRY_LEN];
char username[MEDIUM_REGISTRY_LEN];
char password[MEDIUM_REGISTRY_LEN];
char conn_settings[LARGE_REGISTRY_LEN];
char protocol[SMALL_REGISTRY_LEN];
char port[SMALL_REGISTRY_LEN];
char onlyread[SMALL_REGISTRY_LEN];
char fake_oid_index[SMALL_REGISTRY_LEN];
char show_oid_column[SMALL_REGISTRY_LEN];
char row_versioning[SMALL_REGISTRY_LEN];
char show_system_tables[SMALL_REGISTRY_LEN];
char translation_dll[MEDIUM_REGISTRY_LEN];
char translation_option[SMALL_REGISTRY_LEN];
char focus_password;
char disallow_premature;
char allow_keyset;
char updatable_cursors;
char lf_conversion;
char true_is_minus1;
char int8_as;
GLOBAL_VALUES drivers; /* moved from driver's option */
} ConnInfo;
/* Macro to determine is the connection using 6.2 protocol? */
#define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)
/* Macro to determine is the connection using 6.3 protocol? */
#define PROTOCOL_63(conninfo_) (strncmp((conninfo_)->protocol, PG63, strlen(PG63)) == 0)
/*
* Macros to compare the server's version with a specified version
* 1st parameter: pointer to a ConnectionClass object
* 2nd parameter: major version number
* 3rd parameter: minor version number
*/
#define SERVER_VERSION_GT(conn, major, minor) \
((conn)->pg_version_major > major || \
((conn)->pg_version_major == major && (conn)->pg_version_minor > minor))
#define SERVER_VERSION_GE(conn, major, minor) \
((conn)->pg_version_major > major || \
((conn)->pg_version_major == major && (conn)->pg_version_minor >= minor))
#define SERVER_VERSION_EQ(conn, major, minor) \
((conn)->pg_version_major == major && (conn)->pg_version_minor == minor)
#define SERVER_VERSION_LE(conn, major, minor) (! SERVER_VERSION_GT(conn, major, minor))
#define SERVER_VERSION_LT(conn, major, minor) (! SERVER_VERSION_GE(conn, major, minor))
/*#if ! defined(HAVE_CONFIG_H) || defined(HAVE_STRINGIZE)*/
#define STRING_AFTER_DOT(string) (strchr(#string, '.') + 1)
/*#else
#define STRING_AFTER_DOT(str) (strchr("str", '.') + 1)
#endif*/
/*
* Simplified macros to compare the server's version with a
* specified version
* Note: Never pass a variable as the second parameter.
* It must be a decimal constant of the form %d.%d .
*/
#define PG_VERSION_GT(conn, ver) \
(SERVER_VERSION_GT(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))
#define PG_VERSION_GE(conn, ver) \
(SERVER_VERSION_GE(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))
#define PG_VERSION_EQ(conn, ver) \
(SERVER_VERSION_EQ(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))
#define PG_VERSION_LE(conn, ver) (! PG_VERSION_GT(conn, ver))
#define PG_VERSION_LT(conn, ver) (! PG_VERSION_GE(conn, ver))
/* This is used to store cached table information in the connection */
struct col_info
{
QResultClass *result;
char *schema;
char name[MAX_TABLE_LEN + 1];
};
/* Translation DLL entry points */
#ifdef WIN32
#define DLLHANDLE HINSTANCE
#else
#define WINAPI CALLBACK
#define DLLHANDLE void *
#define HINSTANCE void *
#endif
typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD,
SWORD,
PTR,
SDWORD,
PTR,
SDWORD,
SDWORD FAR *,
UCHAR FAR *,
SWORD,
SWORD FAR *);
typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD,
SWORD,
PTR,
SDWORD,
PTR,
SDWORD,
SDWORD FAR *,
UCHAR FAR *,
SWORD,
SWORD FAR *);
/******* The Connection handle ************/
struct ConnectionClass_
{
HENV henv; /* environment this connection was created
* on */
StatementOptions stmtOptions;
ARDFields ardOptions;
APDFields apdOptions;
char *errormsg;
int errornumber;
CONN_Status status;
ConnInfo connInfo;
StatementClass **stmts;
int num_stmts;
SocketClass *sock;
int lobj_type;
int ntables;
COL_INFO **col_info;
long translation_option;
HINSTANCE translation_handle;
DataSourceToDriverProc DataSourceToDriver;
DriverToDataSourceProc DriverToDataSource;
Int2 driver_version; /* prepared for ODBC3.0 */
char transact_status;/* Is a transaction is currently in
* progress */
char errormsg_created; /* has an informative error msg
* been created? */
char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL
* we're connected to -
* DJP 25-1-2001 */
float pg_version_number;
Int2 pg_version_major;
Int2 pg_version_minor;
char ms_jet;
char unicode;
char result_uncommitted;
char schema_support;
#ifdef MULTIBYTE
char *client_encoding;
char *server_encoding;
#endif /* MULTIBYTE */
int ccsc;
int be_pid; /* pid returned by backend */
int be_key; /* auth code needed to send cancel */
UInt4 isolation;
char *current_schema;
};
/* Accessor functions */
#define CC_get_socket(x) (x->sock)
#define CC_get_database(x) (x->connInfo.database)
#define CC_get_server(x) (x->connInfo.server)
#define CC_get_DSN(x) (x->connInfo.dsn)
#define CC_get_username(x) (x->connInfo.username)
#define CC_is_onlyread(x) (x->connInfo.onlyread[0] == '1')
/* for CC_DSN_info */
#define CONN_DONT_OVERWRITE 0
#define CONN_OVERWRITE 1
/* prototypes */
ConnectionClass *CC_Constructor(void);
void CC_conninfo_init(ConnInfo *conninfo);
char CC_Destructor(ConnectionClass *self);
int CC_cursor_count(ConnectionClass *self);
char CC_cleanup(ConnectionClass *self);
char CC_begin(ConnectionClass *self);
char CC_commit(ConnectionClass *self);
char CC_abort(ConnectionClass *self);
int CC_set_translation(ConnectionClass *self);
char CC_connect(ConnectionClass *self, char password_req, char *salt);
char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
char CC_get_error(ConnectionClass *self, int *number, char **message);
QResultClass *CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag);
void CC_clear_error(ConnectionClass *self);
char *CC_create_errormsg(ConnectionClass *self);
int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);
char CC_send_settings(ConnectionClass *self);
void CC_lookup_lo(ConnectionClass *conn);
void CC_lookup_pg_version(ConnectionClass *conn);
void CC_initialize_pg_version(ConnectionClass *conn);
void CC_log_error(const char *func, const char *desc, const ConnectionClass *self);
int CC_get_max_query_len(const ConnectionClass *self);
int CC_send_cancel_request(const ConnectionClass *conn);
void CC_on_commit(ConnectionClass *conn);
void CC_on_abort(ConnectionClass *conn, UDWORD opt);
void ProcessRollback(ConnectionClass *conn, BOOL undo);
const char *CC_get_current_schema(ConnectionClass *conn);
/* CC_send_query options */
#define CLEAR_RESULT_ON_ABORT 1L
#define CREATE_KEYSET (1L << 1) /* create keyset for updatable curosrs */
#define GO_INTO_TRANSACTION (1L << 2) /* issue begin in advance */
/* CC_on_abort options */
#define NO_TRANS 1L
#define CONN_DEAD (1L << 1) /* connection is no longer valid */
#endif /* __CONNECTION_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,56 +0,0 @@
/* File: convert.h
*
* Description: See "convert.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __CONVERT_H__
#define __CONVERT_H__
#include "psqlodbc.h"
/* copy_and_convert results */
#define COPY_OK 0
#define COPY_UNSUPPORTED_TYPE 1
#define COPY_UNSUPPORTED_CONVERSION 2
#define COPY_RESULT_TRUNCATED 3
#define COPY_GENERAL_ERROR 4
#define COPY_NO_DATA_FOUND 5
/* convert_escape results */
#define CONVERT_ESCAPE_OK 0
#define CONVERT_ESCAPE_OVERFLOW 1
#define CONVERT_ESCAPE_ERROR -1
typedef struct
{
int infinity;
int m;
int d;
int y;
int hh;
int mm;
int ss;
int fr;
} SIMPLE_TIME;
int copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col);
int copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue);
int copy_statement_with_parameters(StatementClass *stmt);
BOOL convert_money(const char *s, char *sout, size_t soutmax);
char parse_datetime(const char *buf, SIMPLE_TIME *st);
int convert_linefeeds(const char *s, char *dst, size_t max, BOOL convlf, BOOL *changed);
int convert_special_chars(const char *si, char *dst, int used, BOOL convlf,int ccsc);
int convert_pgbinary_to_char(const char *value, char *rgbValue, int cbValueMax);
int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax);
int convert_to_pgbinary(const unsigned char *in, char *out, int len);
void encode(const char *in, char *out);
void decode(const char *in, char *out);
int convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue,
SDWORD cbValueMax, SDWORD *pcbValue);
#endif

View File

@ -1,104 +0,0 @@
/* File: descriptor.h
*
* Description: This file contains defines and declarations that are related to
* the entire driver.
*
* Comments: See "notice.txt" for copyright and license information.
*
* $Id: descriptor.h,v 1.6 2002/06/06 04:50:47 inoue Exp $
*
*/
#ifndef __DESCRIPTOR_H__
#define __DESCRIPTOR_H__
#include "psqlodbc.h"
typedef struct
{
COL_INFO *col_info; /* cached SQLColumns info for this table */
char schema[MAX_SCHEMA_LEN + 1];
char name[MAX_TABLE_LEN + 1];
char alias[MAX_TABLE_LEN + 1];
char updatable;
} TABLE_INFO;
typedef struct
{
TABLE_INFO *ti; /* resolve to explicit table names */
int column_size; /* precision in 2.x */
int decimal_digits; /* scale in 2.x */
int display_size;
int length;
int type;
char nullable;
char func;
char expr;
char quote;
char dquote;
char numeric;
char updatable;
char dot[MAX_TABLE_LEN + 1];
char name[MAX_COLUMN_LEN + 1];
char alias[MAX_COLUMN_LEN + 1];
char *schema;
} FIELD_INFO;
Int4 FI_precision(const FIELD_INFO *);
Int4 FI_scale(const FIELD_INFO *);
struct ARDFields_
{
StatementClass *stmt;
int rowset_size;
int bind_size; /* size of each structure if using Row
* Binding */
UInt2 *row_operation_ptr;
UInt4 *row_offset_ptr;
BindInfoClass *bookmark;
BindInfoClass *bindings;
int allocated;
};
struct APDFields_
{
StatementClass *stmt;
int paramset_size;
int param_bind_type; /* size of each structure if using Param
* Binding */
UInt2 *param_operation_ptr;
UInt4 *param_offset_ptr;
ParameterInfoClass *parameters;
int allocated;
};
struct IRDFields_
{
StatementClass *stmt;
UInt4 *rowsFetched;
UInt2 *rowStatusArray;
UInt4 nfields;
FIELD_INFO **fi;
};
struct IPDFields_
{
StatementClass *stmt;
UInt4 *param_processed_ptr;
UInt2 *param_status_ptr;
};
void InitializeARDFields(ARDFields *self);
void InitializeAPDFields(APDFields *self);
/* void InitializeIRDFields(IRDFields *self);
void InitializeIPDFiedls(IPDFields *self); */
void ARDFields_free(ARDFields *self);
void APDFields_free(APDFields *self);
void IRDFields_free(IRDFields *self);
void IPDFields_free(IPDFields *self);
void ARD_unbind_cols(ARDFields *self, BOOL freeall);
void APD_free_params(APDFields *self, char option);
#if (ODBCVER >= 0x0300)
void Desc_set_error(SQLHDESC hdesc, int errornumber, const char * errormsg);
#endif /* ODBCVER */
#endif

View File

@ -1,971 +0,0 @@
/*-------
* Module: dlg_specific.c
*
* Description: This module contains any specific code for handling
* dialog boxes such as driver/datasource options. Both the
* ConfigDSN() and the SQLDriverConnect() functions use
* functions in this module. If you were to add a new option
* to any dialog box, you would most likely only have to change
* things in here rather than in 2 separate places as before.
*
* Classes: none
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
#include "dlg_specific.h"
#include "convert.h"
#ifdef MULTIBYTE
#include "multibyte.h"
#endif
#include "pgapifunc.h"
#ifndef BOOL
#define BOOL int
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
#ifndef TRUE
#define TRUE (BOOL)1
#endif
extern GLOBAL_VALUES globals;
void
makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
{
char got_dsn = (ci->dsn[0] != '\0');
char encoded_conn_settings[LARGE_REGISTRY_LEN];
UWORD hlen;
/*BOOL abbrev = (len <= 400);*/
BOOL abbrev = (len < 1024);
/* fundamental info */
sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
got_dsn ? "DSN" : "DRIVER",
got_dsn ? ci->dsn : ci->driver,
ci->database,
ci->server,
ci->port,
ci->username,
ci->password);
encode(ci->conn_settings, encoded_conn_settings);
/* extra info */
hlen = strlen(connect_string);
if (!abbrev)
sprintf(&connect_string[hlen],
";%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d",
INI_READONLY,
ci->onlyread,
INI_PROTOCOL,
ci->protocol,
INI_FAKEOIDINDEX,
ci->fake_oid_index,
INI_SHOWOIDCOLUMN,
ci->show_oid_column,
INI_ROWVERSIONING,
ci->row_versioning,
INI_SHOWSYSTEMTABLES,
ci->show_system_tables,
INI_CONNSETTINGS,
encoded_conn_settings,
INI_FETCH,
ci->drivers.fetch_max,
INI_SOCKET,
ci->drivers.socket_buffersize,
INI_UNKNOWNSIZES,
ci->drivers.unknown_sizes,
INI_MAXVARCHARSIZE,
ci->drivers.max_varchar_size,
INI_MAXLONGVARCHARSIZE,
ci->drivers.max_longvarchar_size,
INI_DEBUG,
ci->drivers.debug,
INI_COMMLOG,
ci->drivers.commlog,
INI_OPTIMIZER,
ci->drivers.disable_optimizer,
INI_KSQO,
ci->drivers.ksqo,
INI_USEDECLAREFETCH,
ci->drivers.use_declarefetch,
INI_TEXTASLONGVARCHAR,
ci->drivers.text_as_longvarchar,
INI_UNKNOWNSASLONGVARCHAR,
ci->drivers.unknowns_as_longvarchar,
INI_BOOLSASCHAR,
ci->drivers.bools_as_char,
INI_PARSE,
ci->drivers.parse,
INI_CANCELASFREESTMT,
ci->drivers.cancel_as_freestmt,
INI_EXTRASYSTABLEPREFIXES,
ci->drivers.extra_systable_prefixes,
INI_LFCONVERSION,
ci->lf_conversion,
INI_UPDATABLECURSORS,
ci->allow_keyset,
INI_DISALLOWPREMATURE,
ci->disallow_premature,
INI_TRUEISMINUS1,
ci->true_is_minus1,
INI_INT8AS,
ci->true_is_minus1);
/* Abbrebiation is needed ? */
if (abbrev || strlen(connect_string) >= len)
{
unsigned long flag = 0;
if (ci->disallow_premature)
flag |= BIT_DISALLOWPREMATURE;
if (ci->allow_keyset)
flag |= BIT_UPDATABLECURSORS;
if (ci->lf_conversion)
flag |= BIT_LFCONVERSION;
if (ci->drivers.unique_index)
flag |= BIT_UNIQUEINDEX;
if (strncmp(ci->protocol, PG64, strlen(PG64)) == 0)
flag |= BIT_PROTOCOL_64;
else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
flag |= BIT_PROTOCOL_63;
switch (ci->drivers.unknown_sizes)
{
case UNKNOWNS_AS_DONTKNOW:
flag |= BIT_UNKNOWN_DONTKNOW;
break;
case UNKNOWNS_AS_MAX:
flag |= BIT_UNKNOWN_ASMAX;
break;
}
if (ci->drivers.disable_optimizer)
flag |= BIT_OPTIMIZER;
if (ci->drivers.ksqo)
flag |= BIT_KSQO;
if (ci->drivers.commlog)
flag |= BIT_COMMLOG;
if (ci->drivers.debug)
flag |= BIT_DEBUG;
if (ci->drivers.parse)
flag |= BIT_PARSE;
if (ci->drivers.cancel_as_freestmt)
flag |= BIT_CANCELASFREESTMT;
if (ci->drivers.use_declarefetch)
flag |= BIT_USEDECLAREFETCH;
if (ci->onlyread[0] == '1')
flag |= BIT_READONLY;
if (ci->drivers.text_as_longvarchar)
flag |= BIT_TEXTASLONGVARCHAR;
if (ci->drivers.unknowns_as_longvarchar)
flag |= BIT_UNKNOWNSASLONGVARCHAR;
if (ci->drivers.bools_as_char)
flag |= BIT_BOOLSASCHAR;
if (ci->row_versioning[0] == '1')
flag |= BIT_ROWVERSIONING;
if (ci->show_system_tables[0] == '1')
flag |= BIT_SHOWSYSTEMTABLES;
if (ci->show_oid_column[0] == '1')
flag |= BIT_SHOWOIDCOLUMN;
if (ci->fake_oid_index[0] == '1')
flag |= BIT_FAKEOIDINDEX;
if (ci->true_is_minus1)
flag |= BIT_TRUEISMINUS1;
sprintf(&connect_string[hlen],
";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;%s=%d;C2=%s;CX=%02x%lx",
encoded_conn_settings,
ci->drivers.fetch_max,
ci->drivers.socket_buffersize,
ci->drivers.max_varchar_size,
ci->drivers.max_longvarchar_size,
INI_INT8AS,
ci->int8_as,
ci->drivers.extra_systable_prefixes,
EFFECTIVE_BIT_COUNT,
flag);
}
}
static void
unfoldCXAttribute(ConnInfo *ci, const char *value)
{
int count;
unsigned long flag;
if (strlen(value) < 2)
{
count = 3;
sscanf(value, "%lx", &flag);
}
else
{
char cnt[8];
memcpy(cnt, value, 2);
cnt[2] = '\0';
sscanf(cnt, "%x", &count);
sscanf(value + 2, "%lx", &flag);
}
ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0);
ci->allow_keyset = (char)((flag & BIT_UPDATABLECURSORS) != 0);
ci->lf_conversion = (char)((flag & BIT_LFCONVERSION) != 0);
if (count < 4)
return;
ci->drivers.unique_index = (char)((flag & BIT_UNIQUEINDEX) != 0);
if ((flag & BIT_PROTOCOL_64) != 0)
strcpy(ci->protocol, PG64);
else if ((flag & BIT_PROTOCOL_63) != 0)
strcpy(ci->protocol, PG63);
else
strcpy(ci->protocol, PG62);
if ((flag & BIT_UNKNOWN_DONTKNOW) != 0)
ci->drivers.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
else if ((flag & BIT_UNKNOWN_ASMAX) != 0)
ci->drivers.unknown_sizes = UNKNOWNS_AS_MAX;
else
ci->drivers.unknown_sizes = UNKNOWNS_AS_LONGEST;
ci->drivers.disable_optimizer = (char)((flag & BIT_OPTIMIZER) != 0);
ci->drivers.ksqo = (char)((flag & BIT_KSQO) != 0);
ci->drivers.commlog = (char)((flag & BIT_COMMLOG) != 0);
ci->drivers.debug = (char)((flag & BIT_DEBUG) != 0);
ci->drivers.parse = (char)((flag & BIT_PARSE) != 0);
ci->drivers.cancel_as_freestmt = (char)((flag & BIT_CANCELASFREESTMT) != 0);
ci->drivers.use_declarefetch = (char)((flag & BIT_USEDECLAREFETCH) != 0);
sprintf(ci->onlyread, "%d", (char)((flag & BIT_READONLY) != 0));
ci->drivers.text_as_longvarchar = (char)((flag & BIT_TEXTASLONGVARCHAR) !=0);
ci->drivers.unknowns_as_longvarchar = (char)((flag & BIT_UNKNOWNSASLONGVARCHAR) !=0);
ci->drivers.bools_as_char = (char)((flag & BIT_BOOLSASCHAR) != 0);
sprintf(ci->row_versioning, "%d", (char)((flag & BIT_ROWVERSIONING) != 0));
sprintf(ci->show_system_tables, "%d", (char)((flag & BIT_SHOWSYSTEMTABLES) != 0));
sprintf(ci->show_oid_column, "%d", (char)((flag & BIT_SHOWOIDCOLUMN) != 0));
sprintf(ci->fake_oid_index, "%d", (char)((flag & BIT_FAKEOIDINDEX) != 0));
ci->true_is_minus1 = (char)((flag & BIT_TRUEISMINUS1) != 0);
}
void
copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
{
if (stricmp(attribute, "DSN") == 0)
strcpy(ci->dsn, value);
else if (stricmp(attribute, "driver") == 0)
strcpy(ci->driver, value);
else if (stricmp(attribute, INI_DATABASE) == 0)
strcpy(ci->database, value);
else if (stricmp(attribute, INI_SERVER) == 0 || stricmp(attribute, "server") == 0)
strcpy(ci->server, value);
else if (stricmp(attribute, INI_USER) == 0 || stricmp(attribute, "uid") == 0)
strcpy(ci->username, value);
else if (stricmp(attribute, INI_PASSWORD) == 0 || stricmp(attribute, "pwd") == 0)
strcpy(ci->password, value);
else if (stricmp(attribute, INI_PORT) == 0)
strcpy(ci->port, value);
else if (stricmp(attribute, INI_READONLY) == 0 || stricmp(attribute, "A0") == 0)
strcpy(ci->onlyread, value);
else if (stricmp(attribute, INI_PROTOCOL) == 0 || stricmp(attribute, "A1") == 0)
strcpy(ci->protocol, value);
else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0 || stricmp(attribute, "A3") == 0)
strcpy(ci->show_oid_column, value);
else if (stricmp(attribute, INI_FAKEOIDINDEX) == 0 || stricmp(attribute, "A2") == 0)
strcpy(ci->fake_oid_index, value);
else if (stricmp(attribute, INI_ROWVERSIONING) == 0 || stricmp(attribute, "A4") == 0)
strcpy(ci->row_versioning, value);
else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0 || stricmp(attribute, "A5") == 0)
strcpy(ci->show_system_tables, value);
else if (stricmp(attribute, INI_CONNSETTINGS) == 0 || stricmp(attribute, "A6") == 0)
{
decode(value, ci->conn_settings);
/* strcpy(ci->conn_settings, value); */
}
else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0)
ci->disallow_premature = atoi(value);
else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0)
ci->allow_keyset = atoi(value);
else if (stricmp(attribute, INI_LFCONVERSION) == 0)
ci->lf_conversion = atoi(value);
else if (stricmp(attribute, INI_TRUEISMINUS1) == 0)
ci->true_is_minus1 = atoi(value);
else if (stricmp(attribute, INI_INT8AS) == 0)
ci->int8_as = atoi(value);
else if (stricmp(attribute, "CX") == 0)
unfoldCXAttribute(ci, value);
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature);
}
void
copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value)
{
if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0)
ci->drivers.fetch_max = atoi(value);
else if (stricmp(attribute, INI_SOCKET) == 0 || stricmp(attribute, "A8") == 0)
ci->drivers.socket_buffersize = atoi(value);
else if (stricmp(attribute, INI_DEBUG) == 0 || stricmp(attribute, "B2") == 0)
ci->drivers.debug = atoi(value);
else if (stricmp(attribute, INI_COMMLOG) == 0 || stricmp(attribute, "B3") == 0)
ci->drivers.commlog = atoi(value);
else if (stricmp(attribute, INI_OPTIMIZER) == 0 || stricmp(attribute, "B4") == 0)
ci->drivers.disable_optimizer = atoi(value);
else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0)
ci->drivers.ksqo = atoi(value);
/*
* else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 ||
* stricmp(attribute, "UIX") == 0) ci->drivers.unique_index =
* atoi(value);
*/
else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0)
ci->drivers.unknown_sizes = atoi(value);
else if (stricmp(attribute, INI_LIE) == 0)
ci->drivers.lie = atoi(value);
else if (stricmp(attribute, INI_PARSE) == 0 || stricmp(attribute, "C0") == 0)
ci->drivers.parse = atoi(value);
else if (stricmp(attribute, INI_CANCELASFREESTMT) == 0 || stricmp(attribute, "C1") == 0)
ci->drivers.cancel_as_freestmt = atoi(value);
else if (stricmp(attribute, INI_USEDECLAREFETCH) == 0 || stricmp(attribute, "B6") == 0)
ci->drivers.use_declarefetch = atoi(value);
else if (stricmp(attribute, INI_MAXVARCHARSIZE) == 0 || stricmp(attribute, "B0") == 0)
ci->drivers.max_varchar_size = atoi(value);
else if (stricmp(attribute, INI_MAXLONGVARCHARSIZE) == 0 || stricmp(attribute, "B1") == 0)
ci->drivers.max_longvarchar_size = atoi(value);
else if (stricmp(attribute, INI_TEXTASLONGVARCHAR) == 0 || stricmp(attribute, "B7") == 0)
ci->drivers.text_as_longvarchar = atoi(value);
else if (stricmp(attribute, INI_UNKNOWNSASLONGVARCHAR) == 0 || stricmp(attribute, "B8") == 0)
ci->drivers.unknowns_as_longvarchar = atoi(value);
else if (stricmp(attribute, INI_BOOLSASCHAR) == 0 || stricmp(attribute, "B9") == 0)
ci->drivers.bools_as_char = atoi(value);
else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0)
strcpy(ci->drivers.extra_systable_prefixes, value);
mylog("CopyCommonAttributes: A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
ci->drivers.fetch_max,
ci->drivers.socket_buffersize,
ci->drivers.unknown_sizes,
ci->drivers.max_varchar_size,
ci->drivers.max_longvarchar_size,
ci->drivers.debug,
ci->drivers.commlog,
ci->drivers.disable_optimizer,
ci->drivers.ksqo,
ci->drivers.use_declarefetch,
ci->drivers.text_as_longvarchar,
ci->drivers.unknowns_as_longvarchar,
ci->drivers.bools_as_char,
ci->drivers.parse,
ci->drivers.cancel_as_freestmt,
ci->drivers.extra_systable_prefixes);
}
void
getDSNdefaults(ConnInfo *ci)
{
if (ci->port[0] == '\0')
strcpy(ci->port, DEFAULT_PORT);
if (ci->onlyread[0] == '\0')
sprintf(ci->onlyread, "%d", globals.onlyread);
if (ci->protocol[0] == '\0')
strcpy(ci->protocol, globals.protocol);
if (ci->fake_oid_index[0] == '\0')
sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);
if (ci->show_oid_column[0] == '\0')
sprintf(ci->show_oid_column, "%d", DEFAULT_SHOWOIDCOLUMN);
if (ci->show_system_tables[0] == '\0')
sprintf(ci->show_system_tables, "%d", DEFAULT_SHOWSYSTEMTABLES);
if (ci->row_versioning[0] == '\0')
sprintf(ci->row_versioning, "%d", DEFAULT_ROWVERSIONING);
if (ci->disallow_premature < 0)
ci->disallow_premature = DEFAULT_DISALLOWPREMATURE;
if (ci->allow_keyset < 0)
ci->allow_keyset = DEFAULT_UPDATABLECURSORS;
if (ci->lf_conversion < 0)
ci->lf_conversion = DEFAULT_LFCONVERSION;
if (ci->true_is_minus1 < 0)
ci->true_is_minus1 = DEFAULT_TRUEISMINUS1;
if (ci->int8_as < -100)
ci->int8_as = DEFAULT_INT8AS;
}
void
getDSNinfo(ConnInfo *ci, char overwrite)
{
char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN],
temp[SMALL_REGISTRY_LEN];
/*
* If a driver keyword was present, then dont use a DSN and return.
* If DSN is null and no driver, then use the default datasource.
*/
if (DSN[0] == '\0')
{
if (ci->driver[0] != '\0')
return;
else
strcpy(DSN, INI_DSN);
}
/* brute-force chop off trailing blanks... */
while (*(DSN + strlen(DSN) - 1) == ' ')
*(DSN + strlen(DSN) - 1) = '\0';
/* Proceed with getting info for the given DSN. */
if (ci->desc[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
if (ci->server[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_SERVER, "", ci->server, sizeof(ci->server), ODBC_INI);
if (ci->database[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI);
if (ci->username[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI);
if (ci->password[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_PASSWORD, "", ci->password, sizeof(ci->password), ODBC_INI);
if (ci->port[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
if (ci->onlyread[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI);
if (ci->show_oid_column[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, "", ci->show_oid_column, sizeof(ci->show_oid_column), ODBC_INI);
if (ci->fake_oid_index[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, "", ci->fake_oid_index, sizeof(ci->fake_oid_index), ODBC_INI);
if (ci->row_versioning[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, "", ci->row_versioning, sizeof(ci->row_versioning), ODBC_INI);
if (ci->show_system_tables[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI);
if (ci->protocol[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);
if (ci->conn_settings[0] == '\0' || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI);
decode(encoded_conn_settings, ci->conn_settings);
}
if (ci->translation_dll[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI);
if (ci->translation_option[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);
if (ci->disallow_premature < 0 || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_DISALLOWPREMATURE, "", temp, sizeof(temp), ODBC_INI);
if (temp[0])
ci->disallow_premature = atoi(temp);
}
if (ci->allow_keyset < 0 || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_UPDATABLECURSORS, "", temp, sizeof(temp), ODBC_INI);
if (temp[0])
ci->allow_keyset = atoi(temp);
}
if (ci->lf_conversion < 0 || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_LFCONVERSION, "", temp, sizeof(temp), ODBC_INI);
if (temp[0])
ci->lf_conversion = atoi(temp);
}
if (ci->true_is_minus1 < 0 || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_TRUEISMINUS1, "", temp, sizeof(temp), ODBC_INI);
if (temp[0])
ci->true_is_minus1 = atoi(temp);
}
if (ci->int8_as < -100 || overwrite)
{
SQLGetPrivateProfileString(DSN, INI_INT8AS, "", temp, sizeof(temp), ODBC_INI);
if (temp[0])
ci->int8_as = atoi(temp);
}
/* Allow override of odbcinst.ini parameters here */
getCommonDefaults(DSN, ODBC_INI, ci);
qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n",
DSN,
ci->server,
ci->port,
ci->database,
ci->username,
ci->password);
qlog(" onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
ci->onlyread,
ci->protocol,
ci->show_oid_column,
ci->fake_oid_index,
ci->show_system_tables);
#ifdef MULTIBYTE
check_client_encoding(ci->conn_settings);
qlog(" conn_settings='%s',conn_encoding='%s'\n",
ci->conn_settings,
check_client_encoding(ci->conn_settings));
#else
qlog(" conn_settings='%s'\n",
ci->conn_settings);
#endif
qlog(" translation_dll='%s',translation_option='%s'\n",
ci->translation_dll,
ci->translation_option);
}
/*
* This function writes any global parameters (that can be manipulated)
* to the ODBCINST.INI portion of the registry
*/
void
writeDriverCommoninfo(const ConnInfo *ci)
{
const char *sectionName;
const char *fileName;
const GLOBAL_VALUES *comval;
char tmp[128];
if (ci)
if (ci->dsn && ci->dsn[0])
{
mylog("DSN=%s updating\n", ci->dsn);
comval = &(ci->drivers);
sectionName = ci->dsn;
fileName = ODBC_INI;
}
else
{
mylog("ci but dsn==NULL\n");
return;
}
else
{
mylog("drivers updating\n");
comval = &globals;
sectionName = DBMS_NAME;
fileName = ODBCINST_INI;
}
sprintf(tmp, "%d", comval->fetch_max);
SQLWritePrivateProfileString(sectionName,
INI_FETCH, tmp, fileName);
sprintf(tmp, "%d", comval->commlog);
SQLWritePrivateProfileString(sectionName,
INI_COMMLOG, tmp, fileName);
sprintf(tmp, "%d", comval->debug);
SQLWritePrivateProfileString(sectionName,
INI_DEBUG, tmp, fileName);
sprintf(tmp, "%d", comval->disable_optimizer);
SQLWritePrivateProfileString(sectionName,
INI_OPTIMIZER, tmp, fileName);
sprintf(tmp, "%d", comval->ksqo);
SQLWritePrivateProfileString(sectionName,
INI_KSQO, tmp, fileName);
sprintf(tmp, "%d", comval->unique_index);
SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName);
/*
* Never update the onlyread from this module.
*/
if (!ci)
{
sprintf(tmp, "%d", comval->onlyread);
SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
fileName);
}
sprintf(tmp, "%d", comval->use_declarefetch);
SQLWritePrivateProfileString(sectionName,
INI_USEDECLAREFETCH, tmp, fileName);
sprintf(tmp, "%d", comval->unknown_sizes);
SQLWritePrivateProfileString(sectionName,
INI_UNKNOWNSIZES, tmp, fileName);
sprintf(tmp, "%d", comval->text_as_longvarchar);
SQLWritePrivateProfileString(sectionName,
INI_TEXTASLONGVARCHAR, tmp, fileName);
sprintf(tmp, "%d", comval->unknowns_as_longvarchar);
SQLWritePrivateProfileString(sectionName,
INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
sprintf(tmp, "%d", comval->bools_as_char);
SQLWritePrivateProfileString(sectionName,
INI_BOOLSASCHAR, tmp, fileName);
sprintf(tmp, "%d", comval->parse);
SQLWritePrivateProfileString(sectionName,
INI_PARSE, tmp, fileName);
sprintf(tmp, "%d", comval->cancel_as_freestmt);
SQLWritePrivateProfileString(sectionName,
INI_CANCELASFREESTMT, tmp, fileName);
sprintf(tmp, "%d", comval->max_varchar_size);
SQLWritePrivateProfileString(sectionName,
INI_MAXVARCHARSIZE, tmp, fileName);
sprintf(tmp, "%d", comval->max_longvarchar_size);
SQLWritePrivateProfileString(sectionName,
INI_MAXLONGVARCHARSIZE, tmp, fileName);
SQLWritePrivateProfileString(sectionName,
INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
/*
* Never update the conn_setting from this module
* SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS,
* comval->conn_settings, fileName);
*/
}
/* This is for datasource based options only */
void
writeDSNinfo(const ConnInfo *ci)
{
const char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN],
temp[SMALL_REGISTRY_LEN];
encode(ci->conn_settings, encoded_conn_settings);
SQLWritePrivateProfileString(DSN,
INI_KDESC,
ci->desc,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_DATABASE,
ci->database,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_SERVER,
ci->server,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_PORT,
ci->port,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_USER,
ci->username,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_PASSWORD,
ci->password,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_READONLY,
ci->onlyread,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_SHOWOIDCOLUMN,
ci->show_oid_column,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_FAKEOIDINDEX,
ci->fake_oid_index,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_ROWVERSIONING,
ci->row_versioning,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_SHOWSYSTEMTABLES,
ci->show_system_tables,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_PROTOCOL,
ci->protocol,
ODBC_INI);
SQLWritePrivateProfileString(DSN,
INI_CONNSETTINGS,
encoded_conn_settings,
ODBC_INI);
sprintf(temp, "%d", ci->disallow_premature);
SQLWritePrivateProfileString(DSN,
INI_DISALLOWPREMATURE,
temp,
ODBC_INI);
sprintf(temp, "%d", ci->allow_keyset);
SQLWritePrivateProfileString(DSN,
INI_UPDATABLECURSORS,
temp,
ODBC_INI);
sprintf(temp, "%d", ci->lf_conversion);
SQLWritePrivateProfileString(DSN,
INI_LFCONVERSION,
temp,
ODBC_INI);
sprintf(temp, "%d", ci->true_is_minus1);
SQLWritePrivateProfileString(DSN,
INI_TRUEISMINUS1,
temp,
ODBC_INI);
sprintf(temp, "%d", ci->int8_as);
SQLWritePrivateProfileString(DSN,
INI_INT8AS,
temp,
ODBC_INI);
}
/*
* This function reads the ODBCINST.INI portion of
* the registry and gets any driver defaults.
*/
void
getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
{
char temp[256];
GLOBAL_VALUES *comval;
if (ci)
comval = &(ci->drivers);
else
comval = &globals;
/* Fetch Count is stored in driver section */
SQLGetPrivateProfileString(section, INI_FETCH, "",
temp, sizeof(temp), filename);
if (temp[0])
{
comval->fetch_max = atoi(temp);
/* sanity check if using cursors */
if (comval->fetch_max <= 0)
comval->fetch_max = FETCH_MAX;
}
else if (!ci)
comval->fetch_max = FETCH_MAX;
/* Socket Buffersize is stored in driver section */
SQLGetPrivateProfileString(section, INI_SOCKET, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->socket_buffersize = atoi(temp);
else if (!ci)
comval->socket_buffersize = SOCK_BUFFER_SIZE;
/* Debug is stored in the driver section */
SQLGetPrivateProfileString(section, INI_DEBUG, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->debug = atoi(temp);
else if (!ci)
comval->debug = DEFAULT_DEBUG;
/* CommLog is stored in the driver section */
SQLGetPrivateProfileString(section, INI_COMMLOG, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->commlog = atoi(temp);
else if (!ci)
comval->commlog = DEFAULT_COMMLOG;
if (!ci)
logs_on_off(0, 0, 0);
/* Optimizer is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->disable_optimizer = atoi(temp);
else if (!ci)
comval->disable_optimizer = DEFAULT_OPTIMIZER;
/* KSQO is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_KSQO, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->ksqo = atoi(temp);
else if (!ci)
comval->ksqo = DEFAULT_KSQO;
/* Recognize Unique Index is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->unique_index = atoi(temp);
else if (!ci)
comval->unique_index = DEFAULT_UNIQUEINDEX;
/* Unknown Sizes is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->unknown_sizes = atoi(temp);
else if (!ci)
comval->unknown_sizes = DEFAULT_UNKNOWNSIZES;
/* Lie about supported functions? */
SQLGetPrivateProfileString(section, INI_LIE, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->lie = atoi(temp);
else if (!ci)
comval->lie = DEFAULT_LIE;
/* Parse statements */
SQLGetPrivateProfileString(section, INI_PARSE, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->parse = atoi(temp);
else if (!ci)
comval->parse = DEFAULT_PARSE;
/* SQLCancel calls SQLFreeStmt in Driver Manager */
SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->cancel_as_freestmt = atoi(temp);
else if (!ci)
comval->cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
/* UseDeclareFetch is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->use_declarefetch = atoi(temp);
else if (!ci)
comval->use_declarefetch = DEFAULT_USEDECLAREFETCH;
/* Max Varchar Size */
SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->max_varchar_size = atoi(temp);
else if (!ci)
comval->max_varchar_size = MAX_VARCHAR_SIZE;
/* Max TextField Size */
SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->max_longvarchar_size = atoi(temp);
else if (!ci)
comval->max_longvarchar_size = TEXT_FIELD_SIZE;
/* Text As LongVarchar */
SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->text_as_longvarchar = atoi(temp);
else if (!ci)
comval->text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
/* Unknowns As LongVarchar */
SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->unknowns_as_longvarchar = atoi(temp);
else if (!ci)
comval->unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
/* Bools As Char */
SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->bools_as_char = atoi(temp);
else if (!ci)
comval->bools_as_char = DEFAULT_BOOLSASCHAR;
/* Extra Systable prefixes */
/*
* Use @@@ to distinguish between blank extra prefixes and no key
* entry
*/
SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
temp, sizeof(temp), filename);
if (strcmp(temp, "@@@"))
strcpy(comval->extra_systable_prefixes, temp);
else if (!ci)
strcpy(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES);
mylog("globals.extra_systable_prefixes = '%s'\n", comval->extra_systable_prefixes);
/* Dont allow override of an override! */
if (!ci)
{
/*
* ConnSettings is stored in the driver section and per datasource
* for override
*/
SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
comval->conn_settings, sizeof(comval->conn_settings), filename);
/* Default state for future DSN's Readonly attribute */
SQLGetPrivateProfileString(section, INI_READONLY, "",
temp, sizeof(temp), filename);
if (temp[0])
comval->onlyread = atoi(temp);
else
comval->onlyread = DEFAULT_READONLY;
/*
* Default state for future DSN's protocol attribute This isn't a
* real driver option YET. This is more intended for
* customization from the install.
*/
SQLGetPrivateProfileString(section, INI_PROTOCOL, "@@@",
temp, sizeof(temp), filename);
if (strcmp(temp, "@@@"))
strcpy(comval->protocol, temp);
else
strcpy(comval->protocol, DEFAULT_PROTOCOL);
}
}

View File

@ -1,200 +0,0 @@
/* File: dlg_specific.h
*
* Description: See "dlg_specific.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __DLG_SPECIFIC_H__
#define __DLG_SPECIFIC_H__
#include "psqlodbc.h"
#include "connection.h"
#ifdef WIN32
#include <windowsx.h>
#include "resource.h"
#endif
/* Unknown data type sizes */
#define UNKNOWNS_AS_MAX 0
#define UNKNOWNS_AS_DONTKNOW 1
#define UNKNOWNS_AS_LONGEST 2
/* ODBC initialization files */
#ifndef WIN32
#define ODBC_INI ".odbc.ini"
#define ODBCINST_INI "odbcinst.ini"
#else
#define ODBC_INI "ODBC.INI"
#define ODBCINST_INI "ODBCINST.INI"
#endif
#define INI_DSN DBMS_NAME /* Name of default
* Datasource in ini
* file (not used?) */
#define INI_KDESC "Description" /* Data source
* description */
#define INI_SERVER "Servername" /* Name of Server
* running the Postgres
* service */
#define INI_PORT "Port" /* Port on which the
* Postmaster is listening */
#define INI_DATABASE "Database" /* Database Name */
#define INI_USER "Username" /* Default User Name */
#define INI_PASSWORD "Password" /* Default Password */
#define INI_DEBUG "Debug" /* Debug flag */
#define INI_FETCH "Fetch" /* Fetch Max Count */
#define INI_SOCKET "Socket" /* Socket buffer size */
#define INI_READONLY "ReadOnly" /* Database is read only */
#define INI_COMMLOG "CommLog" /* Communication to
* backend logging */
#define INI_PROTOCOL "Protocol" /* What protocol (6.2) */
#define INI_OPTIMIZER "Optimizer" /* Use backend genetic
* optimizer */
#define INI_KSQO "Ksqo" /* Keyset query
* optimization */
#define INI_CONNSETTINGS "ConnSettings" /* Anything to send to
* backend on successful
* connection */
#define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique
* indexes */
#define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown
* result set sizes */
#define INI_CANCELASFREESTMT "CancelAsFreeStmt"
#define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch
* cursors */
/* More ini stuff */
#define INI_TEXTASLONGVARCHAR "TextAsLongVarchar"
#define INI_UNKNOWNSASLONGVARCHAR "UnknownsAsLongVarchar"
#define INI_BOOLSASCHAR "BoolsAsChar"
#define INI_MAXVARCHARSIZE "MaxVarcharSize"
#define INI_MAXLONGVARCHARSIZE "MaxLongVarcharSize"
#define INI_FAKEOIDINDEX "FakeOidIndex"
#define INI_SHOWOIDCOLUMN "ShowOidColumn"
#define INI_ROWVERSIONING "RowVersioning"
#define INI_SHOWSYSTEMTABLES "ShowSystemTables"
#define INI_LIE "Lie"
#define INI_PARSE "Parse"
#define INI_EXTRASYSTABLEPREFIXES "ExtraSysTablePrefixes"
#define INI_TRANSLATIONNAME "TranslationName"
#define INI_TRANSLATIONDLL "TranslationDLL"
#define INI_TRANSLATIONOPTION "TranslationOption"
#define INI_DISALLOWPREMATURE "DisallowPremature"
#define INI_UPDATABLECURSORS "UpdatableCursors"
#define INI_LFCONVERSION "LFConversion"
#define INI_TRUEISMINUS1 "TrueIsMinus1"
#define INI_INT8AS "BI"
/* Bit representaion for abbreviated connection strings */
#define BIT_LFCONVERSION (1L)
#define BIT_UPDATABLECURSORS (1L<<1)
#define BIT_DISALLOWPREMATURE (1L<<2)
#define BIT_UNIQUEINDEX (1L<<3)
#define BIT_PROTOCOL_63 (1L<<4)
#define BIT_PROTOCOL_64 (1L<<5)
#define BIT_UNKNOWN_DONTKNOW (1L<<6)
#define BIT_UNKNOWN_ASMAX (1L<<7)
#define BIT_OPTIMIZER (1L<<8)
#define BIT_KSQO (1L<<9)
#define BIT_COMMLOG (1L<<10)
#define BIT_DEBUG (1L<<11)
#define BIT_PARSE (1L<<12)
#define BIT_CANCELASFREESTMT (1L<<13)
#define BIT_USEDECLAREFETCH (1L<<14)
#define BIT_READONLY (1L<<15)
#define BIT_TEXTASLONGVARCHAR (1L<<16)
#define BIT_UNKNOWNSASLONGVARCHAR (1L<<17)
#define BIT_BOOLSASCHAR (1L<<18)
#define BIT_ROWVERSIONING (1L<<19)
#define BIT_SHOWSYSTEMTABLES (1L<<20)
#define BIT_SHOWOIDCOLUMN (1L<<21)
#define BIT_FAKEOIDINDEX (1L<<22)
#define BIT_TRUEISMINUS1 (1L<<23)
#define EFFECTIVE_BIT_COUNT 24
/* Connection Defaults */
#define DEFAULT_PORT "5432"
#define DEFAULT_READONLY 0
#define DEFAULT_PROTOCOL "6.4" /* the latest protocol is
* the default */
#define DEFAULT_USEDECLAREFETCH 0
#define DEFAULT_TEXTASLONGVARCHAR 1
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
#define DEFAULT_BOOLSASCHAR 1
#define DEFAULT_OPTIMIZER 1 /* disable */
#define DEFAULT_KSQO 1 /* on */
#define DEFAULT_UNIQUEINDEX 1 /* dont recognize */
#define DEFAULT_COMMLOG 0 /* dont log */
#define DEFAULT_DEBUG 0
#define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX
#define DEFAULT_FAKEOIDINDEX 0
#define DEFAULT_SHOWOIDCOLUMN 0
#define DEFAULT_ROWVERSIONING 0
#define DEFAULT_SHOWSYSTEMTABLES 0 /* dont show system tables */
#define DEFAULT_LIE 0
#define DEFAULT_PARSE 0
#define DEFAULT_CANCELASFREESTMT 0
#define DEFAULT_EXTRASYSTABLEPREFIXES "dd_;"
#define DEFAULT_DISALLOWPREMATURE 0
#define DEFAULT_TRUEISMINUS1 0
#ifdef DRIVER_CURSOR_IMPLEMENT
#define DEFAULT_UPDATABLECURSORS 1
#else
#define DEFAULT_UPDATABLECURSORS 0
#endif /* DRIVER_CURSOR_IMPLEMENT */
#ifdef WIN32
#define DEFAULT_LFCONVERSION 1
#else
#define DEFAULT_LFCONVERSION 0
#endif /* WIN32 */
#define DEFAULT_INT8AS 0
/* prototypes */
void getCommonDefaults(const char *section, const char *filename, ConnInfo *ci);
#ifdef WIN32
void SetDlgStuff(HWND hdlg, const ConnInfo *ci);
void GetDlgStuff(HWND hdlg, ConnInfo *ci);
int CALLBACK driver_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
int CALLBACK global_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
int CALLBACK ds_options1Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
int CALLBACK ds_options2Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
#endif /* WIN32 */
void updateGlobals(void);
void writeDriverCommoninfo(const ConnInfo *ci);
void writeDSNinfo(const ConnInfo *ci);
void getDSNdefaults(ConnInfo *ci);
void getDSNinfo(ConnInfo *ci, char overwrite);
void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD);
void copyAttributes(ConnInfo *ci, const char *attribute, const char *value);
void copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value);
#endif

View File

@ -1,523 +0,0 @@
#ifdef WIN32
/*-------
* Module: dlg_wingui.c
*
* Description: This module contains any specific code for handling
* dialog boxes such as driver/datasource options. Both the
* ConfigDSN() and the SQLDriverConnect() functions use
* functions in this module. If you were to add a new option
* to any dialog box, you would most likely only have to change
* things in here rather than in 2 separate places as before.
*
* Classes: none
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
#include "dlg_specific.h"
#include "convert.h"
#ifdef MULTIBYTE
#include "multibyte.h"
#endif
#include "pgapifunc.h"
#ifndef BOOL
#define BOOL int
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
#ifndef TRUE
#define TRUE (BOOL)1
#endif
extern GLOBAL_VALUES globals;
extern HINSTANCE NEAR s_hModule;
static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable);
static int driver_options_update(HWND hdlg, ConnInfo *ci, BOOL);
void
SetDlgStuff(HWND hdlg, const ConnInfo *ci)
{
/*
* If driver attribute NOT present, then set the datasource name and
* description
*/
if (ci->driver[0] == '\0')
{
SetDlgItemText(hdlg, IDC_DSNAME, ci->dsn);
SetDlgItemText(hdlg, IDC_DESC, ci->desc);
}
SetDlgItemText(hdlg, IDC_DATABASE, ci->database);
SetDlgItemText(hdlg, IDC_SERVER, ci->server);
SetDlgItemText(hdlg, IDC_USER, ci->username);
SetDlgItemText(hdlg, IDC_PASSWORD, ci->password);
SetDlgItemText(hdlg, IDC_PORT, ci->port);
}
void
GetDlgStuff(HWND hdlg, ConnInfo *ci)
{
GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc));
GetDlgItemText(hdlg, IDC_DATABASE, ci->database, sizeof(ci->database));
GetDlgItemText(hdlg, IDC_SERVER, ci->server, sizeof(ci->server));
GetDlgItemText(hdlg, IDC_USER, ci->username, sizeof(ci->username));
GetDlgItemText(hdlg, IDC_PASSWORD, ci->password, sizeof(ci->password));
GetDlgItemText(hdlg, IDC_PORT, ci->port, sizeof(ci->port));
}
static int
driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable)
{
const GLOBAL_VALUES *comval;
static BOOL defset = FALSE;
static GLOBAL_VALUES defval;
switch (src)
{
case 0: /* driver common */
comval = &globals;
break;
case 1: /* dsn specific */
comval = &(ci->drivers);
break;
case 2: /* default */
if (!defset)
{
defval.commlog = DEFAULT_COMMLOG;
defval.disable_optimizer = DEFAULT_OPTIMIZER;
defval.ksqo = DEFAULT_KSQO;
defval.unique_index = DEFAULT_UNIQUEINDEX;
defval.onlyread = DEFAULT_READONLY;
defval.use_declarefetch = DEFAULT_USEDECLAREFETCH;
defval.parse = DEFAULT_PARSE;
defval.cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
defval.debug = DEFAULT_DEBUG;
/* Unknown Sizes */
defval.unknown_sizes = DEFAULT_UNKNOWNSIZES;
defval.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
defval.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
defval.bools_as_char = DEFAULT_BOOLSASCHAR;
}
defset = TRUE;
comval = &defval;
break;
}
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL2), enable ? SW_SHOW : SW_HIDE);
CheckDlgButton(hdlg, DRV_COMMLOG, comval->commlog);
#ifndef Q_LOG
EnableWindow(GetDlgItem(hdlg, DRV_COMMLOG), FALSE);
#endif /* Q_LOG */
CheckDlgButton(hdlg, DRV_OPTIMIZER, comval->disable_optimizer);
CheckDlgButton(hdlg, DRV_KSQO, comval->ksqo);
CheckDlgButton(hdlg, DRV_UNIQUEINDEX, comval->unique_index);
/* EnableWindow(GetDlgItem(hdlg, DRV_UNIQUEINDEX), enable); */
CheckDlgButton(hdlg, DRV_READONLY, comval->onlyread);
EnableWindow(GetDlgItem(hdlg, DRV_READONLY), enable);
CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, comval->use_declarefetch);
/* Unknown Sizes clear */
CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 0);
CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 0);
CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 0);
/* Unknown (Default) Data Type sizes */
switch (comval->unknown_sizes)
{
case UNKNOWNS_AS_DONTKNOW:
CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1);
break;
case UNKNOWNS_AS_LONGEST:
CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1);
break;
case UNKNOWNS_AS_MAX:
default:
CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1);
break;
}
CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, comval->text_as_longvarchar);
CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, comval->unknowns_as_longvarchar);
CheckDlgButton(hdlg, DRV_BOOLS_CHAR, comval->bools_as_char);
CheckDlgButton(hdlg, DRV_PARSE, comval->parse);
CheckDlgButton(hdlg, DRV_CANCELASFREESTMT, comval->cancel_as_freestmt);
CheckDlgButton(hdlg, DRV_DEBUG, comval->debug);
#ifndef MY_LOG
EnableWindow(GetDlgItem(hdlg, DRV_DEBUG), FALSE);
#endif /* MY_LOG */
SetDlgItemInt(hdlg, DRV_CACHE_SIZE, comval->fetch_max, FALSE);
SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, comval->max_varchar_size, FALSE);
SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, comval->max_longvarchar_size, TRUE);
SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes);
/* Driver Connection Settings */
SetDlgItemText(hdlg, DRV_CONNSETTINGS, comval->conn_settings);
EnableWindow(GetDlgItem(hdlg, DRV_CONNSETTINGS), enable);
ShowWindow(GetDlgItem(hdlg, IDPREVPAGE), enable ? SW_HIDE : SW_SHOW);
ShowWindow(GetDlgItem(hdlg, IDNEXTPAGE), enable ? SW_HIDE : SW_SHOW);
return 0;
}
static int
driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile)
{
GLOBAL_VALUES *comval;
if (ci)
comval = &(ci->drivers);
else
comval = &globals;
comval->commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
comval->disable_optimizer = IsDlgButtonChecked(hdlg, DRV_OPTIMIZER);
comval->ksqo = IsDlgButtonChecked(hdlg, DRV_KSQO);
comval->unique_index = IsDlgButtonChecked(hdlg, DRV_UNIQUEINDEX);
if (!ci)
{
comval->onlyread = IsDlgButtonChecked(hdlg, DRV_READONLY);
}
comval->use_declarefetch = IsDlgButtonChecked(hdlg, DRV_USEDECLAREFETCH);
/* Unknown (Default) Data Type sizes */
if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_MAX))
comval->unknown_sizes = UNKNOWNS_AS_MAX;
else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_DONTKNOW))
comval->unknown_sizes = UNKNOWNS_AS_DONTKNOW;
else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_LONGEST))
comval->unknown_sizes = UNKNOWNS_AS_LONGEST;
else
comval->unknown_sizes = UNKNOWNS_AS_MAX;
comval->text_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_TEXT_LONGVARCHAR);
comval->unknowns_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_UNKNOWNS_LONGVARCHAR);
comval->bools_as_char = IsDlgButtonChecked(hdlg, DRV_BOOLS_CHAR);
comval->parse = IsDlgButtonChecked(hdlg, DRV_PARSE);
comval->cancel_as_freestmt = IsDlgButtonChecked(hdlg, DRV_CANCELASFREESTMT);
comval->debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
comval->fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
comval->max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
comval->max_longvarchar_size = GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for
* SQL_NO_TOTAL */
GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, sizeof(comval->extra_systable_prefixes));
/* Driver Connection Settings */
if (!ci)
GetDlgItemText(hdlg, DRV_CONNSETTINGS, comval->conn_settings, sizeof(comval->conn_settings));
if (updateProfile)
writeDriverCommoninfo(ci);
/* fall through */
return 0;
}
int CALLBACK
driver_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
switch (wMsg)
{
case WM_INITDIALOG:
SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */
ci = (ConnInfo *) lParam;
SetWindowText(hdlg, "Advanced Options (Default)");
SetWindowText(GetDlgItem(hdlg, IDOK), "Save");
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE);
driver_optionsDraw(hdlg, ci, 0, TRUE);
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
driver_options_update(hdlg, NULL,
ci && ci->dsn && ci->dsn[0]);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
case IDDEFAULTS:
driver_optionsDraw(hdlg, NULL, 2, TRUE);
break;
}
}
return FALSE;
}
int CALLBACK
global_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (wMsg)
{
case WM_INITDIALOG:
CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
#ifndef Q_LOG
EnableWindow(GetDlgItem(hdlg, DRV_COMMLOG), FALSE);
#endif /* Q_LOG */
CheckDlgButton(hdlg, DRV_DEBUG, globals.debug);
#ifndef MY_LOG
EnableWindow(GetDlgItem(hdlg, DRV_DEBUG), FALSE);
#endif /* MY_LOG */
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
driver_options_update(hdlg, NULL, TRUE);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
}
}
return FALSE;
}
int CALLBACK
ds_options1Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
switch (wMsg)
{
case WM_INITDIALOG:
SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */
ci = (ConnInfo *) lParam;
if (ci && ci->dsn && ci->dsn[0])
SetWindowText(hdlg, "Advanced Options (DSN 1/2)");
else
{
SetWindowText(hdlg, "Advanced Options (Connection 1/2)");
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE);
}
driver_optionsDraw(hdlg, ci, 1, FALSE);
break;
case WM_COMMAND:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
driver_options_update(hdlg, ci, FALSE);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
case IDAPPLY:
driver_options_update(hdlg, ci, FALSE);
SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam);
break;
case IDDEFAULTS:
driver_optionsDraw(hdlg, ci, 0, FALSE);
break;
case IDNEXTPAGE:
driver_options_update(hdlg, ci, FALSE);
EndDialog(hdlg, FALSE);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DS),
hdlg, ds_options2Proc, (LPARAM)
ci);
break;
}
}
return FALSE;
}
int CALLBACK
ds_options2Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
char buf[128];
DWORD cmd;
switch (wMsg)
{
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK */
/* Change window caption */
if (ci->driver[0])
{
SetWindowText(hdlg, "Advanced Options (Connection 2/2)");
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); }
else
{
sprintf(buf, "Advanced Options (%s) 2/2", ci->dsn);
SetWindowText(hdlg, buf);
}
/* Readonly */
CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
/* Protocol */
if (strncmp(ci->protocol, PG62, strlen(PG62)) == 0)
CheckDlgButton(hdlg, DS_PG62, 1);
else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
CheckDlgButton(hdlg, DS_PG63, 1);
else
/* latest */
CheckDlgButton(hdlg, DS_PG64, 1);
/* Int8 As */
switch (ci->int8_as)
{
case SQL_BIGINT:
CheckDlgButton(hdlg, DS_INT8_AS_BIGINT, 1);
break;
case SQL_NUMERIC:
CheckDlgButton(hdlg, DS_INT8_AS_NUMERIC, 1);
break;
case SQL_VARCHAR:
CheckDlgButton(hdlg, DS_INT8_AS_VARCHAR, 1);
break;
case SQL_DOUBLE:
CheckDlgButton(hdlg, DS_INT8_AS_DOUBLE, 1);
break;
case SQL_INTEGER:
CheckDlgButton(hdlg, DS_INT8_AS_INT4, 1);
break;
default:
CheckDlgButton(hdlg, DS_INT8_AS_DEFAULT, 1);
}
CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column));
CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index));
CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning));
CheckDlgButton(hdlg, DS_SHOWSYSTEMTABLES, atoi(ci->show_system_tables));
CheckDlgButton(hdlg, DS_DISALLOWPREMATURE, ci->disallow_premature);
CheckDlgButton(hdlg, DS_LFCONVERSION, ci->lf_conversion);
CheckDlgButton(hdlg, DS_TRUEISMINUS1, ci->true_is_minus1);
CheckDlgButton(hdlg, DS_UPDATABLECURSORS, ci->allow_keyset);
#ifndef DRIVER_CURSOR_IMPLEMENT
EnableWindow(GetDlgItem(hdlg, DS_UPDATABLECURSORS), FALSE);
#endif /* DRIVER_CURSOR_IMPLEMENT */
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
/* Datasource Connection Settings */
SetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings);
break;
case WM_COMMAND:
switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
{
case DS_SHOWOIDCOLUMN:
mylog("WM_COMMAND: DS_SHOWOIDCOLUMN\n");
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
return TRUE;
case IDOK:
case IDAPPLY:
case IDPREVPAGE:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
mylog("IDOK: got ci = %u\n", ci);
/* Readonly */
sprintf(ci->onlyread, "%d", IsDlgButtonChecked(hdlg, DS_READONLY));
/* Protocol */
if (IsDlgButtonChecked(hdlg, DS_PG62))
strcpy(ci->protocol, PG62);
else if (IsDlgButtonChecked(hdlg, DS_PG63))
strcpy(ci->protocol, PG63);
else
/* latest */
strcpy(ci->protocol, PG64);
/* Int8 As */
if (IsDlgButtonChecked(hdlg, DS_INT8_AS_DEFAULT))
ci->int8_as = 0;
else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_BIGINT))
ci->int8_as = SQL_BIGINT;
else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_NUMERIC))
ci->int8_as = SQL_NUMERIC;
else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_DOUBLE))
ci->int8_as = SQL_DOUBLE;
else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_INT4))
ci->int8_as = SQL_INTEGER;
else
ci->int8_as = SQL_VARCHAR;
sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
sprintf(ci->row_versioning, "%d", IsDlgButtonChecked(hdlg, DS_ROWVERSIONING));
ci->disallow_premature = IsDlgButtonChecked(hdlg, DS_DISALLOWPREMATURE);
ci->lf_conversion = IsDlgButtonChecked(hdlg, DS_LFCONVERSION);
ci->true_is_minus1 = IsDlgButtonChecked(hdlg, DS_TRUEISMINUS1);
#ifdef DRIVER_CURSOR_IMPLEMENT
ci->allow_keyset = IsDlgButtonChecked(hdlg, DS_UPDATABLECURSORS);
#endif /* DRIVER_CURSOR_IMPLEMENT */
/* OID Options */
sprintf(ci->fake_oid_index, "%d", IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX));
sprintf(ci->show_oid_column, "%d", IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
/* Datasource Connection Settings */
GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
if (IDAPPLY == cmd)
{
SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam);
break;
}
EndDialog(hdlg, cmd == IDOK);
if (IDOK == cmd)
return TRUE;
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) ci);
break;
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
}
}
return FALSE;
}
#endif /* WIN32 */

View File

@ -1,435 +0,0 @@
/*-------
Module: drvconn.c
*
* Description: This module contains only routines related to
* implementing SQLDriverConnect.
*
* Classes: n/a
*
* API functions: SQLDriverConnect
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <stdlib.h>
#include "connection.h"
#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#define NEAR
#else
#include <winsock.h>
#endif
#include <string.h>
#ifdef WIN32
#include <windowsx.h>
#include "resource.h"
#endif
#include "pgapifunc.h"
#ifndef TRUE
#define TRUE (BOOL)1
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
#include "dlg_specific.h"
/* prototypes */
void dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo *ci);
static void dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo *ci);
#ifdef WIN32
BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci);
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
#endif
RETCODE SQL_API
PGAPI_DriverConnect(
HDBC hdbc,
HWND hwnd,
UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn,
UCHAR FAR * szConnStrOut,
SWORD cbConnStrOutMax,
SWORD FAR * pcbConnStrOut,
UWORD fDriverCompletion)
{
static char *func = "PGAPI_DriverConnect";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci;
#ifdef WIN32
RETCODE dialog_result;
#endif
RETCODE result;
char connStrIn[MAX_CONNECT_STRING];
char connStrOut[MAX_CONNECT_STRING];
int retval;
char salt[5];
char password_required = AUTH_REQ_OK;
int len = 0;
SWORD lenStrout;
mylog("%s: entering...\n", func);
if (!conn)
{
CC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
make_string(szConnStrIn, cbConnStrIn, connStrIn);
mylog("**** PGAPI_DriverConnect: fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn);
qlog("conn=%u, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, connStrIn, fDriverCompletion);
ci = &(conn->connInfo);
/* Parse the connect string and fill in conninfo for this hdbc. */
dconn_get_connect_attributes(connStrIn, ci);
/*
* If the ConnInfo in the hdbc is missing anything, this function will
* fill them in from the registry (assuming of course there is a DSN
* given -- if not, it does nothing!)
*/
getDSNinfo(ci, CONN_DONT_OVERWRITE);
dconn_get_common_attributes(connStrIn, ci);
logs_on_off(1, ci->drivers.debug, ci->drivers.commlog);
/* Fill in any default parameters if they are not there. */
getDSNdefaults(ci);
/* initialize pg_version */
CC_initialize_pg_version(conn);
salt[0] = '\0';
#ifdef WIN32
dialog:
#endif
ci->focus_password = password_required;
switch (fDriverCompletion)
{
#ifdef WIN32
case SQL_DRIVER_PROMPT:
dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS)
return dialog_result;
break;
case SQL_DRIVER_COMPLETE_REQUIRED:
/* Fall through */
case SQL_DRIVER_COMPLETE:
/* Password is not a required parameter. */
if (ci->username[0] == '\0' ||
ci->server[0] == '\0' ||
ci->database[0] == '\0' ||
ci->port[0] == '\0' ||
password_required)
{
dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS)
return dialog_result;
}
break;
#else
case SQL_DRIVER_PROMPT:
case SQL_DRIVER_COMPLETE:
case SQL_DRIVER_COMPLETE_REQUIRED:
#endif
case SQL_DRIVER_NOPROMPT:
break;
}
/*
* Password is not a required parameter unless authentication asks for
* it. For now, I think it's better to just let the application ask
* over and over until a password is entered (the user can always hit
* Cancel to get out)
*/
if (ci->username[0] == '\0' ||
ci->server[0] == '\0' ||
ci->database[0] == '\0' ||
ci->port[0] == '\0')
{
/* (password_required && ci->password[0] == '\0')) */
return SQL_NO_DATA_FOUND;
}
/* do the actual connect */
retval = CC_connect(conn, password_required, salt);
if (retval < 0)
{ /* need a password */
if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
{
CC_log_error(func, "Need password but Driver_NoPrompt", conn);
return SQL_ERROR; /* need a password but not allowed to
* prompt so error */
}
else
{
#ifdef WIN32
password_required = -retval;
goto dialog;
#else
return SQL_ERROR; /* until a better solution is found. */
#endif
}
}
else if (retval == 0)
{
/* error msg filled in above */
CC_log_error(func, "Error from CC_Connect", conn);
return SQL_ERROR;
}
/*
* Create the Output Connection String
*/
result = SQL_SUCCESS;
lenStrout = cbConnStrOutMax;
if (conn->ms_jet && lenStrout > 255)
lenStrout = 255;
makeConnectString(connStrOut, ci, lenStrout);
len = strlen(connStrOut);
if (szConnStrOut)
{
/*
* Return the completed string to the caller. The correct method
* is to only construct the connect string if a dialog was put up,
* otherwise, it should just copy the connection input string to
* the output. However, it seems ok to just always construct an
* output string. There are possible bad side effects on working
* applications (Access) by implementing the correct behavior,
* anyway.
*/
strncpy_null(szConnStrOut, connStrOut, cbConnStrOutMax);
if (len >= cbConnStrOutMax)
{
int clen;
for (clen = strlen(szConnStrOut) - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--)
szConnStrOut[clen] = '\0';
result = SQL_SUCCESS_WITH_INFO;
conn->errornumber = CONN_TRUNCATED;
conn->errormsg = "The buffer was too small for the ConnStrOut.";
}
}
if (pcbConnStrOut)
*pcbConnStrOut = len;
mylog("szConnStrOut = '%s' len=%d,%d\n", szConnStrOut, len, cbConnStrOutMax);
qlog("conn=%u, PGAPI_DriverConnect(out)='%s'\n", conn, szConnStrOut);
mylog("PGAPI_DriverConnect: returning %d\n", result);
return result;
}
#ifdef WIN32
RETCODE
dconn_DoDialog(HWND hwnd, ConnInfo *ci)
{
int dialog_result;
mylog("dconn_DoDialog: ci = %u\n", ci);
if (hwnd)
{
dialog_result = DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_CONFIG),
hwnd, dconn_FDriverConnectProc, (LPARAM) ci);
if (!dialog_result || (dialog_result == -1))
return SQL_NO_DATA_FOUND;
else
return SQL_SUCCESS;
}
return SQL_ERROR;
}
BOOL FAR PASCAL
dconn_FDriverConnectProc(
HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
switch (wMsg)
{
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
/* Change the caption for the setup dialog */
SetWindowText(hdlg, "PostgreSQL Connection");
SetWindowText(GetDlgItem(hdlg, IDC_DATASOURCE), "Connection");
/* Hide the DSN and description fields */
ShowWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_DSNAME), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_DESC), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_DRIVER), SW_HIDE);
SetWindowLong(hdlg, DWL_USER, lParam); /* Save the ConnInfo for
* the "OK" */
SetDlgStuff(hdlg, ci);
if (ci->database[0] == '\0')
; /* default focus */
else if (ci->server[0] == '\0')
SetFocus(GetDlgItem(hdlg, IDC_SERVER));
else if (ci->port[0] == '\0')
SetFocus(GetDlgItem(hdlg, IDC_PORT));
else if (ci->username[0] == '\0')
SetFocus(GetDlgItem(hdlg, IDC_USER));
else if (ci->focus_password)
SetFocus(GetDlgItem(hdlg, IDC_PASSWORD));
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
GetDlgStuff(hdlg, ci);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
case IDC_DATASOURCE:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) ci);
break;
case IDC_DRIVER:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, driver_optionsProc, (LPARAM) ci);
break;
}
}
return FALSE;
}
#endif /* WIN32 */
void
dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo *ci)
{
char *our_connect_string;
char *pair,
*attribute,
*value,
*equals;
char *strtok_arg;
CC_conninfo_init(ci);
our_connect_string = strdup(connect_string);
strtok_arg = our_connect_string;
mylog("our_connect_string = '%s'\n", our_connect_string);
while (1)
{
pair = strtok(strtok_arg, ";");
if (strtok_arg)
strtok_arg = 0;
if (!pair)
break;
equals = strchr(pair, '=');
if (!equals)
continue;
*equals = '\0';
attribute = pair; /* ex. DSN */
value = equals + 1; /* ex. 'CEO co1' */
mylog("attribute = '%s', value = '%s'\n", attribute, value);
if (!attribute || !value)
continue;
/* Copy the appropriate value to the conninfo */
copyAttributes(ci, attribute, value);
}
free(our_connect_string);
}
static void
dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo *ci)
{
char *our_connect_string;
char *pair,
*attribute,
*value,
*equals;
char *strtok_arg;
our_connect_string = strdup(connect_string);
strtok_arg = our_connect_string;
mylog("our_connect_string = '%s'\n", our_connect_string);
while (1)
{
pair = strtok(strtok_arg, ";");
if (strtok_arg)
strtok_arg = 0;
if (!pair)
break;
equals = strchr(pair, '=');
if (!equals)
continue;
*equals = '\0';
attribute = pair; /* ex. DSN */
value = equals + 1; /* ex. 'CEO co1' */
mylog("attribute = '%s', value = '%s'\n", attribute, value);
if (!attribute || !value)
continue;
/* Copy the appropriate value to the conninfo */
copyCommonAttributes(ci, attribute, value);
}
free(our_connect_string);
}

View File

@ -1,661 +0,0 @@
/*-------
* Module: environ.c
*
* Description: This module contains routines related to
* the environment, such as storing connection handles,
* and returning errors.
*
* Classes: EnvironmentClass (Functions prefix: "EN_")
*
* API functions: SQLAllocEnv, SQLFreeEnv, SQLError
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "environ.h"
#include "connection.h"
#include "dlg_specific.h"
#include "statement.h"
#include <stdlib.h>
#include <string.h>
#include "pgapifunc.h"
extern GLOBAL_VALUES globals;
/* The one instance of the handles */
ConnectionClass *conns[MAX_CONNECTIONS];
RETCODE SQL_API
PGAPI_AllocEnv(HENV FAR * phenv)
{
static char *func = "PGAPI_AllocEnv";
mylog("**** in PGAPI_AllocEnv ** \n");
/*
* Hack for systems on which none of the constructor-making techniques
* in psqlodbc.c work: if globals appears not to have been
* initialized, then cause it to be initialized. Since this should be
* the first function called in this shared library, doing it here
* should work.
*/
if (globals.socket_buffersize <= 0)
getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL);
*phenv = (HENV) EN_Constructor();
if (!*phenv)
{
*phenv = SQL_NULL_HENV;
EN_log_error(func, "Error allocating environment", NULL);
return SQL_ERROR;
}
mylog("** exit PGAPI_AllocEnv: phenv = %u **\n", *phenv);
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_FreeEnv(HENV henv)
{
static char *func = "PGAPI_FreeEnv";
EnvironmentClass *env = (EnvironmentClass *) henv;
mylog("**** in PGAPI_FreeEnv: env = %u ** \n", env);
if (env && EN_Destructor(env))
{
mylog(" ok\n");
return SQL_SUCCESS;
}
mylog(" error\n");
EN_log_error(func, "Error freeing environment", env);
return SQL_ERROR;
}
static void
pg_sqlstate_set(const EnvironmentClass *env, UCHAR *szSqlState, const UCHAR *ver3str, const UCHAR *ver2str)
{
strcpy(szSqlState, EN_is_odbc3(env) ? ver3str : ver2str);
}
#define DRVMNGRDIV 511
/* Returns the next SQL error information. */
RETCODE SQL_API
PGAPI_StmtError( HSTMT hstmt,
SWORD RecNumber,
UCHAR FAR * szSqlState,
SDWORD FAR * pfNativeError,
UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
SWORD FAR * pcbErrorMsg,
UWORD flag)
{
/* CC: return an error of a hstmt */
StatementClass *stmt = (StatementClass *) hstmt;
EnvironmentClass *env = (EnvironmentClass *) SC_get_conn(stmt)->henv;
char *msg;
int status;
BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0),
clear_str = ((flag & PODBC_ERROR_CLEAR) != 0);
SWORD msglen, stapos, wrtlen, pcblen;
mylog("**** PGAPI_StmtError: hstmt=%u <%d>\n", hstmt, cbErrorMsgMax);
if (cbErrorMsgMax < 0)
return SQL_ERROR;
if (!SC_get_error(stmt, &status, &msg) || NULL == msg || !msg[0])
{
mylog("SC_Get_error returned nothing.\n");
if (NULL != szSqlState)
strcpy(szSqlState, "00000");
if (NULL != pcbErrorMsg)
*pcbErrorMsg = 0;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
szErrorMsg[0] = '\0';
return SQL_NO_DATA_FOUND;
}
mylog("SC_get_error: status = %d, msg = #%s#\n", status, msg);
msglen = (SWORD) strlen(msg);
/*
* Even though an application specifies a larger error message
* buffer, the driver manager changes it silently.
* Therefore we divide the error message into ...
*/
if (stmt->error_recsize < 0)
{
if (cbErrorMsgMax > 0)
stmt->error_recsize = cbErrorMsgMax - 1; /* apply the first request */
else
stmt->error_recsize = DRVMNGRDIV;
}
if (RecNumber < 0)
{
if (0 == stmt->errorpos)
RecNumber = 1;
else
RecNumber = 2 + (stmt->errorpos - 1) / stmt->error_recsize;
}
stapos = (RecNumber - 1) * stmt->error_recsize;
if (stapos > msglen)
return SQL_NO_DATA_FOUND;
pcblen = wrtlen = msglen - stapos;
if (pcblen > stmt->error_recsize)
pcblen = stmt->error_recsize;
if (0 == cbErrorMsgMax)
wrtlen = 0;
else if (wrtlen >= cbErrorMsgMax)
{
if (partial_ok)
wrtlen = cbErrorMsgMax - 1;
else if (cbErrorMsgMax <= stmt->error_recsize)
wrtlen = 0;
else
wrtlen = stmt->error_recsize;
}
if (wrtlen > pcblen)
wrtlen = pcblen;
if (NULL != pcbErrorMsg)
*pcbErrorMsg = pcblen;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
{
memcpy(szErrorMsg, msg + stapos, wrtlen);
szErrorMsg[wrtlen] = '\0';
}
if (NULL != pfNativeError)
*pfNativeError = status;
if (NULL != szSqlState)
switch (status)
{
/* now determine the SQLSTATE to be returned */
case STMT_ROW_VERSION_CHANGED:
pg_sqlstate_set(env, szSqlState, "01001", "01001");
/* data truncated */
break;
case STMT_TRUNCATED:
pg_sqlstate_set(env, szSqlState, "01004", "01004");
/* data truncated */
break;
case STMT_INFO_ONLY:
pg_sqlstate_set(env, szSqlState, "00000", "0000");
/* just information that is returned, no error */
break;
case STMT_BAD_ERROR:
pg_sqlstate_set(env, szSqlState, "08S01", "08S01");
/* communication link failure */
break;
case STMT_CREATE_TABLE_ERROR:
pg_sqlstate_set(env, szSqlState, "42S01", "S0001");
/* table already exists */
break;
case STMT_STATUS_ERROR:
case STMT_SEQUENCE_ERROR:
pg_sqlstate_set(env, szSqlState, "HY010", "S1010");
/* Function sequence error */
break;
case STMT_NO_MEMORY_ERROR:
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
/* memory allocation failure */
break;
case STMT_COLNUM_ERROR:
pg_sqlstate_set(env, szSqlState, "07009", "S1002");
/* invalid column number */
break;
case STMT_NO_STMTSTRING:
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
/* having no stmtstring is also a malloc problem */
break;
case STMT_ERROR_TAKEN_FROM_BACKEND:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
case STMT_INTERNAL_ERROR:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
case STMT_FETCH_OUT_OF_RANGE:
pg_sqlstate_set(env, szSqlState, "HY106", "S1106");
break;
case STMT_ROW_OUT_OF_RANGE:
pg_sqlstate_set(env, szSqlState, "HY107", "S1107");
break;
case STMT_OPERATION_CANCELLED:
pg_sqlstate_set(env, szSqlState, "HY008", "S1008");
break;
case STMT_NOT_IMPLEMENTED_ERROR:
pg_sqlstate_set(env, szSqlState, "HYC00", "S1C00"); /* == 'driver not
* capable' */
break;
case STMT_OPTION_OUT_OF_RANGE_ERROR:
pg_sqlstate_set(env, szSqlState, "HY092", "S1092");
break;
case STMT_BAD_PARAMETER_NUMBER_ERROR:
pg_sqlstate_set(env, szSqlState, "07009", "S1093");
break;
case STMT_INVALID_COLUMN_NUMBER_ERROR:
pg_sqlstate_set(env, szSqlState, "07009", "S1002");
break;
case STMT_RESTRICTED_DATA_TYPE_ERROR:
pg_sqlstate_set(env, szSqlState, "07006", "07006");
break;
case STMT_INVALID_CURSOR_STATE_ERROR:
pg_sqlstate_set(env, szSqlState, "07005", "24000");
break;
case STMT_ERROR_IN_ROW:
pg_sqlstate_set(env, szSqlState, "01S01", "01S01");
break;
case STMT_OPTION_VALUE_CHANGED:
pg_sqlstate_set(env, szSqlState, "01S02", "01S02");
break;
case STMT_POS_BEFORE_RECORDSET:
pg_sqlstate_set(env, szSqlState, "01S06", "01S06");
break;
case STMT_INVALID_CURSOR_NAME:
pg_sqlstate_set(env, szSqlState, "34000", "34000");
break;
case STMT_NO_CURSOR_NAME:
pg_sqlstate_set(env, szSqlState, "S1015", "S1015");
break;
case STMT_INVALID_ARGUMENT_NO:
pg_sqlstate_set(env, szSqlState, "HY024", "S1009");
/* invalid argument value */
break;
case STMT_INVALID_CURSOR_POSITION:
pg_sqlstate_set(env, szSqlState, "HY109", "S1109");
break;
case STMT_RETURN_NULL_WITHOUT_INDICATOR:
pg_sqlstate_set(env, szSqlState, "22002", "22002");
break;
case STMT_VALUE_OUT_OF_RANGE:
pg_sqlstate_set(env, szSqlState, "HY019", "22003");
break;
case STMT_OPERATION_INVALID:
pg_sqlstate_set(env, szSqlState, "HY011", "S1011");
break;
case STMT_INVALID_DESCRIPTOR_IDENTIFIER:
pg_sqlstate_set(env, szSqlState, "HY091", "HY091");
break;
case STMT_INVALID_OPTION_IDENTIFIER:
pg_sqlstate_set(env, szSqlState, "HY092", "HY092");
break;
case STMT_OPTION_NOT_FOR_THE_DRIVER:
pg_sqlstate_set(env, szSqlState, "HYC00", "HYC00");
break;
case STMT_EXEC_ERROR:
default:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* also a general error */
break;
}
mylog(" szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, pcblen, szErrorMsg);
if (clear_str)
{
stmt->errorpos = stapos + wrtlen;
if (stmt->errorpos >= msglen)
SC_clear_error(stmt);
}
if (wrtlen == 0)
return SQL_SUCCESS_WITH_INFO;
else
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_ConnectError( HDBC hdbc,
SWORD RecNumber,
UCHAR FAR * szSqlState,
SDWORD FAR * pfNativeError,
UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
SWORD FAR * pcbErrorMsg,
UWORD flag)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
EnvironmentClass *env = (EnvironmentClass *) conn->henv;
char *msg;
int status;
BOOL once_again = FALSE;
SWORD msglen;
mylog("**** PGAPI_ConnectError: hdbc=%u <%d>\n", hdbc, cbErrorMsgMax);
if (RecNumber != 1 && RecNumber != -1)
return SQL_NO_DATA_FOUND;
if (cbErrorMsgMax < 0)
return SQL_ERROR;
if (!CC_get_error(conn, &status, &msg) || NULL == msg)
{
mylog("CC_Get_error returned nothing.\n");
if (NULL != szSqlState)
strcpy(szSqlState, "00000");
if (NULL != pcbErrorMsg)
*pcbErrorMsg = 0;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
szErrorMsg[0] = '\0';
return SQL_NO_DATA_FOUND;
}
mylog("CC_get_error: status = %d, msg = #%s#\n", status, msg);
msglen = strlen(msg);
if (NULL != pcbErrorMsg)
{
*pcbErrorMsg = msglen;
if (cbErrorMsgMax == 0)
once_again = TRUE;
else if (msglen >= cbErrorMsgMax)
*pcbErrorMsg = cbErrorMsgMax - 1;
}
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
strncpy_null(szErrorMsg, msg, cbErrorMsgMax);
if (NULL != pfNativeError)
*pfNativeError = status;
if (NULL != szSqlState)
switch (status)
{
case STMT_OPTION_VALUE_CHANGED:
case CONN_OPTION_VALUE_CHANGED:
pg_sqlstate_set(env, szSqlState, "01S02", "01S02");
break;
case STMT_TRUNCATED:
case CONN_TRUNCATED:
pg_sqlstate_set(env, szSqlState, "01004", "01004");
/* data truncated */
break;
case CONN_INIREAD_ERROR:
pg_sqlstate_set(env, szSqlState, "IM002", "IM002");
/* data source not found */
break;
case CONNECTION_SERVER_NOT_REACHED:
case CONN_OPENDB_ERROR:
pg_sqlstate_set(env, szSqlState, "08001", "08001");
/* unable to connect to data source */
break;
case CONN_INVALID_AUTHENTICATION:
case CONN_AUTH_TYPE_UNSUPPORTED:
pg_sqlstate_set(env, szSqlState, "28000", "28000");
break;
case CONN_STMT_ALLOC_ERROR:
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
/* memory allocation failure */
break;
case CONN_IN_USE:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
case CONN_UNSUPPORTED_OPTION:
pg_sqlstate_set(env, szSqlState, "IM001", "IM001");
/* driver does not support this function */
case CONN_INVALID_ARGUMENT_NO:
pg_sqlstate_set(env, szSqlState, "HY009", "S1009");
/* invalid argument value */
break;
case CONN_TRANSACT_IN_PROGRES:
pg_sqlstate_set(env, szSqlState, "HY010", "S1010");
/*
* when the user tries to switch commit mode in a
* transaction
*/
/* -> function sequence error */
break;
case CONN_NO_MEMORY_ERROR:
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
break;
case CONN_NOT_IMPLEMENTED_ERROR:
case STMT_NOT_IMPLEMENTED_ERROR:
pg_sqlstate_set(env, szSqlState, "HYC00", "S1C00");
break;
case STMT_RETURN_NULL_WITHOUT_INDICATOR:
pg_sqlstate_set(env, szSqlState, "22002", "22002");
break;
case CONN_VALUE_OUT_OF_RANGE:
case STMT_VALUE_OUT_OF_RANGE:
pg_sqlstate_set(env, szSqlState, "HY019", "22003");
break;
default:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
}
mylog(" szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, msglen, szErrorMsg);
if (once_again)
{
conn->errornumber = status;
return SQL_SUCCESS_WITH_INFO;
}
else
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_EnvError( HENV henv,
SWORD RecNumber,
UCHAR FAR * szSqlState,
SDWORD FAR * pfNativeError,
UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
SWORD FAR * pcbErrorMsg,
UWORD flag)
{
EnvironmentClass *env = (EnvironmentClass *) henv;
char *msg;
int status;
mylog("**** PGAPI_EnvError: henv=%u <%d>\n", henv, cbErrorMsgMax);
if (RecNumber != 1 && RecNumber != -1)
return SQL_NO_DATA_FOUND;
if (cbErrorMsgMax < 0)
return SQL_ERROR;
if (!EN_get_error(env, &status, &msg) || NULL == msg)
{
mylog("EN_get_error: status = %d, msg = #%s#\n", status, msg);
if (NULL != szSqlState)
pg_sqlstate_set(env, szSqlState, "00000", "00000");
if (NULL != pcbErrorMsg)
*pcbErrorMsg = 0;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
szErrorMsg[0] = '\0';
return SQL_NO_DATA_FOUND;
}
mylog("EN_get_error: status = %d, msg = #%s#\n", status, msg);
if (NULL != pcbErrorMsg)
*pcbErrorMsg = (SWORD) strlen(msg);
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
strncpy_null(szErrorMsg, msg, cbErrorMsgMax);
if (NULL != pfNativeError)
*pfNativeError = status;
if (szSqlState)
{
switch (status)
{
case ENV_ALLOC_ERROR:
/* memory allocation failure */
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
break;
default:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
}
}
return SQL_SUCCESS;
}
/* Returns the next SQL error information. */
RETCODE SQL_API
PGAPI_Error(
HENV henv,
HDBC hdbc,
HSTMT hstmt,
UCHAR FAR * szSqlState,
SDWORD FAR * pfNativeError,
UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
SWORD FAR * pcbErrorMsg)
{
RETCODE ret;
UWORD flag = PODBC_ALLOW_PARTIAL_EXTRACT | PODBC_ERROR_CLEAR;
mylog("**** PGAPI_Error: henv=%u, hdbc=%u hstmt=%d\n", henv, hdbc, hstmt);
if (cbErrorMsgMax < 0)
return SQL_ERROR;
if (SQL_NULL_HSTMT != hstmt)
ret = PGAPI_StmtError(hstmt, -1, szSqlState, pfNativeError,
szErrorMsg, cbErrorMsgMax, pcbErrorMsg, flag);
else if (SQL_NULL_HDBC != hdbc)
ret = PGAPI_ConnectError(hdbc, -1, szSqlState, pfNativeError,
szErrorMsg, cbErrorMsgMax, pcbErrorMsg, flag);
else if (SQL_NULL_HENV != hdbc)
ret = PGAPI_EnvError(henv, -1, szSqlState, pfNativeError,
szErrorMsg, cbErrorMsgMax, pcbErrorMsg, flag);
else
{
if (NULL != szSqlState)
strcpy(szSqlState, "00000");
if (NULL != pcbErrorMsg)
*pcbErrorMsg = 0;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
szErrorMsg[0] = '\0';
ret = SQL_NO_DATA_FOUND;
}
mylog("**** PGAPI_Error exit code=%d\n", ret);
return ret;
}
/*
* EnvironmentClass implementation
*/
EnvironmentClass *
EN_Constructor(void)
{
EnvironmentClass *rv;
rv = (EnvironmentClass *) malloc(sizeof(EnvironmentClass));
if (rv)
{
rv->errormsg = 0;
rv->errornumber = 0;
rv->flag = 0;
}
return rv;
}
char
EN_Destructor(EnvironmentClass *self)
{
int lf;
char rv = 1;
mylog("in EN_Destructor, self=%u\n", self);
/*
* the error messages are static strings distributed throughout the
* source--they should not be freed
*/
/* Free any connections belonging to this environment */
for (lf = 0; lf < MAX_CONNECTIONS; lf++)
{
if (conns[lf] && conns[lf]->henv == self)
rv = rv && CC_Destructor(conns[lf]);
}
free(self);
mylog("exit EN_Destructor: rv = %d\n", rv);
#ifdef _MEMORY_DEBUG_
debug_memory_check();
#endif /* _MEMORY_DEBUG_ */
return rv;
}
char
EN_get_error(EnvironmentClass *self, int *number, char **message)
{
if (self && self->errormsg && self->errornumber)
{
*message = self->errormsg;
*number = self->errornumber;
self->errormsg = 0;
self->errornumber = 0;
return 1;
}
else
return 0;
}
char
EN_add_connection(EnvironmentClass *self, ConnectionClass *conn)
{
int i;
mylog("EN_add_connection: self = %u, conn = %u\n", self, conn);
for (i = 0; i < MAX_CONNECTIONS; i++)
{
if (!conns[i])
{
conn->henv = self;
conns[i] = conn;
mylog(" added at i =%d, conn->henv = %u, conns[i]->henv = %u\n", i, conn->henv, conns[i]->henv);
return TRUE;
}
}
return FALSE;
}
char
EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
{
int i;
for (i = 0; i < MAX_CONNECTIONS; i++)
if (conns[i] == conn && conns[i]->status != CONN_EXECUTING)
{
conns[i] = NULL;
return TRUE;
}
return FALSE;
}
void
EN_log_error(char *func, char *desc, EnvironmentClass *self)
{
if (self)
qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
else
qlog("INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
}

View File

@ -1,38 +0,0 @@
/* File: environ.h
*
* Description: See "environ.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __ENVIRON_H__
#define __ENVIRON_H__
#include "psqlodbc.h"
#define ENV_ALLOC_ERROR 1
/********** Environment Handle *************/
struct EnvironmentClass_
{
char *errormsg;
int errornumber;
Int4 flag;
};
/* Environment prototypes */
EnvironmentClass *EN_Constructor(void);
char EN_Destructor(EnvironmentClass *self);
char EN_get_error(EnvironmentClass *self, int *number, char **message);
char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn);
char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn);
void EN_log_error(char *func, char *desc, EnvironmentClass *self);
#define EN_OV_ODBC2 1L
#define EN_is_odbc2(env) ((env->flag & EN_OV_ODBC2) != 0)
#define EN_is_odbc3(env) ((env->flag & EN_OV_ODBC2) == 0)
#define EN_set_odbc2(env) (env->flag |= EN_OV_ODBC2)
#define EN_set_odbc3(env) (env->flag &= EN_OV_ODBC2)
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,454 +0,0 @@
/*-------
* GetPrivateProfileString()
*
* approximate implementation of
* Windows NT System Services version of GetPrivateProfileString()
* probably doesn't handle the NULL key for section name or value key
* correctly also, doesn't provide Microsoft backwards compatability
* wrt TAB characters in the value string
*
* Microsoft terminates value
* at the first TAB, but I couldn't discover what the behavior should
* be regarding TABS in quoted strings so, I treat tabs like any other
* characters
*
* NO comments following value string separated by a TAB
* are allowed (that is an anachronism anyway)
* Added code to search for ODBC_INI file in users home directory on
* Unix
*-------
*/
#if !defined(WIN32) && !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
#include "gpps.h"
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#if HAVE_PWD_H
#include <pwd.h>
#endif
#include <sys/types.h>
#include <string.h>
#include "misc.h"
#include "dlg_specific.h"
#ifndef TRUE
#define TRUE ((BOOL)1)
#endif
#ifndef FALSE
#define FALSE ((BOOL)0)
#endif
#ifndef ODBCINSTDIR
#error "ODBCINSTDIR must be defined to compile this file"
#endif
/*
* theIniFileName is searched for in:
* $HOME/theIniFileName
* theIniFileName
* ODBCINSTDIR/ODBCINST_INI
*/
DWORD
GetPrivateProfileString(const char *theSection, /* section name */
const char *theKey, /* search key name */
const char *theDefault, /* default value if not
* found */
char *theReturnBuffer, /* return value stored
* here */
size_t theReturnBufferLength, /* byte length of return
* buffer */
const char *theIniFileName) /* pathname of ini file
* to search */
{
char buf[MAXPGPATH];
char *ptr = 0;
FILE *aFile = 0;
size_t aLength;
char aLine[2048];
char *aValue;
char *aStart;
char *aString;
size_t aLineLength;
size_t aReturnLength = 0;
BOOL aSectionFound = FALSE;
BOOL aKeyFound = FALSE;
ptr = (char *) getpwuid(getuid()); /* get user info */
if (ptr == NULL || (((struct passwd *) ptr)->pw_dir) == NULL || *(((struct passwd *) ptr)->pw_dir) == '\0')
ptr = "/home";
else
ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */
/*
* If it can't be opened because the paths are too long, then skip it,
* don't just truncate the path string... The truncated path might
* accidently be an existing file. The default value will be returned
* instead.
*/
if (MAXPGPATH - 1 >= strlen(ptr) + 1 + strlen(theIniFileName))
{
sprintf(buf, "%s/%s", ptr, theIniFileName);
aFile = (FILE *) fopen(buf, PG_BINARY_R);
}
/*
* This code makes it so that a file in the users home dir overrides a
* the "default" file as passed in
*/
if (!aFile)
{
aFile = (FILE *) fopen(theIniFileName, PG_BINARY_R);
if (!aFile)
aFile = (FILE *) fopen(ODBCINSTDIR "/" ODBCINST_INI, PG_BINARY_R);
}
aLength = (theDefault == NULL) ? 0 : strlen(theDefault);
if (theReturnBufferLength == 0 || theReturnBuffer == NULL)
{
if (aFile)
fclose(aFile);
return 0;
}
if (aFile == NULL)
{
/* no ini file specified, return the default */
++aLength; /* room for NULL char */
aLength = theReturnBufferLength < aLength ?
theReturnBufferLength : aLength;
strncpy(theReturnBuffer, theDefault, aLength);
theReturnBuffer[aLength - 1] = '\0';
return aLength - 1;
}
while (fgets(aLine, sizeof(aLine), aFile) != NULL)
{
aLineLength = strlen(aLine);
/* strip final '\n' */
if (aLineLength > 0 && aLine[aLineLength - 1] == '\n')
aLine[aLineLength - 1] = '\0';
switch (*aLine)
{
case ' ': /* blank line */
case ';': /* comment line */
continue;
break;
case '[': /* section marker */
if ((aString = strchr(aLine, ']')))
{
aStart = aLine + 1;
aString--;
while (isspace((unsigned char) *aStart))
aStart++;
while (isspace((unsigned char) *aString))
aString--;
*(aString + 1) = '\0';
/* accept as matched if NULL key or exact match */
if (!theSection || !strcmp(aStart, theSection))
aSectionFound = TRUE;
else
aSectionFound = FALSE;
}
break;
default:
/* try to match value keys if in proper section */
if (aSectionFound)
{
/* try to match requested key */
if ((aString = aValue = strchr(aLine, '=')))
{
*aValue = '\0';
++aValue;
/* strip leading blanks in value field */
while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
*aValue++ = '\0';
if (aValue >= aLine + sizeof(aLine))
aValue = "";
}
else
aValue = "";
aStart = aLine;
while (isspace((unsigned char) *aStart))
aStart++;
/* strip trailing blanks from key */
if (aString)
{
while (--aString >= aStart && *aString == ' ')
*aString = '\0';
}
/* see if key is matched */
if (theKey == NULL || !strcmp(theKey, aStart))
{
/* matched -- first, terminate value part */
aKeyFound = TRUE;
aLength = strlen(aValue);
/* remove trailing blanks from aValue if any */
aString = aValue + aLength - 1;
while (--aString > aValue && *aString == ' ')
{
*aString = '\0';
--aLength;
}
/* unquote value if quoted */
if (aLength >= 2 && aValue[0] == '"' &&
aValue[aLength - 1] == '"')
{
/* string quoted with double quotes */
aValue[aLength - 1] = '\0';
++aValue;
aLength -= 2;
}
else
{
/* single quotes allowed also... */
if (aLength >= 2 && aValue[0] == '\'' &&
aValue[aLength - 1] == '\'')
{
aValue[aLength - 1] = '\0';
++aValue;
aLength -= 2;
}
}
/* compute maximum length copyable */
aLineLength = (aLength <
theReturnBufferLength - aReturnLength) ? aLength :
theReturnBufferLength - aReturnLength;
/* do the copy to return buffer */
if (aLineLength)
{
strncpy(&theReturnBuffer[aReturnLength],
aValue, aLineLength);
aReturnLength += aLineLength;
if (aReturnLength < theReturnBufferLength)
{
theReturnBuffer[aReturnLength] = '\0';
++aReturnLength;
}
}
if (aFile)
{
fclose(aFile);
aFile = NULL;
}
return aReturnLength > 0 ? aReturnLength - 1 : 0;
}
}
break;
}
}
if (aFile)
fclose(aFile);
if (!aKeyFound)
{
/* key wasn't found return default */
++aLength; /* room for NULL char */
aLength = theReturnBufferLength < aLength ?
theReturnBufferLength : aLength;
strncpy(theReturnBuffer, theDefault, aLength);
theReturnBuffer[aLength - 1] = '\0';
aReturnLength = aLength - 1;
}
return aReturnLength > 0 ? aReturnLength - 1 : 0;
}
DWORD
WritePrivateProfileString(const char *theSection, /* section name */
const char *theKey, /* write key name */
const char *theBuffer, /* input buffer */
const char *theIniFileName) /* pathname of ini file
* to write */
{
return 0;
}
#if NOT_USED
/*
* Ok. What the hell's the default behaviour for a null input buffer, and null
* section name. For now if either are null I ignore the request, until
* I find out different.
*/
DWORD
WritePrivateProfileString(char *theSection, /* section name */
char *theKey, /* write key name */
char *theBuffer, /* input buffer */
char *theIniFileName) /* pathname of ini file to
* write */
{
char buf[MAXPGPATH];
char *ptr = 0;
FILE *aFile = 0;
size_t aLength;
char aLine[2048];
char *aValue;
char *aString;
size_t aLineLength;
size_t aReturnLength = 0;
BOOL aSectionFound = FALSE;
BOOL keyFound = FALSE;
int j = 0;
/* If this isn't correct processing we'll change it later */
if (theSection == NULL || theKey == NULL || theBuffer == NULL ||
theIniFileName == NULL)
return 0;
aLength = strlen(theBuffer);
if (aLength == 0)
return 0;
j = strlen(theIniFileName) + 1;
ptr = (char *) getpwuid(getuid()); /* get user info */
if (ptr == NULL)
{
if (MAXPGPATH - 1 < j)
theIniFileName[MAXPGPATH - 1] = '\0';
sprintf(buf, "%s", theIniFileName);
}
ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */
if (ptr == NULL || *ptr == '\0')
ptr = "/home";
/*
* This doesn't make it so we find an ini file but allows normal
* processing to continue further on down. The likelihood is that the
* file won't be found and thus the default value will be returned.
*/
if (MAXPGPATH - 1 < strlen(ptr) + j)
{
if (MAXPGPATH - 1 < strlen(ptr))
ptr[MAXPGPATH - 1] = '\0';
else
theIniFileName[MAXPGPATH - 1 - strlen(ptr)] = '\0';
}
sprintf(buf, "%s/%s", ptr, theIniFileName);
/*
* This code makes it so that a file in the users home dir overrides a
* the "default" file as passed in
*/
aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
if (!aFile)
{
sprintf(buf, "%s", theIniFileName);
aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
if (!aFile)
return 0;
}
aLength = strlen(theBuffer);
/*
* We have to search for theKey, because if it already exists we have
* to overwrite it. If it doesn't exist we just write a new line to
* the file.
*/
while (fgets(aLine, sizeof(aLine), aFile) != NULL)
{
aLineLength = strlen(aLine);
/* strip final '\n' */
if (aLineLength > 0 && aLine[aLineLength - 1] == '\n')
aLine[aLineLength - 1] = '\0';
switch (*aLine)
{
case ' ': /* blank line */
case ';': /* comment line */
continue;
break;
case '[': /* section marker */
if ((aString = strchr(aLine, ']')))
{
*aString = '\0';
/* accept as matched if key exact match */
if (!strcmp(aLine + 1, theSection))
aSectionFound = TRUE;
}
break;
default:
/* try to match value keys if in proper section */
if (aSectionFound)
{
/* try to match requested key */
if ((aString = aValue = strchr(aLine, '=')))
{
*aValue = '\0';
++aValue;
/* strip leading blanks in value field */
while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
*aValue++ = '\0';
if (aValue >= aLine + sizeof(aLine))
aValue = "";
}
else
aValue = "";
/* strip trailing blanks from key */
if (aString)
{
while (--aString >= aLine && *aString == ' ')
*aString = '\0';
}
/* see if key is matched */
if (!strcmp(theKey, aLine))
{
keyFound = TRUE;
/* matched -- first, terminate value part */
/* overwrite current value */
fseek(aFile, -aLineLength, SEEK_CUR);
/* overwrite key and value */
sprintf(aLine, "%s = %s\n", theKey, theBuffer);
fputs(aLine, aFile);
}
}
}
break;
}
}
if (!keyFound)
{ /* theKey wasn't in file so */
if (aFile)
fclose(aFile);
return aReturnLength > 0 ? aReturnLength - 1 : 0;
}
#endif /* NOT_USED */
#endif /* not WIN32 */

View File

@ -1,48 +0,0 @@
/* GetPrivateProfileString
* for UNIX use
*/
#ifndef GPPS_H
#define GPPS_H
#include "psqlodbc.h"
#ifndef WIN32
#include <sys/types.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"
{
#endif
DWORD
GetPrivateProfileString(const char *theSection, /* section name */
const char *theKey, /* search key name */
const char *theDefault, /* default value if not
* found */
char *theReturnBuffer, /* return valuse stored
* here */
size_t theBufferLength, /* byte length of return
* buffer */
const char *theIniFileName); /* pathname of ini file
* to search */
DWORD
WritePrivateProfileString(const char *theSection, /* section name */
const char *theKey, /* write key name */
const char *theBuffer, /* input buffer */
const char *theIniFileName); /* pathname of ini file
* to write */
#ifdef __cplusplus
}
#endif
#ifndef WIN32
#undef DWORD
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,396 +0,0 @@
/*-------
* Module: info30.c
*
* Description: This module contains routines related to ODBC 3.0
* SQLGetInfo().
*
*/
#ifndef ODBCVER
#define ODBCVER 0x0300
#endif
#include "connection.h"
#include "pgapifunc.h"
RETCODE SQL_API
PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
SWORD cbInfoValueMax, SWORD FAR * pcbInfoValue)
{
static char *func = "PGAPI_GetInfo30";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci = &(conn->connInfo);
char *p = NULL;
int len = 0,
value = 0;
RETCODE result;
switch (fInfoType)
{
case SQL_DYNAMIC_CURSOR_ATTRIBUTES1:
len = 4;
value = 0;
break;
case SQL_DYNAMIC_CURSOR_ATTRIBUTES2:
len = 4;
value = 0;
break;
case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1:
len = 4;
value = SQL_CA1_NEXT; /* others aren't allowed in ODBC spec */
break;
case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2:
len = 4;
value = SQL_CA2_READ_ONLY_CONCURRENCY;
break;
case SQL_KEYSET_CURSOR_ATTRIBUTES1:
len = 4;
value = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE
| SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK
| SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_POS_POSITION
| SQL_CA1_POS_REFRESH;
if (ci->updatable_cursors || ci->drivers.lie)
value |= (SQL_CA1_POS_UPDATE | SQL_CA1_POS_DELETE
| SQL_CA1_BULK_ADD
| SQL_CA1_BULK_UPDATE_BY_BOOKMARK
| SQL_CA1_BULK_DELETE_BY_BOOKMARK
| SQL_CA1_BULK_FETCH_BY_BOOKMARK
);
if (ci->drivers.lie)
value |= (SQL_CA1_LOCK_EXCLUSIVE
| SQL_CA1_LOCK_UNLOCK
| SQL_CA1_POSITIONED_UPDATE
| SQL_CA1_POSITIONED_DELETE
| SQL_CA1_SELECT_FOR_UPDATE
);
break;
case SQL_KEYSET_CURSOR_ATTRIBUTES2:
len = 4;
value = SQL_CA2_READ_ONLY_CONCURRENCY;
if (ci->updatable_cursors || ci->drivers.lie)
value |= (SQL_CA2_OPT_ROWVER_CONCURRENCY
/*| SQL_CA2_CRC_APPROXIMATE*/
| SQL_CA2_CRC_EXACT
| SQL_CA2_SENSITIVITY_DELETIONS
| SQL_CA2_SENSITIVITY_UPDATES
/* | SQL_CA2_SENSITIVITY_ADDITIONS */
);
if (ci->drivers.lie)
value |= (SQL_CA2_READ_ONLY_CONCURRENCY
| SQL_CA2_LOCK_CONCURRENCY
| SQL_CA2_OPT_VALUES_CONCURRENCY
| SQL_CA2_MAX_ROWS_SELECT
| SQL_CA2_MAX_ROWS_INSERT
| SQL_CA2_MAX_ROWS_DELETE
| SQL_CA2_MAX_ROWS_UPDATE
| SQL_CA2_MAX_ROWS_CATALOG
| SQL_CA2_MAX_ROWS_AFFECTS_ALL
| SQL_CA2_SIMULATE_NON_UNIQUE
| SQL_CA2_SIMULATE_TRY_UNIQUE
| SQL_CA2_SIMULATE_UNIQUE
);
break;
case SQL_STATIC_CURSOR_ATTRIBUTES1:
len = 4;
value = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE
| SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK
| SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_POS_POSITION
| SQL_CA1_POS_REFRESH;
if (ci->updatable_cursors)
value |= (SQL_CA1_POS_UPDATE | SQL_CA1_POS_DELETE
| SQL_CA1_BULK_ADD
);
break;
case SQL_STATIC_CURSOR_ATTRIBUTES2:
len = 4;
value = SQL_CA2_READ_ONLY_CONCURRENCY;
if (ci->updatable_cursors)
value |= (SQL_CA2_OPT_ROWVER_CONCURRENCY
| SQL_CA2_CRC_EXACT
/* | SQL_CA2_SENSITIVITY_ADDITIONS
| SQL_CA2_SENSITIVITY_DELETIONS
| SQL_CA2_SENSITIVITY_UPDATES */
);
break;
case SQL_ODBC_INTERFACE_CONFORMANCE:
len = 4;
value = SQL_OIC_CORE;
if (ci->drivers.lie)
value = SQL_OIC_LEVEL2;
break;
case SQL_ACTIVE_ENVIRONMENTS:
len = 2;
value = 0;
break;
case SQL_AGGREGATE_FUNCTIONS:
len = 4;
value = SQL_AF_ALL;
break;
case SQL_ALTER_DOMAIN:
len = 4;
value = 0;
break;
case SQL_ASYNC_MODE:
len = 4;
value = SQL_AM_NONE;
break;
case SQL_BATCH_ROW_COUNT:
len = 4;
value = SQL_BRC_EXPLICIT;
break;
case SQL_BATCH_SUPPORT:
len = 4;
value = SQL_BS_SELECT_EXPLICIT | SQL_BS_ROW_COUNT_EXPLICIT;
break;
case SQL_CATALOG_NAME:
len = 0;
if (PG_VERSION_LE(conn, 7.2))
p = "N";
else
p = "Y"; /* hopefully */
break;
case SQL_COLLATION_SEQ:
len = 0;
p = "";
break;
case SQL_CREATE_ASSERTION:
len = 4;
value = 0;
break;
case SQL_CREATE_CHARACTER_SET:
len = 4;
value = 0;
break;
case SQL_CREATE_COLLATION:
len = 4;
value = 0;
break;
case SQL_CREATE_DOMAIN:
len = 4;
value = 0;
break;
case SQL_CREATE_SCHEMA:
len = 4;
if (conn->schema_support)
value = SQL_CS_CREATE_SCHEMA | SQL_CS_AUTHORIZATION;
else
value = 0;
break;
case SQL_CREATE_TABLE:
len = 4;
value = SQL_CT_CREATE_TABLE | SQL_CT_TABLE_CONSTRAINT
| SQL_CT_CONSTRAINT_NAME_DEFINITION
| SQL_CT_LOCAL_TEMPORARY | SQL_CT_COLUMN_CONSTRAINT
| SQL_CT_COLUMN_DEFAULT | SQL_CT_CONSTRAINT_INITIALLY_DEFERRED
| SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE | SQL_CT_CONSTRAINT_DEFERRABLE;
break;
case SQL_CREATE_TRANSLATION:
len = 4;
value = 0;
break;
case SQL_CREATE_VIEW:
len = 4;
value = SQL_CV_CREATE_VIEW;
break;
case SQL_DDL_INDEX:
len = 4;
value = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX;
break;
case SQL_DESCRIBE_PARAMETER:
len = 0;
p = "N";
break;
case SQL_DROP_ASSERTION:
len = 4;
value = 0;
break;
case SQL_DROP_CHARACTER_SET:
len = 4;
value = 0;
break;
case SQL_DROP_COLLATION:
len = 4;
value = 0;
break;
case SQL_DROP_DOMAIN:
len = 4;
value = 0;
break;
case SQL_DROP_SCHEMA:
len = 4;
if (conn->schema_support)
value = SQL_DS_DROP_SCHEMA | SQL_DS_RESTRICT | SQL_DS_CASCADE;
else
value = 0;
break;
case SQL_DROP_TABLE:
len = 4;
value = SQL_DT_DROP_TABLE;
if (PG_VERSION_GT(conn, 7.2)) /* hopefully */
value |= (SQL_DT_RESTRICT | SQL_DT_CASCADE);
break;
case SQL_DROP_TRANSLATION:
len = 4;
value = 0;
break;
case SQL_DROP_VIEW:
len = 4;
value = SQL_DV_DROP_VIEW;
if (PG_VERSION_GT(conn, 7.2)) /* hopefully */
value |= (SQL_DV_RESTRICT | SQL_DV_CASCADE);
break;
case SQL_INDEX_KEYWORDS:
len = 4;
value = SQL_IK_NONE;
case SQL_INFO_SCHEMA_VIEWS:
len = 4;
value = 0;
break;
case SQL_INSERT_STATEMENT:
len = 4;
value = SQL_IS_INSERT_LITERALS | SQL_IS_INSERT_SEARCHED | SQL_IS_SELECT_INTO;
break;
case SQL_MAX_IDENTIFIER_LEN:
len = 4;
value = 32;
break;
case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
len = 0;
p = "Y";
break;
case SQL_PARAM_ARRAY_ROW_COUNTS:
len = 4;
value = SQL_PARC_BATCH;
break;
case SQL_PARAM_ARRAY_SELECTS:
len = 4;
value = SQL_PAS_BATCH;
break;
case SQL_SQL_CONFORMANCE:
len = 4;
value = SQL_SC_SQL92_ENTRY;
break;
case SQL_SQL92_DATETIME_FUNCTIONS:
len = 4;
value = SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIME | SQL_SDF_CURRENT_TIMESTAMP;
break;
case SQL_SQL92_FOREIGN_KEY_DELETE_RULE:
len = 4;
value = SQL_SFKD_CASCADE | SQL_SFKD_NO_ACTION | SQL_SFKD_SET_DEFAULT | SQL_SFKD_SET_NULL;
break;
case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE:
len = 4;
value = SQL_SFKU_CASCADE | SQL_SFKU_NO_ACTION | SQL_SFKU_SET_DEFAULT | SQL_SFKU_SET_NULL;
break;
case SQL_SQL92_GRANT:
len = 4;
value = SQL_SG_DELETE_TABLE | SQL_SG_INSERT_TABLE | SQL_SG_REFERENCES_TABLE | SQL_SG_SELECT_TABLE | SQL_SG_UPDATE_TABLE;
break;
case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS:
len = 4;
value = SQL_SNVF_BIT_LENGTH | SQL_SNVF_CHAR_LENGTH
| SQL_SNVF_CHARACTER_LENGTH | SQL_SNVF_EXTRACT
| SQL_SNVF_OCTET_LENGTH | SQL_SNVF_POSITION;
break;
case SQL_SQL92_PREDICATES:
len = 4;
value = SQL_SP_BETWEEN | SQL_SP_COMPARISON
| SQL_SP_EXISTS | SQL_SP_IN
| SQL_SP_ISNOTNULL | SQL_SP_ISNULL
| SQL_SP_LIKE | SQL_SP_OVERLAPS
| SQL_SP_QUANTIFIED_COMPARISON;
break;
case SQL_SQL92_RELATIONAL_JOIN_OPERATORS:
len = 4;
if (PG_VERSION_GE(conn, 7.1))
value = SQL_SRJO_CROSS_JOIN | SQL_SRJO_EXCEPT_JOIN
| SQL_SRJO_FULL_OUTER_JOIN | SQL_SRJO_INNER_JOIN
| SQL_SRJO_INTERSECT_JOIN | SQL_SRJO_LEFT_OUTER_JOIN
| SQL_SRJO_NATURAL_JOIN | SQL_SRJO_RIGHT_OUTER_JOIN
| SQL_SRJO_UNION_JOIN;
break;
case SQL_SQL92_REVOKE:
len = 4;
value = SQL_SR_DELETE_TABLE | SQL_SR_INSERT_TABLE | SQL_SR_REFERENCES_TABLE | SQL_SR_SELECT_TABLE | SQL_SR_UPDATE_TABLE;
break;
case SQL_SQL92_ROW_VALUE_CONSTRUCTOR:
len = 4;
value = SQL_SRVC_VALUE_EXPRESSION | SQL_SRVC_NULL;
break;
case SQL_SQL92_STRING_FUNCTIONS:
len = 4;
value = SQL_SSF_CONVERT | SQL_SSF_LOWER
| SQL_SSF_UPPER | SQL_SSF_SUBSTRING
| SQL_SSF_TRANSLATE | SQL_SSF_TRIM_BOTH
| SQL_SSF_TRIM_LEADING | SQL_SSF_TRIM_TRAILING;
break;
case SQL_SQL92_VALUE_EXPRESSIONS:
len = 4;
value = SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF;
break;
/* The followings aren't implemented yet */
case SQL_DATETIME_LITERALS:
len = 4;
case SQL_DM_VER:
len = 0;
case SQL_DRIVER_HDESC:
len = 4;
case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS:
len = 4;
case SQL_STANDARD_CLI_CONFORMANCE:
len = 4;
case SQL_XOPEN_CLI_YEAR:
len = 0;
default:
/* unrecognized key */
conn->errormsg = "Unrecognized key passed to SQLGetInfo30.";
conn->errornumber = CONN_NOT_IMPLEMENTED_ERROR;
CC_log_error(func, "", conn);
return SQL_ERROR;
}
result = SQL_SUCCESS;
mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "<NULL>", len, value, cbInfoValueMax);
if (p)
{
/* char/binary data */
len = strlen(p);
if (rgbInfoValue)
{
#ifdef UNICODE_SUPPORT
if (conn->unicode)
{
len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / 2);
len *= 2;
}
else
#endif /* UNICODE_SUPPORT */
strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax);
if (len >= cbInfoValueMax)
{
result = SQL_SUCCESS_WITH_INFO;
conn->errornumber = CONN_TRUNCATED;
conn->errormsg = "The buffer was too small for tthe InfoValue.";
}
}
}
else
{
/* numeric data */
if (rgbInfoValue)
{
if (len == 2)
*((WORD *) rgbInfoValue) = (WORD) value;
else if (len == 4)
*((DWORD *) rgbInfoValue) = (DWORD) value;
}
}
if (pcbInfoValue)
*pcbInfoValue = len;
return result;
}

View File

@ -1,68 +0,0 @@
#ifndef _IODBC_H
#define _IODBC_H
#if !defined(WIN32) && !defined(WIN32_SYSTEM)
#define _UNIX_
#include <stdlib.h>
#include <sys/types.h>
#define MEM_ALLOC(size) (malloc((size_t)(size)))
#define MEM_FREE(ptr) \
do { \
if(ptr) \
free(ptr); \
} while (0)
#define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
#define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
#define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
#define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
#define STREQ(a, b) (strcmp((char*)(a), (char*)(b)) == 0)
#define STRLEN(str) ((str)? strlen((char*)(str)):0)
#define EXPORT
#define CALLBACK
#define FAR
typedef signed short SSHOR;
typedef short WORD;
typedef long DWORD;
typedef WORD WPARAM;
typedef DWORD LPARAM;
typedef void *HWND;
typedef int BOOL;
#endif /* _UNIX_ */
#if defined(WIN32) || defined(WIN32_SYSTEM)
#include <windows.h>
#include <windowsx.h>
#ifdef _MSVC_
#define MEM_ALLOC(size) (fmalloc((size_t)(size)))
#define MEM_FREE(ptr) ((ptr)? ffree((PTR)(ptr)):0))
#define STRCPY(t, s) (fstrcpy((char FAR*)(t), (char FAR*)(s)))
#define STRNCPY(t,s,n) (fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
#define STRLEN(str) ((str)? fstrlen((char FAR*)(str)):0)
#define STREQ(a, b) (fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
#endif
#ifdef _BORLAND_
#define MEM_ALLOC(size) (farmalloc((unsigned long)(size))
#define MEM_FREE(ptr) ((ptr)? farfree((void far*)(ptr)):0)
#define STRCPY(t, s) (_fstrcpy((char FAR*)(t), (char FAR*)(s)))
#define STRNCPY(t,s,n) (_fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
#define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0)
#define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
#endif
#endif /* WIN32 */
#define SYSERR (-1)
#ifndef NULL
#define NULL ((void FAR*)0UL)
#endif
#endif

View File

@ -1,246 +0,0 @@
/*
* Modified isql.h file from iodbc. This file should be placed in the
* include path to be used to create ODBC compliant applications.
*/
#ifndef _INTRINSIC_SQL_H
#define _INTRINSIC_SQL_H
typedef unsigned char UCHAR;
typedef long int SDWORD;
typedef short int SWORD;
typedef unsigned long int UDWORD;
typedef unsigned short int UWORD;
typedef void FAR *PTR;
typedef void FAR *HENV;
typedef void FAR *HDBC;
typedef void FAR *HSTMT;
typedef signed short RETCODE;
#ifdef WIN32
#define SQL_API __stdcall
#else
#define SQL_API EXPORT CALLBACK
#endif
/*#define ODBCVER 0x0250 */
#define SQL_MAX_MESSAGE_LENGTH 512
#define SQL_MAX_DSN_LENGTH 32
/* return code */
#define SQL_INVALID_HANDLE (-2)
#define SQL_ERROR (-1)
#define SQL_SUCCESS 0
#define SQL_SUCCESS_WITH_INFO 1
#define SQL_NO_DATA_FOUND 100
/* standard SQL datatypes (agree with ANSI type numbering) */
#define SQL_CHAR 1
#define SQL_NUMERIC 2
#define SQL_DECIMAL 3
#define SQL_INTEGER 4
#define SQL_SMALLINT 5
#define SQL_FLOAT 6
#define SQL_REAL 7
#define SQL_DOUBLE 8
#define SQL_VARCHAR 12
#define SQL_TYPE_MIN SQL_CHAR
#define SQL_TYPE_NULL 0
#define SQL_TYPE_MAX SQL_VARCHAR
/* C to SQL datatype mapping */
#define SQL_C_CHAR SQL_CHAR
#define SQL_C_LONG SQL_INTEGER
#define SQL_C_SHORT SQL_SMALLINT
#define SQL_C_FLOAT SQL_REAL
#define SQL_C_DOUBLE SQL_DOUBLE
#define SQL_C_DEFAULT 99
#define SQL_NO_NULLS 0
#define SQL_NULLABLE 1
#define SQL_NULLABLE_UNKNOWN 2
/* some special length values */
#define SQL_NULL_DATA (-1)
#define SQL_DATA_AT_EXEC (-2)
#define SQL_NTS (-3)
/* SQLFreeStmt flag values */
#define SQL_CLOSE 0
#define SQL_DROP 1
#define SQL_UNBIND 2
#define SQL_RESET_PARAMS 3
/* SQLTransact flag values */
#define SQL_COMMIT 0
#define SQL_ROLLBACK 1
/* SQLColAttributes flag values */
#define SQL_COLUMN_COUNT 0
#define SQL_COLUMN_LABEL 18
#define SQL_COLATT_OPT_MAX SQL_COLUMN_LABEL
#define SQL_COLUMN_DRIVER_START 1000
#define SQL_COLATT_OPT_MIN SQL_COLUMN_COUNT
/* Null handles */
#define SQL_NULL_HENV 0
#define SQL_NULL_HDBC 0
#define SQL_NULL_HSTMT 0
/* All code below has been added to the original isql.h coming from iodbc */
typedef unsigned char BYTE;
/* More SQLColAttributes flag values */
#define SQL_COLUMN_NAME 1
#define SQL_COLUMN_TYPE 2
#define SQL_COLUMN_LENGTH 3
#define SQL_COLUMN_PRECISION 4
#define SQL_COLUMN_SCALE 5
#define SQL_COLUMN_DISPLAY_SIZE 6
#define SQL_COLUMN_NULLABLE 7
#define SQL_COLUMN_UNSIGNED 8
#define SQL_COLUMN_MONEY 9
#define SQL_COLUMN_UPDATABLE 10
#define SQL_COLUMN_AUTO_INCREMENT 11
#define SQL_COLUMN_CASE_SENSITIVE 12
#define SQL_COLUMN_SEARCHABLE 13
#define SQL_COLUMN_TYPE_NAME 14
#define SQL_COLUMN_TABLE_NAME 15
#define SQL_COLUMN_OWNER_NAME 16
#define SQL_COLUMN_QUALIFIER_NAME 17
/* SQLColAttributes Searchable flags */
#define SQL_UNSEARCHABLE 0
#define SQL_LIKE_ONLY 1
#define SQL_ALL_EXCEPT_LIKE 2
#define SQL_SEARCHABLE 3
#define SQL_PRED_SEARCHABLE SQL_SEARCHABLE
/* SQLColAttributes Updateable flags */
#define SQL_ATTR_READONLY 0
#define SQL_ATTR_WRITE 1
#define SQL_ATTR_READWRITE_UNKNOWN 2
/*
* function prototypes previously not contained in isql.h
*/
#ifdef __cplusplus
extern "C"
{
#endif
RETCODE SQL_API SQLAllocConnect(HENV henv,
HDBC FAR * phdbc);
RETCODE SQL_API SQLAllocEnv(HENV FAR * phenv);
RETCODE SQL_API SQLAllocStmt(HDBC hdbc,
HSTMT FAR * phstmt);
RETCODE SQL_API SQLBindCol(HSTMT hstmt,
UWORD icol,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
SDWORD FAR * pcbValue);
RETCODE SQL_API SQLCancel(HSTMT hstmt);
RETCODE SQL_API SQLColAttributes(HSTMT hstmt,
UWORD icol,
UWORD fDescType,
PTR rgbDesc,
SWORD cbDescMax,
SWORD FAR * pcbDesc,
SDWORD FAR * pfDesc);
RETCODE SQL_API SQLConnect(HDBC hdbc,
UCHAR FAR * szDSN,
SWORD cbDSN,
UCHAR FAR * szUID,
SWORD cbUID,
UCHAR FAR * szAuthStr,
SWORD cbAuthStr);
RETCODE SQL_API SQLDescribeCol(HSTMT hstmt,
UWORD icol,
UCHAR FAR * szColName,
SWORD cbColNameMax,
SWORD FAR * pcbColName,
SWORD FAR * pfSqlType,
UDWORD FAR * pcbColDef,
SWORD FAR * pibScale,
SWORD FAR * pfNullable);
RETCODE SQL_API SQLDisconnect(HDBC hdbc);
RETCODE SQL_API SQLError(HENV henv,
HDBC hdbc,
HSTMT hstmt,
UCHAR FAR * szSqlState,
SDWORD FAR * pfNativeError,
UCHAR FAR * szErrorMsg,
SWORD cbErrorMsgMax,
SWORD FAR * pcbErrorMsg);
RETCODE SQL_API SQLExecDirect(HSTMT hstmt,
UCHAR FAR * szSqlStr,
SDWORD cbSqlStr);
RETCODE SQL_API SQLExecute(HSTMT hstmt);
RETCODE SQL_API SQLFetch(HSTMT hstmt);
RETCODE SQL_API SQLFreeConnect(HDBC hdbc);
RETCODE SQL_API SQLFreeEnv(HENV henv);
RETCODE SQL_API SQLFreeStmt(HSTMT hstmt,
UWORD fOption);
RETCODE SQL_API SQLGetCursorName(HSTMT hstmt,
UCHAR FAR * szCursor,
SWORD cbCursorMax,
SWORD FAR * pcbCursor);
RETCODE SQL_API SQLNumResultCols(HSTMT hstmt,
SWORD FAR * pccol);
RETCODE SQL_API SQLPrepare(HSTMT hstmt,
UCHAR FAR * szSqlStr,
SDWORD cbSqlStr);
RETCODE SQL_API SQLRowCount(HSTMT hstmt,
SDWORD FAR * pcrow);
RETCODE SQL_API SQLSetCursorName(HSTMT hstmt,
UCHAR FAR * szCursor,
SWORD cbCursor);
RETCODE SQL_API SQLTransact(HENV henv,
HDBC hdbc,
UWORD fType);
RETCODE SQL_API SQLSetParam(HSTMT hstmt,
UWORD ipar,
SWORD fCType,
SWORD fSqlType,
UDWORD cbColDef,
SWORD ibScale,
PTR rgbValue,
SDWORD FAR * pcbValue);
RETCODE SQL_API SQLDataSources(HENV henv,
UWORD Direction, UCHAR FAR * ServerName,
WORD BufferLength1, WORD *NameLength1,
UCHAR FAR * Description, WORD BufferLength2,
WORD *NameLength2);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,962 +0,0 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,186 +0,0 @@
/*--------
* Module: lobj.c
*
* Description: This module contains routines related to manipulating
* large objects.
*
* Classes: none
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*--------
*/
#include "lobj.h"
#include "connection.h"
Oid
lo_creat(ConnectionClass *conn, int mode)
{
LO_ARG argv[1];
int retval,
result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = mode;
if (!CC_send_function(conn, LO_CREAT, &retval, &result_len, 1, argv, 1))
return 0; /* invalid oid */
else
return retval;
}
int
lo_open(ConnectionClass *conn, int lobjId, int mode)
{
int fd;
int result_len;
LO_ARG argv[2];
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = lobjId;
argv[1].isint = 1;
argv[1].len = 4;
argv[1].u.integer = mode;
if (!CC_send_function(conn, LO_OPEN, &fd, &result_len, 1, argv, 2))
return -1;
if (fd >= 0 && lo_lseek(conn, fd, 0L, SEEK_SET) < 0)
return -1;
return fd;
}
int
lo_close(ConnectionClass *conn, int fd)
{
LO_ARG argv[1];
int retval,
result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
if (!CC_send_function(conn, LO_CLOSE, &retval, &result_len, 1, argv, 1))
return -1;
else
return retval;
}
int
lo_read(ConnectionClass *conn, int fd, char *buf, int len)
{
LO_ARG argv[2];
int result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
argv[1].isint = 1;
argv[1].len = 4;
argv[1].u.integer = len;
if (!CC_send_function(conn, LO_READ, (int *) buf, &result_len, 0, argv, 2))
return -1;
else
return result_len;
}
int
lo_write(ConnectionClass *conn, int fd, char *buf, int len)
{
LO_ARG argv[2];
int retval,
result_len;
if (len <= 0)
return 0;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
argv[1].isint = 0;
argv[1].len = len;
argv[1].u.ptr = (char *) buf;
if (!CC_send_function(conn, LO_WRITE, &retval, &result_len, 1, argv, 2))
return -1;
else
return retval;
}
int
lo_lseek(ConnectionClass *conn, int fd, int offset, int whence)
{
LO_ARG argv[3];
int retval,
result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
argv[1].isint = 1;
argv[1].len = 4;
argv[1].u.integer = offset;
argv[2].isint = 1;
argv[2].len = 4;
argv[2].u.integer = whence;
if (!CC_send_function(conn, LO_LSEEK, &retval, &result_len, 1, argv, 3))
return -1;
else
return retval;
}
int
lo_tell(ConnectionClass *conn, int fd)
{
LO_ARG argv[1];
int retval,
result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
if (!CC_send_function(conn, LO_TELL, &retval, &result_len, 1, argv, 1))
return -1;
else
return retval;
}
int
lo_unlink(ConnectionClass *conn, Oid lobjId)
{
LO_ARG argv[1];
int retval,
result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = lobjId;
if (!CC_send_function(conn, LO_UNLINK, &retval, &result_len, 1, argv, 1))
return -1;
else
return retval;
}

View File

@ -1,47 +0,0 @@
/* File: lobj.h
*
* Description: See "lobj.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __LOBJ_H__
#define __LOBJ_H__
#include "psqlodbc.h"
struct lo_arg
{
int isint;
int len;
union
{
int integer;
char *ptr;
} u;
};
#define LO_CREAT 957
#define LO_OPEN 952
#define LO_CLOSE 953
#define LO_READ 954
#define LO_WRITE 955
#define LO_LSEEK 956
#define LO_TELL 958
#define LO_UNLINK 964
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
Oid lo_creat(ConnectionClass *conn, int mode);
int lo_open(ConnectionClass *conn, int lobjId, int mode);
int lo_close(ConnectionClass *conn, int fd);
int lo_read(ConnectionClass *conn, int fd, char *buf, int len);
int lo_write(ConnectionClass *conn, int fd, char *buf, int len);
int lo_lseek(ConnectionClass *conn, int fd, int offset, int len);
int lo_tell(ConnectionClass *conn, int fd);
int lo_unlink(ConnectionClass *conn, Oid lobjId);
#endif

View File

@ -1,351 +0,0 @@
/*
* md5.c
*
* Implements the MD5 Message-Digest Algorithm as specified in
* RFC 1321. This implementation is a simple one, in that it
* needs every input byte to be buffered before doing any
* calculations. I do not expect this file to be used for
* general purpose MD5'ing of large amounts of data, only for
* generating hashed passwords from limited input.
*
* Sverre H. Huseby <sverrehu@online.no>
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/md5.c,v 1.8 2002/06/20 20:29:54 momjian Exp $
*/
/*
* NOTE:
*
* There are two copies of this file, one in backend/libpq and another
* in interfaces/odbc. They should be identical. This is done so ODBC
* can be compiled stand-alone.
*/
#ifndef MD5_ODBC
#include "postgres.h"
#include "libpq/crypt.h"
#else
#include "md5.h"
#endif
#ifdef FRONTEND
#undef palloc
#define palloc malloc
#undef pfree
#define pfree free
#endif
/*
* PRIVATE FUNCTIONS
*/
/*
* The returned array is allocated using malloc. the caller should free it
* when it is no longer needed.
*/
static uint8 *
createPaddedCopyWithLength(uint8 *b, uint32 *l)
{
uint8 *ret;
uint32 q;
uint32 len,
newLen448;
uint32 len_high,
len_low; /* 64-bit value split into 32-bit sections */
len = ((b == NULL) ? 0 : *l);
newLen448 = len + 64 - (len % 64) - 8;
if (newLen448 <= len)
newLen448 += 64;
*l = newLen448 + 8;
if ((ret = (uint8 *) malloc(sizeof(uint8) * *l)) == NULL)
return NULL;
if (b != NULL)
memcpy(ret, b, sizeof(uint8) * len);
/* pad */
ret[len] = 0x80;
for (q = len + 1; q < newLen448; q++)
ret[q] = 0x00;
/* append length as a 64 bit bitcount */
len_low = len;
/* split into two 32-bit values */
/* we only look at the bottom 32-bits */
len_high = len >> 29;
len_low <<= 3;
q = newLen448;
ret[q++] = (len_low & 0xff);
len_low >>= 8;
ret[q++] = (len_low & 0xff);
len_low >>= 8;
ret[q++] = (len_low & 0xff);
len_low >>= 8;
ret[q++] = (len_low & 0xff);
ret[q++] = (len_high & 0xff);
len_high >>= 8;
ret[q++] = (len_high & 0xff);
len_high >>= 8;
ret[q++] = (len_high & 0xff);
len_high >>= 8;
ret[q] = (len_high & 0xff);
return ret;
}
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define ROT_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
static void
doTheRounds(uint32 X[16], uint32 state[4])
{
uint32 a,
b,
c,
d;
a = state[0];
b = state[1];
c = state[2];
d = state[3];
/* round 1 */
a = b + ROT_LEFT((a + F(b, c, d) + X[0] + 0xd76aa478), 7); /* 1 */
d = a + ROT_LEFT((d + F(a, b, c) + X[1] + 0xe8c7b756), 12); /* 2 */
c = d + ROT_LEFT((c + F(d, a, b) + X[2] + 0x242070db), 17); /* 3 */
b = c + ROT_LEFT((b + F(c, d, a) + X[3] + 0xc1bdceee), 22); /* 4 */
a = b + ROT_LEFT((a + F(b, c, d) + X[4] + 0xf57c0faf), 7); /* 5 */
d = a + ROT_LEFT((d + F(a, b, c) + X[5] + 0x4787c62a), 12); /* 6 */
c = d + ROT_LEFT((c + F(d, a, b) + X[6] + 0xa8304613), 17); /* 7 */
b = c + ROT_LEFT((b + F(c, d, a) + X[7] + 0xfd469501), 22); /* 8 */
a = b + ROT_LEFT((a + F(b, c, d) + X[8] + 0x698098d8), 7); /* 9 */
d = a + ROT_LEFT((d + F(a, b, c) + X[9] + 0x8b44f7af), 12); /* 10 */
c = d + ROT_LEFT((c + F(d, a, b) + X[10] + 0xffff5bb1), 17); /* 11 */
b = c + ROT_LEFT((b + F(c, d, a) + X[11] + 0x895cd7be), 22); /* 12 */
a = b + ROT_LEFT((a + F(b, c, d) + X[12] + 0x6b901122), 7); /* 13 */
d = a + ROT_LEFT((d + F(a, b, c) + X[13] + 0xfd987193), 12); /* 14 */
c = d + ROT_LEFT((c + F(d, a, b) + X[14] + 0xa679438e), 17); /* 15 */
b = c + ROT_LEFT((b + F(c, d, a) + X[15] + 0x49b40821), 22); /* 16 */
/* round 2 */
a = b + ROT_LEFT((a + G(b, c, d) + X[1] + 0xf61e2562), 5); /* 17 */
d = a + ROT_LEFT((d + G(a, b, c) + X[6] + 0xc040b340), 9); /* 18 */
c = d + ROT_LEFT((c + G(d, a, b) + X[11] + 0x265e5a51), 14); /* 19 */
b = c + ROT_LEFT((b + G(c, d, a) + X[0] + 0xe9b6c7aa), 20); /* 20 */
a = b + ROT_LEFT((a + G(b, c, d) + X[5] + 0xd62f105d), 5); /* 21 */
d = a + ROT_LEFT((d + G(a, b, c) + X[10] + 0x02441453), 9); /* 22 */
c = d + ROT_LEFT((c + G(d, a, b) + X[15] + 0xd8a1e681), 14); /* 23 */
b = c + ROT_LEFT((b + G(c, d, a) + X[4] + 0xe7d3fbc8), 20); /* 24 */
a = b + ROT_LEFT((a + G(b, c, d) + X[9] + 0x21e1cde6), 5); /* 25 */
d = a + ROT_LEFT((d + G(a, b, c) + X[14] + 0xc33707d6), 9); /* 26 */
c = d + ROT_LEFT((c + G(d, a, b) + X[3] + 0xf4d50d87), 14); /* 27 */
b = c + ROT_LEFT((b + G(c, d, a) + X[8] + 0x455a14ed), 20); /* 28 */
a = b + ROT_LEFT((a + G(b, c, d) + X[13] + 0xa9e3e905), 5); /* 29 */
d = a + ROT_LEFT((d + G(a, b, c) + X[2] + 0xfcefa3f8), 9); /* 30 */
c = d + ROT_LEFT((c + G(d, a, b) + X[7] + 0x676f02d9), 14); /* 31 */
b = c + ROT_LEFT((b + G(c, d, a) + X[12] + 0x8d2a4c8a), 20); /* 32 */
/* round 3 */
a = b + ROT_LEFT((a + H(b, c, d) + X[5] + 0xfffa3942), 4); /* 33 */
d = a + ROT_LEFT((d + H(a, b, c) + X[8] + 0x8771f681), 11); /* 34 */
c = d + ROT_LEFT((c + H(d, a, b) + X[11] + 0x6d9d6122), 16); /* 35 */
b = c + ROT_LEFT((b + H(c, d, a) + X[14] + 0xfde5380c), 23); /* 36 */
a = b + ROT_LEFT((a + H(b, c, d) + X[1] + 0xa4beea44), 4); /* 37 */
d = a + ROT_LEFT((d + H(a, b, c) + X[4] + 0x4bdecfa9), 11); /* 38 */
c = d + ROT_LEFT((c + H(d, a, b) + X[7] + 0xf6bb4b60), 16); /* 39 */
b = c + ROT_LEFT((b + H(c, d, a) + X[10] + 0xbebfbc70), 23); /* 40 */
a = b + ROT_LEFT((a + H(b, c, d) + X[13] + 0x289b7ec6), 4); /* 41 */
d = a + ROT_LEFT((d + H(a, b, c) + X[0] + 0xeaa127fa), 11); /* 42 */
c = d + ROT_LEFT((c + H(d, a, b) + X[3] + 0xd4ef3085), 16); /* 43 */
b = c + ROT_LEFT((b + H(c, d, a) + X[6] + 0x04881d05), 23); /* 44 */
a = b + ROT_LEFT((a + H(b, c, d) + X[9] + 0xd9d4d039), 4); /* 45 */
d = a + ROT_LEFT((d + H(a, b, c) + X[12] + 0xe6db99e5), 11); /* 46 */
c = d + ROT_LEFT((c + H(d, a, b) + X[15] + 0x1fa27cf8), 16); /* 47 */
b = c + ROT_LEFT((b + H(c, d, a) + X[2] + 0xc4ac5665), 23); /* 48 */
/* round 4 */
a = b + ROT_LEFT((a + I(b, c, d) + X[0] + 0xf4292244), 6); /* 49 */
d = a + ROT_LEFT((d + I(a, b, c) + X[7] + 0x432aff97), 10); /* 50 */
c = d + ROT_LEFT((c + I(d, a, b) + X[14] + 0xab9423a7), 15); /* 51 */
b = c + ROT_LEFT((b + I(c, d, a) + X[5] + 0xfc93a039), 21); /* 52 */
a = b + ROT_LEFT((a + I(b, c, d) + X[12] + 0x655b59c3), 6); /* 53 */
d = a + ROT_LEFT((d + I(a, b, c) + X[3] + 0x8f0ccc92), 10); /* 54 */
c = d + ROT_LEFT((c + I(d, a, b) + X[10] + 0xffeff47d), 15); /* 55 */
b = c + ROT_LEFT((b + I(c, d, a) + X[1] + 0x85845dd1), 21); /* 56 */
a = b + ROT_LEFT((a + I(b, c, d) + X[8] + 0x6fa87e4f), 6); /* 57 */
d = a + ROT_LEFT((d + I(a, b, c) + X[15] + 0xfe2ce6e0), 10); /* 58 */
c = d + ROT_LEFT((c + I(d, a, b) + X[6] + 0xa3014314), 15); /* 59 */
b = c + ROT_LEFT((b + I(c, d, a) + X[13] + 0x4e0811a1), 21); /* 60 */
a = b + ROT_LEFT((a + I(b, c, d) + X[4] + 0xf7537e82), 6); /* 61 */
d = a + ROT_LEFT((d + I(a, b, c) + X[11] + 0xbd3af235), 10); /* 62 */
c = d + ROT_LEFT((c + I(d, a, b) + X[2] + 0x2ad7d2bb), 15); /* 63 */
b = c + ROT_LEFT((b + I(c, d, a) + X[9] + 0xeb86d391), 21); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
}
static int
calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16])
{
register uint32 i,
j,
k,
newI;
uint32 l;
uint8 *input;
register uint32 *wbp;
uint32 workBuff[16],
state[4];
l = len;
state[0] = 0x67452301;
state[1] = 0xEFCDAB89;
state[2] = 0x98BADCFE;
state[3] = 0x10325476;
if ((input = createPaddedCopyWithLength(b, &l)) == NULL)
return 0;
for (i = 0;;)
{
if ((newI = i + 16 * 4) > l)
break;
k = i + 3;
for (j = 0; j < 16; j++)
{
wbp = (workBuff + j);
*wbp = input[k--];
*wbp <<= 8;
*wbp |= input[k--];
*wbp <<= 8;
*wbp |= input[k--];
*wbp <<= 8;
*wbp |= input[k];
k += 7;
}
doTheRounds(workBuff, state);
i = newI;
}
free(input);
j = 0;
for (i = 0; i < 4; i++)
{
k = state[i];
sum[j++] = (k & 0xff);
k >>= 8;
sum[j++] = (k & 0xff);
k >>= 8;
sum[j++] = (k & 0xff);
k >>= 8;
sum[j++] = (k & 0xff);
}
return 1;
}
static void
bytesToHex(uint8 b[16], char *s)
{
static char *hex = "0123456789abcdef";
int q,
w;
for (q = 0, w = 0; q < 16; q++)
{
s[w++] = hex[(b[q] >> 4) & 0x0F];
s[w++] = hex[b[q] & 0x0F];
}
s[w] = '\0';
}
/*
* PUBLIC FUNCTIONS
*/
/*
* md5_hash
*
* Calculates the MD5 sum of the bytes in a buffer.
*
* SYNOPSIS #include "crypt.h"
* int md5_hash(const void *buff, size_t len, char *hexsum)
*
* INPUT buff the buffer containing the bytes that you want
* the MD5 sum of.
* len number of bytes in the buffer.
*
* OUTPUT hexsum the MD5 sum as a '\0'-terminated string of
* hexadecimal digits. an MD5 sum is 16 bytes long.
* each byte is represented by two heaxadecimal
* characters. you thus need to provide an array
* of 33 characters, including the trailing '\0'.
*
* RETURNS 0 on failure (out of memory for internal buffers) or
* non-zero on success.
*
* STANDARDS MD5 is described in RFC 1321.
*
* AUTHOR Sverre H. Huseby <sverrehu@online.no>
*
*/
bool
md5_hash(const void *buff, size_t len, char *hexsum)
{
uint8 sum[16];
if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
return false;
bytesToHex(sum, hexsum);
return true;
}
/*
* Computes MD5 checksum of "passwd" (a null-terminated string) followed
* by "salt" (which need not be null-terminated).
*
* Output format is "md5" followed by a 32-hex-digit MD5 checksum.
* Hence, the output buffer "buf" must be at least 36 bytes long.
*
* Returns TRUE if okay, FALSE on error (out of memory).
*/
bool
EncryptMD5(const char *passwd, const char *salt, size_t salt_len,
char *buf)
{
size_t passwd_len = strlen(passwd);
char *crypt_buf = palloc(passwd_len + salt_len);
bool ret;
/*
* Place salt at the end because it may be known by users trying to
* crack the MD5 output.
*/
strcpy(crypt_buf, passwd);
memcpy(crypt_buf + passwd_len, salt, salt_len);
strcpy(buf, "md5");
ret = md5_hash(crypt_buf, passwd_len + salt_len, buf + 3);
pfree(crypt_buf);
return ret;
}

View File

@ -1,49 +0,0 @@
/* File: md5.h
*
* Description: See "md5.h"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __MD5_H__
#define __MD5_H__
#include "psqlodbc.h"
#include <stdlib.h>
#include <string.h>
#define MD5_PASSWD_LEN 35
/* From c.h */
#ifndef __BEOS__
#ifndef __cplusplus
#ifndef bool
typedef char bool;
#endif
#ifndef true
#define true ((bool) 1)
#endif
#ifndef false
#define false ((bool) 0)
#endif
#endif /* not C++ */
#endif /* __BEOS__ */
/* Also defined in include/c.h */
#ifndef HAVE_UINT8
typedef unsigned char uint8; /* == 8 bits */
typedef unsigned short uint16; /* == 16 bits */
typedef unsigned int uint32; /* == 32 bits */
#endif /* not HAVE_UINT8 */
extern bool md5_hash(const void *buff, size_t len, char *hexsum);
extern bool EncryptMD5(const char *passwd, const char *salt,
size_t salt_len, char *buf);
#endif

View File

@ -1,329 +0,0 @@
/*-------
* Module: misc.c
*
* Description: This module contains miscellaneous routines
* such as for debugging/logging and string functions.
*
* Classes: n/a
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#ifndef WIN32
#if HAVE_PWD_H
#include <pwd.h>
#endif
#include <sys/types.h>
#include <unistd.h>
#else
#include <process.h> /* Byron: is this where Windows keeps def.
* of getpid ? */
#endif
#include "connection.h"
extern GLOBAL_VALUES globals;
void generate_filename(const char *, const char *, char *);
void
generate_filename(const char *dirname, const char *prefix, char *filename)
{
int pid = 0;
#ifndef WIN32
struct passwd *ptr = 0;
ptr = getpwuid(getuid());
#endif
pid = getpid();
if (dirname == 0 || filename == 0)
return;
strcpy(filename, dirname);
strcat(filename, DIRSEPARATOR);
if (prefix != 0)
strcat(filename, prefix);
#ifndef WIN32
strcat(filename, ptr->pw_name);
#endif
sprintf(filename, "%s%u%s", filename, pid, ".log");
return;
}
static int mylog_on = 0,
qlog_on = 0;
void
logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff)
{
static int mylog_on_count = 0,
mylog_off_count = 0,
qlog_on_count = 0,
qlog_off_count = 0;
if (mylog_onoff)
mylog_on_count += cnopen;
else
mylog_off_count += cnopen;
if (mylog_on_count > 0)
mylog_on = 1;
else if (mylog_off_count > 0)
mylog_on = 0;
else
mylog_on = globals.debug;
if (qlog_onoff)
qlog_on_count += cnopen;
else
qlog_off_count += cnopen;
if (qlog_on_count > 0)
qlog_on = 1;
else if (qlog_off_count > 0)
qlog_on = 0;
else
qlog_on = globals.commlog;
}
#ifdef MY_LOG
void
mylog(char *fmt,...)
{
va_list args;
char filebuf[80];
static FILE *LOGFP = NULL;
if (mylog_on)
{
va_start(args, fmt);
if (!LOGFP)
{
generate_filename(MYLOGDIR, MYLOGFILE, filebuf);
LOGFP = fopen(filebuf, PG_BINARY_A);
setbuf(LOGFP, NULL);
}
if (LOGFP)
vfprintf(LOGFP, fmt, args);
va_end(args);
}
}
#else
void
MyLog(char *fmt,...)
{
}
#endif
#ifdef Q_LOG
void
qlog(char *fmt,...)
{
va_list args;
char filebuf[80];
static FILE *LOGFP = NULL;
if (qlog_on)
{
va_start(args, fmt);
if (!LOGFP)
{
generate_filename(QLOGDIR, QLOGFILE, filebuf);
LOGFP = fopen(filebuf, PG_BINARY_A);
setbuf(LOGFP, NULL);
}
if (LOGFP)
vfprintf(LOGFP, fmt, args);
va_end(args);
}
}
#endif
/*
* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied
* (not including null term)
*/
int
my_strcpy(char *dst, int dst_len, const char *src, int src_len)
{
if (dst_len <= 0)
return STRCPY_FAIL;
if (src_len == SQL_NULL_DATA)
{
dst[0] = '\0';
return STRCPY_NULL;
}
else if (src_len == SQL_NTS)
src_len = strlen(src);
if (src_len <= 0)
return STRCPY_FAIL;
else
{
if (src_len < dst_len)
{
memcpy(dst, src, src_len);
dst[src_len] = '\0';
}
else
{
memcpy(dst, src, dst_len - 1);
dst[dst_len - 1] = '\0'; /* truncated */
return STRCPY_TRUNCATED;
}
}
return strlen(dst);
}
/*
* strncpy copies up to len characters, and doesn't terminate
* the destination string if src has len characters or more.
* instead, I want it to copy up to len-1 characters and always
* terminate the destination string.
*/
char *
strncpy_null(char *dst, const char *src, int len)
{
int i;
if (NULL != dst)
{
/* Just in case, check for special lengths */
if (len == SQL_NULL_DATA)
{
dst[0] = '\0';
return NULL;
}
else if (len == SQL_NTS)
len = strlen(src) + 1;
for (i = 0; src[i] && i < len - 1; i++)
dst[i] = src[i];
if (len > 0)
dst[i] = '\0';
}
return dst;
}
/*------
* Create a null terminated string (handling the SQL_NTS thing):
* 1. If buf is supplied, place the string in there
* (assumes enough space) and return buf.
* 2. If buf is not supplied, malloc space and return this string
*------
*/
char *
make_string(const char *s, int len, char *buf)
{
int length;
char *str;
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0)))
{
length = (len > 0) ? len : strlen(s);
if (buf)
{
strncpy_null(buf, s, length + 1);
return buf;
}
str = malloc(length + 1);
if (!str)
return NULL;
strncpy_null(str, s, length + 1);
return str;
}
return NULL;
}
/*
* Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing.
* "fmt" must contain somewhere in it the single form '%.*s'.
* This is heavily used in creating queries for info routines (SQLTables, SQLColumns).
* This routine could be modified to use vsprintf() to handle multiple arguments.
*/
char *
my_strcat(char *buf, const char *fmt, const char *s, int len)
{
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0)))
{
int length = (len > 0) ? len : strlen(s);
int pos = strlen(buf);
sprintf(&buf[pos], fmt, length, s);
return buf;
}
return NULL;
}
char *
schema_strcat(char *buf, const char *fmt, const char *s, int len, const char *tbname, int tbnmlen, ConnectionClass *conn)
{
if (!s || 0 == len)
{
/*
* Note that this driver assumes the implicit schema is
* the CURRENT_SCHEMA() though it doesn't worth the
* naming.
*/
if (conn->schema_support && tbname && (tbnmlen > 0 || tbnmlen == SQL_NTS))
return my_strcat(buf, fmt, CC_get_current_schema(conn), SQL_NTS);
return NULL;
}
return my_strcat(buf, fmt, s, len);
}
void
remove_newlines(char *string)
{
unsigned int i;
for (i = 0; i < strlen(string); i++)
{
if ((string[i] == '\n') ||
(string[i] == '\r'))
string[i] = ' ';
}
}
char *
trim(char *s)
{
int i;
for (i = strlen(s) - 1; i >= 0; i--)
{
if (s[i] == ' ')
s[i] = '\0';
else
break;
}
return s;
}

View File

@ -1,107 +0,0 @@
/* File: misc.h
*
* Description: See "misc.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __MISC_H__
#define __MISC_H__
#include "psqlodbc.h"
#include <stdio.h>
/* Uncomment MY_LOG define to compile in the mylog() statements.
Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI
portion of the registry. You may have to manually add this key.
This logfile is intended for development use, not for an end user!
*/
#define MY_LOG
/* Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog).
This logfile contains serious log statements that are intended for an
end user to be able to read and understand. It is controlled by the
'CommLog' flag in the ODBCINST.INI portion of the registry (see above),
which is manipulated on the setup/connection dialog boxes.
*/
#define Q_LOG
#ifdef MY_LOG
#define MYLOGFILE "mylog_"
#ifndef WIN32
#define MYLOGDIR "/tmp"
#else
#define MYLOGDIR "c:"
#endif /* WIN32 */
extern void mylog(char *fmt,...);
#else
#ifndef WIN32
#define mylog(args...) /* GNU convention for variable arguments */
#else
extern void MyLog(char *fmt,...);
#define mylog if (0) MyLog /* mylog */
#endif /* WIN32 */
#endif /* MY_LOG */
#define inolog mylog /* for really temporary debug */
#ifdef Q_LOG
#define QLOGFILE "psqlodbc_"
#ifndef WIN32
#define QLOGDIR "/tmp"
#else
#define QLOGDIR "c:"
#endif
extern void qlog(char *fmt,...);
#else
#ifndef WIN32
#define qlog(args...) /* GNU convention for variable arguments */
#else
#define qlog /* qlog */
#endif
#endif
#define inoqlog qlog
#ifndef WIN32
#define DIRSEPARATOR "/"
#else
#define DIRSEPARATOR "\\"
#endif
#ifdef WIN32
#define PG_BINARY O_BINARY
#define PG_BINARY_R "rb"
#define PG_BINARY_W "wb"
#define PG_BINARY_A "ab"
#else
#define PG_BINARY 0
#define PG_BINARY_R "r"
#define PG_BINARY_W "w"
#define PG_BINARY_A "a"
#endif
void remove_newlines(char *string);
char *strncpy_null(char *dst, const char *src, int len);
char *trim(char *string);
char *make_string(const char *s, int len, char *buf);
char *my_strcat(char *buf, const char *fmt, const char *s, int len);
char *schema_strcat(char *buf, const char *fmt, const char *s, int len,
const char *, int, ConnectionClass *conn);
/* #define GET_SCHEMA_NAME(nspname) (stricmp(nspname, "public") ? nspname : "") */
#define GET_SCHEMA_NAME(nspname) (nspname)
/* defines for return value of my_strcpy */
#define STRCPY_SUCCESS 1
#define STRCPY_FAIL 0
#define STRCPY_TRUNCATED (-1)
#define STRCPY_NULL (-2)
int my_strcpy(char *dst, int dst_len, const char *src, int src_len);
#endif

View File

@ -1,454 +0,0 @@
/*--------
* Module : multibyte.c
*
* Description: New Mlutibyte related additional function.
*
* Create 2001-03-03 Eiji Tokuya
* New Create 2001-09-16 Eiji Tokuya
*--------
*/
#include "multibyte.h"
#include "connection.h"
#include "pgapifunc.h"
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef TRUE
#define TRUE 1
#endif
pg_CS CS_Table[] =
{
{ "SQL_ASCII", SQL_ASCII },
{ "EUC_JP", EUC_JP },
{ "EUC_CN", EUC_CN },
{ "EUC_KR", EUC_KR },
{ "EUC_TW", EUC_TW },
{ "JOHAB", JOHAB },
{ "UNICODE", UTF8 },
{ "MULE_INTERNAL",MULE_INTERNAL },
{ "LATIN1", LATIN1 },
{ "LATIN2", LATIN2 },
{ "LATIN3", LATIN3 },
{ "LATIN4", LATIN4 },
{ "LATIN5", LATIN5 },
{ "LATIN6", LATIN6 },
{ "LATIN7", LATIN7 },
{ "LATIN8", LATIN8 },
{ "LATIN9", LATIN9 },
{ "LATIN10", LATIN10 },
{ "WIN1256", WIN1256 },
{ "TCVN", TCVN },
{ "WIN874", WIN874 },
{ "KOI8", KOI8R },
{ "WIN", WIN1251 },
{ "ALT", ALT },
{ "ISO_8859_5", ISO_8859_5 },
{ "ISO_8859_6", ISO_8859_6 },
{ "ISO_8859_7", ISO_8859_7 },
{ "ISO_8859_8", ISO_8859_8 },
{ "SJIS", SJIS },
{ "BIG5", BIG5 },
{ "GBK", GBK },
{ "UHC", UHC },
{ "WIN1250", WIN1250 },
{ "GB18030", GB18030 },
{ "OTHER", OTHER }
};
#ifdef NOT_USED
static int
pg_ismb(int characterset_code)
{
int i=0,MB_CHARACTERSET[]={EUC_JP,EUC_CN,EUC_KR,EUC_TW,UTF8,MULE_INTERNAL,SJIS,BIG5,GBK,UHC,JOHAB};
while (MB_CHARACTERSET[i] != characterset_code || OTHER != MB_CHARACTERSET[i] )
{
i++;
}
return (MB_CHARACTERSET[i]);
}
#endif
int
pg_CS_code(const unsigned char *characterset_string)
{
int i = 0, c = -1;
unsigned len = 0;
for(i = 0; CS_Table[i].code != OTHER; i++)
{
if (strstr(characterset_string,CS_Table[i].name))
{
if(strlen(CS_Table[i].name) >= len)
{
len = strlen(CS_Table[i].name);
c = CS_Table[i].code;
}
}
}
if (c < 0)
c = i;
return (c);
}
unsigned char *
pg_CS_name(int characterset_code)
{
int i;
for (i = 0; CS_Table[i].code != OTHER; i++)
{
if (CS_Table[i].code == characterset_code)
return CS_Table[i].name;
}
return ("OTHER");
}
int
pg_CS_stat(int stat,unsigned int character,int characterset_code)
{
if (character == 0)
stat = 0;
switch (characterset_code)
{
case UTF8:
{
if (stat < 2 &&
character >= 0x80)
{
if (character >= 0xfc)
stat = 6;
else if (character >= 0xf8)
stat = 5;
else if (character >= 0xf0)
stat = 4;
else if (character >= 0xe0)
stat = 3;
else if (character >= 0xc0)
stat = 2;
}
else if (stat > 2 &&
character > 0x7f)
stat--;
else
stat=0;
}
break;
/* Shift-JIS Support. */
case SJIS:
{
if (stat < 2 &&
character > 0x80 &&
!(character > 0x9f &&
character < 0xe0))
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/* Chinese Big5 Support. */
case BIG5:
{
if (stat < 2 &&
character > 0xA0)
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/* Chinese GBK Support. */
case GBK:
{
if (stat < 2 &&
character > 0x7F)
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/* Korian UHC Support. */
case UHC:
{
if (stat < 2 &&
character > 0x7F)
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/* EUC_JP Support */
case EUC_JP:
{
if (stat < 3 &&
character == 0x8f) /* JIS X 0212 */
stat = 3;
else
if (stat != 2 &&
(character == 0x8e ||
character > 0xa0)) /* Half Katakana HighByte & Kanji HighByte */
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/* EUC_CN, EUC_KR, JOHAB Support */
case EUC_CN:
case EUC_KR:
case JOHAB:
{
if (stat < 2 &&
character > 0xa0)
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
case EUC_TW:
{
if (stat < 4 &&
character == 0x8e)
stat = 4;
else if (stat == 4 &&
character > 0xa0)
stat = 3;
else if ((stat == 3 ||
stat < 2) &&
character > 0xa0)
stat = 2;
else if (stat == 2)
stat = 1;
else
stat = 0;
}
break;
/*Chinese GB18030 support.Added by Bill Huang <bhuang@redhat.com> <bill_huanghb@ybb.ne.jp>*/
case GB18030:
{
if (stat < 2 && character > 0x80)
stat = 2;
else if (stat = 2)
if (character >= 0x30 && character <= 0x39)
stat = 3;
else
stat = 1;
else if (stat = 3)
if (character >= 0x30 && character <= 0x39)
stat = 1;
else
stat = 3;
else
stat = 0;
}
break;
default:
{
stat = 0;
}
break;
}
return stat;
}
unsigned char *
pg_mbschr(int csc, const unsigned char *string, unsigned int character)
{
int mb_st = 0;
const unsigned char *s, *rs = NULL;
for(s = string; *s ; s++)
{
mb_st = pg_CS_stat(mb_st, (unsigned char) *s, csc);
if (mb_st == 0 && (*s == character))
{
rs = s;
break;
}
}
return (rs);
}
int
pg_mbslen(int csc, const unsigned char *string)
{
unsigned char *s;
int len, cs_stat;
for (len = 0, cs_stat = 0, s = (unsigned char *) string; *s != 0; s++)
{
cs_stat = pg_CS_stat(cs_stat,(unsigned int) *s, csc);
if (cs_stat < 2)
len++;
}
return len;
}
unsigned char *
pg_mbsinc(int csc, const unsigned char *current )
{
int mb_stat = 0;
if (*current != 0)
{
mb_stat = (int) pg_CS_stat(mb_stat, *current, csc);
if (mb_stat == 0)
mb_stat = 1;
return ((unsigned char *) current + mb_stat);
}
else
return NULL;
}
static char *
CC_lookup_cs_new(ConnectionClass *self)
{
char *encstr = NULL;
QResultClass *res;
res = CC_send_query(self, "select pg_client_encoding()", NULL, CLEAR_RESULT_ON_ABORT);
if (res)
{
char *enc = QR_get_value_backend_row(res, 0, 0);
if (enc)
encstr = strdup(enc);
QR_Destructor(res);
}
return encstr;
}
static char *
CC_lookup_cs_old(ConnectionClass *self)
{
char *encstr = NULL;
HSTMT hstmt;
RETCODE result;
result = PGAPI_AllocStmt(self, &hstmt);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
return encstr;
result = PGAPI_ExecDirect(hstmt, "Show Client_Encoding", SQL_NTS);
if (result == SQL_SUCCESS_WITH_INFO)
{
char sqlState[8], errormsg[128], enc[32];
if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, errormsg,
sizeof(errormsg), NULL) == SQL_SUCCESS &&
sscanf(errormsg, "%*s %*s %*s %*s %*s %s", enc) > 0)
encstr = strdup(enc);
}
PGAPI_FreeStmt(hstmt, SQL_DROP);
return encstr;
}
void
CC_lookup_characterset(ConnectionClass *self)
{
char *encstr;
static char *func = "CC_lookup_characterset";
mylog("%s: entering...\n", func);
if (PG_VERSION_LT(self, 7.2))
encstr = CC_lookup_cs_old(self);
else
encstr = CC_lookup_cs_new(self);
if (self->client_encoding)
free(self->client_encoding);
#ifndef UNICODE_SUPPORT
#ifdef WIN32
else
{
const char *wenc = NULL;
switch (GetACP())
{
case 932:
wenc = "SJIS";
break;
case 936:
wenc = "GBK";
break;
case 949:
wenc = "UHC";
break;
case 950:
wenc = "BIG5";
break;
}
if (wenc && stricmp(encstr, wenc))
{
QResultClass *res;
char query[64];
sprintf(query, "set client_encoding to '%s'", wenc);
res = CC_send_query(self, query, NULL, CLEAR_RESULT_ON_ABORT);
if (res)
{
self->client_encoding = strdup(wenc);
self->ccsc = pg_CS_code(self->client_encoding);
QR_Destructor(res);
free(encstr);
return;
}
}
}
#endif /* WIN32 */
#endif /* UNICODE_SUPPORT */
if (encstr)
{
self->client_encoding = encstr;
self->ccsc = pg_CS_code(encstr);
qlog(" [ Client encoding = '%s' (code = %d) ]\n", self->client_encoding, self->ccsc);
if (stricmp(pg_CS_name(self->ccsc), encstr))
{
qlog(" Client encoding = '%s' and %s\n", self->client_encoding, pg_CS_name(self->ccsc));
self->errornumber = CONN_VALUE_OUT_OF_RANGE;
self->errormsg = "client encoding mismatch";
}
}
else
{
self->ccsc = SQL_ASCII;
self->client_encoding = NULL;
}
}
void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str)
{
encstr->ccsc = ccsc;
encstr->encstr = str;
encstr->pos = -1;
encstr->ccst = 0;
}
int encoded_nextchar(encoded_str *encstr)
{
int chr;
chr = encstr->encstr[++encstr->pos];
encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc);
return chr;
}
int encoded_byte_check(encoded_str *encstr, int abspos)
{
int chr;
chr = encstr->encstr[encstr->pos = abspos];
encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc);
return chr;
}

View File

@ -1,90 +0,0 @@
/*
*
* Multibyte library header ( psqlODBC Only )
*
*/
#include "psqlodbc.h"
#include "qresult.h"
/* PostgreSQL client encoding */
#define SQL_ASCII 0 /* SQL/ASCII */
#define EUC_JP 1 /* EUC for Japanese */
#define EUC_CN 2 /* EUC for Chinese */
#define EUC_KR 3 /* EUC for Korean */
#define EUC_TW 4 /* EUC for Taiwan */
#define JOHAB 5
#define UTF8 6 /* Unicode UTF-8 */
#define MULE_INTERNAL 7 /* Mule internal code */
#define LATIN1 8 /* ISO-8859 Latin 1 */
#define LATIN2 9 /* ISO-8859 Latin 2 */
#define LATIN3 10 /* ISO-8859 Latin 3 */
#define LATIN4 11 /* ISO-8859 Latin 4 */
#define LATIN5 12 /* ISO-8859 Latin 5 */
#define LATIN6 13 /* ISO-8859 Latin 6 */
#define LATIN7 14 /* ISO-8859 Latin 7 */
#define LATIN8 15 /* ISO-8859 Latin 8 */
#define LATIN9 16 /* ISO-8859 Latin 9 */
#define LATIN10 17 /* ISO-8859 Latin 10 */
#define WIN1256 18 /* Arabic Windows */
#define TCVN 19 /* Vietnamese Windows */
#define WIN874 20 /* Thai Windows */
#define KOI8R 21 /* KOI8-R/U */
#define WIN1251 22 /* windows-1251 */
#define ALT 23 /* Alternativny Variant (MS-DOS CP866) */
#define ISO_8859_5 24 /* ISO-8859-5 */
#define ISO_8859_6 25 /* ISO-8859-6 */
#define ISO_8859_7 26 /* ISO-8859-7 */
#define ISO_8859_8 27 /* ISO-8859-8 */
#define SJIS 28 /* Shift JIS */
#define BIG5 29 /* Big5 */
#define GBK 30 /* GBK */
#define UHC 31 /* UHC */
#define WIN1250 32 /* windows-1250 */
#define GB18030 33 /* GB18030 */
#define OTHER -1
#define MAX_CHARACTERSET_NAME 24
#define MAX_CHARACTER_LEN 6
/* OLD Type */
// extern int multibyte_client_encoding; /* Multibyte client encoding. */
// extern int multibyte_status; /* Multibyte charcter status. */
//
// void multibyte_init(void);
// unsigned char *check_client_encoding(unsigned char *sql_string);
// int multibyte_char_check(unsigned char s);
// unsigned char *multibyte_strchr(const unsigned char *string, unsigned int c);
/* New Type */
extern void CC_lookup_characterset(ConnectionClass *self);
extern int pg_CS_stat(int stat,unsigned int charcter,int characterset_code);
extern int pg_CS_code(const unsigned char *stat_string);
extern unsigned char *pg_CS_name(int code);
typedef struct pg_CS
{
unsigned char *name;
int code;
}pg_CS;
extern int pg_mbslen(int ccsc, const unsigned char *string);
extern unsigned char *pg_mbschr(int ccsc, const unsigned char *string, unsigned int character);
extern unsigned char *pg_mbsinc(int ccsc, const unsigned char *current );
/* Old Type Compatible */
typedef struct
{
int ccsc;
const char *encstr;
int pos;
int ccst;
} encoded_str;
#define ENCODE_STATUS(enc) ((enc).ccst)
void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str);
#define make_encoded_str(encstr, conn, str) encoded_str_constr(encstr, conn->ccsc, str)
extern int encoded_nextchar(encoded_str *encstr);
extern int encoded_byte_check(encoded_str *encstr, int abspos);
#define check_client_encoding(X) pg_CS_name(pg_CS_code(X))

View File

@ -1,38 +0,0 @@
/********************************************************************
PSQLODBC.DLL - A library to talk to the PostgreSQL DBMS using ODBC.
Copyright (C) 1998 Insight Distribution Systems
Copyright (C) 1998 - 2002 The PostgreSQL Global Development Group
Multibyte support was added by Sankyo Unyu Service, (C) 2001.
The code contained in this library is based on code written by
Christian Czezatke and Dan McGuirk, (C) 1996.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library (see "license.txt"); if not, write to
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
02139, USA.
How to contact the authors:
email: pgsql-odbc@postgresql.org
***********************************************************************/

View File

@ -1,228 +0,0 @@
-- PostgreSQL catalog extensions for ODBC compatibility
-- $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/odbc.sql,v 1.7 2001/12/21 06:01:36 thomas Exp $
-- ODBC functions are described here:
-- <http://msdn.microsoft.com/library/en-us/odbc/htm/odbcscalar_functions.asp>
-- Note: If we format this file consistently we can automatically
-- generate a corresponding "drop script". Start "CREATE" in the first
-- column, and keep everything up to and including the argument list on
-- the same line. See also the makefile rule.
-- String Functions
-- ++++++++++++++++
--
-- Built-in: ASCII, BIT_LENGTH, CHAR_LENGTH, CHARACTER_LENGTH, LTRIM,
-- OCTET_LENGTH, POSITION, REPEAT, RTRIM, SUBSTRING
-- Missing: DIFFERENCE, REPLACE, SOUNDEX, LENGTH (ODBC sense)
-- Keyword problems: CHAR
-- CHAR(code)
CREATE OR REPLACE FUNCTION "char"(integer) RETURNS text AS '
SELECT chr($1);
' LANGUAGE SQL;
-- CONCAT(string1, string2)
CREATE OR REPLACE FUNCTION concat(text, text) RETURNS text AS '
SELECT $1 || $2;
' LANGUAGE SQL;
-- INSERT(string1, start, len, string2)
CREATE OR REPLACE FUNCTION insert(text, integer, integer, text) RETURNS text AS '
SELECT substring($1 from 1 for $2 - 1) || $4 || substring($1 from $2 + $3);
' LANGUAGE SQL;
-- LCASE(string)
CREATE OR REPLACE FUNCTION lcase(text) RETURNS text AS '
SELECT lower($1);
' LANGUAGE SQL;
-- LEFT(string, count)
CREATE OR REPLACE FUNCTION left(text, integer) RETURNS text AS '
SELECT substring($1 for $2);
' LANGUAGE SQL;
-- LOCATE(substring, string[, start])
CREATE OR REPLACE FUNCTION locate(text, text) RETURNS integer AS '
SELECT position($1 in $2);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION locate(text, text, integer) RETURNS integer AS '
SELECT position($1 in substring($2 from $3)) + $3 - 1;
' LANGUAGE SQL;
-- RIGHT(string, count)
CREATE OR REPLACE FUNCTION right(text, integer) RETURNS text AS '
SELECT substring($1 from char_length($1) - $2 + 1);
' LANGUAGE SQL;
-- SPACE(count)
CREATE OR REPLACE FUNCTION space(integer) RETURNS text AS '
SELECT repeat('' '', $1);
' LANGUAGE SQL;
-- UCASE(string)
CREATE OR REPLACE FUNCTION ucase(text) RETURNS text AS '
SELECT upper($1);
' LANGUAGE SQL;
-- Numeric Functions
-- +++++++++++++++++
--
-- Built-in: ABS, ACOS, ASIN, ATAN, ATAN2, COS, COT, DEGRESS, EXP,
-- FLOOR, MOD, PI, RADIANS, ROUND, SIGN, SIN, SQRT, TAN
-- Missing: LOG (ODBC sense)
-- CEILING(num)
CREATE OR REPLACE FUNCTION ceiling(numeric) RETURNS numeric AS '
SELECT ceil($1);
' LANGUAGE SQL;
-- LOG10(num)
CREATE OR REPLACE FUNCTION log10(double precision) RETURNS double precision AS '
SELECT log($1);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION log10(numeric) RETURNS numeric AS '
SELECT log($1);
' LANGUAGE SQL;
-- POWER(num, num)
CREATE OR REPLACE FUNCTION power(double precision, double precision)
RETURNS double precision AS '
SELECT pow($1, $2);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION power(numeric, numeric)
RETURNS numeric AS '
SELECT pow($1, $2);
' LANGUAGE SQL;
-- RAND([seed])
CREATE OR REPLACE FUNCTION rand() RETURNS double precision AS '
SELECT random();
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION rand(double precision) RETURNS double precision AS '
SELECT setseed($1);
SELECT random();
' LANGUAGE SQL;
-- TRUNCATE(num, places)
CREATE OR REPLACE FUNCTION truncate(numeric, integer) RETURNS numeric AS '
SELECT trunc($1, $2);
' LANGUAGE SQL;
-- Time, Date, and Interval Functions
-- ++++++++++++++++++++++++++++++++++
--
-- Built-in: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, EXTRACT, NOW
-- Missing: none
CREATE OR REPLACE FUNCTION curdate() RETURNS date AS '
SELECT current_date;
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION curtime() RETURNS time with time zone AS '
SELECT current_time;
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION odbc_timestamp() RETURNS timestamp with time zone AS '
SELECT current_timestamp;
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION dayname(timestamp) RETURNS text AS '
SELECT to_char($1,''Day'');
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION dayofmonth(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(day FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION dayofweek(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(dow FROM $1) AS integer) + 1;
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION dayofyear(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(doy FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION hour(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(hour FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION minute(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(minute FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION month(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(month FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION monthname(timestamp) RETURNS text AS '
SELECT to_char($1, ''Month'');
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION quarter(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(quarter FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION second(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(second FROM $1) AS integer);
' LANGUAGE SQL;
/*
-- The first argument is an integer constant denoting the units
-- of the second argument. Until we know the actual values, we
-- cannot implement these. - thomas 2000-04-11
xCREATE OR REPLACE FUNCTION timestampadd(integer, integer, timestamp)
RETURNS timestamp AS '
SELECT CAST(($3 + ($2 * $1)) AS timestamp);
' LANGUAGE SQL;
xCREATE OR REPLACE FUNCTION timestampdiff(integer, integer, timestamp)
RETURNS timestamp AS '
SELECT CAST(($3 + ($2 * $1)) AS timestamp);
' LANGUAGE SQL;
*/
CREATE OR REPLACE FUNCTION week(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(week FROM $1) AS integer);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION year(timestamp) RETURNS integer AS '
SELECT CAST(EXTRACT(year FROM $1) AS integer);
' LANGUAGE SQL;
-- System Functions
-- ++++++++++++++++
--
-- Built-in: USER
-- Missing: DATABASE, IFNULL
CREATE OR REPLACE FUNCTION odbc_user() RETURNS text AS '
SELECT CAST(current_user AS TEXT);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION odbc_current_user() RETURNS text AS '
SELECT CAST(current_user AS TEXT);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION odbc_session_user() RETURNS text AS '
SELECT CAST(session_user AS TEXT);
' LANGUAGE SQL;

View File

@ -1,716 +0,0 @@
/*-------
* Module: odbcapi.c
*
* Description: This module contains routines related to
* preparing and executing an SQL statement.
*
* Classes: n/a
*
* API functions: SQLAllocConnect, SQLAllocEnv, SQLAllocStmt,
SQLBindCol, SQLCancel, SQLColumns, SQLConnect,
SQLDataSources, SQLDescribeCol, SQLDisconnect,
SQLError, SQLExecDirect, SQLExecute, SQLFetch,
SQLFreeConnect, SQLFreeEnv, SQLFreeStmt,
SQLGetConnectOption, SQLGetCursorName, SQLGetData,
SQLGetFunctions, SQLGetInfo, SQLGetStmtOption,
SQLGetTypeInfo, SQLNumResultCols, SQLParamData,
SQLPrepare, SQLPutData, SQLRowCount,
SQLSetConnectOption, SQLSetCursorName, SQLSetParam,
SQLSetStmtOption, SQLSpecialColumns, SQLStatistics,
SQLTables, SQLTransact, SQLColAttributes,
SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch,
SQLForeignKeys, SQLMoreResults, SQLNativeSql,
SQLNumParams, SQLParamOptions, SQLPrimaryKeys,
SQLProcedureColumns, SQLProcedures, SQLSetPos,
SQLTablePrivileges, SQLBindParameter
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "pgapifunc.h"
#include "connection.h"
#include "statement.h"
RETCODE SQL_API
SQLAllocConnect(HENV EnvironmentHandle,
HDBC FAR * ConnectionHandle)
{
mylog("[SQLAllocConnect]");
return PGAPI_AllocConnect(EnvironmentHandle, ConnectionHandle);
}
RETCODE SQL_API
SQLAllocEnv(HENV FAR * EnvironmentHandle)
{
mylog("[SQLAllocEnv]");
return PGAPI_AllocEnv(EnvironmentHandle);
}
RETCODE SQL_API
SQLAllocStmt(HDBC ConnectionHandle,
HSTMT *StatementHandle)
{
mylog("[SQLAllocStmt]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_AllocStmt(ConnectionHandle, StatementHandle);
}
RETCODE SQL_API
SQLBindCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLINTEGER BufferLength,
SQLINTEGER *StrLen_or_Ind)
{
mylog("[SQLBindCol]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_BindCol(StatementHandle, ColumnNumber,
TargetType, TargetValue, BufferLength, StrLen_or_Ind);
}
RETCODE SQL_API
SQLCancel(HSTMT StatementHandle)
{
mylog("[SQLCancel]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Cancel(StatementHandle);
}
RETCODE SQL_API
SQLColumns(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
{
mylog("[SQLColumns]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Columns(StatementHandle, CatalogName, NameLength1,
SchemaName, NameLength2, TableName, NameLength3,
ColumnName, NameLength4, 0);
}
RETCODE SQL_API
SQLConnect(HDBC ConnectionHandle,
SQLCHAR *ServerName, SQLSMALLINT NameLength1,
SQLCHAR *UserName, SQLSMALLINT NameLength2,
SQLCHAR *Authentication, SQLSMALLINT NameLength3)
{
mylog("[SQLConnect]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_Connect(ConnectionHandle, ServerName, NameLength1,
UserName, NameLength2, Authentication, NameLength3);
}
RETCODE SQL_API
SQLDriverConnect(HDBC hdbc,
HWND hwnd,
UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn,
UCHAR FAR * szConnStrOut,
SWORD cbConnStrOutMax,
SWORD FAR * pcbConnStrOut,
UWORD fDriverCompletion)
{
mylog("[SQLDriverConnect]");
CC_clear_error((ConnectionClass *) hdbc);
return PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion);
}
RETCODE SQL_API
SQLBrowseConnect(
HDBC hdbc,
SQLCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut)
{
mylog("[SQLBrowseConnect]");
CC_clear_error((ConnectionClass *) hdbc);
return PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
}
RETCODE SQL_API
SQLDataSources(HENV EnvironmentHandle,
SQLUSMALLINT Direction, SQLCHAR *ServerName,
SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
SQLCHAR *Description, SQLSMALLINT BufferLength2,
SQLSMALLINT *NameLength2)
{
mylog("[SQLDataSources]");
/*
* return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
* BufferLength1, NameLength1, Description, BufferLength2,
* NameLength2);
*/
return SQL_ERROR;
}
RETCODE SQL_API
SQLDescribeCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
mylog("[SQLDescribeCol]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_DescribeCol(StatementHandle, ColumnNumber,
ColumnName, BufferLength, NameLength,
DataType, ColumnSize, DecimalDigits, Nullable);
}
RETCODE SQL_API
SQLDisconnect(HDBC ConnectionHandle)
{
mylog("[SQLDisconnect]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_Disconnect(ConnectionHandle);
}
RETCODE SQL_API
SQLError(HENV EnvironmentHandle,
HDBC ConnectionHandle, HSTMT StatementHandle,
SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength)
{
mylog("[SQLError]");
return PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
Sqlstate, NativeError, MessageText, BufferLength,
TextLength);
}
RETCODE SQL_API
SQLExecDirect(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength)
{
mylog("[SQLExecDirect]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_ExecDirect(StatementHandle, StatementText, TextLength);
}
RETCODE SQL_API
SQLExecute(HSTMT StatementHandle)
{
mylog("[SQLExecute]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Execute(StatementHandle);
}
RETCODE SQL_API
SQLFetch(HSTMT StatementHandle)
{
static char *func = "SQLFetch";
#if (ODBCVER >= 0x0300)
StatementClass *stmt = (StatementClass *) StatementHandle;
ConnectionClass *conn = SC_get_conn(stmt);
SC_clear_error(stmt);
if (conn->driver_version >= 0x0300)
{
IRDFields *irdopts = SC_get_IRD(stmt);
SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray;
SQLINTEGER *pcRow = irdopts->rowsFetched;
mylog("[[%s]]", func);
return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0,
pcRow, rowStatusArray, 0);
}
#endif
mylog("[%s]", func);
return PGAPI_Fetch(StatementHandle);
}
RETCODE SQL_API
SQLFreeConnect(HDBC ConnectionHandle)
{
mylog("[SQLFreeConnect]");
return PGAPI_FreeConnect(ConnectionHandle);
}
RETCODE SQL_API
SQLFreeEnv(HENV EnvironmentHandle)
{
mylog("[SQLFreeEnv]");
return PGAPI_FreeEnv(EnvironmentHandle);
}
RETCODE SQL_API
SQLFreeStmt(HSTMT StatementHandle,
SQLUSMALLINT Option)
{
mylog("[SQLFreeStmt]");
return PGAPI_FreeStmt(StatementHandle, Option);
}
RETCODE SQL_API
SQLGetConnectOption(HDBC ConnectionHandle,
SQLUSMALLINT Option, PTR Value)
{
mylog("[SQLGetConnectOption]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_GetConnectOption(ConnectionHandle, Option, Value);
}
RETCODE SQL_API
SQLGetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT BufferLength,
SQLSMALLINT *NameLength)
{
mylog("[SQLGetCursorName]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength,
NameLength);
}
RETCODE SQL_API
SQLGetData(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLINTEGER BufferLength,
SQLINTEGER *StrLen_or_Ind)
{
mylog("[SQLGetData]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_GetData(StatementHandle, ColumnNumber, TargetType,
TargetValue, BufferLength, StrLen_or_Ind);
}
RETCODE SQL_API
SQLGetFunctions(HDBC ConnectionHandle,
SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
{
mylog("[SQLGetFunctions]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
#if (ODBCVER >= 0x0300)
if (FunctionId == SQL_API_ODBC3_ALL_FUNCTIONS)
return PGAPI_GetFunctions30(ConnectionHandle, FunctionId, Supported);
#endif
return PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported);
}
RETCODE SQL_API
SQLGetInfo(HDBC ConnectionHandle,
SQLUSMALLINT InfoType, PTR InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
CC_clear_error(conn);
#if (ODBCVER >= 0x0300)
mylog("[SQLGetInfo(30)]");
if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength)) == SQL_ERROR)
{
if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x0300)
{
CC_clear_error(conn);
ret = PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength);
}
}
if (SQL_ERROR == ret)
CC_log_error("SQLGetInfo30", "", conn);
#else
mylog("[SQLGetInfo]");
if (ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength), SQL_ERROR == ret)
CC_log_error("PGAPI_GetInfo", "", conn);
#endif
return ret;
}
RETCODE SQL_API
SQLGetStmtOption(HSTMT StatementHandle,
SQLUSMALLINT Option, PTR Value)
{
mylog("[SQLGetStmtOption]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_GetStmtOption(StatementHandle, Option, Value);
}
RETCODE SQL_API
SQLGetTypeInfo(HSTMT StatementHandle,
SQLSMALLINT DataType)
{
mylog("[SQLGetTypeInfo]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_GetTypeInfo(StatementHandle, DataType);
}
RETCODE SQL_API
SQLNumResultCols(HSTMT StatementHandle,
SQLSMALLINT *ColumnCount)
{
mylog("[SQLNumResultCols]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_NumResultCols(StatementHandle, ColumnCount);
}
RETCODE SQL_API
SQLParamData(HSTMT StatementHandle,
PTR *Value)
{
mylog("[SQLParamData]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_ParamData(StatementHandle, Value);
}
RETCODE SQL_API
SQLPrepare(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength)
{
mylog("[SQLPrepare]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Prepare(StatementHandle, StatementText, TextLength);
}
RETCODE SQL_API
SQLPutData(HSTMT StatementHandle,
PTR Data, SQLINTEGER StrLen_or_Ind)
{
mylog("[SQLPutData]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind);
}
RETCODE SQL_API
SQLRowCount(HSTMT StatementHandle,
SQLINTEGER *RowCount)
{
mylog("[SQLRowCount]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_RowCount(StatementHandle, RowCount);
}
RETCODE SQL_API
SQLSetConnectOption(HDBC ConnectionHandle,
SQLUSMALLINT Option, SQLUINTEGER Value)
{
mylog("[SQLSetConnectionOption]");
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
}
RETCODE SQL_API
SQLSetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT NameLength)
{
mylog("[SQLSetCursorName]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_SetCursorName(StatementHandle, CursorName, NameLength);
}
RETCODE SQL_API
SQLSetParam(HSTMT StatementHandle,
SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
SQLSMALLINT ParameterScale, PTR ParameterValue,
SQLINTEGER *StrLen_or_Ind)
{
mylog("[SQLSetParam]");
SC_clear_error((StatementClass *) StatementHandle);
/*
* return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType,
* ParameterType, LengthPrecision, ParameterScale, ParameterValue,
* StrLen_or_Ind);
*/
return SQL_ERROR;
}
RETCODE SQL_API
SQLSetStmtOption(HSTMT StatementHandle,
SQLUSMALLINT Option, SQLUINTEGER Value)
{
mylog("[SQLSetStmtOption]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_SetStmtOption(StatementHandle, Option, Value);
}
RETCODE SQL_API
SQLSpecialColumns(HSTMT StatementHandle,
SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
SQLSMALLINT NameLength2, SQLCHAR *TableName,
SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
SQLUSMALLINT Nullable)
{
mylog("[SQLSpecialColumns]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_SpecialColumns(StatementHandle, IdentifierType, CatalogName,
NameLength1, SchemaName, NameLength2, TableName, NameLength3,
Scope, Nullable);
}
RETCODE SQL_API
SQLStatistics(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
mylog("[SQLStatistics]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Statistics(StatementHandle, CatalogName, NameLength1,
SchemaName, NameLength2, TableName, NameLength3, Unique,
Reserved);
}
RETCODE SQL_API
SQLTables(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *TableType, SQLSMALLINT NameLength4)
{
mylog("[SQLTables]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_Tables(StatementHandle, CatalogName, NameLength1,
SchemaName, NameLength2, TableName, NameLength3,
TableType, NameLength4);
}
RETCODE SQL_API
SQLTransact(HENV EnvironmentHandle,
HDBC ConnectionHandle, SQLUSMALLINT CompletionType)
{
mylog("[SQLTransact]");
return PGAPI_Transact(EnvironmentHandle, ConnectionHandle, CompletionType);
}
RETCODE SQL_API
SQLColAttributes(
HSTMT hstmt,
SQLUSMALLINT icol,
SQLUSMALLINT fDescType,
PTR rgbDesc,
SQLSMALLINT cbDescMax,
SQLSMALLINT *pcbDesc,
SQLINTEGER *pfDesc)
{
mylog("[SQLColAttributes]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
cbDescMax, pcbDesc, pfDesc);
}
RETCODE SQL_API
SQLColumnPrivileges(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
mylog("[SQLColumnPrivileges]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ColumnPrivileges(hstmt, szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName, szTableName, cbTableName,
szColumnName, cbColumnName);
}
RETCODE SQL_API
SQLDescribeParam(
HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT *pfSqlType,
SQLUINTEGER *pcbParamDef,
SQLSMALLINT *pibScale,
SQLSMALLINT *pfNullable)
{
mylog("[SQLDescribeParam]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef,
pibScale, pfNullable);
}
RETCODE SQL_API
SQLExtendedFetch(
HSTMT hstmt,
SQLUSMALLINT fFetchType,
SQLINTEGER irow,
SQLUINTEGER *pcrow,
SQLUSMALLINT *rgfRowStatus)
{
mylog("[SQLExtendedFetch]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus, 0);
}
RETCODE SQL_API
SQLForeignKeys(
HSTMT hstmt,
SQLCHAR *szPkCatalogName,
SQLSMALLINT cbPkCatalogName,
SQLCHAR *szPkSchemaName,
SQLSMALLINT cbPkSchemaName,
SQLCHAR *szPkTableName,
SQLSMALLINT cbPkTableName,
SQLCHAR *szFkCatalogName,
SQLSMALLINT cbFkCatalogName,
SQLCHAR *szFkSchemaName,
SQLSMALLINT cbFkSchemaName,
SQLCHAR *szFkTableName,
SQLSMALLINT cbFkTableName)
{
mylog("[SQLForeignKeys]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName,
szPkSchemaName, cbPkSchemaName, szPkTableName,
cbPkTableName, szFkCatalogName, cbFkCatalogName,
szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
}
RETCODE SQL_API
SQLMoreResults(HSTMT hstmt)
{
mylog("[SQLMoreResults]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_MoreResults(hstmt);
}
RETCODE SQL_API
SQLNativeSql(
HDBC hdbc,
SQLCHAR *szSqlStrIn,
SQLINTEGER cbSqlStrIn,
SQLCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax,
SQLINTEGER *pcbSqlStr)
{
mylog("[SQLNativeSql]");
CC_clear_error((ConnectionClass *) hdbc);
return PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr,
cbSqlStrMax, pcbSqlStr);
}
RETCODE SQL_API
SQLNumParams(
HSTMT hstmt,
SQLSMALLINT *pcpar)
{
mylog("[SQLNumParams]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_NumParams(hstmt, pcpar);
}
RETCODE SQL_API
SQLParamOptions(
HSTMT hstmt,
SQLUINTEGER crow,
SQLUINTEGER *pirow)
{
mylog("[SQLParamOptions]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ParamOptions(hstmt, crow, pirow);
}
RETCODE SQL_API
SQLPrimaryKeys(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName)
{
mylog("[SQLPrimaryKeys]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_PrimaryKeys(hstmt, szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName, szTableName, cbTableName);
}
RETCODE SQL_API
SQLProcedureColumns(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
mylog("[SQLProcedureColumns]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_ProcedureColumns(hstmt, szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName, szProcName, cbProcName,
szColumnName, cbColumnName);
}
RETCODE SQL_API
SQLProcedures(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName)
{
mylog("[SQLProcedures]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_Procedures(hstmt, szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName, szProcName, cbProcName);
}
RETCODE SQL_API
SQLSetPos(
HSTMT hstmt,
SQLUSMALLINT irow,
SQLUSMALLINT fOption,
SQLUSMALLINT fLock)
{
mylog("[SQLSetPos]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_SetPos(hstmt, irow, fOption, fLock);
}
RETCODE SQL_API
SQLTablePrivileges(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName)
{
mylog("[SQLTablePrivileges]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_TablePrivileges(hstmt, szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName, szTableName, cbTableName, 0);
}
RETCODE SQL_API
SQLBindParameter(
HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT fParamType,
SQLSMALLINT fCType,
SQLSMALLINT fSqlType,
SQLUINTEGER cbColDef,
SQLSMALLINT ibScale,
PTR rgbValue,
SQLINTEGER cbValueMax,
SQLINTEGER *pcbValue)
{
mylog("[SQLBindParameter]");
SC_clear_error((StatementClass *) hstmt);
return PGAPI_BindParameter(hstmt, ipar, fParamType, fCType,
fSqlType, cbColDef, ibScale, rgbValue, cbValueMax,
pcbValue);
}

View File

@ -1,81 +0,0 @@
/*-------
* Module: odbcapi25w.c
*
* Description: This module contains UNICODE routines
*
* Classes: n/a
*
* API functions: SQLColAttributesW, SQLErrorW, SQLGetConnectOptionW,
SQLSetConnectOptionW
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "pgapifunc.h"
#include "connection.h"
#include "statement.h"
RETCODE SQL_API SQLErrorW(HENV EnvironmentHandle,
HDBC ConnectionHandle, HSTMT StatementHandle,
SQLWCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLWCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength)
{
RETCODE ret;
SWORD tlen, buflen;
char *qst = NULL, *mtxt = NULL;
mylog("[SQLErrorW]");
if (Sqlstate)
qst = malloc(8);
buflen = 0;
if (MessageText && BufferLength > 0)
{
buflen = BufferLength * 3 + 1;
mtxt = malloc(buflen);
}
ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
qst, NativeError, mtxt, buflen, &tlen);
if (qst)
utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5);
if (TextLength)
*TextLength = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength);
free(qst);
if (mtxt)
free(mtxt);
return ret;
}
RETCODE SQL_API SQLGetConnectOptionW(HDBC ConnectionHandle,
SQLUSMALLINT Option, PTR Value)
{
mylog("[SQLGetConnectOptionW]");
((ConnectionClass *) ConnectionHandle)->unicode = 1;
return PGAPI_GetConnectOption(ConnectionHandle, Option, Value);
}
RETCODE SQL_API SQLSetConnectOptionW(HDBC ConnectionHandle,
SQLUSMALLINT Option, SQLUINTEGER Value)
{
mylog("[SQLSetConnectionOptionW]");
if (!ConnectionHandle) return SQL_ERROR;
((ConnectionClass *) ConnectionHandle)->unicode = 1;
return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
}
RETCODE SQL_API SQLColAttributesW(
HSTMT hstmt,
SQLUSMALLINT icol,
SQLUSMALLINT fDescType,
PTR rgbDesc,
SQLSMALLINT cbDescMax,
SQLSMALLINT *pcbDesc,
SQLINTEGER *pfDesc)
{
mylog("[SQLColAttributesW]");
return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
cbDescMax, pcbDesc, pfDesc);
}

View File

@ -1,550 +0,0 @@
/*-------
* Module: odbcapi30.c
*
* Description: This module contains routines related to ODBC 3.0
* most of their implementations are temporary
* and must be rewritten properly.
* 2001/07/23 inoue
*
* Classes: n/a
*
* API functions: SQLAllocHandle, SQLBindParam, SQLCloseCursor,
SQLColAttribute, SQLCopyDesc, SQLEndTran,
SQLFetchScroll, SQLFreeHandle, SQLGetDescField,
SQLGetDescRec, SQLGetDiagField, SQLGetDiagRec,
SQLGetEnvAttr, SQLGetConnectAttr, SQLGetStmtAttr,
SQLSetConnectAttr, SQLSetDescField, SQLSetDescRec,
SQLSetEnvAttr, SQLSetStmtAttr, SQLBulkOperations
*-------
*/
#ifndef ODBCVER
#define ODBCVER 0x0300
#endif
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "environ.h"
#include "connection.h"
#include "statement.h"
#include "pgapifunc.h"
/* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */
RETCODE SQL_API
SQLAllocHandle(SQLSMALLINT HandleType,
SQLHANDLE InputHandle, SQLHANDLE * OutputHandle)
{
mylog("[[SQLAllocHandle]]");
switch (HandleType)
{
case SQL_HANDLE_ENV:
return PGAPI_AllocEnv(OutputHandle);
case SQL_HANDLE_DBC:
return PGAPI_AllocConnect(InputHandle, OutputHandle);
case SQL_HANDLE_STMT:
return PGAPI_AllocStmt(InputHandle, OutputHandle);
default:
break;
}
return SQL_ERROR;
}
/* SQLBindParameter/SQLSetParam -> SQLBindParam */
RETCODE SQL_API
SQLBindParam(HSTMT StatementHandle,
SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
SQLSMALLINT ParameterScale, PTR ParameterValue,
SQLINTEGER *StrLen_or_Ind)
{
int BufferLength = 512; /* Is it OK ? */
mylog("[[SQLBindParam]]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_BindParameter(StatementHandle, ParameterNumber, SQL_PARAM_INPUT, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, BufferLength, StrLen_or_Ind);
}
/* New function */
RETCODE SQL_API
SQLCloseCursor(HSTMT StatementHandle)
{
mylog("[[SQLCloseCursor]]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_FreeStmt(StatementHandle, SQL_CLOSE);
}
/* SQLColAttributes -> SQLColAttribute */
RETCODE SQL_API
SQLColAttribute(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
PTR CharacterAttribute, SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength, PTR NumericAttribute)
{
mylog("[[SQLColAttribute]]");
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_ColAttributes(StatementHandle, ColumnNumber,
FieldIdentifier, CharacterAttribute, BufferLength,
StringLength, NumericAttribute);
}
static HSTMT
descHandleFromStatementHandle(HSTMT StatementHandle, SQLINTEGER descType)
{
switch (descType)
{
case SQL_ATTR_APP_ROW_DESC: /* 10010 */
return StatementHandle; /* this is bogus */
case SQL_ATTR_APP_PARAM_DESC: /* 10011 */
return (HSTMT) ((SQLUINTEGER) StatementHandle + 1) ; /* this is bogus */
case SQL_ATTR_IMP_ROW_DESC: /* 10012 */
return (HSTMT) ((SQLUINTEGER) StatementHandle + 2); /* this is bogus */
case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */
return (HSTMT) ((SQLUINTEGER) StatementHandle + 3); /* this is bogus */
}
return (HSTMT) 0;
}
static HSTMT
statementHandleFromDescHandle(HSTMT DescHandle, SQLINTEGER *descType)
{
SQLUINTEGER res = (SQLUINTEGER) DescHandle % 4;
switch (res)
{
case 0: *descType = SQL_ATTR_APP_ROW_DESC; /* 10010 */
break;
case 1: *descType = SQL_ATTR_APP_PARAM_DESC; /* 10011 */
break;
case 2: *descType = SQL_ATTR_IMP_ROW_DESC; /* 10012 */
break;
case 3: *descType = SQL_ATTR_IMP_PARAM_DESC; /* 10013 */
break;
}
return (HSTMT) ((SQLUINTEGER) DescHandle - res);
}
/* new function */
RETCODE SQL_API
SQLCopyDesc(SQLHDESC SourceDescHandle,
SQLHDESC TargetDescHandle)
{
mylog("[[SQLCopyDesc]]\n");
mylog("Error not implemented\n");
return SQL_ERROR;
}
/* SQLTransact -> SQLEndTran */
RETCODE SQL_API
SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle,
SQLSMALLINT CompletionType)
{
mylog("[[SQLEndTran]]");
switch (HandleType)
{
case SQL_HANDLE_ENV:
return PGAPI_Transact(Handle, SQL_NULL_HDBC, CompletionType);
case SQL_HANDLE_DBC:
CC_clear_error((ConnectionClass *) Handle);
return PGAPI_Transact(SQL_NULL_HENV, Handle, CompletionType);
default:
break;
}
return SQL_ERROR;
}
/* SQLExtendedFetch -> SQLFetchScroll */
RETCODE SQL_API
SQLFetchScroll(HSTMT StatementHandle,
SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
{
static char *func = "SQLFetchScroll";
StatementClass *stmt = (StatementClass *) StatementHandle;
RETCODE ret;
IRDFields *irdopts = SC_get_IRD(stmt);
SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray;
SQLINTEGER *pcRow = irdopts->rowsFetched, bkmarkoff = 0;
mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset);
SC_clear_error(stmt);
if (FetchOrientation == SQL_FETCH_BOOKMARK)
{
if (stmt->options.bookmark_ptr)
{
bkmarkoff = FetchOffset;
FetchOffset = *((Int4 *) stmt->options.bookmark_ptr);
mylog("bookmark=%u FetchOffset = %d\n", FetchOffset, bkmarkoff);
}
else
{
stmt->errornumber = STMT_SEQUENCE_ERROR;
stmt->errormsg = "Bookmark isn't specifed yet";
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
}
ret = PGAPI_ExtendedFetch(StatementHandle, FetchOrientation, FetchOffset,
pcRow, rowStatusArray, bkmarkoff);
if (ret != SQL_SUCCESS)
mylog("%s return = %d\n", func, ret);
return ret;
}
/* SQLFree(Connect/Env/Stmt) -> SQLFreeHandle */
RETCODE SQL_API
SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
{
mylog("[[SQLFreeHandle]]");
switch (HandleType)
{
case SQL_HANDLE_ENV:
return PGAPI_FreeEnv(Handle);
case SQL_HANDLE_DBC:
return PGAPI_FreeConnect(Handle);
case SQL_HANDLE_STMT:
return PGAPI_FreeStmt(Handle, SQL_DROP);
default:
break;
}
return SQL_ERROR;
}
/* new function */
RETCODE SQL_API
SQLGetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
PTR Value, SQLINTEGER BufferLength,
SQLINTEGER *StringLength)
{
mylog("[[SQLGetDescField]]\n");
return PGAPI_GetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
Value, BufferLength, StringLength);
}
/* new function */
RETCODE SQL_API
SQLGetDescRec(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLCHAR *Name,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
SQLSMALLINT *Type, SQLSMALLINT *SubType,
SQLINTEGER *Length, SQLSMALLINT *Precision,
SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
{
mylog("[[SQLGetDescRec]]\n");
mylog("Error not implemented\n");
return SQL_ERROR;
}
/* new function */
RETCODE SQL_API
SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
PTR DiagInfo, SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength)
{
mylog("[[SQLGetDiagField]] Handle=(%u,%x) Rec=%d Id=%d\n", HandleType, Handle, RecNumber, DiagIdentifier);
return PGAPI_GetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
DiagInfo, BufferLength, StringLength);
}
/* SQLError -> SQLDiagRec */
RETCODE SQL_API
SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
SQLINTEGER *NativeError, SQLCHAR *MessageText,
SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
{
mylog("[[SQLGetDiagRec]]\n");
return PGAPI_GetDiagRec(HandleType, Handle, RecNumber, Sqlstate,
NativeError, MessageText, BufferLength, TextLength);
}
/* new function */
RETCODE SQL_API
SQLGetEnvAttr(HENV EnvironmentHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle;
mylog("[[SQLGetEnvAttr]] %d\n", Attribute);
switch (Attribute)
{
case SQL_ATTR_CONNECTION_POOLING:
*((unsigned int *) Value) = SQL_CP_OFF;
break;
case SQL_ATTR_CP_MATCH:
*((unsigned int *) Value) = SQL_CP_RELAXED_MATCH;
break;
case SQL_ATTR_ODBC_VERSION:
*((unsigned int *) Value) = EN_is_odbc2(env) ? SQL_OV_ODBC2 : SQL_OV_ODBC3;
break;
case SQL_ATTR_OUTPUT_NTS:
*((unsigned int *) Value) = SQL_TRUE;
break;
default:
env->errornumber = CONN_INVALID_ARGUMENT_NO;
return SQL_ERROR;
}
return SQL_SUCCESS;
}
/* SQLGetConnectOption -> SQLGetconnectAttr */
RETCODE SQL_API
SQLGetConnectAttr(HDBC ConnectionHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
mylog("[[SQLGetConnectAttr]] %d\n", Attribute);
CC_clear_error((ConnectionClass *) ConnectionHandle);
return PGAPI_GetConnectAttr(ConnectionHandle, Attribute,Value,
BufferLength, StringLength);
}
/* SQLGetStmtOption -> SQLGetStmtAttr */
RETCODE SQL_API
SQLGetStmtAttr(HSTMT StatementHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
static char *func = "SQLGetStmtAttr";
mylog("[[%s]] Handle=%u %d\n", func, StatementHandle, Attribute);
SC_clear_error((StatementClass *) StatementHandle);
return PGAPI_GetStmtAttr(StatementHandle, Attribute, Value,
BufferLength, StringLength);
}
/* SQLSetConnectOption -> SQLSetConnectAttr */
RETCODE SQL_API
SQLSetConnectAttr(HDBC ConnectionHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER StringLength)
{
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
mylog("[[SQLSetConnectAttr]] %d\n", Attribute);
CC_clear_error(conn);
return PGAPI_SetConnectAttr(ConnectionHandle, Attribute, Value,
StringLength);
}
/* new function */
RETCODE SQL_API
SQLSetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
PTR Value, SQLINTEGER BufferLength)
{
RETCODE ret;
mylog("[[SQLSetDescField]] h=%u rec=%d field=%d val=%x\n", DescriptorHandle, RecNumber, FieldIdentifier, Value);
ret = PGAPI_SetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
Value, BufferLength);
return ret;
}
/* new fucntion */
RETCODE SQL_API
SQLSetDescRec(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLSMALLINT Type,
SQLSMALLINT SubType, SQLINTEGER Length,
SQLSMALLINT Precision, SQLSMALLINT Scale,
PTR Data, SQLINTEGER *StringLength,
SQLINTEGER *Indicator)
{
const char *func = "SQLSetDescRec";
mylog("[[SQLSetDescRec]]\n");
mylog("Error not implemented\n");
return SQL_ERROR;
}
/* new function */
RETCODE SQL_API
SQLSetEnvAttr(HENV EnvironmentHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER StringLength)
{
EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle;
mylog("[[SQLSetEnvAttr]] att=%d,%u\n", Attribute, Value);
switch (Attribute)
{
case SQL_ATTR_CONNECTION_POOLING:
if ((SQLUINTEGER) Value == SQL_CP_OFF)
return SQL_SUCCESS;
break;
case SQL_ATTR_CP_MATCH:
/* *((unsigned int *) Value) = SQL_CP_RELAXED_MATCH; */
return SQL_SUCCESS;
case SQL_ATTR_ODBC_VERSION:
if ((SQLUINTEGER) Value == SQL_OV_ODBC2)
EN_set_odbc2(env);
else
EN_set_odbc3(env);
return SQL_SUCCESS;
break;
case SQL_ATTR_OUTPUT_NTS:
if ((SQLUINTEGER) Value == SQL_TRUE)
return SQL_SUCCESS;
break;
default:
env->errornumber = CONN_INVALID_ARGUMENT_NO;
return SQL_ERROR;
}
env->errornumber = CONN_OPTION_VALUE_CHANGED;
env->errormsg = "SetEnv changed to ";
return SQL_SUCCESS_WITH_INFO;
}
/* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */
RETCODE SQL_API
SQLSetStmtAttr(HSTMT StatementHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER StringLength)
{
static char *func = "SQLSetStmtAttr";
StatementClass *stmt = (StatementClass *) StatementHandle;
mylog("[[%s]] Handle=%u %d,%u\n", func, StatementHandle, Attribute, Value);
SC_clear_error(stmt);
return PGAPI_SetStmtAttr(StatementHandle, Attribute, Value, StringLength);
}
#define SQL_FUNC_ESET(pfExists, uwAPI) \
(*(((UWORD*) (pfExists)) + ((uwAPI) >> 4)) \
|= (1 << ((uwAPI) & 0x000F)) \
)
RETCODE SQL_API
PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR * pfExists)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci = &(conn->connInfo);
CC_clear_error(conn);
if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS)
return SQL_ERROR;
memset(pfExists, 0, sizeof(UWORD) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE);
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCSTMT); 3 deprecated */
/*
* for (i = SQL_API_SQLBINDCOL; i <= 23; i++) SQL_FUNC_ESET(pfExists,
* i);
*/
SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLCANCEL); /* 5 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLERROR); 10 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREECONNECT); 14 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEENV); 15 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPARAM); 22 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLTRANSACT); 23 deprecated */
/*
* for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++)
* SQL_FUNC_ESET(pfExists, i);
*/
SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTOPTION); 42 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTOPTION); 46 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 deprecated */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTOPTION); 51 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSPECIALCOLUMNS); /* 52 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLES); /* 54 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */
if (ci->drivers.lie)
SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 not implemented yet */
SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */
if (ci->drivers.lie)
SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 not properly implemented */
SQL_FUNC_ESET(pfExists, SQL_API_SQLEXTENDEDFETCH); /* 59 deprecated ? */
/*
* for (++i; i < SQL_API_SQLBINDPARAMETER; i++)
* SQL_FUNC_ESET(pfExists, i);
*/
SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMOPTIONS); 64 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */
if (ci->drivers.lie)
SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 not implemeted yet */
SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPOS); /* 68 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); 69 deprecated */
SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */
/* SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS); */ /* 71 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */
if (ci->drivers.lie)
SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC); /* 1004 not implemented yet */
SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 */
if (ci->drivers.lie)
{
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented yet */
}
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 minimal implementation */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 */
if (ci->drivers.lie)
{
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */
}
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */
if (ci->updatable_cursors)
SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS); /* 24 */
return SQL_SUCCESS;
}
RETCODE SQL_API
SQLBulkOperations(HSTMT hstmt, SQLSMALLINT operation)
{
static char *func = "SQLBulkOperations";
#ifndef DRIVER_CURSOR_IMPLEMENT
StatementClass *stmt = (StatementClass *) hstmt;
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
stmt->errormsg = "driver must be compiled with the DRIVER_CURSOR_IMPLEMENT option";
SC_log_error(func, "", stmt);
return SQL_ERROR;
#else
mylog("[[%s]] Handle=%u %d\n", func, hstmt, operation);
SC_clear_error((StatementClass *) hstmt);
return PGAPI_BulkOperations(hstmt, operation);
#endif /* DRIVER_CURSOR_IMPLEMENT */
}

View File

@ -1,282 +0,0 @@
/*-------
* Module: odbcapi30w.c
*
* Description: This module contains UNICODE routines
*
* Classes: n/a
*
* API functions: SQLColAttributeW, SQLGetStmtAttrW, SQLSetStmtAttrW,
SQLSetConnectAttrW, SQLGetConnectAttrW,
SQLGetDescFieldW, SQLGetDescRecW, SQLGetDiagFieldW,
SQLGetDiagRecW,
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "pgapifunc.h"
#include "connection.h"
#include "statement.h"
RETCODE SQL_API SQLGetStmtAttrW(SQLHSTMT hstmt,
SQLINTEGER fAttribute,
PTR rgbValue,
SQLINTEGER cbValueMax,
SQLINTEGER *pcbValue)
{
RETCODE ret;
mylog("[SQLGetStmtAttrW]");
SC_clear_error((StatementClass *) hstmt);
ret = PGAPI_GetStmtAttr(hstmt, fAttribute, rgbValue,
cbValueMax, pcbValue);
return ret;
}
RETCODE SQL_API SQLSetStmtAttrW(SQLHSTMT hstmt,
SQLINTEGER fAttribute,
PTR rgbValue,
SQLINTEGER cbValueMax)
{
RETCODE ret;
mylog("[SQLSetStmtAttrW]");
SC_clear_error((StatementClass *) hstmt);
ret = PGAPI_SetStmtAttr(hstmt, fAttribute, rgbValue,
cbValueMax);
return ret;
}
RETCODE SQL_API SQLGetConnectAttrW(HDBC hdbc,
SQLINTEGER fAttribute,
PTR rgbValue,
SQLINTEGER cbValueMax,
SQLINTEGER *pcbValue)
{
RETCODE ret;
mylog("[SQLGetConnectAttrW]");
CC_clear_error((ConnectionClass *) hdbc);
ret = PGAPI_GetConnectAttr(hdbc, fAttribute, rgbValue,
cbValueMax, pcbValue);
return ret;
}
RETCODE SQL_API SQLSetConnectAttrW(HDBC hdbc,
SQLINTEGER fAttribute,
PTR rgbValue,
SQLINTEGER cbValue)
{
RETCODE ret;
mylog("[SQLSetConnectAttrW]");
CC_clear_error((ConnectionClass *) hdbc);
ret = PGAPI_SetConnectAttr(hdbc, fAttribute, rgbValue,
cbValue);
return ret;
}
/* new function */
RETCODE SQL_API
SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber,
SQLSMALLINT FieldIdentifier, PTR Value,
SQLINTEGER BufferLength)
{
RETCODE ret;
UInt4 vallen;
char *uval = NULL;
BOOL val_alloced = FALSE;
mylog("[SQLSetDescFieldW]");
if (BufferLength > 0)
{
switch (FieldIdentifier)
{
case SQL_DESC_BASE_COLUMN_NAME:
case SQL_DESC_BASE_TABLE_NAME:
case SQL_DESC_CATALOG_NAME:
case SQL_DESC_LABEL:
case SQL_DESC_LITERAL_PREFIX:
case SQL_DESC_LITERAL_SUFFIX:
case SQL_DESC_LOCAL_TYPE_NAME:
case SQL_DESC_NAME:
case SQL_DESC_SCHEMA_NAME:
case SQL_DESC_TABLE_NAME:
case SQL_DESC_TYPE_NAME:
uval = ucs2_to_utf8(Value, BufferLength / 2, &vallen);
val_alloced = TRUE;
break;
}
}
if (!val_alloced)
{
uval = Value;
vallen = BufferLength;
}
ret = PGAPI_SetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
uval, vallen);
if (val_alloced)
free(uval);
return ret;
}
RETCODE SQL_API
SQLGetDescFieldW(SQLHDESC hdesc, SQLSMALLINT iRecord, SQLSMALLINT iField,
PTR rgbValue, SQLINTEGER cbValueMax,
SQLINTEGER *pcbValue)
{
RETCODE ret;
BOOL alloced = FALSE;
SQLINTEGER blen, bMax, *pcbV;
char *rgbV = NULL;
mylog("[SQLGetDescFieldW]");
switch (iField)
{
case SQL_DESC_BASE_COLUMN_NAME:
case SQL_DESC_BASE_TABLE_NAME:
case SQL_DESC_CATALOG_NAME:
case SQL_DESC_LABEL:
case SQL_DESC_LITERAL_PREFIX:
case SQL_DESC_LITERAL_SUFFIX:
case SQL_DESC_LOCAL_TYPE_NAME:
case SQL_DESC_NAME:
case SQL_DESC_SCHEMA_NAME:
case SQL_DESC_TABLE_NAME:
case SQL_DESC_TYPE_NAME:
alloced = TRUE;
bMax = cbValueMax * 3 / 2;
rgbV = malloc(bMax + 1);
pcbV = &blen;
break;
default:
rgbV = rgbValue;
bMax = cbValueMax;
pcbV = pcbValue;
break;
}
ret = PGAPI_GetDescField(hdesc, iRecord, iField, rgbV, bMax, pcbV);
if (alloced)
{
blen = utf8_to_ucs2(rgbV, blen, (SQLWCHAR *) rgbValue, cbValueMax / 2);
if (SQL_SUCCESS == ret && blen * 2 > cbValueMax)
{
ret = SQL_SUCCESS_WITH_INFO;
Desc_set_error(hdesc, STMT_TRUNCATED, "The buffer was too small for the rgbDesc.");
}
if (pcbValue)
*pcbValue = blen * 2;
free(rgbV);
}
return ret;
}
RETCODE SQL_API SQLGetDiagRecW(SWORD fHandleType,
SQLHANDLE handle,
SQLSMALLINT iRecord,
SQLWCHAR *szSqlState,
SQLINTEGER *pfNativeError,
SQLWCHAR *szErrorMsg,
SQLSMALLINT cbErrorMsgMax,
SQLSMALLINT *pcbErrorMsg)
{
RETCODE ret;
SWORD buflen, tlen;
char *qstr = NULL, *mtxt = NULL;
mylog("[SQLGetDiagRecW]");
if (szSqlState)
qstr = malloc(8);
buflen = 0;
if (szErrorMsg && cbErrorMsgMax > 0)
{
buflen = cbErrorMsgMax;
mtxt = malloc(buflen);
}
ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qstr,
pfNativeError, mtxt, buflen, &tlen);
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
{
if (qstr)
utf8_to_ucs2(qstr, strlen(qstr), szSqlState, 6);
if (mtxt && tlen <= cbErrorMsgMax)
{
tlen = utf8_to_ucs2(mtxt, tlen, szErrorMsg, cbErrorMsgMax);
if (tlen >= cbErrorMsgMax)
ret = SQL_SUCCESS_WITH_INFO;
}
if (pcbErrorMsg)
*pcbErrorMsg = tlen;
}
if (qstr);
free(qstr);
if (mtxt)
free(mtxt);
return ret;
}
RETCODE SQL_API SQLColAttributeW(
HSTMT hstmt,
SQLUSMALLINT icol,
SQLUSMALLINT fDescType,
PTR rgbDesc,
SQLSMALLINT cbDescMax,
SQLSMALLINT *pcbDesc,
SQLINTEGER *pfDesc)
{
RETCODE ret;
BOOL alloced = FALSE;
SQLSMALLINT *rgbL, blen, bMax;
char *rgbD = NULL;
mylog("[SQLColAttributeW]");
SC_clear_error((StatementClass *) hstmt);
switch (fDescType)
{
case SQL_DESC_BASE_COLUMN_NAME:
case SQL_DESC_BASE_TABLE_NAME:
case SQL_DESC_CATALOG_NAME:
case SQL_DESC_LABEL:
case SQL_DESC_LITERAL_PREFIX:
case SQL_DESC_LITERAL_SUFFIX:
case SQL_DESC_LOCAL_TYPE_NAME:
case SQL_DESC_NAME:
case SQL_DESC_SCHEMA_NAME:
case SQL_DESC_TABLE_NAME:
case SQL_DESC_TYPE_NAME:
case SQL_COLUMN_NAME:
alloced = TRUE;
bMax = cbDescMax * 3 / 2;
rgbD = malloc(bMax + 1);
rgbL = &blen;
break;
default:
rgbD = rgbDesc;
bMax = cbDescMax;
rgbL = pcbDesc;
break;
}
ret = PGAPI_ColAttributes(hstmt, icol, fDescType, rgbD,
bMax, rgbL, pfDesc);
if (alloced)
{
blen = utf8_to_ucs2(rgbD, blen, (SQLWCHAR *) rgbDesc, cbDescMax / 2);
if (SQL_SUCCESS == ret && blen * 2 > cbDescMax)
{
StatementClass *stmt = (StatementClass *) hstmt;
ret = SQL_SUCCESS_WITH_INFO;
stmt->errornumber = STMT_TRUNCATED;
stmt->errormsg = "The buffer was too small for the rgbDesc.";
}
if (pcbDesc)
*pcbDesc = blen * 2;
free(rgbD);
}
return ret;
}

View File

@ -1,626 +0,0 @@
/*-------
* Module: odbcapiw.c
*
* Description: This module contains UNICODE routines
*
* Classes: n/a
*
* API functions: SQLColumnPrivilegesW, SQLColumnsW,
SQLConnectW, SQLDataSourcesW, SQLDescribeColW,
SQLDriverConnectW, SQLExecDirectW,
SQLForeignKeysW,
SQLGetCursorNameW, SQLGetInfoW, SQLNativeSqlW,
SQLPrepareW, SQLPrimaryKeysW, SQLProcedureColumnsW,
SQLProceduresW, SQLSetCursorNameW,
SQLSpecialColumnsW, SQLStatisticsW, SQLTablesW,
SQLTablePrivilegesW, SQLGetTypeInfoW
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "pgapifunc.h"
#include "connection.h"
#include "statement.h"
RETCODE SQL_API SQLColumnsW(HSTMT StatementHandle,
SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLWCHAR *TableName, SQLSMALLINT NameLength3,
SQLWCHAR *ColumnName, SQLSMALLINT NameLength4)
{
RETCODE ret;
char *ctName, *scName, *tbName, *clName;
UInt4 nmlen1, nmlen2, nmlen3, nmlen4;
mylog("[SQLColumnsW]");
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4);
ret = PGAPI_Columns(StatementHandle, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
clName, (SWORD) nmlen4, 0);
if (ctName)
free(ctName);
if (scName);
free(scName);
if (tbName)
free(tbName);
if (clName);
free(clName);
return ret;
}
RETCODE SQL_API SQLConnectW(HDBC ConnectionHandle,
SQLWCHAR *ServerName, SQLSMALLINT NameLength1,
SQLWCHAR *UserName, SQLSMALLINT NameLength2,
SQLWCHAR *Authentication, SQLSMALLINT NameLength3)
{
char *svName, *usName, *auth;
UInt4 nmlen1, nmlen2, nmlen3;
RETCODE ret;
mylog("[SQLConnectW]");
((ConnectionClass *) ConnectionHandle)->unicode = 1;
svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1);
usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2);
auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3);
ret = PGAPI_Connect(ConnectionHandle, svName, (SWORD) nmlen1,
usName, (SWORD) nmlen2, auth, (SWORD) nmlen3);
if (svName);
free(svName);
if (usName);
free(usName);
if (auth);
free(auth);
return ret;
}
RETCODE SQL_API SQLDriverConnectW(HDBC hdbc,
HWND hwnd,
SQLWCHAR *szConnStrIn,
SWORD cbConnStrIn,
SQLWCHAR *szConnStrOut,
SWORD cbConnStrOutMax,
SWORD FAR *pcbConnStrOut,
UWORD fDriverCompletion)
{
char *szIn, *szOut;
UInt4 inlen, obuflen;
SWORD olen;
RETCODE ret;
mylog("[SQLDriverConnectW]");
((ConnectionClass *) hdbc)->unicode = 1;
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen);
obuflen = cbConnStrOutMax + 1;
szOut = malloc(obuflen);
ret = PGAPI_DriverConnect(hdbc, hwnd, szIn, (SWORD) inlen,
szOut, cbConnStrOutMax, &olen, fDriverCompletion);
if (ret != SQL_ERROR)
{
UInt4 outlen = utf8_to_ucs2(szOut, olen, szConnStrOut, cbConnStrOutMax);
if (pcbConnStrOut)
*pcbConnStrOut = outlen;
}
free(szOut);
if (szIn);
free(szIn);
return ret;
}
RETCODE SQL_API SQLBrowseConnectW(
HDBC hdbc,
SQLWCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLWCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut)
{
char *szIn, *szOut;
UInt4 inlen, obuflen;
SWORD olen;
RETCODE ret;
mylog("[SQLBrowseConnectW]");
((ConnectionClass *) hdbc)->unicode = 1;
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen);
obuflen = cbConnStrOutMax + 1;
szOut = malloc(obuflen);
ret = PGAPI_BrowseConnect(hdbc, szIn, (SWORD) inlen,
szOut, cbConnStrOutMax, &olen);
if (ret != SQL_ERROR)
{
UInt4 outlen = utf8_to_ucs2(szOut, olen, szConnStrOut, cbConnStrOutMax);
if (pcbConnStrOut)
*pcbConnStrOut = outlen;
}
free(szOut);
if (szIn);
free(szIn);
return ret;
}
RETCODE SQL_API SQLDataSourcesW(HENV EnvironmentHandle,
SQLUSMALLINT Direction, SQLWCHAR *ServerName,
SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
SQLWCHAR *Description, SQLSMALLINT BufferLength2,
SQLSMALLINT *NameLength2)
{
mylog("[SQLDataSourcesW]");
/*
return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
BufferLength1, NameLength1, Description, BufferLength2,
NameLength2);
*/
return SQL_ERROR;
}
RETCODE SQL_API SQLDescribeColW(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLWCHAR *ColumnName,
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
RETCODE ret;
SWORD buflen, nmlen;
char *clName;
mylog("[SQLDescribeColW]");
buflen = BufferLength * 3 + 1;
clName = malloc(buflen);
ret = PGAPI_DescribeCol(StatementHandle, ColumnNumber,
clName, buflen, &nmlen, DataType, ColumnSize,
DecimalDigits, Nullable);
if (ret == SQL_SUCCESS)
{
UInt4 nmcount = utf8_to_ucs2(clName, nmlen, ColumnName, BufferLength);
if (nmcount > (UInt4) BufferLength)
{
StatementClass *stmt = (StatementClass *) StatementHandle;
ret = SQL_SUCCESS_WITH_INFO;
stmt->errornumber = STMT_TRUNCATED;
stmt->errormsg = "Column name too large";
}
if (NameLength)
*NameLength = nmcount;
}
free(clName);
return ret;
}
RETCODE SQL_API SQLExecDirectW(HSTMT StatementHandle,
SQLWCHAR *StatementText, SQLINTEGER TextLength)
{
RETCODE ret;
char *stxt;
UInt4 slen;
mylog("[SQLExecDirectW]");
stxt = ucs2_to_utf8(StatementText, TextLength, &slen);
ret = PGAPI_ExecDirect(StatementHandle, stxt, slen);
if (stxt);
free(stxt);
return ret;
}
RETCODE SQL_API SQLGetCursorNameW(HSTMT StatementHandle,
SQLWCHAR *CursorName, SQLSMALLINT BufferLength,
SQLSMALLINT *NameLength)
{
RETCODE ret;
char *crName;
SWORD clen, buflen;
mylog("[SQLGetCursorNameW]");
buflen = BufferLength * 3 + 1;
crName = malloc(buflen);
ret = PGAPI_GetCursorName(StatementHandle, crName, buflen, &clen);
if (ret == SQL_SUCCESS)
{
UInt4 nmcount = utf8_to_ucs2(crName, (Int4) clen, CursorName, BufferLength);
if (nmcount > (UInt4) BufferLength)
{
StatementClass *stmt = (StatementClass *) StatementHandle;
ret = SQL_SUCCESS_WITH_INFO;
stmt->errornumber = STMT_TRUNCATED;
stmt->errormsg = "Cursor name too large";
}
if (NameLength)
*NameLength = utf8_to_ucs2(crName, (Int4) clen, CursorName, BufferLength);
}
free(crName);
return ret;
}
RETCODE SQL_API SQLGetInfoW(HDBC ConnectionHandle,
SQLUSMALLINT InfoType, PTR InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
RETCODE ret;
conn->unicode = 1;
CC_clear_error(conn);
#if (ODBCVER >= 0x0300)
mylog("[SQLGetInfoW(30)]");
if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength)) == SQL_ERROR)
{
if (conn->driver_version >= 0x0300)
{
CC_clear_error(conn);
ret = PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength);
}
}
if (SQL_ERROR == ret)
CC_log_error("SQLGetInfoW(30)", "", conn);
#else
mylog("[SQLGetInfoW]");
ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength);
if (SQL_ERROR == ret)
CC_log_error("SQLGetInfoW", "", conn);
#endif
return ret;
}
RETCODE SQL_API SQLPrepareW(HSTMT StatementHandle,
SQLWCHAR *StatementText, SQLINTEGER TextLength)
{
RETCODE ret;
char *stxt;
UInt4 slen;
mylog("[SQLPrepareW]");
stxt = ucs2_to_utf8(StatementText, TextLength, &slen);
ret = PGAPI_Prepare(StatementHandle, stxt, slen);
if (stxt);
free(stxt);
return ret;
}
RETCODE SQL_API SQLSetCursorNameW(HSTMT StatementHandle,
SQLWCHAR *CursorName, SQLSMALLINT NameLength)
{
RETCODE ret;
char *crName;
UInt4 nlen;
mylog("[SQLSetCursorNameW]");
crName = ucs2_to_utf8(CursorName, NameLength, &nlen);
ret = PGAPI_SetCursorName(StatementHandle, crName, (SWORD) nlen);
if (crName);
free(crName);
return ret;
}
RETCODE SQL_API SQLSpecialColumnsW(HSTMT StatementHandle,
SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
SQLSMALLINT NameLength2, SQLWCHAR *TableName,
SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
SQLUSMALLINT Nullable)
{
RETCODE ret;
char *ctName, *scName, *tbName;
UInt4 nmlen1, nmlen2, nmlen3;
mylog("[SQLSpecialColumnsW]");
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
(SWORD) nmlen1, scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
Scope, Nullable);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
return ret;
}
RETCODE SQL_API SQLStatisticsW(HSTMT StatementHandle,
SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLWCHAR *TableName, SQLSMALLINT NameLength3,
SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
RETCODE ret;
char *ctName, *scName, *tbName;
UInt4 nmlen1, nmlen2, nmlen3;
mylog("[SQLStatisticsW]");
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
return PGAPI_Statistics(StatementHandle, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3, Unique,
Reserved);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
return ret;
}
RETCODE SQL_API SQLTablesW(HSTMT StatementHandle,
SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLWCHAR *TableName, SQLSMALLINT NameLength3,
SQLWCHAR *TableType, SQLSMALLINT NameLength4)
{
RETCODE ret;
char *ctName, *scName, *tbName, *tbType;
UInt4 nmlen1, nmlen2, nmlen3, nmlen4;
mylog("[SQLTablesW]");
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4);
return PGAPI_Tables(StatementHandle, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
tbType, (SWORD) nmlen4);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
if (tbType);
free(tbType);
return ret;
}
RETCODE SQL_API SQLColumnPrivilegesW(
HSTMT hstmt,
SQLWCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLWCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLWCHAR *szTableName,
SQLSMALLINT cbTableName,
SQLWCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
RETCODE ret;
char *ctName, *scName, *tbName, *clName;
UInt4 nmlen1, nmlen2, nmlen3, nmlen4;
mylog("[SQLColumnPrivilegesW]");
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4);
ret = PGAPI_ColumnPrivileges(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
clName, (SWORD) nmlen4);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
if (clName);
free(clName);
return ret;
}
RETCODE SQL_API SQLForeignKeysW(
HSTMT hstmt,
SQLWCHAR *szPkCatalogName,
SQLSMALLINT cbPkCatalogName,
SQLWCHAR *szPkSchemaName,
SQLSMALLINT cbPkSchemaName,
SQLWCHAR *szPkTableName,
SQLSMALLINT cbPkTableName,
SQLWCHAR *szFkCatalogName,
SQLSMALLINT cbFkCatalogName,
SQLWCHAR *szFkSchemaName,
SQLSMALLINT cbFkSchemaName,
SQLWCHAR *szFkTableName,
SQLSMALLINT cbFkTableName)
{
RETCODE ret;
char *ctName, *scName, *tbName, *fkctName, *fkscName, *fktbName;
UInt4 nmlen1, nmlen2, nmlen3, nmlen4, nmlen5, nmlen6;
mylog("[SQLForeignKeysW]");
ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1);
scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2);
tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3);
fkctName = ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4);
fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5);
fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6);
ret = PGAPI_ForeignKeys(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
fkctName, (SWORD) nmlen4, fkscName, (SWORD) nmlen5,
fktbName, (SWORD) nmlen6);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
if (fkctName);
free(fkctName);
if (fkscName);
free(fkscName);
if (fktbName);
free(fktbName);
return ret;
}
RETCODE SQL_API SQLNativeSqlW(
HDBC hdbc,
SQLWCHAR *szSqlStrIn,
SQLINTEGER cbSqlStrIn,
SQLWCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax,
SQLINTEGER *pcbSqlStr)
{
RETCODE ret;
char *szIn, *szOut;
UInt4 slen;
SQLINTEGER buflen, olen;
mylog("[SQLNativeSqlW]");
((ConnectionClass *) hdbc)->unicode = 1;
szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen);
buflen = 3 * cbSqlStrMax + 1;
szOut = malloc(buflen);
ret = PGAPI_NativeSql(hdbc, szIn, (SQLINTEGER) slen,
szOut, buflen, &olen);
if (szIn);
free(szIn);
if (ret == SQL_SUCCESS)
{
UInt4 szcount = utf8_to_ucs2(szOut, olen, szSqlStr, cbSqlStrMax);
if (szcount > (UInt4) cbSqlStrMax)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
ret = SQL_SUCCESS_WITH_INFO;
conn->errornumber = CONN_TRUNCATED;
conn->errormsg = "Sql string too large";
}
if (pcbSqlStr)
*pcbSqlStr = szcount;
}
free(szOut);
return ret;
}
RETCODE SQL_API SQLPrimaryKeysW(
HSTMT hstmt,
SQLWCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLWCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLWCHAR *szTableName,
SQLSMALLINT cbTableName)
{
RETCODE ret;
char *ctName, *scName, *tbName;
UInt4 nmlen1, nmlen2, nmlen3;
mylog("[SQLPrimaryKeysW]");
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
return PGAPI_PrimaryKeys(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
return ret;
}
RETCODE SQL_API SQLProcedureColumnsW(
HSTMT hstmt,
SQLWCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLWCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLWCHAR *szProcName,
SQLSMALLINT cbProcName,
SQLWCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
RETCODE ret;
char *ctName, *scName, *prName, *clName;
UInt4 nmlen1, nmlen2, nmlen3, nmlen4;
mylog("[SQLProcedureColumnsW]");
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4);
ret = PGAPI_ProcedureColumns(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, prName, (SWORD) nmlen3,
clName, (SWORD) nmlen4);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (prName);
free(prName);
if (clName);
free(clName);
return ret;
}
RETCODE SQL_API SQLProceduresW(
HSTMT hstmt,
SQLWCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLWCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLWCHAR *szProcName,
SQLSMALLINT cbProcName)
{
RETCODE ret;
char *ctName, *scName, *prName;
UInt4 nmlen1, nmlen2, nmlen3;
mylog("[SQLProceduresW]");
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3);
ret = PGAPI_Procedures(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, prName, (SWORD) nmlen3);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (prName);
free(prName);
return ret;
}
RETCODE SQL_API SQLTablePrivilegesW(
HSTMT hstmt,
SQLWCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLWCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLWCHAR *szTableName,
SQLSMALLINT cbTableName)
{
RETCODE ret;
char *ctName, *scName, *tbName;
UInt4 nmlen1, nmlen2, nmlen3;
mylog("[SQLTablePrivilegesW]");
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
ret = PGAPI_TablePrivileges(hstmt, ctName, (SWORD) nmlen1,
scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3, 0);
if (ctName);
free(ctName);
if (scName);
free(scName);
if (tbName);
free(tbName);
return ret;
}
RETCODE SQL_API SQLGetTypeInfoW(
SQLHSTMT StatementHandle,
SQLSMALLINT DataType)
{
return PGAPI_GetTypeInfo(StatementHandle, DataType);
}

View File

@ -1,3 +0,0 @@
[PostgreSQL]
Debug = 0
CommLog = 1

View File

@ -1,728 +0,0 @@
/*--------
* Module: options.c
*
* Description: This module contains routines for getting/setting
* connection and statement options.
*
* Classes: n/a
*
* API functions: SQLSetConnectOption, SQLSetStmtOption, SQLGetConnectOption,
* SQLGetStmtOption
*
* Comments: See "notice.txt" for copyright and license information.
*--------
*/
#include "psqlodbc.h"
#include <string.h>
#include "environ.h"
#include "connection.h"
#include "statement.h"
#include "qresult.h"
#include "pgapifunc.h"
RETCODE set_statement_option(ConnectionClass *conn,
StatementClass *stmt,
UWORD fOption,
UDWORD vParam);
RETCODE
set_statement_option(ConnectionClass *conn,
StatementClass *stmt,
UWORD fOption,
UDWORD vParam)
{
static char *func = "set_statement_option";
char changed = FALSE;
ConnInfo *ci = NULL;
UDWORD setval;
if (conn)
ci = &(conn->connInfo);
else if (stmt)
ci = &(SC_get_conn(stmt)->connInfo);
switch (fOption)
{
case SQL_ASYNC_ENABLE: /* ignored */
break;
case SQL_BIND_TYPE:
/* now support multi-column and multi-row binding */
if (conn)
conn->ardOptions.bind_size = vParam;
if (stmt)
SC_get_ARD(stmt)->bind_size = vParam;
break;
case SQL_CONCURRENCY:
/*
* positioned update isn't supported so cursor concurrency is
* read-only
*/
mylog("SetStmtOption(): SQL_CONCURRENCY = %d ", vParam);
setval = SQL_CONCUR_READ_ONLY;
if (SQL_CONCUR_READ_ONLY == vParam)
;
if (ci->drivers.lie)
setval = vParam;
else if (ci->updatable_cursors)
setval = SQL_CONCUR_ROWVER;
if (conn)
conn->stmtOptions.scroll_concurrency = setval;
else if (stmt)
stmt->options.scroll_concurrency = setval;
if (setval != vParam)
changed = TRUE;
mylog("-> %d\n", setval);
break;
case SQL_CURSOR_TYPE:
/*
* if declare/fetch, then type can only be forward. otherwise,
* it can only be forward or static.
*/
mylog("SetStmtOption(): SQL_CURSOR_TYPE = %d ", vParam);
setval = SQL_CURSOR_FORWARD_ONLY;
if (ci->drivers.lie)
setval = vParam;
else if (ci->drivers.use_declarefetch)
;
else if (SQL_CURSOR_STATIC == vParam)
setval = vParam;
else if (SQL_CURSOR_KEYSET_DRIVEN == vParam)
{
if (ci->updatable_cursors)
setval = vParam;
else
setval = SQL_CURSOR_STATIC; /* at least scrollable */
}
if (conn)
conn->stmtOptions.cursor_type = setval;
else if (stmt)
stmt->options.cursor_type = setval;
if (setval != vParam)
changed = TRUE;
mylog("-> %d\n", setval);
break;
case SQL_KEYSET_SIZE: /* ignored, but saved and returned */
mylog("SetStmtOption(): SQL_KEYSET_SIZE, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.keyset_size = vParam;
if (stmt)
stmt->options.keyset_size = vParam;
break;
/*-------
* if (ci->drivers.lie)
* stmt->keyset_size = vParam;
* else
* {
* stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
* stmt->errormsg = "Driver does not support keyset size option";
* SC_log_error(func, "", stmt);
* return SQL_ERROR;
* }
*-------
*/
case SQL_MAX_LENGTH: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.maxLength = vParam;
if (stmt)
stmt->options.maxLength = vParam;
break;
case SQL_MAX_ROWS: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.maxRows = vParam;
if (stmt)
stmt->options.maxRows = vParam;
break;
case SQL_NOSCAN: /* ignored */
mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam);
break;
case SQL_QUERY_TIMEOUT: /* ignored */
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
/* "0" returned in SQLGetStmtOption */
break;
case SQL_RETRIEVE_DATA:
mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.retrieve_data = vParam;
if (stmt)
stmt->options.retrieve_data = vParam;
break;
case SQL_ROWSET_SIZE:
mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", vParam);
/*
* Save old rowset size for SQLExtendedFetch purposes If the
* rowset_size is being changed since the last call to fetch
* rows.
*/
if (stmt && stmt->save_rowset_size <= 0 && stmt->last_fetch_count > 0)
stmt->save_rowset_size = SC_get_ARD(stmt)->rowset_size;
if (vParam < 1)
{
vParam = 1;
changed = TRUE;
}
if (conn)
conn->ardOptions.rowset_size = vParam;
if (stmt)
SC_get_ARD(stmt)->rowset_size = vParam;
break;
case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */
if (stmt)
{
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
stmt->errormsg = "Simulated positioned update/delete not supported. Use the cursor library.";
SC_log_error(func, "", stmt);
}
if (conn)
{
conn->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
conn->errormsg = "Simulated positioned update/delete not supported. Use the cursor library.";
CC_log_error(func, "", conn);
}
return SQL_ERROR;
case SQL_USE_BOOKMARKS:
if (stmt)
stmt->options.use_bookmarks = vParam;
if (conn)
conn->stmtOptions.use_bookmarks = vParam;
break;
case 1227:
case 1228:
if (stmt)
{
stmt->errornumber = STMT_OPTION_NOT_FOR_THE_DRIVER;
stmt->errormsg = "The option may be for MS SQL Server(Set)";
}
else if (conn)
{
conn->errornumber = STMT_OPTION_NOT_FOR_THE_DRIVER;
conn->errormsg = "The option may be for MS SQL Server(Set)";
}
return SQL_ERROR;
default:
{
char option[64];
if (stmt)
{
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
stmt->errormsg = "Unknown statement option (Set)";
sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam);
SC_log_error(func, option, stmt);
}
if (conn)
{
conn->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
conn->errormsg = "Unknown statement option (Set)";
sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam);
CC_log_error(func, option, conn);
}
return SQL_ERROR;
}
}
if (changed)
{
if (stmt)
{
stmt->errormsg = "Requested value changed.";
stmt->errornumber = STMT_OPTION_VALUE_CHANGED;
}
if (conn)
{
conn->errormsg = "Requested value changed.";
conn->errornumber = STMT_OPTION_VALUE_CHANGED;
}
return SQL_SUCCESS_WITH_INFO;
}
else
return SQL_SUCCESS;
}
/* Implements only SQL_AUTOCOMMIT */
RETCODE SQL_API
PGAPI_SetConnectOption(
HDBC hdbc,
UWORD fOption,
UDWORD vParam)
{
static char *func = "PGAPI_SetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
char changed = FALSE;
RETCODE retval;
int i;
mylog("%s: entering fOption = %d vParam = %d\n", func, fOption, vParam);
if (!conn)
{
CC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
switch (fOption)
{
/*
* Statement Options (apply to all stmts on the connection and
* become defaults for new stmts)
*/
case SQL_ASYNC_ENABLE:
case SQL_BIND_TYPE:
case SQL_CONCURRENCY:
case SQL_CURSOR_TYPE:
case SQL_KEYSET_SIZE:
case SQL_MAX_LENGTH:
case SQL_MAX_ROWS:
case SQL_NOSCAN:
case SQL_QUERY_TIMEOUT:
case SQL_RETRIEVE_DATA:
case SQL_ROWSET_SIZE:
case SQL_SIMULATE_CURSOR:
case SQL_USE_BOOKMARKS:
/* Affect all current Statements */
for (i = 0; i < conn->num_stmts; i++)
{
if (conn->stmts[i])
set_statement_option(NULL, conn->stmts[i], fOption, vParam);
}
/*
* Become the default for all future statements on this
* connection
*/
retval = set_statement_option(conn, NULL, fOption, vParam);
if (retval == SQL_SUCCESS_WITH_INFO)
changed = TRUE;
else if (retval == SQL_ERROR)
return SQL_ERROR;
break;
/*
* Connection Options
*/
case SQL_ACCESS_MODE: /* ignored */
break;
case SQL_AUTOCOMMIT:
if (vParam == SQL_AUTOCOMMIT_ON && CC_is_in_autocommit(conn))
break;
else if (vParam == SQL_AUTOCOMMIT_OFF && !CC_is_in_autocommit(conn))
break;
if (CC_is_in_trans(conn))
CC_commit(conn);
mylog("PGAPI_SetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
switch (vParam)
{
case SQL_AUTOCOMMIT_OFF:
CC_set_autocommit_off(conn);
break;
case SQL_AUTOCOMMIT_ON:
CC_set_autocommit_on(conn);
break;
default:
conn->errormsg = "Illegal parameter value for SQL_AUTOCOMMIT";
conn->errornumber = CONN_INVALID_ARGUMENT_NO;
CC_log_error(func, "", conn);
return SQL_ERROR;
}
break;
case SQL_CURRENT_QUALIFIER: /* ignored */
break;
case SQL_LOGIN_TIMEOUT: /* ignored */
break;
case SQL_PACKET_SIZE: /* ignored */
break;
case SQL_QUIET_MODE: /* ignored */
break;
case SQL_TXN_ISOLATION: /* ignored */
retval = SQL_SUCCESS;
if (CC_is_in_trans(conn))
{
conn->errormsg = "Cannot switch isolation level while a transaction is in progress";
conn->errornumber = CONN_TRANSACT_IN_PROGRES;
CC_log_error(func, "", conn);
return SQL_ERROR;
}
if (conn->isolation == vParam)
break;
switch (vParam)
{
case SQL_TXN_SERIALIZABLE:
if (PG_VERSION_GE(conn, 6.5) &&
PG_VERSION_LE(conn, 7.0))
retval = SQL_ERROR;
break;
case SQL_TXN_READ_COMMITTED:
if (PG_VERSION_LT(conn, 6.5))
retval = SQL_ERROR;
break;
default:
retval = SQL_ERROR;
}
if (SQL_ERROR == retval)
{
conn->errornumber = CONN_INVALID_ARGUMENT_NO;
conn->errormsg = "Illegal parameter value for SQL_TXN_ISOLATION";
CC_log_error(func, "", conn);
return SQL_ERROR;
}
else
{
char *query;
QResultClass *res;
if (vParam == SQL_TXN_SERIALIZABLE)
query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE";
else
query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED";
res = CC_send_query(conn, query, NULL, 0);
if (!res || !QR_command_maybe_successful(res))
retval = SQL_ERROR;
else
conn->isolation = vParam;
if (res)
QR_Destructor(res);
if (SQL_ERROR == retval)
{
conn->errornumber = STMT_EXEC_ERROR;
conn->errormsg = "ISOLATION change request to the server error";
return SQL_ERROR;
}
}
break;
/* These options should be handled by driver manager */
case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE:
case SQL_TRANSLATE_DLL:
case SQL_TRANSLATE_OPTION:
CC_log_error(func, "This connect option (Set) is only used by the Driver Manager", conn);
break;
default:
{
char option[64];
conn->errormsg = "Unknown connect option (Set)";
conn->errornumber = CONN_UNSUPPORTED_OPTION;
sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam);
if (fOption == 30002 && vParam)
{
int cmp;
#ifdef UNICODE_SUPPORT
char *asPara;
if (conn->unicode)
{
asPara = ucs2_to_utf8((SQLWCHAR *) vParam, -1, NULL);
cmp = strcmp(asPara, "Microsoft Jet");
free(asPara);
}
else
#endif /* UNICODE_SUPPORT */
cmp = strncmp((char *) vParam, "Microsoft Jet", 13);
if (0 == cmp)
{
mylog("Microsoft Jet !!!!\n");
conn->errornumber = 0;
conn->ms_jet = 1;
return SQL_SUCCESS;
}
}
CC_log_error(func, option, conn);
return SQL_ERROR;
}
}
if (changed)
{
conn->errornumber = CONN_OPTION_VALUE_CHANGED;
conn->errormsg = "Requested value changed.";
return SQL_SUCCESS_WITH_INFO;
}
else
return SQL_SUCCESS;
}
/* This function just can tell you whether you are in Autcommit mode or not */
RETCODE SQL_API
PGAPI_GetConnectOption(
HDBC hdbc,
UWORD fOption,
PTR pvParam)
{
static char *func = "PGAPI_GetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci = &(conn->connInfo);
mylog("%s: entering...\n", func);
if (!conn)
{
CC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
switch (fOption)
{
case SQL_ACCESS_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = SQL_MODE_READ_WRITE;
break;
case SQL_AUTOCOMMIT:
*((UDWORD *) pvParam) = (UDWORD) (CC_is_in_autocommit(conn) ?
SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
break;
case SQL_CURRENT_QUALIFIER: /* don't use qualifiers */
if (pvParam)
((char *) pvParam)[0] = ((char *) pvParam)[1] = '\0';
break;
case SQL_LOGIN_TIMEOUT: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = 0;
break;
case SQL_PACKET_SIZE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = ci->drivers.socket_buffersize;
break;
case SQL_QUIET_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = (UDWORD) NULL;
break;
case SQL_TXN_ISOLATION:
*((UDWORD *) pvParam) = conn->isolation;
break;
/* These options should be handled by driver manager */
case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE:
case SQL_TRANSLATE_DLL:
case SQL_TRANSLATE_OPTION:
CC_log_error(func, "This connect option (Get) is only used by the Driver Manager", conn);
break;
default:
{
char option[64];
conn->errormsg = "Unknown connect option (Get)";
conn->errornumber = CONN_UNSUPPORTED_OPTION;
sprintf(option, "fOption=%d", fOption);
CC_log_error(func, option, conn);
return SQL_ERROR;
break;
}
}
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_SetStmtOption(
HSTMT hstmt,
UWORD fOption,
UDWORD vParam)
{
static char *func = "PGAPI_SetStmtOption";
StatementClass *stmt = (StatementClass *) hstmt;
mylog("%s: entering...\n", func);
/*
* Though we could fake Access out by just returning SQL_SUCCESS all
* the time, but it tries to set a huge value for SQL_MAX_LENGTH and
* expects the driver to reduce it to the real value.
*/
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
return set_statement_option(NULL, stmt, fOption, vParam);
}
RETCODE SQL_API
PGAPI_GetStmtOption(
HSTMT hstmt,
UWORD fOption,
PTR pvParam)
{
static char *func = "PGAPI_GetStmtOption";
StatementClass *stmt = (StatementClass *) hstmt;
QResultClass *res;
ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
mylog("%s: entering...\n", func);
/*
* thought we could fake Access out by just returning SQL_SUCCESS all
* the time, but it tries to set a huge value for SQL_MAX_LENGTH and
* expects the driver to reduce it to the real value
*/
if (!stmt)
{
SC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
switch (fOption)
{
case SQL_GET_BOOKMARK:
case SQL_ROW_NUMBER:
res = SC_get_Curres(stmt);
if (stmt->manual_result || !ci->drivers.use_declarefetch)
{
/* make sure we're positioned on a valid row */
if ((stmt->currTuple < 0) ||
(stmt->currTuple >= QR_get_num_backend_tuples(res)))
{
stmt->errormsg = "Not positioned on a valid row.";
stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
}
else
{
if (stmt->currTuple == -1 || !res || !res->tupleField)
{
stmt->errormsg = "Not positioned on a valid row.";
stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
}
if (fOption == SQL_GET_BOOKMARK && stmt->options.use_bookmarks == SQL_UB_OFF)
{
stmt->errormsg = "Operation invalid because use bookmarks not enabled.";
stmt->errornumber = STMT_OPERATION_INVALID;
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
*((UDWORD *) pvParam) = SC_get_bookmark(stmt);
break;
case SQL_ASYNC_ENABLE: /* NOT SUPPORTED */
*((SDWORD *) pvParam) = SQL_ASYNC_ENABLE_OFF;
break;
case SQL_BIND_TYPE:
*((SDWORD *) pvParam) = SC_get_ARD(stmt)->bind_size;
break;
case SQL_CONCURRENCY: /* NOT REALLY SUPPORTED */
mylog("GetStmtOption(): SQL_CONCURRENCY %d\n", stmt->options.scroll_concurrency);
*((SDWORD *) pvParam) = stmt->options.scroll_concurrency;
break;
case SQL_CURSOR_TYPE: /* PARTIAL SUPPORT */
mylog("GetStmtOption(): SQL_CURSOR_TYPE %d\n", stmt->options.cursor_type);
*((SDWORD *) pvParam) = stmt->options.cursor_type;
break;
case SQL_KEYSET_SIZE: /* NOT SUPPORTED, but saved */
mylog("GetStmtOption(): SQL_KEYSET_SIZE\n");
*((SDWORD *) pvParam) = stmt->options.keyset_size;
break;
case SQL_MAX_LENGTH: /* NOT SUPPORTED, but saved */
*((SDWORD *) pvParam) = stmt->options.maxLength;
break;
case SQL_MAX_ROWS: /* NOT SUPPORTED, but saved */
*((SDWORD *) pvParam) = stmt->options.maxRows;
mylog("GetSmtOption: MAX_ROWS, returning %d\n", stmt->options.maxRows);
break;
case SQL_NOSCAN: /* NOT SUPPORTED */
*((SDWORD *) pvParam) = SQL_NOSCAN_ON;
break;
case SQL_QUERY_TIMEOUT: /* NOT SUPPORTED */
*((SDWORD *) pvParam) = 0;
break;
case SQL_RETRIEVE_DATA:
*((SDWORD *) pvParam) = stmt->options.retrieve_data;
break;
case SQL_ROWSET_SIZE:
*((SDWORD *) pvParam) = SC_get_ARD(stmt)->rowset_size;
break;
case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */
*((SDWORD *) pvParam) = SQL_SC_NON_UNIQUE;
break;
case SQL_USE_BOOKMARKS:
*((SDWORD *) pvParam) = stmt->options.use_bookmarks;
break;
default:
{
char option[64];
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
stmt->errormsg = "Unknown statement option (Get)";
sprintf(option, "fOption=%d", fOption);
SC_log_error(func, option, stmt);
return SQL_ERROR;
}
}
return SQL_SUCCESS;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,294 +0,0 @@
/*-------
* Module: pgapifunc.h
*
*-------
*/
#ifndef _PG_API_FUNC_H__
#define _PG_API_FUNC_H__
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#define PODBC_NOT_SEARCH_PATTERN 1L
#define PODBC_ALLOW_PARTIAL_EXTRACT 1L
#define PODBC_ERROR_CLEAR (1L << 1)
RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle,
HDBC FAR * ConnectionHandle);
RETCODE SQL_API PGAPI_AllocEnv(HENV FAR * EnvironmentHandle);
RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle,
HSTMT *StatementHandle);
RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLINTEGER BufferLength,
SQLINTEGER *StrLen_or_Ind);
RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle);
RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *ColumnName, SQLSMALLINT NameLength4,
UWORD flag);
RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle,
SQLCHAR *ServerName, SQLSMALLINT NameLength1,
SQLCHAR *UserName, SQLSMALLINT NameLength2,
SQLCHAR *Authentication, SQLSMALLINT NameLength3);
RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd,
UCHAR FAR * szConnStrIn, SWORD cbConnStrIn,
UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax,
SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion);
RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc,
SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut);
RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle,
SQLUSMALLINT Direction, SQLCHAR *ServerName,
SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
SQLCHAR *Description, SQLSMALLINT BufferLength2,
SQLSMALLINT *NameLength2);
RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable);
RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle);
RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle,
HDBC ConnectionHandle, HSTMT StatementHandle,
SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength);
/* Helper functions for Error handling */
RETCODE SQL_API PGAPI_EnvError(HENV EnvironmentHandle, SWORD RecNumber,
SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength, UWORD flag);
RETCODE SQL_API PGAPI_ConnectError(HDBC ConnectionHandle, SWORD RecNumber,
SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength, UWORD flag);
RETCODE SQL_API PGAPI_StmtError(HSTMT StatementHandle, SWORD RecNumber,
SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
SQLCHAR *MessageText, SQLSMALLINT BufferLength,
SQLSMALLINT *TextLength, UWORD flag);
RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength);
RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle);
RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle);
RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle);
RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle);
RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle,
SQLUSMALLINT Option);
RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle,
SQLUSMALLINT Option, PTR Value);
RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT BufferLength,
SQLSMALLINT *NameLength);
RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLINTEGER BufferLength,
SQLINTEGER *StrLen_or_Ind);
RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle,
SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported);
RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle,
SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported);
RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle,
SQLUSMALLINT InfoType, PTR InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength);
RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle,
SQLUSMALLINT InfoType, PTR InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength);
RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle,
SQLUSMALLINT Option, PTR Value);
RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle,
SQLSMALLINT DataType);
RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle,
SQLSMALLINT *ColumnCount);
RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle,
PTR *Value);
RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength);
RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle,
PTR Data, SQLINTEGER StrLen_or_Ind);
RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle,
SQLINTEGER *RowCount);
RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle,
SQLUSMALLINT Option, SQLUINTEGER Value);
RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT NameLength);
RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle,
SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
SQLSMALLINT ParameterScale, PTR ParameterValue,
SQLINTEGER *StrLen_or_Ind);
RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle,
SQLUSMALLINT Option, SQLUINTEGER Value);
RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle,
SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
SQLSMALLINT NameLength2, SQLCHAR *TableName,
SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
SQLUSMALLINT Nullable);
RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLUSMALLINT Unique, SQLUSMALLINT Reserved);
RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *TableType, SQLSMALLINT NameLength4);
RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle,
HDBC ConnectionHandle, SQLUSMALLINT CompletionType);
RETCODE SQL_API PGAPI_ColAttributes(
HSTMT hstmt,
SQLUSMALLINT icol,
SQLUSMALLINT fDescType,
PTR rgbDesc,
SQLSMALLINT cbDescMax,
SQLSMALLINT *pcbDesc,
SQLINTEGER *pfDesc);
RETCODE SQL_API PGAPI_ColumnPrivileges(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName);
RETCODE SQL_API PGAPI_DescribeParam(
HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT *pfSqlType,
SQLUINTEGER *pcbParamDef,
SQLSMALLINT *pibScale,
SQLSMALLINT *pfNullable);
RETCODE SQL_API PGAPI_ExtendedFetch(
HSTMT hstmt,
SQLUSMALLINT fFetchType,
SQLINTEGER irow,
SQLUINTEGER *pcrow,
SQLUSMALLINT *rgfRowStatus,
SQLINTEGER FetchOffset);
RETCODE SQL_API PGAPI_ForeignKeys(
HSTMT hstmt,
SQLCHAR *szPkCatalogName,
SQLSMALLINT cbPkCatalogName,
SQLCHAR *szPkSchemaName,
SQLSMALLINT cbPkSchemaName,
SQLCHAR *szPkTableName,
SQLSMALLINT cbPkTableName,
SQLCHAR *szFkCatalogName,
SQLSMALLINT cbFkCatalogName,
SQLCHAR *szFkSchemaName,
SQLSMALLINT cbFkSchemaName,
SQLCHAR *szFkTableName,
SQLSMALLINT cbFkTableName);
RETCODE SQL_API PGAPI_MoreResults(
HSTMT hstmt);
RETCODE SQL_API PGAPI_NativeSql(
HDBC hdbc,
SQLCHAR *szSqlStrIn,
SQLINTEGER cbSqlStrIn,
SQLCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax,
SQLINTEGER *pcbSqlStr);
RETCODE SQL_API PGAPI_NumParams(
HSTMT hstmt,
SQLSMALLINT *pcpar);
RETCODE SQL_API PGAPI_ParamOptions(
HSTMT hstmt,
SQLUINTEGER crow,
SQLUINTEGER *pirow);
RETCODE SQL_API PGAPI_PrimaryKeys(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName);
RETCODE SQL_API PGAPI_ProcedureColumns(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName);
RETCODE SQL_API PGAPI_Procedures(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName);
RETCODE SQL_API PGAPI_SetPos(
HSTMT hstmt,
SQLUSMALLINT irow,
SQLUSMALLINT fOption,
SQLUSMALLINT fLock);
RETCODE SQL_API PGAPI_TablePrivileges(
HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName,
UWORD flag);
RETCODE SQL_API PGAPI_BindParameter(
HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT fParamType,
SQLSMALLINT fCType,
SQLSMALLINT fSqlType,
SQLUINTEGER cbColDef,
SQLSMALLINT ibScale,
PTR rgbValue,
SQLINTEGER cbValueMax,
SQLINTEGER *pcbValue);
RETCODE SQL_API PGAPI_SetScrollOptions(
HSTMT hstmt,
UWORD fConcurrency,
SDWORD crowKeyset,
UWORD crowRowset);
#if (ODBCVER >= 0x0300)
RETCODE SQL_API PGAPI_GetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
SQLINTEGER *NativeError, SQLCHAR *MessageText,
SQLSMALLINT BufferLength, SQLSMALLINT *TextLength);
RETCODE SQL_API PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
PTR DiagInfoPtr, SQLSMALLINT BufferLength,
SQLSMALLINT *StringLengthPtr);
RETCODE SQL_API PGAPI_GetConnectAttr(HDBC ConnectionHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength);
RETCODE SQL_API PGAPI_GetStmtAttr(HSTMT StatementHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength);
RETCODE SQL_API PGAPI_SetConnectAttr(HDBC ConnectionHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER StringLength);
RETCODE SQL_API PGAPI_SetStmtAttr(HSTMT StatementHandle,
SQLINTEGER Attribute, PTR Value,
SQLINTEGER StringLength);
RETCODE SQL_API PGAPI_BulkOperations(HSTMT StatementHandle,
SQLSMALLINT operation);
RETCODE SQL_API PGAPI_SetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
PTR Value, SQLINTEGER BufferLength);
RETCODE SQL_API PGAPI_GetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength);
#endif /* ODBCVER */
#endif /* define_PG_API_FUNC_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
/* File: pgtypes.h
*
* Description: See "pgtypes.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __PGTYPES_H__
#define __PGTYPES_H__
#include "psqlodbc.h"
/* the type numbers are defined by the OID's of the types' rows */
/* in table pg_type */
#if 0
#define PG_TYPE_LO ???? /* waiting for permanent type */
#endif
#define PG_TYPE_BOOL 16
#define PG_TYPE_BYTEA 17
#define PG_TYPE_CHAR 18
#define PG_TYPE_NAME 19
#define PG_TYPE_INT8 20
#define PG_TYPE_INT2 21
#define PG_TYPE_INT2VECTOR 22
#define PG_TYPE_INT4 23
#define PG_TYPE_REGPROC 24
#define PG_TYPE_TEXT 25
#define PG_TYPE_OID 26
#define PG_TYPE_TID 27
#define PG_TYPE_XID 28
#define PG_TYPE_CID 29
#define PG_TYPE_OIDVECTOR 30
#define PG_TYPE_SET 32
#define PG_TYPE_CHAR2 409
#define PG_TYPE_CHAR4 410
#define PG_TYPE_CHAR8 411
#define PG_TYPE_POINT 600
#define PG_TYPE_LSEG 601
#define PG_TYPE_PATH 602
#define PG_TYPE_BOX 603
#define PG_TYPE_POLYGON 604
#define PG_TYPE_FILENAME 605
#define PG_TYPE_FLOAT4 700
#define PG_TYPE_FLOAT8 701
#define PG_TYPE_ABSTIME 702
#define PG_TYPE_RELTIME 703
#define PG_TYPE_TINTERVAL 704
#define PG_TYPE_UNKNOWN 705
#define PG_TYPE_MONEY 790
#define PG_TYPE_OIDINT2 810
#define PG_TYPE_OIDINT4 910
#define PG_TYPE_OIDNAME 911
#define PG_TYPE_BPCHAR 1042
#define PG_TYPE_VARCHAR 1043
#define PG_TYPE_DATE 1082
#define PG_TYPE_TIME 1083
#define PG_TYPE_TIMESTAMP_NO_TMZONE 1114 /* since 7.2 */
#define PG_TYPE_DATETIME 1184
#define PG_TYPE_TIME_WITH_TMZONE 1266 /* since 7.1 */
#define PG_TYPE_TIMESTAMP 1296 /* deprecated since 7.0 */
#define PG_TYPE_NUMERIC 1700
/* extern Int4 pgtypes_defined[]; */
extern Int2 sqlTypes[];
/* Defines for pgtype_precision */
#define PG_STATIC (-1)
Int4 sqltype_to_pgtype(StatementClass *stmt, Int2 fSqlType);
Int2 pgtype_to_concise_type(StatementClass *stmt, Int4 type);
Int2 pgtype_to_sqldesctype(StatementClass *stmt, Int4 type);
Int2 pgtype_to_datetime_sub(StatementClass *stmt, Int4 type);
Int2 pgtype_to_ctype(StatementClass *stmt, Int4 type);
char *pgtype_to_name(StatementClass *stmt, Int4 type);
/* These functions can use static numbers or result sets(col parameter) */
Int4 pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); /* corresponds to "precision" in ODBC 2.x */
Int4 pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); /* "precsion in ODBC 3.x */
Int4 pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
Int4 pgtype_buffer_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
Int4 pgtype_desclength(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
Int4 pgtype_transfer_octet_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as);
Int2 pgtype_decimal_digits(StatementClass *stmt, Int4 type, int col); /* corresponds to "scale" in ODBC 2.x */
Int2 pgtype_scale(StatementClass *stmt, Int4 type, int col); /* ODBC 3.x " */
Int2 pgtype_radix(StatementClass *stmt, Int4 type);
Int2 pgtype_nullable(StatementClass *stmt, Int4 type);
Int2 pgtype_auto_increment(StatementClass *stmt, Int4 type);
Int2 pgtype_case_sensitive(StatementClass *stmt, Int4 type);
Int2 pgtype_money(StatementClass *stmt, Int4 type);
Int2 pgtype_searchable(StatementClass *stmt, Int4 type);
Int2 pgtype_unsigned(StatementClass *stmt, Int4 type);
char *pgtype_literal_prefix(StatementClass *stmt, Int4 type);
char *pgtype_literal_suffix(StatementClass *stmt, Int4 type);
char *pgtype_create_params(StatementClass *stmt, Int4 type);
Int2 sqltype_to_default_ctype(Int2 sqltype);
Int4 ctype_length(Int2 ctype);
#define USE_ZONE FALSE
#endif

View File

@ -1,132 +0,0 @@
/*--------
* Module: psqlodbc.c
*
* Description: This module contains the main entry point (DllMain)
* for the library. It also contains functions to get
* and set global variables for the driver in the registry.
*
* Classes: n/a
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*--------
*/
#include "psqlodbc.h"
#include "dlg_specific.h"
#ifdef WIN32
#include <winsock.h>
#endif
GLOBAL_VALUES globals;
RETCODE SQL_API SQLDummyOrdinal(void);
#ifdef WIN32
HINSTANCE NEAR s_hModule; /* Saved module handle. */
/* This is where the Driver Manager attaches to this Driver */
BOOL WINAPI
DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
WORD wVersionRequested;
WSADATA wsaData;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
s_hModule = hInst; /* Save for dialog boxes */
/* Load the WinSock Library */
wVersionRequested = MAKEWORD(1, 1);
if (WSAStartup(wVersionRequested, &wsaData))
return FALSE;
/* Verify that this is the minimum version of WinSock */
if (LOBYTE(wsaData.wVersion) != 1 ||
HIBYTE(wsaData.wVersion) != 1)
{
WSACleanup();
return FALSE;
}
getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_PROCESS_DETACH:
WSACleanup();
return TRUE;
case DLL_THREAD_DETACH:
break;
default:
break;
}
return TRUE;
UNREFERENCED_PARAMETER(lpReserved);
}
#else /* not WIN32 */
#ifndef TRUE
#define TRUE (BOOL)1
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
#ifdef __GNUC__
/* This function is called at library initialization time. */
static BOOL
__attribute__((constructor))
init(void)
{
getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL);
return TRUE;
}
#else /* not __GNUC__ */
/*
* These two functions do shared library initialziation on UNIX, well at least
* on Linux. I don't know about other systems.
*/
BOOL
_init(void)
{
getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL);
return TRUE;
}
BOOL
_fini(void)
{
return TRUE;
}
#endif /* not __GNUC__ */
#endif /* not WIN32 */
/*
* This function is used to cause the Driver Manager to
* call functions by number rather than name, which is faster.
* The ordinal value of this function must be 199 to have the
* Driver Manager do this. Also, the ordinal values of the
* functions must match the value of fFunction in SQLGetFunctions()
*/
RETCODE SQL_API
SQLDummyOrdinal(void)
{
return SQL_SUCCESS;
}

View File

@ -1,279 +0,0 @@
/* File: psqlodbc.h
*
* Description: This file contains defines and declarations that are related to
* the entire driver.
*
* Comments: See "notice.txt" for copyright and license information.
*
* $Id: psqlodbc.h,v 1.69 2002/07/11 01:52:46 inoue Exp $
*
*/
#ifndef __PSQLODBC_H__
#define __PSQLODBC_H__
#ifndef WIN32
#include "pg_config.h"
#else
#include <windows.h>
#endif
#include <stdio.h> /* for FILE* pointers: see GLOBAL_VALUES */
#include "version.h"
/* Must come before sql.h */
#ifndef ODBCVER
#define ODBCVER 0x0250
#endif /* ODBCVER_REP */
#ifndef NAMEDATALEN
#define NAMEDATALEN 32
#endif /* NAMEDATALEN */
#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
#define UInt4 unsigned int
#define Int2 short
#define UInt2 unsigned short
#endif
typedef UInt4 Oid;
#ifndef WIN32
#define stricmp strcasecmp
#define strnicmp strncasecmp
#else
#define snprintf _snprintf
#endif
/* Driver stuff */
#define DRIVERNAME "PostgreSQL ODBC"
#if (ODBCVER >= 0x0300)
#define DRIVER_ODBC_VER "03.00"
#define DBMS_NAME "PostgreSQL30"
#else
#define DRIVER_ODBC_VER "02.50"
#define DBMS_NAME "PostgreSQL"
#endif /* ODBCVER */
#ifdef WIN32
#if (ODBCVER >= 0x0300)
#ifdef UNICODE_SUPPORT
#define DRIVER_FILE_NAME "PSQLODBC30W.DLL"
#else
#define DRIVER_FILE_NAME "PSQLODBC30.DLL"
#endif /* UNICODE_SUPPORT */
#else
#define DRIVER_FILE_NAME "PSQLODBC.DLL"
#endif /* ODBCVER */
#else
#define DRIVER_FILE_NAME "libpsqlodbc.so"
#endif /* WIN32 */
/* Limits */
#ifdef WIN32
#define BLCKSZ 4096
#endif
#define MAX_MESSAGE_LEN 65536 /* This puts a limit on
* query size but I don't */
/* see an easy way round this - DJP 24-1-2001 */
#define MAX_CONNECT_STRING 4096
#define ERROR_MSG_LENGTH 4096
#define FETCH_MAX 100 /* default number of rows to cache
* for declare/fetch */
#define TUPLE_MALLOC_INC 100
#define SOCK_BUFFER_SIZE 4096 /* default socket buffer
* size */
#define MAX_CONNECTIONS 128 /* conns per environment
* (arbitrary) */
#define MAX_FIELDS 512
#define BYTELEN 8
#define VARHDRSZ sizeof(Int4)
#define MAX_SCHEMA_LEN NAMEDATALEN
#define MAX_TABLE_LEN NAMEDATALEN
#define MAX_COLUMN_LEN NAMEDATALEN
#define MAX_CURSOR_LEN 32
/* Registry length limits */
#define LARGE_REGISTRY_LEN 4096 /* used for special cases */
#define MEDIUM_REGISTRY_LEN 256 /* normal size for
* user,database,etc. */
#define SMALL_REGISTRY_LEN 10 /* for 1/0 settings */
/* These prefixes denote system tables */
#define POSTGRES_SYS_PREFIX "pg_"
#define KEYS_TABLE "dd_fkey"
/* Info limits */
#define MAX_INFO_STRING 128
#define MAX_KEYPARTS 20
#define MAX_KEYLEN 512 /* max key of the form
* "date+outlet+invoice" */
#define MAX_ROW_SIZE 0 /* Unlimited rowsize with the
* Tuple Toaster */
#define MAX_STATEMENT_LEN 0 /* Unlimited statement size with
* 7.0 */
/* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
/* Now that's 0, lets use this instead. DJP 24-1-2001 */
#define STD_STATEMENT_LEN MAX_MESSAGE_LEN
#define PG62 "6.2" /* "Protocol" key setting
* to force Postgres 6.2 */
#define PG63 "6.3" /* "Protocol" key setting
* to force postgres 6.3 */
#define PG64 "6.4"
typedef struct ConnectionClass_ ConnectionClass;
typedef struct StatementClass_ StatementClass;
typedef struct QResultClass_ QResultClass;
typedef struct SocketClass_ SocketClass;
typedef struct BindInfoClass_ BindInfoClass;
typedef struct ParameterInfoClass_ ParameterInfoClass;
typedef struct ColumnInfoClass_ ColumnInfoClass;
typedef struct TupleListClass_ TupleListClass;
typedef struct EnvironmentClass_ EnvironmentClass;
typedef struct TupleNode_ TupleNode;
typedef struct TupleField_ TupleField;
typedef struct KeySet_ KeySet;
typedef struct Rollback_ Rollback;
typedef struct ARDFields_ ARDFields;
typedef struct APDFields_ APDFields;
typedef struct IRDFields_ IRDFields;
typedef struct IPDFields_ IPDFields;
typedef struct col_info COL_INFO;
typedef struct lo_arg LO_ARG;
typedef struct GlobalValues_
{
int fetch_max;
int socket_buffersize;
int unknown_sizes;
int max_varchar_size;
int max_longvarchar_size;
char debug;
char commlog;
char disable_optimizer;
char ksqo;
char unique_index;
char onlyread; /* readonly is reserved on Digital C++
* compiler */
char use_declarefetch;
char text_as_longvarchar;
char unknowns_as_longvarchar;
char bools_as_char;
char lie;
char parse;
char cancel_as_freestmt;
char extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
char conn_settings[LARGE_REGISTRY_LEN];
char protocol[SMALL_REGISTRY_LEN];
} GLOBAL_VALUES;
typedef struct StatementOptions_
{
int maxRows;
int maxLength;
int keyset_size;
int cursor_type;
int scroll_concurrency;
int retrieve_data;
int use_bookmarks;
void *bookmark_ptr;
} StatementOptions;
/* Used to pass extra query info to send_query */
typedef struct QueryInfo_
{
int row_size;
QResultClass *result_in;
char *cursor;
} QueryInfo;
void logs_on_off(int cnopen, int, int);
#define PG_TYPE_LO (-999) /* hack until permanent
* type available */
#define PG_TYPE_LO_NAME "lo"
#define OID_ATTNUM (-2) /* the attnum in pg_index
* of the oid */
/* sizes */
#define TEXT_FIELD_SIZE 8190 /* size of text fields
* (not including null
* term) */
#define NAME_FIELD_SIZE NAMEDATALEN /* size of name fields */
#define MAX_VARCHAR_SIZE 254 /* maximum size of a varchar (not
* including null term) */
#define PG_NUMERIC_MAX_PRECISION 1000
#define PG_NUMERIC_MAX_SCALE 1000
#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for
* queries used in info.c inoue
* 2001/05/17 */
#include "misc.h"
#ifdef UNICODE_SUPPORT
UInt4 ucs2strlen(const SQLWCHAR *ucs2str);
char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen);
UInt4 utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
#define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
#endif /* UNICODE_SUPPORT */
/*#define _MEMORY_DEBUG_ */
#ifdef _MEMORY_DEBUG_
void *debug_alloc(size_t);
void *debug_realloc(void *, size_t);
char *debug_strdup(const char *);
void debug_free(void *);
void debug_memory_check(void);
#define malloc debug_alloc
#define realloc debug_realloc
#define strdup debug_strdup
#define free debug_free
#endif /* _MEMORY_DEBUG_ */
#endif

View File

@ -1,321 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
#include "version.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// ‰pŒê (±Òض) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""version.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
DLG_CONFIG DIALOG DISCARDABLE 65, 43, 292, 116
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "PostgreSQL ODBC Driver (psqlODBC) Setup"
FONT 10, "Terminal"
BEGIN
RTEXT "&Data Source",IDC_DSNAMETEXT,5,11,50,12,NOT WS_GROUP
EDITTEXT IDC_DSNAME,57,10,72,12,ES_AUTOHSCROLL | WS_GROUP
RTEXT "Des&cription",IDC_DESCTEXT,129,10,45,12,NOT WS_GROUP
EDITTEXT IDC_DESC,176,10,107,12,ES_AUTOHSCROLL
RTEXT "Data&base",IDC_STATIC,16,26,38,12,NOT WS_GROUP
EDITTEXT IDC_DATABASE,57,25,72,12,ES_AUTOHSCROLL
RTEXT "&Server",IDC_STATIC,26,41,29,12,NOT WS_GROUP
EDITTEXT IDC_SERVER,57,40,72,12,ES_AUTOHSCROLL
RTEXT "&Port",IDC_STATIC,151,41,22,12
EDITTEXT IDC_PORT,175,40,37,12,ES_AUTOHSCROLL
RTEXT "&User Name",IDC_STATIC,16,56,39,12
EDITTEXT IDC_USER,57,55,72,12,ES_AUTOHSCROLL
RTEXT "Pass&word",IDC_STATIC,139,57,34,9
EDITTEXT IDC_PASSWORD,175,55,72,12,ES_PASSWORD | ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,25,87,40,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,80,87,40,14
GROUPBOX "Options",IDC_OPTIONS,140,74,140,35,BS_LEFT
PUSHBUTTON "Datasource",IDC_DATASOURCE,159,87,50,14
PUSHBUTTON "Global",IDC_DRIVER,220,87,50,14
CTEXT "Please supply any missing information required to connect.",
DRV_MSG_LABEL,36,2,220,10
END
DLG_OPTIONS_DRV DIALOG DISCARDABLE 0, 0, 287, 231
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Advanced Options (DataSource)"
FONT 10, "Terminal"
BEGIN
PUSHBUTTON "Page 1",IDPREVPAGE,5,5,40,15
PUSHBUTTON "Page 2",IDNEXTPAGE,49,5,40,15
CONTROL "Disable Genetic &Optimizer",DRV_OPTIMIZER,"Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,26,116,10
CONTROL "Comm&Log (C:\\psqlodbc_xxxx.log)",DRV_COMMLOG,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,26,131,10
CONTROL "&KSQO(Keyset Query Optimization)",DRV_KSQO,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,41,132,10
CONTROL "Recognize Unique &Indexes",DRV_UNIQUEINDEX,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,56,110,10
CONTROL "P&arse Statements",DRV_PARSE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,149,41,80,10
CONTROL "&Use Declare/Fetch",DRV_USEDECLAREFETCH,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,71,83,10
CONTROL "Cancel as FreeStmt (Exp)",DRV_CANCELASFREESTMT,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,56,114,10
CONTROL "MyLog (C:\\mylog_xxxx.log)",DRV_DEBUG,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,71,112,10
GROUPBOX "Unknown Sizes",IDC_STATIC,5,85,277,25
CONTROL "Maximum",DRV_UNKNOWN_MAX,"Button",BS_AUTORADIOBUTTON |
WS_GROUP | WS_TABSTOP,15,96,45,10
CONTROL "Don't Know",DRV_UNKNOWN_DONTKNOW,"Button",
BS_AUTORADIOBUTTON | WS_TABSTOP,105,96,53,10
CONTROL "Longest",DRV_UNKNOWN_LONGEST,"Button",
BS_AUTORADIOBUTTON | WS_TABSTOP,215,95,50,10
GROUPBOX "Data Type Options",IDC_STATIC,5,115,277,25
CONTROL "Text as LongVarChar",DRV_TEXT_LONGVARCHAR,"Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,125,90,10
CONTROL "Unknowns as LongVarChar",DRV_UNKNOWNS_LONGVARCHAR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,125,105,10
CONTROL "Bools as Char",DRV_BOOLS_CHAR,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,215,125,67,10
LTEXT "&Cache Size:",IDC_STATIC,14,183,52,8
EDITTEXT DRV_CACHE_SIZE,69,181,35,12,ES_AUTOHSCROLL
LTEXT "Max &Varchar:",IDC_STATIC,13,161,54,8
EDITTEXT DRV_VARCHAR_SIZE,70,160,35,12,ES_AUTOHSCROLL
LTEXT "Max Lon&gVarChar:",IDC_STATIC,125,161,67,8
EDITTEXT DRV_LONGVARCHAR_SIZE,199,160,35,12,ES_AUTOHSCROLL
LTEXT "SysTable &Prefixes:",IDC_STATIC,125,183,61,18
EDITTEXT DRV_EXTRASYSTABLEPREFIXES,199,181,71,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,5,212,50,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,81,211,50,15
PUSHBUTTON "Apply",IDAPPLY,156,212,50,14
PUSHBUTTON "Defaults",IDDEFAULTS,232,211,50,15
GROUPBOX "Miscellanous",IDC_STATIC,5,145,277,58
END
DLG_OPTIONS_DS DIALOG DISCARDABLE 0, 0, 287, 231
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Advanced Options (DataSource)"
FONT 10, "Terminal"
BEGIN
PUSHBUTTON "Page 2",IDNEXTPAGE,49,5,40,15
PUSHBUTTON "Page 1",IDPREVPAGE,5,5,40,15
CONTROL "&Read Only",DS_READONLY,"Button",BS_AUTOCHECKBOX |
WS_GROUP | WS_TABSTOP,15,26,102,10
CONTROL "Row &Versioning",DS_ROWVERSIONING,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,26,85,10
CONTROL "Show System &Tables",DS_SHOWSYSTEMTABLES,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,41,100,10
CONTROL "Disallow &Premature",DS_DISALLOWPREMATURE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,41,85,10
CONTROL "LF <-> CR/LF conversion",DS_LFCONVERSION,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,56,106,10
CONTROL "True is -1",DS_TRUEISMINUS1,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,149,56,86,10
CONTROL "Updatable Cursors",DS_UPDATABLECURSORS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,71,87,10
GROUPBOX "Int8 As",IDC_STATIC,5,85,277,25
CONTROL "default",DS_INT8_AS_DEFAULT,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,12,95,40,10
CONTROL "bigint",DS_INT8_AS_BIGINT,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,55,95,35,10
CONTROL "numeric",DS_INT8_AS_NUMERIC,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,98,95,40,10
CONTROL "varchar",DS_INT8_AS_VARCHAR,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,141,95,40,10
CONTROL "double",DS_INT8_AS_DOUBLE,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,184,95,40,10
CONTROL "int4",DS_INT8_AS_INT4,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,227,95,29,10
GROUPBOX "Protocol",IDC_STATIC,5,115,277,25
CONTROL "7.X,6.4+",DS_PG64,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,44,126,49,10
CONTROL "6.3",DS_PG63,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
117,126,26,10
CONTROL "6.2",DS_PG62,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
191,126,26,10
GROUPBOX "OID Options",IDC_STATIC,5,145,277,25
CONTROL "Show &Column",DS_SHOWOIDCOLUMN,"Button",BS_AUTOCHECKBOX |
WS_GROUP | WS_TABSTOP,53,157,59,10
CONTROL "Fake &Index",DS_FAKEOIDINDEX,"Button",BS_AUTOCHECKBOX |
WS_GROUP | WS_TABSTOP,155,156,51,10
LTEXT "Connect &Settings:",IDC_STATIC,5,182,62,17
EDITTEXT DS_CONNSETTINGS,71,178,211,27,ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
DEFPUSHBUTTON "OK",IDOK,5,212,50,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,81,212,50,14
PUSHBUTTON "Apply",IDAPPLY,156,212,50,14
END
DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 87
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Global settings"
FONT 10, "Terminal"
BEGIN
CONTROL "Comm&Log (C:\\psqlodbc_xxxx.log - Communications log)",
DRV_COMMLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,24,
263,10
CONTROL "Mylog (C:\\mylog_xxxx.log - Detailed debug output)",
DRV_DEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,42,
264,10
DEFPUSHBUTTON "OK",IDOK,82,68,50,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,172,67,50,15
GROUPBOX "Pre-connection/default logging options",IDC_STATIC,5,5,
296,58
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
DLG_CONFIG, DIALOG
BEGIN
BOTTOMMARGIN, 115
END
DLG_OPTIONS_DRV, DIALOG
BEGIN
LEFTMARGIN, 5
RIGHTMARGIN, 282
TOPMARGIN, 5
BOTTOMMARGIN, 226
END
DLG_OPTIONS_DS, DIALOG
BEGIN
LEFTMARGIN, 5
RIGHTMARGIN, 282
TOPMARGIN, 5
BOTTOMMARGIN, 226
END
DLG_OPTIONS_GLOBAL, DIALOG
BEGIN
LEFTMARGIN, 5
RIGHTMARGIN, 301
TOPMARGIN, 5
BOTTOMMARGIN, 82
END
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION PG_DRVFILE_VERSION
PRODUCTVERSION PG_DRVFILE_VERSION
FILEFLAGSMASK 0x3L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "PostgreSQL ODBC driver\0"
VALUE "CompanyName", "Insight Distribution Systems\0"
VALUE "FileDescription", "PostgreSQL Driver\0"
VALUE "FileVersion", POSTGRES_RESOURCE_VERSION
VALUE "InternalName", "psqlodbc\0"
VALUE "LegalCopyright", "\0"
VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation. Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0"
VALUE "OriginalFilename", "psqlodbc.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Microsoft Open Database Connectivity\0"
VALUE "ProductVersion", POSTGRES_RESOURCE_VERSION
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_BADDSN "Invalid DSN entry, please recheck."
IDS_MSGTITLE "Invalid DSN"
END
#endif // ‰pŒê (±Òض) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,16 +0,0 @@
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI]
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"PostgreSQL"="Installed"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL]
"APILevel"="1"
"ConnectFunctions"="YYN"
"Driver"="PSQLODBC.DLL"
"DriverODBCVer"="02.50"
"FileUsage"="0"
"Setup"="PSQLODBC.DLL"
"SQLLevel"="1"
"UsageCount"=dword:00000001

View File

@ -1,16 +0,0 @@
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI]
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"PostgreSQL+ (Beta)"="Installed"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL+ (Beta)]
"APILevel"="1"
"ConnectFunctions"="YYN"
"Driver"="PSQLODBC30.DLL"
"DriverODBCVer"="03.00"
"FileUsage"="0"
"Setup"="PSQLODBC30.DLL"
"SQLLevel"="1"
"UsageCount"=dword:00000001

View File

@ -1,16 +0,0 @@
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI]
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"PostgreSQL+ Unicode (Beta)"="Installed"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL+ Unicode (Beta)]
"APILevel"="1"
"ConnectFunctions"="YYN"
"Driver"="PSQLODBC30W.DLL"
"DriverODBCVer"="03.00"
"FileUsage"="0"
"Setup"="PSQLODBC30W.DLL"
"SQLLevel"="1"
"UsageCount"=dword:00000001

View File

@ -1,82 +0,0 @@
LIBRARY psqlodbc30
EXPORTS
SQLAllocConnect @1
SQLAllocEnv @2
SQLAllocStmt @3
SQLBindCol @4
SQLCancel @5
; SQLColAttributes @6 */
SQLConnect @7
SQLDescribeCol @8
SQLDisconnect @9
SQLError @10
SQLExecDirect @11
SQLExecute @12
SQLFetch @13
SQLFreeConnect @14
SQLFreeEnv @15
SQLFreeStmt @16
SQLGetCursorName @17
SQLNumResultCols @18
SQLPrepare @19
SQLRowCount @20
SQLSetCursorName @21
SQLTransact @23
SQLColumns @40
SQLDriverConnect @41
SQLGetConnectOption @42
SQLGetData @43
SQLGetFunctions @44
SQLGetInfo @45
SQLGetStmtOption @46
SQLGetTypeInfo @47
SQLParamData @48
SQLPutData @49
SQLSetConnectOption @50
SQLSetStmtOption @51
SQLSpecialColumns @52
SQLStatistics @53
SQLTables @54
SQLBrowseConnect @55
SQLColumnPrivileges @56
SQLDescribeParam @58
SQLExtendedFetch @59
SQLForeignKeys @60
SQLMoreResults @61
SQLNativeSql @62
SQLNumParams @63
SQLParamOptions @64
SQLPrimaryKeys @65
SQLProcedureColumns @66
SQLProcedures @67
SQLSetPos @68
SQLSetScrollOptions @69
SQLTablePrivileges @70
SQLBindParameter @72
SQLAllocHandle @80
SQLBindParam @81
SQLCloseCursor @82
SQLColAttribute @83
SQLCopyDesc @84
SQLEndTran @85
SQLFetchScroll @86
SQLFreeHandle @87
SQLGetDescField @88
SQLGetDescRec @89
SQLGetDiagField @90
SQLGetDiagRec @91
SQLGetEnvAttr @92
SQLGetConnectAttr @93
SQLGetStmtAttr @94
SQLSetConnectAttr @95
SQLSetDescField @96
SQLSetDescRec @97
SQLSetEnvAttr @98
SQLSetStmtAttr @99
SQLBulkOperations @100
SQLDummyOrdinal @199
dconn_FDriverConnectProc @200
DllMain @201
ConfigDSN @202

View File

@ -1,107 +0,0 @@
LIBRARY psqlodbc30w
EXPORTS
SQLAllocConnect @1
SQLAllocEnv @2
SQLAllocStmt @3
SQLBindCol @4
SQLCancel @5
; SQLColAttributes @6
SQLConnect @7
SQLDescribeCol @8
SQLDisconnect @9
SQLError @10
SQLExecDirect @11
SQLExecute @12
SQLFetch @13
SQLFreeConnect @14
SQLFreeEnv @15
SQLFreeStmt @16
SQLGetCursorName @17
SQLNumResultCols @18
SQLPrepare @19
SQLRowCount @20
SQLSetCursorName @21
SQLTransact @23
SQLColumns @40
SQLDriverConnect @41
SQLGetData @43
SQLGetFunctions @44
SQLGetInfo @45
SQLGetStmtOption @46
SQLGetTypeInfo @47
SQLParamData @48
SQLPutData @49
SQLSpecialColumns @52
SQLStatistics @53
SQLTables @54
SQLBrowseConnect @55
SQLColumnPrivileges @56
SQLDescribeParam @58
SQLExtendedFetch @59
SQLForeignKeys @60
SQLMoreResults @61
SQLNativeSql @62
SQLNumParams @63
SQLParamOptions @64
SQLPrimaryKeys @65
SQLProcedureColumns @66
SQLProcedures @67
SQLSetPos @68
SQLSetScrollOptions @69
SQLTablePrivileges @70
SQLBindParameter @72
SQLAllocHandle @80
SQLBindParam @81
SQLCloseCursor @82
SQLColAttribute @83
SQLCopyDesc @84
SQLEndTran @85
SQLFetchScroll @86
SQLFreeHandle @87
SQLGetDescField @88
SQLGetDescRec @89
SQLGetDiagField @90
SQLGetDiagRec @91
SQLGetEnvAttr @92
SQLGetConnectAttr @93
SQLGetStmtAttr @94
SQLSetConnectAttr @95
SQLSetDescField @96
SQLSetDescRec @97
SQLSetEnvAttr @98
SQLSetStmtAttr @99
SQLBulkOperations @100
SQLDummyOrdinal @199
dconn_FDriverConnectProc @200
DllMain @201
ConfigDSN @202
SQLColAttributeW @101
SQLColumnPrivilegesW @102
SQLColumnsW @103
SQLConnectW @104
SQLDescribeColW @106
SQLExecDirectW @107
SQLForeignKeysW @108
SQLGetConnectAttrW @109
SQLGetCursorNameW @110
SQLGetInfoW @111
SQLNativeSqlW @112
SQLPrepareW @113
SQLPrimaryKeysW @114
SQLProcedureColumnsW @115
SQLProceduresW @116
SQLSetConnectAttrW @117
SQLSetCursorNameW @118
SQLSpecialColumnsW @119
SQLStatisticsW @120
SQLTablesW @121
SQLTablePrivilegesW @122
SQLDriverConnectW @123
SQLGetDiagRecW @124
SQLGetStmtAttrW @125
SQLSetStmtAttrW @126
SQLSetDescFieldW @127
SQLGetTypeInfoW @128

View File

@ -1,84 +0,0 @@
LIBRARY psqlodbc
EXPORTS
SQLAllocConnect @1
SQLAllocEnv @2
SQLAllocStmt @3
SQLBindCol @4
SQLCancel @5
SQLColAttributes @6
SQLConnect @7
SQLDescribeCol @8
SQLDisconnect @9
SQLError @10
SQLExecDirect @11
SQLExecute @12
SQLFetch @13
SQLFreeConnect @14
SQLFreeEnv @15
SQLFreeStmt @16
SQLGetCursorName @17
SQLNumResultCols @18
SQLPrepare @19
SQLRowCount @20
SQLSetCursorName @21
SQLTransact @23
SQLColumns @40
SQLDriverConnect @41
SQLGetConnectOption @42
SQLGetData @43
SQLGetFunctions @44
SQLGetInfo @45
SQLGetStmtOption @46
SQLGetTypeInfo @47
SQLParamData @48
SQLPutData @49
SQLSetConnectOption @50
SQLSetStmtOption @51
SQLSpecialColumns @52
SQLStatistics @53
SQLTables @54
SQLBrowseConnect @55
SQLColumnPrivileges @56
SQLDescribeParam @58
SQLExtendedFetch @59
SQLForeignKeys @60
SQLMoreResults @61
SQLNativeSql @62
SQLNumParams @63
SQLParamOptions @64
SQLPrimaryKeys @65
SQLProcedureColumns @66
SQLProcedures @67
SQLSetPos @68
SQLSetScrollOptions @69
SQLTablePrivileges @70
SQLBindParameter @72
SQLColAttributesW @101
SQLColumnPrivilegesW @102
SQLColumnsW @103
SQLConnectW @104
SQLDescribeColW @106
SQLExecDirectW @107
SQLForeignKeysW @108
SQLGetConnectOptionW @109
SQLGetCursorNameW @110
SQLGetInfoW @111
SQLNativeSqlW @112
SQLPrepareW @113
SQLPrimaryKeysW @114
SQLProcedureColumnsW @115
SQLProceduresW @116
SQLSetConnectOptionW @117
SQLSetCursorNameW @118
SQLSpecialColumnsW @119
SQLStatisticsW @120
SQLTablesW @121
SQLTablePrivilegesW @122
SQLDriverConnectW @123
SQLErrorW @124
SQLGetTypeInfoW @128
dconn_FDriverConnectProc @200
DllMain @201
ConfigDSN @202

View File

@ -1,60 +0,0 @@
LIBRARY psqlodbc
EXPORTS
SQLAllocConnect @1
SQLAllocEnv @2
SQLAllocStmt @3
SQLBindCol @4
SQLCancel @5
SQLColAttributes @6
SQLConnect @7
SQLDescribeCol @8
SQLDisconnect @9
SQLError @10
SQLExecDirect @11
SQLExecute @12
SQLFetch @13
SQLFreeConnect @14
SQLFreeEnv @15
SQLFreeStmt @16
SQLGetCursorName @17
SQLNumResultCols @18
SQLPrepare @19
SQLRowCount @20
SQLSetCursorName @21
SQLTransact @23
SQLColumns @40
SQLDriverConnect @41
SQLGetConnectOption @42
SQLGetData @43
SQLGetFunctions @44
SQLGetInfo @45
SQLGetStmtOption @46
SQLGetTypeInfo @47
SQLParamData @48
SQLPutData @49
SQLSetConnectOption @50
SQLSetStmtOption @51
SQLSpecialColumns @52
SQLStatistics @53
SQLTables @54
SQLBrowseConnect @55
SQLColumnPrivileges @56
SQLDescribeParam @58
SQLExtendedFetch @59
SQLForeignKeys @60
SQLMoreResults @61
SQLNativeSql @62
SQLNumParams @63
SQLParamOptions @64
SQLPrimaryKeys @65
SQLProcedureColumns @66
SQLProcedures @67
SQLSetPos @68
SQLSetScrollOptions @69
SQLTablePrivileges @70
SQLBindParameter @72
SQLDummyOrdinal @199
dconn_FDriverConnectProc @200
DllMain @201
ConfigDSN @202

View File

@ -1,846 +0,0 @@
/*---------
* Module: qresult.c
*
* Description: This module contains functions related to
* managing result information (i.e, fetching rows
* from the backend, managing the tuple cache, etc.)
* and retrieving it. Depending on the situation, a
* QResultClass will hold either data from the backend
* or a manually built result (see "qresult.h" to
* see which functions/macros are for manual or backend
* results. For manually built results, the
* QResultClass simply points to TupleList and
* ColumnInfo structures, which actually hold the data.
*
* Classes: QResultClass (Functions prefix: "QR_")
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*---------
*/
#include "qresult.h"
#include "misc.h"
#include <stdio.h>
#include <string.h>
#ifndef TRUE
#define TRUE (BOOL)1
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
/*
* Used for building a Manual Result only
* All info functions call this function to create the manual result set.
*/
void
QR_set_num_fields(QResultClass *self, int new_num_fields)
{
mylog("in QR_set_num_fields\n");
CI_set_num_fields(self->fields, new_num_fields);
if (self->manual_tuples)
TL_Destructor(self->manual_tuples);
self->manual_tuples = TL_Constructor(new_num_fields);
mylog("exit QR_set_num_fields\n");
}
void
QR_set_position(QResultClass *self, int pos)
{
self->tupleField = self->backend_tuples + ((self->base + pos) * self->num_fields);
}
void
QR_set_cache_size(QResultClass *self, int cache_size)
{
self->cache_size = cache_size;
}
void
QR_set_rowset_size(QResultClass *self, int rowset_size)
{
self->rowset_size = rowset_size;
}
void
QR_inc_base(QResultClass *self, int base_inc)
{
self->base += base_inc;
}
/*
* CLASS QResult
*/
QResultClass *
QR_Constructor()
{
QResultClass *rv;
mylog("in QR_Constructor\n");
rv = (QResultClass *) malloc(sizeof(QResultClass));
if (rv != NULL)
{
rv->status = PGRES_EMPTY_QUERY;
/* construct the column info */
if (!(rv->fields = CI_Constructor()))
{
free(rv);
return NULL;
}
rv->manual_tuples = NULL;
rv->backend_tuples = NULL;
rv->message = NULL;
rv->command = NULL;
rv->notice = NULL;
rv->conn = NULL;
rv->next = NULL;
rv->inTuples = FALSE;
rv->count_backend_allocated = 0;
rv->count_keyset_allocated = 0;
rv->num_total_rows = 0;
rv->num_backend_rows = 0;
rv->fetch_count = 0;
rv->base = 0;
rv->recent_processed_row_count = -1;
rv->currTuple = -1;
rv->num_fields = 0;
rv->tupleField = NULL;
rv->cursor = NULL;
rv->aborted = FALSE;
rv->cache_size = 0;
rv->rowset_size = 1;
rv->haskeyset = 0;
rv->keyset = NULL;
rv->rb_alloc = 0;
rv->rb_count = 0;
rv->rollback = NULL;
rv->dl_alloc = 0;
rv->dl_count = 0;
rv->deleted = NULL;
}
mylog("exit QR_Constructor\n");
return rv;
}
void
QR_Destructor(QResultClass *self)
{
mylog("QResult: in DESTRUCTOR\n");
/* manual result set tuples */
if (self->manual_tuples)
TL_Destructor(self->manual_tuples);
/*
* If conn is defined, then we may have used "backend_tuples", so in
* case we need to, free it up. Also, close the cursor.
*/
if (self->conn && self->conn->sock && CC_is_in_trans(self->conn))
QR_close(self); /* close the cursor if there is one */
QR_free_memory(self); /* safe to call anyway */
/* Should have been freed in the close() but just in case... */
if (self->cursor)
free(self->cursor);
/* Free up column info */
if (self->fields)
CI_Destructor(self->fields);
/* Free command info (this is from strdup()) */
if (self->command)
free(self->command);
/* Free notice info (this is from strdup()) */
if (self->notice)
free(self->notice);
/* Destruct the result object in the chain */
if (self->next)
QR_Destructor(self->next);
free(self);
mylog("QResult: exit DESTRUCTOR\n");
}
void
QR_set_command(QResultClass *self, char *msg)
{
if (self->command)
free(self->command);
self->command = msg ? strdup(msg) : NULL;
}
void
QR_set_notice(QResultClass *self, char *msg)
{
if (self->notice)
free(self->notice);
self->notice = msg ? strdup(msg) : NULL;
}
void
QR_free_memory(QResultClass *self)
{
register int lf,
row;
register TupleField *tuple = self->backend_tuples;
int num_backend_rows = self->num_backend_rows;
int num_fields = self->num_fields;
mylog("QResult: free memory in, fcount=%d\n", num_backend_rows);
if (self->backend_tuples)
{
for (row = 0; row < num_backend_rows; row++)
{
mylog("row = %d, num_fields = %d\n", row, num_fields);
for (lf = 0; lf < num_fields; lf++)
{
if (tuple[lf].value != NULL)
{
mylog("free [lf=%d] %u\n", lf, tuple[lf].value);
free(tuple[lf].value);
}
}
tuple += num_fields; /* next row */
}
free(self->backend_tuples);
self->count_backend_allocated = 0;
self->backend_tuples = NULL;
}
if (self->keyset)
{
free(self->keyset);
self->keyset = NULL;
self->count_keyset_allocated = 0;
}
if (self->rollback)
{
free(self->rollback);
self->rb_alloc = 0;
self->rb_count = 0;
self->rollback = NULL;
}
if (self->deleted)
{
free(self->deleted);
self->dl_alloc = 0;
self->dl_count = 0;
self->deleted = NULL;
}
self->num_total_rows = 0;
self->num_backend_rows = 0;
mylog("QResult: free memory out\n");
}
/* This function is called by send_query() */
char
QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
{
int tuple_size;
/*
* If called from send_query the first time (conn != NULL), then set
* the inTuples state, and read the tuples. If conn is NULL, it
* implies that we are being called from next_tuple(), like to get
* more rows so don't call next_tuple again!
*/
if (conn != NULL)
{
ConnInfo *ci = &(conn->connInfo);
BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]);
self->conn = conn;
mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n", (cursor == NULL) ? "" : cursor, self->cursor);
if (self->cursor)
free(self->cursor);
self->cursor = NULL;
if (fetch_cursor)
{
if (!cursor || cursor[0] == '\0')
{
self->status = PGRES_INTERNAL_ERROR;
QR_set_message(self, "Internal Error -- no cursor for fetch");
return FALSE;
}
self->cursor = strdup(cursor);
}
/*
* Read the field attributes.
*
* $$$$ Should do some error control HERE! $$$$
*/
if (CI_read_fields(self->fields, self->conn))
{
self->status = PGRES_FIELDS_OK;
self->num_fields = CI_get_num_fields(self->fields);
if (self->haskeyset)
self->num_fields -= 2;
}
else
{
self->status = PGRES_BAD_RESPONSE;
QR_set_message(self, "Error reading field information");
return FALSE;
}
mylog("QR_fetch_tuples: past CI_read_fields: num_fields = %d\n", self->num_fields);
if (fetch_cursor)
{
if (self->cache_size <= 0)
self->cache_size = ci->drivers.fetch_max;
tuple_size = self->cache_size;
}
else
tuple_size = TUPLE_MALLOC_INC;
/* allocate memory for the tuple cache */
mylog("MALLOC: tuple_size = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size);
self->count_backend_allocated = self->count_keyset_allocated = 0;
if (self->num_fields > 0)
{
self->backend_tuples = (TupleField *) malloc(self->num_fields * sizeof(TupleField) * tuple_size);
if (!self->backend_tuples)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Could not get memory for tuple cache.");
return FALSE;
}
self->count_backend_allocated = tuple_size;
}
if (self->haskeyset)
{
if (self->keyset = (KeySet *) calloc(sizeof(KeySet), tuple_size), !self->keyset)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Could not get memory for tuple cache.");
return FALSE;
}
self->count_keyset_allocated = tuple_size;
}
self->inTuples = TRUE;
/* Force a read to occur in next_tuple */
self->num_total_rows = 0;
self->num_backend_rows = tuple_size + 1;
self->fetch_count = tuple_size + 1;
self->base = 0;
return QR_next_tuple(self);
}
else
{
/*
* Always have to read the field attributes. But we dont have to
* reallocate memory for them!
*/
if (!CI_read_fields(NULL, self->conn))
{
self->status = PGRES_BAD_RESPONSE;
QR_set_message(self, "Error reading field information");
return FALSE;
}
return TRUE;
}
}
/*
* Close the cursor and end the transaction (if no cursors left)
* We only close cursor/end the transaction if a cursor was used.
*/
int
QR_close(QResultClass *self)
{
QResultClass *res;
if (self->conn && self->cursor && self->conn->connInfo.drivers.use_declarefetch)
{
char buf[64];
sprintf(buf, "close %s", self->cursor);
mylog("QResult: closing cursor: '%s'\n", buf);
res = CC_send_query(self->conn, buf, NULL, CLEAR_RESULT_ON_ABORT);
self->inTuples = FALSE;
self->currTuple = -1;
free(self->cursor);
self->cursor = NULL;
if (res == NULL)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Error closing cursor.");
return FALSE;
}
QR_Destructor(res);
/* End the transaction if there are no cursors left on this conn */
if (CC_is_in_autocommit(self->conn) && CC_cursor_count(self->conn) == 0)
{
mylog("QResult: END transaction on conn=%u\n", self->conn);
if (!CC_commit(self->conn))
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Error ending transaction.");
return FALSE;
}
}
}
return TRUE;
}
/* This function is called by fetch_tuples() AND SQLFetch() */
int
QR_next_tuple(QResultClass *self)
{
int id;
QResultClass *res;
SocketClass *sock;
/* Speed up access */
int fetch_count = self->fetch_count;
int num_backend_rows = self->num_backend_rows;
int fetch_size,
offset = 0;
int end_tuple = self->rowset_size + self->base;
char corrected = FALSE;
TupleField *the_tuples = self->backend_tuples;
/* ERROR_MSG_LENGTH is sufficient */
static char msgbuffer[ERROR_MSG_LENGTH + 1];
/* QR_set_command() dups this string so doesn't need static */
char cmdbuffer[ERROR_MSG_LENGTH + 1];
char fetch[128];
QueryInfo qi;
ConnInfo *ci = NULL;
BOOL msg_truncated;
UDWORD abort_opt;
if (fetch_count < num_backend_rows)
{
/* return a row from cache */
mylog("next_tuple: fetch_count < fcount: returning tuple %d, fcount = %d\n", fetch_count, num_backend_rows);
self->tupleField = the_tuples + (fetch_count * self->num_fields); /* next row */
self->fetch_count++;
return TRUE;
}
else if (self->num_backend_rows < self->cache_size)
{
/* last row from cache */
/* We are done because we didn't even get CACHE_SIZE tuples */
mylog("next_tuple: fcount < CACHE_SIZE: fcount = %d, fetch_count = %d\n", num_backend_rows, fetch_count);
self->tupleField = NULL;
self->status = PGRES_END_TUPLES;
/* end of tuples */
return -1;
}
else
{
/*
* See if we need to fetch another group of rows. We may be being
* called from send_query(), and if so, don't send another fetch,
* just fall through and read the tuples.
*/
self->tupleField = NULL;
if (!self->inTuples)
{
ci = &(self->conn->connInfo);
if (!self->cursor || !ci->drivers.use_declarefetch)
{
mylog("next_tuple: ALL_ROWS: done, fcount = %d, fetch_count = %d\n", self->num_total_rows, fetch_count);
self->tupleField = NULL;
self->status = PGRES_END_TUPLES;
return -1; /* end of tuples */
}
if (self->base == num_backend_rows)
{
int row, lf;
TupleField *tuple = self->backend_tuples;
/* not a correction */
/* Determine the optimum cache size. */
if (ci->drivers.fetch_max % self->rowset_size == 0)
fetch_size = ci->drivers.fetch_max;
else if (self->rowset_size < ci->drivers.fetch_max)
fetch_size = (ci->drivers.fetch_max / self->rowset_size) * self->rowset_size;
else
fetch_size = self->rowset_size;
self->cache_size = fetch_size;
/* clear obsolete tuples */
inolog("clear obsolete %d tuples\n", num_backend_rows);
for (row = 0; row < num_backend_rows; row++)
{
for (lf = 0; lf < self->num_fields; lf++)
{
if (tuple[lf].value != NULL)
{
free(tuple[lf].value);
tuple[lf].value = NULL;
}
}
tuple += self->num_fields;
}
self->fetch_count = 1;
}
else
{
/* need to correct */
corrected = TRUE;
fetch_size = end_tuple - num_backend_rows;
self->cache_size += fetch_size;
offset = self->fetch_count;
self->fetch_count++;
}
if (!self->backend_tuples || self->cache_size > self->count_backend_allocated)
{
self->count_backend_allocated = 0;
if (self->num_fields > 0)
{
self->backend_tuples = (TupleField *) realloc(self->backend_tuples,
self->num_fields * sizeof(TupleField) * self->cache_size);
if (!self->backend_tuples)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Out of memory while reading tuples.");
return FALSE;
}
self->count_backend_allocated = self->cache_size;
}
}
if (self->haskeyset && (!self->keyset || self->cache_size > self->count_keyset_allocated))
{
self->count_keyset_allocated = 0;
self->keyset = (KeySet *) realloc(self->keyset, sizeof(KeySet) * self->cache_size);
self->count_keyset_allocated = self->cache_size;
}
sprintf(fetch, "fetch %d in %s", fetch_size, self->cursor);
mylog("next_tuple: sending actual fetch (%d) query '%s'\n", fetch_size, fetch);
/* don't read ahead for the next tuple (self) ! */
qi.row_size = self->cache_size;
qi.result_in = self;
qi.cursor = NULL;
res = CC_send_query(self->conn, fetch, &qi, CLEAR_RESULT_ON_ABORT);
if (res == NULL)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Error fetching next group.");
return FALSE;
}
self->inTuples = TRUE;
}
else
{
mylog("next_tuple: inTuples = true, falling through: fcount = %d, fetch_count = %d\n", self->num_backend_rows, self->fetch_count);
/*
* This is a pre-fetch (fetching rows right after query but
* before any real SQLFetch() calls. This is done so the
* field attributes are available.
*/
self->fetch_count = 0;
}
}
if (!corrected)
{
self->base = 0;
self->num_backend_rows = 0;
}
sock = CC_get_socket(self->conn);
self->tupleField = NULL;
ci = &(self->conn->connInfo);
for (;;)
{
id = SOCK_get_char(sock);
switch (id)
{
case 'T': /* Tuples within tuples cannot be handled */
self->status = PGRES_BAD_RESPONSE;
QR_set_message(self, "Tuples within tuples cannot be handled");
return FALSE;
case 'B': /* Tuples in binary format */
case 'D': /* Tuples in ASCII format */
if (!self->cursor || !ci->drivers.use_declarefetch)
{
if (self->num_fields > 0 &&
self->num_total_rows >= self->count_backend_allocated)
{
int tuple_size = self->count_backend_allocated;
mylog("REALLOC: old_count = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size);
tuple_size *= 2;
self->backend_tuples = (TupleField *) realloc(self->backend_tuples,
tuple_size * self->num_fields * sizeof(TupleField));
if (!self->backend_tuples)
{
self->status = PGRES_FATAL_ERROR;
QR_set_message(self, "Out of memory while reading tuples.");
return FALSE;
}
self->count_backend_allocated = tuple_size;
}
if (self->haskeyset &&
self->num_total_rows >= self->count_keyset_allocated)
{
int tuple_size = self->count_keyset_allocated;
tuple_size *= 2;
self->keyset = (KeySet *) realloc(self->keyset, sizeof(KeySet) * tuple_size);
self->count_keyset_allocated = tuple_size;
}
}
if (!QR_read_tuple(self, (char) (id == 0)))
{
self->status = PGRES_BAD_RESPONSE;
QR_set_message(self, "Error reading the tuple");
return FALSE;
}
self->num_total_rows++;
if (self->num_fields > 0)
self->num_backend_rows++;
break; /* continue reading */
case 'C': /* End of tuple list */
SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
QR_set_command(self, cmdbuffer);
mylog("end of tuple list -- setting inUse to false: this = %u\n", self);
self->inTuples = FALSE;
if (self->num_total_rows > 0)
{
qlog(" [ fetched %d rows ]\n", self->num_total_rows);
mylog("_next_tuple: 'C' fetch_max && fcount = %d\n", self->num_total_rows);
/* set to first row */
self->tupleField = self->backend_tuples + (offset * self->num_fields);
return TRUE;
}
else
{
/* We are surely done here (we read 0 tuples) */
qlog(" [ fetched 0 rows ]\n");
mylog("_next_tuple: 'C': DONE (fcount == 0)\n");
return -1; /* end of tuples */
}
case 'E': /* Error */
msg_truncated = SOCK_get_string(sock, msgbuffer,
ERROR_MSG_LENGTH);
/* Remove a newline */
if (msgbuffer[0] != '\0' && msgbuffer[strlen(msgbuffer) - 1] == '\n')
msgbuffer[strlen(msgbuffer) - 1] = '\0';
abort_opt = 0;
if (!strncmp(msgbuffer, "FATAL", 5))
abort_opt = NO_TRANS | CONN_DEAD;
CC_on_abort(self->conn, abort_opt);
QR_set_status(self, PGRES_FATAL_ERROR);
QR_set_message(self, msgbuffer);
QR_set_aborted(self, TRUE);
mylog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
qlog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
while (msg_truncated)
msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
return FALSE;
case 'N': /* Notice */
msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
QR_set_notice(self, cmdbuffer);
if (QR_command_successful(self))
QR_set_status(self, PGRES_NONFATAL_ERROR);
qlog("NOTICE from backend in next_tuple: '%s'\n", msgbuffer);
while (msg_truncated)
msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
continue;
default: /* this should only happen if the backend
* dumped core */
mylog("QR_next_tuple: Unexpected result from backend: id = '%c' (%d)\n", id, id);
qlog("QR_next_tuple: Unexpected result from backend: id = '%c' (%d)\n", id, id);
QR_set_message(self, "Unexpected result from backend. It probably crashed");
self->status = PGRES_FATAL_ERROR;
CC_on_abort(self->conn, NO_TRANS | CONN_DEAD);
return FALSE;
}
}
return TRUE;
}
char
QR_read_tuple(QResultClass *self, char binary)
{
Int2 field_lf;
TupleField *this_tuplefield;
KeySet *this_keyset = NULL;
char bmp,
bitmap[MAX_FIELDS]; /* Max. len of the bitmap */
Int2 bitmaplen; /* len of the bitmap in bytes */
Int2 bitmap_pos;
Int2 bitcnt;
Int4 len;
char *buffer;
int ci_num_fields = QR_NumResultCols(self); /* speed up access */
int num_fields = self->num_fields; /* speed up access */
SocketClass *sock = CC_get_socket(self->conn);
ColumnInfoClass *flds;
int effective_cols;
char tidoidbuf[32];
/* set the current row to read the fields into */
effective_cols = ci_num_fields;
this_tuplefield = self->backend_tuples + (self->num_backend_rows * num_fields);
if (self->haskeyset)
{
this_keyset = self->keyset + self->num_total_rows;
this_keyset->status = 0;
effective_cols -= 2;
}
bitmaplen = (Int2) ci_num_fields / BYTELEN;
if ((ci_num_fields % BYTELEN) > 0)
bitmaplen++;
/*
* At first the server sends a bitmap that indicates which database
* fields are null
*/
SOCK_get_n_char(sock, bitmap, bitmaplen);
bitmap_pos = 0;
bitcnt = 0;
bmp = bitmap[bitmap_pos];
flds = self->fields;
for (field_lf = 0; field_lf < ci_num_fields; field_lf++)
{
/* Check if the current field is NULL */
if (!(bmp & 0200))
{
/* YES, it is NULL ! */
this_tuplefield[field_lf].len = 0;
this_tuplefield[field_lf].value = 0;
}
else
{
/*
* NO, the field is not null. so get at first the length of
* the field (four bytes)
*/
len = SOCK_get_int(sock, VARHDRSZ);
if (!binary)
len -= VARHDRSZ;
if (field_lf >= effective_cols)
buffer = tidoidbuf;
else
buffer = (char *) malloc(len + 1);
SOCK_get_n_char(sock, buffer, len);
buffer[len] = '\0';
mylog("qresult: len=%d, buffer='%s'\n", len, buffer);
if (field_lf >= effective_cols)
{
if (field_lf == effective_cols)
sscanf(buffer, "(%lu,%hu)",
&this_keyset->blocknum, &this_keyset->offset);
else
this_keyset->oid = strtoul(buffer, NULL, 10);
}
else
{
this_tuplefield[field_lf].len = len;
this_tuplefield[field_lf].value = buffer;
/*
* This can be used to set the longest length of the column
* for any row in the tuple cache. It would not be accurate
* for varchar and text fields to use this since a tuple cache
* is only 100 rows. Bpchar can be handled since the strlen of
* all rows is fixed, assuming there are not 100 nulls in a
* row!
*/
if (flds && flds->display_size && flds->display_size[field_lf] < len)
flds->display_size[field_lf] = len;
}
}
/*
* Now adjust for the next bit to be scanned in the next loop.
*/
bitcnt++;
if (BYTELEN == bitcnt)
{
bitmap_pos++;
bmp = bitmap[bitmap_pos];
bitcnt = 0;
}
else
bmp <<= 1;
}
self->currTuple++;
return TRUE;
}

View File

@ -1,146 +0,0 @@
/* File: qresult.h
*
* Description: See "qresult.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __QRESULT_H__
#define __QRESULT_H__
#include "psqlodbc.h"
#include "connection.h"
#include "socket.h"
#include "columninfo.h"
#include "tuplelist.h"
#include "tuple.h"
enum QueryResultCode_
{
PGRES_EMPTY_QUERY = 0,
PGRES_COMMAND_OK, /* a query command that doesn't return */
/* anything was executed properly by the backend */
PGRES_TUPLES_OK, /* a query command that returns tuples */
/* was executed properly by the backend, PGresult */
/* contains the resulttuples */
PGRES_COPY_OUT,
PGRES_COPY_IN,
PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from
* the backend */
PGRES_NONFATAL_ERROR,
PGRES_FATAL_ERROR,
PGRES_FIELDS_OK, /* field information from a query was
* successful */
PGRES_END_TUPLES,
PGRES_INTERNAL_ERROR
};
typedef enum QueryResultCode_ QueryResultCode;
struct QResultClass_
{
ColumnInfoClass *fields; /* the Column information */
TupleListClass *manual_tuples; /* manual result tuple list */
ConnectionClass *conn; /* the connection this result is using
* (backend) */
QResultClass *next; /* the following result class */
/* Stuff for declare/fetch tuples */
int num_total_rows; /* total count of rows read in */
int count_backend_allocated;/* m(re)alloced count */
int count_keyset_allocated; /* m(re)alloced count */
int num_backend_rows; /* count of tuples kept in backend_tuples member */
int fetch_count; /* logical rows read so far */
int currTuple;
int base;
int num_fields; /* number of fields in the result */
int cache_size;
int rowset_size;
Int4 recent_processed_row_count;
QueryResultCode status;
char *message;
char *cursor; /* The name of the cursor for select
* statements */
char *command;
char *notice;
TupleField *backend_tuples; /* data from the backend (the tuple cache) */
TupleField *tupleField; /* current backend tuple being retrieved */
char inTuples; /* is a fetch of rows from the backend in
* progress? */
char aborted; /* was aborted? */
char haskeyset; /* this result contains keyset ? */
KeySet *keyset;
UInt2 rb_alloc; /* count of allocated rollback info */
UInt2 rb_count; /* count of rollback info */
Rollback *rollback;
UInt2 dl_alloc; /* count of allocated deleted info */
UInt2 dl_count; /* count of deleted info */
UInt4 *deleted;
};
#define QR_get_fields(self) (self->fields)
/* These functions are for retrieving data from the qresult */
#define QR_get_value_manual(self, tupleno, fieldno) (TL_get_fieldval(self->manual_tuples, tupleno, fieldno))
#define QR_get_value_backend(self, fieldno) (self->tupleField[fieldno].value)
#define QR_get_value_backend_row(self, tupleno, fieldno) ((self->backend_tuples + (tupleno * self->num_fields))[fieldno].value)
/* These functions are used by both manual and backend results */
#define QR_NumResultCols(self) (CI_get_num_fields(self->fields))
#define QR_get_fieldname(self, fieldno_) (CI_get_fieldname(self->fields, fieldno_))
#define QR_get_fieldsize(self, fieldno_) (CI_get_fieldsize(self->fields, fieldno_))
#define QR_get_display_size(self, fieldno_) (CI_get_display_size(self->fields, fieldno_))
#define QR_get_atttypmod(self, fieldno_) (CI_get_atttypmod(self->fields, fieldno_))
#define QR_get_field_type(self, fieldno_) (CI_get_oid(self->fields, fieldno_))
/* These functions are used only for manual result sets */
#define QR_get_num_total_tuples(self) (self->manual_tuples ? TL_get_num_tuples(self->manual_tuples) : self->num_total_rows)
#define QR_get_num_backend_tuples(self) (self->manual_tuples ? TL_get_num_tuples(self->manual_tuples) : self->num_backend_rows)
#define QR_add_tuple(self, new_tuple) (TL_add_tuple(self->manual_tuples, new_tuple))
#define QR_set_field_info(self, field_num, name, adtid, adtsize) (CI_set_field_info(self->fields, field_num, name, adtid, adtsize, -1))
/* status macros */
#define QR_command_successful(self) ( !(self->status == PGRES_BAD_RESPONSE || self->status == PGRES_NONFATAL_ERROR || self->status == PGRES_FATAL_ERROR))
#define QR_command_maybe_successful(self) ( !(self->status == PGRES_BAD_RESPONSE || self->status == PGRES_FATAL_ERROR))
#define QR_command_nonfatal(self) ( self->status == PGRES_NONFATAL_ERROR)
#define QR_end_tuples(self) ( self->status == PGRES_END_TUPLES)
#define QR_set_status(self, condition) ( self->status = condition )
#define QR_set_message(self, message_) ( self->message = message_)
#define QR_set_aborted(self, aborted_) ( self->aborted = aborted_)
#define QR_set_haskeyset(self) (self->haskeyset = TRUE)
#define QR_get_message(self) (self->message)
#define QR_get_command(self) (self->command)
#define QR_get_notice(self) (self->notice)
#define QR_get_status(self) (self->status)
#define QR_get_aborted(self) (self->aborted)
#define QR_aborted(self) (!self || self->aborted)
/* Core Functions */
QResultClass *QR_Constructor(void);
void QR_Destructor(QResultClass *self);
char QR_read_tuple(QResultClass *self, char binary);
int QR_next_tuple(QResultClass *self);
int QR_close(QResultClass *self);
char QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor);
void QR_free_memory(QResultClass *self);
void QR_set_command(QResultClass *self, char *msg);
void QR_set_notice(QResultClass *self, char *msg);
void QR_set_num_fields(QResultClass *self, int new_num_fields); /* manual result only */
void QR_inc_base(QResultClass *self, int base_inc);
void QR_set_cache_size(QResultClass *self, int cache_size);
void QR_set_rowset_size(QResultClass *self, int rowset_size);
void QR_set_position(QResultClass *self, int pos);
#endif

View File

@ -1,84 +0,0 @@
Readme for psqlodbc.dll 04/04/2001
-----------------------------------------------------------------------------------
Precompiled binaries for Win32 are available from ftp://ftp.postgresql.org/pub/odbc
I. Building the Driver from the source code
This section describes how to build the PostgreSQL ODBC Driver (psqlodbc.dll).
Microsoft Visual C++ version 4.0 or higher is required. Other compilers may work
but have not been formally tested. The psqlodbc.dll may be built either in the
VC++ IDE or from the command line:
IDE Method
----------
1. Create a new project workspace with the type DLL. For the name, type in the
name "psqlodbc".
2. The above step creates the directory "psqlodbc" under the
"\<Visual C++ top level directory>\projects" path to hold the source files.
(example, \msdev\projects\psqlodbc). Now, either unzip the source code release
into this directory or just copy all the files into this directory.
3. Insert all of the source files (*.c, *.h, *.rc, *.def) into the Visual project
using the "Insert files into project" command. You may have to do 2 inserts --
the first to get the 'c' and header files, and the second to get the def file.
Don't forget the .def file since it is an important part of the release.
You can even insert ".txt" files into the projects -- they will do nothing.
4. Add the "wsock32.lib" library to the end of the list of libraries for linking
using the Build settings menu.
5. Select the type of build on the toolbar (i.e., Release or Debug). This is
one of the useful features of the visual c++ environment in that you can
browse the entire project if you build the "Debug" release. For release
purposes however, select "Release" build.
6. Build the dll by selecting Build from the build menu.
7. When complete, the "psqlodbc.dll" file is under the "Release" subdirectory.
(i.e., "\msdev\projects\psqlodbc\release\psqlodbc.dll")
Command Line Method
-------------------
1. From a command prompt, CD to the directory containing the source code.
2. Use NMAKE to build the dll eg:
C:\psqlodbc\> nmake /f win32.mak CFG=Release ALL
Possible configurations are Release, Debug, MultiByteRelease or MultiByteDebug
Possible build types are ALL or CLEAN
II. Using Large Objects for handling LongVarBinary (OLE Objects in Access)
Large objects are mapped to LONGVARBINARY in the driver to allow storing things like
OLE objects in Microsoft Access. Multiple SQLPutData and SQLGetData calls are usually
used to send and retrieve these objects. The driver creates a new large object and simply
inserts its 'identifier' into the respective table. However, since Postgres uses an 'Oid'
to identify a Large Object, it is necessary to create a new Postgres type to be able
to discriminate between an ordinary Oid and a Large Object Oid. Until this new type
becomes an official part of Postgres, it must be added into the desired database and
looked up for each connection. The type used in the driver is simply called "lo" and
here is the command used to create it:
create type lo (internallength=4,externallength=10,input=int4in,output=int4out,
default='',passedbyvalue);
Once this is done, simply use the new 'lo' type to define columns in that database. Note
that this must be done for each database you want to use large objects in with the driver.
When the driver sees an 'lo' type, it will handle it as LONGVARBINARY.
Another important note is that this new type is lacking in functionality. It will not
cleanup after itself on updates and deletes, thus leaving orphans around and using up
extra disk space. And currently, Postgres does not support the vacuuming of large
objects. Hopefully in the future, a real large object data type will be available.
But for now, it sure is fun to stick a Word document, Visio document, or avi of a dancing
baby into a database column, even if you will fill up your server's hard disk after a while!

View File

@ -1,79 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by psqlodbc.rc
//
#define IDS_BADDSN 1
#define IDS_MSGTITLE 2
#define DLG_OPTIONS_DRV 102
#define DLG_OPTIONS_DS 103
#define DLG_OPTIONS_GLOBAL 104
#define IDC_DSNAME 400
#define IDC_DSNAMETEXT 401
#define IDC_DESC 404
#define IDC_SERVER 407
#define IDC_DATABASE 408
#define DLG_CONFIG 1001
#define IDC_PORT 1002
#define IDC_USER 1006
#define IDC_PASSWORD 1009
#define DS_READONLY 1011
#define DS_SHOWOIDCOLUMN 1012
#define DS_FAKEOIDINDEX 1013
#define DRV_COMMLOG 1014
#define DS_PG62 1016
#define IDC_DATASOURCE 1018
#define DRV_OPTIMIZER 1019
#define DS_CONNSETTINGS 1020
#define IDC_DRIVER 1021
#define DRV_CONNSETTINGS 1031
#define DRV_UNIQUEINDEX 1032
#define DRV_UNKNOWN_MAX 1035
#define DRV_UNKNOWN_DONTKNOW 1036
#define DRV_READONLY 1037
#define IDC_DESCTEXT 1039
#define DRV_MSG_LABEL 1040
#define DRV_UNKNOWN_LONGEST 1041
#define DRV_TEXT_LONGVARCHAR 1043
#define DRV_UNKNOWNS_LONGVARCHAR 1044
#define DRV_CACHE_SIZE 1045
#define DRV_VARCHAR_SIZE 1046
#define DRV_LONGVARCHAR_SIZE 1047
#define IDDEFAULTS 1048
#define DRV_USEDECLAREFETCH 1049
#define DRV_BOOLS_CHAR 1050
#define DS_SHOWSYSTEMTABLES 1051
#define DRV_EXTRASYSTABLEPREFIXES 1051
#define DS_ROWVERSIONING 1052
#define DRV_PARSE 1052
#define DRV_CANCELASFREESTMT 1053
#define IDC_OPTIONS 1054
#define DRV_KSQO 1055
#define DS_PG64 1057
#define DS_PG63 1058
#define DRV_OR_DSN 1059
#define DRV_DEBUG 1060
#define DS_DISALLOWPREMATURE 1061
#define DS_LFCONVERSION 1062
#define DS_TRUEISMINUS1 1063
#define DS_UPDATABLECURSORS 1064
#define IDNEXTPAGE 1065
#define IDPREVPAGE 1066
#define DS_INT8_AS_DEFAULT 1067
#define DS_INT8_AS_BIGINT 1068
#define DS_INT8_AS_NUMERIC 1069
#define DS_INT8_AS_VARCHAR 1070
#define DS_INT8_AS_DOUBLE 1071
#define DS_INT8_AS_INT4 1072
#define DRV_MSG_LABEL2 1073
#define IDAPPLY 1074
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1075
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,409 +0,0 @@
/*-------
* Module: setup.c
*
* Description: This module contains the setup functions for
* adding/modifying a Data Source in the ODBC.INI portion
* of the registry.
*
* Classes: n/a
*
* API functions: ConfigDSN
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "psqlodbc.h"
#include "connection.h"
#include <windowsx.h>
#include <string.h>
#include <stdlib.h>
#include "resource.h"
#include "dlg_specific.h"
#include "win_setup.h"
#define INTFUNC __stdcall
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
extern GLOBAL_VALUES globals;
/* Constants */
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#ifdef WIN32
#define MAXPGPATH (255+1)
#endif
#define MAXKEYLEN (15+1) /* Max keyword length */
#define MAXDESC (255+1) /* Max description length */
#define MAXDSNAME (32+1) /* Max data source name length */
/*--------
* ConfigDSN
*
* Description: ODBC Setup entry point
* This entry point is called by the ODBC Installer
* (see file header for more details)
* Input : hwnd ----------- Parent window handle
* fRequest ------- Request type (i.e., add, config, or remove)
* lpszDriver ----- Driver name
* lpszAttributes - data source attribute string
* Output : TRUE success, FALSE otherwise
*--------
*/
BOOL CALLBACK
ConfigDSN(HWND hwnd,
WORD fRequest,
LPCSTR lpszDriver,
LPCSTR lpszAttributes)
{
BOOL fSuccess; /* Success/fail flag */
GLOBALHANDLE hglbAttr;
LPSETUPDLG lpsetupdlg;
/* Allocate attribute array */
hglbAttr = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(SETUPDLG));
if (!hglbAttr)
return FALSE;
lpsetupdlg = (LPSETUPDLG) GlobalLock(hglbAttr);
/* Parse attribute string */
if (lpszAttributes)
ParseAttributes(lpszAttributes, lpsetupdlg);
/* Save original data source name */
if (lpsetupdlg->ci.dsn[0])
lstrcpy(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn);
else
lpsetupdlg->szDSN[0] = '\0';
/* Remove data source */
if (ODBC_REMOVE_DSN == fRequest)
{
/* Fail if no data source name was supplied */
if (!lpsetupdlg->ci.dsn[0])
fSuccess = FALSE;
/* Otherwise remove data source from ODBC.INI */
else
fSuccess = SQLRemoveDSNFromIni(lpsetupdlg->ci.dsn);
}
/* Add or Configure data source */
else
{
/* Save passed variables for global access (e.g., dialog access) */
lpsetupdlg->hwndParent = hwnd;
lpsetupdlg->lpszDrvr = lpszDriver;
lpsetupdlg->fNewDSN = (ODBC_ADD_DSN == fRequest);
lpsetupdlg->fDefault = !lstrcmpi(lpsetupdlg->ci.dsn, INI_DSN);
/*
* Display the appropriate dialog (if parent window handle
* supplied)
*/
if (hwnd)
{
/* Display dialog(s) */
fSuccess = (IDOK == DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_CONFIG),
hwnd,
ConfigDlgProc,
(LONG) (LPSTR) lpsetupdlg));
}
else if (lpsetupdlg->ci.dsn[0])
fSuccess = SetDSNAttributes(hwnd, lpsetupdlg);
else
fSuccess = FALSE;
}
GlobalUnlock(hglbAttr);
GlobalFree(hglbAttr);
return fSuccess;
}
/*-------
* CenterDialog
*
* Description: Center the dialog over the frame window
* Input : hdlg -- Dialog window handle
* Output : None
*-------
*/
void INTFUNC
CenterDialog(HWND hdlg)
{
HWND hwndFrame;
RECT rcDlg,
rcScr,
rcFrame;
int cx,
cy;
hwndFrame = GetParent(hdlg);
GetWindowRect(hdlg, &rcDlg);
cx = rcDlg.right - rcDlg.left;
cy = rcDlg.bottom - rcDlg.top;
GetClientRect(hwndFrame, &rcFrame);
ClientToScreen(hwndFrame, (LPPOINT) (&rcFrame.left));
ClientToScreen(hwndFrame, (LPPOINT) (&rcFrame.right));
rcDlg.top = rcFrame.top + (((rcFrame.bottom - rcFrame.top) - cy) >> 1);
rcDlg.left = rcFrame.left + (((rcFrame.right - rcFrame.left) - cx) >> 1);
rcDlg.bottom = rcDlg.top + cy;
rcDlg.right = rcDlg.left + cx;
GetWindowRect(GetDesktopWindow(), &rcScr);
if (rcDlg.bottom > rcScr.bottom)
{
rcDlg.bottom = rcScr.bottom;
rcDlg.top = rcDlg.bottom - cy;
}
if (rcDlg.right > rcScr.right)
{
rcDlg.right = rcScr.right;
rcDlg.left = rcDlg.right - cx;
}
if (rcDlg.left < 0)
rcDlg.left = 0;
if (rcDlg.top < 0)
rcDlg.top = 0;
MoveWindow(hdlg, rcDlg.left, rcDlg.top, cx, cy, TRUE);
return;
}
/*-------
* ConfigDlgProc
* Description: Manage add data source name dialog
* Input : hdlg --- Dialog window handle
* wMsg --- Message
* wParam - Message parameter
* lParam - Message parameter
* Output : TRUE if message processed, FALSE otherwise
*-------
*/
int CALLBACK
ConfigDlgProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
LPSETUPDLG lpsetupdlg;
ConnInfo *ci;
DWORD cmd;
switch (wMsg)
{
/* Initialize the dialog */
case WM_INITDIALOG:
lpsetupdlg = (LPSETUPDLG) lParam;
ci = &lpsetupdlg->ci;
/* Hide the driver connect message */
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
SetWindowText(GetDlgItem(hdlg, IDOK), "Save");
SetWindowLong(hdlg, DWL_USER, lParam);
CenterDialog(hdlg); /* Center dialog */
/*
* NOTE: Values supplied in the attribute string will always
*/
/* override settings in ODBC.INI */
memcpy(&ci->drivers, &globals, sizeof(globals));
/* Get the rest of the common attributes */
getDSNinfo(ci, CONN_DONT_OVERWRITE);
/* Fill in any defaults */
getDSNdefaults(ci);
/* Initialize dialog fields */
SetDlgStuff(hdlg, ci);
if (lpsetupdlg->fDefault)
{
EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE);
EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE);
}
else
SendDlgItemMessage(hdlg, IDC_DSNAME,
EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);
SendDlgItemMessage(hdlg, IDC_DESC,
EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
return TRUE; /* Focus was not set */
/* Process buttons */
case WM_COMMAND:
switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
{
/*
* Ensure the OK button is enabled only when a data
* source name
*/
/* is entered */
case IDC_DSNAME:
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
{
char szItem[MAXDSNAME]; /* Edit control text */
/* Enable/disable the OK button */
EnableWindow(GetDlgItem(hdlg, IDOK),
GetDlgItemText(hdlg, IDC_DSNAME,
szItem, sizeof(szItem)));
return TRUE;
}
break;
/* Accept results */
case IDOK:
case IDAPPLY:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
/* Retrieve dialog values */
if (!lpsetupdlg->fDefault)
GetDlgItemText(hdlg, IDC_DSNAME,
lpsetupdlg->ci.dsn,
sizeof(lpsetupdlg->ci.dsn));
/* Get Dialog Values */
GetDlgStuff(hdlg, &lpsetupdlg->ci);
/* Update ODBC.INI */
SetDSNAttributes(hdlg, lpsetupdlg);
if (IDAPPLY == cmd)
break;
/* Return to caller */
case IDCANCEL:
EndDialog(hdlg, wParam);
return TRUE;
case IDC_DATASOURCE:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) &lpsetupdlg->ci);
return TRUE;
case IDC_DRIVER:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);
return TRUE;
}
break;
}
/* Message not processed */
return FALSE;
}
/*-------
* ParseAttributes
*
* Description: Parse attribute string moving values into the aAttr array
* Input : lpszAttributes - Pointer to attribute string
* Output : None (global aAttr normally updated)
*-------
*/
void INTFUNC
ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
{
LPCSTR lpsz;
LPCSTR lpszStart;
char aszKey[MAXKEYLEN];
int cbKey;
char value[MAXPGPATH];
CC_conninfo_init(&(lpsetupdlg->ci));
for (lpsz = lpszAttributes; *lpsz; lpsz++)
{
/*
* Extract key name (e.g., DSN), it must be terminated by an
* equals
*/
lpszStart = lpsz;
for (;; lpsz++)
{
if (!*lpsz)
return; /* No key was found */
else if (*lpsz == '=')
break; /* Valid key found */
}
/* Determine the key's index in the key table (-1 if not found) */
cbKey = lpsz - lpszStart;
if (cbKey < sizeof(aszKey))
{
_fmemcpy(aszKey, lpszStart, cbKey);
aszKey[cbKey] = '\0';
}
/* Locate end of key value */
lpszStart = ++lpsz;
for (; *lpsz; lpsz++)
;
/* lpsetupdlg->aAttr[iElement].fSupplied = TRUE; */
_fmemcpy(value, lpszStart, MIN(lpsz - lpszStart + 1, MAXPGPATH));
mylog("aszKey='%s', value='%s'\n", aszKey, value);
/* Copy the appropriate value to the conninfo */
copyAttributes(&lpsetupdlg->ci, aszKey, value);
}
return;
}
/*--------
* SetDSNAttributes
*
* Description: Write data source attributes to ODBC.INI
* Input : hwnd - Parent window handle (plus globals)
* Output : TRUE if successful, FALSE otherwise
*--------
*/
BOOL INTFUNC
SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg)
{
LPCSTR lpszDSN; /* Pointer to data source name */
lpszDSN = lpsetupdlg->ci.dsn;
/* Validate arguments */
if (lpsetupdlg->fNewDSN && !*lpsetupdlg->ci.dsn)
return FALSE;
/* Write the data source name */
if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr))
{
if (hwndParent)
{
char szBuf[MAXPGPATH];
char szMsg[MAXPGPATH];
LoadString(s_hModule, IDS_BADDSN, szBuf, sizeof(szBuf));
wsprintf(szMsg, szBuf, lpszDSN);
LoadString(s_hModule, IDS_MSGTITLE, szBuf, sizeof(szBuf));
MessageBox(hwndParent, szMsg, szBuf, MB_ICONEXCLAMATION | MB_OK);
}
return FALSE;
}
/* Update ODBC.INI */
writeDriverCommoninfo(&lpsetupdlg->ci);
writeDSNinfo(&lpsetupdlg->ci);
/* If the data source name has changed, remove the old name */
if (lstrcmpi(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn))
SQLRemoveDSNFromIni(lpsetupdlg->szDSN);
return TRUE;
}

View File

@ -1,495 +0,0 @@
/*
# Insight Distribution Systems - System V - Apr 1998
#ident "@(#)setup.rul 1.13 :/sccs/sql/odbc/s.setup.rul 1/6/99 14:47:48"
*/
/*----------------------------------------------------------------------------*\
*
* PostgreSQL ODBC Driver Installation Script for InstallShield
*
\*----------------------------------------------------------------------------*/
#define APP_NAME "PostgreSQL ODBC Driver"
#define DRIVER_NAME "PostgreSQL"
#define DRIVER_FILE "PSQLODBC.DLL"
#define OLD_DRIVER_FILE "PODBC32.DLL"
#define OLD_DRIVER_FILE_RENAMED "podbc32_sav.dll"
#define COMPANY_NAME "Insight"
#define PRODUCT_NAME "PostgreSQL ODBC Driver"
#define PRODUCT_VERSION "6.3"
#define PRODUCT_KEY "PSQLODBC.DLL"
#define UNINSTALL_KEY "PSQLODBCv6.3"
#define ODBC_DM_KEY "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\SharedDLLs"
#define ODBC_COMP_KEY "\\SOFTWARE\\ODBC\\ODBCINST.INI"
#define ODBC_CORE_KEY "\\SOFTWARE\\ODBC\\ODBCINST.INI\\ODBC Core"
#define ODBC_DRIVERS_KEY "\\SOFTWARE\\ODBC\\ODBCINST.INI\\ODBC Drivers"
declare
// functions
prototype SetupScreen();
prototype FileCompare(STRING, STRING, STRING, STRING);
// variables
STRING svMainDirectory [_MAX_STRING], svGrp, svUninstLogFile, svPath;
STRING svValue, szName, szKey, szMessage;
STRING szMsg, szTmp, szTmp2, szFileSet, szProgram;
NUMBER nResult, pos, nvType, nvSize, nStartup, ComponentUsageCount;
NUMBER nvDoNot, nvVersion, nvInstall, nCore, nDM;
STRING dm, core, szFileName, svFileName;
NUMBER options, nvInfo, nvResult;
LONG lResult;
STRING svCompVersion, svFileVersion, svCompDate, svCompTime, svFileDate, svFileTime;
program
StartHere:
Disable( BACKGROUND );
// Set up the installation screen.
SetupScreen();
InstallationInfo(COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY);
RegDBSetAppInfo("Location", REGDB_STRING, WINSYSDIR ^ DRIVER_FILE, -1);
// Create a Welcome dialog.
WelcomeDlg:
Disable( BACKBUTTON );
Welcome( "Welcome to the PostgreSQL Odbc Driver Installation", 0 );
Enable( BACKBUTTON );
Enable( NEXTBUTTON );
GetTargetDirectory:
svMainDirectory = WINSYSDIR;
OptionsDlg:
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = ODBC_DM_KEY;
nCore = RegDBKeyExist(szKey);
szName = WINSYSDIR ^ "ODBC32.DLL";
nDM = RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize);
szMessage = "Select options for installing the ODBC Driver Manager.\n" +
"Analysis of your system suggests that the ODBC Driver Manager\n";
nvDoNot = FALSE;
nvInstall = FALSE;
nvVersion = FALSE;
if (nCore >= 0 && nDM >= 0) then
nvDoNot = TRUE;
szMessage = szMessage + "is already installed. Therefore, you may choose not to install it.";
else
nvInstall = TRUE;
szMessage = szMessage + "is not installed. Therefore, you should install it now.";
endif;
Enable(FINISHBUTTON);
nResult = AskOptions(EXCLUSIVE, szMessage,
"Do not install Driver Manager", nvDoNot,
"Install Driver Manager ", nvInstall,
"Install Driver Manager (with version checking)", nvVersion);
if (nResult = BACK) then
Disable(FINISHBUTTON);
goto WelcomeDlg;
endif;
Version:
CompressInfo("driver.z", DRIVER_FILE, COMP_INFO_VERSIONMS|COMP_INFO_VERSIONLS, nvInfo, svCompVersion);
szFileName = WINSYSDIR ^ DRIVER_FILE;
nResult = VerGetFileVersion(szFileName, svFileVersion);
// MessageBox("System file PSQLODBC.dll version is " + svFileVersion, INFORMATION);
lResult = VerCompare(svCompVersion, svFileVersion, VERSION);
if (lResult = EQUALS) then
//date
CompressInfo("driver.z", DRIVER_FILE, COMP_INFO_DATE, nvInfo, svCompDate);
GetFileInfo(szFileName, FILE_DATE, nvResult, svFileDate);
//time
CompressInfo("driver.z", DRIVER_FILE, COMP_INFO_TIME, nvInfo, svCompTime);
GetFileInfo(szFileName, FILE_TIME, nvResult, svFileTime);
// If compressed file date/time is earlier than system file date/time
// then
nResult = FileCompare(svCompDate, svCompTime, svFileDate, svFileTime);
if (nResult < 0) then
lResult = LESS_THAN;
endif;
NumToStr(szTmp, nResult);
// MessageBox("File Compare = " + szTmp, INFORMATION);
endif;
if (lResult = LESS_THAN) then
MessageBeep(0);
nResult = AskYesNo("The " + PRODUCT_NAME + " is already installed on your system \nand is a newer version than the one that is about to be installed.\n\n" +
"Would you like to continue the installation anyway (not recommended)?", NO);
if (nResult = NO) then
MessageBeep(0);
MessageBox("Installation has been aborted.\nNo changes have been made to your system.", WARNING);
exit;
endif;
else
/*
nResult = AskYesNo("Ready to install " + PRODUCT_NAME + ".\n\nPress Yes to proceed with the installation.\nPress No to abort the installation.", YES);
if (nResult = NO) then
MessageBeep(0);
MessageBox("Installation has been aborted.\nNo changes have been made to your system.", WARNING);
exit;
endif;
*/
endif;
CheckRegistry:
Enable(STATUSDLG);
SetStatusWindow(5, "Checking registry entries...");
Delay(1);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = ODBC_DM_KEY;
nResult = RegDBKeyExist(szKey);
if (nResult < 0 && nvDoNot = TRUE) then
MessageBeep(0);
MessageBox("ODBC Core Components are not installed!", SEVERE);
Disable(STATUSDLG);
MessageBeep(0);
MessageBox("Please install the ODBC Core Components\nand rerun this setup program.", INFORMATION);
exit;
endif;
szName = WINSYSDIR ^ "ODBC32.DLL";
nResult = RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize);
if (nResult < 0 && nvDoNot = TRUE) then
MessageBeep(0);
MessageBox("ODBC Driver Manager (ODBC32.DLL) is not installed!", SEVERE);
Disable(STATUSDLG);
MessageBeep(0);
MessageBox("Please install the ODBC Driver Manager\nand rerun this setup program.", INFORMATION);
exit;
endif;
FileSetup:
SetStatusWindow( 10, "Copying program files...");
StatusUpdate(ON, 90);
DeinstallStart(svMainDirectory, svUninstLogFile, UNINSTALL_KEY, 0);
// Show the uninstall under Add/Remove Programs in Control Panel
RegDBSetItem(REGDB_UNINSTALL_NAME, PRODUCT_NAME);
szFileSet = "psqlodbc";
TARGETDIR = svMainDirectory; // winsys
FileSetBeginDefine(szFileSet);
nResult = CompressGet("driver.z", "*.*", COMP_NORMAL);
if (nResult < 0) then
NumToStr(szTmp, nResult);
MessageBox("Compress Get Error on driver.z files.\n\nError # " + szTmp, SEVERE);
exit;
endif;
TARGETDIR = svMainDirectory; // winsys
// Driver Manager stuff
if (! nvDoNot) then
if (nvVersion) then
options = COMP_UPDATE_VERSION;
else
options = COMP_NORMAL;
endif;
// The File usage count increments are handled by CompressGet
// with the SHAREDFILE option.
nResult = CompressGet("redist.z", "*.*", options|SHAREDFILE);
if (nResult < 0) then
NumToStr(szTmp, nResult);
MessageBox("Compress Get Error on redist.z files.\n\nError # " + szTmp, SEVERE);
exit;
endif;
endif;
FileSetEndDefine(szFileSet);
FileTransfer:
nResult = FileSetPerformEz(szFileSet, 0);
switch(nResult)
case FS_DONE:
case FS_CREATEDIR:
MessageBeep(0);
MessageBox("Unable to create a required subdirectory under " + TARGETDIR + "."
+ "\nPlease check write access to this directory.", SEVERE);
abort;
default:
NumToStr(szTmp, nResult);
MessageBeep(0);
MessageBox("Error copying files to " + TARGETDIR + "."
+ "\nPlease check this location and try again."
+ "\n\nError Number:"+szTmp, SEVERE);
abort;
endswitch;
UpdateRegistry:
SetStatusWindow(95, "Creating registry entries...");
Delay(2);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
Disable(LOGGING);
// Create ODBC Core Subkey (if it doesn't exist)
// (But don't create uninstall information for it)
szKey = ODBC_CORE_KEY;
nResult = RegDBCreateKeyEx(szKey, "");
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create ODBC Core subkey.", SEVERE);
exit;
endif;
// Create Installed Driver Key (if it doesn't exist)
// (But don't create uninstall information for it)
szKey = ODBC_DRIVERS_KEY;
nResult = RegDBCreateKeyEx(szKey, "");
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create ODBC Drivers subkey.", SEVERE);
exit;
endif;
// Increment Driver Manager Component UsageCount
szKey = ODBC_CORE_KEY;
szName = "UsageCount";
if (RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize) < 0) then
ComponentUsageCount = 0;
endif;
// MessageBox("Current Driver Manager Component Usage Count = " + svValue, INFORMATION);
StrToNum(ComponentUsageCount, svValue);
ComponentUsageCount = ComponentUsageCount + 1;
NumToStr(szTmp, ComponentUsageCount);
// MessageBox("New Driver Manager Component Usage Count = " + szTmp, INFORMATION);
nResult = RegDBSetKeyValueEx(szKey, szName, REGDB_NUMBER, szTmp, -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to increment Driver Manager component usage count.", SEVERE);
exit;
endif;
// Re-enable logging now
Enable(LOGGING);
// set ODBC Drivers Subkey (installed)
szKey = ODBC_DRIVERS_KEY;
nResult = RegDBSetKeyValueEx(szKey, DRIVER_NAME, REGDB_STRING, "Installed", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'Installed' key value.", SEVERE);
exit;
endif;
// Driver Specification Subkey (PostgreSQL)
szKey = ODBC_COMP_KEY + "\\" + DRIVER_NAME;
nResult = RegDBCreateKeyEx(szKey, "");
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create ODBC Driver Key.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "APILevel", REGDB_STRING, "1", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'APILevel' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "ConnectFunctions", REGDB_STRING, "YYN", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'ConnectFunctions' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "Driver", REGDB_STRING, WINSYSDIR ^ DRIVER_FILE, -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'Driver' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "DriverODBCVer", REGDB_STRING, "02.00", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'DriverODBCVer' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "FileUsage", REGDB_STRING, "0", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'FileUsage' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "Setup", REGDB_STRING, WINSYSDIR ^ DRIVER_FILE, -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'Setup' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "SQLLevel", REGDB_STRING, "1", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'SQLLevel' key value.", SEVERE);
exit;
endif;
nResult = RegDBSetKeyValueEx(szKey, "UsageCount", REGDB_NUMBER, "1", -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'UsageCount' key value.", SEVERE);
exit;
endif;
pos = StrFind(CMDLINE, "UseDeclareFetch=");
if (pos >= 0) then
StrSub(svValue, CMDLINE, pos + 16, 1);
nResult = RegDBSetKeyValueEx(szKey, "UseDeclareFetch", REGDB_STRING, svValue, -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'UseDeclareFetch' key value.", SEVERE);
exit;
endif;
endif;
pos = StrFind(CMDLINE, "Protocol=");
if (pos >= 0) then
StrSub(svValue, CMDLINE, pos + 9, 3);
nResult = RegDBSetKeyValueEx(szKey, "Protocol", REGDB_STRING, svValue, -1);
if (nResult < 0) then
MessageBeep(0);
MessageBox("Unable to create 'Protocol' key value.", SEVERE);
exit;
endif;
endif;
RenameOld:
if (FindFile(WINSYSDIR, OLD_DRIVER_FILE, svFileName) = 0) then
szMessage = "Renaming old driver to " + OLD_DRIVER_FILE_RENAMED + " ...";
SetStatusWindow(98, szMessage);
Delay(1);
Disable(LOGGING);
SRCDIR= WINSYSDIR;
TARGETDIR = WINSYSDIR;
RenameFile(OLD_DRIVER_FILE, OLD_DRIVER_FILE_RENAMED);
Enable(LOGGING);
endif;
Done:
Delay(1);
SetStatusWindow(100, "Installation complete");
Delay(1);
Disable(STATUSDLG);
if (BATCH_INSTALL = TRUE) then
szMsg = "Some files could not be updated because they are " +
"currently in use by other programs on the system. " +
"Files in use will be updated the next time you restart " +
"your system.";
RebootDialog("Restart Windows", szMsg, SYS_BOOTMACHINE);
CommitSharedFiles(0);
szMsg = "Driver setup complete.\n\nReboot your system to complete the installation.";
MessageBeep(0);
MessageBox(szMsg, INFORMATION);
else
szMsg = "Driver installation completed successfully.";
MessageBeep(0);
MessageBox(szMsg, INFORMATION);
endif;
exit;
/*---------------------------------------------------------------------------*\
*
* Function: SetupScreen
*
* Purpose: This function will set up the screen look. This includes
* colors, fonts, text to be displayed, etc.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function SetupScreen()
begin
Enable( INDVFILESTATUS );
SetTitle( APP_NAME + " Setup", 28, WHITE );
SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
Enable( BACKGROUND );
end;
function FileCompare(szCompInfoDate, szCompInfoTime, szFileInfoDate, szFileInfoTime)
STRING year, month, day, file_date, file_time;
NUMBER nResult;
begin
StrSub(year, szFileInfoDate, 2, 2);
StrSub(month, szFileInfoDate, 5, 2);
StrSub(day, szFileInfoDate, 8, 2);
file_date = month + "-" + day + "-" + year;
nResult = StrCompare(szCompInfoDate, file_date);
if (nResult != 0) then
return nResult;
endif;
StrSub(file_time, szFileInfoTime, 0, 5);
// MessageBox("Comp = " + szCompInfoDate + " " + szCompInfoTime + ", File = " + file_date + " " + file_time, INFORMATION);
nResult = StrCompare(szCompInfoTime, file_time);
return nResult;
end;

View File

@ -1,354 +0,0 @@
/*-------
* Module: socket.c
*
* Description: This module contains functions for low level socket
* operations (connecting/reading/writing to the backend)
*
* Classes: SocketClass (Functions prefix: "SOCK_")
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "socket.h"
#include "connection.h"
#ifndef WIN32
#include <stdlib.h>
#include <string.h> /* for memset */
#endif
extern GLOBAL_VALUES globals;
#ifndef BOOL
#define BOOL int
#endif
#ifndef TRUE
#define TRUE (BOOL)1
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif
void
SOCK_clear_error(SocketClass *self)
{
self->errornumber = 0;
self->errormsg = NULL;
}
SocketClass *
SOCK_Constructor(const ConnectionClass *conn)
{
SocketClass *rv;
rv = (SocketClass *) malloc(sizeof(SocketClass));
if (rv != NULL)
{
rv->socket = (SOCKETFD) - 1;
rv->buffer_filled_in = 0;
rv->buffer_filled_out = 0;
rv->buffer_read_in = 0;
if (rv)
rv->buffer_size = conn->connInfo.drivers.socket_buffersize;
else
rv->buffer_size = globals.socket_buffersize;
rv->buffer_in = (unsigned char *) malloc(rv->buffer_size);
if (!rv->buffer_in)
{
free(rv);
return NULL;
}
rv->buffer_out = (unsigned char *) malloc(rv->buffer_size);
if (!rv->buffer_out)
{
free(rv->buffer_in);
free(rv);
return NULL;
}
rv->errormsg = NULL;
rv->errornumber = 0;
rv->reverse = FALSE;
}
return rv;
}
void
SOCK_Destructor(SocketClass *self)
{
mylog("SOCK_Destructor\n");
if (self->socket != -1)
{
SOCK_put_char(self, 'X');
SOCK_flush_output(self);
closesocket(self->socket);
}
if (self->buffer_in)
free(self->buffer_in);
if (self->buffer_out)
free(self->buffer_out);
free(self);
}
char
SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname)
{
struct hostent *host;
unsigned long iaddr;
if (self->socket != -1)
{
self->errornumber = SOCKET_ALREADY_CONNECTED;
self->errormsg = "Socket is already connected";
return 0;
}
memset((char *) &(self->sadr), 0, sizeof(self->sadr));
/*
* If it is a valid IP address, use it. Otherwise use hostname lookup.
*/
iaddr = inet_addr(hostname);
if (iaddr == INADDR_NONE)
{
host = gethostbyname(hostname);
if (host == NULL)
{
self->errornumber = SOCKET_HOST_NOT_FOUND;
self->errormsg = "Could not resolve hostname.";
return 0;
}
memcpy(&(self->sadr.sin_addr), host->h_addr, host->h_length);
}
else
memcpy(&(self->sadr.sin_addr), (struct in_addr *) & iaddr, sizeof(iaddr));
self->sadr.sin_family = AF_INET;
self->sadr.sin_port = htons(port);
self->socket = socket(AF_INET, SOCK_STREAM, 0);
if (self->socket == -1)
{
self->errornumber = SOCKET_COULD_NOT_CREATE_SOCKET;
self->errormsg = "Could not create Socket.";
return 0;
}
if (connect(self->socket, (struct sockaddr *) & (self->sadr),
sizeof(self->sadr)) < 0)
{
self->errornumber = SOCKET_COULD_NOT_CONNECT;
self->errormsg = "Could not connect to remote socket.";
closesocket(self->socket);
self->socket = (SOCKETFD) - 1;
return 0;
}
return 1;
}
void
SOCK_get_n_char(SocketClass *self, char *buffer, int len)
{
int lf;
if (!buffer)
{
self->errornumber = SOCKET_NULLPOINTER_PARAMETER;
self->errormsg = "get_n_char was called with NULL-Pointer";
return;
}
for (lf = 0; lf < len; lf++)
buffer[lf] = SOCK_get_next_byte(self);
}
void
SOCK_put_n_char(SocketClass *self, char *buffer, int len)
{
int lf;
if (!buffer)
{
self->errornumber = SOCKET_NULLPOINTER_PARAMETER;
self->errormsg = "put_n_char was called with NULL-Pointer";
return;
}
for (lf = 0; lf < len; lf++)
SOCK_put_next_byte(self, (unsigned char) buffer[lf]);
}
/*
* bufsize must include room for the null terminator
* will read at most bufsize-1 characters + null.
* returns TRUE if truncation occurs.
*/
BOOL
SOCK_get_string(SocketClass *self, char *buffer, int bufsize)
{
register int lf = 0;
for (lf = 0; lf < bufsize - 1; lf++)
if (!(buffer[lf] = SOCK_get_next_byte(self)))
return FALSE;
buffer[bufsize - 1] = '\0';
return TRUE;
}
void
SOCK_put_string(SocketClass *self, char *string)
{
register int lf;
int len;
len = strlen(string) + 1;
for (lf = 0; lf < len; lf++)
SOCK_put_next_byte(self, (unsigned char) string[lf]);
}
int
SOCK_get_int(SocketClass *self, short len)
{
switch (len)
{
case 2:
{
unsigned short buf;
SOCK_get_n_char(self, (char *) &buf, len);
if (self->reverse)
return buf;
else
return ntohs(buf);
}
case 4:
{
unsigned int buf;
SOCK_get_n_char(self, (char *) &buf, len);
if (self->reverse)
return buf;
else
return ntohl(buf);
}
default:
self->errornumber = SOCKET_GET_INT_WRONG_LENGTH;
self->errormsg = "Cannot read ints of that length";
return 0;
}
}
void
SOCK_put_int(SocketClass *self, int value, short len)
{
unsigned int rv;
switch (len)
{
case 2:
rv = self->reverse ? value : htons((unsigned short) value);
SOCK_put_n_char(self, (char *) &rv, 2);
return;
case 4:
rv = self->reverse ? value : htonl((unsigned int) value);
SOCK_put_n_char(self, (char *) &rv, 4);
return;
default:
self->errornumber = SOCKET_PUT_INT_WRONG_LENGTH;
self->errormsg = "Cannot write ints of that length";
return;
}
}
void
SOCK_flush_output(SocketClass *self)
{
int written;
written = send(self->socket, (char *) self->buffer_out, self->buffer_filled_out, 0);
if (written != self->buffer_filled_out)
{
self->errornumber = SOCKET_WRITE_ERROR;
self->errormsg = "Could not flush socket buffer.";
}
self->buffer_filled_out = 0;
}
unsigned char
SOCK_get_next_byte(SocketClass *self)
{
if (self->buffer_read_in >= self->buffer_filled_in)
{
/*
* there are no more bytes left in the buffer so reload the buffer
*/
self->buffer_read_in = 0;
self->buffer_filled_in = recv(self->socket, (char *) self->buffer_in, self->buffer_size, 0);
mylog("read %d, global_socket_buffersize=%d\n", self->buffer_filled_in, self->buffer_size);
if (self->buffer_filled_in < 0)
{
self->errornumber = SOCKET_READ_ERROR;
self->errormsg = "Error while reading from the socket.";
self->buffer_filled_in = 0;
return 0;
}
if (self->buffer_filled_in == 0)
{
self->errornumber = SOCKET_CLOSED;
self->errormsg = "Socket has been closed.";
self->buffer_filled_in = 0;
return 0;
}
}
return self->buffer_in[self->buffer_read_in++];
}
void
SOCK_put_next_byte(SocketClass *self, unsigned char next_byte)
{
int bytes_sent;
self->buffer_out[self->buffer_filled_out++] = next_byte;
if (self->buffer_filled_out == self->buffer_size)
{
/* buffer is full, so write it out */
bytes_sent = send(self->socket, (char *) self->buffer_out, self->buffer_size, 0);
if (bytes_sent != self->buffer_size)
{
self->errornumber = SOCKET_WRITE_ERROR;
self->errormsg = "Error while writing to the socket.";
}
self->buffer_filled_out = 0;
}
}

View File

@ -1,95 +0,0 @@
/* File: socket.h
*
* Description: See "socket.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __SOCKET_H__
#define __SOCKET_H__
#include "psqlodbc.h"
#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define closesocket(xxx) close(xxx)
#define SOCKETFD int
#ifndef INADDR_NONE
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
typedef unsigned int in_addr_t;
#endif
#define INADDR_NONE ((in_addr_t)-1)
#endif
#else
#include <winsock.h>
#define SOCKETFD SOCKET
#endif
#define SOCKET_ALREADY_CONNECTED 1
#define SOCKET_HOST_NOT_FOUND 2
#define SOCKET_COULD_NOT_CREATE_SOCKET 3
#define SOCKET_COULD_NOT_CONNECT 4
#define SOCKET_READ_ERROR 5
#define SOCKET_WRITE_ERROR 6
#define SOCKET_NULLPOINTER_PARAMETER 7
#define SOCKET_PUT_INT_WRONG_LENGTH 8
#define SOCKET_GET_INT_WRONG_LENGTH 9
#define SOCKET_CLOSED 10
struct SocketClass_
{
int buffer_size;
int buffer_filled_in;
int buffer_filled_out;
int buffer_read_in;
unsigned char *buffer_in;
unsigned char *buffer_out;
SOCKETFD socket;
char *errormsg;
int errornumber;
struct sockaddr_in sadr; /* Used for handling connections for cancel */
char reverse; /* used to handle Postgres 6.2 protocol
* (reverse byte order) */
};
#define SOCK_get_char(self) (SOCK_get_next_byte(self))
#define SOCK_put_char(self, c) (SOCK_put_next_byte(self, c))
/* error functions */
#define SOCK_get_errcode(self) (self->errornumber)
#define SOCK_get_errmsg(self) (self->errormsg)
/* Socket prototypes */
SocketClass *SOCK_Constructor(const ConnectionClass *conn);
void SOCK_Destructor(SocketClass *self);
char SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname);
void SOCK_get_n_char(SocketClass *self, char *buffer, int len);
void SOCK_put_n_char(SocketClass *self, char *buffer, int len);
BOOL SOCK_get_string(SocketClass *self, char *buffer, int bufsize);
void SOCK_put_string(SocketClass *self, char *string);
int SOCK_get_int(SocketClass *self, short len);
void SOCK_put_int(SocketClass *self, int value, short len);
void SOCK_flush_output(SocketClass *self);
unsigned char SOCK_get_next_byte(SocketClass *self);
void SOCK_put_next_byte(SocketClass *self, unsigned char next_byte);
void SOCK_clear_error(SocketClass *self);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,248 +0,0 @@
/* File: statement.h
*
* Description: See "statement.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __STATEMENT_H__
#define __STATEMENT_H__
#include "psqlodbc.h"
#include "bind.h"
#include "descriptor.h"
#ifndef FALSE
#define FALSE (BOOL)0
#endif
#ifndef TRUE
#define TRUE (BOOL)1
#endif
typedef enum
{
STMT_ALLOCATED, /* The statement handle is allocated, but
* not used so far */
STMT_READY, /* the statement is waiting to be executed */
STMT_PREMATURE, /* ODBC states that it is legal to call
* e.g. SQLDescribeCol before a call to
* SQLExecute, but after SQLPrepare. To
* get all the necessary information in
* such a case, we simply execute the
* query _before_ the actual call to
* SQLExecute, so that statement is
* considered to be "premature". */
STMT_FINISHED, /* statement execution has finished */
STMT_EXECUTING /* statement execution is still going on */
} STMT_Status;
#define STMT_ROW_VERSION_CHANGED (-4)
#define STMT_POS_BEFORE_RECORDSET (-3)
#define STMT_TRUNCATED (-2)
#define STMT_INFO_ONLY (-1) /* not an error message,
* just a notification
* to be returned by
* SQLError */
#define STMT_OK 0 /* will be interpreted
* as "no error pending" */
#define STMT_EXEC_ERROR 1
#define STMT_STATUS_ERROR 2
#define STMT_SEQUENCE_ERROR 3
#define STMT_NO_MEMORY_ERROR 4
#define STMT_COLNUM_ERROR 5
#define STMT_NO_STMTSTRING 6
#define STMT_ERROR_TAKEN_FROM_BACKEND 7
#define STMT_INTERNAL_ERROR 8
#define STMT_STILL_EXECUTING 9
#define STMT_NOT_IMPLEMENTED_ERROR 10
#define STMT_BAD_PARAMETER_NUMBER_ERROR 11
#define STMT_OPTION_OUT_OF_RANGE_ERROR 12
#define STMT_INVALID_COLUMN_NUMBER_ERROR 13
#define STMT_RESTRICTED_DATA_TYPE_ERROR 14
#define STMT_INVALID_CURSOR_STATE_ERROR 15
#define STMT_OPTION_VALUE_CHANGED 16
#define STMT_CREATE_TABLE_ERROR 17
#define STMT_NO_CURSOR_NAME 18
#define STMT_INVALID_CURSOR_NAME 19
#define STMT_INVALID_ARGUMENT_NO 20
#define STMT_ROW_OUT_OF_RANGE 21
#define STMT_OPERATION_CANCELLED 22
#define STMT_INVALID_CURSOR_POSITION 23
#define STMT_VALUE_OUT_OF_RANGE 24
#define STMT_OPERATION_INVALID 25
#define STMT_PROGRAM_TYPE_OUT_OF_RANGE 26
#define STMT_BAD_ERROR 27
#define STMT_INVALID_OPTION_IDENTIFIER 28
#define STMT_RETURN_NULL_WITHOUT_INDICATOR 29
#define STMT_ERROR_IN_ROW 30
#define STMT_INVALID_DESCRIPTOR_IDENTIFIER 31
#define STMT_OPTION_NOT_FOR_THE_DRIVER 32
#define STMT_FETCH_OUT_OF_RANGE 33
/* statement types */
enum
{
STMT_TYPE_UNKNOWN = -2,
STMT_TYPE_OTHER = -1,
STMT_TYPE_SELECT = 0,
STMT_TYPE_INSERT,
STMT_TYPE_UPDATE,
STMT_TYPE_DELETE,
STMT_TYPE_CREATE,
STMT_TYPE_ALTER,
STMT_TYPE_DROP,
STMT_TYPE_GRANT,
STMT_TYPE_REVOKE,
STMT_TYPE_PROCCALL,
STMT_TYPE_LOCK
};
#define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT)
/* Parsing status */
enum
{
STMT_PARSE_NONE = 0,
STMT_PARSE_COMPLETE,
STMT_PARSE_INCOMPLETE,
STMT_PARSE_FATAL,
};
/* Result style */
enum
{
STMT_FETCH_NONE = 0,
STMT_FETCH_NORMAL,
STMT_FETCH_EXTENDED,
};
/******** Statement Handle ***********/
struct StatementClass_
{
ConnectionClass *hdbc; /* pointer to ConnectionClass this
* statement belongs to */
QResultClass *result; /* result of the current statement */
QResultClass *curres; /* the current result in the chain */
HSTMT FAR *phstmt;
StatementOptions options;
ARDFields ardopts;
IRDFields irdopts;
APDFields apdopts;
IPDFields ipdopts;
STMT_Status status;
char *errormsg;
int errornumber;
Int4 currTuple; /* current absolute row number (GetData,
* SetPos, SQLFetch) */
int save_rowset_size; /* saved rowset size in case of
* change/FETCH_NEXT */
int rowset_start; /* start of rowset (an absolute row
* number) */
int bind_row; /* current offset for Multiple row/column
* binding */
int last_fetch_count; /* number of rows retrieved in
* last fetch/extended fetch */
int current_col; /* current column for GetData -- used to
* handle multiple calls */
int lobj_fd; /* fd of the current large object */
char *statement; /* if non--null pointer to the SQL
* statement that has been executed */
TABLE_INFO **ti;
int ntab;
int parse_status;
int statement_type; /* According to the defines above */
int data_at_exec; /* Number of params needing SQLPutData */
int current_exec_param; /* The current parameter for
* SQLPutData */
char put_data; /* Has SQLPutData been called yet? */
char errormsg_created; /* has an informative error msg
* been created? */
char manual_result; /* Is the statement result manually built? */
char prepare; /* is this statement a prepared statement
* or direct */
char internal; /* Is this statement being called
* internally? */
char cursor_name[MAX_CURSOR_LEN + 1];
char *stmt_with_params; /* statement after parameter
* substitution */
int stmt_size_limit;
int exec_start_row;
int exec_end_row;
int exec_current_row;
char pre_executing; /* This statement is prematurely executing */
char inaccurate_result; /* Current status is PREMATURE but
* result is inaccurate */
char miscinfo;
char updatable;
SWORD errorpos;
SWORD error_recsize;
Int4 diag_row_count;
char *load_statement; /* to (re)load updatable individual rows */
Int4 from_pos;
Int4 where_pos;
Int4 last_fetch_count_include_ommitted;
};
#define SC_get_conn(a) (a->hdbc)
#define SC_set_Result(a, b) (a->result = a->curres = b)
#define SC_get_Result(a) (a->result)
#define SC_set_Curres(a, b) (a->curres = b)
#define SC_get_Curres(a) (a->curres)
#define SC_get_ARD(a) (&(a->ardopts))
#define SC_get_APD(a) (&(a->apdopts))
#define SC_get_IRD(a) (&(a->irdopts))
#define SC_get_IPD(a) (&(a->ipdopts))
/* options for SC_free_params() */
#define STMT_FREE_PARAMS_ALL 0
#define STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY 1
/* misc info */
#define SC_set_pre_executable(a) (a->miscinfo |= 1L)
#define SC_no_pre_executable(a) (a->miscinfo &= ~1L)
#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0)
#define SC_set_fetchcursor(a) (a->miscinfo |= 2L)
#define SC_no_fetchcursor(a) (a->miscinfo &= ~2L)
#define SC_is_fetchcursor(a) ((a->miscinfo & 2L) != 0)
/* Statement prototypes */
StatementClass *SC_Constructor(void);
void InitializeStatementOptions(StatementOptions *opt);
char SC_Destructor(StatementClass *self);
int statement_type(char *statement);
char parse_statement(StatementClass *stmt);
void SC_pre_execute(StatementClass *self);
char SC_unbind_cols(StatementClass *self);
char SC_recycle_statement(StatementClass *self);
void SC_clear_error(StatementClass *self);
char SC_get_error(StatementClass *self, int *number, char **message);
char *SC_create_errormsg(StatementClass *self);
RETCODE SC_execute(StatementClass *self);
RETCODE SC_fetch(StatementClass *self);
void SC_free_params(StatementClass *self, char option);
void SC_log_error(const char *func, const char *desc, const StatementClass *self);
unsigned long SC_get_bookmark(StatementClass *self);
RETCODE SC_pos_update(StatementClass *self, UWORD irow, UDWORD index);
RETCODE SC_pos_delete(StatementClass *self, UWORD irow, UDWORD index);
RETCODE SC_pos_refresh(StatementClass *self, UWORD irow, UDWORD index);
RETCODE SC_pos_add(StatementClass *self, UWORD irow);
#endif

View File

@ -1,66 +0,0 @@
/*-------
* Module: tuple.c
*
* Description: This module contains functions for setting the data
* for individual fields (TupleField structure) of a
* manual result set.
*
* Important Note: These functions are ONLY used in building manual
* result sets for info functions (SQLTables,
* SQLColumns, etc.)
*
* Classes: n/a
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*-------
*/
#include "tuple.h"
#include <string.h>
#include <stdlib.h>
void
set_tuplefield_null(TupleField *tuple_field)
{
tuple_field->len = 0;
tuple_field->value = NULL; /* strdup(""); */
}
void
set_tuplefield_string(TupleField *tuple_field, char *string)
{
tuple_field->len = strlen(string);
tuple_field->value = malloc(strlen(string) + 1);
strcpy(tuple_field->value, string);
}
void
set_tuplefield_int2(TupleField *tuple_field, Int2 value)
{
char buffer[10];
sprintf(buffer, "%d", value);
tuple_field->len = strlen(buffer) + 1;
/* +1 ... is this correct (better be on the save side-...) */
tuple_field->value = strdup(buffer);
}
void
set_tuplefield_int4(TupleField *tuple_field, Int4 value)
{
char buffer[15];
sprintf(buffer, "%ld", value);
tuple_field->len = strlen(buffer) + 1;
/* +1 ... is this correct (better be on the save side-...) */
tuple_field->value = strdup(buffer);
}

View File

@ -1,72 +0,0 @@
/* File: tuple.h
*
* Description: See "tuple.c"
*
* Important NOTE: The TupleField structure is used both to hold backend data and
* manual result set data. The "set_" functions and the TupleNode
* structure are only used for manual result sets by info routines.
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __TUPLE_H__
#define __TUPLE_H__
#include "psqlodbc.h"
/* Used by backend data AND manual result sets */
struct TupleField_
{
Int4 len; /* length of the current Tuple */
void *value; /* an array representing the value */
};
/* Used ONLY for manual result sets */
struct TupleNode_
{
struct TupleNode_ *prev,
*next;
TupleField tuple[1];
};
/* keyset(TID + OID) info */
struct KeySet_
{
UWORD status;
UWORD offset;
UDWORD blocknum;
UDWORD oid;
};
/* Rollback(index + original TID) info */
struct Rollback_
{
UDWORD index;
UDWORD blocknum;
UWORD offset;
};
#define KEYSET_INFO_PUBLIC 0x07
#define CURS_SELF_ADDING (1L << 3)
#define CURS_SELF_DELETING (1L << 4)
#define CURS_SELF_UPDATING (1L << 5)
#define CURS_SELF_ADDED (1L << 6)
#define CURS_SELF_DELETED (1L << 7)
#define CURS_SELF_UPDATED (1L << 8)
#define CURS_NEEDS_REREAD (1L << 9)
#define CURS_IN_ROWSET (1L << 10)
#define CURS_OTHER_DELETED (1L << 11)
/* These macros are wrappers for the corresponding set_tuplefield functions
but these handle automatic NULL determination and call set_tuplefield_null()
if appropriate for the datatype (used by SQLGetTypeInfo).
*/
#define set_nullfield_string(FLD, VAL) ((VAL) ? set_tuplefield_string(FLD, (VAL)) : set_tuplefield_null(FLD))
#define set_nullfield_int2(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int2(FLD, (VAL)) : set_tuplefield_null(FLD))
#define set_nullfield_int4(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int4(FLD, (VAL)) : set_tuplefield_null(FLD))
void set_tuplefield_null(TupleField *tuple_field);
void set_tuplefield_string(TupleField *tuple_field, char *string);
void set_tuplefield_int2(TupleField *tuple_field, Int2 value);
void set_tuplefield_int4(TupleField *tuple_field, Int4 value);
#endif

View File

@ -1,216 +0,0 @@
/*--------
* Module: tuplelist.c
*
* Description: This module contains functions for creating a manual
* result set (the TupleList) and retrieving data from
* it for a specific row/column.
*
* Classes: TupleListClass (Functions prefix: "TL_")
*
* API functions: none
*
* Comments: See "notice.txt" for copyright and license information.
*--------
*/
#include "tuplelist.h"
#include <stdlib.h>
#include "tuple.h"
TupleListClass *
TL_Constructor(UInt4 fieldcnt)
{
TupleListClass *rv;
mylog("in TL_Constructor\n");
rv = (TupleListClass *) malloc(sizeof(TupleListClass));
if (rv)
{
rv->num_fields = fieldcnt;
rv->num_tuples = 0;
rv->list_start = NULL;
rv->list_end = NULL;
rv->lastref = NULL;
rv->last_indexed = -1;
}
mylog("exit TL_Constructor\n");
return rv;
}
void
TL_Destructor(TupleListClass *self)
{
int lf;
TupleNode *node,
*tp;
mylog("TupleList: in DESTRUCTOR\n");
node = self->list_start;
while (node != NULL)
{
for (lf = 0; lf < self->num_fields; lf++)
if (node->tuple[lf].value != NULL)
free(node->tuple[lf].value);
tp = node->next;
free(node);
node = tp;
}
free(self);
mylog("TupleList: exit DESTRUCTOR\n");
}
void *
TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno)
{
Int4 lf;
Int4 delta,
from_end;
char end_is_closer,
start_is_closer;
TupleNode *rv;
if (self->last_indexed == -1)
/* we have an empty tuple list */
return NULL;
/* some more sanity checks */
if ((tupleno >= self->num_tuples) || (tupleno < 0))
/* illegal tuple number range */
return NULL;
if ((fieldno >= self->num_fields) || (fieldno < 0))
/* illegel field number range */
return NULL;
/*
* check if we are accessing the same tuple that was used in the last
* fetch (e.g: for fetching all the fields one after another. Do this
* to speed things up
*/
if (tupleno == self->last_indexed)
return self->lastref->tuple[fieldno].value;
/* now for the tricky part... */
/*
* Since random access is quite inefficient for linked lists we use
* the lastref pointer that points to the last element referenced by a
* get_fieldval() call in conjunction with the its index number that
* is stored in last_indexed. (So we use some locality of reference
* principle to speed things up)
*/
delta = tupleno - self->last_indexed;
/* if delta is positive, we have to go forward */
/*
* now check if we are closer to the start or the end of the list than
* to our last_indexed pointer
*/
from_end = (self->num_tuples - 1) - tupleno;
start_is_closer = labs(delta) > tupleno;
/*
* true if we are closer to the start of the list than to the
* last_indexed pointer
*/
end_is_closer = labs(delta) > from_end;
/* true if we are closer at the end of the list */
if (end_is_closer)
{
/* scanning from the end is the shortest way. so we do that... */
rv = self->list_end;
for (lf = 0; lf < from_end; lf++)
rv = rv->prev;
}
else if (start_is_closer)
{
/*
* the shortest way is to start the search from the head of the
* list
*/
rv = self->list_start;
for (lf = 0; lf < tupleno; lf++)
rv = rv->next;
}
else
{
/* the closest way is starting from our lastref - pointer */
rv = self->lastref;
/*
* at first determine whether we have to search forward or
* backwards
*/
if (delta < 0)
{
/* we have to search backwards */
for (lf = 0; lf < (-1) * delta; lf++)
rv = rv->prev;
}
else
{
/* ok, we have to search forward... */
for (lf = 0; lf < delta; lf++)
rv = rv->next;
}
}
/*
* now we have got our return pointer, so update the lastref and the
* last_indexed values
*/
self->lastref = rv;
self->last_indexed = tupleno;
return rv->tuple[fieldno].value;
}
char
TL_add_tuple(TupleListClass *self, TupleNode *new_field)
{
/*
* we append the tuple at the end of the doubly linked list of the
* tuples we have already read in
*/
new_field->prev = NULL;
new_field->next = NULL;
if (self->list_start == NULL)
{
/* the list is empty, we have to add the first tuple */
self->list_start = new_field;
self->list_end = new_field;
self->lastref = new_field;
self->last_indexed = 0;
}
else
{
/*
* there is already an element in the list, so add the new one at
* the end of the list
*/
self->list_end->next = new_field;
new_field->prev = self->list_end;
self->list_end = new_field;
}
self->num_tuples++;
/* this method of building a list cannot fail, so we return 1 */
return 1;
}

View File

@ -1,35 +0,0 @@
/* File: tuplelist.h
*
* Description: See "tuplelist.c"
*
* Important Note: This structure and its functions are ONLY used in building manual result
* sets for info functions (SQLTables, SQLColumns, etc.)
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __TUPLELIST_H__
#define __TUPLELIST_H__
#include "psqlodbc.h"
struct TupleListClass_
{
Int4 num_fields;
Int4 num_tuples;
TupleNode *list_start,
*list_end,
*lastref;
Int4 last_indexed;
};
#define TL_get_num_tuples(x) (x->num_tuples)
/* Create a TupleList. Each tuple consits of fieldcnt columns */
TupleListClass *TL_Constructor(UInt4 fieldcnt);
void TL_Destructor(TupleListClass *self);
void *TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno);
char TL_add_tuple(TupleListClass *self, TupleNode *new_field);
#endif

View File

@ -1,16 +0,0 @@
/* File: version.h
*
* Description: This file defines the driver version.
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __VERSION_H__
#define __VERSION_H__
#define POSTGRESDRIVERVERSION "07.02.0002"
#define POSTGRES_RESOURCE_VERSION "07.02.0002\0"
#define PG_DRVFILE_VERSION 7,2,0,02
#endif

View File

@ -1,511 +0,0 @@
#
# File: win32.mak
#
# Description: psqlodbc Makefile for Win32.
#
# Configurations: Debug, Release, MultibyteDebug, MultibyteRelease
# Build Types: ALL, CLEAN
# Usage: NMAKE /f win32.mak CFG=[Release | Debug | MultibyteRelease | MultiByteDebug] [ALL | CLEAN]
#
# Comments: Created by Dave Page, 2001-02-12
#
!MESSAGE Building the PostgreSQL ODBC Driver for Win32...
!MESSAGE
!IF "$(CFG)" == ""
CFG=MultibyteRelease
!MESSAGE No configuration specified. Defaulting to Release.
!MESSAGE
!ENDIF
!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug" && "$(CFG)" != "MultibyteRelease" && "$(CFG)" != "MultibyteDebug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f win32.mak CFG=[Release | Debug | MultibyteRelease | MultiByteDebug] [ALL | CLEAN]
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Release" (Win32 Release DLL)
!MESSAGE "Debug" (Win32 Debug DLL)
!MESSAGE "MultibyteRelease" (Win32 Release DLL with Multibyte support)
!MESSAGE "MultibyteDebug" (Win32 Debug DLL with Multibyte support)
!MESSAGE
!ERROR An invalid configuration was specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "Release" || "$(CFG)" == "MultibyteRelease"
!IF "$(CFG)" == "MultibyteRelease"
OUTDIR=.\MultibyteRelease
OUTDIRBIN=.\MultibyteRelease
INTDIR=.\MultibyteRelease
!ELSE
OUTDIR=.\Release
OUTDIRBIN=.\Release
INTDIR=.\Release
!ENDIF
ALL : "$(OUTDIRBIN)\psqlodbc.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
!IF "$(CFG)" == "MultibyteRelease"
-@erase "$(INTDIR)\multibyte.obj"
!ENDIF
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\psqlodbc.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
!IF "$(CFG)" == "MultibyteRelease"
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "MULTIBYTE" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
!ELSE
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc_win32.def" /out:"$(OUTDIRBIN)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
DEF_FILE= "psqlodbc_win32.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj" \
"$(INTDIR)\misc.obj" \
!IF "$(CFG)" == "MultibyteRelease"
"$(INTDIR)\multibyte.obj" \
!ENDIF
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIRBIN)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Debug" || "$(CFG)" == "MultibyteDebug"
!IF "$(CFG)" == "MultibyteDebug"
OUTDIR=.\MultibyteDebug
INTDIR=.\MultibyteDebug
!ELSE
OUTDIR=.\Debug
INTDIR=.\Debug
!ENDIF
ALL : "$(OUTDIR)\psqlodbc.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
!IF "$(CFG)" == "MultibyteDebug"
-@erase "$(INTDIR)\multibyte.obj"
!ENDIF
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\psqlodbc.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.ilk"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pdb"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
!IF "$(CFG)" == "MultibyteDebug"
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "MULTIBYTE" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
!ELSE
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc_win32.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
DEF_FILE= "psqlodbc_win32.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj"
"$(INTDIR)\misc.obj" \
!IF "$(CFG)" == "MultibyteDebug"
"$(INTDIR)\multibyte.obj" \
!ENDIF
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIR)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(CFG)" == "Release" || "$(CFG)" == "Debug" || "$(CFG)" == "MultibyteRelease" || "$(CFG)" == "MultibyteDebug"
SOURCE=bind.c
"$(INTDIR)\bind.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=columninfo.c
"$(INTDIR)\columninfo.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=connection.c
"$(INTDIR)\connection.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=convert.c
"$(INTDIR)\convert.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_specific.c
"$(INTDIR)\dlg_specific.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_wingui.c
"$(INTDIR)\dlg_wingui.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=drvconn.c
"$(INTDIR)\drvconn.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=environ.c
"$(INTDIR)\environ.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=execute.c
"$(INTDIR)\execute.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info.c
"$(INTDIR)\info.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=lobj.c
"$(INTDIR)\lobj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=misc.c
"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!IF "$(CFG)" == "MultibyteRelease" || "$(CFG)" == "MultibyteDebug"
SOURCE=multibyte.c
"$(INTDIR)\multibyte.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
SOURCE=options.c
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=parse.c
"$(INTDIR)\parse.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgtypes.c
"$(INTDIR)\pgtypes.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.c
"$(INTDIR)\psqlodbc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.rc
!IF "$(CFG)" == "Release"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "MultibyteRelease"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "Debug"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "MultibyteDebug"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
SOURCE=qresult.c
"$(INTDIR)\qresult.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=results.c
"$(INTDIR)\results.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=setup.c
"$(INTDIR)\setup.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=socket.c
"$(INTDIR)\socket.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=statement.c
"$(INTDIR)\statement.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuple.c
"$(INTDIR)\tuple.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuplelist.c
"$(INTDIR)\tuplelist.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_md5.c
"$(INTDIR)\win_md5.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi.c
"$(INTDIR)\odbcapi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -1,537 +0,0 @@
#
# File: win32_30.mak
#
# Description: psqlodbc30 Makefile for Win32.
#
# Configurations: ODBC30Debug, ODBC30, MultibyteDebug30, MultibyteODBC30
# Build Types: ALL, CLEAN
# Usage: NMAKE /f win32_30.mak CFG=[ODBC30 | ODBC30Debug | MultibyteODBC30 | MultibyteDebug30] [ALL | CLEAN]
#
# Comments: Created by Dave Page, 2001-02-12
#
!MESSAGE Building the PostgreSQL ODBC 3.0 Driver for Win32...
!MESSAGE
!IF "$(CFG)" == ""
CFG=MultibyteODBC30
!MESSAGE No configuration specified. Defaulting to ODBC30.
!MESSAGE
!ENDIF
!IF "$(CFG)" != "ODBC30" && "$(CFG)" != "ODBC30Debug" && "$(CFG)" != "MultibyteODBC30" && "$(CFG)" != "MultibyteDebug30"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f win32_30.mak CFG=[ODBC30 | ODBC30Debug | MultibyteODBC30 | MultiByteDebug] [ALL | CLEAN]
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ODBC30" (Win32 Release DLL)
!MESSAGE "ODBC30Debug" (Win32 Debug DLL)
!MESSAGE "MultibyteODBC30" (Win32 Release DLL with Multibyte support)
!MESSAGE "MultibyteDebug30" (Win32 Debug DLL with Multibyte support)
!MESSAGE
!ERROR An invalid configuration was specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "ODBC30" || "$(CFG)" == "MultibyteODBC30"
!IF "$(CFG)" == "MultibyteODBC30"
OUTDIR=.\MultibyteODBC30
OUTDIRBIN=.\MultibyteODBC30
INTDIR=.\MultibyteODBC30
!ELSE
OUTDIR=.\ODBC30
OUTDIRBIN=.\ODBC30
INTDIR=.\ODBC30
!ENDIF
ALL : "$(OUTDIRBIN)\psqlodbc30.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\info30.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
!IF "$(CFG)" == "MultibyteODBC30"
-@erase "$(INTDIR)\multibyte.obj"
!ENDIF
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\odbcapi30.obj"
-@erase "$(INTDIR)\pgapi30.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\psqlodbc30.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
!IF "$(CFG)" == "MultibyteODBC30"
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "MULTIBYTE" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
!ELSE
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc_api30.def" /out:"$(OUTDIRBIN)\psqlodbc30.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
DEF_FILE= "psqlodbc_api30.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\info30.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj" \
"$(INTDIR)\misc.obj" \
!IF "$(CFG)" == "MultibyteODBC30"
"$(INTDIR)\multibyte.obj" \
!ENDIF
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\odbcapi30.obj" \
"$(INTDIR)\pgapi30.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIRBIN)\psqlodbc30.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "ODBC30Debug" || "$(CFG)" == "MultibyteDebug30"
!IF "$(CFG)" == "MultibyteDebug30"
OUTDIR=.\MultibyteDebug30
INTDIR=.\MultibyteDebug30
!ELSE
OUTDIR=.\ODBC30Debug
INTDIR=.\ODBC30Debug
!ENDIF
ALL : "$(OUTDIR)\psqlodbc30.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\info30.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
!IF "$(CFG)" == "MultibyteDebug30"
-@erase "$(INTDIR)\multibyte.obj"
!ENDIF
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\odbcapi30.obj"
-@erase "$(INTDIR)\pgapi30.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\psqlodbc30.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.ilk"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pdb"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
!IF "$(CFG)" == "MultibyteDebug30"
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "MULTIBYTE" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
!ELSE
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc_api30.def" /out:"$(OUTDIR)\psqlodbc30.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
DEF_FILE= "psqlodbc_api30.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\info30.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj"
"$(INTDIR)\misc.obj" \
!IF "$(CFG)" == "MultibyteDebug30"
"$(INTDIR)\multibyte.obj" \
!ENDIF
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\odbcapi30.obj" \
"$(INTDIR)\pgapi30.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIR)\psqlodbc30.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(CFG)" == "ODBC30" || "$(CFG)" == "ODBC30Debug" || "$(CFG)" == "MultibyteODBC30" || "$(CFG)" == "MultibyteDebug30"
SOURCE=bind.c
"$(INTDIR)\bind.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=columninfo.c
"$(INTDIR)\columninfo.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=connection.c
"$(INTDIR)\connection.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=convert.c
"$(INTDIR)\convert.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_specific.c
"$(INTDIR)\dlg_specific.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_wingui.c
"$(INTDIR)\dlg_wingui.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=drvconn.c
"$(INTDIR)\drvconn.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=environ.c
"$(INTDIR)\environ.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=execute.c
"$(INTDIR)\execute.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info.c
"$(INTDIR)\info.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info30.c
"$(INTDIR)\info30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=lobj.c
"$(INTDIR)\lobj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=misc.c
"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!IF "$(CFG)" == "MultibyteODBC30" || "$(CFG)" == "MultibyteDebug30"
SOURCE=multibyte.c
"$(INTDIR)\multibyte.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
SOURCE=options.c
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=parse.c
"$(INTDIR)\parse.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgtypes.c
"$(INTDIR)\pgtypes.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.c
"$(INTDIR)\psqlodbc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.rc
!IF "$(CFG)" == "ODBC30"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "MultibyteODBC30"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "ODBC30Debug"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "MultibyteDebug30"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
SOURCE=qresult.c
"$(INTDIR)\qresult.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=results.c
"$(INTDIR)\results.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=setup.c
"$(INTDIR)\setup.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=socket.c
"$(INTDIR)\socket.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=statement.c
"$(INTDIR)\statement.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuple.c
"$(INTDIR)\tuple.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuplelist.c
"$(INTDIR)\tuplelist.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_md5.c
"$(INTDIR)\win_md5.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi.c
"$(INTDIR)\odbcapi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi30.c
"$(INTDIR)\odbcapi30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgcapi30.c
"$(INTDIR)\pgcapi30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -1,520 +0,0 @@
#
# File: win32_30w.mak
#
# Description: psqlodbc30w Unicode version Makefile for Win32.
#
# Configurations: Unicode30Debug, Unicode30
# Build Types: ALL, CLEAN
# Usage: NMAKE /f win32_30.mak CFG=[Unicode30 | Unicode30Debug] [ALL | CLEAN]
#
# Comments: Created by Dave Page, 2001-02-12
#
!MESSAGE Building the PostgreSQL Unicode 3.0 Driver for Win32...
!MESSAGE
!IF "$(CFG)" == ""
CFG=Unicode30
!MESSAGE No configuration specified. Defaulting to Unicode30.
!MESSAGE
!ENDIF
!IF "$(CFG)" != "Unicode30" && "$(CFG)" != "Unicode30Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f win32_30.mak CFG=[Unicode30 | Unicode30Debug] [ALL | CLEAN]
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Unicode30" (Win32 Release DLL)
!MESSAGE "Unicode30Debug" (Win32 Debug DLL)
!MESSAGE
!ERROR An invalid configuration was specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "Unicode30"
OUTDIR=.\Unicode30
OUTDIRBIN=.\Unicode30
INTDIR=.\Unicode30
ALL : "$(OUTDIRBIN)\psqlodbc30w.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\info30.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
-@erase "$(INTDIR)\pgapi30.obj"
-@erase "$(INTDIR)\multibyte.obj"
-@erase "$(INTDIR)\odbcapiw.obj"
-@erase "$(INTDIR)\odbcapi30w.obj"
-@erase "$(INTDIR)\win_unicode.obj"
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\odbcapi30.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\psqlodbc30w.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc_api30w.def" /out:"$(OUTDIRBIN)\psqlodbc30w.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
DEF_FILE= "psqlodbc_api30w.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\info30.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj" \
"$(INTDIR)\misc.obj" \
"$(INTDIR)\pgapi30.obj" \
"$(INTDIR)\multibyte.obj" \
"$(INTDIR)\odbcapiw.obj" \
"$(INTDIR)\odbcapi30w.obj" \
"$(INTDIR)\win_unicode.obj" \
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\odbcapi30.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIRBIN)\psqlodbc30w.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Unicode30Debug"
ALL : "$(OUTDIR)\psqlodbc30w.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\dlg_wingui.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\info30.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
-@erase "$(INTDIR)\pgapi30.obj"
-@erase "$(INTDIR)\multibyte.obj"
-@erase "$(INTDIR)\odbcapiw.obj"
-@erase "$(INTDIR)\odbcapi30w.obj"
-@erase "$(INTDIR)\win_unicode.obj"
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\odbcapi30.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\psqlodbc30w.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.ilk"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pdb"
-@erase "$(OUTDIR)\psqlodbc.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0300" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /D "DRIVER_CURSOR_IMPLEMENT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc_api30w.def" /out:"$(OUTDIR)\psqlodbc30w.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
DEF_FILE= "psqlodbc_api30w.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\dlg_wingui.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\info30.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj"
"$(INTDIR)\misc.obj" \
"$(INTDIR)\pgapi30.obj" \
"$(INTDIR)\multibyte.obj" \
"$(INTDIR)\odbcapiw.obj" \
"$(INTDIR)\odbcapi30w.obj" \
"$(INTDIR)\win_unicode.obj" \
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\odbcapi30.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIR)\psqlodbc30w.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(CFG)" == "Unicode30" || "$(CFG)" == "Unicode30Debug"
SOURCE=bind.c
"$(INTDIR)\bind.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=columninfo.c
"$(INTDIR)\columninfo.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=connection.c
"$(INTDIR)\connection.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=convert.c
"$(INTDIR)\convert.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_specific.c
"$(INTDIR)\dlg_specific.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_wingui.c
"$(INTDIR)\dlg_wingui.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=drvconn.c
"$(INTDIR)\drvconn.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=environ.c
"$(INTDIR)\environ.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=execute.c
"$(INTDIR)\execute.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info.c
"$(INTDIR)\info.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info30.c
"$(INTDIR)\info30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=lobj.c
"$(INTDIR)\lobj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=misc.c
"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=multibyte.c
"$(INTDIR)\multibyte.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapiw.c
"$(INTDIR)\odbcapiw.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgapi30.c
"$(INTDIR)\pgapi30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi30w.c
"$(INTDIR)\odbcapi30w.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_unicode.c
"$(INTDIR)\win_unicode.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=options.c
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=parse.c
"$(INTDIR)\parse.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgtypes.c
"$(INTDIR)\pgtypes.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.c
"$(INTDIR)\psqlodbc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.rc
!IF "$(CFG)" == "Unicode30"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "Unicode30Debug"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" $(SOURCE)
!ENDIF
SOURCE=qresult.c
"$(INTDIR)\qresult.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=results.c
"$(INTDIR)\results.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=setup.c
"$(INTDIR)\setup.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=socket.c
"$(INTDIR)\socket.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=statement.c
"$(INTDIR)\statement.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuple.c
"$(INTDIR)\tuple.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuplelist.c
"$(INTDIR)\tuplelist.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_md5.c
"$(INTDIR)\win_md5.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi.c
"$(INTDIR)\odbcapi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi30.c
"$(INTDIR)\odbcapi30.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -1,478 +0,0 @@
#
# File: win32w.mak
#
# Description: psqlodbc Unicode version Makefile for Win32.
#
# Configurations: UnicodeDebug, Unicode
# Build Types: ALL, CLEAN
# Usage: NMAKE /f win32w.mak CFG=[Unicode | UnicodeDebug] [ALL | CLEAN]
#
# Comments: Created by Dave Page, 2001-02-12
#
!MESSAGE Building the PostgreSQL Unicode Driver for Win32...
!MESSAGE
!IF "$(CFG)" == ""
CFG=Unicode
!MESSAGE No configuration specified. Defaulting to Unicode.
!MESSAGE
!ENDIF
!IF "$(CFG)" != "Unicode" && "$(CFG)" != "UnicodeDebug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f win32w.mak CFG=[Unicode | UnicodeDebug] [ALL | CLEAN]
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Unicode" (Win32 Release DLL)
!MESSAGE "UnicodeDebug" (Win32 Debug DLL)
!MESSAGE
!ERROR An invalid configuration was specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "Unicode"
OUTDIR=.\Unicode
OUTDIRBIN=.\Unicode
INTDIR=.\Unicode
ALL : "$(OUTDIRBIN)\psqlodbc.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
-@erase "$(INTDIR)\multibyte.obj"
-@erase "$(INTDIR)\odbcapiw.obj"
-@erase "$(INTDIR)\odbcapi25w.obj"
-@erase "$(INTDIR)\win_unicode.obj"
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\psqlodbc.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0250" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /D "DRIVER_CURSOR_IMPLEMENT" /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc_apiw.def" /out:"$(OUTDIRBIN)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
DEF_FILE= "psqlodbc_apiw.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj" \
"$(INTDIR)\misc.obj" \
"$(INTDIR)\multibyte.obj" \
"$(INTDIR)\odbcapiw.obj" \
"$(INTDIR)\odbcapi25w.obj" \
"$(INTDIR)\win_unicode.obj" \
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIRBIN)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "UnicodeDebug"
ALL : "$(OUTDIR)\psqlodbc.dll"
CLEAN :
-@erase "$(INTDIR)\bind.obj"
-@erase "$(INTDIR)\columninfo.obj"
-@erase "$(INTDIR)\connection.obj"
-@erase "$(INTDIR)\convert.obj"
-@erase "$(INTDIR)\dlg_specific.obj"
-@erase "$(INTDIR)\drvconn.obj"
-@erase "$(INTDIR)\environ.obj"
-@erase "$(INTDIR)\execute.obj"
-@erase "$(INTDIR)\info.obj"
-@erase "$(INTDIR)\lobj.obj"
-@erase "$(INTDIR)\win_md5.obj"
-@erase "$(INTDIR)\misc.obj"
-@erase "$(INTDIR)\multibyte.obj"
-@erase "$(INTDIR)\odbcapiw.obj"
-@erase "$(INTDIR)\odbcapi25w.obj"
-@erase "$(INTDIR)\win_unicode.obj"
-@erase "$(INTDIR)\options.obj"
-@erase "$(INTDIR)\parse.obj"
-@erase "$(INTDIR)\pgtypes.obj"
-@erase "$(INTDIR)\psqlodbc.obj"
-@erase "$(INTDIR)\psqlodbc.res"
-@erase "$(INTDIR)\qresult.obj"
-@erase "$(INTDIR)\results.obj"
-@erase "$(INTDIR)\setup.obj"
-@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\statement.obj"
-@erase "$(INTDIR)\tuple.obj"
-@erase "$(INTDIR)\tuplelist.obj"
-@erase "$(INTDIR)\odbcapi.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\psqlodbc.dll"
-@erase "$(OUTDIR)\psqlodbc.exp"
-@erase "$(OUTDIR)\psqlodbc.ilk"
-@erase "$(OUTDIR)\psqlodbc.lib"
-@erase "$(OUTDIR)\psqlodbc.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "ODBCVER=0x0250" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /D "DRIVER_CURSOR_IMPLEMENT" /Fp"$(INTDIR)\psqlodbc.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc_apiw.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
DEF_FILE= "psqlodbc_apiw.def"
LINK32_OBJS= \
"$(INTDIR)\bind.obj" \
"$(INTDIR)\columninfo.obj" \
"$(INTDIR)\connection.obj" \
"$(INTDIR)\convert.obj" \
"$(INTDIR)\dlg_specific.obj" \
"$(INTDIR)\drvconn.obj" \
"$(INTDIR)\environ.obj" \
"$(INTDIR)\execute.obj" \
"$(INTDIR)\info.obj" \
"$(INTDIR)\lobj.obj" \
"$(INTDIR)\win_md5.obj"
"$(INTDIR)\misc.obj" \
"$(INTDIR)\multibyte.obj" \
"$(INTDIR)\odbcapiw.obj" \
"$(INTDIR)\odbcapi25w.obj" \
"$(INTDIR)\win_unicode.obj" \
"$(INTDIR)\options.obj" \
"$(INTDIR)\parse.obj" \
"$(INTDIR)\pgtypes.obj" \
"$(INTDIR)\psqlodbc.obj" \
"$(INTDIR)\qresult.obj" \
"$(INTDIR)\results.obj" \
"$(INTDIR)\setup.obj" \
"$(INTDIR)\socket.obj" \
"$(INTDIR)\statement.obj" \
"$(INTDIR)\tuple.obj" \
"$(INTDIR)\tuplelist.obj" \
"$(INTDIR)\odbcapi.obj" \
"$(INTDIR)\psqlodbc.res"
"$(OUTDIR)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(CFG)" == "Unicode" || "$(CFG)" == "UnicodeDebug"
SOURCE=bind.c
"$(INTDIR)\bind.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=columninfo.c
"$(INTDIR)\columninfo.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=connection.c
"$(INTDIR)\connection.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=convert.c
"$(INTDIR)\convert.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=dlg_specific.c
"$(INTDIR)\dlg_specific.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=drvconn.c
"$(INTDIR)\drvconn.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=environ.c
"$(INTDIR)\environ.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=execute.c
"$(INTDIR)\execute.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=info.c
"$(INTDIR)\info.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=lobj.c
"$(INTDIR)\lobj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=misc.c
"$(INTDIR)\misc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=multibyte.c
"$(INTDIR)\multibyte.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapiw.c
"$(INTDIR)\odbcapiw.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi25w.c
"$(INTDIR)\odbcapi25w.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_unicode.c
"$(INTDIR)\win_unicode.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=options.c
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=parse.c
"$(INTDIR)\parse.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=pgtypes.c
"$(INTDIR)\pgtypes.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.c
"$(INTDIR)\psqlodbc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=psqlodbc.rc
!IF "$(CFG)" == "Unicode"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "NDEBUG" /d "MULTIBYTE" $(SOURCE)
!ENDIF
!IF "$(CFG)" == "UnicodeDebug"
"$(INTDIR)\psqlodbc.res" : $(SOURCE) "$(INTDIR)"
$(RSC) /l 0x809 /fo"$(INTDIR)\psqlodbc.res" /d "_DEBUG" $(SOURCE)
!ENDIF
SOURCE=qresult.c
"$(INTDIR)\qresult.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=results.c
"$(INTDIR)\results.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=setup.c
"$(INTDIR)\setup.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=socket.c
"$(INTDIR)\socket.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=statement.c
"$(INTDIR)\statement.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuple.c
"$(INTDIR)\tuple.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tuplelist.c
"$(INTDIR)\tuplelist.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=win_md5.c
"$(INTDIR)\win_md5.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=odbcapi.c
"$(INTDIR)\odbcapi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -1,15 +0,0 @@
/*
* win_md5.c
* Under Windows I don't love the following /D in makefiles. - inoue
*/
#define MD5_ODBC
#define FRONTEND
/*
* md5.c is the exact copy of the src/backend/libpq/md5.c.
*
* psqlodbc driver stuff never refer(link) to other
* stuff directly.
*
*/
#include "md5.c"

View File

@ -1,27 +0,0 @@
#ifndef _WIN_SETUP_H__
#define _WIN_SETUP_H__
#ifndef INTFUNC
#define INTFUNC __stdcall
#endif /* INTFUNC */
#define MAXDSNAME (32+1) /* Max data source name length */
/* Globals */
/* NOTE: All these are used by the dialog procedures */
typedef struct tagSETUPDLG
{
HWND hwndParent; /* Parent window handle */
LPCSTR lpszDrvr; /* Driver description */
ConnInfo ci;
char szDSN[MAXDSNAME]; /* Original data source name */
BOOL fNewDSN; /* New data source flag */
BOOL fDefault; /* Default data source flag */
} SETUPDLG, FAR * LPSETUPDLG;
/* Prototypes */
void INTFUNC CenterDialog(HWND hdlg);
int CALLBACK ConfigDlgProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
void INTFUNC ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg);
BOOL INTFUNC SetDSNAttributes(HWND hwnd, LPSETUPDLG lpsetupdlg);
#endif /* _WIN_SETUP_H__ */

View File

@ -1,149 +0,0 @@
/*-------
* Module: win_unicode.c
*
* Description: This module contains utf8 <-> ucs2 conversion routines
* under WIndows
*
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#define byte3check 0xf800
#define byte2_base 0x80c0
#define byte2_mask1 0x07c0
#define byte2_mask2 0x003f
#define byte3_base 0x8080e0
#define byte3_mask1 0xf000
#define byte3_mask2 0x0fc0
#define byte3_mask3 0x003f
UInt4 ucs2strlen(const SQLWCHAR *ucs2str)
{
UInt4 len;
for (len = 0; ucs2str[len]; len++)
;
return len;
}
char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen)
{
char * utf8str;
/*mylog("ucs2_to_utf8 %x ilen=%d ", ucs2str, ilen);*/
if (!ucs2str)
return NULL;
if (ilen < 0)
ilen = ucs2strlen(ucs2str);
/*mylog(" newlen=%d", ilen);*/
utf8str = (char *) malloc(ilen * 3 + 1);
if (utf8str)
{
int i, len = 0;
UInt2 byte2code;
Int4 byte4code;
const SQLWCHAR *wstr;
for (i = 0, wstr = ucs2str; i < ilen; i++, wstr++)
{
if (!*wstr)
break;
else if (0 == (*wstr & 0xff80))
utf8str[len++] = (char) *wstr;
else if ((*wstr & byte3check) == 0)
{
byte2code = byte2_base |
((byte2_mask1 & *wstr) >> 6) |
((byte2_mask2 & *wstr) << 8);
memcpy(utf8str + len, (char *) &byte2code, sizeof(byte2code));
len += 2;
}
else
{
byte4code = byte3_base |
((byte3_mask1 & *wstr) >> 12) |
((byte3_mask2 & *wstr) << 2) |
((byte3_mask3 & *wstr) << 16);
memcpy(utf8str + len, (char *) &byte4code, 3);
len += 3;
}
}
utf8str[len] = '\0';
if (olen)
*olen = len;
}
/*mylog(" olen=%d %s\n", *olen, utf8str ? utf8str : "");*/
return utf8str;
}
#define byte3_m1 0x0f
#define byte3_m2 0x3f
#define byte3_m3 0x3f
#define byte2_m1 0x1f
#define byte2_m2 0x3f
UInt4 utf8_to_ucs2_lf(const char *utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 bufcount)
{
int i;
UInt4 ocount, wcode;
const unsigned char *str;
/*mylog("utf8_to_ucs2 ilen=%d bufcount=%d", ilen, bufcount);*/
if (!utf8str || !ilen)
return 0;
/*mylog(" string=%s\n", utf8str);*/
if (!bufcount)
ucs2str = NULL;
else if (!ucs2str)
bufcount = 0;
if (ilen < 0)
ilen = strlen(utf8str);
for (i = 0, ocount = 0, str = utf8str; i < ilen;)
{
if (iswascii(*str))
{
if (lfconv && *str == '\n' &&
(i == 0 || str[-1] != '\r'))
{
if (ocount < bufcount)
ucs2str[ocount] = '\r';
ocount++;
}
if (ocount < bufcount)
ucs2str[ocount] = *str;
ocount++;
i++;
str++;
}
else if (0xe0 == (*str & 0xe0)) /* 3 byte code */
{
if (ocount < bufcount)
{
wcode = ((((UInt4) *str) & byte3_m1) << 12) |
((((UInt4) str[1]) & byte3_m2) << 6) |
(((UInt4) str[2]) & byte3_m3);
ucs2str[ocount] = (SQLWCHAR) wcode;
}
ocount++;
i += 3;
str += 3;
}
else
{
if (ocount < bufcount)
{
wcode = ((((UInt4) *str) & byte2_m1) << 6) |
(((UInt4) str[1]) & byte2_m2);
ucs2str[ocount] = (SQLWCHAR) wcode;
}
ocount++;
i += 2;
str += 2;
}
}
if (ocount && ocount < bufcount && ucs2str)
ucs2str[ocount] = 0;
/*mylog(" ocount=%d\n", ocount);*/
return ocount;
}