first commit for openGauss connect odbc code

This commit is contained in:
lishifu
2020-06-24 16:11:37 +08:00
parent 2a3a17f54e
commit 59eb2808c4
458 changed files with 141117 additions and 75 deletions

11
BuildAll.bat Executable file
View File

@ -0,0 +1,11 @@
::
:: Build all dlls of psqlodbc project
::
@echo off
if "%1" == "/?" (
powershell Get-Help '%~dp0\winbuild\BuildAll.ps1' -detailed
) else if "%1" == "-?" (
powershell Get-Help '%~dp0\winbuild\BuildAll.ps1' %2 %3 %4 %5 %6 %7 %8 %9
) else (
powershell "& '%~dp0\winbuild\BuildAll.ps1' %*"
)

106
Makefile.am Normal file
View File

@ -0,0 +1,106 @@
#-------------------------------------------------------------------------
#
# Makefile.am for psqlodbc30w (PostgreSQL ODBC driver)
#
#-------------------------------------------------------------------------
AUTOMAKE_OPTIONS = 1.8 foreign
ACLOCAL_AMFLAGS = -I config
lib_LTLIBRARIES = psqlodbcw.la psqlodbca.la
AM_LDFLAGS = -module -no-undefined -avoid-version -export-symbols-regex '^SQL'
psqlodbcw_la_CFLAGS = -DUNICODE_SUPPORT # -DUNICODE_SUPPORTXX
psqlodbca_la_SOURCES = \
info.c bind.c columninfo.c connection.c convert.c drvconn.c \
environ.c execute.c lobj.c misc.c options.c \
pgtypes.c psqlodbc.c qresult.c results.c parse.c \
statement.c tuple.c dlg_specific.c \
multibyte.c odbcapi.c descriptor.c \
odbcapi30.c pgapi30.c mylog.c \
\
bind.h catfunc.h columninfo.h connection.h convert.h \
descriptor.h dlg_specific.h environ.h unicode_support.h \
lobj.h misc.h multibyte.h pgapifunc.h pgtypes.h \
psqlodbc.h qresult.h resource.h statement.h tuple.h \
version.h pgenlist.h mylog.h xalibname.h
psqlodbcw_la_SOURCES = $(psqlodbca_la_SOURCES) \
odbcapi30w.c odbcapiw.c win_unicode.c
EXTRA_DIST = license.txt readme.txt readme_winbuild.txt \
psqlodbc.def psqlodbca.def editConfiguration.bat BuildAll.bat \
windows-defaults.mak buildInstallers.bat regress.bat \
pgenlist.def pgenlista.def connexp.h \
dlg_wingui.c loadlib.c loadlib.h inouealc.c win_setup.h \
psqlsetup.c setup.c win_unicode.c psqlodbc.rc win64.mak \
psqlodbc.reg psqlodbc.dsp psqlodbc.vcproj \
psqlodbc.sln msdtc_enlist.cpp pgxalib.cpp xalibname.c \
pgxalib.def psqlsetup.def psqlsetupa.def odbc.sql odbc-drop.sql \
\
docs/config-opt.html \
docs/config.html \
docs/README.txt \
docs/release-7.3.html \
docs/release.html \
docs/unix-compilation.html \
docs/win32-compilation.html \
docs/msdtc_pgxalib_tracing_enable.reg \
docs/msdtc_pgxalib_tracing_disable.reg \
docs/msdtc_pgxalib_tracing_README.txt \
docs/editConfiguration.jpg \
\
installer/background.bmp \
installer/banner.bmp \
installer/buildInstallers.ps1 \
installer/installer.mak \
installer/lgpl.rtf \
installer/modify_msi.vbs \
installer/productcodes.mak \
installer/psqlodbc-setup \
installer/README.txt \
installer/psqlodbcm_cpu.wxs \
installer/psqlodbc_cpu.wxs \
installer/psqlodbc-setup/buildBootstrapper.ps1 \
installer/psqlodbc-setup/Bundle.wxs \
installer/psqlodbc-setup/Make.bat \
installer/psqlodbc-setup/psqlodbc-setup.wixproj \
installer/psqlodbc-setup/vcredist.wxs \
\
winbuild/BuildAll.ps1 \
winbuild/platformbuild.vcxproj \
winbuild/MSProgram-Get.psm1 \
winbuild/psqlodbc.Cpp.props \
winbuild/Psqlodbc-config.psm1 \
winbuild/psqlodbc.vcxproj \
winbuild/configuration_template.xml \
winbuild/psqlsetup.vcxproj \
winbuild/editConfiguration.ps1 \
winbuild/readme.txt \
winbuild/pgenlist.vcxproj \
winbuild/regress.ps1 \
winbuild/pguser.Cpp.props \
winbuild/regress_one.vcxproj \
winbuild/pgxalib.vcxproj \
winbuild/std_dbmsname.Cpp.props \
\
test/Makefile.in \
test/odbcini-gen.sh \
test/README.txt \
test/RegisterRegdsn.c \
test/reset-db.c \
test/runsuite.c \
test/sampletables.sql \
test/tests \
test/win.mak \
test/expected \
test/src
MAINTAINERCLEANFILES = \
Makefile.in config/config.guess config.h.in config/config.sub configure \
config/install-sh config/missing aclocal.m4 config/ltmain.sh \
config/depcomp

1220
Makefile.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
# openGauss-connector-odbc
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,39 +0,0 @@
# openGauss-connector-odbc
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

File diff suppressed because it is too large Load Diff

1223
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

1036
bind.c Normal file

File diff suppressed because it is too large Load Diff

134
bind.h Normal file
View File

@ -0,0 +1,134 @@
/* File: bind.h
*
* Description: See "bind.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __BIND_H__
#define __BIND_H__
#include "psqlodbc.h"
#include "descriptor.h"
/*
* BindInfoClass -- stores information about a bound column
*/
struct BindInfoClass_
{
SQLLEN buflen; /* size of buffer */
char *buffer; /* pointer to the buffer */
SQLLEN *used; /* used space in the buffer (for strings
* not counting the '\0') */
SQLLEN *indicator; /* indicator == used in many cases ? */
SQLSMALLINT returntype; /* kind of conversion to be applied when
* returning (SQL_C_DEFAULT,
* SQL_C_CHAR... etc) */
SQLSMALLINT precision; /* the precision for numeric or timestamp type */
SQLSMALLINT scale; /* the scale for numeric type */
/* area for work variables */
char dummy_data; /* currently not used */
};
/* struct for SQLGetData */
typedef struct
{
/* for BLOBs which don't hold the data */
struct GetBlobDataClass {
Int8 data_left64; /* amount of large object data
left to read before conversion */
} blob;
/* for non-BLOBs which hold the data in ttlbuf after conversion */
char *ttlbuf; /* to save the large result */
SQLLEN ttlbuflen; /* the buffer length */
SQLLEN ttlbufused; /* used length of the buffer */
SQLLEN data_left; /* amount of data left to read */
} GetDataClass;
#define GETDATA_RESET(gdc) ((gdc).blob.data_left64 = (gdc).data_left = -1)
/*
* ParameterInfoClass -- stores information about a bound parameter
*/
struct ParameterInfoClass_
{
SQLLEN buflen;
char *buffer;
SQLLEN *used;
SQLLEN *indicator; /* indicator == used in many cases ? */
SQLSMALLINT CType;
SQLSMALLINT precision; /* the precision for numeric or timestamp type */
SQLSMALLINT scale; /* the scale for numeric type */
/* area for work variables */
char data_at_exec;
};
typedef struct
{
SQLLEN *EXEC_used; /* amount of data */
char *EXEC_buffer; /* the data */
OID lobj_oid;
} PutDataClass;
/*
* ParameterImplClass -- stores implementation information about a parameter
*/
struct ParameterImplClass_
{
pgNAME paramName; /* this is unavailable even in 8.1 */
SQLSMALLINT paramType;
SQLSMALLINT SQLType;
OID PGType;
SQLULEN column_size;
SQLSMALLINT decimal_digits;
SQLSMALLINT precision; /* the precision for numeric or timestamp type */
SQLSMALLINT scale; /* the scale for numeric type */
};
typedef struct
{
GetDataClass fdata;
SQLSMALLINT allocated;
GetDataClass *gdata;
} GetDataInfo;
typedef struct
{
SQLSMALLINT allocated;
PutDataClass *pdata;
} PutDataInfo;
#define PARSE_PARAM_CAST FALSE
#define EXEC_PARAM_CAST TRUE
#define SIMPLE_PARAM_CAST TRUE
#define CALC_BOOKMARK_ADDR(book, offset, bind_size, index) \
(book->buffer + offset + \
(bind_size > 0 ? bind_size : (SQL_C_VARBOOKMARK == book->returntype ? book->buflen : sizeof(UInt4))) * index)
/* Macros to handle pgtype of parameters */
#define PIC_get_pgtype(pari) ((pari).PGType)
#define PIC_set_pgtype(pari, type) ((pari).PGType = (type))
#define PIC_dsp_pgtype(conn, pari) ((pari).PGType ? (pari).PGType : sqltype_to_pgtype(conn, (pari).SQLType))
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_params);
void extend_iparameter_bindings(IPDFields *opts, int num_params);
void reset_a_parameter_binding(APDFields *opts, int ipar);
void reset_a_iparameter_binding(IPDFields *opts, int ipar);
int CountParameters(const StatementClass *stmt, Int2 *inCount, Int2 *ioCount, Int2 *outputCount);
void GetDataInfoInitialize(GetDataInfo *gdata);
void extend_getdata_info(GetDataInfo *gdata, int num_columns, BOOL shrink);
void reset_a_getdata_info(GetDataInfo *gdata, int icol);
void GDATA_unbind_cols(GetDataInfo *gdata, BOOL freeall);
void PutDataInfoInitialize(PutDataInfo *pdata);
void extend_putdata_info(PutDataInfo *pdata, int num_params, BOOL shrink);
void reset_a_putdata_info(PutDataInfo *pdata, int ipar);
void PDATA_free_params(PutDataInfo *pdata, char option);
void SC_param_next(const StatementClass*, int *param_number, ParameterInfoClass **, ParameterImplClass **);
RETCODE prepareParameters(StatementClass *stmt, BOOL fake_params);
RETCODE prepareParametersNoDesc(StatementClass *stmt, BOOL fake_params, BOOL param_cast);
int decideHowToPrepare(StatementClass *stmt, BOOL force);
#endif

141
build.sh Executable file
View File

@ -0,0 +1,141 @@
#!/bin/bash
# description: the script that make install PSQLODBC
######################################################################
# Parameter setting
######################################################################
LOCAL_PATH=${0}
FIRST_CHAR=$(expr substr "$LOCAL_PATH" 1 1)
if [ "$FIRST_CHAR" = "/" ]; then
LOCAL_PATH=${0}
else
LOCAL_PATH="$(pwd)/${LOCAL_PATH}"
fi
LOCAL_DIR=$(dirname "${LOCAL_PATH}")
BUILD_OPTION=
TAR_FILE_NAME=unixODBC-2.3.6.tar.gz
SOURCE_CODE_PATH=unixODBC-2.3.6
LOG_FILE=${LOCAL_DIR}/build_PSQLODBC.log
BUILD_FAILED=1
#######################################################################
## print help information
#######################################################################
function print_help()
{
echo "Usage: $0 [OPTION]
-h|--help show help information
-m|--build_option provode the path of GAUSSHOME
"
}
if [ $# = 0 ] ; then
log "missing option"
print_help
exit 1
fi
#######################################################################
# Print log.
#######################################################################
log()
{
echo "[Build unixODBC] $(date +%y-%m-%d' '%T): $@"
echo "[Build unixODBC] $(date +%y-%m-%d' '%T): $@" >> "$LOG_FILE" 2>&1
}
#######################################################################
# print log and exit.
#######################################################################
die()
{
log "$@"
echo "$@"
exit $BUILD_FAILED
}
#######################################################################
# build and install component
#######################################################################
function build_component()
{
cd ${LOCAL_DIR}/third_party/unixodbc/
sh ./build_unixodbc.sh -m build >> "$LOG_FILE" 2>&1
cd ${LOCAL_DIR}
export GAUSSHOME=$BUILD_OPTION
export LD_LIBRARY_PATH=$BUILD_OPTION/lib:$LD_LIBRARY_PATH
log "[Notice] PSQLODBC configure string: ./configure CFLAGS='-fstack-protector-all -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIC' --prefix=`pwd`/install --with-libpq=$BUILD_OPTION --with-unixodbc=./third_party/unixodbc/install_comm/unixODBC-2.3.6/"
./configure CFLAGS='-fstack-protector-all -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIC' --prefix=`pwd`/install --with-libpq=$BUILD_OPTION --with-unixodbc=./third_party/unixodbc/install_comm/unixODBC-2.3.6/ >> "$LOG_FILE" 2>&1
log "[Notice] PSQLODBC Begin make"
make -sj >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
die "PSQLODBC make failed."
fi
log "[Notice] PSQLODBC Begin make install"
make install -sj >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
die "[Error] PSQLODBC make install failed."
fi
make clean >> "$LOG_FILE" 2>&1
log "[Notice] PSQLODBC Begin make package"
mv ${LOCAL_DIR}/install ${LOCAL_DIR}/odbc
rm -rf ${LOCAL_DIR}/lib
mkdir ${LOCAL_DIR}/lib
#copy libraries into lib
cp $BUILD_OPTION/lib/libpq* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libssl* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libcrypto* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libgssapi_krb5_gauss* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libgssrpc_gauss* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libkrb5_gauss* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libkrb5support_gauss* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libk5crypto_gauss* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libconfig* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libpgport_tool* ${LOCAL_DIR}/lib
cp $BUILD_OPTION/lib/libcom_err_gauss* ${LOCAL_DIR}/lib
cp ./third_party/unixodbc/install_comm/unixODBC-2.3.6/lib/libodbcinst* ${LOCAL_DIR}/lib
tar -czvf openGauss-1.0.0-ODBC.tar.gz ./lib ./odbc
rm -rf ${LOCAL_DIR}/lib
log "[Notice] PSQLODBC has been finished"
}
##########################################################################
#read command line paramenters
##########################################################################
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
print_help
exit 1
;;
-m|--build_option)
if [ "$2"X = X ];then
die "no given path of GAUSSHOME"
fi
BUILD_OPTION=$2
shift 2
;;
*)
log "Internal Error: option processing error: $1" 1>&2
log "please input right paramtenter, the following command may help you"
log "./build.sh --help or ./build.sh -h"
exit 1
esac
done
build_component

202
catfunc.h Normal file
View File

@ -0,0 +1,202 @@
/* File: catfunc.h
*
* Description: See "info.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __CATFUNC_H__
#define __CATFUNC_H__
#include "psqlodbc.h"
/* SQLTables field position */
enum {
TABLES_CATALOG_NAME = 0
,TABLES_SCHEMA_NAME
,TABLES_TABLE_NAME
,TABLES_TABLE_TYPE
,TABLES_REMARKS
,NUM_OF_TABLES_FIELDS
};
/* SQLColumns field position */
enum {
COLUMNS_CATALOG_NAME = 0
,COLUMNS_SCHEMA_NAME
,COLUMNS_TABLE_NAME
,COLUMNS_COLUMN_NAME
,COLUMNS_DATA_TYPE
,COLUMNS_TYPE_NAME
,COLUMNS_PRECISION
,COLUMNS_LENGTH
,COLUMNS_SCALE
,COLUMNS_RADIX
,COLUMNS_NULLABLE
,COLUMNS_REMARKS
,COLUMNS_COLUMN_DEF /* ODBC 3.0 but always use it */
,COLUMNS_SQL_DATA_TYPE
,COLUMNS_SQL_DATETIME_SUB
,COLUMNS_CHAR_OCTET_LENGTH
,COLUMNS_ORDINAL_POSITION
,COLUMNS_IS_NULLABLE
,COLUMNS_DISPLAY_SIZE
,COLUMNS_FIELD_TYPE
,COLUMNS_AUTO_INCREMENT
,COLUMNS_PHYSICAL_NUMBER
,COLUMNS_TABLE_OID
,COLUMNS_BASE_TYPEID
,COLUMNS_ATTTYPMOD
,COLUMNS_TABLE_INFO
,NUM_OF_COLUMNS_FIELDS
};
/* SQLPrimaryKeys field position */
enum {
PKS_TABLE_CAT = 0
,PKS_TABLE_SCHEM
,PKS_TABLE_NAME
,PKS_COLUMN_NAME
,PKS_KEY_SQ
,PKS_PK_NAME
,NUM_OF_PKS_FIELDS
};
/* SQLForeignKeys field position */
enum {
FKS_PKTABLE_CAT = 0
,FKS_PKTABLE_SCHEM
,FKS_PKTABLE_NAME
,FKS_PKCOLUMN_NAME
,FKS_FKTABLE_CAT
,FKS_FKTABLE_SCHEM
,FKS_FKTABLE_NAME
,FKS_FKCOLUMN_NAME
,FKS_KEY_SEQ
,FKS_UPDATE_RULE
,FKS_DELETE_RULE
,FKS_FK_NAME
,FKS_PK_NAME
,FKS_DEFERRABILITY
,FKS_TRIGGER_NAME
,NUM_OF_FKS_FIELDS
};
/* SQLColAttribute */
enum {
COLATTR_DESC_COUNT = -1
,COLATTR_DESC_AUTO_UNIQUE_VALUE = 0
,COLATTR_DESC_BASE_COLUMN_NAME
,COLATTR_DESC_BASE_TABLE_NAME
,COLATTR_DESC_CASE_SENSITIVE
,COLATTR_DESC_CATALOG_NAME
,COLATTR_DESC_CONCISE_TYPE
,COLATTR_DESC_DISPLAY_SIZE
,COLATTR_DESC_FIXED_PREC_SCALE
,COLATTR_DESC_LABEL
,COLATTR_DESC_LENGTH
,COLATTR_DESC_LITERAL_PREFIX
,COLATTR_DESC_LITERAL_SUFFIX
,COLATTR_DESC_LOCAL_TYPE_NAME
,COLATTR_DESC_NAME
,COLATTR_DESC_NULLABLE
,COLATTR_DESC_NUM_PREX_RADIX
,COLATTR_DESC_OCTET_LENGTH
,COLATTR_DESC_PRECISION
,COLATTR_DESC_SCALE
,COLATTR_DESC_SCHEMA_NAME
,COLATTR_DESC_SEARCHABLE
,COLATTR_DESC_TABLE_NAME
,COLATTR_DESC_TYPE
,COLATTR_DESC_TYPE_NAME
,COLATTR_DESC_UNNAMED
,COLATTR_DESC_UNSIGNED
,COLATTR_DESC_UPDATABLE
};
/* SQLStatistics field position */
enum {
STATS_CATALOG_NAME = 0
,STATS_SCHEMA_NAME
,STATS_TABLE_NAME
,STATS_NON_UNIQUE
,STATS_INDEX_QUALIFIER
,STATS_INDEX_NAME
,STATS_TYPE
,STATS_SEQ_IN_INDEX
,STATS_COLUMN_NAME
,STATS_COLLATION
,STATS_CARDINALITY
,STATS_PAGES
,STATS_FILTER_CONDITION
,NUM_OF_STATS_FIELDS
};
/* SQLProcedureColumns field position */
enum {
PROCOLS_PROCEDURE_CAT = 0
,PROCOLS_PROCEDURE_SCHEM
,PROCOLS_PROCEDURE_NAME
,PROCOLS_COLUMN_NAME
,PROCOLS_COLUMN_TYPE
,PROCOLS_DATA_TYPE
,PROCOLS_TYPE_NAME
,PROCOLS_COLUMN_SIZE
,PROCOLS_BUFFER_LENGTH
,PROCOLS_DECIMAL_DIGITS
,PROCOLS_NUM_PREC_RADIX
,PROCOLS_NULLABLE
,PROCOLS_REMARKS
,PROCOLS_COLUMN_DEF
,PROCOLS_SQL_DATA_TYPE
,PROCOLS_SQL_DATETIME_SUB
,PROCOLS_CHAR_OCTET_LENGTH
,PROCOLS_ORDINAL_POSITION
,PROCOLS_IS_NULLABLE
,NUM_OF_PROCOLS_FIELDS
};
/* SQLGetTypeInfo field position */
enum {
GETTYPE_TYPE_NAME = 0
,GETTYPE_DATA_TYPE
,GETTYPE_COLUMN_SIZE
,GETTYPE_LITERAL_PREFIX
,GETTYPE_LITERAL_SUFFIX
,GETTYPE_CREATE_PARAMS
,GETTYPE_NULLABLE
,GETTYPE_CASE_SENSITIVE
,GETTYPE_SEARCHABLE
,GETTYPE_UNSIGNED_ATTRIBUTE
,GETTYPE_FIXED_PREC_SCALE
,GETTYPE_AUTO_UNIQUE_VALUE
,GETTYPE_LOCAL_TYPE_NAME
,GETTYPE_MINIMUM_SCALE
,GETTYPE_MAXIMUM_SCALE
,GETTYPE_SQL_DATA_TYPE
,GETTYPE_SQL_DATETIME_SUB
,GETTYPE_NUM_PREC_RADIX
,GETTYPE_INTERVAL_PRECISION
,NUM_OF_GETTYPE_FIELDS
};
/* SQLSpecialColumns field position */
enum {
SPECOLS_SCOPE = 0
,SPECOLS_COLUMN_NAME
,SPECOLS_DATA_TYPE
,SPECOLS_TYPE_NAME
,SPECOLS_COLUMN_SIZE
,SPECOLS_BUFFER_LENGTH
,SPECOLS_DECIMAL_DIGITS
,SPECOLS_PSEUDO_COLUMN
,NUM_OF_SPECOLS_FIELDS
};
/* SQLTablePrivileges field position */
enum {
TABPRIV_TABLE_CAT = 0
,TABPRIV_TABLE_SCHEM
,TABPRIV_TABLE_NAME
,TABPRIV_GRANTOR
,TABPRIV_GRANTEE
,TABPRIV_PRIVILEGE
,TABPRIV_IS_GRANTABLE
,NUM_OF_TABPRIV_FIELDS
};
#endif /* __CARFUNC_H__ */

168
columninfo.c Normal file
View File

@ -0,0 +1,168 @@
/*-------
* 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 "readme.txt" for copyright and license information.
*-------
*/
#include "pgtypes.h"
#include "columninfo.h"
#include "connection.h"
#include <stdlib.h>
#include <string.h>
#include "pgapifunc.h"
#include <libpq-fe.h>
ColumnInfoClass *
CI_Constructor(void)
{
ColumnInfoClass *rv;
rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass));
if (rv)
{
rv->refcount = 0;
rv->num_fields = 0;
rv->coli_array = NULL;
}
return rv;
}
void
CI_Destructor(ColumnInfoClass *self)
{
CI_free_memory(self);
free(self);
}
/*
* Read in field descriptions from a libpq result set.
* If self is not null, then also store the information.
* If self is null, then just read, don't store.
*/
BOOL
CI_read_fields_from_pgres(ColumnInfoClass *self, PGresult *pgres)
{
Int2 lf;
int new_num_fields;
OID new_adtid, new_relid = 0, new_attid = 0;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
char *new_field_name;
/* at first read in the number of fields that are in the query */
new_num_fields = PQnfields(pgres);
QLOG(0, "\tnFields: %d\n", new_num_fields);
if (self)
{
/* according to that allocate memory */
CI_set_num_fields(self, new_num_fields);
if (new_num_fields > 0 && NULL == self->coli_array)
return FALSE;
}
/* now read in the descriptions */
for (lf = 0; lf < new_num_fields; lf++)
{
new_field_name = PQfname(pgres, lf);
new_relid = PQftable(pgres, lf);
new_attid = PQftablecol(pgres, lf);
new_adtid = PQftype(pgres, lf);
new_adtsize = PQfsize(pgres, lf);
MYLOG(0, "READING ATTTYPMOD\n");
new_atttypmod = PQfmod(pgres, lf);
/* 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;
QLOG(0, "\tfieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d (rel,att)=(%d,%d)\n", new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid);
if (self)
CI_set_field_info(self, lf, new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid);
}
return TRUE;
}
void
CI_free_memory(ColumnInfoClass *self)
{
register Int2 lf;
int num_fields = self->num_fields;
/* Safe to call even if null */
self->num_fields = 0;
if (self->coli_array)
{
for (lf = 0; lf < num_fields; lf++)
{
if (self->coli_array[lf].name)
{
free(self->coli_array[lf].name);
self->coli_array[lf].name = NULL;
}
}
free(self->coli_array);
self->coli_array = 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->coli_array = (struct srvr_info *) calloc(sizeof(struct srvr_info), 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,
OID new_relid, OID new_attid)
{
/* check bounds */
if ((field_num < 0) || (field_num >= self->num_fields))
return;
/* store the info */
self->coli_array[field_num].name = strdup(new_name);
self->coli_array[field_num].adtid= new_adtid;
self->coli_array[field_num].adtsize = new_adtsize;
self->coli_array[field_num].atttypmod = new_atttypmod;
self->coli_array[field_num].display_size = PG_ADT_UNSET;
self->coli_array[field_num].relid = new_relid;
self->coli_array[field_num].attid = new_attid;
}

54
columninfo.h Normal file
View File

@ -0,0 +1,54 @@
/* File: columninfo.h
*
* Description: See "columninfo.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __COLUMNINFO_H__
#define __COLUMNINFO_H__
#include "psqlodbc.h"
#include <libpq-fe.h>
struct ColumnInfoClass_
{
UInt4 refcount; /* reference count. A ColumnInfo can be shared by
* several qresults. */
Int2 num_fields;
struct srvr_info
{
char *name; /* field name */
OID adtid; /* type oid */
Int2 adtsize; /* type size */
Int4 display_size; /* the display size (longest row) */
Int4 atttypmod; /* the length of bpchar/varchar */
OID relid; /* the relation id */
Int2 attid; /* the attribute number */
} *coli_array;
};
#define CI_get_num_fields(self) (self->num_fields)
#define CI_get_oid(self, col) (self->coli_array[col].adtid)
#define CI_get_fieldname(self, col) (self->coli_array[col].name)
#define CI_get_fieldsize(self, col) (self->coli_array[col].adtsize)
#define CI_get_display_size(self, col) (self->coli_array[col].display_size)
#define CI_get_atttypmod(self, col) (self->coli_array[col].atttypmod)
#define CI_get_relid(self, col) (self->coli_array[col].relid)
#define CI_get_attid(self, col) (self->coli_array[col].attid)
ColumnInfoClass *CI_Constructor(void);
void CI_Destructor(ColumnInfoClass *self);
void CI_free_memory(ColumnInfoClass *self);
BOOL CI_read_fields_from_pgres(ColumnInfoClass *self, PGresult *pgres);
/* 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,
OID new_relid, OID new_attid);
#endif

165
config.h.in Normal file
View File

@ -0,0 +1,165 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `c16rtomb' function. */
#undef HAVE_C16RTOMB
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
don't. */
#undef HAVE_DECL_STRERROR_R
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `pq' library (-lpq). */
#undef HAVE_LIBPQ
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `pthreads' library (-lpthreads). */
#undef HAVE_LIBPTHREADS
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if you have the `mbrtoc16' function. */
#undef HAVE_MBRTOC16
/* Define to 1 if you have the `mbstowcs' function. */
#undef HAVE_MBSTOWCS
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `pthread_mutexattr_settype' function. */
#undef HAVE_PTHREAD_MUTEXATTR_SETTYPE
/* Define to 1 if the system has the type `signed char'. */
#undef HAVE_SIGNED_CHAR
/* Define to 1 if the system has the type `ssize_t'. */
#undef HAVE_SSIZE_T
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strlcat' function. */
#undef HAVE_STRLCAT
/* Define to 1 if you have the `strtok_r' function. */
#undef HAVE_STRTOK_R
/* Define to 1 if you have the `strtoll' function. */
#undef HAVE_STRTOLL
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <uchar.h> header file. */
#undef HAVE_UCHAR_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `wcstombs' function. */
#undef HAVE_WCSTOMBS
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define if you have PTHREAD_MUTEX_RECURSIVE_NP */
#undef PG_RECURSIVE_MUTEXATTR
/* Define to 1 to build with pthreads support (--enable-pthreads) */
#undef POSIX_MULTITHREAD_SUPPORT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* Define to 1 if SQLColAttribute use SQLLEN */
#undef SQLCOLATTRIBUTE_SQLLEN
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if strerror_r returns char *. */
#undef STRERROR_R_CHAR_P
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to 1 to build with iODBC support */
#undef WITH_IODBC
/* Define to 1 to build with unixODBC support */
#undef WITH_UNIXODBC
/* Define _REENTRANT for several plaforms */
#undef _REENTRANT
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

348
config/compile Executable file
View File

@ -0,0 +1,348 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2016-01-11.22; # UTC
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

1433
config/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1804
config/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

791
config/depcomp Executable file
View File

@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2016-01-11.22; # UTC
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

152
config/general.m4 Normal file
View File

@ -0,0 +1,152 @@
# $PostgreSQL: pgsql/config/general.m4,v 1.9 2006/11/30 22:21:23 tgl Exp $
# This file defines new macros to process configure command line
# arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE.
# The flaw in these is particularly that they only differentiate
# between "given" and "not given" and do not provide enough help to
# process arguments that only accept "yes/no", that require an
# argument (other than "yes/no"), etc.
#
# The point of this implementation is to reduce code size and
# redundancy in configure.in and to improve robustness and consistency
# in the option evaluation code.
# Convert type and name to shell variable name (e.g., "enable_long_strings")
m4_define([pgac_arg_to_variable],
[$1[]_[]patsubst($2, -, _)])
# PGAC_ARG(TYPE, NAME, HELP-STRING,
# [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG],
# [ACTION-IF-OMITTED])
# ----------------------------------------------------------
# This is the base layer. TYPE is either "with" or "enable", depending
# on what you like. NAME is the rest of the option name, HELP-STRING
# as usual. ACTION-IF-YES is executed if the option is given without
# an argument (or "yes", which is the same); similar for ACTION-IF-NO.
AC_DEFUN([PGAC_ARG],
[
pgac_args="$pgac_args pgac_arg_to_variable([$1],[$2])"
m4_case([$1],
enable, [
AC_ARG_ENABLE([$2], [$3], [
case [$]enableval in
yes)
m4_default([$4], :)
;;
no)
m4_default([$5], :)
;;
*)
$6
;;
esac
],
[$7])[]dnl AC_ARG_ENABLE
],
with, [
AC_ARG_WITH([$2], [$3], [
case [$]withval in
yes)
m4_default([$4], :)
;;
no)
m4_default([$5], :)
;;
*)
$6
;;
esac
],
[$7])[]dnl AC_ARG_WITH
],
[m4_fatal([first argument of $0 must be 'enable' or 'with', not '$1'])]
)
])# PGAC_ARG
# PGAC_ARG_CHECK()
# ----------------
# Checks if the user passed any --with/without/enable/disable
# arguments that were not defined. Just prints out a warning message,
# so this should be called near the end, so the user will see it.
AC_DEFUN([PGAC_ARG_CHECK],
[for pgac_var in `set | sed 's/=.*//' | $EGREP 'with_|enable_'`; do
for pgac_arg in $pgac_args with_gnu_ld; do
if test "$pgac_var" = "$pgac_arg"; then
continue 2
fi
done
pgac_txt=`echo $pgac_var | sed 's/_/-/g'`
AC_MSG_WARN([option ignored: --$pgac_txt])
done])# PGAC_ARG_CHECK
# PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING,
# [ACTION-IF-YES], [ACTION-IF-NO])
# -----------------------------------------------
# Accept a boolean option, that is, one that only takes yes or no.
# ("no" is equivalent to "disable" or "without"). DEFAULT is what
# should be done if the option is omitted; it should be "yes" or "no".
# (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always
# execute.)
AC_DEFUN([PGAC_ARG_BOOL],
[PGAC_ARG([$1], [$2], [$4], [$5], [$6],
[AC_MSG_ERROR([no argument expected for --$1-$2 option])],
[m4_case([$3],
yes, [pgac_arg_to_variable([$1], [$2])=yes
$5],
no, [pgac_arg_to_variable([$1], [$2])=no
$6],
[m4_fatal([third argument of $0 must be 'yes' or 'no', not '$3'])])])[]dnl
])# PGAC_ARG_BOOL
# PGAC_ARG_REQ(TYPE, NAME, HELP-STRING, [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN])
# -------------------------------------------------------------------------------
# This option will require an argument; "yes" or "no" will not be
# accepted.
AC_DEFUN([PGAC_ARG_REQ],
[PGAC_ARG([$1], [$2], [$3],
[AC_MSG_ERROR([argument required for --$1-$2 option])],
[AC_MSG_ERROR([argument required for --$1-$2 option])],
[$4],
[$5])])# PGAC_ARG_REQ
# PGAC_ARG_OPTARG(TYPE, NAME, HELP-STRING, [DEFAULT-ACTION], [ARG-ACTION]
# [ACTION-ENABLED], [ACTION-DISABLED])
# -----------------------------------------------------------------------
# This will create an option that behaves as follows: If omitted, or
# called with "no", then set the enable_variable to "no" and do
# nothing else. If called with "yes", then execute DEFAULT-ACTION. If
# called with argument, set enable_variable to "yes" and execute
# ARG-ACTION. Additionally, execute ACTION-ENABLED if we ended up with
# "yes" either way, else ACTION-DISABLED.
#
# The intent is to allow enabling a feature, and optionally pass an
# additional piece of information.
AC_DEFUN([PGAC_ARG_OPTARG],
[PGAC_ARG([$1], [$2], [$3], [$4], [],
[pgac_arg_to_variable([$1], [$2])=yes
$5],
[pgac_arg_to_variable([$1], [$2])=no])
dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED.
m4_ifval([$6[]$7],
[
if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then
m4_default([$6], :)
m4_ifval([$7],
[else
$7
])[]dnl
fi
])[]dnl
])# PGAC_ARG_OPTARG

501
config/install-sh Executable file
View File

@ -0,0 +1,501 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2016-01-11.22; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

7982
config/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

9706
config/ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

384
config/ltoptions.m4 vendored Normal file
View File

@ -0,0 +1,384 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 7 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the `shared' and
# `disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the `static' and
# `disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install'
# and `disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
# LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for lt_pkg in $withval; do
IFS="$lt_save_ifs"
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

123
config/ltsugar.m4 vendored Normal file
View File

@ -0,0 +1,123 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

23
config/ltversion.m4 vendored Normal file
View File

@ -0,0 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 3337 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.2])
m4_define([LT_PACKAGE_REVISION], [1.3337])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.2'
macro_revision='1.3337'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

98
config/lt~obsolete.m4 vendored Normal file
View File

@ -0,0 +1,98 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])

215
config/missing Executable file
View File

@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2016-01-11.22; # UTC
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

15599
configure vendored Executable file

File diff suppressed because it is too large Load Diff

265
configure.ac Normal file
View File

@ -0,0 +1,265 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(psqlodbc, 10.03.0000, [pgsql-odbc@postgresql.org])
AC_PREREQ(2.57)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([bind.c])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE
# 0. Options processing
AC_PROG_CC
AM_CONDITIONAL([GCC], [test -n "$GCC"])
if test -n "$GCC" && test "$ac_test_CFLAGS" != set; then
AC_MSG_CHECKING(-Wall is a valid compile option)
CFLAGS_SAVE="${CFLAGS}"
CFLAGS="${CFLAGS} -Wall"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <stdio.h>]],
[])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
CFLAGS="${CFLAGS_SAVE}"])
fi
#
# Whether unixODBC driver manager is used
#
AC_ARG_WITH(unixodbc, [ --with-unixodbc[[=DIR]] [[default=yes]] DIR is the unixODBC base install
directory or the path to odbc_config],
[], [with_unixodbc=yes])
#
# Whether iODBC driver manager is used
#
AC_ARG_WITH(iodbc, [ --with-iodbc[[=DIR]] [[default=no]] DIR is the iODBC base install
directory or the path to iodbc-config],
[], [with_iodbc=no])
if test "$with_iodbc" != no; then
with_unixodbc=no
AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support])
if test "$with_iodbc" = yes; then
AC_PATH_PROGS(ODBC_CONFIG, iodbc-config)
else
ODBC_CONFIG=$with_iodbc
fi
if test ! -x "${ODBC_CONFIG}/bin/iodbc-config"; then
if test ! -x "${ODBC_CONFIG}"; then
AC_MSG_ERROR([iodbc-config not found (required for iODBC build)])
fi
else
ODBC_CONFIG=${ODBC_CONFIG}/bin/iodbc-config
fi
fi
if test "$with_unixodbc" != no; then
AC_DEFINE(WITH_UNIXODBC, 1,
[Define to 1 to build with unixODBC support])
if test "$with_unixodbc" = yes; then
AC_PATH_PROGS(ODBC_CONFIG, odbc_config)
else
ODBC_CONFIG=$with_unixodbc
fi
if test ! -x "${ODBC_CONFIG}/bin/odbc_config"; then
if test ! -x "${ODBC_CONFIG}"; then
AC_MSG_ERROR([odbc_config not found (required for unixODBC build)])
fi
else
ODBC_CONFIG=${ODBC_CONFIG}/bin/odbc_config
fi
fi
#
# ODBC include and library
#
if test "$ODBC_CONFIG" != ""; then
if test "$with_iodbc" != no; then
ODBC_INCLUDE=`${ODBC_CONFIG} --cflags`
CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}"
# Linking libiodoc is rather problematic
[ODBC_LIBDIR=`${ODBC_CONFIG} --libs | sed -e "s/^\(-L\|.*[ \t]-L\)\([^ \n\r\f\t]*\).*$/-L\2/"`]
LDFLAGS="$LDFLAGS ${ODBC_LIBDIR}"
else
ODBC_INCLUDE=`${ODBC_CONFIG} --include-prefix`
CPPFLAGS="$CPPFLAGS -I${ODBC_INCLUDE}"
# Linking libodoc is rather problematic
ODBC_LIBDIR=`${ODBC_CONFIG} --lib-prefix`
LDFLAGS="$LDFLAGS -L${ODBC_LIBDIR}"
fi
AC_MSG_NOTICE([using $ODBC_INCLUDE $ODBC_LIBDIR])
fi
#
# SQLCOLATTRIBUTE_SQLLEN check
#
AC_MSG_CHECKING(last argument to SQLColAttribute is SQLLEN *)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sql.h>
SQLRETURN SQL_API SQLColAttribute(SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLUSMALLINT FieldIdentifier,
SQLPOINTER CharacterAttribute,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength,
SQLLEN *NumericAttribute)
{
SQLLEN t = 1;
*NumericAttribute = t;
return 0;
}
]])],
[AC_DEFINE(SQLCOLATTRIBUTE_SQLLEN, 1,
[Define to 1 if SQLColAttribute use SQLLEN])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
#
# Whether libpq functionalities are used
#
AC_ARG_WITH(libpq, [ --with-libpq[[=DIR]] DIR is the PostgreSQL base install
directory or the path to pg_config],
[], [with_libpq=yes])
if test "$with_libpq" = no; then
AC_MSG_ERROR([libpq is mandatory, --without-libpq is no longer supported])
fi
if test "$with_libpq" != yes; then
if test -d "$with_libpq"; then
PATH="$PATH:$with_libpq/bin"
CPPFLAGS="$CPPFLAGS -I$with_libpq/include -I$with_libpq/include/postgresql/internal"
LDFLAGS="$LDFLAGS -L$with_libpq/lib"
else
if test -x "$with_libpq"; then
PG_CONFIG=$with_libpq
else
AC_MSG_ERROR([specified pg_config not found])
fi
fi
fi
#
# Pthreads
#
PGAC_ARG_BOOL(enable, pthreads, yes,
[ --disable-pthreads do not build with POSIX threads],
[AC_DEFINE(POSIX_MULTITHREAD_SUPPORT, 1,
[Define to 1 to build with pthreads support (--enable-pthreads)])
AC_DEFINE(_REENTRANT, 1, [Define _REENTRANT for several plaforms])])
#
# Find libpq headers and libraries
#
if test -z "$PG_CONFIG"; then
AC_PATH_PROGS(PG_CONFIG, pg_config)
fi
if test -n "$PG_CONFIG"; then
pg_includedir=`"$PG_CONFIG" --includedir`
pg_pkg_includedir=`"$PG_CONFIG" --pkgincludedir`
pg_libdir=`"$PG_CONFIG" --libdir`
CPPFLAGS="$CPPFLAGS -I$pg_includedir -I$pg_pkg_includedir/internal"
LDFLAGS="$LDFLAGS -L$pg_libdir"
fi
# 1. Programs
# 'prove' is used to pretty-print regression test results, if available.
AC_CHECK_PROGS(PROVE, prove)
# 2. Libraries
AC_LIBTOOL_WIN32_DLL
AC_DISABLE_STATIC
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
if test "$with_unixodbc" != no; then
AC_SEARCH_LIBS(SQLGetPrivateProfileString, odbcinst, [],
[AC_MSG_ERROR([unixODBC library "odbcinst" not found])])
fi
if test "$with_iodbc" != no; then
AC_SEARCH_LIBS(SQLGetPrivateProfileString, iodbcinst, [],
[AC_MSG_ERROR([iODBC library "iodbcinst" not found])])
fi
if test "$enable_pthreads" = yes; then
AC_CHECK_LIB(pthreads, pthread_create,
[],
[AC_CHECK_LIB(pthread, pthread_create)])
fi
AC_CHECK_LIB(pq, PQsetSingleRowMode, [],
[AC_MSG_ERROR([libpq library version >= 9.2 is required])])
# 3. Header files
AC_CHECK_HEADERS(locale.h sys/time.h uchar.h)
AC_CHECK_HEADER(libpq-fe.h,,[AC_MSG_ERROR([libpq header not found])])
AC_HEADER_TIME
# 4. Types
# unixODBC wants the following to get sane behavior for ODBCINT64
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void *)
AC_CHECK_TYPES(long long)
AC_CHECK_TYPES(signed char)
AC_CHECK_TYPES(ssize_t)
AC_TYPE_SIZE_T
# 5. Structures
AC_STRUCT_TM
# 6. Compiler characteristics
AC_C_CONST
# 7. Functions, global variables
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS(strtoul strtoll strlcat mbstowcs wcstombs mbrtoc16 c16rtomb)
if test "$enable_pthreads" = yes; then
AC_CHECK_FUNCS(localtime_r strtok_r pthread_mutexattr_settype)
if test x"$ac_cv_func_pthread_mutexattr_settype" = xyes; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_MUTEX_RECURSIVE;]])],
[AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE,
[Define if you have PTHREAD_MUTEX_RECURSIVE])],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_MUTEX_RECURSIVE_NP;]])],
[AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE_NP,
[Define if you have PTHREAD_MUTEX_RECURSIVE_NP])])])
fi
fi
# 8. Libltdl This release doesn't need libltdl
# AC_CHECK_LIB(ltdl, lt_dlopen)
AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT

3777
connection.c Normal file

File diff suppressed because it is too large Load Diff

523
connection.h Normal file
View File

@ -0,0 +1,523 @@
/* File: connection.h
*
* Description: See "connection.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __CONNECTION_H__
#define __CONNECTION_H__
#include "psqlodbc.h"
#include <libpq-fe.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include "descriptor.h"
#if defined (POSIX_MULTITHREAD_SUPPORT)
#include <pthread.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
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_SEVERITY_FATAL 108
#define CONNECTION_COULD_NOT_RECEIVE 109
#define CONNECTION_SERVER_REPORTED_SEVERITY_ERROR 110
#define CONNECTION_NEED_PASSWORD 112
#define CONNECTION_COMMUNICATION_ERROR 113
#define CONN_ERROR_IGNORED (-3)
#define CONN_TRUNCATED (-2)
#define CONN_OPTION_VALUE_CHANGED (-1)
/* 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_ILLEGAL_TRANSACT_STATE 213
#define CONN_VALUE_OUT_OF_RANGE 214
#define CONN_OPTION_NOT_FOR_THE_DRIVER 216
#define CONN_EXEC_ERROR 217
/* Conn_status defines */
#define CONN_IN_AUTOCOMMIT 1L
#define CONN_IN_TRANSACTION (1L<<1)
#define CONN_IN_MANUAL_TRANSACTION (1L<<2)
#define CONN_IN_ERROR_BEFORE_IDLE (1L<<3)
/* not connected yet || already disconnected */
#define CC_not_connected(x) (!(x) || CONN_DOWN == (x)->status || CONN_NOT_CONNECTED == (x)->status)
/* AutoCommit functions */
#define CC_is_in_autocommit(x) (x->transact_status & CONN_IN_AUTOCOMMIT)
#define CC_does_autocommit(x) (CONN_IN_AUTOCOMMIT == ((x)->transact_status & (CONN_IN_AUTOCOMMIT | CONN_IN_MANUAL_TRANSACTION)))
#define CC_loves_visible_trans(x) ((0 == ((x)->transact_status & CONN_IN_AUTOCOMMIT)) || (0 != ((x)->transact_status & CONN_IN_MANUAL_TRANSACTION)))
/* 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 | CONN_IN_ERROR_BEFORE_IDLE))
#define CC_is_in_trans(x) (0 != (x->transact_status & CONN_IN_TRANSACTION))
/* Manual transaction in/not functions */
#define CC_set_in_manual_trans(x) (x->transact_status |= CONN_IN_MANUAL_TRANSACTION)
#define CC_set_no_manual_trans(x) (x->transact_status &= ~CONN_IN_MANUAL_TRANSACTION)
#define CC_is_in_manual_trans(x) (0 != (x->transact_status & CONN_IN_MANUAL_TRANSACTION))
/* Error waiting for ROLLBACK */
#define CC_set_in_error_trans(x) (x->transact_status |= CONN_IN_ERROR_BEFORE_IDLE)
#define CC_set_no_error_trans(x) (x->transact_status &= ~CONN_IN_ERROR_BEFORE_IDLE)
#define CC_is_in_error_trans(x) (x->transact_status & CONN_IN_ERROR_BEFORE_IDLE)
#define CC_get_errornumber(x) (x->__error_number)
#define CC_get_errormsg(x) (x->__error_message)
#define CC_set_errornumber(x, n) (x->__error_number = n)
/* Unicode handling */
#define CONN_UNICODE_DRIVER (1L)
#define CONN_ANSI_APP (1L << 1)
#define CONN_DISALLOW_WCHAR (1L << 2)
#define CC_set_in_unicode_driver(x) (x->unicode |= CONN_UNICODE_DRIVER)
#define CC_set_in_ansi_app(x) (x->unicode |= CONN_ANSI_APP)
#define CC_is_in_unicode_driver(x) (0 != (x->unicode & CONN_UNICODE_DRIVER))
#define CC_is_in_ansi_app(x) (0 != (x->unicode & CONN_ANSI_APP))
#define CC_is_in_global_trans(x) (NULL != (x)->asdum)
#define ALLOW_WCHAR(x) (0 != (x->unicode & CONN_UNICODE_DRIVER) && 0 == (x->unicode & CONN_DISALLOW_WCHAR))
#define CC_MALLOC_return_with_error(t, tp, s, x, m, ret) \
do { \
if (t = malloc(s), NULL == t) \
{ \
CC_set_error(x, CONN_NO_MEMORY_ERROR, m, ""); \
return ret; \
} \
} while (0)
#define CC_REALLOC_return_with_error(t, tp, s, x, m, ret) \
do { \
tp *tmp; \
if (tmp = (tp *) realloc(t, s), NULL == tmp) \
{ \
CC_set_error(x, CONN_NO_MEMORY_ERROR, m, ""); \
return ret; \
} \
t = tmp; \
} while (0)
/* For Multi-thread */
#if defined(WIN_MULTITHREAD_SUPPORT)
#define INIT_CONN_CS(x) InitializeCriticalSection(&((x)->cs))
#define INIT_CONNLOCK(x) InitializeCriticalSection(&((x)->slock))
#define ENTER_CONN_CS(x) EnterCriticalSection(&((x)->cs))
#define CONNLOCK_ACQUIRE(x) EnterCriticalSection(&((x)->slock))
#define TRY_ENTER_CONN_CS(x) TryEnterCriticalSection(&((x)->cs))
#define ENTER_INNER_CONN_CS(x, entered) \
do { \
EnterCriticalSection(&((x)->cs)); \
entered++; \
} while (0)
#define LEAVE_CONN_CS(x) LeaveCriticalSection(&((x)->cs))
#define CONNLOCK_RELEASE(x) LeaveCriticalSection(&((x)->slock))
#define DELETE_CONN_CS(x) DeleteCriticalSection(&((x)->cs))
#define DELETE_CONNLOCK(x) DeleteCriticalSection(&((x)->slock))
#elif defined(POSIX_THREADMUTEX_SUPPORT)
#define INIT_CONN_CS(x) pthread_mutex_init(&((x)->cs), getMutexAttr())
#define INIT_CONNLOCK(x) pthread_mutex_init(&((x)->slock), getMutexAttr())
#define ENTER_CONN_CS(x) pthread_mutex_lock(&((x)->cs))
#define CONNLOCK_ACQUIRE(x) pthread_mutex_lock(&((x)->slock))
#define TRY_ENTER_CONN_CS(x) (0 == pthread_mutex_trylock(&((x)->cs)))
#define ENTER_INNER_CONN_CS(x, entered) \
do { \
if (getMutexAttr()) \
{ \
if (pthread_mutex_lock(&((x)->cs)) == 0) \
entered++; \
} \
} while (0)
#define LEAVE_CONN_CS(x) pthread_mutex_unlock(&((x)->cs))
#define CONNLOCK_RELEASE(x) pthread_mutex_unlock(&((x)->slock))
#define DELETE_CONN_CS(x) pthread_mutex_destroy(&((x)->cs))
#define DELETE_CONNLOCK(x) pthread_mutex_destroy(&((x)->slock))
#else
#define INIT_CONN_CS(x)
#define INIT_CONNLOCK(x)
#define TRY_ENTER_CONN_CS(x) (1)
#define ENTER_CONN_CS(x)
#define CONNLOCK_ACQUIRE(x)
#define ENTER_INNER_CONN_CS(x, entered)
#define LEAVE_CONN_CS(x)
#define CONNLOCK_RELEASE(x)
#define DELETE_CONN_CS(x)
#define DELETE_CONNLOCK(x)
#endif /* WIN_MULTITHREAD_SUPPORT */
#define LEAVE_INNER_CONN_CS(entered, conn) \
do { \
if (entered > 0) \
{ \
LEAVE_CONN_CS(conn); \
entered--; \
} \
} while (0)
#define CLEANUP_FUNC_CONN_CS(entered, conn) \
do { \
while (entered > 0) \
{ \
LEAVE_CONN_CS(conn); \
entered--; \
} \
} while (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 STRING_AFTER_DOT(string) (strchr(#string, '.') + 1)
/*
* 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
{
Int2 refcnt;
QResultClass *result;
pgNAME schema_name;
pgNAME table_name;
OID table_oid;
int table_info;
time_t acc_time;
};
enum {
TBINFO_HASOIDS = 1L
,TBINFO_HASSUBCLASS = (1L << 1)
};
#define free_col_info_contents(coli) \
{ \
if (NULL != coli->result) \
QR_Destructor(coli->result); \
coli->result = NULL; \
NULL_THE_NAME(coli->schema_name); \
NULL_THE_NAME(coli->table_name); \
coli->table_oid = 0; \
coli->refcnt = 0; \
coli->acc_time = 0; \
}
#define col_info_initialize(coli) (memset(coli, 0, sizeof(COL_INFO)))
/* Translation DLL entry points */
#ifdef WIN32
#define DLLHANDLE HINSTANCE
#else
#define WINAPI CALLBACK
#define DLLHANDLE void *
#define HINSTANCE void *
#endif
typedef BOOL (WINAPI * DataSourceToDriverProc) (UDWORD, SWORD, PTR,
SDWORD, PTR, SDWORD, SDWORD *, UCHAR *, SWORD,
SWORD *);
typedef BOOL (WINAPI * DriverToDataSourceProc) (UDWORD, SWORD, PTR,
SDWORD, PTR, SDWORD, SDWORD *, UCHAR *, SWORD,
SWORD *);
/******* The Connection handle ************/
struct ConnectionClass_
{
HENV henv; /* environment this connection was
* created on */
SQLUINTEGER login_timeout;
signed char autocommit_public;
StatementOptions stmtOptions;
ARDFields ardOptions;
APDFields apdOptions;
char *__error_message;
int __error_number;
char sqlstate[8];
CONN_Status status;
ConnInfo connInfo;
StatementClass **stmts;
Int2 num_stmts;
Int2 ncursors;
PGconn *pqconn;
Int4 lobj_type;
Int2 coli_allocated;
Int2 ntables;
COL_INFO **col_info;
long translation_option;
HINSTANCE translation_handle;
DataSourceToDriverProc DataSourceToDriver;
DriverToDataSourceProc DriverToDataSource;
char transact_status; /* Is a transaction is currently
* in progress */
char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL
* we're connected to -
* DJP 25-1-2001 */
Int2 pg_version_major;
Int2 pg_version_minor;
char ms_jet;
char unicode;
char result_uncommitted;
char lo_is_domain;
char current_schema_valid; /* is current_schema valid? TRUE when
* current_schema == NULL means it's
* really NULL, while FALSE means it's
* unknown */
unsigned char on_commit_in_progress;
/* for per statement rollback */
char internal_svp; /* is set? */
char internal_op; /* operation being executed as to internal savepoint */
unsigned char rbonerr;
unsigned char opt_in_progress;
unsigned char opt_previous;
char *original_client_encoding;
char *locale_encoding;
char *server_encoding;
Int2 ccsc;
Int2 mb_maxbyte_per_char;
SQLUINTEGER isolation; /* isolation level initially unknown */
SQLUINTEGER server_isolation; /* isolation at server initially unknown */
char *current_schema;
StatementClass *unnamed_prepared_stmt;
Int2 max_identifier_length;
Int2 num_discardp;
char **discardp;
int num_descs;
SQLUINTEGER default_isolation; /* server's default isolation initially unkown */
DescriptorClass **descs;
pgNAME schemaIns;
pgNAME tableIns;
SQLULEN stmt_timeout_in_effect;
#if defined(WIN_MULTITHREAD_SUPPORT)
CRITICAL_SECTION cs;
CRITICAL_SECTION slock;
#elif defined(POSIX_THREADMUTEX_SUPPORT)
pthread_mutex_t cs;
pthread_mutex_t slock;
#endif /* WIN_MULTITHREAD_SUPPORT */
#ifdef _HANDLE_ENLIST_IN_DTC_
UInt4 gTranInfo;
void *asdum;
#endif /* _HANDLE_ENLIST_IN_DTC_ */
};
/* Accessor functions */
#define CC_get_env(x) ((x)->henv)
#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')
#define CC_fake_mss(x) (/* 0 != (x)->ms_jet && */ 0 < (x)->connInfo.fake_mss)
#define CC_accessible_only(x) (0 < (x)->connInfo.accessible_only)
#define CC_default_is_c(x) (CC_is_in_ansi_app(x) || x->ms_jet /* not only */ || TRUE /* but for any other ? */)
#ifdef _HANDLE_ENLIST_IN_DTC_
enum {
DTC_IN_PROGRESS = 1L
,DTC_ENLISTED = (1L << 1)
,DTC_REQUEST_EXECUTING = (1L << 2)
,DTC_ISOLATED = (1L << 3)
,DTC_PREPARE_REQUESTED = (1L << 4)
};
#define CC_set_dtc_clear(x) ((x)->gTranInfo = 0)
#define CC_set_dtc_enlisted(x) ((x)->gTranInfo |= (DTC_IN_PROGRESS | DTC_ENLISTED))
#define CC_no_dtc_enlisted(x) ((x)->gTranInfo &= (~DTC_ENLISTED))
#define CC_is_dtc_enlisted(x) (0 != ((x)->gTranInfo & DTC_ENLISTED))
#define CC_set_dtc_executing(x) ((x)->gTranInfo |= DTC_REQUEST_EXECUTING)
#define CC_no_dtc_executing(x) ((x)->gTranInfo &= (~DTC_REQUEST_EXECUTING))
#define CC_is_dtc_executing(x) (0 != ((x)->gTranInfo & DTC_REQUEST_EXECUTING))
#define CC_set_dtc_prepareRequested(x) ((x)->gTranInfo |= (DTC_PREPARE_REQUESTED))
#define CC_no_dtc_prepareRequested(x) ((x)->gTranInfo &= (~DTC_PREPARE_REQUESTED))
#define CC_is_dtc_prepareRequested(x) (0 != ((x)->gTranInfo & DTC_PREPARE_REQUESTED))
#define CC_is_dtc_executing(x) (0 != ((x)->gTranInfo & DTC_REQUEST_EXECUTING))
#define CC_set_dtc_isolated(x) ((x)->gTranInfo |= DTC_ISOLATED)
#define CC_is_idle_in_global_transaction(x) (0 != ((x)->gTranInfo & DTC_PREPARE_REQUESTED) || (x)->gTranInfo == DTC_IN_PROGRESS)
#endif /* _HANDLE_ENLIST_IN_DTC_ */
/* statement callback */
#define CC_start_stmt(a) ((a)->rbonerr = 0)
#define CC_start_tc_stmt(a) ((a)->rbonerr = (1L << 1))
#define CC_is_tc_stmt(a) (((a)->rbonerr & (1L << 1)) != 0)
#define CC_start_rb_stmt(a) ((a)->rbonerr = (1L << 2))
#define CC_is_rb_stmt(a) (((a)->rbonerr & (1L << 2)) != 0)
#define CC_set_accessed_db(a) ((a)->rbonerr |= (1L << 3))
#define CC_accessed_db(a) (((a)->rbonerr & (1L << 3)) != 0)
#define CC_start_rbpoint(a) ((a)->rbonerr |= (1L << 4), (a)->internal_svp = 1)
#define CC_started_rbpoint(a) (((a)->rbonerr & (1L << 4)) != 0)
/* prototypes */
ConnectionClass *CC_Constructor(void);
char CC_Destructor(ConnectionClass *self);
int CC_cursor_count(ConnectionClass *self);
char CC_cleanup(ConnectionClass *self, BOOL keepCommunication);
char CC_begin(ConnectionClass *self);
char CC_commit(ConnectionClass *self);
char CC_abort(ConnectionClass *self);
char CC_set_autocommit(ConnectionClass *self, BOOL on);
int CC_set_translation(ConnectionClass *self);
char CC_connect(ConnectionClass *self, char *salt);
char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt)
;
char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc);
char CC_remove_descriptor(ConnectionClass *self, DescriptorClass *desc);
void CC_set_error(ConnectionClass *self, int number, const char *message, const char *func);
void CC_set_errormsg(ConnectionClass *self, const char *message);
char CC_get_error(ConnectionClass *self, int *number, char **message);
QResultClass *CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UDWORD flag, StatementClass *stmt, const char *appendq);
#define CC_send_query(self, query, qi, flag, stmt) CC_send_query_append(self, query, qi, flag, stmt, NULL)
void handle_pgres_error(ConnectionClass *self, const PGresult *pgres,
const char *comment,
QResultClass *res, BOOL error_not_a_notice);
void CC_clear_error(ConnectionClass *self);
int CC_send_function(ConnectionClass *conn, const char *fn_name, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);
char CC_send_settings(ConnectionClass *self, const char *set_query);
void CC_initialize_pg_version(ConnectionClass *conn);
void CC_log_error(const char *func, const char *desc, const ConnectionClass *self);
int CC_send_cancel_request(const ConnectionClass *conn);
void CC_on_commit(ConnectionClass *conn);
void CC_on_abort(ConnectionClass *conn, unsigned int opt);
void CC_on_abort_partial(ConnectionClass *conn);
void ProcessRollback(ConnectionClass *conn, BOOL undo, BOOL partial);
const char *CC_get_current_schema(ConnectionClass *conn);
int CC_mark_a_object_to_discard(ConnectionClass *conn, int type, const char *plan);
int CC_discard_marked_objects(ConnectionClass *conn);
int CC_get_max_idlen(ConnectionClass *self);
char CC_get_escape(const ConnectionClass *self);
char * identifierEscape(const SQLCHAR *src, SQLLEN srclen, const ConnectionClass *conn, char *buf, size_t bufsize, BOOL double_quote);
int findIdentifier(const UCHAR *str, int ccsc, const UCHAR **next_token);
int eatTableIdentifiers(const UCHAR *str, int ccsc, pgNAME *table, pgNAME *schema);
const char *CurrCat(const ConnectionClass *self);
const char *CurrCatString(const ConnectionClass *self);
SQLUINTEGER CC_get_isolation(ConnectionClass *self);
SQLCHAR *make_lstring_ifneeded(ConnectionClass *, const SQLCHAR *s, ssize_t len, BOOL);
#define TABLE_IS_VALID(tbname, tblen) ((tbname) && (tblen > 0 || SQL_NTS == tblen))
int schema_str(char *buf, int buflen, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn);
char *schema_strcat(char *buf, int buflen, const char *fmt, const SQLCHAR *s, SQLLEN len,
BOOL table_is_valid, ConnectionClass *conn);
char *schema_strcat1(char *buf, int buflen, const char *fmt, const char *s1,
const char *s,
const SQLCHAR *, int, ConnectionClass *conn);
void schema_appendPQExpBuffer(PQExpBufferData *buf, const char *fmt, const SQLCHAR *s, SQLLEN len,
BOOL table_is_valid, ConnectionClass *conn);
void schema_appendPQExpBuffer1(PQExpBufferData *buf, const char *fmt, const char *s1, const char *s,
BOOL table_is_valid, ConnectionClass *conn);
void CC_examine_global_transaction(ConnectionClass *self);
BOOL CC_set_transact(ConnectionClass *self, UInt4 isolation);
int CC_send_client_encoding(ConnectionClass *self, const char *encoding);
/* CC_send_query options */
enum {
IGNORE_ABORT_ON_CONN = 1L /* not set the error result even when */
,CREATE_KEYSET = (1L << 1) /* create keyset for updatable cursors */
,GO_INTO_TRANSACTION = (1L << 2) /* issue BEGIN in advance */
,ROLLBACK_ON_ERROR = (1L << 3) /* rollback the query when an error occurs */
,END_WITH_COMMIT = (1L << 4) /* the query ends with COMMIT command */
,READ_ONLY_QUERY = (1L << 5) /* the query is read-only */
};
/* CC_on_abort options */
#define NO_TRANS 1L
#define CONN_DEAD (1L << 1) /* connection is no longer valid */
/*
* internal savepoint related
*/
#define _RELEASE_INTERNAL_SAVEPOINT
/* Internal rollback */
enum {
PER_STATEMENT_ROLLBACK = 1
,PER_QUERY_ROLLBACK
};
int CC_internal_rollback(ConnectionClass *, int rollback_type, BOOL ignore_abort);
/* Commands generated */
enum {
INTERNAL_SAVEPOINT_OPERATION = 1
,INTERNAL_ROLLBACK_OPERATION
};
int GenerateSvpCommand(ConnectionClass *conn, int type, char *cmd, int bufsize);
/* Operations in progress */
enum {
SAVEPOINT_IN_PROGRESS = 1
,PREPEND_IN_PROGRESS
};
/* StatementSvp entry option */
enum {
SVPOPT_RDONLY = 1L
,SVPOPT_REDUCE_ROUNDTRIP = (1L << 1)
};
#define INIT_SVPOPT (SVPOPT_RDONLY)
#define CC_svp_init(a) ((a)->internal_svp = (a)->internal_op = 0, (a)->opt_in_progress = (a)->opt_previous = INIT_SVPOPT)
#define CC_init_opt_in_progress(a) ((a)->opt_in_progress = INIT_SVPOPT)
#define CC_init_opt_previous(a) ((a)->opt_previous = INIT_SVPOPT)
#ifdef __cplusplus
}
#endif
#endif /* __CONNECTION_H__ */

86
connexp.h Normal file
View File

@ -0,0 +1,86 @@
/* File: connexp.h
*
* Description: See "connection.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __CONNEXPORT_H__
#define __CONNEXPORT_H__
/*
* The psqlodbc dll exports functions below used in the pgenlist dll.
*
*/
#undef DLL_DECLARE
#ifdef _PGDTC_FUNCS_IMPLEMENT_
#define DLL_DECLARE _declspec(dllexport)
#else
#ifdef _PGDTC_FUNCS_IMPORT_
#define DLL_DECLARE _declspec(dllimport)
#else
#define DLL_DECLARE
#endif /* _PGDTC_FUNC_IMPORT_ */
#endif /* _PGDTC_FUNCS_IMPLEMENT_ */
#ifdef __cplusplus
extern "C" {
#endif
#define KEYWORD_DTC_CHECK "dtchk"
#define DTC_CHECK_LINK_ONLY 1
#define DTC_CHECK_BEFORE_LINK 2
#define DTC_CHECK_RM_CONNECTION 3
/* Property */
enum {
inprogress
,enlisted
,inTrans /* read-only */
,errorNumber /* read_only */
,idleInGlobalTransaction /* read-only */
,connected /* read-only */
,prepareRequested
};
/* PgDtc_isolate option */
enum {
disposingConnection = 1L
,useAnotherRoom = (1L << 1)
};
/* One phase commit operations */
enum {
ONE_PHASE_COMMIT = 0
,ONE_PHASE_ROLLBACK
,ABORT_GLOBAL_TRANSACTION
,SHUTDOWN_LOCAL_TRANSACTION
};
/* Two phase commit operations */
enum {
PREPARE_TRANSACTION = 0
,COMMIT_PREPARED
,ROLLBACK_PREPARED
};
DLL_DECLARE void PgDtc_create_connect_string(void *self, char *connstr, int strsize);
DLL_DECLARE int PgDtc_is_recovery_available(void *self, char *reason, int rsize);
DLL_DECLARE void PgDtc_set_async(void *self, void *async);
DLL_DECLARE void *PgDtc_get_async(void *self);
DLL_DECLARE void PgDtc_set_property(void *self, int property, void *value);
DLL_DECLARE void PgDtc_set_error(void *self, const char *message, const char *func);
DLL_DECLARE int PgDtc_get_property(void *self, int property);
DLL_DECLARE BOOL PgDtc_connect(void *self);
DLL_DECLARE void PgDtc_free_connect(void *self);
DLL_DECLARE BOOL PgDtc_one_phase_operation(void *self, int operation);
DLL_DECLARE BOOL PgDtc_two_phase_operation(void *self, int operation, const char *gxid);
DLL_DECLARE BOOL PgDtc_lock_cntrl(void *self, BOOL acquire, BOOL bTrial);
DLL_DECLARE void *PgDtc_isolate(void *self, DWORD option);
#ifdef __cplusplus
}
#endif
#endif /* __CONNEXPORT_H__ */

6623
convert.c Normal file

File diff suppressed because it is too large Load Diff

55
convert.h Normal file
View File

@ -0,0 +1,55 @@
/* File: convert.h
*
* Description: See "convert.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __CONVERT_H__
#define __CONVERT_H__
#include "psqlodbc.h"
#ifdef __cplusplus
extern "C" {
#endif
/* 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
#define COPY_INVALID_STRING_CONVERSION 6
int copy_and_convert_field_bindinfo(StatementClass *stmt, OID field_type, int atttypmod, void *value, int col);
int copy_and_convert_field(StatementClass *stmt,
OID field_type, int atttypmod,
void *value,
SQLSMALLINT fCType, int precision,
PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue, SQLLEN *pIndicator);
int copy_statement_with_parameters(StatementClass *stmt, BOOL);
SQLLEN pg_hex2bin(const char *in, char *out, SQLLEN len);
size_t findTag(const char *str, int ccsc);
BOOL build_libpq_bind_params(StatementClass *stmt,
int *nParams, OID **paramTypes,
char ***paramValues,
int **paramLengths,
int **paramFormats,
int *resultFormat);
BOOL build_libpq_bind_params_batch(StatementClass *stmt,
int *nParams,
int *nBatchCount,
OID **paramTypes,
char ***paramValues,
int **paramLengths,
int **paramFormats,
int *resultFormat);
#ifdef __cplusplus
}
#endif
#endif

747
descriptor.c Normal file
View File

@ -0,0 +1,747 @@
/*-------
* Module: descriptor.c
*
* Description: This module contains functions related to creating
* and manipulating a statement.
*
* Classes: DescriptorClass (Functions prefix: "DC_")
*
*
* Comments: See "readme.txt" for copyright and license information.
*-------
*/
#include "environ.h"
#include "connection.h"
#include "descriptor.h"
#include "statement.h"
#include "qresult.h"
#include "misc.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "pgapifunc.h"
void TI_Constructor(TABLE_INFO *self, const ConnectionClass *conn)
{
memset(self, 0, sizeof(TABLE_INFO));
TI_set_updatable(self);
}
void TI_Destructor(TABLE_INFO **ti, int count)
{
int i;
MYLOG(DETAIL_LOG_LEVEL, "entering count=%d\n", count);
if (ti)
{
for (i = 0; i < count; i++)
{
if (ti[i])
{
COL_INFO *coli = ti[i]->col_info;
if (coli)
{
MYLOG(0, "!!!refcnt %p:%d -> %d\n", coli, coli->refcnt, coli->refcnt - 1);
coli->refcnt--;
if (coli->refcnt <= 0 && 0 == coli->acc_time) /* acc_time == 0 means the table is dropped */
free_col_info_contents(coli);
}
NULL_THE_NAME(ti[i]->schema_name);
NULL_THE_NAME(ti[i]->table_name);
NULL_THE_NAME(ti[i]->table_alias);
NULL_THE_NAME(ti[i]->bestitem);
NULL_THE_NAME(ti[i]->bestqual);
TI_Destroy_IH(ti[i]);
free(ti[i]);
ti[i] = NULL;
}
}
}
}
void FI_Constructor(FIELD_INFO *self, BOOL reuse)
{
MYLOG(DETAIL_LOG_LEVEL, "entering reuse=%d\n", reuse);
if (reuse)
FI_Destructor(&self, 1, FALSE);
memset(self, 0, sizeof(FIELD_INFO));
self->nullable = TRUE;
self->columnkey = -1;
self->typmod = -1;
}
void FI_Destructor(FIELD_INFO **fi, int count, BOOL freeFI)
{
int i;
MYLOG(DETAIL_LOG_LEVEL, "entering count=%d\n", count);
if (fi)
{
for (i = 0; i < count; i++)
{
if (fi[i])
{
NULL_THE_NAME(fi[i]->column_name);
NULL_THE_NAME(fi[i]->column_alias);
NULL_THE_NAME(fi[i]->schema_name);
NULL_THE_NAME(fi[i]->before_dot);
if (freeFI)
{
free(fi[i]);
fi[i] = NULL;
}
}
}
if (freeFI)
free(fi);
}
}
static const pgNAME invNAME = {NULL};
#define INIT_IH 32
void TI_Create_IH(TABLE_INFO *ti)
{
int alloc = INIT_IH;
InheritanceClass *ih;
ih = (InheritanceClass *) malloc(sizeof(InheritanceClass) + (alloc - 1) * sizeof(ih->inf[0]));
memset(ih, 0, sizeof(InheritanceClass));
ih->allocated = alloc;
ti->ih = ih;
}
void TI_Destroy_IH(TABLE_INFO *ti)
{
InheritanceClass *ih;
int i;
if (NULL == (ih = ti->ih))
return;
for (i = 0; i < ih->count; i++)
{
NULL_THE_NAME(ih->inf[i].fullTable);
}
free(ih);
ti->ih = NULL;
}
const pgNAME TI_From_IH(TABLE_INFO *ti, OID tableoid)
{
InheritanceClass *ih;
int i;
if (NULL == (ih = ti->ih))
return invNAME;
if (tableoid == ih->cur_tableoid)
return ih->cur_fullTable;
for (i = 0; i < ih->count; i++)
{
if (ih->inf[i].tableoid == tableoid)
{
ih->cur_tableoid = tableoid;
ih->cur_fullTable = ih->inf[i].fullTable;
return ih->cur_fullTable;
}
}
return invNAME;
}
const pgNAME TI_Ins_IH(TABLE_INFO *ti, OID tableoid, const char *fullName)
{
InheritanceClass *ih;
int count;
if (NULL == (ih = ti->ih))
{
TI_Create_IH(ti);
if (ih = ti->ih, NULL == ih)
return invNAME;
}
if ((count = ih->count) >= ih->allocated)
{
int alloc = ih->allocated * 2;
InheritanceClass *nih;
if (nih = (InheritanceClass *) realloc(ih, sizeof(InheritanceClass) + (alloc - 1) * sizeof(ih->inf[0])), NULL == nih)
{
TI_Destroy_IH(ti);
return invNAME;
}
ti->ih = ih = nih;
ih->allocated = alloc;
}
ih->inf[count].tableoid = tableoid;
INIT_NAME(ih->inf[count].fullTable);
STR_TO_NAME(ih->inf[count].fullTable, fullName);
ih->cur_tableoid = tableoid;
ih->cur_fullTable = ih->inf[count].fullTable;
ih->count++;
return ih->inf[count].fullTable;
}
void DC_Constructor(DescriptorClass *self, BOOL embedded, StatementClass *stmt)
{
memset(self, 0, sizeof(DescriptorClass));
self->deschd.embedded = embedded;
}
static void ARDFields_free(ARDFields * self)
{
MYLOG(DETAIL_LOG_LEVEL, "entering %p bookmark=%p\n", self, self->bookmark);
if (self->bookmark)
{
free(self->bookmark);
self->bookmark = NULL;
}
/*
* the memory pointed to by the bindings is not deallocated by the
* driver but by the application that uses that driver, so we don't
* have to care
*/
ARD_unbind_cols(self, TRUE);
}
static void APDFields_free(APDFields * self)
{
if (self->bookmark)
{
free(self->bookmark);
self->bookmark = NULL;
}
/* param bindings */
APD_free_params(self, STMT_FREE_PARAMS_ALL);
}
static void IRDFields_free(IRDFields * self)
{
/* Free the parsed field information */
if (self->fi)
{
FI_Destructor(self->fi, self->allocated, TRUE);
self->fi = NULL;
}
self->allocated = 0;
self->nfields = 0;
}
static void IPDFields_free(IPDFields * self)
{
/* param bindings */
IPD_free_params(self, STMT_FREE_PARAMS_ALL);
}
void DC_Destructor(DescriptorClass *self)
{
DescriptorHeader *deschd = &(self->deschd);
if (deschd->__error_message)
{
free(deschd->__error_message);
deschd->__error_message = NULL;
}
if (deschd->pgerror)
{
ER_Destructor(deschd->pgerror);
deschd->pgerror = NULL;
}
if (deschd->type_defined)
{
switch (deschd->desc_type)
{
case SQL_ATTR_APP_ROW_DESC:
ARDFields_free(&(self->ardf));
break;
case SQL_ATTR_APP_PARAM_DESC:
APDFields_free(&(self->apdf));
break;
case SQL_ATTR_IMP_ROW_DESC:
IRDFields_free(&(self->irdf));
break;
case SQL_ATTR_IMP_PARAM_DESC:
IPDFields_free(&(self->ipdf));
break;
}
}
}
void InitializeEmbeddedDescriptor(DescriptorClass *self, StatementClass *stmt,
UInt4 desc_type)
{
DescriptorHeader *deschd = &(self->deschd);
DC_Constructor(self, TRUE, stmt);
DC_get_conn(self) = SC_get_conn(stmt);
deschd->type_defined = TRUE;
deschd->desc_type = desc_type;
switch (desc_type)
{
case SQL_ATTR_APP_ROW_DESC:
memset(&(self->ardf), 0, sizeof(ARDFields));
stmt->ard = self;
break;
case SQL_ATTR_APP_PARAM_DESC:
memset(&(self->apdf), 0, sizeof(APDFields));
stmt->apd = self;
break;
case SQL_ATTR_IMP_ROW_DESC:
memset(&(self->irdf), 0, sizeof(IRDFields));
stmt->ird = self;
stmt->ird->irdf.stmt = stmt;
break;
case SQL_ATTR_IMP_PARAM_DESC:
memset(&(self->ipdf), 0, sizeof(IPDFields));
stmt->ipd = self;
break;
}
}
/*
* ARDFields initialize
*/
void
InitializeARDFields(ARDFields *opt)
{
memset(opt, 0, sizeof(ARDFields));
opt->size_of_rowset = 1;
opt->bind_size = 0; /* default is to bind by column */
opt->size_of_rowset_odbc2 = 1;
}
/*
* APDFields initialize
*/
void
InitializeAPDFields(APDFields *opt)
{
memset(opt, 0, sizeof(APDFields));
opt->paramset_size = 1;
opt->param_bind_type = 0; /* default is to bind by column */
opt->paramset_size_dummy = 1; /* dummy setting */
}
BindInfoClass *ARD_AllocBookmark(ARDFields *ardopts)
{
if (!ardopts->bookmark)
{
ardopts->bookmark = (BindInfoClass *) malloc(sizeof(BindInfoClass));
if (ardopts->bookmark)
memset(ardopts->bookmark, 0, sizeof(BindInfoClass));
}
return ardopts->bookmark;
}
#define DESC_INCREMENT 10
char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc)
{
int i;
int new_num_descs;
DescriptorClass **descs;
MYLOG(0, "entering self=%p, desc=%p\n", self, desc);
for (i = 0; i < self->num_descs; i++)
{
if (!self->descs[i])
{
DC_get_conn(desc) = self;
self->descs[i] = desc;
return TRUE;
}
}
/* no more room -- allocate more memory */
new_num_descs = DESC_INCREMENT + self->num_descs;
descs = (DescriptorClass **) realloc(self->descs, sizeof(DescriptorClass *) * new_num_descs);
if (!descs)
return FALSE;
self->descs = descs;
memset(&self->descs[self->num_descs], 0, sizeof(DescriptorClass *) *
DESC_INCREMENT);
DC_get_conn(desc) = self;
self->descs[self->num_descs] = desc;
self->num_descs = new_num_descs;
return TRUE;
}
/*
* This API allocates a Application descriptor.
*/
RETCODE SQL_API
PGAPI_AllocDesc(HDBC ConnectionHandle,
SQLHDESC *DescriptorHandle)
{
CSTR func = "PGAPI_AllocDesc";
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
RETCODE ret = SQL_SUCCESS;
DescriptorClass *desc;
MYLOG(0, "entering...\n");
desc = (DescriptorClass *) malloc(sizeof(DescriptorClass));
if (desc)
{
memset(desc, 0, sizeof(DescriptorClass));
DC_get_conn(desc) = conn;
if (CC_add_descriptor(conn, desc))
*DescriptorHandle = desc;
else
{
free(desc);
CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "Maximum number of descriptors exceeded", func);
ret = SQL_ERROR;
}
}
else
{
CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "No more memory ti allocate a further descriptor", func);
ret = SQL_ERROR;
}
return ret;
}
RETCODE SQL_API
PGAPI_FreeDesc(SQLHDESC DescriptorHandle)
{
DescriptorClass *desc = (DescriptorClass *) DescriptorHandle;
RETCODE ret = SQL_SUCCESS;
MYLOG(0, "entering...\n");
DC_Destructor(desc);
if (!desc->deschd.embedded)
{
int i;
ConnectionClass *conn = DC_get_conn(desc);
for (i = 0; i < conn->num_descs; i++)
{
if (conn->descs[i] == desc)
{
conn->descs[i] = NULL;
break;
}
}
free(desc);
}
return ret;
}
static void BindInfoClass_copy(const BindInfoClass *src, BindInfoClass *target)
{
memcpy(target, src, sizeof(BindInfoClass));
}
static void ARDFields_copy(const ARDFields *src, ARDFields *target)
{
memcpy(target, src, sizeof(ARDFields));
target->bookmark = NULL;
if (src->bookmark)
{
BindInfoClass *bookmark = ARD_AllocBookmark(target);
if (bookmark)
BindInfoClass_copy(src->bookmark, bookmark);
}
if (src->allocated <= 0)
{
target->allocated = 0;
target->bindings = NULL;
}
else
{
int i;
target->bindings = malloc(target->allocated * sizeof(BindInfoClass));
if (!target->bindings)
target->allocated = 0;
for (i = 0; i < target->allocated; i++)
BindInfoClass_copy(&src->bindings[i], &target->bindings[i]);
}
}
static void ParameterInfoClass_copy(const ParameterInfoClass *src, ParameterInfoClass *target)
{
memcpy(target, src, sizeof(ParameterInfoClass));
}
static void APDFields_copy(const APDFields *src, APDFields *target)
{
memcpy(target, src, sizeof(APDFields));
if (src->bookmark)
{
target->bookmark = malloc(sizeof(ParameterInfoClass));
if (target->bookmark)
ParameterInfoClass_copy(src->bookmark, target->bookmark);
}
if (src->allocated <= 0)
{
target->allocated = 0;
target->parameters = NULL;
}
else
{
int i;
target->parameters = malloc(target->allocated * sizeof(ParameterInfoClass));
if (!target->parameters)
target->allocated = 0;
for (i = 0; i < target->allocated; i++)
ParameterInfoClass_copy(&src->parameters[i], &target->parameters[i]);
}
}
static void ParameterImplClass_copy(const ParameterImplClass *src, ParameterImplClass *target)
{
memcpy(target, src, sizeof(ParameterImplClass));
}
static void IPDFields_copy(const IPDFields *src, IPDFields *target)
{
memcpy(target, src, sizeof(IPDFields));
if (src->allocated <= 0)
{
target->allocated = 0;
target->parameters = NULL;
}
else
{
int i;
target->parameters = (ParameterImplClass *) malloc(target->allocated * sizeof(ParameterImplClass));
if (!target->parameters)
target->allocated = 0;
for (i = 0; i < target->allocated; i++)
ParameterImplClass_copy(&src->parameters[i], &target->parameters[i]);
}
}
RETCODE SQL_API
PGAPI_CopyDesc(SQLHDESC SourceDescHandle,
SQLHDESC TargetDescHandle)
{
RETCODE ret = SQL_ERROR;
DescriptorClass *src, *target;
DescriptorHeader *srchd, *targethd;
ARDFields *ard_src, *ard_tgt;
APDFields *apd_src, *apd_tgt;
IPDFields *ipd_src, *ipd_tgt;
MYLOG(0, "entering...\n");
src = (DescriptorClass *) SourceDescHandle;
target = (DescriptorClass *) TargetDescHandle;
srchd = &(src->deschd);
targethd = &(target->deschd);
if (!srchd->type_defined)
{
MYLOG(0, "source type undefined\n");
DC_set_error(target, DESC_EXEC_ERROR, "source handle type undefined");
return ret;
}
if (targethd->type_defined)
{
MYLOG(DETAIL_LOG_LEVEL, "source type=%d -> target type=%d\n", srchd->desc_type, targethd->desc_type);
if (SQL_ATTR_IMP_ROW_DESC == targethd->desc_type)
{
MYLOG(0, "can't modify IRD\n");
DC_set_error(target, DESC_EXEC_ERROR, "can't copy to IRD");
return ret;
}
else if (targethd->desc_type != srchd->desc_type)
{
if (targethd->embedded)
{
MYLOG(0, "src type != target type\n");
DC_set_error(target, DESC_EXEC_ERROR, "copying different type descriptor to embedded one");
return ret;
}
}
DC_Destructor(target);
}
ret = SQL_SUCCESS;
switch (srchd->desc_type)
{
case SQL_ATTR_APP_ROW_DESC:
MYLOG(DETAIL_LOG_LEVEL, "src=%p target=%p type=%d", src, target, srchd->desc_type);
if (!targethd->type_defined)
{
targethd->desc_type = srchd->desc_type;
}
ard_src = &(src->ardf);
MYPRINTF(DETAIL_LOG_LEVEL, " rowset_size=" FORMAT_LEN " bind_size=%d ope_ptr=%p off_ptr=%p\n",
ard_src->size_of_rowset, ard_src->bind_size,
ard_src->row_operation_ptr, ard_src->row_offset_ptr);
ard_tgt = &(target->ardf);
MYPRINTF(DETAIL_LOG_LEVEL, " target=%p", ard_tgt);
ARDFields_copy(ard_src, ard_tgt);
MYPRINTF(DETAIL_LOG_LEVEL, " offset_ptr=%p\n", ard_tgt->row_offset_ptr);
break;
case SQL_ATTR_APP_PARAM_DESC:
if (!targethd->type_defined)
{
targethd->desc_type = srchd->desc_type;
}
apd_src = &(src->apdf);
apd_tgt = &(target->apdf);
APDFields_copy(apd_src, apd_tgt);
break;
case SQL_ATTR_IMP_PARAM_DESC:
if (!targethd->type_defined)
{
targethd->desc_type = srchd->desc_type;
}
ipd_src = &(src->ipdf);
ipd_tgt = &(target->ipdf);
IPDFields_copy(ipd_src, ipd_tgt);
break;
default:
MYLOG(0, "invalid descriptor handle type=%d\n", srchd->desc_type);
DC_set_error(target, DESC_EXEC_ERROR, "invalid descriptor type");
ret = SQL_ERROR;
}
if (SQL_SUCCESS == ret)
targethd->type_defined = TRUE;
return ret;
}
void DC_clear_error(DescriptorClass *self)
{
DescriptorHeader *deschd = &(self->deschd);
if (deschd->__error_message)
{
free(deschd->__error_message);
deschd->__error_message = NULL;
}
if (deschd->pgerror)
{
ER_Destructor(deschd->pgerror);
deschd->pgerror = NULL;
}
deschd->__error_number = 0;
deschd->error_row = 0;
deschd->error_index = 0;
}
void DC_set_error(DescriptorClass *self, int errornumber, const char *errormsg)
{
DescriptorHeader *deschd = &(self->deschd);
if (deschd->__error_message)
free(deschd->__error_message);
deschd->__error_number = errornumber;
deschd->__error_message = errormsg ? strdup(errormsg) : NULL;
}
void DC_set_errormsg(DescriptorClass *self, const char *errormsg)
{
DescriptorHeader *deschd = &(self->deschd);
if (deschd->__error_message)
free(deschd->__error_message);
deschd->__error_message = errormsg ? strdup(errormsg) : NULL;
}
const char *DC_get_errormsg(const DescriptorClass *desc)
{
return desc->deschd.__error_message;
}
int DC_get_errornumber(const DescriptorClass *desc)
{
return desc->deschd.__error_number;
}
/* Map sql commands to statement types */
static const struct
{
int number;
const char ver3str[6];
const char ver2str[6];
} Descriptor_sqlstate[] =
{
{ DESC_ERROR_IN_ROW, "01S01", "01S01" },
{ DESC_OPTION_VALUE_CHANGED, "01S02", "01S02" },
{ DESC_OK, "00000", "00000" }, /* OK */
{ DESC_EXEC_ERROR, "HY000", "S1000" }, /* also a general error */
{ DESC_STATUS_ERROR, "HY010", "S1010" },
{ DESC_SEQUENCE_ERROR, "HY010", "S1010" }, /* Function sequence error */
{ DESC_NO_MEMORY_ERROR, "HY001", "S1001" }, /* memory allocation failure */
{ DESC_COLNUM_ERROR, "07009", "S1002" }, /* invalid column number */
{ DESC_NO_STMTSTRING, "HY001", "S1001" }, /* having no stmtstring is also a malloc problem */
{ DESC_ERROR_TAKEN_FROM_BACKEND, "HY000", "S1000" }, /* general error */
{ DESC_INTERNAL_ERROR, "HY000", "S1000" }, /* general error */
{ DESC_STILL_EXECUTING, "HY010", "S1010" },
{ DESC_NOT_IMPLEMENTED_ERROR, "HYC00", "S1C00" }, /* == 'driver not
* capable' */
{ DESC_BAD_PARAMETER_NUMBER_ERROR, "07009", "S1093" },
{ DESC_OPTION_OUT_OF_RANGE_ERROR, "HY092", "S1092" },
{ DESC_INVALID_COLUMN_NUMBER_ERROR, "07009", "S1002" },
{ DESC_RESTRICTED_DATA_TYPE_ERROR, "07006", "07006" },
{ DESC_INVALID_CURSOR_STATE_ERROR, "07005", "24000" },
{ DESC_CREATE_TABLE_ERROR, "42S01", "S0001" }, /* table already exists */
{ DESC_NO_CURSOR_NAME, "S1015", "S1015" },
{ DESC_INVALID_CURSOR_NAME, "34000", "34000" },
{ DESC_INVALID_ARGUMENT_NO, "HY024", "S1009" }, /* invalid argument value */
{ DESC_ROW_OUT_OF_RANGE, "HY107", "S1107" },
{ DESC_OPERATION_CANCELLED, "HY008", "S1008" },
{ DESC_INVALID_CURSOR_POSITION, "HY109", "S1109" },
{ DESC_VALUE_OUT_OF_RANGE, "HY019", "22003" },
{ DESC_OPERATION_INVALID, "HY011", "S1011" },
{ DESC_PROGRAM_TYPE_OUT_OF_RANGE, "?????", "?????" },
{ DESC_BAD_ERROR, "08S01", "08S01" }, /* communication link failure */
{ DESC_INVALID_OPTION_IDENTIFIER, "HY092", "HY092" },
{ DESC_RETURN_NULL_WITHOUT_INDICATOR, "22002", "22002" },
{ DESC_INVALID_DESCRIPTOR_IDENTIFIER, "HY091", "HY091" },
{ DESC_OPTION_NOT_FOR_THE_DRIVER, "HYC00", "HYC00" },
{ DESC_FETCH_OUT_OF_RANGE, "HY106", "S1106" },
{ DESC_COUNT_FIELD_INCORRECT, "07002", "07002" },
};
static PG_ErrorInfo *DC_create_errorinfo(const DescriptorClass *self)
{
const DescriptorHeader *deschd = &(self->deschd);
PG_ErrorInfo *error;
ConnectionClass *conn;
EnvironmentClass *env;
Int4 errornum;
BOOL env_is_odbc3 = TRUE;
if (deschd->pgerror)
return deschd->pgerror;
errornum = deschd->__error_number;
error = ER_Constructor(errornum, deschd->__error_message);
if (!error)
return error;
conn = DC_get_conn(self);
if (conn && (env = (EnvironmentClass *) conn->henv))
env_is_odbc3 = EN_is_odbc3(env);
errornum -= LOWEST_DESC_ERROR;
if (errornum < 0 ||
errornum >= sizeof(Descriptor_sqlstate) / sizeof(Descriptor_sqlstate[0]))
errornum = 1 - LOWEST_DESC_ERROR;
STRCPY_FIXED(error->sqlstate, env_is_odbc3 ? Descriptor_sqlstate[errornum].ver3str : Descriptor_sqlstate[errornum].ver2str);
return error;
}
void
DC_log_error(const char *func, const char *desc, const DescriptorClass *self)
{
#define nullcheck(a) (a ? a : "(NULL)")
if (self)
{
MYLOG(0, "DESCRIPTOR ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->deschd.__error_number, nullcheck(self->deschd.__error_message));
}
}
/* Returns the next SQL error information. */
RETCODE SQL_API
PGAPI_DescError(SQLHDESC hdesc,
SQLSMALLINT RecNumber,
SQLCHAR * szSqlState,
SQLINTEGER * pfNativeError,
SQLCHAR * szErrorMsg,
SQLSMALLINT cbErrorMsgMax,
SQLSMALLINT * pcbErrorMsg,
UWORD flag)
{
/* CC: return an error of a hdesc */
DescriptorClass *desc = (DescriptorClass *) hdesc;
DescriptorHeader *deschd = &(desc->deschd);
MYLOG(0, "entering RecN=%hd\n", RecNumber);
deschd->pgerror = DC_create_errorinfo(desc);
return ER_ReturnError(deschd->pgerror, RecNumber, szSqlState,
pfNativeError, szErrorMsg, cbErrorMsgMax,
pcbErrorMsg, flag);
}

263
descriptor.h Normal file
View File

@ -0,0 +1,263 @@
/* File: descriptor.h
*
* Description: This file contains defines and declarations that are related to
* the entire driver.
*
* Comments: See "readme.txt" for copyright and license information.
*/
#ifndef __DESCRIPTOR_H__
#define __DESCRIPTOR_H__
#include "psqlodbc.h"
typedef struct InheritanceClass
{
UInt4 allocated;
UInt4 count;
OID cur_tableoid;
pgNAME cur_fullTable;
struct {
OID tableoid;
pgNAME fullTable;
} inf[1];
} InheritanceClass;
enum {
TI_UPDATABLE = 1L
,TI_HASOIDS_CHECKED = (1L << 1)
,TI_HASOIDS = (1L << 2)
,TI_COLATTRIBUTE = (1L << 3)
,TI_HASSUBCLASS = (1L << 4)
};
typedef struct
{
OID table_oid;
COL_INFO *col_info; /* cached SQLColumns info for this table */
pgNAME schema_name;
pgNAME table_name;
pgNAME table_alias;
pgNAME bestitem;
pgNAME bestqual;
UInt4 flags;
InheritanceClass *ih;
} TABLE_INFO;
#define TI_set_updatable(ti) (ti->flags |= TI_UPDATABLE)
#define TI_is_updatable(ti) (0 != (ti->flags & TI_UPDATABLE))
#define TI_no_updatable(ti) (ti->flags &= (~TI_UPDATABLE))
#define TI_set_hasoids_checked(ti) (ti->flags |= TI_HASOIDS_CHECKED)
#define TI_checked_hasoids(ti) (0 != (ti->flags & TI_HASOIDS))
#define TI_set_hasoids(ti) (ti->flags |= TI_HASOIDS)
#define TI_has_oids(ti) (0 != (ti->flags & TI_HASOIDS))
#define TI_set_has_no_oids(ti) (ti->flags &= (~TI_HASOIDS))
#define TI_set_hassubclass(ti) (ti->flags |= TI_HASSUBCLASS)
#define TI_has_subclass(ti) (0 != (ti->flags & TI_HASSUBCLASS))
#define TI_set_has_no_subclass(ti) (ti->flags &= (~TI_HASSUBCLASS))
void TI_Constructor(TABLE_INFO *, const ConnectionClass *);
void TI_Destructor(TABLE_INFO **, int);
void TI_Create_IH(TABLE_INFO *ti);
void TI_Destroy_IH(TABLE_INFO *ti);
const pgNAME TI_From_IH(TABLE_INFO *ti, OID tableoid);
const pgNAME TI_Ins_IH(TABLE_INFO *ti, OID tableoid, const char *fullName);
enum {
FIELD_INITIALIZED = 0
,FIELD_PARSING = 1L
,FIELD_TEMP_SET = (1L << 1)
,FIELD_COL_ATTRIBUTE = (1L << 2)
,FIELD_PARSED_OK = (1L << 3)
,FIELD_PARSED_INCOMPLETE = (1L << 4)
};
typedef struct
{
char flag;
char updatable;
Int2 attnum;
pgNAME schema_name;
TABLE_INFO *ti; /* to resolve explicit table names */
pgNAME column_name;
pgNAME column_alias;
char nullable;
char auto_increment;
char func;
char columnkey;
int column_size; /* precision in 2.x */
int decimal_digits; /* scale in 2.x */
int display_size;
SQLLEN length;
OID columntype;
OID basetype; /* may be the basetype when the column type is a domain */
int typmod;
char expr;
char quote;
char dquote;
char numeric;
pgNAME before_dot;
} FIELD_INFO;
Int4 FI_precision(const FIELD_INFO *);
Int4 FI_scale(const FIELD_INFO *);
void FI_Constructor(FIELD_INFO *, BOOL reuse);
void FI_Destructor(FIELD_INFO **, int, BOOL freeFI);
#define FI_is_applicable(fi) (NULL != fi && (fi->flag & (FIELD_PARSED_OK | FIELD_COL_ATTRIBUTE)) != 0)
#define FI_type(fi) (0 == (fi)->basetype ? (fi)->columntype : (fi)->basetype)
typedef struct DescriptorHeader_
{
ConnectionClass *conn_conn;
char embedded;
char type_defined;
UInt4 desc_type;
UInt4 error_row; /* 1-based row */
UInt4 error_index; /* 1-based index */
Int4 __error_number;
char *__error_message;
PG_ErrorInfo *pgerror;
} DescriptorHeader;
/*
* ARD and APD are(must be) of the same format
*/
struct ARDFields_
{
SQLLEN size_of_rowset; /* for ODBC3 fetch operation */
SQLUINTEGER bind_size; /* size of each structure if using
* Row-wise Binding */
SQLUSMALLINT *row_operation_ptr;
SQLULEN *row_offset_ptr;
BindInfoClass *bookmark;
BindInfoClass *bindings;
SQLSMALLINT allocated;
SQLLEN size_of_rowset_odbc2; /* for SQLExtendedFetch */
};
/*
* APD must be of the same format as ARD
*/
struct APDFields_
{
SQLLEN paramset_size; /* really an SQLINTEGER type */
SQLUINTEGER param_bind_type; /* size of each structure if using
* Row-wise Parameter Binding */
SQLUSMALLINT *param_operation_ptr;
SQLULEN *param_offset_ptr;
ParameterInfoClass *bookmark; /* dummy item to fit APD to ARD */
ParameterInfoClass *parameters;
SQLSMALLINT allocated;
SQLLEN paramset_size_dummy; /* dummy item to fit APD to ARD */
};
struct IRDFields_
{
StatementClass *stmt;
SQLULEN *rowsFetched;
SQLUSMALLINT *rowStatusArray;
UInt4 nfields;
SQLSMALLINT allocated;
FIELD_INFO **fi;
};
struct IPDFields_
{
SQLULEN *param_processed_ptr;
SQLUSMALLINT *param_status_ptr;
SQLSMALLINT allocated;
ParameterImplClass *parameters;
};
/***
typedef struct
{
DescriptorHeader deschd;
ARDFields ardopts;
} ARDClass;
typedef struct
{
DescriptorHeader deschd;
APDFields apdopts;
} APDClass;
typedef struct
{
DescriptorHeader deschd;
IRDFields irdopts;
} IRDClass;
typedef struct
{
DescriptorHeader deschd;
IPDFields ipdopts;
} IPDClass;
***/
typedef struct
{
DescriptorHeader deschd;
union {
ARDFields ardf;
APDFields apdf;
IRDFields irdf;
IPDFields ipdf;
};
} DescriptorClass;
#define DC_get_conn(a) ((a)->deschd.conn_conn)
#define DC_get_desc_type(a) ((a)->deschd.desc_type)
#define DC_get_embedded(a) ((a)->deschd.embedded)
void InitializeEmbeddedDescriptor(DescriptorClass *, StatementClass *stmt,
UInt4 desc_type);
void DC_Destructor(DescriptorClass *desc);
void InitializeARDFields(ARDFields *self);
void InitializeAPDFields(APDFields *self);
BindInfoClass *ARD_AllocBookmark(ARDFields *self);
void ARD_unbind_cols(ARDFields *self, BOOL freeall);
void APD_free_params(APDFields *self, char option);
void IPD_free_params(IPDFields *self, char option);
BOOL getCOLIfromTI(const char *, ConnectionClass *, StatementClass *, const OID, TABLE_INFO **);
RETCODE DC_set_stmt(DescriptorClass *desc, StatementClass *stmt);
void DC_clear_error(DescriptorClass *desc);
void DC_set_error(DescriptorClass *desc, int errornumber, const char * errormsg);
void DC_set_errormsg(DescriptorClass *desc, const char * errormsg);
PG_ErrorInfo *DC_get_error(DescriptorClass *self);
int DC_get_errornumber(const DescriptorClass *self);
const char *DC_get_errormsg(const DescriptorClass *self);
void DC_log_error(const char *func, const char *desc, const DescriptorClass *self);
/* Error numbers about descriptor handle */
enum {
LOWEST_DESC_ERROR = -2
/* minus means warning/notice message */
,DESC_ERROR_IN_ROW = -2
,DESC_OPTION_VALUE_CHANGED = -1
,DESC_OK = 0
,DESC_EXEC_ERROR
,DESC_STATUS_ERROR
,DESC_SEQUENCE_ERROR
,DESC_NO_MEMORY_ERROR
,DESC_COLNUM_ERROR
,DESC_NO_STMTSTRING
,DESC_ERROR_TAKEN_FROM_BACKEND
,DESC_INTERNAL_ERROR
,DESC_STILL_EXECUTING
,DESC_NOT_IMPLEMENTED_ERROR
,DESC_BAD_PARAMETER_NUMBER_ERROR
,DESC_OPTION_OUT_OF_RANGE_ERROR
,DESC_INVALID_COLUMN_NUMBER_ERROR
,DESC_RESTRICTED_DATA_TYPE_ERROR
,DESC_INVALID_CURSOR_STATE_ERROR
,DESC_CREATE_TABLE_ERROR
,DESC_NO_CURSOR_NAME
,DESC_INVALID_CURSOR_NAME
,DESC_INVALID_ARGUMENT_NO
,DESC_ROW_OUT_OF_RANGE
,DESC_OPERATION_CANCELLED
,DESC_INVALID_CURSOR_POSITION
,DESC_VALUE_OUT_OF_RANGE
,DESC_OPERATION_INVALID
,DESC_PROGRAM_TYPE_OUT_OF_RANGE
,DESC_BAD_ERROR
,DESC_INVALID_OPTION_IDENTIFIER
,DESC_RETURN_NULL_WITHOUT_INDICATOR
,DESC_INVALID_DESCRIPTOR_IDENTIFIER
,DESC_OPTION_NOT_FOR_THE_DRIVER
,DESC_FETCH_OUT_OF_RANGE
,DESC_COUNT_FIELD_INCORRECT
};
#endif /* __DESCRIPTOR_H__ */

1871
dlg_specific.c Normal file

File diff suppressed because it is too large Load Diff

331
dlg_specific.h Normal file
View File

@ -0,0 +1,331 @@
/* File: dlg_specific.h
*
* Description: See "dlg_specific.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __DLG_SPECIFIC_H__
#define __DLG_SPECIFIC_H__
#include "psqlodbc.h"
#ifdef WIN32
#include <windowsx.h>
#include "resource.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* 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 ODBC_DATASOURCES "ODBC Data Sources"
#define INVALID_DRIVER " @@driver not exist@@ "
#ifdef UNICODE_SUPPORT
#define INI_DSN "PostgreSQL35W"
#else
#define INI_DSN "PostgreSQL30"
#endif /* UNICODE_SUPPORT */
#define INI_KDESC "Description" /* Data source
* description */
#define INI_SERVER "Servername" /* Name of Server
* running the Postgres
* service */
#define SPEC_SERVER "server"
#define INI_PORT "Port" /* Port on which the
* Postmaster is listening */
#define INI_DATABASE "Database" /* Database Name */
#define INI_UID "UID" /* Default User Name */
#define INI_USERNAME "Username" /* Default User Name */
#define INI_PASSWORD "Password" /* Default Password */
#define INI_ABBREVIATE "CX"
#define INI_DEBUG "Debug" /* Debug flag */
#define ABBR_DEBUG "B2"
#define INI_FETCH "Fetch" /* Fetch Max Count */
#define ABBR_FETCH "A7"
/*
* "Socket", abbreviated as "A8" was used for socket buffer. Now that we do
* everything through libpq, it's not used
*/
#define INI_READONLY "ReadOnly" /* Database is read only */
#define ABBR_READONLY "A0"
#define INI_COMMLOG "CommLog" /* Communication to
* backend logging */
#define ABBR_COMMLOG "B3"
#define INI_PROTOCOL "Protocol" /* Controls rollback-on-error
* behavior. Called "Protocol"
* for historical reasons */
#define ABBR_PROTOCOL "A1"
/* "Optimizer", abbreviated to B4 used to stand for "disable genetic query
* optimizer". No longer supported, you can use generic ConnSettings instead.
#define INI_OPTIMIZER "Optimizer"
#define ABBR_OPTIMIZER "B4"
*/
/* "Ksqo", abbreviated to B5 was used with pre-7.1 server versions for
* "keyset query optimization". No longer used.
#define INI_KSQO "Ksqo"
#define ABBR_KSQO "B5"
*/
#define INI_CONNSETTINGS "ConnSettings" /* Anything to send to
* backend on successful
* connection */
#define ABBR_CONNSETTINGS "A6"
#define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique
* indexes */
#define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown
* result set sizes */
#define ABBR_UNKNOWNSIZES "A9"
/* "CancelAsFreeStmt", abbreviated to "C1" was used with ODBC versions older
* than 3.51. It was a hack that made SQLCancel to imply
* SQLFreeStmt(SQL_CLOSE). It never had an effect in > 3.51 mode.
#define INI_CANCELASFREESTMT "CancelAsFreeStmt"
#define ABBR_CANCELASFREESTMT "C1"
*/
#define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch
* cursors */
#define ABBR_USEDECLAREFETCH "B6"
#define INI_FOREXTENSIONCONNECTOR "ForExtensionConnector"
/* More ini stuff */
#define INI_TEXTASLONGVARCHAR "TextAsLongVarchar"
#define ABBR_TEXTASLONGVARCHAR "B7"
#define INI_UNKNOWNSASLONGVARCHAR "UnknownsAsLongVarchar"
#define ABBR_UNKNOWNSASLONGVARCHAR "B8"
#define INI_BOOLSASCHAR "BoolsAsChar"
#define ABBR_BOOLSASCHAR "B9"
#define INI_MAXVARCHARSIZE "MaxVarcharSize"
#define ABBR_MAXVARCHARSIZE "B0"
#define INI_MAXLONGVARCHARSIZE "MaxLongVarcharSize"
#define ABBR_MAXLONGVARCHARSIZE "B1"
#define INI_FAKEOIDINDEX "FakeOidIndex"
#define ABBR_FAKEOIDINDEX "A2"
#define INI_SHOWOIDCOLUMN "ShowOidColumn"
#define ABBR_SHOWOIDCOLUMN "A3"
#define INI_ROWVERSIONING "RowVersioning"
#define ABBR_ROWVERSIONING "A4"
#define INI_SHOWSYSTEMTABLES "ShowSystemTables"
#define ABBR_SHOWSYSTEMTABLES "A5"
#define INI_LIE "Lie"
#define INI_PARSE "Parse"
#define ABBR_PARSE "C0"
#define INI_EXTRASYSTABLEPREFIXES "ExtraSysTablePrefixes"
#define ABBR_EXTRASYSTABLEPREFIXES "C2"
#define INI_TRANSLATIONNAME "TranslationName"
#define INI_TRANSLATIONDLL "TranslationDLL"
#define INI_TRANSLATIONOPTION "TranslationOption"
/*
* "DisallowPremature", abbreviated "C3", used to mean that we should not
* execute a statement prematurely, before SQLExecute() when e.g.
* SQLPrepare+SQLDescribeCol is called. We never do that anymore.
*
#define INI_DISALLOWPREMATURE "DisallowPremature"
#define ABBR_DISALLOWPREMATURE "C3"
*/
#define INI_UPDATABLECURSORS "UpdatableCursors"
#define ABBR_UPDATABLECURSORS "C4"
#define INI_LFCONVERSION "LFConversion"
#define ABBR_LFCONVERSION "C5"
#define INI_TRUEISMINUS1 "TrueIsMinus1"
#define ABBR_TRUEISMINUS1 "C6"
#define INI_INT8AS "BI"
#define INI_BYTEAASLONGVARBINARY "ByteaAsLongVarBinary"
#define ABBR_BYTEAASLONGVARBINARY "C7"
#define INI_USESERVERSIDEPREPARE "UseServerSidePrepare"
#define ABBR_USESERVERSIDEPREPARE "C8"
#define INI_LOWERCASEIDENTIFIER "LowerCaseIdentifier"
#define ABBR_LOWERCASEIDENTIFIER "C9"
#define INI_SSLMODE "SSLmode"
#define ABBR_SSLMODE "CA"
#define INI_EXTRAOPTIONS "AB"
#define INI_LOGDIR "Logdir"
#define INI_KEEPALIVETIME "KeepaliveTime"
#define ABBR_KEEPALIVETIME "D1"
#define INI_KEEPALIVEINTERVAL "KeepaliveInterval"
#define ABBR_KEEPALIVEINTERVAL "D2"
#define INI_PQOPT "pqopt"
#define ABBR_PQOPT "D5"
#define INI_DTCLOG "Dtclog"
/* "PreferLibpq", abbreviated "D4", used to mean whether to prefer libpq.
* libpq is now required
#define INI_PREFERLIBPQ "PreferLibpq"
#define ABBR_PREFERLIBPQ "D3"
*/
#define ABBR_XAOPT "D4"
#define INI_CONNECTIONEXTRAINFO "ConnectionExtraInfo"
/* Whether to use batch protocol ('U' message) while batch executing. */
#define INI_USEBATCHPROTOCOL "UseBatchProtocol"
#define SSLMODE_DISABLE "disable"
#define SSLMODE_ALLOW "allow"
#define SSLMODE_PREFER "prefer"
#define SSLMODE_REQUIRE "require"
#define SSLMODE_VERIFY_CA "verify-ca"
#define SSLMODE_VERIFY_FULL "verify-full"
#define SSLLBYTE_DISABLE 'd'
#define SSLLBYTE_ALLOW 'a'
#define SSLLBYTE_PREFER 'p'
#define SSLLBYTE_REQUIRE 'r'
#define SSLLBYTE_VERIFY 'v'
#ifdef _HANDLE_ENLIST_IN_DTC_
#define INI_XAOPT "XaOpt"
#endif /* _HANDLE_ENLIST_IN_DTC_ */
/* Bit representation for abbreviated connection strings */
#define BIT_LFCONVERSION (1L)
#define BIT_UPDATABLECURSORS (1L<<1)
#define BIT_UNIQUEINDEX (1L<<3)
#define BIT_UNKNOWN_DONTKNOW (1L<<6)
#define BIT_UNKNOWN_ASMAX (1L<<7)
#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 BIT_BYTEAASLONGVARBINARY (1L<<24)
#define BIT_USESERVERSIDEPREPARE (1L<<25)
#define BIT_LOWERCASEIDENTIFIER (1L<<26)
#define EFFECTIVE_BIT_COUNT 28
/* Mask for extra options */
#define BIT_FORCEABBREVCONNSTR 1L
#define BIT_FAKE_MSS (1L << 1)
#define BIT_BDE_ENVIRONMENT (1L << 2)
#define BIT_CVT_NULL_DATE (1L << 3)
#define BIT_ACCESSIBLE_ONLY (1L << 4)
#define BIT_IGNORE_ROUND_TRIP_TIME (1L << 5)
#define BIT_DISABLE_KEEPALIVE (1L << 6)
/* Connection Defaults */
#define DEFAULT_READONLY 0
#define DEFAULT_PROTOCOL "7.4" /* the latest protocol is
* the default */
#define DEFAULT_USEDECLAREFETCH 0
#define DEFAULT_FOREXTENSIONCONNECTOR 0
#define DEFAULT_TEXTASLONGVARCHAR 1
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
#define DEFAULT_BOOLSASCHAR 1
#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 ""
#define DEFAULT_TRUEISMINUS1 0
#define DEFAULT_UPDATABLECURSORS 1
#ifdef WIN32
#define DEFAULT_LFCONVERSION 1
#else
#define DEFAULT_LFCONVERSION 0
#endif /* WIN32 */
#define DEFAULT_INT8AS 0
#define DEFAULT_BYTEAASLONGVARBINARY 1
#define DEFAULT_USESERVERSIDEPREPARE 1
#define DEFAULT_USEBATCHPROTOCOL 1
#define DEFAULT_CONNECTIONEXTRAINFO 0
#define DEFAULT_LOWERCASEIDENTIFIER 0
#define DEFAULT_SSLMODE SSLMODE_DISABLE
#ifdef _HANDLE_ENLIST_IN_DTC_
#define DEFAULT_XAOPT 1
#endif /* _HANDLE_ENLIST_IN_DTC_ */
/* for CC_DSN_info */
#define CONN_DONT_OVERWRITE 0
#define CONN_OVERWRITE 1
/* prototypes */
#ifdef WIN32
void SetDlgStuff(HWND hdlg, const ConnInfo *ci);
void GetDlgStuff(HWND hdlg, ConnInfo *ci);
LRESULT CALLBACK driver_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT CALLBACK global_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT CALLBACK ds_options1Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT CALLBACK ds_options2Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT CALLBACK ds_options3Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT CALLBACK manage_dsnProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
#endif /* WIN32 */
int write_Ci_Drivers(const char *fileName, const char *sectionName,
const GLOBAL_VALUES *);
int writeDriversDefaults(const char *drivername, const GLOBAL_VALUES *);
void writeDSNinfo(const ConnInfo *ci);
void getDriversDefaults(const char *drivername, GLOBAL_VALUES *);
void getDSNinfo(ConnInfo *ci, const char *configDrvrname);
void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD);
BOOL get_DSN_or_Driver(ConnInfo *ci, const char *attribute, char *value);
BOOL copyConnAttributes(ConnInfo *ci, const char *attribute, char *value);
int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen);
UInt4 getExtraOptions(const ConnInfo *);
BOOL setExtraOptions(ConnInfo *, const char *str, const char *format);
char *extract_extra_attribute_setting(const pgNAME setting, const char *attr);
signed char ci_updatable_cursors_set(ConnInfo *ci);
void getCiAllDefaults(ConnInfo *ci);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DLG_SPECIFIC_H__ */

991
dlg_wingui.c Normal file
View File

@ -0,0 +1,991 @@
#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 "readme.txt" for copyright and license information.
*-------
*/
/* Multibyte support Eiji Tokuya 2001-03-15 */
#include "dlg_specific.h"
#include "misc.h" // strncpy_null
#include "win_setup.h"
#include "loadlib.h"
#include "pgapifunc.h"
#ifdef _HANDLE_ENLIST_IN_DTC_
#include "xalibname.h"
#include "connexp.h"
#endif /* _HANDLE_ENLIST_IN_DTC_ */
extern HINSTANCE s_hModule;
static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable);
static int driver_options_update(HWND hdlg, ConnInfo *ci);
static int ds_options_update(HWND hdlg, ConnInfo *ci);
static int ds_options3Draw(HWND, const ConnInfo *);
static int ds_options3_update(HWND hdlg, ConnInfo *ci);
static struct {
int ids;
const char * const modestr;
} modetab[] = {
{IDS_SSLREQUEST_DISABLE, SSLMODE_DISABLE}
, {IDS_SSLREQUEST_ALLOW, SSLMODE_ALLOW}
, {IDS_SSLREQUEST_PREFER, SSLMODE_PREFER}
, {IDS_SSLREQUEST_REQUIRE, SSLMODE_REQUIRE}
, {IDS_SSLREQUEST_VERIFY_CA, SSLMODE_VERIFY_CA}
, {IDS_SSLREQUEST_VERIFY_FULL, SSLMODE_VERIFY_FULL}
};
static int dspcount_bylevel[] = {1, 4, 6};
void
SetDlgStuff(HWND hdlg, const ConnInfo *ci)
{
char buff[MEDIUM_REGISTRY_LEN + 1];
int i, dsplevel, selidx, dspcount;
/*
* If driver attribute NOT present, then set the datasource name and
* description
*/
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, SAFE_NAME(ci->password));
SetDlgItemText(hdlg, IDC_PORT, ci->port);
dsplevel = 0;
/*
* XXX: We used to hide or show this depending whether libpq was loaded,
* but we depend on libpq directly nowadays, so it's always loaded.
*/
ShowWindow(GetDlgItem(hdlg, IDC_NOTICE_USER), SW_HIDE);
dsplevel = 2;
selidx = -1;
for (i = 0; i < sizeof(modetab) / sizeof(modetab[0]); i++)
{
if (!stricmp(ci->sslmode, modetab[i].modestr))
{
selidx = i;
break;
}
}
for (i = dsplevel; i < sizeof(dspcount_bylevel) / sizeof(int); i++)
{
if (selidx < dspcount_bylevel[i])
break;
dsplevel++;
}
dspcount = dspcount_bylevel[dsplevel];
for (i = 0; i < dspcount; i++)
{
LoadString(GetWindowInstance(hdlg), modetab[i].ids, buff, MEDIUM_REGISTRY_LEN);
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
}
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SETCURSEL, selidx, (WPARAM) 0);
}
void
GetDlgStuff(HWND hdlg, ConnInfo *ci)
{
int sslposition;
char medium_buf[MEDIUM_REGISTRY_LEN];
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, medium_buf, sizeof(medium_buf));
STR_TO_NAME(ci->password, medium_buf);
GetDlgItemText(hdlg, IDC_PORT, ci->port, sizeof(ci->port));
sslposition = (int)(DWORD)SendMessage(GetDlgItem(hdlg, IDC_SSLMODE), CB_GETCURSEL, 0L, 0L);
STRCPY_FIXED(ci->sslmode, modetab[sslposition].modestr);
}
static void
getDriversDefaultsOfCi(const ConnInfo *ci, GLOBAL_VALUES *glbv)
{
const char *drivername = NULL;
if (ci->drivername[0])
drivername = ci->drivername;
else if (NAME_IS_VALID(ci->drivers.drivername))
drivername = SAFE_NAME(ci->drivers.drivername);
if (drivername && drivername[0])
getDriversDefaults(drivername, glbv);
else
getDriversDefaults(INVALID_DRIVER, glbv);
}
static int
driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable)
{
const GLOBAL_VALUES *comval = NULL;
const char * drivername = NULL;
GLOBAL_VALUES defval;
MYLOG(0, "entering src=%d\n", src);
init_globals(&defval);
switch (src)
{
case 0: /* default */
getDriversDefaultsOfCi(ci, &defval);
defval.debug = DEFAULT_DEBUG;
defval.commlog = DEFAULT_COMMLOG;
comval = &defval;
break;
case 1: /* dsn specific */
comval = &(ci->drivers);
break;
default:
return 0;
}
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL2), enable ? SW_SHOW : SW_HIDE);
CheckDlgButton(hdlg, DRV_COMMLOG, comval->commlog > 0);
SetDlgItemInt(hdlg, DS_COMMLOG, comval->commlog, FALSE);
ShowWindow(GetDlgItem(hdlg, DS_COMMLOG), comval->commlog > 0 ? SW_SHOW : SW_HIDE);
CheckDlgButton(hdlg, DRV_UNIQUEINDEX, comval->unique_index);
EnableWindow(GetDlgItem(hdlg, DRV_READONLY), FALSE);
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_DEBUG, comval->debug > 0);
SetDlgItemInt(hdlg, DS_DEBUG, comval->debug, FALSE);
ShowWindow(GetDlgItem(hdlg, DS_DEBUG), comval->debug > 0 ? SW_SHOW : SW_HIDE);
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 */
EnableWindow(GetDlgItem(hdlg, DRV_CONNSETTINGS), FALSE);
ShowWindow(GetDlgItem(hdlg, ID2NDPAGE), enable ? SW_HIDE : SW_SHOW);
ShowWindow(GetDlgItem(hdlg, ID3RDPAGE), enable ? SW_HIDE : SW_SHOW);
finalize_globals(&defval);
return 0;
}
#define INIT_DISP_LOGVAL 2
static int
driver_options_update(HWND hdlg, ConnInfo *ci)
{
GLOBAL_VALUES *comval;
BOOL bTranslated;
MYLOG(3, "entering\n");
comval = &(ci->drivers);
(comval->commlog = GetDlgItemInt(hdlg, DS_COMMLOG, &bTranslated, FALSE)) || bTranslated || (comval->commlog = INIT_DISP_LOGVAL);
comval->unique_index = IsDlgButtonChecked(hdlg, DRV_UNIQUEINDEX);
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->debug = GetDlgItemInt(hdlg, DS_DEBUG, &bTranslated, FALSE)) || bTranslated || (comval->debug = INIT_DISP_LOGVAL);
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));
/* fall through */
return 0;
}
#ifdef _HANDLE_ENLIST_IN_DTC_
static
HMODULE DtcProc(const char *procname, FARPROC *proc)
{
HMODULE hmodule;
*proc = NULL;
if (hmodule = LoadLibraryEx(GetXaLibPath(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH), NULL != hmodule)
{
MYLOG(0, "GetProcAddres for %s\n", procname);
*proc = GetProcAddress(hmodule, procname);
}
return hmodule;
}
#endif /* _HANDLE_ENLIST_IN_DTC_ */
#include <sys/stat.h>
static const char *IsAnExistingDirectory(const char *path)
{
struct stat st;
if (stat(path, &st) < 0)
{
CSTR errmsg_doesnt_exist = "doesn't exist";
return errmsg_doesnt_exist;
}
if ((st.st_mode & S_IFDIR) == 0)
{
CSTR errmsg_isnt_a_dir = "isn't a directory";
return errmsg_isnt_a_dir;
}
return NULL;
}
LRESULT CALLBACK
global_optionsProc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
#ifdef _HANDLE_ENLIST_IN_DTC_
HMODULE hmodule;
FARPROC proc;
#endif /* _HANDLE_ENLIST_IN_DTC_ */
ConnInfo *ci;
char logdir[PATH_MAX];
const char *logmsg;
GLOBAL_VALUES defval;
init_globals(&defval);
switch (wMsg)
{
case WM_INITDIALOG:
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for test etc */
ci = (ConnInfo *) lParam;
getDriversDefaultsOfCi(ci, &defval);
CheckDlgButton(hdlg, DRV_COMMLOG, getGlobalCommlog());
CheckDlgButton(hdlg, DRV_DEBUG, getGlobalDebug());
getLogDir(logdir, sizeof(logdir));
SetDlgItemText(hdlg, DS_LOGDIR, logdir);
#ifdef _HANDLE_ENLIST_IN_DTC_
hmodule = DtcProc("GetMsdtclog", &proc);
if (proc)
{
INT_PTR res = (*proc)();
CheckDlgButton(hdlg, DRV_DTCLOG, 0 != res);
}
else
EnableWindow(GetDlgItem(hdlg, DRV_DTCLOG), FALSE);
if (hmodule)
FreeLibrary(hmodule);
#else
ShowWindow(GetDlgItem(hdlg, DRV_DTCLOG), SW_HIDE);
#endif /* _HANDLE_ENLIST_IN_DTC_ */
break;
case WM_COMMAND:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
getDriversDefaultsOfCi(ci, &defval);
GetDlgItemText(hdlg, DS_LOGDIR, logdir, sizeof(logdir));
if (logdir[0] && (logmsg = IsAnExistingDirectory(logdir)) != NULL)
{
MessageBox(hdlg, "Folder for logging error", logmsg, MB_ICONEXCLAMATION | MB_OK);
break;
}
setGlobalCommlog(IsDlgButtonChecked(hdlg, DRV_COMMLOG));
setGlobalDebug(IsDlgButtonChecked(hdlg, DRV_DEBUG));
writeGlobalLogs();
if (writeDriversDefaults(ci->drivername, &defval) < 0)
MessageBox(hdlg, "Sorry, impossible to update the values\nWrite permission seems to be needed", "Update Error", MB_ICONEXCLAMATION | MB_OK);
setLogDir(logdir[0] ? logdir : NULL);
#ifdef _HANDLE_ENLIST_IN_DTC_
hmodule = DtcProc("SetMsdtclog", &proc);
if (proc)
(*proc)(IsDlgButtonChecked(hdlg, DRV_DTCLOG));
if (hmodule)
FreeLibrary(hmodule);
#endif /* _HANDLE_ENLIST_IN_DTC_ */
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
}
}
finalize_globals(&defval);
return FALSE;
}
static void
CtrlCheckButton(HWND hdlg, int nIDcheck, int nIDint)
{
BOOL bTranslated;
switch (Button_GetCheck(GetDlgItem(hdlg, nIDcheck)))
{
case BST_CHECKED:
if (!GetDlgItemInt(hdlg, nIDint, &bTranslated, FALSE))
{
ShowWindow(GetDlgItem(hdlg, nIDint), SW_SHOW);
if (bTranslated)
SetDlgItemInt(hdlg, nIDint, INIT_DISP_LOGVAL, FALSE);
}
break;
case BST_UNCHECKED:
if (GetDlgItemInt(hdlg, nIDint, &bTranslated, FALSE))
{
ShowWindow(GetDlgItem(hdlg, nIDint), SW_HIDE);
SetDlgItemInt(hdlg, nIDint, 0, FALSE);
}
break;
}
}
LRESULT CALLBACK
ds_options1Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
char strbuf[128];
switch (wMsg)
{
case WM_INITDIALOG:
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK etc */
ci = (ConnInfo *) lParam;
if (ci && ci->dsn && ci->dsn[0])
{
DWORD cmd;
char fbuf[64];
cmd = LoadString(s_hModule,
IDS_ADVANCE_OPTION_DSN1,
fbuf,
sizeof(fbuf));
if (cmd <= 0)
STRCPY_FIXED(fbuf, "Advanced Options (%s) 1/3");
SPRINTF_FIXED(strbuf, fbuf, ci->dsn);
SetWindowText(hdlg, strbuf);
}
else
{
LoadString(s_hModule, IDS_ADVANCE_OPTION_CON1, strbuf, sizeof(strbuf));
SetWindowText(hdlg, strbuf);
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE);
}
driver_optionsDraw(hdlg, ci, 1, FALSE);
break;
case WM_COMMAND:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
driver_options_update(hdlg, ci);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
case IDAPPLY:
driver_options_update(hdlg, ci);
SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam);
break;
case IDDEFAULTS:
driver_optionsDraw(hdlg, ci, 0, FALSE);
break;
case ID2NDPAGE:
driver_options_update(hdlg, ci);
EndDialog(hdlg, FALSE);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DS),
hdlg, ds_options2Proc, (LPARAM) ci);
break;
case ID3RDPAGE:
driver_options_update(hdlg, ci);
EndDialog(hdlg, FALSE);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DS3),
hdlg, ds_options3Proc, (LPARAM) ci);
break;
case DRV_COMMLOG:
case DS_COMMLOG:
CtrlCheckButton(hdlg, DRV_COMMLOG, DS_COMMLOG);
break;
case DRV_DEBUG:
case DS_DEBUG:
CtrlCheckButton(hdlg, DRV_DEBUG, DS_DEBUG);
break;
}
}
return FALSE;
}
static int
ds_options_update(HWND hdlg, ConnInfo *ci)
{
char buf[128];
MYLOG(0, "entering got ci=%p\n", ci);
/* Readonly */
ITOA_FIXED(ci->onlyread, IsDlgButtonChecked(hdlg, DS_READONLY));
/* Issue rollback command on error */
if (IsDlgButtonChecked(hdlg, DS_NO_ROLLBACK))
ci->rollback_on_error = 0;
else if (IsDlgButtonChecked(hdlg, DS_TRANSACTION_ROLLBACK))
ci->rollback_on_error = 1;
else if (IsDlgButtonChecked(hdlg, DS_STATEMENT_ROLLBACK))
ci->rollback_on_error = 2;
else
/* no button is checked */
ci->rollback_on_error = -1;
/* 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;
GetDlgItemText(hdlg, DS_EXTRA_OPTIONS, buf, sizeof(buf));
setExtraOptions(ci, buf, NULL);
ITOA_FIXED(ci->show_system_tables, IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
ITOA_FIXED(ci->row_versioning, IsDlgButtonChecked(hdlg, DS_ROWVERSIONING));
ci->lf_conversion = IsDlgButtonChecked(hdlg, DS_LFCONVERSION);
ci->true_is_minus1 = IsDlgButtonChecked(hdlg, DS_TRUEISMINUS1);
ci->allow_keyset = IsDlgButtonChecked(hdlg, DS_UPDATABLECURSORS);
ci->use_server_side_prepare = IsDlgButtonChecked(hdlg, DS_SERVERSIDEPREPARE);
ci->bytea_as_longvarbinary = IsDlgButtonChecked(hdlg, DS_BYTEAASLONGVARBINARY);
/* OID Options */
ITOA_FIXED(ci->fake_oid_index, IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX));
ITOA_FIXED(ci->show_oid_column, IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
/* Datasource Connection Settings */
{
char conn_settings[LARGE_REGISTRY_LEN];
GetDlgItemText(hdlg, DS_CONNSETTINGS, conn_settings, sizeof(conn_settings));
if ('\0' != conn_settings[0])
STR_TO_NAME(ci->conn_settings, conn_settings);
}
/* TCP KEEPALIVE */
ci->disable_keepalive = IsDlgButtonChecked(hdlg, DS_DISABLE_KEEPALIVE);
if (ci->disable_keepalive)
{
ci->keepalive_idle = -1;
ci->keepalive_interval = -1;
}
else
{
char temp[64];
int val;
GetDlgItemText(hdlg, DS_KEEPALIVETIME, temp, sizeof(temp));
if (val = atoi(temp), 0 == val)
val = -1;
ci->keepalive_idle = val;
GetDlgItemText(hdlg, DS_KEEPALIVEINTERVAL, temp, sizeof(temp));
if (val = atoi(temp), 0 == val)
val = -1;
ci->keepalive_interval = val;
}
return 0;
}
LRESULT CALLBACK
ds_options2Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
char buf[128];
DWORD cmd;
BOOL enable;
switch (wMsg)
{
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK */
/* Change window caption */
if (ci && ci->dsn && ci->dsn[0])
{
char fbuf[64];
cmd = LoadString(s_hModule,
IDS_ADVANCE_OPTION_DSN2,
fbuf,
sizeof(fbuf));
if (cmd <= 0)
STRCPY_FIXED(fbuf, "Advanced Options (%s) 2/3");
SPRINTF_FIXED(buf, fbuf, ci->dsn);
SetWindowText(hdlg, buf);
}
else
{
LoadString(s_hModule, IDS_ADVANCE_OPTION_CON2, buf, sizeof(buf));
SetWindowText(hdlg, buf);
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); }
/* Readonly */
CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
/* Protocol */
enable = (ci->sslmode[0] == SSLLBYTE_DISABLE || ci->username[0] == '\0');
/* How to issue Rollback */
switch (ci->rollback_on_error)
{
case 0:
CheckDlgButton(hdlg, DS_NO_ROLLBACK, 1);
break;
case 1:
CheckDlgButton(hdlg, DS_TRANSACTION_ROLLBACK, 1);
break;
case 2:
CheckDlgButton(hdlg, DS_STATEMENT_ROLLBACK, 1);
break;
}
/* 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);
}
SPRINTF_FIXED(buf, "0x%x", getExtraOptions(ci));
SetDlgItemText(hdlg, DS_EXTRA_OPTIONS, buf);
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_LFCONVERSION, ci->lf_conversion);
CheckDlgButton(hdlg, DS_TRUEISMINUS1, ci->true_is_minus1);
CheckDlgButton(hdlg, DS_UPDATABLECURSORS, ci->allow_keyset);
CheckDlgButton(hdlg, DS_SERVERSIDEPREPARE, ci->use_server_side_prepare);
CheckDlgButton(hdlg, DS_BYTEAASLONGVARBINARY, ci->bytea_as_longvarbinary);
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
/* Datasource Connection Settings */
SetDlgItemText(hdlg, DS_CONNSETTINGS, SAFE_NAME(ci->conn_settings));
/* KEEPALIVE */
enable = (0 == (ci->extra_opts & BIT_DISABLE_KEEPALIVE));
CheckDlgButton(hdlg, DS_DISABLE_KEEPALIVE, !enable);
if (enable)
{
if (ci->keepalive_idle > 0)
{
ITOA_FIXED(buf, ci->keepalive_idle);
SetDlgItemText(hdlg, DS_KEEPALIVETIME, buf);
}
if (ci->keepalive_interval > 0)
{
ITOA_FIXED(buf, ci->keepalive_interval);
SetDlgItemText(hdlg, DS_KEEPALIVEINTERVAL, buf);
}
}
break;
case WM_COMMAND:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
{
case DS_SHOWOIDCOLUMN:
MYLOG(0, "WM_COMMAND: DS_SHOWOIDCOLUMN\n");
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
return TRUE;
case DS_DISABLE_KEEPALIVE:
MYLOG(0, "WM_COMMAND: DS_SHOWOIDCOLUMN\n");
EnableWindow(GetDlgItem(hdlg, DS_KEEPALIVETIME), !IsDlgButtonChecked(hdlg, cmd));
EnableWindow(GetDlgItem(hdlg, DS_KEEPALIVEINTERVAL), !IsDlgButtonChecked(hdlg, cmd));
return TRUE;
case IDOK:
ds_options_update(hdlg, ci);
case IDCANCEL:
EndDialog(hdlg, IDOK == cmd);
return TRUE;
case IDAPPLY:
ds_options_update(hdlg, ci);
SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam);
break;
case ID1STPAGE:
ds_options_update(hdlg, ci);
EndDialog(hdlg, cmd == IDOK);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) ci);
break;
case ID3RDPAGE:
ds_options_update(hdlg, ci);
EndDialog(hdlg, cmd == IDOK);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DS3),
hdlg, ds_options3Proc, (LPARAM) ci);
break;
}
}
return FALSE;
}
static int
ds_options3Draw(HWND hdlg, const ConnInfo *ci)
{
BOOL enable = TRUE;
static BOOL defset = FALSE;
MYLOG(0, "entering\n");
#ifdef _HANDLE_ENLIST_IN_DTC_
switch (ci->xa_opt)
{
case 0:
enable = FALSE;
break;
case DTC_CHECK_LINK_ONLY:
CheckDlgButton(hdlg, DS_DTC_LINK_ONLY, 1);
break;
case DTC_CHECK_BEFORE_LINK:
CheckDlgButton(hdlg, DS_DTC_SIMPLE_PRECHECK, 1);
break;
case DTC_CHECK_RM_CONNECTION:
CheckDlgButton(hdlg, DS_DTC_CONFIRM_RM_CONNECTION, 1);
break;
}
#else
enable = FALSE;
#endif /* _HANDLE_ENLIST_IN_DTC_ */
if (!enable)
{
EnableWindow(GetDlgItem(hdlg, DS_DTC_LINK_ONLY), enable);
EnableWindow(GetDlgItem(hdlg, DS_DTC_SIMPLE_PRECHECK), enable);
EnableWindow(GetDlgItem(hdlg, DS_DTC_CONFIRM_RM_CONNECTION), enable);
}
/* Datasource libpq parameters */
SetDlgItemText(hdlg, DS_LIBPQOPT, SAFE_NAME(ci->pqopt));
return 0;
}
void *PQconninfoParse(const char *, char **);
void PQconninfoFree(void *);
typedef void *(*PQCONNINFOPARSEPROC)(const char *, char **);
typedef void (*PQCONNINFOFREEPROC)(void *);
static int
ds_options3_update(HWND hdlg, ConnInfo *ci)
{
void *connOpt = NULL;
char *ermsg = NULL;
char pqopt[LARGE_REGISTRY_LEN];
HMODULE hmodule;
PQCONNINFOPARSEPROC pproc = NULL;
PQCONNINFOFREEPROC fproc = NULL;
MYLOG(0, "entering got ci=%p\n", ci);
/* Datasource libpq parameters */
GetDlgItemText(hdlg, DS_LIBPQOPT, pqopt, sizeof(pqopt));
if (hmodule = LoadLibraryEx("libpq.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH), NULL != hmodule)
{
pproc = (PQCONNINFOPARSEPROC) GetProcAddress(hmodule, "PQconninfoParse");
if (NULL != pproc && NULL == (connOpt= (*pproc)(pqopt, &ermsg)))
{
const char *logmsg = "libpq parameter error";
MessageBox(hdlg, ermsg ? ermsg : "memory over?", logmsg, MB_ICONEXCLAMATION | MB_OK);
if (NULL != ermsg)
free(ermsg);
FreeLibrary(hmodule);
return 1;
}
fproc = (PQCONNINFOFREEPROC) GetProcAddress(hmodule, "PQconninfoFree");
if (fproc)
(*fproc)(connOpt);
FreeLibrary(hmodule);
}
STR_TO_NAME(ci->pqopt, pqopt);
#ifdef _HANDLE_ENLIST_IN_DTC_
if (IsDlgButtonChecked(hdlg, DS_DTC_LINK_ONLY))
ci->xa_opt = DTC_CHECK_LINK_ONLY;
else if (IsDlgButtonChecked(hdlg, DS_DTC_SIMPLE_PRECHECK))
ci->xa_opt = DTC_CHECK_BEFORE_LINK;
else if (IsDlgButtonChecked(hdlg, DS_DTC_CONFIRM_RM_CONNECTION))
ci->xa_opt = DTC_CHECK_RM_CONNECTION;
else
ci->xa_opt = 0;
#endif /* _HANDLE_ENLIST_IN_DTC_ */
return 0;
}
LRESULT CALLBACK
ds_options3Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci, tmpInfo;
char buf[128];
DWORD cmd;
if (WM_INITDIALOG == wMsg || WM_COMMAND == wMsg)
MYLOG(0, "entering wMsg=%d\n", wMsg);
switch (wMsg)
{
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK */
/* Change window caption */
if (ci && ci->dsn && ci->dsn[0])
{
char fbuf[64];
cmd = LoadString(s_hModule,
IDS_ADVANCE_OPTION_DSN3,
fbuf,
sizeof(fbuf));
if (cmd <= 0)
STRCPY_FIXED(fbuf, "Advanced Options (%s) 3/3");
SPRINTF_FIXED(buf, fbuf, ci->dsn);
SetWindowText(hdlg, buf);
}
else
{
LoadString(s_hModule, IDS_ADVANCE_OPTION_CON3, buf, sizeof(buf));
SetWindowText(hdlg, buf);
ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); }
ds_options3Draw(hdlg, ci);
break;
case WM_COMMAND:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
ds_options3_update(hdlg, ci);
case IDCANCEL:
EndDialog(hdlg, IDOK == cmd);
return TRUE;
case IDAPPLY:
ds_options3_update(hdlg, ci);
SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam);
break;
case IDC_TEST:
CC_copy_conninfo(&tmpInfo, ci);
ds_options3_update(hdlg, &tmpInfo);
test_connection(hdlg, &tmpInfo, TRUE);
CC_conninfo_release(&tmpInfo);
break;
case ID1STPAGE:
ds_options3_update(hdlg, ci);
EndDialog(hdlg, cmd == IDOK);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) ci);
break;
case ID2NDPAGE:
ds_options3_update(hdlg, ci);
EndDialog(hdlg, cmd == IDOK);
DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_OPTIONS_DS),
hdlg, ds_options2Proc, (LPARAM) ci);
break;
}
}
return FALSE;
}
typedef SQLRETURN (SQL_API *SQLAPIPROC)();
static int
makeDriversList(HWND lwnd, const ConnInfo *ci)
{
HMODULE hmodule;
SQLHENV henv;
int lcount = 0;
LRESULT iidx;
char drvname[64], drvatt[128];
SQLUSMALLINT direction = SQL_FETCH_FIRST;
SQLSMALLINT drvncount, drvacount;
SQLRETURN ret;
SQLAPIPROC addr;
hmodule = GetModuleHandle("ODBC32");
if (!hmodule) return lcount;
addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLAllocEnv");
if (!addr) return lcount;
ret = (*addr)(&henv);
if (SQL_SUCCESS != ret) return lcount;
do
{
ret = SQLDrivers(henv, direction,
drvname, sizeof(drvname), &drvncount,
drvatt, sizeof(drvatt), &drvacount);
if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret)
break;
if (strnicmp(drvname, "postgresql", 10) == 0)
{
iidx = SendMessage(lwnd, LB_ADDSTRING, 0, (LPARAM) drvname);
if (LB_ERR != iidx && stricmp(drvname, ci->drivername) == 0)
{
SendMessage(lwnd, LB_SETCURSEL, (WPARAM) iidx, (LPARAM) 0);
}
lcount++;
}
direction = SQL_FETCH_NEXT;
} while (1);
addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLFreeEnv");
if (addr)
(*addr)(henv);
return lcount;
}
LRESULT CALLBACK
manage_dsnProc(HWND hdlg, UINT wMsg,
WPARAM wParam, LPARAM lParam)
{
LPSETUPDLG lpsetupdlg;
ConnInfo *ci;
HWND lwnd;
LRESULT sidx;
char drvname[64];
switch (wMsg)
{
case WM_INITDIALOG:
SetWindowLongPtr(hdlg, DWLP_USER, lParam);
lpsetupdlg = (LPSETUPDLG) lParam;
ci = &lpsetupdlg->ci;
lwnd = GetDlgItem(hdlg, IDC_DRIVER_LIST);
makeDriversList(lwnd, ci);
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
lwnd = GetDlgItem(hdlg, IDC_DRIVER_LIST);
sidx = SendMessage(lwnd, LB_GETCURSEL,
(WPARAM) 0, (LPARAM) 0);
if (LB_ERR == sidx)
return FALSE;
sidx = SendMessage(lwnd, LB_GETTEXT,
(WPARAM) sidx, (LPARAM) drvname);
if (LB_ERR == sidx)
return FALSE;
ChangeDriverName(hdlg, lpsetupdlg, drvname);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
}
}
return FALSE;
}
#endif /* WIN32 */

3
docs/README.txt Normal file
View File

@ -0,0 +1,3 @@
This directory contains documentation specific to this version. More general
documentation about the psqlODBC project, and on how to use the driver is
available at the psqlODBC website, at https://odbc.postgresql.org/.

482
docs/config-opt.html Normal file
View File

@ -0,0 +1,482 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html">
<TITLE>How to specify as a connection option</TITLE>
</HEAD>
<BODY>
<P STYLE="margin-bottom: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=5>
<B>How to specify as a connection option </B></FONT></FONT>
</P>
<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3 STYLE="page-break-inside: avoid">
<COL WIDTH=96*>
<COL WIDTH=80*>
<COL WIDTH=79*>
<TR>
<TD WIDTH=38%>
<B><FONT SIZE=4>Definition</FONT></B>
</TD>
<TD WIDTH=31%>
<B><FONT SIZE=4>Keyword</FONT></B>
</TD>
<TD WIDTH=31%>
<FONT SIZE=4><B>Abbreviation</FONT>
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Data source description
</TD>
<TD WIDTH=31%>
Description
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Name of Server
</TD>
<TD WIDTH=31%>
Servername
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Postmaster listening port
</TD>
<TD WIDTH=31%>
Port
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
User Name
</TD>
<TD WIDTH=31%>
Username
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Password
</TD>
<TD WIDTH=31%>
Password
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Debug flag
</TD>
<TD WIDTH=31%>
Debug
</TD>
<TD WIDTH=31%>
B2
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Fetch Max Count
</TD>
<TD WIDTH=31%>
Fetch
</TD>
<TD WIDTH=31%>
A7
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Socket buffer size
</TD>
<TD WIDTH=31%>
Socket
</TD>
<TD WIDTH=31%>
A8
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Database is read only
</TD>
<TD WIDTH=31%>
ReadOnly
</TD>
<TD WIDTH=31%>
A0
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Communication to backend logging
</TD>
<TD WIDTH=31%>
CommLog
</TD>
<TD WIDTH=31%>
B3
</TD>
</TR>
<TR>
<TD WIDTH=38%>
PostgreSQL backend protocol
</TD>
<TD WIDTH=31%>
Protocol
</TD>
<TD WIDTH=31%>
A1
</TD>
</TR>
<!-- TR>
<TD WIDTH=38%>
Backend genetic optimizer
</TD>
<TD WIDTH=31%>
Optimizer
</TD>
<TD WIDTH=31%>
B4
</TD>
</TR
<TR>
<TD WIDTH=38%>
Keyset query optimization
</TD>
<TD WIDTH=31%>
Ksqo
</TD>
<TD WIDTH=31%>
B5
</TD>
</TR -->
<TR>
<TD WIDTH=38%>
Connect Settings (commands sent to backend on connection)
</TD>
<TD WIDTH=31%>
ConnSettings
</TD>
<TD WIDTH=31%>
A6
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Recognize unique indexes
</TD>
<TD WIDTH=31%>
UniqueIndex
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Unknown result set sizes
</TD>
<TD WIDTH=31%>
UnknownSizes
</TD>
<TD WIDTH=31%>
A9
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Use Declare/Fetch cursors
</TD>
<TD WIDTH=31%>
UseDeclareFetch
</TD>
<TD WIDTH=31%>
B6
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Text as LongVarchar
</TD>
<TD WIDTH=31%>
TextAsLongVarchar
</TD>
<TD WIDTH=31%>
B7
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Unknowns as LongVarchar
</TD>
<TD WIDTH=31%>
UnknownsAsLongVarchar
</TD>
<TD WIDTH=31%>
B8
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Bools as Char
</TD>
<TD WIDTH=31%>
BoolsAsChar
</TD>
<TD WIDTH=31%>
B9
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Max Varchar size
</TD>
<TD WIDTH=31%>
MaxVarcharSize
</TD>
<TD WIDTH=31%>
B0
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Max LongVarchar size
</TD>
<TD WIDTH=31%>
MaxLongVarcharSize
</TD>
<TD WIDTH=31%>
B1
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Fakes a unique index on OID
</TD>
<TD WIDTH=31%>
FakeOidIndex
</TD>
<TD WIDTH=31%>
A2
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Includes the OID in SQLColumns
</TD>
<TD WIDTH=31%>
ShowOidColumn
</TD>
<TD WIDTH=31%>
A3
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Row Versioning
</TD>
<TD WIDTH=31%>
RowVersioning
</TD>
<TD WIDTH=31%>
A4
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Show SystemTables
</TD>
<TD WIDTH=31%>
ShowSystemTables
</TD>
<TD WIDTH=31%>
A5
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Parse Statements
</TD>
<TD WIDTH=31%>
Parse
</TD>
<TD WIDTH=31%>
C0
</TD>
</TR>
<TR>
<TD WIDTH=38%>
SysTable Prefixes
</TD>
<TD WIDTH=31%>
ExtraSysTablePrefixes
</TD>
<TD WIDTH=31%>
C2
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Updateable Cursors
</TD>
<TD WIDTH=31%>
UpdatableCursors
</TD>
<TD WIDTH=31%>
C4
</TD>
</TR>
<TR>
<TD WIDTH=38%>
LF &lt;-&gt; CR/LF conversion
</TD>
<TD WIDTH=31%>
LFConversion
</TD>
<TD WIDTH=31%>
C5
</TD>
</TR>
<TR>
<TD WIDTH=38%>
True is -1
</TD>
<TD WIDTH=31%>
TrueIsMinus1
</TD>
<TD WIDTH=31%>
C6
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Datatype to report int8 columns as
</TD>
<TD WIDTH=31%>
BI
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Bytea as LO (longVarBinary)
</TD>
<TD WIDTH=31%>
ByteaAsLongVarBinary
</TD>
<TD WIDTH=31%>
C7
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Use serverside prepare
</TD>
<TD WIDTH=31%>
UseServerSidePrepare
</TD>
<TD WIDTH=31%>
C8
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Lower case identifier
</TD>
<TD WIDTH=31%>
LowerCaseIdentifier
</TD>
<TD WIDTH=31%>
C9
</TD>
</TR>
<TR>
<TD WIDTH=38%>
SSL mode
</TD>
<TD WIDTH=31%>
SSLmode
</TD>
<TD WIDTH=31%>
CA
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Extra options
</TD>
<TD WIDTH=31%>
AB
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Abbreviate(simple setup of a recommendation value)
</TD>
<TD WIDTH=31%>
CX
</TD>
<TD WIDTH=31%>
Nothing
</TD>
</TR>
<TR>
<TD WIDTH=38%>
TCP KEEPALIVE setting: idle time
</TD>
<TD WIDTH=31%>
KeepaliveTime
</TD>
<TD WIDTH=31%>
D1
</TD>
</TR>
<TR>
<TD WIDTH=38%>
TCP KEEPALIVE setting: interval
</TD>
<TD WIDTH=31%>
KeepaliveInterval
</TD>
<TD WIDTH=31%>
D2
</TD>
</TR>
<TR>
<TD WIDTH=38%>
Libpq parameters (a conninfo style string e.g. pqopt={sslcert=~/mycert sslkey=~/mykey} enclosed with braces in the case of connection strings)
</TD>
<TD WIDTH=31%>
Pqopt
</TD>
<TD WIDTH=31%>
D5
</TD>
</TR>
</TABLE>
</TABLE>
<P><BR><BR>
</P>
</BODY>
</HTML>

309
docs/config.html Normal file
View File

@ -0,0 +1,309 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>psqlODBC Configuration Options</title>
</HEAD>
<body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
<h1>psqlODBC Configuration Options</h1>
<h2>Advanced Options 1/3 Dialog Box</h2>
<ul>
<li><b>DEFAULTS:</b> Press to this button restore the normal defaults for the
settings described below.<br />&nbsp;</li>
<li><b>Recognize Unique Indexes:</b>
Check this option.<br />&nbsp;</li>
<li><b>Use Declare/Fetch:</b> If
true, the driver automatically uses declare cursor/fetch to handle
SELECT statements and keeps 100 rows in a cache. This is mostly a
great advantage, especially if you are only interested in reading and not
updating. It results in the driver not sucking down lots of memory
to buffer the entire result set. If set to false, cursors will not
be used and the driver will retrieve the entire result set. For very
large tables, this is very inefficient and may use up all the Windows memory/resources.
However, it may handle updates better since the tables are not kept open,
as they are when using cursors. This was the style of the old podbc32
driver. However, the behavior of the memory allocation is much improved
so even when not using cursors, performance should at least be better than
the old podbc32.<br />&nbsp;</li>
<li><b>CommLog (C:\psqlodbc_xxxx.log):</b>
Log communications to/from the backend to that file. This is good
for debugging problems.<br />&nbsp;</li>
<li><b>Parse Statements:</b> Tell the driver how to gather the information
about result columns of queries, if the application requests that information
before executing the query. See also <em>ServerSide Prepare</em> options.<br>
The driver checks this option first. If disabled then it checks the Server Side Prepare option.<br>
<br>
If this option is enabled,
the driver will parse an SQL query statement to identify the columns and
tables and gather statistics about them such as precision, nullability,
aliases, etc. It then reports this information in SQLDescribeCol,
SQLColAttributes, and SQLNumResultCols.<br><br>
When this option is disabled (the default), the query is sent to the server
to be parsed and described.
If the parser can not deal with a column (because it is a function
or expression, etc.), it will fall back to describing the statement in
the server. The parser is fairly
sophisticated and can handle many things such as column and table aliases,
quoted identifiers, literals, joins, cross-products, etc. It can
correctly identify a function or expression column, regardless of the complexity,
but it does not attempt to determine the data type or precision of these
columns.<br />&nbsp;</li>
<li><b>MyLog (C:\mylog_xxxx.log):</b>
Log debug messages to that file. This is good
for debugging problems with the driver.<br />&nbsp;</li>
<li><b>Unknown Sizes: </b>This controls
what SQLDescribeCol and SQLColAttributes will return as to precision for
character data types (varchar, text, and unknown) in a result set when
the precision is unknown. <b>This was more of a workaround for pre-6.4
versions of PostgreSQL not being able to return the defined column width
of the varchar data type</b>.<br><br>
<ul>
<li><i>Maximum</i>: Always
return the maximum precision of the data type.</li>
<li><i>Dont Know</i>: Return "Don't Know"
value and let application decide.</li>
<li><i>Longest</i>: Return
the longest string length of the column of any row. Beware of this
setting when using cursors because the cache size may not be a good representation
of the longest column in the cache.</li>
<br>
<i>MS Access</i>: Seems to handle <i>Maximum</i> setting ok, as well as all the others.<br>
<i>Borland</i>: If sizes are large and lots of columns, Borland may crash badly (it doesn't seem to handle memory allocation well)
if using <i>Maximum</i> size.
</ul><br>
<li><b>Data Type Options:</b> affects how some data types are mapped:<br />&nbsp;</li>
<ul>
<li><i>Text as LongVarChar</i>:
PostgreSQL TEXT type is mapped to SQLLongVarchar, otherwise SQLVarchar.</li>
<li><i>Unknowns as LongVarChar</i>: Unknown types (arrays, etc) are mapped to SQLLongVarChar, otherwise SQLVarchar</li>
<li><i>Bools as Char</i>: Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.</li>
</ul><br>
<li><b>Max Varchar</b> The maximum
precision of the Varchar and BPChar(char[x]) types. The default is 254
which actually means 255 because of the null terminator. Note, if
you set this value higher than 254, Access will not let you index on varchar
columns!<br />&nbsp;</li>
<li><b>Cache Size:</b>When using
cursors, this is the row size of the tuple cache. If not using cursors,
this is how many tuples to allocate memory for at any given time.
The default is 100 rows for either case.<br />&nbsp;</li>
<li><b>Max LongVarChar:</b> The maximum
precision of the LongVarChar type. The default is 4094 which actually
means 4095 with the null terminator. You can even specify (-4) for
this size, which is the odbc SQL_NO_TOTAL value.<br />&nbsp;</li>
<li><b>SysTable Prefixes:</b> Additional prefixes of table names to regard
as System Tables. Tables that begin with "pg_" are always treated as system
tables, even without this option. Separate each prefix with a semicolon
(;)<br />&nbsp;</li>
</ul>
<h2>Advanced Options 2/3 Dialog Box</h2>
<ul>
<li><b>ReadOnly:</b> Whether the
datasource will allow updates.<br />&nbsp;</li>
<li><b>Show System Tables:</b> The
driver will treat system tables as regular tables in SQLTables. This
is good for Access so you can see system tables.<br />&nbsp;</li>
<li><b>LF <-> CR/LF conversion:</b> Convert Unix style line endings to
DOS style.<br />&nbsp;</li>
<li><b>Updateable Cursors:</b> Enable updateable cursor emulation in the
driver.<br />&nbsp;</li>
<li><b>Bytea as LO:</b> Allow the use of bytea columns for Large Objects.
<br />&nbsp;</li>
<li><b>Row Versioning:</b> Allows
applications to detect whether data has been modified by other users while
you are attempting to update a row. It also speeds the update process
since every single column does not need to be specified in the where clause
to update a row. The driver uses the "xmin" system field of PostgreSQL
to allow for row versioning. Microsoft products seem to use this
option well. See the <a "https://odbc.postgresql.org/faq.html">faq</a>
for details on what you need to do to your database to allow for the row
versioning feature to be used.<br />&nbsp;</li>
<li><b>True is -1:</b> Represent TRUE as -1 for compatibility with some applications.
<br />&nbsp;</li>
<li><b>Server side prepare:</b>If set, the driver uses server-side prepared
statements. See also <em>Parse Statement</em> option. Note that if a query
needs to be described before execution, e.g. because the application calls
SQLDescribeCol() or SQLNumResultCols() before SQLExecute(), the driver will
send a Parse request to the server even if this option is disabled. In that
case, the query that is sent to the server for parsing will have the
parameter markers replaced with the actual parameter values, or NULL literals
if the values are not known yet.
<li><b>Int8 As:</b> Define what datatype to report int8 columns as.<br />&nbsp;</li>
<li><b>Extra Opts:</b> combination of the following bits.<br /><br>&nbsp;
0x1: Force the output of short-length formatted connection string. Check this bit when you use MFC CDatabase class.<br />&nbsp;
0x2: Fake MS SQL Server so that MS Access recognizes PostgreSQL's serial type as AutoNumber type.<br />&nbsp;
0x4: Reply ANSI (not Unicode) char types for the inquiries from applications. Try to check this bit when your applications don't seem to be good at handling Unicode data.<br />&nbsp;</li>
<li><b>Protocol:</b> The libpq protocol version to use.<br /><br />
This option controls two aspects of the connection, the libpq protocol version and the level of rollback on errors.
For historical reasons the libpq protocol version is encoded as a PostgreSQL version number. The libpq protocol version used is the highest version, the given PostgreSQL server version supports.
The level of rollback on errors is optional and is a dash separated suffix number as described below.<br /><br />
<ul>
<li><i>7.4+</i>: Use the 7.4(V3) protocol. This is currently the only supported libpq protocol and this part of the parameter is currently ignored.<br />&nbsp;</li>
</ul></li>
<li><b>Level of rollback on errors:</b> Specifies what to rollback should an
error occur.<br />&nbsp;
<ul>
<li><i>Nop(0):</i> Don't rollback anything and let the application handle the
error.<br />&nbsp;</li>
<li><i>Transaction(1):</i> Rollback the entire transaction.<br />&nbsp;</li>
<li><i>Statement(2):</i> Rollback the statement.<br />&nbsp;</li>
<br>
<b>Setup note: This specification is set up with the PROTOCOL option parameter.</b><br><br>
PROTOCOL=7.4-(0|1|2)<br>
default value is Statement (it is Transaction for servers before 8.0).<br>
<br>
</ul></li>
<li><b>OID Options:</b><br />&nbsp;
<ul>
<li><i>Show Column: </i> Includes the OID
in SQLColumns. This is good for using as a unique identifier to update
records if no good key exists OR if the key has many parts, which
blows up the backend.<br />&nbsp;</li>
<li><i>Fake Index: </i> This option
fakes a unique index on OID. This is useful when there is not a real
unique index on OID and for apps which can't ask what the unique identifier
should be (i.e, Access 2.0).<br />&nbsp;</li>
</ul></li>
<li><b>Connect Settings:</b> The
driver sends these commands to the backend upon a successful connection.&nbsp;
It sends these settings AFTER it sends the driver "Connect Settings".
Use a semi-colon (;) to separate commands. This can now handle any
query, even if it returns results. The results will be thrown away
however!<br />&nbsp;</li>
<li><b>TCP KEEPALIVE setting(by sec):</b> Specifies TCP keepalives setting.<br />&nbsp;
<ul>
<li><i>disable:</i> Check when client-side TCP keepalives are not used.<br />&nbsp;</li>
<li><i>idle time:</i> The number of seconds of inactivity after which TCP should send a keepalive message to the server.<br />&nbsp;</li>
<li><i>interval:</i> The number of seconds after which a TCP keepalive message that is not acknowledged by the server should be retransmitted.<br />&nbsp;</li></ul>
<br>
</ul>
<h2>Advanced Options 3/3 Dialog Box</h2>
<ul>
<li><b>Allow connections urecoverable by MSDTC?:</b> How to test distributed transactions.
<br />&nbsp;</li>
<ul>
<li><i>yes:</i> MSDTC is needless unless applications crash. So don't check the connectivity from MSDTC.<br />&nbsp;</li>
<li><i>rejects sslmode verify-[ca|full]:</i> reject ssl connections with verify-ca or verify-full mode because in those cases msdtc could hardly establish the connection.<br />&nbsp;</li>
<li><i>no:</i> First confirm the connectivity from MSDTC.<br />&nbsp;</li></ul>
<br>
<li><b>Libpq parameters:</b> Specify libpq connection parameters with conninfo
style strings e.g. <b>sslrootcert=c:\\myfolder\\myroot sslcert=C:\\myfolder\\mycert sslkey=C:\\myfolder\\mykey</b>.<br>
Though host, port, dbname, user, password, sslmode, keepalives_idle or
keepalive_interval parameters can be set using this(pqopt) option, the use
is not recommended because they are ordinarily set by other options.
When some settings for those parameters conflict with other ordinary options,
connections are rejected.<br />&nbsp;</li>
</ul>
<h2>Global settings Dialog Box</h2>
<p>This dialog allows you to specify pre-connection/default logging
options</p>
<ul>
<li><b>CommLog (C:\psqlodbc_xxxx.log - Communications log):</b>
Log communications to/from the backend to that file. This is good
for debugging problems.<br />&nbsp;</li>
<li><b>MyLog (C:\mylog_xxxx.log - Detailed debug output):</b>
Log debug messages to that file. This is good
for debugging problems with the driver.<br />&nbsp;</li>
<li><b>MSDTCLog (C:\pgdtclog\mylog_xxxx.log - MSDTC debug output):</b>
Log debug messages to that file. This is good
for debugging problems with the MSDTC.<br />&nbsp;</li>
<li><b>Specification of the holder for log outputs:</b>
Adjustment of write permission.<br />&nbsp;</li>
</ul>
<h2>Manage DSN Dialog Box</h2>
<p>This dialog allows you to select which PostgreSQL ODBC driver
to use for this connection. Note that this may not work with third
party drivers.</p>
<h2>How to specify as a connection option</h2>
<p>There is a method of specifying a connection option in a keyword strings.</p>
<p>Example:VBA</p>
<ul><li><b>
myConn = "ODBC;DRIVER={PostgreSQL Unicode};" & serverConn & _<br>
"A0=0;A1=7.4;A2=0;A3=0;A4=0;A5=0;A6=;A7=100;A8=4096;A9=0;" & _<br>
"B0=254;B1=8190;B2=0;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;BI=-5;" & _<br>
"C0=0;C2=dd_;C4=1;C5=1;C6=1;C7=1;C8=1;C9=0;CA=verify-full;D1=30;D4=40;" & _<br>
"D5={sslrootcert=C:\\myfolder\\myroot sslcert=C:\\myfolder\\mycert sslkey=C:\\myfolder\\mykey}"
</b></li>
</ul>
<p>Please refer to a <a href="config-opt.html">keyword list</a> for details. </p>
</body>
</html>

BIN
docs/editConfiguration.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -0,0 +1,29 @@
The files:
msdtc_pgxalib_tracing_enable.reg
msdtc_pgxalib_tracing_disable.reg
are Windows Registry Editor files that can be opened to add registry entries
that turn psqlODBC's tracing for the Microsoft Distributed Transaction
Co-Ordinator (MSDTC) on and off.
You must also create C:\pgdtclog and ensure NETWORKSERVICE has write
permissions. (It will by default on most Windows installs). At time of writing
the trace path is hard coded to this location.
This tracing is separate to regular ODBC API tracing and to psqlODBC's "mylog"
tracing. It only traces access to the XA transaction manager used by MSDTC when
doing XA transaction co-ordination. You probably only need this if you're
debugging issues with "In doubt" or "only failed to notify" transactions in
MSDTC.
If you're tracing XA transactions in MSDTC you probably also want to trace
MSDTC its self. For that, see:
http://msdn.microsoft.com/en-us/library/ms684379(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms678917(v=vs.85).aspx
Tests suggest that only some SDKs' versions of the tracefmt.exe tool required
will work - I found that Windows SDK 7.1's worked, but Visual Studio Express
for Desktop 2012's didn't. Your results may vary.

Binary file not shown.

Binary file not shown.

670
docs/release-7.3.html Normal file
View File

@ -0,0 +1,670 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>psqlODBC release notes - 7.3 and below</title>
</HEAD>
<body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
<h1>psqlODBC release notes - 7.3 and below</h1>
<h2>Note</h2>
<p>Releases from this point onwards are based on the REL-07_03_ENHANCED code branch
of psqlODBC - please see
<a href="http://archives.postgresql.org/pgsql-odbc/2006-02/msg00131.php">http://archives.postgresql.org/pgsql-odbc/2006-02/msg00131.php</a>
for further details.</p>
<p>The following changes are based on the 07.03 codebase</p>
<pre>
[7.3.0261]
1.Handle the converion from text-like field to SQL_C_BINARY more properly.
2.Make buffer extension in SQLPutData more effective.
3.Reply SQL_CONVERT_xxxx correctly for SQLGetInfo request.
4.Reply DBMS_NAME, DBMS_VERSION correctly for SQLGetInfo request.
5.Not call show max_identifier_length in PG 7.4.
6.Change adjustLikePattern() to take literal quote(') into account.
7.Fix a bug in memory debug routine.
8.Change the multibyte encoding list to match that of the current
offical driver.
9.Change SC_clear_error() to call CC_clear_error() also.
10.Change the length values returned when they are unknown for
SQLDescribeCol or SQLColAttribute requests.
[7.3.0261]
1.Fix the handling of *too small buffer* in the Unicode version.
2.Fix the behavior of DiscardStatementSvp which resets the status too early.
3.Fix the bug in PGAPI_ParamData which fails to count the number
of parameters.
4.Allow blanks in password.
5.Add an option to force abbreviation of connection string.
6.Fix the handling of "PROTOCOL=x.x-x" in the connction string.
7.Fix the loadlib module of *nix.
[7.3.0260]
1. Change delay load import library mechanism(libpq,openssl)
2. Compile Optimization correspondence.
3. SQLForeignKeys ResultSet accuracy correspondence.
[7.3.0258]
1. bug fix: SQLBulkOperations rollback option.
There was a case where a rollback was not published in SQLBulkOperations
as option specification at the time of error generating.
[7.3.0257]
1. Fault correction of the division SQLGetData to SQL_C_WCHAR.
[7.3.0256]
1. SQLSetPos does not position to current-row to renewal of unblock cursor.
(Data is unacquirable by SQLGetData etc.)
[7.3.0255]
1. bug fix: leak of a return value clearance
2. Correspondence Windows English Dialog.
3. Changes into the libpq link method.
[7.3.0254]
1. Setting menu of SSLMODE is added.
2. Correspondence to domain type lo (an approvement is still required).
3. bug fix: LIBPQ version cancellation request transmitting correspondence.
4. Correction of the exclusive control between threads of SQLCancel
[7.3.0253]
1. Compilation of escape usage.
(preliminaries corresponding to a literal-escape abolition schedule)
2. Correspondence of libpq and openssl.
3. SQLProcedureColumns()RESULT_COLS row is outputted.
4. bug fix: server-side prepare the number check of parameters.
5. bug fix: parameter bind without a parameter marker is disregarded.
6. bug fix: Retrying without carrying out a select operation to EWOULDBLOCK of socket/SSL-read.
7. Abolition of abolition in manual_result mode, TupleList, and TupleNode employment
[7.3.0252]
1. Bug fix: Multi-byte employment by a table name etc.
2. The text (varchar/char) type key assignation was enabled by MS-Access.
[7.3.0251]
1. Suppression of SQLColumnPrivilege support
It rejects using information_schema.column_privileges.
2. Binary mode is used for a bytea type parameter value setup.
(Performs by the sequence of SQLPrepare->SQLExecute by server_side_prepare employment)
3. Coexistence of LO type and bytea type.
When the parameter of LongVarBinary exists not by SQLPrepare->SQLExecute but by
SQLExecDirect at the time of direct dispatching, the Parse/Describe function of
a protocol 3 is used, the model in saver of LongVarBinary is acquired beforehand,
and a bytea type and LO type are recognized.
[Feature of Driver7.3.025x]
1. Correspondence protocol 3
Options, such as client encoding, are set up by the start-up packet.
This makes the most of the mechanism of Parse/Bind/Execute.
.The outfit of SQLDescribeParam
.PREPARE/EXECUTE is changed from the command base to the protocol base.
.FETCH command is changed to an Execute request as it has come out.
.Moreover, bytea and lo type coexistence is possible.
.Others...
2. Enhancement in declare/fetch mode (7.4 or later)
Even if a certain renewal occurs on the way by holdable cursor exploitation,
a commitment is possible in comfort.
Moreover, the static update cursor was supported.
(Only for SQLSetPos correspondence, SQLBulkOperation are un-supporting)
Bug fix of the cursor which can be updated.
3. Rollback support of a syntactical unit at the time of an error.(8.0 or later)
Can choose from three Transaction module,Statement module,Nothing.
These can be specified by data source setup.
4. Output parameter support (8.1 or later)
Corresponded to the output parameter of the function introduced by 8.1.
(Only the return value of a function was supported before.)
</pre>
<hr>
<h2>psqlODBC 08.01.0200 Release</h2>
<p>psqlODBC 08.01.0200 contains only documentation changes over the 08.01.0108
development build.</p>
<br>
<li>Notes: psqlODBC 08.01.0108</li><br>
1) fix most warnings during build in x86_64 environment<br>
2) fixed point of failure on x86_64 boxes<br>
3) fixed autocommit = off behaviour with starting transactions when needed<br>
4) quick hack againist access violation with Disallow premature -
this rarely used feature is still broken, but should no longer crash<br>
5) report correct SQLSTATE in SQLGetDiagField and SQLGetDiagRec<br>
<br>
<li>Notes: psqlODBC 08.01.0107</li><br>
1) fix next problem with calling implicit rollback in bad time<br>
2) detecting transaction commands into if branch which mean backend
successfuly done the command. add support for "start transaction"<br>
3) fix bug when mylog output can't be created<br>
4) fix problem with SQLSetPos<br>
5) fix problem with column length in CC_mapping<br>
6) fix - typelen could be less then zero not only -1<br>
<br>
<li>Notes: psqlODBC 08.01.0106</li><br>
1) fix problem with getting long text in unicode driver<br>
2) fix sqlstate iin case of error in statement<br>
3) doesn't call rollback in autocommit off or in manual transaction<br>
4) remove obsolete parameter protocol<br>
<br>
<li>Notes: psqlODBC 08.01.0105</li><br>
Changes:<br>
1) fix problem with rollback aborted queries<br>
2) SQLColumns or SQLColAttribute may return bad answer when Show system tables is turned off<br>
3) adds support for ; delimited options in ConfigDSN<br>
4) fixes problem with binding parameters and SQLCancel without SQLFreeStmt<br>
<br>
<li>Notes: psqlODBC 08.01.0104</li><br>
Changes:<br>
1) add commit after set basic options in SQLDriverConnect when autocommit is turned off<br>
2) driver doesn't fail when there isn't bind enough parameters<br>
3) collattributes doesn't work since switch to libpq.<br>
There is still problem with select '' as xx from table<br>
4) SQLTables after SQLExecDirect has problem with GetData for all rows<br>
5) grow MAXKEYLEN for SQLConfigDataSource<br>
6) repair behaviour of more queries in one statement<br>
<br>
<li>Notes: psqlODBC 08.01.0103</li><br>
Changes:<br>
1) RowCount problem in SELECT<br>
2) Server side prepare - but only first run in allocated statement<br>
(http://pgfoundry.org/tracker/index.php?func=detail&aid=1000460&group_id=1000125&atid=538)<br>
3) Table names repeated in BDE with usedeclarefetch=1<br>
4) Binding parameters are now freed in SQLCancel<br>
5) Skip fetching data for commands<br>
<br>
<li>Notes: psqlODBC 08.01.0102</li><br>
Changes:<br>
1) Server side prepare now works correctly.<br>
2) A bug in SQLTables that shows up in Borland SQL Explorer in<br>
3) Declare/Fetch mode has been fixed.<br>
4) A number of inconsistent internal APIs have been cleaned up. These<br>
issues only showed up on some OS's.<br>
5) Correct value returned by SQLGetInfo for<br>
SQL_CATALOG_LOCATION/SQL_QUALIFIER_LOCATION. This prevented use of the<br>
driver in Visual Studio 2005.<br>
<br>
The last four numbers will represent the build. If the last 2 digits are<br>
both zero, a stable version is indicated. If the last two digits are<br>
non-zero, it is a development snapshot. <br>
So, starting with the next stable release, we will have:<br>
08.01.0200 - Stable<br>
08.01.0201 - Development<br>
...<br>
...<br>
08.01.0299 - Development<br>
08.01.0300 - Stable<br>
Of course, we won't necessarily have 99 snaphosts between stable releases!<br>
<br>
<li>Notes: psqlODBC 08.01.0101</li><br>
Changes:<br>
This release fixes a serious problem in non-declare/fetch mode where<br>
recordsets over the configured declare/fetch cache size were returned<br>
incorrectly. It is advised that all users of v08.01.0100 upgrade as soon<br>
as possible.<br>
<br>
<h2>psqlODBC 08.01.0100 Release</h2>
This release represents a major change to the driver over previous versions;<br>
in particular, the network code has been replaced with the PostgreSQL libpq<br>
library. This allows us to more easily take advantage of updates and new<br>
features that might be introduced to the PostgreSQL wire protocol, and also<br>
allowed us to upgrade straight away to the version 3 protocol which was<br>
previously unsupported. We were also able to add SSL support, as well as<br>
Kerberos authentication support.<br>
<br>
>From this release, two versions of the driver are provided for Windows,<br>
'PostgreSQL ANSI' which supports single and multibyte applications through<br>
the ANSI ODBC API, and 'PostgreSQL Unicode' which provides Unicode support<br>
through the Unicode ODBC API. On Unix systems, the driver type may be<br>
selected via a configure option.<br>
<br>
psqlODBC may be downloaded from http://www.postgresql.org/ftp/odbc/versions/<br>
in source, Windows Installer, merge module, and basic zip file formats.<br>
<br>
Please post any bug reports to the pgsql-odbc@postgresql.org mailing list.<br>
<br>
I'd like to take this opportunity to thank all those involved with the<br>
development, testing and bug fixing of the updated driver.<br>
PostgreSQL Core Team<br>
<br>
<li>Notes: psqlODBC 08.00.0102</li><br>
This is a bug fix release<br>
of the pre-libpq version of the driver, specifically to fix a bug<br>
affecting Unix users<br>
(http://gborg.postgresql.org/project/psqlodbc/bugs/bugupdate.php?1176)<br>
<br>
<h2>psqlODBC 08.00.0100 Release</h2>
The driver is available in source form, as well as a dll, merge module<br>
and msi installer for Windows.<br>
<br>
Regards, Dave.<br>
<br>
<li>Notes: psqlODBC 08.00.0005</li><br>
This version<br>
contains a some recent fixes, and is packaged in a new installer built<br>
entirely using open source tools (specifically, the Wix toolkit).<br>
<br>
<li>Notes: psqlODBC 08.00.0002</li><br>
This version of the driver is a minor update<br>
with a fix to the string sizing code in SQLGetInfo, and removal of the<br>
need for tables to be in the search path or public schema for them to be<br>
returned by SQLTables.<br>
<br>
<li>Notes: psqlODBC 08.00.0001</li><br>
The purpose of this version is to try to get something stable, with<br>
proper schema/without OID support ready for the 8.0 release<br>
(particularly the win32 release). To that end, this release is mainly a<br>
quick cleanup of the following:<br>
<br>
- GUI cleanup. Dialogues should behave better now and not have unlabeled<br>
buttons or move around the screen in strange ways.<br>
<br>
- Updateable Cursor support. This is largely experimental and is (I<br>
believe) the cause of a least a couple of stability issues in the recent<br>
snapshots. In this release it is marked 'experimental' on the setup<br>
dialogue (only in English, if anyone can do the Japanese version, please<br>
send a patch) and turned off by default.<br>
<br>
I'd appreciate it if ppl could test it a little with Updateable Cursors<br>
*turned off* and report any bugs.<br>
<br>
<h2>psqlODBC 07.05.0001</h2>
This is version 07.05.0001. For those that don't know or don't recall<br>
how the versioning works, the major and minor number track the latest<br>
release of PostgreSQL that the driver is expected to work with. The<br>
revision number is a bit more complex. The first two digits are the<br>
version number, where even numbers are development versions, and odd are<br>
release. The last two digits are the build number.<br>
<br>
In other words, this driver is build 01 of development version 00, and<br>
is expected to work with PostgreSQL 7.5dev. :-) The leading zeros are an<br>
ODBC thing...<br>
<br>
<h2>psqlODBC 07.03.0100 Release</h2>
I'm pleased to announce the long awaited new version of psqlODBC. This<br>
release represents a major change in the packaging and distribution of<br>
psqlODBC. In particular the following points should be noted:<br>
<br>
1) The build number will now be used to indicate both the release number<br>
(first 2 digits), and snapshot build number (last 2 digits). this<br>
release is 0100, or release 1, snapshot 0. The first development<br>
snapshot will become 0101, the second 0102 and so on. The next official<br>
release should be 07.03.0200.<br>
<br>
2) With this release, the ODBC 3 driver is now the default. The<br>
filenames, driver names and their capabilities are as follows:<br>
<br>
psqlodbc.dll PostgreSQL ODBC3.0 Level<br>
driver<br>
psqlodbc25.dll PostgreSQL Legacy ODBC2.5 Level<br>
driver<br>
psqlodbc30w.dll PostgreSQL Unicode (Beta) Beta quality ODBC3.0<br>
level driver with Unicode support<br>
<br>
3) The 3 drivers are no longer self contained. psqlodbc.dll is used as<br>
the setup dll for all three drivers, hence no matter how you<br>
redistribute or install the drivers, you should always include this<br>
file.<br>
<br>
In addition, this driver fixes an annoying problem with recent builds of<br>
PostgreSQL on Redhat systems that have a particularly long compiler<br>
version string that caused a buffer overflow resulting in a GPF on<br>
Windows upon connection to the database.<br>
The driver is released under the LGPL, and can be downloaded from the<br>
Downloads page on the website at<br>
http://gborg.postgresql.org/project/psqlodbc/projdisplay.php<br>
<br>
<h2>=== gborg.postgresql.org(This is the past history.) ===</h2>
1.33 by hinoue Annotate <br>
Thu Feb 5 09:11:44 2004 (2 weeks, 3 days ago)<br>
Changed since 1.32: +3 -3 [Select for Diff] <br>
Diffs to version 1.32 (long / unified) <br>
Diffs ignoring whitespace to version 1.32 (long / unified) <br>
[7.3.0208]<br>
1) Change catalog functions to search 'public' schema if a user<br>
tries to search the user named schema and finds no record to<br>
return.<br>
2) Set the statement status to STMT_FINISHED(not STMT_PREPARED)<br>
if the pre execution causes an error.<br>
3) Adjust null terminator for SQL_C_WCHAR type.<br>
4) Change getCharColumnSize to return max size when the<br>
statement has no result.<br>
5) Cache the number of parameters for statements. <br>
<br>
1.32 by hinoue Annotate <br>
Tue Jan 6 09:58:22 2004 (46 hours, 12 minutes ago)<br>
Changed since 1.31: +3 -3 [Select for Diff] <br>
Diffs to version 1.31 (long / unified) <br>
Diffs ignoring whitespace to version 1.31 (long / unified) <br>
1) Correct the handling of SQL_C_ULONG (for *nix).<br>
2) Prevent plan deallocation errors when the transaction<br>
is in abort status.<br>
3) Avoid a connection failure when notice message arrives.<br>
4) Improve the handling of mutex(critical section).<br>
5) Correct the cursor open check.<br>
6) Change the Unicode driver to set the NULL terminator<br>
of SQL_C_WCHAR type data properly.<br>
7) Add some m(re)alloc error check.<br>
8) Add proper cleanup steps for some functions.<br>
9) Return proper min & max scale for timestamp data type.<br>
10) Return proper scale for timestamp data fields.<br>
11) Fix the bug that .009 numeric generates .9 output. (George A.J) <br>
<br>
1.31 by hinoue Annotate <br>
Tue Dec 9 05:01:38 2003 (44 hours, 22 minutes ago)<br>
Changed since 1.30: +3 -3 [Select for Diff] <br>
Diffs to version 1.30 (long / unified) <br>
Diffs ignoring whitespace to version 1.30 (long / unified) <br>
[7.3.0205]<br>
(for *nix)<br>
1. Detect -lsocket for some platforms.<br>
2. Handle unix domain sockets.<br>
3. EINTR safety for send/recv.<br>
4. Set TCP_NDEALY option for inet connections.<br>
<1-4: thanks to Hartmut Raschick><br>
5. Use recursive mutex if possible.<br>
6. Add descriptor.c to Makefile.<br>
(for Windows)<br>
7. Automatic setting of client encoding for latin1(9).<br>
(common)<br>
8. Avoid those notorious core dumps when logging on hitting<br>
"null" data...<br>
<8: thanls to Hartmut Raschick><br>
9. Removed a static varible for thread-safety.<br>
10. Improve the performance of keyset-driven fetch operation.<br>
11. Map (var)char type to SQL type more properly.<br>
12. Change create_params for NUMERIC type to (precison, scale).<br>
13. Add type cast to remove some compiler warnings. <br>
<br>
1.30 by hinoue <br>
Wed Nov 12 05:15:21 2003 (8 days, 1 hour ago)<br>
Changed since 1.29: +3 -3 [Select for Diff] <br>
Diffs to version 1.29 (long / unified) <br>
Diffs ignoring whitespace to version 1.29 (long / unified) <br>
[7.03.0204]<br>
1) Clear statements' cursors on commit/rollback.<br>
2) Change SQLColumns, SQLTablePrivileges to take show_system_tables<br>
option into account.<br>
3) When an ODBC 2.x application working with an ODBC 3.x driver<br>
1.calls SQLExecDirect, SQLExecute, or SQLParamData, and a searched<br>
2.update or delete statement was executed but did not affect any<br>
3.rows at the data source, the ODBC 3.x driver should return<br>
4.SQL_SUCCESS. When an ODBC 3.x application working with an ODBC<br>
5.3.x driver calls SQLExecDirect, SQLExecute, or SQLParamData<br>
6.with the same result, the ODBC 3.x driver should return SQL_NO_DATA.<br>
<br>
1.29 by hinoue <br>
Mon Nov 10 02:10:07 2003 (10 hours, 1 minute ago)<br>
Changed since 1.28: +3 -3 [Select for Diff] <br>
Diffs to version 1.28 (long / unified) <br>
Diffs ignoring whitespace to version 1.28 (long / unified) <br>
[7.03.0203]<br>
1) Add conversion from text to SQL_C_BINARY(bug report from Brad Wilson).<br>
2) Change SQLColumns, SQLTables etc to initialize the statement handle<br>
properly(bug report from Yutaka Tanida).<br>
3) Improve the handling of mutex under *nix(bug report from Steve Wampler). <br>
<br>
1.28 by hinoue <br>
Wed Nov 5 20:35:02 2003 (4 days, 15 hours ago)<br>
Changed since 1.27: +3 -3 [Select for Diff] <br>
Diffs to version 1.27 (long / unified) <br>
Diffs ignoring whitespace to version 1.27 (long / unified) <br>
[7.03.0202]<br>
1) Improve SQLColAttributes(SQL_COLUMN_DISPLAY_SIZE) (bug report from Benjamin Riefenstahl).<br>
2) Correct EN_set_odbc3 macro (bug report from tomas@nocrew.org(Tomas Skäre)). <br>
<br>
1.27 by hinoue <br>
Sat Oct 25 00:19:23 2003 (2 weeks, 2 days ago)<br>
Changed since 1.26: +3 -3 [Select for Diff] <br>
Diffs to version 1.26 (long / unified) <br>
Diffs ignoring whitespace to version 1.26 (long / unified) <br>
[7.03.0201]<br>
1) Revise the handling of descriptors and implement SQLCopyDesc.<br>
2) Handle data_at_execution columns for SQLSetPos or SQLBulkOperations. <br>
<br>
1.26 by dpage <br>
Wed Oct 22 09:07:25 2003 (2 weeks, 5 days ago)<br>
CVS Tags: REL-07_03_0200 <br>
Changed since 1.25: +3 -3 [Select for Diff] <br>
Diffs to version 1.25 (long / unified) <br>
Diffs ignoring whitespace to version 1.25 (long / unified) <br>
Version number bump. <br>
<br>
1.25 by hinoue <br>
Sun Oct 19 22:37:42 2003 (3 weeks ago)<br>
Changed since 1.24: +3 -3 [Select for Diff] <br>
Diffs to version 1.24 (long / unified) <br>
Diffs ignoring whitespace to version 1.24 (long / unified) <br>
[7.03.0116]<br>
1. Fix a memory leak in case of updatable KEYSET_DRIVEN cursors.<br>
2. Change SQLMoreResults to initialize the cursor position.<br>
3. Hopefully, SQLDescribeCol() returns a more appropriate<br>
error code(SQLSTATE). <br>
<br>
1.24 by hinoue <br>
Fri Sep 19 05:25:17 2003 (7 weeks, 3 days ago)<br>
Changed since 1.23: +3 -3 [Select for Diff] <br>
Diffs to version 1.23 (long / unified) <br>
Diffs ignoring whitespace to version 1.23 (long / unified) <br>
1) Correct the return info for SQLGetInfo(.., SQL_CURSOR_COMMIT<br>
(ROLLBACK)_BEHAVIOR) call.<br>
2) Explictly reject the SQLBrowseConnect call. <br>
<br>
1.23 by hinoue <br>
Mon Sep 15 04:25:03 2003 (8 weeks ago)<br>
Changed since 1.22: +3 -3 [Select for Diff] <br>
Diffs to version 1.22 (long / unified) <br>
Diffs ignoring whitespace to version 1.22 (long / unified) <br>
1. Serialize the connection use for communication(multi-thread).<br>
2. Let escape strings case-insensitive. <br>
<br>
1.22 by hinoue <br>
Tue Sep 2 07:25:53 2003 (2 months, 1 week ago)<br>
Changed since 1.21: +1 -1 [Select for Diff] <br>
Diffs to version 1.21 (long / unified) <br>
Diffs ignoring whitespace to version 1.21 (long / unified) <br>
Fix a bug when handling data_at_execution parameter array<br>
reported by Jol Valentine <jolv@genaware.com>. <br>
<br>
1.21 by hinoue <br>
Wed Aug 27 06:17:53 2003 (2 months, 2 weeks ago)<br>
Changed since 1.20: +3 -3 [Select for Diff] <br>
Diffs to version 1.20 (long / unified) <br>
Diffs ignoring whitespace to version 1.20 (long / unified) <br>
1) Fix a bug on SQLSetStmtAttr(.., SQL_CONCURRENCY) reported by Shachar Shemesh.<br>
2) Apply a patch to changes the storage type of the debug "func" variables<br>
to be stored in the constant area of the program(Shachar Shemesh).<br>
3) Correct the column size in case of bytea as LO. <br>
<br>
1.20 by hinoue <br>
Wed Jul 30 21:57:50 2003 (3 months, 1 week ago)<br>
Changed since 1.19: +3 -3 [Select for Diff] <br>
Diffs to version 1.19 (long / unified) <br>
Diffs ignoring whitespace to version 1.19 (long / unified) <br>
1) Distinguish the rowset size for SQLFetch(Scroll) from that for<br>
SQLExtendedFetch.<br>
2) Implement SQLGetDiagFieldW() for the Unicode driver. <br>
<br>
1.19 by hinoue <br>
Fri Jul 11 06:47:17 2003 (4 months ago)<br>
Changed since 1.18: +3 -3 [Select for Diff] <br>
Diffs to version 1.18 (long / unified) <br>
Diffs ignoring whitespace to version 1.18 (long / unified) <br>
Improve SQLGetDiagField so that an MFC appliaction reports<br>
error messages properly(bug report from Silvio Scarpati). <br>
<br>
1.18 by hinoue <br>
Wed Jul 9 04:09:11 2003 (4 months ago)<br>
Changed since 1.17: +3 -3 [Select for Diff] <br>
Diffs to version 1.17 (long / unified) <br>
Diffs ignoring whitespace to version 1.17 (long / unified) <br>
Add quotes around table names to use ::regclass in parse.c . <br>
<br>
1.17 by hinoue <br>
Sun Jun 29 23:51:24 2003 (4 months, 1 week ago)<br>
Changed since 1.16: +3 -3 [Select for Diff] <br>
Diffs to version 1.16 (long / unified) <br>
Diffs ignoring whitespace to version 1.16 (long / unified) <br>
Change SQLGetFunctions to contain ODBC3 APIs. <br>
<br>
1.16 by hinoue <br>
Thu May 29 22:30:33 2003 (5 months, 1 week ago)<br>
Changed since 1.15: +3 -3 [Select for Diff] <br>
Diffs to version 1.15 (long / unified) <br>
Diffs ignoring whitespace to version 1.15 (long / unified) <br>
1) Improve the SQL_C_VARBOOKMARK type handling.<br>
2) Cleanup copy_and_convert_field() a little.<br>
3) Set an error number and an error message for SQLAllocHandle(<br>
SQL_HANDLE_DESC). <br>
<br>
1.15 by hinoue <br>
Tue May 27 22:26:37 2003 (5 months, 2 weeks ago)<br>
Changed since 1.14: +3 -3 [Select for Diff] <br>
Diffs to version 1.14 (long / unified) <br>
Diffs ignoring whitespace to version 1.14 (long / unified) <br>
Fix a bug about a bookmark handling in SQLBulkOperaitons(SQL_ADD,..) <br>
<br>
1.14 by hinoue <br>
Tue May 27 19:23:41 2003 (5 months, 2 weeks ago)<br>
Changed since 1.13: +3 -3 [Select for Diff] <br>
Diffs to version 1.13 (long / unified) <br>
Diffs ignoring whitespace to version 1.13 (long / unified) <br>
Remove date cast(::date) from the conversion of {d escape before<br>
7.3 servers. 7.2 servers are poor in implicit cast from date -><br>
timestamp without time zone. <br>
<br>
1.13 by hinoue <br>
Tue May 27 01:20:09 2003 (5 months, 2 weeks ago)<br>
Changed since 1.12: +3 -3 [Select for Diff] <br>
Diffs to version 1.12 (long / unified) <br>
Diffs ignoring whitespace to version 1.12 (long / unified) <br>
1) Corrent the handling of bookmark in SQLBulkOperations.<br>
2) Correct the calculation of a global index in SC_pos_add.<br>
3) Cleanup global/rowset/resultset index handling a little. <br>
<br>
1.12 by hinoue <br>
Sun May 25 20:47:50 2003 (5 months, 2 weeks ago)<br>
Changed since 1.11: +3 -3 [Select for Diff] <br>
Diffs to version 1.11 (long / unified) <br>
Diffs ignoring whitespace to version 1.11 (long / unified) <br>
Correct a handling of offset in SQLBulkOperations. <br>
<br>
1.11 by hinoue <br>
Tue May 20 10:11:22 2003 (5 months, 3 weeks ago)<br>
Changed since 1.10: +4 -4 [Select for Diff] <br>
Diffs to version 1.10 (long / unified) <br>
Diffs ignoring whitespace to version 1.10 (long / unified) <br>
Fix a crash bug in SQLDriverConnect(). <br>
<br>
1.10 by hinoue <br>
Tue May 20 06:39:28 2003 (5 months, 3 weeks ago)<br>
Changed since 1.9: +3 -3 [Select for Diff] <br>
Diffs to version 1.9 (long / unified) <br>
Diffs ignoring whitespace to version 1.9 (long / unified) <br>
The previous change wasn't in time of 7.3.0100.<br>
It belongs to 7.03.0101. <br>
<br>
1.9 by hinoue <br>
Mon May 19 06:12:09 2003 (5 months, 3 weeks ago)<br>
Changed since 1.8: +1 -1 [Select for Diff] <br>
Diffs to version 1.8 (long / unified) <br>
Diffs ignoring whitespace to version 1.8 (long / unified) <br>
1) Revert a *int8 as* DSN option to *numeric* for MS Jet.<br>
2) Add a SQL_CA2_SENSITIVITY_ADDTIONS mask to the reply for<br>
SQLGetInfo(.., SQL_ATTR_KEYSET_DRIVEN_CURSOR_ATTRIBUTES2)<br>
which would make a little OpenOffice happy.<br>
3) Fix a bug in SQLGetInfo(.., SQL_ATTR_ROW_NUMBER) for keyset_driven<br>
cursors. <br>
<br>
1.8 by dpage <br>
Thu May 15 04:24:40 2003 (5 months, 3 weeks ago)<br>
CVS Tags: REL-07_03_0100 <br>
Changed since 1.7: +3 -3 [Select for Diff] <br>
Diffs to version 1.7 (long / unified) <br>
Diffs ignoring whitespace to version 1.7 (long / unified) <br>
Updates for 07.03.0100 <br>
<br>
1.7 by dpage <br>
Thu May 15 03:38:16 2003 (5 months, 3 weeks ago)<br>
Changed since 1.6: +3 -3 [Select for Diff] <br>
Diffs to version 1.6 (long / unified) <br>
Diffs ignoring whitespace to version 1.6 (long / unified) <br>
Updates for 07.03.0001 <br>
<br>
1.6 by hinoue <br>
Mon May 12 11:44:08 2003 (5 months, 4 weeks ago)<br>
Changed since 1.5: +3 -3 [Select for Diff] <br>
Diffs to version 1.5 (long / unified) <br>
Diffs ignoring whitespace to version 1.5 (long / unified) <br>
1) Add a *bytea as LO* DSN option button.<br>
2) Add japanese resources to psqlodbc.rc.<br>
3) Add a dialog for the driver change. <br>
<br>
1.5 by hinoue <br>
Wed Apr 23 05:49:47 2003 (6 months, 2 weeks ago)<br>
Changed since 1.4: +3 -3 [Select for Diff] <br>
Diffs to version 1.4 (long / unified) <br>
Diffs ignoring whitespace to version 1.4 (long / unified) <br>
1) Avoid password leak in the log.<br>
2) Reduce time() calls for the performance.<br>
3) Improve the handling of per Driver resource.<br>
4) #define HAVE_STRTOLL<br>
etc. <br>
<br>
1.4 by hinoue <br>
Wed Nov 27 04:30:53 2002 (11 months, 1 week ago)<br>
CVS Tags: REL-07_02_0005 <br>
Changed since 1.3: +3 -3 [Select for Diff] <br>
Diffs to version 1.3 (long / unified) <br>
Diffs ignoring whitespace to version 1.3 (long / unified) <br>
Upgrade to 7.2.0005. <br>
<br>
1.3 by hinoue <br>
Thu Oct 10 02:37:54 2002 (13 months ago)<br>
CVS Tags: REL-07_02_0004 <br>
Changed since 1.2: +3 -3 [Select for Diff] <br>
Diffs to version 1.2 (long / unified) <br>
Diffs ignoring whitespace to version 1.2 (long / unified) <br>
1) Change SQLDescribeCol or SQLColAttribute to return right ResultNumCols for<br>
keyset/static cursors.<br>
2) Change PG_TYPE_TEXT -> PG_TYPE_VARCHAR for character columns of the<br>
result of catalog functions (bug report from Mike Mascari). <br>
<br>
1.2 by hinoue <br>
Mon Sep 23 04:08:22 2002 (13 months, 2 weeks ago)<br>
CVS Tags: REL-07_02_0003 <br>
Changed since 1.1: +3 -3 [Select for Diff] <br>
Diffs to version 1.1 (long / unified) <br>
Diffs ignoring whitespace to version 1.1 (long / unified) <br>
1) Removed most static variables for thread safety.<br>
2) Trial implementation of the thread safe driver under<br>
Windows.<br>
3) Fix a bug about DSN options setting.<br>
4) Fix a bug about Driver options setting.<br>
5) Implement SQLProcedureColumns().<br>
6) Changed default numeric precision/scale.<br>
7) Fix some memory leaks in Unicode driver.<br>
8) datetime -> timestamp with time zone since 7.0.<br>
9) Change manually started(using begin) transactions never<br>
be implicitly committed. <br>
<br>
1.1 by inoue <br>
Thu May 9 00:10:22 2002 (18 months ago)<br>
[Select for Diff] <br>
Add a file for version control. <br>
<br>
</body>
</html>

1363
docs/release.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compiling psqlODBC on Unix</title>
</HEAD>
<body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
<h1>Compiling psqlODBC on Unix</h1>
<p>Following psqlODBC's move away from the main PostgreSQL source tree, Peter Eisentraut was kind enough
provide a build environment for us which is now included in psqlODBC tarballs.</p>
<h2>Installation</h2>
<p>To install, just try something like:</p>
<blockquote>
<pre>
% tar -zxvf psqlodbc-xx.xx.xxxx.tar.gz
% cd psqlodbc-xx.xx.xxxx
% ./configure
% make
% make install
</pre>
</blockquote>
<p>The configure script will accept the following useful options:</p>
<ul>
<li>--with-libpq=DIR postgresql path (mandatory)</li>
<li>--with-unixodbc=DIR path or direct odbc_config file (default:yes)</li>
<li>--with-iodbc=DIR path or direct iodbc-config file</li>
<li>--with-odbcver=VERSION change default ODBC version number [0x0351]</li>
<li>--enable-pthreads (thread-safe driver on some platforms)</li>
<li>--disable-unicode (build non-Unicode driver)</li>
<li>--help</li>
</ul>
<h2>Building a distribution</h2>
<h3>Prerequisites</h3>
<ul>
<li>Autoconf 2.59 or higher</li>
<li>Automake 1.9.2 (Lower versions are rejected, version 1.7 untested.)</li>
<li>Libtool 1.5.10 or higher</li>
<li>PostgreSQL source tree (9.0 branch)</li>
</ul>
<h3>Bootstrapping</h3>
<blockquote>
<pre>
autoreconf -i
</pre>
</blockquote>
<p>You can run 'make maintainer-clean' to remove all the files this generates.</p>
<h3>Building</h3>
<blockquote>
<pre>
./configure
make
make install
</pre>
</blockquote>
<p>configure has the same options that the PostgreSQL configure used to
have for ODBC, namely --with-iodbc or --with-unixodbc
<h3>Making a Source Distribution</h3>
<p>'make dist' makes a file psqlodbc-xx.xx.xxxx.tar.gz. It's even better to
use 'make distcheck', which runs a number of tests to see if the
distribution is internally consistent.</p>
<p>The distribution does not contain any Windows-specific files (*.def,
maybe others). If it is desired to include them, edit Makefile.am.</p>
</body>
</html>

310
docs/win32-compilation.html Normal file
View File

@ -0,0 +1,310 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compiling psqlODBC on Windows</title>
<script src="frame_adjust.js" language="javascript"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
<h1>Compiling psqlODBC on Windows</h1>
<p>
This page describes how to build the PostgreSQL ODBC Driver on Windows. There
are three methods to build: from command line using nmake makefiles, from
Powershell using MSBuild files, and from Visual Studio IDE.
</p>
<p>
The following 3rd party software are required for the build:
<ul>
<li> Microsoft Windows SDK 7.0 (or later), or Microsoft Visual Studio C++ 2005
Edition (or later). Other compilers may work but have not been tested.
Download the latest version from <a href="http://www.microsoft.com/downloads/">Microsoft's download page</a>
</li>
<li> PostgreSQL Client library (libpq.dll) and headers. Download the latest
version from the <a href="http://www.enterprisedb.com/products-services-training/pgbindownload/">
PostgreSQL Binaries Download page</a>.
</li>
<li> WiX Toolset. Required for building the installer. Download the latest
version from the <a href="http://wixtoolset.org/">WiX Toolset website</a>
</ul>
</p>
<h2>Building with Powershell and MSBuild</h2>
<pre>
Using Powershell and MSBuild is recommended.
In fact the binaries of official release are built using this mothod.
Currently 4 Windows Powershell scripts are provided for developers.
winbuild/BuildAll.ps1 - build all dlls for psqlodbc drivers using
MSBuild.
winbuild/editConfiguration.ps1 - a GUI tool to set Build environment
winbuild/regress.ps1 - build regression test programs and run
installer/buildInstallers.ps1 - build installers(.msi and setup.exe)
Use Powershell console or Command Prompt to invoke scripts:
For example, to build the driver:
C:\psqlodbc\winbuild\> (Powershell) ./BuildAll.ps1 &lt;options&gt;
or you can use the same functionality from Command Prompt using Windows
helper batch at the parent folder (..\). See ..\readme_winbuild.txt.
C:\psqlodbc\> (Commnd Prompt) .\BuildAll.bat &lt;options&gt;
1. Please start a powershell console and set the ExecutionPolicy of
Powershell to RemoteSigned or Unrestricted.
You can get the ExecutionPolicy by typing
Get-ExecutionPolicy
When the ExectionPolicy is "Restricted" or "AllSigned" then type e.g.
Set-ExecutionPolicy RemoteSigned
To see details about ExecutionPolicy, type
Get-Help about_Execution_Policies
2. You have to install one of the following.
. Visual Studio 2015 non-Express edtion or Express 2015 for Windows
Desktop
. Visual Studio 2013 non-Express edtion or Express 2013 for Windows
Desktop
. Visual Studio 2012 non-Express edtion or Express 2012 for Windows
Desktop
. Full Microsoft Visual C++ 2010
. Windows SDK 7.1
You have to include x64 development tools (bin, lib, include) as
well as x86 ones for the installation.
You can install multiple versions of VC++ and use them.
You can easily switch by specifying VCVersion parameter.
3. Setup Build environment
Please type
.\editConfiguration(.ps1)
and edit the setting of your environment especially the folders
you placed libpq related include/lib/bin files.
<img src="./editConfiguration.jpg" />
4. Build
Please type
.\BuildAll(.ps1)
to invoke build operations.
If you installed both VC10 and VC12 and you'd like to compile
under VC10 environment, type
.\BuildAll(.ps1) -V(CVersion) 10.0
or set the value 10.0 to vcversion using ./editConfiguration.
To see details about the use of BuildAll, type
Get-Help .\BuildAll(.ps1) [-Detailed | -Examples | -Full]
5. Outputs of Build
The build can produce output in up to four directories for each of
the debug and release configurations:
- x64_Unicode_Release the Unicode driver, 64-bit
- x86_ANSI_Release the ANSI driver, 64-bit
- x86_Unicode_Release the ANSI driver, 32-bit
- x86_ANSI_Release the Unicode driver, 32-bit
For debug builds (-Configuration Debug) the directories are named with
Debug instead of Release but otherwise the same.
pgxalib.dll is only built for the multibyte/unicode version, as it is
the same for both unicode and ansi drivers.
6. How to use drivers.
You can't use psqlodbc drivers at once you build the drivers.
Usually you have to install drivers using installers made by
installer/buildInstallers.ps1. buildInstallers.ps1 bundles
libpq and related libraries like ssleay32, libeay32 from the
PostgreSQL bin directory and MSVC runtime libraries compiled with.
However, it is painful for developers to build binaries, build
installers and install each time the source files are changed.
It is recommended to use a special installation-less driver
(postgres_devw) registered by regress.ps1
7. Regression test in place
After BuildAll(.ps1), please type
.\regress(.ps1)
You have to neither install nor copy binaries.
By default, build 32-bit binaries from test sources and run the tests.
If you'd like to test 64-bit version, please type
.\regress(.ps1) -p(latform) x64
Please note the outputs(obj, exe etc) generated by build operations and
results of tests are placed in the directory winbuild/test_x86(test_x64
in case of 64-bit).
8. Installer
To build the .msi installer file:
C:\psqlodbc\installer\> (Powershell) ./buildInstallers.ps1 &lt;options&gt;
or
C:\psqlodbc\> (Command Prompt) .\buildInstallers.bat &lt;options&gt;
By default, buildInstallers.ps1 builds bootstrapper program
psqlodbc-setup.exe together.
See ../installer/readme.txt in the source directory for details.
Troubleshooting:
Some documentation on dealing with Windows SDK installation issues
can be found on the related pg_build_win page:
https://github.com/2ndQuadrant/pg_build_win#troubleshooting
</pre>
<h2>Building with nmake.exe</h2>
Use NMAKE.exe to build the driver for the currently active target:<br><br>
<code>C:\psqlodbc\&gt; nmake /f win64.mak &lt;options&gt;</code><br><br>
<p>
Despite the name, win64.mak is used to build both 32-bit and 64-bit binaries.
With the Microsoft Windows SDK Command Prompt, you can switch between 32-bit
and 64-bit target architectures with <tt>setenv /x86</tt> and <tt>setenv
/x64</tt> commands. If using a Visual Studio Command Prompt you can start the
x86 or x64 versions from the Start menu, or run <tt>vcvarsall.bat</tt> with
appropriate options to switch architectures.
</p>
<p>
To build the .msi installer file:<br><br>
<code>C:\psqlodbc\&gt; nmake /f win64.mak installer</code><br><br>
The resulting installer file goes to installer/x64 or installer/x86 directory.
</p>
<p>
To build both 32-bit and 64-bit versions in one command:<br><br>
<code>C:\psqlodbc\&gt; nmake /f win64.mak world</code><br><br>
</p>
<p>
The following build options may be used, either on the command line, or
by creating a file called "windows-local.mak".
</p>
<p>
<table cellspacing="0" cellpadding="3" width="780" border=1>
<tr>
<td>Variable</td>
<td>Values</td>
</tr>
<tr>
<td>CFG</td>
<td>Release(default), or Debug</td>
</tr>
<tr>
<td>PG_INC</td>
<td>$(PROGRAMFILES)\PostgreSQL\9.3\include</td>
</tr>
<tr>
<td>PG_LIB</td>
<td>$(PROGRAMFILES)\PostgreSQL\9.3\lib</td>
</tr>
<tr>
<td>SSL_INC</td>
<td>C:\OpenSSL-Win32\include</td>
</tr>
<tr>
<td>SSL_LIB</td>
<td>C:\OpenSSL-Win32\lib</td>
</tr>
<tr>
<td>ANSI_VERSION</td>
<td>no (If set to "yes", output dll name to psqlodbc30a.dll)</td>
</tr>
<tr>
<td>MSDTC</td>
<td>yes</td>
</tr>
</table></p>
<ol>
<li>UNICODE is the default (psqlodbc35w.dll), unless ANSI_VERSION is selected (psqlodbc30a.dll)</li>
<li>libpq.dll is mandatory.</li>
<li>If MSDTC == Yes, "pgxalib.dll" is created.</li>
<li>If MSDTC is enabled, ANSI_VERSION also creates "pgenlista.dll", or UNICODE creates "pgenlist.dll".</li>
</ol>
<h2>IDE Method</h2>
<p>A Microsoft Visual Studio project file (and workspace) is included in the source tree.
</p>
<p><strong>psqlodbc.dsp</strong>
can be used with Microsoft Visual C++ 6.0.
</p>
<p><strong>psqlodbc.proj</strong> and
<strong>psqlodbc.sln</strong>
can be used with Microsoft Visual C++ 2005 Edition (including the Express edition which can be downloaded free of charge from <a href="http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx">http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx</a>)
</p>
<p>
Preparation before the build:
</p>
<ol>
<li>The Windows distribution of PostgreSQL will install the required headers and libraries into C:\Program Files\PostgreSQL\9.2
<li>OpenSSL should be installed into C:\OpenSSL (OpenSSL binaries can be downloaded from <a href="http://www.slproweb.com/products/Win32OpenSSL.html">http://www.slproweb.com/products/Win32OpenSSL.html</a>)
</li></ol>
<p>
If you want to change the installation arrangement, it
is necessary to edit the project settings.
</p>
<p>
Note:
</p>
<p>
The default build settings will create the following driver:
</p>
<ol>
<li>UNICODE support.
<li>libpq is mandatory.
<li>The driver filename is "psqlodbc35w.dll".</li></ol>
</body>
</html>

599
drvconn.c Normal file
View File

@ -0,0 +1,599 @@
/*-------
Module: drvconn.c
*
* Description: This module contains only routines related to
* implementing SQLDriverConnect.
*
* Classes: n/a
*
* API functions: SQLDriverConnect
*
* Comments: See "readme.txt" for copyright and license information.
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <stdlib.h>
#include "connection.h"
#include "misc.h"
#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#else
#include <winsock2.h>
#endif
#include <string.h>
#ifdef WIN32
#include <windowsx.h>
#include "resource.h"
#endif
#include "pgapifunc.h"
#include "dlg_specific.h"
#define FORCE_PASSWORD_DISPLAY
#define NULL_IF_NULL(a) (a ? a : "(NULL)")
#ifndef FORCE_PASSWORD_DISPLAY
static char * hide_password(const char *str)
{
char *outstr, *pwdp;
if (!str) return NULL;
outstr = strdup(str);
if (!outstr) return NULL;
if (pwdp = strstr(outstr, "PWD="), !pwdp)
pwdp = strstr(outstr, "pwd=");
if (pwdp)
{
char *p;
for (p=pwdp + 4; *p && *p != ';'; p++)
*p = 'x';
}
return outstr;
}
#endif
/* prototypes */
static BOOL dconn_get_DSN_or_Driver(const char *connect_string, ConnInfo *ci);
static BOOL dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci);
#ifdef WIN32
LRESULT CALLBACK dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci);
extern HINSTANCE s_hModule; /* Saved module handle. */
#endif
#define PASSWORD_IS_REQUIRED 1
static int
paramRequired(const ConnInfo *ci, int reqs)
{
int required = 0;
const char *pw = SAFE_NAME(ci->password);
/* Password is not necessarily a required parameter. */
if ((reqs & PASSWORD_IS_REQUIRED) != 0)
if ('\0' == pw[0])
required |= PASSWORD_IS_REQUIRED;
return required;
}
RETCODE SQL_API
PGAPI_DriverConnect(HDBC hdbc,
HWND hwnd,
const SQLCHAR * szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR * szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT * pcbConnStrOut,
SQLUSMALLINT fDriverCompletion)
{
CSTR func = "PGAPI_DriverConnect";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci;
#ifdef WIN32
RETCODE dialog_result;
BOOL didUI = FALSE;
#endif
const char *lackMessage = NULL;
RETCODE result;
char *connStrIn = NULL;
char connStrOut[MAX_CONNECT_STRING];
int retval;
char salt[5];
ssize_t len = 0;
SQLSMALLINT lenStrout;
int reqs = 0;
MYLOG(0, "entering...\n");
if (!conn)
{
CC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
connStrIn = make_string(szConnStrIn, cbConnStrIn, NULL, 0);
/* CodeDEX with CID=11878 */
if (NULL == connStrIn)
{
CC_set_error(conn, CONN_NO_MEMORY_ERROR, "Out of memory while making_string for connStrIn", func);
return SQL_ERROR;
}
#ifdef FORCE_PASSWORD_DISPLAY
MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn);
#else
if (get_mylog())
{
char *hide_str = hide_password(connStrIn);
MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, NULL_IF_NULL(hide_str));
if (hide_str)
free(hide_str);
}
#endif /* FORCE_PASSWORD_DISPLAY */
ci = &(conn->connInfo);
/* First parse the connect string and get the name of DSN or Driver */
if (!dconn_get_DSN_or_Driver(connStrIn, ci))
{
CC_set_error(conn, CONN_OPENDB_ERROR, "Connection string parse error", func);
return SQL_ERROR;
}
/*
* 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, NULL);
/* Parse the connect string and fill in conninfo for this hdbc. */
if (!dconn_get_connect_attributes(connStrIn, ci))
{
CC_set_error(conn, CONN_OPENDB_ERROR, "Connection string parse error", func);
return SQL_ERROR;
}
logs_on_off(1, ci->drivers.debug, ci->drivers.commlog);
if (connStrIn)
{
free(connStrIn);
connStrIn = NULL;
}
/* initialize pg_version */
CC_initialize_pg_version(conn);
memset(salt, 0, sizeof(salt));
#ifdef WIN32
dialog:
#endif
MYLOG(DETAIL_LOG_LEVEL, "DriverCompletion=%d\n", fDriverCompletion);
switch (fDriverCompletion)
{
#ifdef WIN32
case SQL_DRIVER_PROMPT:
if (NULL == hwnd)
break;
dialog_result = dconn_DoDialog(hwnd, ci);
didUI = TRUE;
if (dialog_result != SQL_SUCCESS)
return dialog_result;
break;
case SQL_DRIVER_COMPLETE_REQUIRED:
/* Fall through */
case SQL_DRIVER_COMPLETE:
if (NULL == hwnd)
break;
if (paramRequired(ci, reqs))
{
dialog_result = dconn_DoDialog(hwnd, ci);
didUI = TRUE;
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 (paramRequired(ci, reqs))
{
if (!lackMessage)
lackMessage = "Please supply password";
CC_set_error(conn, CONN_OPENDB_ERROR, lackMessage, func);
return SQL_ERROR;
}
reqs = 0;
MYLOG(DETAIL_LOG_LEVEL, "before CC_connect\n");
/* do the actual connect */
retval = CC_connect(conn, 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
if (ci->password_required)
reqs |= PASSWORD_IS_REQUIRED;
if (hwnd && paramRequired(ci, reqs))
goto dialog;
#endif /* WIN32 */
/* Prompting for missing options is only supported on Windows. */
return SQL_ERROR;
}
}
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 = (1 == retval ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO);
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((char *) szConnStrOut, connStrOut, cbConnStrOutMax);
if (len >= cbConnStrOutMax)
{
int clen;
for (clen = cbConnStrOutMax - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--)
szConnStrOut[clen] = '\0';
result = SQL_SUCCESS_WITH_INFO;
CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the ConnStrOut.", func);
}
}
if (pcbConnStrOut)
*pcbConnStrOut = (SQLSMALLINT) len;
#ifdef FORCE_PASSWORD_DISPLAY
if (cbConnStrOutMax > 0)
{
MYLOG(0, "szConnStrOut = '%s' len=" FORMAT_SSIZE_T ",%d\n", NULL_IF_NULL((char *) szConnStrOut), len, cbConnStrOutMax);
}
#else
if (get_mylog())
{
char *hide_str = NULL;
if (cbConnStrOutMax > 0)
hide_str = hide_password(szConnStrOut);
MYLOG(0, "szConnStrOut = '%s' len=%d,%d\n", NULL_IF_NULL(hide_str), len, cbConnStrOutMax);
if (hide_str)
free(hide_str);
}
#endif /* FORCE_PASSWORD_DISPLAY */
MYLOG(0, "leaving %d\n", result);
return result;
}
#ifdef WIN32
RETCODE
dconn_DoDialog(HWND hwnd, ConnInfo *ci)
{
LRESULT dialog_result;
MYLOG(0, "entering ci = %p\n", ci);
if (hwnd)
{
dialog_result = DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_CONFIG),
hwnd, dconn_FDriverConnectProc, (LPARAM) ci);
if (-1 == dialog_result)
{
int errc = GetLastError();
MYLOG(0, " LastError=%d\n", errc);
}
if (!dialog_result || (dialog_result == -1))
return SQL_NO_DATA_FOUND;
else
return SQL_SUCCESS;
}
MYLOG(0, " No window specified\n");
return SQL_ERROR;
}
LRESULT CALLBACK
dconn_FDriverConnectProc(
HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
char strbuf[64];
switch (wMsg)
{
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
/* Change the caption for the setup dialog */
SetWindowText(hdlg, "PostgreSQL Connection");
LoadString(s_hModule, IDS_ADVANCE_CONNECTION, strbuf, sizeof(strbuf));
SetWindowText(GetDlgItem(hdlg, IDC_DATASOURCE), strbuf);
/* 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);
ShowWindow(GetDlgItem(hdlg, IDC_TEST), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE);
if ('\0' != ci->server[0])
EnableWindow(GetDlgItem(hdlg, IDC_SERVER), FALSE);
if ('\0' != ci->port[0])
EnableWindow(GetDlgItem(hdlg, IDC_PORT), FALSE);
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* Save the ConnInfo for the "OK" */
SetDlgStuff(hdlg, ci);
if (ci->password_required)
{
HWND notu = GetDlgItem(hdlg, IDC_NOTICE_USER);
SetFocus(GetDlgItem(hdlg, IDC_PASSWORD));
SetWindowText(notu, " Supply password ");
ShowWindow(notu, SW_SHOW);
SendMessage(notu, WM_CTLCOLOR, 0, 0);
}
else 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));
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
GetDlgStuff(hdlg, ci);
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE;
case IDC_DATASOURCE:
ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, ds_options1Proc, (LPARAM) ci);
break;
}
break;
case WM_CTLCOLORSTATIC:
if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER))
{
HBRUSH hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
SetTextColor((HDC)wParam, RGB(255, 0, 0));
return (LRESULT)hBrush;
}
break;
}
return FALSE;
}
#endif /* WIN32 */
#define ATTRIBUTE_DELIMITER ';'
#define OPENING_BRACKET '{'
#define CLOSING_BRACKET '}'
typedef BOOL (*copyfunc)(ConnInfo *, const char *attribute, char *value);
static BOOL
dconn_get_attributes(copyfunc func, const char *connect_string, ConnInfo *ci)
{
BOOL ret = TRUE;
char *our_connect_string;
char *pair,
*attribute,
*value,
*termp;
BOOL eoftok;
char *equals, *delp;
char *strtok_arg;
#ifdef HAVE_STRTOK_R
char *last = NULL;
#endif /* HAVE_STRTOK_R */
if (our_connect_string = strdup(connect_string), NULL == our_connect_string)
return FALSE;
strtok_arg = our_connect_string;
#ifdef FORCE_PASSWORD_DISPLAY
MYLOG(0, "our_connect_string = '%s'\n", our_connect_string);
#else
if (get_mylog())
{
char *hide_str = hide_password(our_connect_string);
MYLOG(0, "our_connect_string = '%s'\n", hide_str);
free(hide_str);
}
#endif /* FORCE_PASSWORD_DISPLAY */
termp = strchr(our_connect_string, '\0');
eoftok = FALSE;
while (!eoftok)
{
if (strtok_arg != NULL && strtok_arg >= termp) /* for safety */
break;
#ifdef HAVE_STRTOK_R
pair = strtok_r(strtok_arg, ";", &last);
#else
pair = strtok(strtok_arg, ";");
#endif /* HAVE_STRTOK_R */
if (strtok_arg)
strtok_arg = NULL;
if (!pair)
break;
equals = strchr(pair, '=');
if (!equals)
continue;
*equals = '\0';
attribute = pair; /* ex. DSN */
value = equals + 1; /* ex. 'CEO co1' */
/*
* Values enclosed with braces({}) can contain ; etc
* We don't remove the braces here because
* decode_or_remove_braces() in dlg_specifi.c
* would remove them later.
* Just correct the misdetected delimter(;).
*/
switch (*value)
{
const char *valuen, *closep;
case OPENING_BRACKET:
delp = strchr(value, '\0');
if (delp >= termp)
{
eoftok = TRUE;
break;
}
/* Where's a corresponding closing bracket? */
closep = strchr(value, CLOSING_BRACKET);
if (NULL != closep &&
closep[1] == '\0')
break;
for (valuen = value; valuen < termp; closep = strchr(valuen, CLOSING_BRACKET))
{
if (NULL == closep)
{
if (!delp) /* error */
{
MYLOG(0, "closing bracket doesn't exist 1\n");
ret = FALSE;
goto cleanup;
}
closep = strchr(delp + 1, CLOSING_BRACKET);
if (!closep) /* error */
{
MYLOG(0, "closing bracket doesn't exist 2\n");
ret = FALSE;
goto cleanup;
}
*delp = ATTRIBUTE_DELIMITER; /* restore delimiter */
delp = NULL;
}
if (CLOSING_BRACKET == closep[1])
{
valuen = closep + 2;
if (valuen >= termp)
break;
else if (valuen == delp)
{
*delp = ATTRIBUTE_DELIMITER;
delp = NULL;
}
continue;
}
else if (ATTRIBUTE_DELIMITER == closep[1] ||
'\0' == closep[1] ||
delp == closep + 1)
{
delp = (char *) (closep + 1);
*delp = '\0';
strtok_arg = delp + 1;
if (strtok_arg + 1 >= termp)
eoftok = TRUE;
break;
}
MYLOG(0, "subsequent char to the closing bracket is %c value=%s\n", closep[1], value);
ret = FALSE;
goto cleanup;
}
}
/* Copy the appropriate value to the conninfo */
(*func)(ci, attribute, value);
}
cleanup:
free(our_connect_string);
return ret;
}
static BOOL
dconn_get_DSN_or_Driver(const char *connect_string, ConnInfo *ci)
{
CC_conninfo_init(ci, INIT_GLOBALS);
return dconn_get_attributes(get_DSN_or_Driver, connect_string, ci);
}
static BOOL
dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci)
{
return dconn_get_attributes(copyConnAttributes, connect_string, ci);
}

4
editConfiguration.bat Executable file
View File

@ -0,0 +1,4 @@
::
:: Start editConfiguration with a mimimized console window
::
powershell -Sta -WindowStyle Minimized "& '%~dp0\winbuild\editConfiguration.ps1' %*"

648
environ.c Normal file
View File

@ -0,0 +1,648 @@
/*-------
* 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 "readme.txt" for copyright and license information.
*-------
*/
#include "environ.h"
#include "misc.h"
#include "connection.h"
#include "dlg_specific.h"
#include "statement.h"
#include <stdlib.h>
#include <string.h>
#include "pgapifunc.h"
#ifdef WIN32
#include <winsock2.h>
#endif /* WIN32 */
#include "loadlib.h"
/* The one instance of the handles */
static int conns_count = 0;
static ConnectionClass **conns = NULL;
#if defined(WIN_MULTITHREAD_SUPPORT)
CRITICAL_SECTION conns_cs;
CRITICAL_SECTION common_cs; /* commonly used for short term blocking */
CRITICAL_SECTION common_lcs; /* commonly used for not necessarily short term blocking */
#elif defined(POSIX_MULTITHREAD_SUPPORT)
pthread_mutex_t conns_cs;
pthread_mutex_t common_cs;
pthread_mutex_t common_lcs;
#endif /* WIN_MULTITHREAD_SUPPORT */
void shortterm_common_lock(void)
{
ENTER_COMMON_CS;
}
void shortterm_common_unlock(void)
{
LEAVE_COMMON_CS;
}
int getConnCount(void)
{
return conns_count;
}
ConnectionClass * const *getConnList(void)
{
return conns;
}
RETCODE SQL_API
PGAPI_AllocEnv(HENV * phenv)
{
CSTR func = "PGAPI_AllocEnv";
SQLRETURN ret = SQL_SUCCESS;
MYLOG(0, "entering\n");
/*
* For systems on which none of the constructor-making
* techniques in psqlodbc.c work:
* It's ok to call initialize_global_cs() twice.
*/
{
initialize_global_cs();
}
*phenv = (HENV) EN_Constructor();
if (!*phenv)
{
*phenv = SQL_NULL_HENV;
EN_log_error(func, "Error allocating environment", NULL);
ret = SQL_ERROR;
}
MYLOG(0, "leaving phenv=%p\n", *phenv);
return ret;
}
RETCODE SQL_API
PGAPI_FreeEnv(HENV henv)
{
CSTR func = "PGAPI_FreeEnv";
SQLRETURN ret = SQL_SUCCESS;
EnvironmentClass *env = (EnvironmentClass *) henv;
MYLOG(0, "entering env=%p\n", env);
if (env && EN_Destructor(env))
{
MYLOG(0, " ok\n");
goto cleanup;
}
ret = SQL_ERROR;
EN_log_error(func, "Error freeing environment", NULL);
cleanup:
return ret;
}
#define SIZEOF_SQLSTATE 6
static void
pg_sqlstate_set(const EnvironmentClass *env, UCHAR *szSqlState, const char *ver3str, const char *ver2str)
{
strncpy_null((char *) szSqlState, EN_is_odbc3(env) ? ver3str : ver2str, SIZEOF_SQLSTATE);
}
PG_ErrorInfo *
ER_Constructor(SDWORD errnumber, const char *msg)
{
PG_ErrorInfo *error;
ssize_t aladd, errsize;
if (DESC_OK == errnumber)
return NULL;
if (msg)
{
errsize = strlen(msg);
aladd = errsize - sizeof(error->__error_message) + 1;
if (aladd < 0)
aladd = 0;
}
else
{
errsize = -1;
aladd = 0;
}
error = (PG_ErrorInfo *) malloc(sizeof(PG_ErrorInfo) + aladd);
if (error)
{
memset(error, 0, sizeof(PG_ErrorInfo));
error->status = errnumber;
error->errorsize = (Int2) errsize;
if (errsize > 0)
memcpy(error->__error_message, msg, errsize);
error->__error_message[errsize] = '\0';
error->recsize = -1;
}
return error;
}
void
ER_Destructor(PG_ErrorInfo *self)
{
free(self);
}
PG_ErrorInfo *
ER_Dup(const PG_ErrorInfo *self)
{
PG_ErrorInfo *new;
Int4 alsize;
if (!self)
return NULL;
alsize = sizeof(PG_ErrorInfo);
if (self->errorsize > 0)
alsize += self->errorsize;
new = (PG_ErrorInfo *) malloc(alsize);
if (new)
memcpy(new, self, alsize);
return new;
}
#define DRVMNGRDIV 511
/* Returns the next SQL error information. */
RETCODE SQL_API
ER_ReturnError(PG_ErrorInfo *pgerror,
SQLSMALLINT RecNumber,
SQLCHAR * szSqlState,
SQLINTEGER * pfNativeError,
SQLCHAR * szErrorMsg,
SQLSMALLINT cbErrorMsgMax,
SQLSMALLINT * pcbErrorMsg,
UWORD flag)
{
/* CC: return an error of a hstmt */
PG_ErrorInfo *error;
BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0);
const char *msg;
SWORD msglen, stapos, wrtlen, pcblen;
if (!pgerror)
return SQL_NO_DATA_FOUND;
error = pgerror;
msg = error->__error_message;
MYLOG(0, "entering status = %d, msg = #%s#\n", error->status, msg);
msglen = (SQLSMALLINT) 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 (error->recsize < 0)
{
if (cbErrorMsgMax > 0)
error->recsize = cbErrorMsgMax - 1; /* apply the first request */
else
error->recsize = DRVMNGRDIV;
}
else if (1 == RecNumber && cbErrorMsgMax > 0)
error->recsize = cbErrorMsgMax - 1;
if (RecNumber < 0)
{
if (0 == error->errorpos)
RecNumber = 1;
else
RecNumber = 2 + (error->errorpos - 1) / error->recsize;
}
stapos = (RecNumber - 1) * error->recsize;
if (stapos > msglen)
return SQL_NO_DATA_FOUND;
pcblen = wrtlen = msglen - stapos;
if (pcblen > error->recsize)
pcblen = error->recsize;
if (0 == cbErrorMsgMax)
wrtlen = 0;
else if (wrtlen >= cbErrorMsgMax)
{
if (partial_ok)
wrtlen = cbErrorMsgMax - 1;
else if (cbErrorMsgMax <= error->recsize)
wrtlen = cbErrorMsgMax - 1;
else
wrtlen = 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 = error->status;
if (NULL != szSqlState)
strncpy_null((char *) szSqlState, error->sqlstate, 6);
MYLOG(0, " szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, pcblen, szErrorMsg);
if (wrtlen < pcblen)
return SQL_SUCCESS_WITH_INFO;
else
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_ConnectError(HDBC hdbc,
SQLSMALLINT RecNumber,
SQLCHAR * szSqlState,
SQLINTEGER * pfNativeError,
SQLCHAR * szErrorMsg,
SQLSMALLINT cbErrorMsgMax,
SQLSMALLINT * pcbErrorMsg,
UWORD flag)
{
ConnectionClass *conn = (ConnectionClass *) hdbc;
EnvironmentClass *env = (EnvironmentClass *) conn->henv;
char *msg;
int status;
BOOL once_again = FALSE;
ssize_t msglen;
MYLOG(0, "entering hdbc=%p <%d>\n", hdbc, cbErrorMsgMax);
if (RecNumber != 1 && RecNumber != -1)
return SQL_NO_DATA_FOUND;
if (cbErrorMsgMax < 0)
return SQL_ERROR;
if (CONN_EXECUTING == conn->status || !CC_get_error(conn, &status, &msg) || NULL == msg)
{
MYLOG(0, "CC_Get_error returned nothing.\n");
if (NULL != szSqlState)
strncpy_null((char *) szSqlState, "00000", SIZEOF_SQLSTATE);
if (NULL != pcbErrorMsg)
*pcbErrorMsg = 0;
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
szErrorMsg[0] = '\0';
return SQL_NO_DATA_FOUND;
}
MYLOG(0, "CC_get_error: status = %d, msg = #%s#\n", status, msg);
msglen = strlen(msg);
if (NULL != pcbErrorMsg)
{
*pcbErrorMsg = (SQLSMALLINT) msglen;
if (cbErrorMsgMax == 0)
once_again = TRUE;
else if (msglen >= cbErrorMsgMax)
*pcbErrorMsg = cbErrorMsgMax - 1;
}
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
strncpy_null((char *) szErrorMsg, msg, cbErrorMsgMax);
if (NULL != pfNativeError)
*pfNativeError = status;
if (NULL != szSqlState)
{
if (conn->sqlstate[0])
strncpy_null((char *) szSqlState, conn->sqlstate, SIZEOF_SQLSTATE);
else
switch (status)
{
case CONN_OPTION_VALUE_CHANGED:
pg_sqlstate_set(env, szSqlState, "01S02", "01S02");
break;
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, "HYC00", "IM001");
/* driver does not support this function */
break;
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, "HY011", "S1011");
break;
case CONN_NO_MEMORY_ERROR:
pg_sqlstate_set(env, szSqlState, "HY001", "S1001");
break;
case CONN_NOT_IMPLEMENTED_ERROR:
pg_sqlstate_set(env, szSqlState, "HYC00", "S1C00");
break;
case CONN_ILLEGAL_TRANSACT_STATE:
pg_sqlstate_set(env, szSqlState, "25000", "S1010");
break;
case CONN_VALUE_OUT_OF_RANGE:
pg_sqlstate_set(env, szSqlState, "HY019", "22003");
break;
case CONNECTION_COULD_NOT_SEND:
case CONNECTION_COULD_NOT_RECEIVE:
case CONNECTION_COMMUNICATION_ERROR:
case CONNECTION_NO_RESPONSE:
pg_sqlstate_set(env, szSqlState, "08S01", "08S01");
break;
default:
pg_sqlstate_set(env, szSqlState, "HY000", "S1000");
/* general error */
break;
}
}
MYLOG(0, " szSqlState = '%s',len=" FORMAT_SSIZE_T ", szError='%s'\n", szSqlState ? (char *) szSqlState : PRINT_NULL, msglen, szErrorMsg ? (char *) szErrorMsg : PRINT_NULL);
if (once_again)
{
CC_set_errornumber(conn, status);
return SQL_SUCCESS_WITH_INFO;
}
else
return SQL_SUCCESS;
}
RETCODE SQL_API
PGAPI_EnvError(HENV henv,
SQLSMALLINT RecNumber,
SQLCHAR * szSqlState,
SQLINTEGER * pfNativeError,
SQLCHAR * szErrorMsg,
SQLSMALLINT cbErrorMsgMax,
SQLSMALLINT * pcbErrorMsg,
UWORD flag)
{
EnvironmentClass *env = (EnvironmentClass *) henv;
char *msg = NULL;
int status;
MYLOG(0, "entering henv=%p <%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(0, "EN_get_error: msg = #%s#\n", 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(0, "EN_get_error: status = %d, msg = #%s#\n", status, msg);
if (NULL != pcbErrorMsg)
*pcbErrorMsg = (SQLSMALLINT) strlen(msg);
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
strncpy_null((char *) 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;
}
/*
* EnvironmentClass implementation
*/
EnvironmentClass *
EN_Constructor(void)
{
EnvironmentClass *rv = NULL;
#ifdef WIN32
WORD wVersionRequested;
WSADATA wsaData;
const int major = 2, minor = 2;
/* Load the WinSock Library */
wVersionRequested = MAKEWORD(major, minor);
if (WSAStartup(wVersionRequested, &wsaData))
{
MYLOG(0, " WSAStartup error\n");
return rv;
}
/* Verify that this is the minimum version of WinSock */
if (LOBYTE(wsaData.wVersion) >= 1 &&
(LOBYTE(wsaData.wVersion) >= 2 ||
HIBYTE(wsaData.wVersion) >= 1))
;
else
{
MYLOG(0, " WSAStartup version=(%d,%d)\n",
LOBYTE(wsaData.wVersion), HIBYTE(wsaData.wVersion));
goto cleanup;
}
#endif /* WIN32 */
rv = (EnvironmentClass *) malloc(sizeof(EnvironmentClass));
if (NULL == rv)
{
MYLOG(0, " malloc error\n");
goto cleanup;
}
rv->errormsg = 0;
rv->errornumber = 0;
rv->flag = 0;
INIT_ENV_CS(rv);
cleanup:
#ifdef WIN32
if (NULL == rv)
{
WSACleanup();
}
#endif /* WIN32 */
return rv;
}
char
EN_Destructor(EnvironmentClass *self)
{
int lf, nullcnt;
char rv = 1;
MYLOG(0, "entering self=%p\n", self);
if (!self)
return 0;
/*
* the error messages are static strings distributed throughout the
* source--they should not be freed
*/
/* Free any connections belonging to this environment */
ENTER_CONNS_CS;
for (lf = 0, nullcnt = 0; lf < conns_count; lf++)
{
if (NULL == conns[lf])
nullcnt++;
else if (conns[lf]->henv == self)
{
if (CC_Destructor(conns[lf]))
conns[lf] = NULL;
else
rv = 0;
nullcnt++;
}
}
if (conns && nullcnt >= conns_count)
{
MYLOG(0, "clearing conns count=%d\n", conns_count);
free(conns);
conns = NULL;
conns_count = 0;
}
LEAVE_CONNS_CS;
DELETE_ENV_CS(self);
free(self);
#ifdef WIN32
WSACleanup();
#endif
MYLOG(0, "leaving 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;
}
#define INIT_CONN_COUNT 128
char
EN_add_connection(EnvironmentClass *self, ConnectionClass *conn)
{
int i, alloc;
ConnectionClass **newa;
char ret = FALSE;
MYLOG(0, "entering self = %p, conn = %p\n", self, conn);
ENTER_CONNS_CS;
for (i = 0; i < conns_count; i++)
{
if (!conns[i])
{
conn->henv = self;
conns[i] = conn;
ret = TRUE;
MYLOG(0, " added at i=%d, conn->henv = %p, conns[i]->henv = %p\n", i, conn->henv, conns[i]->henv);
goto cleanup;
}
}
if (conns_count > 0)
alloc = 2 * conns_count;
else
alloc = INIT_CONN_COUNT;
if (newa = (ConnectionClass **) realloc(conns, alloc * sizeof(ConnectionClass *)), NULL == newa)
goto cleanup;
conn->henv = self;
newa[conns_count] = conn;
conns = newa;
ret = TRUE;
MYLOG(0, " added at %d, conn->henv = %p, conns[%d]->henv = %p\n", conns_count, conn->henv, conns_count, conns[conns_count]->henv);
for (i = conns_count + 1; i < alloc; i++)
conns[i] = NULL;
conns_count = alloc;
cleanup:
LEAVE_CONNS_CS;
return ret;
}
char
EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
{
int i;
for (i = 0; i < conns_count; i++)
if (conns[i] == conn && conns[i]->status != CONN_EXECUTING)
{
ENTER_CONNS_CS;
conns[i] = NULL;
LEAVE_CONNS_CS;
return TRUE;
}
return FALSE;
}
void
EN_log_error(const char *func, char *desc, EnvironmentClass *self)
{
if (self)
MYLOG(0, "ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
else
MYLOG(0, "INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
}

104
environ.h Normal file
View File

@ -0,0 +1,104 @@
/*
*
* Description: See "environ.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __ENVIRON_H__
#define __ENVIRON_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psqlodbc.h"
#if defined (POSIX_MULTITHREAD_SUPPORT)
#include <pthread.h>
#endif
#define ENV_ALLOC_ERROR 1
/********** Environment Handle *************/
struct EnvironmentClass_
{
char *errormsg;
int errornumber;
Int4 flag;
#if defined(WIN_MULTITHREAD_SUPPORT)
CRITICAL_SECTION cs;
#elif defined(POSIX_MULTITHREAD_SUPPORT)
pthread_mutex_t cs;
#endif /* WIN_MULTITHREAD_SUPPORT */
};
/* 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(const char *func, char *desc, EnvironmentClass *self);
int getConnCount(void);
ConnectionClass * const *getConnList(void);
#define EN_OV_ODBC2 1L
#define EN_CONN_POOLING (1L<<1)
#define EN_is_odbc2(env) ((env->flag & EN_OV_ODBC2) != 0)
#define EN_is_odbc3(env) (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)
#define EN_is_pooling(env) (env && (env->flag & EN_CONN_POOLING) != 0)
#define EN_set_pooling(env) (env->flag |= EN_CONN_POOLING)
#define EN_unset_pooling(env) (env->flag &= ~EN_CONN_POOLING)
/* For Multi-thread */
#if defined( WIN_MULTITHREAD_SUPPORT)
#define INIT_CONNS_CS InitializeCriticalSection(&conns_cs)
#define ENTER_CONNS_CS EnterCriticalSection(&conns_cs)
#define LEAVE_CONNS_CS LeaveCriticalSection(&conns_cs)
#define DELETE_CONNS_CS DeleteCriticalSection(&conns_cs)
#define INIT_ENV_CS(x) InitializeCriticalSection(&((x)->cs))
#define ENTER_ENV_CS(x) EnterCriticalSection(&((x)->cs))
#define LEAVE_ENV_CS(x) LeaveCriticalSection(&((x)->cs))
#define DELETE_ENV_CS(x) DeleteCriticalSection(&((x)->cs))
#define INIT_COMMON_CS InitializeCriticalSection(&common_cs)
#define ENTER_COMMON_CS EnterCriticalSection(&common_cs)
#define LEAVE_COMMON_CS LeaveCriticalSection(&common_cs)
#define DELETE_COMMON_CS DeleteCriticalSection(&common_cs)
#elif defined(POSIX_MULTITHREAD_SUPPORT)
#define INIT_CONNS_CS pthread_mutex_init(&conns_cs,0)
#define ENTER_CONNS_CS pthread_mutex_lock(&conns_cs)
#define LEAVE_CONNS_CS pthread_mutex_unlock(&conns_cs)
#define DELETE_CONNS_CS pthread_mutex_destroy(&conns_cs)
#define INIT_ENV_CS(x) pthread_mutex_init(&((x)->cs),0)
#define ENTER_ENV_CS(x) pthread_mutex_lock(&((x)->cs))
#define LEAVE_ENV_CS(x) pthread_mutex_unlock(&((x)->cs))
#define DELETE_ENV_CS(x) pthread_mutex_destroy(&((x)->cs))
#define INIT_COMMON_CS pthread_mutex_init(&common_cs,0)
#define ENTER_COMMON_CS pthread_mutex_lock(&common_cs)
#define LEAVE_COMMON_CS pthread_mutex_unlock(&common_cs)
#define DELETE_COMMON_CS pthread_mutex_destroy(&common_cs)
#else
#define INIT_CONNS_CS
#define ENTER_CONNS_CS
#define LEAVE_CONNS_CS
#define DELETE_CONNS_CS
#define INIT_ENV_CS(x)
#define ENTER_ENV_CS(x)
#define LEAVE_ENV_CS(x)
#define DELETE_ENV_CS(x)
#define INIT_COMMON_CS
#define ENTER_COMMON_CS
#define LEAVE_COMMON_CS
#define DELETE_COMMON_CS
#endif /* WIN_MULTITHREAD_SUPPORT */
void shortterm_common_lock(void);
void shortterm_common_unlock(void);
#ifdef __cplusplus
}
#endif
#endif /* __ENVIRON_H_ */

1770
execute.c Normal file

File diff suppressed because it is too large Load Diff

5952
info.c Normal file

File diff suppressed because it is too large Load Diff

266
inouealc.c Normal file
View File

@ -0,0 +1,266 @@
#undef _MEMORY_DEBUG_
#include "psqlodbc.h"
#ifdef WIN32
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#else
#include <malloc.h>
#endif /* _DEBUG */
#endif /* WIN32 */
#include <string.h>
#include "misc.h"
typedef struct {
size_t len;
void *aladr;
} ALADR;
static int alsize = 0;
static int tbsize = 0;
static ALADR *altbl = NULL;
CSTR ALCERR = "alcerr";
void * pgdebug_alloc(size_t size)
{
void * alloced;
alloced = malloc(size);
MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size);
if (alloced)
{
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
altbl[tbsize].aladr = alloced;
altbl[tbsize].len = size;
tbsize++;
}
else
MYLOG(0, "%s:alloc " FORMAT_SIZE_T "byte\n", ALCERR, size);
return alloced;
}
void * pgdebug_calloc(size_t n, size_t size)
{
void * alloced = calloc(n, size);
if (alloced)
{
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
altbl[tbsize].aladr = alloced;
altbl[tbsize].len = n * size;
tbsize++;
}
else
MYLOG(0, "%s:calloc " FORMAT_SIZE_T "byte\n", ALCERR, size);
MYLOG(2, "calloced = %p\n", alloced);
return alloced;
}
void * pgdebug_realloc(void * ptr, size_t size)
{
void * alloced;
if (!ptr)
return pgdebug_alloc(size);
alloced = realloc(ptr, size);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
}
else /* if (alloced != ptr) */
{
int i;
for (i = 0; i < tbsize; i++)
{
if (altbl[i].aladr == ptr)
{
altbl[i].aladr = alloced;
altbl[i].len = size;
break;
}
}
}
MYLOG(2, "%p->%p\n", ptr, alloced);
return alloced;
}
char * pgdebug_strdup(const char * ptr)
{
char * alloced = strdup(ptr);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
}
else
{
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
altbl[tbsize].aladr = alloced;
altbl[tbsize].len = strlen(ptr) + 1;
tbsize++;
}
MYLOG(2, "%p->%p(%s)\n", ptr, alloced, alloced);
return alloced;
}
void pgdebug_free(void * ptr)
{
int i, j;
int freed = 0;
if (!ptr)
{
MYLOG(0, "%s null ptr\n", ALCERR);
return;
}
for (i = 0; i < tbsize; i++)
{
if (altbl[i].aladr == ptr)
{
for (j = i; j < tbsize - 1; j++)
{
altbl[j].aladr = altbl[j + 1].aladr;
altbl[j].len = altbl[j + 1].len;
}
tbsize--;
freed = 1;
break;
}
}
if (! freed)
{
MYLOG(0, "%s not found ptr %p\n", ALCERR, ptr);
return;
}
else
MYLOG(2, "ptr=%p\n", ptr);
free(ptr);
}
static BOOL out_check(void *out, size_t len, const char *name)
{
BOOL ret = TRUE;
int i;
for (i = 0; i < tbsize; i++)
{
if ((ULONG_PTR)out < (ULONG_PTR)(altbl[i].aladr))
continue;
if ((ULONG_PTR)out < (ULONG_PTR)(altbl[i].aladr) + altbl[i].len)
{
if ((ULONG_PTR)out + len > (ULONG_PTR)(altbl[i].aladr) + altbl[i].len)
{
ret = FALSE;
MYLOG(0, "%s:%s:out_check found memory buffer overrun %p(" FORMAT_SIZE_T ")>=%p(" FORMAT_SIZE_T ")\n", ALCERR, name, out, len, altbl[i].aladr, altbl[i].len);
}
break;
}
}
return ret;
}
char *pgdebug_strcpy(char *out, const char *in)
{
if (!out || !in)
{
MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in);
return NULL;
}
out_check(out, strlen(in) + 1, __FUNCTION__);
return strcpy(out, in);
}
char *pgdebug_strncpy(char *out, const char *in, size_t len)
{
if (!out || !in)
{
MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in);
return NULL;
}
out_check(out, len, __FUNCTION__);
return strncpy(out, in, len);
}
char *pgdebug_strncpy_null(char *out, const char *in, size_t len)
{
if (!out || !in)
{
MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in);
return NULL;
}
out_check(out, len, __FUNCTION__);
strncpy_null(out, in, len);
return out;
}
void *pgdebug_memcpy(void *out, const void *in, size_t len)
{
if (!out || !in)
{
MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in);
return NULL;
}
out_check(out, len, __FUNCTION__);
return memcpy(out, in, len);
}
void *pgdebug_memset(void *out, int c, size_t len)
{
if (!out)
{
MYLOG(0, "%s null pointer out=%p\n", ALCERR, out);
return NULL;
}
out_check(out, len, __FUNCTION__);
return memset(out, c, len);
}
void debug_memory_check(void)
{
int i;
if (0 == tbsize)
{
MYLOG(0, "no memry leak found and max count allocated so far is %d\n", alsize);
free(altbl);
alsize = 0;
}
else
{
MYLOG(0, "%s:memory leak found check count=%d alloc=%d\n", ALCERR, tbsize, alsize);
for (i = 0; i < tbsize; i++)
{
MYLOG(0, "%s:leak = %p(" FORMAT_SIZE_T ")\n", ALCERR, altbl[i].aladr, altbl[i].len);
}
}
}

5
installer/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
psqlodbc.msi
psqlodbc.msm
psqlodbc.wixobj
psqlodbc.wixpdb
psqlodbcm.wixobj

39
installer/README.txt Normal file
View File

@ -0,0 +1,39 @@
This directory contains the psqlODBC installer for Windows. To build the
installer, you will need a copy of WiX installed somewhere in your system
path. The installer has been tested with WiX version 3.0.2420 and WiX 3.8 at
the time writing.
WiX may be downloaded from:
http://wix.codeplex.com/
Two parallel systems to build the installers are currently provided:
POWERSHELL BASED
----------
Ensure that suitable binaries are in the parent directory Release build outputs
(see ..\winbuild for that).
.\buildInstallers.ps1
For help:
Get-Help .\buildInstallers.ps1
If you get execution policy errors:
Set-ExecutionPolicy RemoteSigned
and try again.
Note that these installer generators use the configuration file prepared by the
PowerShell scripts in ..\winbuild, defaulting to ..\winbuild\configuration.xml,
so you can't just mix them with SDK- or NMake based compilation.
NMAKE BASED
-----------
Use the top-level file (win64.mak), per the documentation in
docs/win32-compilation.html, to build installers using NMake.

BIN
installer/background.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

BIN
installer/banner.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -0,0 +1,368 @@
<#
.SYNOPSIS
Build all installers of psqlodbc project.
.DESCRIPTION
Build psqlodbc_x86.msi(msm), psqlodbc_x64.msi(msm).
.PARAMETER cpu
Specify build cpu type, "both"(default), "x86" or "x64" is
available.
.PARAMETER AlongWithDrivers
Specify when you'd like to build drivers before building installers.
.PARAMETER ExcludeRuntime
Specify when you'd like to exclude a msvc runtime dll from the installer.
.PARAMETER RedistUCRT
Specify when you'd like to redistribute Visual C++ 2015(or later) Redistributable.
.PARAMETER NoPDB
Specify when you'd rather not include PDB files.
.PARAMETER BuildConfigPath
Specify the configuration xml file name if you want to use
the configuration file other than standard one.
The relative path is relative to the current directory.
.EXAMPLE
> .\buildInstallers
Build 32bit and 64bit installers.
.EXAMPLE
> .\buildInstallers x86
Build 32bit installers.
.NOTES
Author: Hiroshi Inoue
Date: July 4, 2014
#>
# build 32bit and/or 64bit installers
#
Param(
[ValidateSet("x86", "x64", "both")]
[string]$cpu="both",
[switch]$AlongWithDrivers,
[switch]$ExcludeRuntime,
[switch]$RedistUCRT,
[switch]$NoPDB,
[string]$BuildConfigPath
)
[int]$ucrt_version=14
[String]$str_msvcr="msvcr"
[String]$str_vcrun="vcruntime"
[String]$str_msvcp="msvcp"
[String]$msrun_ptn="msvcr|vcruntime"
function msvcrun([int]$runtime_version)
{
[String]$str = if ($runtime_version -lt $ucrt_version) {$str_msvcr} else {$str_vcrun}
return $str
}
function env_vcversion_no()
{
$viver = $env:VisualStudioVersion
if ("$viver" -ne "") {
if ("$viver" -match "(\d+)\.0") {
return [int]$matches[1]
}
}
return 0
}
function toolset_no_to_runtimeversion([int]$toolset_no)
{
return [int] ($toolset_no / 10)
}
function runtimeversion_to_toolset_no([int]$runtime_version)
{
[int]$toolset_no = $runtime_version * 10
if ($runtime_version -eq 14) { # possibly be v141
[int]$vc_ver = 15;
if ((env_vcversion_no) -eq $vc_ver) { # v141
$toolseto++
} elseif (Find-VSDir $vc_ver -ne "") { # v141
$toolset_no++
}
}
return $toolset_no
}
function toolset_no_to_vcversion([int]$toolset_no)
{
return [int] ($toolset_no / 10 + $toolset_no % 10)
}
function findRuntime([int]$toolset_no, [String]$pgmvc)
{
$runtime_version = toolset_no_to_runtimeversion($toolset_no)
$vcversion_no = toolset_no_to_vcversion($toolset_no)
# where's the dll?
[String]$rt_dllname = (msvcrun $runtime_version) + "${runtime_version}0.dll"
if ("$pgmvc" -ne "") {
$dllspecified = "${pgmvc}\${rt_dllname}"
if (Test-Path -Path $dllspecified) {
return $dllspecified, ""
}
}
$dllinredist = "${LIBPQBINDIR}\${rt_dllname}"
if (Test-Path -Path $dllinredist) {
return $dllinredist, ""
}
if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
$pgmvc = "$env:ProgramFiles"
} else {
$pgmvc = "${env:ProgramFiles(x86)}"
}
$dllinredist = ""
$vsdir = Find-VSDir $vcversion_no
if ("$vsdir" -ne "") {
if ($vcversion_no -gt 14) { # VC15 ~ VC??
$lslist = @(Get-ChildItem "${vsdir}VC\Redist\MSVC\*\${CPUTYPE}\Microsoft.VC${toolset_no}.CRT\${rt_dllname}" -ErrorAction SilentlyContinue)
if ($lslist.Count -gt 0) {
$dllinredist = $lslist[0].FullName
}
} else { # VC10 ~ VC14
$dllinredist = "${vsdir}VC\redist\${CPUTYPE}\Microsoft.VC${toolset_no}.CRT\${rt_dllname}"
}
}
if (("$dllinredist" -ne "") -and (Test-Path -Path $dllinredist)) {
return $dllinredist, ""
} else {
$messageSpec = "Please specify Configuration.$CPUTYPE.runtime_folder element of the configuration file where msvc runtime dll $rt_dllname can be found"
if ($CPUTYPE -eq "x86") {
if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
$pgmvc = "${env:SystemRoot}\system32"
} else {
$pgmvc = "${env:SystemRoot}\syswow64"
}
} else {
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
$pgmvc = "${env:SystemRoot}\system32"
} elseif ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
$pgmvc = "${env:SystemRoot}\sysnative"
} else {
throw "${messageSpec}`n$dllinredist doesn't exist unfortunately"
}
}
$dllinsystem = "${pgmvc}\${rt_dllname}"
if (-not(Test-Path -Path $dllinsystem)) {
throw "${messageSpec}`nneither $dllinredist nor $dllinsystem exists unfortunately"
}
}
return "", $rt_dllname
}
function buildInstaller([string]$CPUTYPE)
{
$LIBPQBINDIR=getPGDir $configInfo $CPUTYPE "bin"
# msvc runtime psqlodbc links
$PODBCMSVCDLL = ""
$PODBCMSVPDLL = ""
$PODBCMSVCSYS = ""
$PODBCMSVPSYS = ""
# msvc runtime libpq links
$LIBPQMSVCDLL = ""
$LIBPQMSVCSYS = ""
$pgmvc = $configInfo.Configuration.$CPUTYPE.runtime_folder
if (-not $ExcludeRuntime) {
$toolset = $configInfo.Configuration.BuildResult.PlatformToolset
if ($toolset -match "^v(\d+)") {
$toolset_no0 = [int]$matches[1]
} else {
$toolset_no0 = 100
}
$runtime_version0 = toolset_no_to_runtimeversion($toolset_no0)
# where's the msvc runtime dll psqlodbc links?
if ($runtime_version0 -ge $ucrt_version -and $RedistUCRT) {
$script:wRedist=$true
} else {
$dlls=findRuntime $toolset_no0 $pgmvc
$PODBCMSVCDLL=$dlls[0]
if ("$PODBCMSVCDLL" -ne "") {
Write-Host "psqlodbc picks $PODBCMSVCDLL"
}
$PODBCMSVCSYS=$dlls[1]
if ("$PODBCMSVCSYS" -ne "") {
Write-Host "psqlodbc picks system $PODBCMSVCSYS"
}
$PODBCMSVPDLL=$PODBCMSVCDLL.Replace((msvcrun $runtime_version0), $str_msvcp)
$PODBCMSVPSYS=$PODBCMSVCSYS.Replace((msvcrun $runtime_version0), $str_msvcp)
}
# where's the runtime dll libpq links?
$msvclist=& ${dumpbinexe} /imports $LIBPQBINDIR\libpq.dll | select-string -pattern "^\s*($msrun_ptn)(\d+)0\.dll" | % {$_.Matches.Groups[2].Value}
if ($msvclist -ne $Null -and $msvclist.length -gt 0) {
if ($msvclist.GetType().Name -eq "String") {
$runtime_version1=[int]$msvclist
} else {
$runtime_version1=[int]$msvclist[0]
}
if ($runtime_version1 -eq $runtime_version0) {
$toolset_no1 = $toolset_no0
} else {
$toolset_no1 = runtimeversion_to_toolset_no($runtime_version1)
}
if ($runtime_version1 -ge $ucrt_version -and $RedistUCRT) {
$script:wRedist=$true
} elseif ($runtime_version1 -ne $runtime_version0) {
$dlls=findRuntime $toolset_no1 $pgmvc
$LIBPQMSVCDLL=$dlls[0]
if ("$LIBPQMSVCDLL" -ne "") {
Write-Host "LIBPQ picks $LIBPQMSVCDLL"
}
$LIBPQMSVCSYS=$dlls[1]
if ("$LIBPQMSVCSYS" -ne "") {
Write-Host "LIBPQ picks system $LIBPQMSVCSYS"
}
}
} else {
$script:wRedist=$true
}
}
Write-Host "CPUTYPE : $CPUTYPE"
Write-Host "VERSION : $VERSION"
Write-Host "LIBPQBINDIR: $LIBPQBINDIR"
if ($env:WIX -ne "")
{
$wix = "$env:WIX"
$env:Path += ";$WIX/bin"
}
# The subdirectory to install into
$SUBLOC=$VERSION.substring(0, 2) + $VERSION.substring(3, 2)
#
$maxmem=10
$libpqmem=Get-RelatedDlls "libpq.dll" $LIBPQBINDIR
for ($i=0; $i -lt $libpqmem.length; ) {
if ($libpqmem[$i] -match "^($msrun_ptn)\d+0.dll") {
$libpqmem[$i]=$Null
} else {
$i++
}
}
if ($libpqmem.length -gt $maxmem) {
throw("number of libpq related dlls exceeds $maxmem")
}
for ($i=$libpqmem.length; $i -lt $maxmem; $i++) {
$libpqmem += ""
}
[string []]$libpqRelArgs=@()
for ($i=0; $i -lt $maxmem; $i++) {
$libpqRelArgs += ("-dLIBPQMEM$i=" + $libpqmem[$i])
}
if (-not(Test-Path -Path $CPUTYPE)) {
New-Item -ItemType directory -Path $CPUTYPE | Out-Null
}
$PRODUCTCODE = [GUID]::NewGuid()
Write-Host "PRODUCTCODE: $PRODUCTCODE"
try {
pushd "$scriptPath"
Write-Host ".`nBuilding psqlODBC/$SUBLOC merge module..."
candle -nologo $libpqRelArgs "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dLIBPQBINDIR=$LIBPQBINDIR" "-dLIBPQMSVCDLL=$LIBPQMSVCDLL" "-dLIBPQMSVCSYS=$LIBPQMSVCSYS" "-dPODBCMSVCDLL=$PODBCMSVCDLL" "-dPODBCMSVPDLL=$PODBCMSVPDLL" "-dPODBCMSVCSYS=$PODBCMSVCSYS" "-dPODBCMSVPSYS=$PODBCMSVPSYS" "-dNoPDB=$NoPDB" -o $CPUTYPE\psqlodbcm.wixobj psqlodbcm_cpu.wxs
if ($LASTEXITCODE -ne 0) {
throw "Failed to build merge module"
}
Write-Host ".`nLinking psqlODBC merge module..."
light -nologo -o $CPUTYPE\psqlodbc_$CPUTYPE.msm $CPUTYPE\psqlodbcm.wixobj
if ($LASTEXITCODE -ne 0) {
throw "Failed to link merge module"
}
Write-Host ".`nBuilding psqlODBC installer database..."
candle -nologo "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dPRODUCTCODE=$PRODUCTCODE" -o $CPUTYPE\psqlodbc.wixobj psqlodbc_cpu.wxs
if ($LASTEXITCODE -ne 0) {
throw "Failed to build installer database"
}
Write-Host ".`nLinking psqlODBC installer database..."
light -nologo -ext WixUIExtension -cultures:en-us -o $CPUTYPE\psqlodbc_$CPUTYPE.msi $CPUTYPE\psqlodbc.wixobj
if ($LASTEXITCODE -ne 0) {
throw "Failed to link installer database"
}
Write-Host ".`nModifying psqlODBC installer database..."
cscript modify_msi.vbs $CPUTYPE\psqlodbc_$CPUTYPE.msi
if ($LASTEXITCODE -ne 0) {
throw "Failed to modify installer database"
}
Write-Host ".`nDone!`n"
}
catch [Exception] {
Write-Host ".`Aborting build!"
throw $error[0]
}
finally {
popd
}
}
$scriptPath = (Split-Path $MyInvocation.MyCommand.Path)
$modulePath="${scriptPath}\..\winbuild"
Import-Module ${modulePath}\Psqlodbc-config.psm1
$defaultConfigDir=$modulePath
$configInfo = LoadConfiguration $BuildConfigPath $defaultConfigDir
if ($AlongWithDrivers) {
try {
pushd "$scriptpath"
$platform = $cpu
if ($cpu -eq "x86") {
$platform = "win32"
}
..\winbuild\BuildAll.ps1 -Platform $platform -BuildConfigPath "$BuildConfigPath"
if ($LASTEXITCODE -ne 0) {
throw "Failed to build binaries"
}
} catch [Exception] {
if ("$_.Exception.Message" -ne "") {
Write-Host ("Error: " + $_.Exception.Message) -ForegroundColor Red
} else {
echo $_.Exception | Format-List -Force
}
Remove-Module Psqlodbc-config
return
} finally {
popd
}
}
Import-Module ${scriptPath}\..\winbuild\MSProgram-Get.psm1
try {
$dumpbinexe = Find-Dumpbin
$wRedist=$false
$VERSION = GetPackageVersion $configInfo "$scriptPath/.."
if ($cpu -eq "both") {
buildInstaller "x86"
buildInstaller "x64"
Write-Host "wRedist=$wRedist"
try {
pushd "$scriptPath"
psqlodbc-setup\buildBootstrapper.ps1 -version $VERSION -withRedist:$wRedist
if ($LASTEXITCODE -ne 0) {
throw "Failed to build bootstrapper"
}
} catch [Exception] {
throw $error[0]
} finally {
popd
}
}
else {
buildInstaller $cpu
}
} catch [Exception] {
if ("$_.Exception.Message" -ne "") {
Write-Host ("Error: " + $_.Exception.Message) -ForegroundColor Red
} else {
echo $_.Exception | Format-List -Force
}
return
} finally {
Remove-Module MSProgram-Get
Remove-Module Psqlodbc-config
}

42
installer/installer.mak Normal file
View File

@ -0,0 +1,42 @@
# All the driver files that will be included in the installer
DRIVER_FILES = ../$(TARGET_CPU)_Unicode_$(CFG)/psqlodbc35w.dll \
../$(TARGET_CPU)_Unicode_$(CFG)/pgxalib.dll \
../$(TARGET_CPU)_Unicode_$(CFG)/pgenlist.dll \
../$(TARGET_CPU)_ANSI_$(CFG)/psqlodbc30a.dll \
../$(TARGET_CPU)_ANSI_$(CFG)/pgxalib.dll \
../$(TARGET_CPU)_ANSI_$(CFG)/pgenlista.dll
ALL: $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi
CANDLE="$(WIX)bin\candle.exe"
LIGHT="$(WIX)bin\light"
!INCLUDE ..\windows-defaults.mak
!IF EXISTS(..\windows-local.mak)
!INCLUDE ..\windows-local.mak
!ENDIF
!MESSAGE determining product code
!INCLUDE productcodes.mak
!MESSAGE Got product code $(PRODUCTCODE)
MSM_OPTS = -dLIBPQBINDIR="$(LIBPQ_BIN)"
# Merge module
$(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm: psqlodbcm_cpu.wxs $(DRIVER_FILES)
echo Building Installer Merge Module
$(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) $(MSM_OPTS) -o $(TARGET_CPU)\psqlodbcm.wixobj psqlodbcm_cpu.wxs
$(LIGHT) -nologo -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbcm.wixobj
$(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi: psqlodbc_cpu.wxs $(DRIVER_FILES)
echo Building Installer
$(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) -dPRODUCTCODE=$(PRODUCTCODE) -o $(TARGET_CPU)\psqlodbc.wixobj psqlodbc_cpu.wxs
$(LIGHT) -nologo -ext WixUIExtension -cultures:en-us -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi $(TARGET_CPU)\psqlodbc.wixobj
cscript modify_msi.vbs $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi
clean:
-rd /Q /S x64 x86

526
installer/lgpl.rtf Normal file
View File

@ -0,0 +1,526 @@
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f23\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}MS Mincho{\*\falt MS ??};}{\f28\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}@MS Mincho;}
{\f35\froman\fcharset238\fprq2 Times New Roman CE;}{\f36\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f38\froman\fcharset161\fprq2 Times New Roman Greek;}{\f39\froman\fcharset162\fprq2 Times New Roman Tur;}
{\f40\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f41\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f42\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f43\fswiss\fcharset238\fprq2 Arial CE;}{\f44\fswiss\fcharset204\fprq2 Arial Cyr;}
{\f46\fswiss\fcharset161\fprq2 Arial Greek;}{\f47\fswiss\fcharset162\fprq2 Arial Tur;}{\f48\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f49\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f50\fswiss\fcharset186\fprq2 Arial Baltic;}
{\f51\fmodern\fcharset238\fprq1 Courier New CE;}{\f52\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f54\fmodern\fcharset161\fprq1 Courier New Greek;}{\f55\fmodern\fcharset162\fprq1 Courier New Tur;}{\f56\fmodern\fcharset177\fprq1 Courier New (Hebrew);}
{\f57\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f58\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f221\fmodern\fcharset0\fprq1 MS Mincho Western{\*\falt MS ??};}{\f219\fmodern\fcharset238\fprq1 MS Mincho CE{\*\falt MS ??};}
{\f220\fmodern\fcharset204\fprq1 MS Mincho Cyr{\*\falt MS ??};}{\f222\fmodern\fcharset161\fprq1 MS Mincho Greek{\*\falt MS ??};}{\f223\fmodern\fcharset162\fprq1 MS Mincho Tur{\*\falt MS ??};}
{\f226\fmodern\fcharset186\fprq1 MS Mincho Baltic{\*\falt MS ??};}{\f261\fmodern\fcharset0\fprq1 @MS Mincho Western;}{\f259\fmodern\fcharset238\fprq1 @MS Mincho CE;}{\f260\fmodern\fcharset204\fprq1 @MS Mincho Cyr;}
{\f262\fmodern\fcharset161\fprq1 @MS Mincho Greek;}{\f263\fmodern\fcharset162\fprq1 @MS Mincho Tur;}{\f266\fmodern\fcharset186\fprq1 @MS Mincho Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;
\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;
\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}{
\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \f2\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \sbasedon0 \snext15 Plain Text;}}{\info{\author Administrator}{\operator Administrator}
{\creatim\yr2001\mo4\dy3\hr19\min37}{\revtim\yr2001\mo4\dy3\hr19\min44}{\version5}{\edmins1}{\nofpages10}{\nofwords3823}{\nofchars21794}{\*\company The Vale Housing Association}{\nofcharsws0}{\vern8269}}\paperw11906\paperh16838\margl1152\margr1152
\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow1\dgvshow1
\jexpand\viewkind4\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd \linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl
{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5
\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang
{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \f2\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {
\fs16\loch\af1\hich\af1\dbch\af23 \tab \tab \hich\af1\dbch\af23\loch\f1 GNU LESSER GENERAL PUBLIC LICENSE
\par \tab \tab \hich\af1\dbch\af23\loch\f1 Version 2.1, February 1999
\par
\par \hich\af1\dbch\af23\loch\f1 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
\par \hich\af1\dbch\af23\loch\f1 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\par \hich\af1\dbch\af23\loch\f1 Everyone is permitted to copy and distribute verbatim copies
\par \hich\af1\dbch\af23\loch\f1 of this license document, but changing it is not allowed.
\par
\par \hich\af1\dbch\af23\loch\f1 [This is the first released version of the Lesser GPL. It also counts
\par \hich\af1\dbch\af23\loch\f1 a\hich\af1\dbch\af23\loch\f1 s the successor of the GNU Library Public License, version 2, hence
\par \hich\af1\dbch\af23\loch\f1 the version number 2.1.]
\par
\par \tab \tab \tab \hich\af1\dbch\af23\loch\f1 Preamble
\par
\par \hich\af1\dbch\af23\loch\f1 The licenses for most software are designed to take away your
\par \hich\af1\dbch\af23\loch\f1 freedom to share and change it. By contrast, the GNU General Public
\par \hich\af1\dbch\af23\loch\f1 Licenses ar\hich\af1\dbch\af23\loch\f1 e intended to guarantee your freedom to share and change
\par \hich\af1\dbch\af23\loch\f1 free software--to make sure the software is free for all its users.
\par
\par \hich\af1\dbch\af23\loch\f1 This license, the Lesser General Public License, applies to some
\par \hich\af1\dbch\af23\loch\f1 specially designated software packages--typically libraries--of\hich\af1\dbch\af23\loch\f1 the
\par \hich\af1\dbch\af23\loch\f1 Free Software Foundation and other authors who decide to use it. You
\par \hich\af1\dbch\af23\loch\f1 can use it too, but we suggest you first think carefully about whether
\par \hich\af1\dbch\af23\loch\f1 this license or the ordinary General Public License is the better
\par \hich\af1\dbch\af23\loch\f1 strategy to use in any particular case, base\hich\af1\dbch\af23\loch\f1 d on the explanations below.
\par
\par \hich\af1\dbch\af23\loch\f1 When we speak of free software, we are referring to freedom of use,
\par \hich\af1\dbch\af23\loch\f1 not price. Our General Public Licenses are designed to make sure that
\par \hich\af1\dbch\af23\loch\f1 you have the freedom to distribute copies of free software (and charge
\par \hich\af1\dbch\af23\loch\f1 for this servi\hich\af1\dbch\af23\loch\f1 ce if you wish); that you receive source code or can get
\par \hich\af1\dbch\af23\loch\f1 it if you want it; that you can change the software and use pieces of
\par \hich\af1\dbch\af23\loch\f1 it in new free programs; and that you are informed that you can do
\par \hich\af1\dbch\af23\loch\f1 these things.
\par
\par \hich\af1\dbch\af23\loch\f1 To protect your rights, we need to make restrictions that forbid
\par \hich\af1\dbch\af23\loch\f1 distributors to deny you these rights or to ask you to surrender these
\par \hich\af1\dbch\af23\loch\f1 rights. These restrictions translate to certain responsibilities for
\par \hich\af1\dbch\af23\loch\f1 you if you distribute copies of the library or i\hich\af1\dbch\af23\loch\f1 f you modify it.
\par
\par \hich\af1\dbch\af23\loch\f1 For example, if you distribute copies of the library, whether gratis
\par \hich\af1\dbch\af23\loch\f1 or for a fee, you must give the recipients all the rights that we gave
\par \hich\af1\dbch\af23\loch\f1 you. You must make sure that they, too, receive or can get the source
\par \hich\af1\dbch\af23\loch\f1 code. If you link other \hich\af1\dbch\af23\loch\f1 code with the library, you must provide
\par \hich\af1\dbch\af23\loch\f1 complete object files to the recipients, so that they can relink them
\par \hich\af1\dbch\af23\loch\f1 with the library after making changes to the library and recompiling
\par \hich\af1\dbch\af23\loch\f1 it. And you must show them these terms so they know their rights.
\par
\par \hich\af1\dbch\af23\loch\f1 We prot\hich\af1\dbch\af23\loch\f1 ect your rights with a two-step method: (1) we copyright the
\par \hich\af1\dbch\af23\loch\f1 library, and (2) we offer you this license, which gives you legal
\par \hich\af1\dbch\af23\loch\f1 permission to copy, distribute and/or modify the library.
\par
\par \hich\af1\dbch\af23\loch\f1 To protect each distributor, we want to make it very clear that
\par \hich\af1\dbch\af23\loch\f1 ther\hich\af1\dbch\af23\loch\f1 e is no warranty for the free library. Also, if the library is
\par \hich\af1\dbch\af23\loch\f1 modified by someone else and passed on, the recipients should know
\par \hich\af1\dbch\af23\loch\f1 that what they have is not the original version, so that the original
\par \hich\af1\dbch\af23\loch\f1 author's reputation will not be affected by problems th\hich\af1\dbch\af23\loch\f1 at might be
\par \hich\af1\dbch\af23\loch\f1 introduced by others.
\par \page
\par \hich\af1\dbch\af23\loch\f1 Finally, software patents pose a constant threat to the existence of
\par \hich\af1\dbch\af23\loch\f1 any free program. We wish to make sure that a company cannot
\par \hich\af1\dbch\af23\loch\f1 effectively restrict the users of a free program by obtaining a
\par \hich\af1\dbch\af23\loch\f1 restrictive licens\hich\af1\dbch\af23\loch\f1 e from a patent holder. Therefore, we insist that
\par \hich\af1\dbch\af23\loch\f1 any patent license obtained for a version of the library must be
\par \hich\af1\dbch\af23\loch\f1 consistent with the full freedom of use specified in this license.
\par
\par \hich\af1\dbch\af23\loch\f1 Most GNU software, including some libraries, is covered by the
\par \hich\af1\dbch\af23\loch\f1 ordinar\hich\af1\dbch\af23\loch\f1 y GNU General Public License. This license, the GNU Lesser
\par \hich\af1\dbch\af23\loch\f1 General Public License, applies to certain designated libraries, and
\par \hich\af1\dbch\af23\loch\f1 is quite different from the ordinary General Public License. We use
\par \hich\af1\dbch\af23\loch\f1 this license for certain libraries in order to permit link\hich\af1\dbch\af23\loch\f1 ing those
\par \hich\af1\dbch\af23\loch\f1 libraries into non-free programs.
\par
\par \hich\af1\dbch\af23\loch\f1 When a program is linked with a library, whether statically or using
\par \hich\af1\dbch\af23\loch\f1 a shared library, the combination of the two is legally speaking a
\par \hich\af1\dbch\af23\loch\f1 combined work, a derivative of the original library. The ordinary
\par \hich\af1\dbch\af23\loch\f1 Genera\hich\af1\dbch\af23\loch\f1 l Public License therefore permits such linking only if the
\par \hich\af1\dbch\af23\loch\f1 entire combination fits its criteria of freedom. The Lesser General
\par \hich\af1\dbch\af23\loch\f1 Public License permits more lax criteria for linking other code with
\par \hich\af1\dbch\af23\loch\f1 the library.
\par
\par \hich\af1\dbch\af23\loch\f1 We call this license the "Lesser" General \hich\af1\dbch\af23\loch\f1 Public License because it
\par \hich\af1\dbch\af23\loch\f1 does Less to protect the user's freedom than the ordinary General
\par \hich\af1\dbch\af23\loch\f1 Public License. It also provides other free software developers Less
\par \hich\af1\dbch\af23\loch\f1 of an advantage over competing non-free programs. These disadvantages
\par \hich\af1\dbch\af23\loch\f1 are the reason we use t\hich\af1\dbch\af23\loch\f1 he ordinary General Public License for many
\par \hich\af1\dbch\af23\loch\f1 libraries. However, the Lesser license provides advantages in certain
\par \hich\af1\dbch\af23\loch\f1 special circumstances.
\par
\par \hich\af1\dbch\af23\loch\f1 For example, on rare occasions, there may be a special need to
\par \hich\af1\dbch\af23\loch\f1 encourage the widest possible use o\hich\af1\dbch\af23\loch\f1 f a certain library, so that it becomes
\par \hich\af1\dbch\af23\loch\f1 a de-facto standard. To achieve this, non-free programs must be
\par \hich\af1\dbch\af23\loch\f1 allowed to use the library. A more frequent case is that a free
\par \hich\af1\dbch\af23\loch\f1 library does the same job as widely used non-free libraries. In this
\par \hich\af1\dbch\af23\loch\f1 case, there is l\hich\af1\dbch\af23\loch\f1 ittle to gain by limiting the free library to free
\par \hich\af1\dbch\af23\loch\f1 software only, so we use the Lesser General Public License.
\par
\par \hich\af1\dbch\af23\loch\f1 In other cases, permission to use a particular library in non-free
\par \hich\af1\dbch\af23\loch\f1 programs enables a greater number of people to use a large body of
\par \hich\af1\dbch\af23\loch\f1 free sof\hich\af1\dbch\af23\loch\f1 tware. For example, permission to use the GNU C Library in
\par \hich\af1\dbch\af23\loch\f1 non-free programs enables many more people to use the whole GNU
\par \hich\af1\dbch\af23\loch\f1 operating system, as well as its variant, the GNU/Linux operating
\par \hich\af1\dbch\af23\loch\f1 system.
\par
\par \hich\af1\dbch\af23\loch\f1 Although the Lesser General Public License is Less prot\hich\af1\dbch\af23\loch\f1 ective of the
\par \hich\af1\dbch\af23\loch\f1 users' freedom, it does ensure that the user of a program that is
\par \hich\af1\dbch\af23\loch\f1 linked with the Library has the freedom and the wherewithal to run
\par \hich\af1\dbch\af23\loch\f1 that program using a modified version of the Library.
\par
\par \hich\af1\dbch\af23\loch\f1 The precise terms and conditions for copying, distri\hich\af1\dbch\af23\loch\f1 bution and
\par \hich\af1\dbch\af23\loch\f1 modification follow. Pay close attention to the difference between a
\par \hich\af1\dbch\af23\loch\f1 "work based on the library" and a "work that uses the library". The
\par \hich\af1\dbch\af23\loch\f1 former contains code derived from the library, whereas the latter must
\par \hich\af1\dbch\af23\loch\f1 be combined with the library in ord\hich\af1\dbch\af23\loch\f1 er to run.
\par \page
\par \tab \tab \hich\af1\dbch\af23\loch\f1 GNU LESSER GENERAL PUBLIC LICENSE
\par \hich\af1\dbch\af23\loch\f1 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
\par
\par \hich\af1\dbch\af23\loch\f1 0. This License Agreement applies to any software library or other
\par \hich\af1\dbch\af23\loch\f1 program which contains a notice placed by the copyright holder or
\par \hich\af1\dbch\af23\loch\f1 other authorized party saying it may be distributed under the terms of
\par \hich\af1\dbch\af23\loch\f1 this Lesser General Public License (also called "this License").
\par \hich\af1\dbch\af23\loch\f1 Each licensee is addressed as "you".
\par
\par \hich\af1\dbch\af23\loch\f1 A "library" means a collection of software functions and/or data
\par \hich\af1\dbch\af23\loch\f1 prepared so as \hich\af1\dbch\af23\loch\f1 to be conveniently linked with application programs
\par \hich\af1\dbch\af23\loch\f1 (which use some of those functions and data) to form executables.
\par
\par \hich\af1\dbch\af23\loch\f1 The "Library", below, refers to any such software library or work
\par \hich\af1\dbch\af23\loch\f1 which has been distributed under these terms. A "work based on the
\par \hich\af1\dbch\af23\loch\f1 L\hich\af1\dbch\af23\loch\f1 ibrary" means either the Library or any derivative work under
\par \hich\af1\dbch\af23\loch\f1 copyright law: that is to say, a work containing the Library or a
\par \hich\af1\dbch\af23\loch\f1 portion of it, either verbatim or with modifications and/or translated
\par \hich\af1\dbch\af23\loch\f1 straightforwardly into another language. (Hereinafter, t\hich\af1\dbch\af23\loch\f1 ranslation is
\par \hich\af1\dbch\af23\loch\f1 included without limitation in the term "modification".)
\par
\par \hich\af1\dbch\af23\loch\f1 "Source code" for a work means the preferred form of the work for
\par \hich\af1\dbch\af23\loch\f1 making modifications to it. For a library, complete source code means
\par \hich\af1\dbch\af23\loch\f1 all the source code for all modules it contai\hich\af1\dbch\af23\loch\f1 ns, plus any associated
\par \hich\af1\dbch\af23\loch\f1 interface definition files, plus the scripts used to control compilation
\par \hich\af1\dbch\af23\loch\f1 and installation of the library.
\par
\par \hich\af1\dbch\af23\loch\f1 Activities other than copying, distribution and modification are not
\par \hich\af1\dbch\af23\loch\f1 covered by this License; they are outside its scope. \hich\af1\dbch\af23\loch\f1 The act of
\par \hich\af1\dbch\af23\loch\f1 running a program using the Library is not restricted, and output from
\par \hich\af1\dbch\af23\loch\f1 such a program is covered only if its contents constitute a work based
\par \hich\af1\dbch\af23\loch\f1 on the Library (independent of the use of the Library in a tool for
\par \hich\af1\dbch\af23\loch\f1 writing it). Whether that is true depends on what the Library does
\par \hich\af1\dbch\af23\loch\f1 and what the program that uses the Library does.
\par \hich\af1\dbch\af23\loch\f1
\par \hich\af1\dbch\af23\loch\f1 1. You may copy and distribute verbatim copies of the Library's
\par \hich\af1\dbch\af23\loch\f1 complete source code as you receive it, in any medium, provided that
\par \hich\af1\dbch\af23\loch\f1 y\hich\af1\dbch\af23\loch\f1 ou conspicuously and appropriately publish on each copy an
\par \hich\af1\dbch\af23\loch\f1 appropriate copyright notice and disclaimer of warranty; keep intact
\par \hich\af1\dbch\af23\loch\f1 all the notices that refer to this License and to the absence of any
\par \hich\af1\dbch\af23\loch\f1 warranty; and distribute a copy of this License along with \hich\af1\dbch\af23\loch\f1 the
\par \hich\af1\dbch\af23\loch\f1 Library.
\par
\par \hich\af1\dbch\af23\loch\f1 You may charge a fee for the physical act of transferring a copy,
\par \hich\af1\dbch\af23\loch\f1 and you may at your option offer warranty protection in exchange for a
\par \hich\af1\dbch\af23\loch\f1 fee.
\par \page
\par \hich\af1\dbch\af23\loch\f1 2. You may modify your copy or copies of the Library or any portion
\par \hich\af1\dbch\af23\loch\f1 of it, thus forming a work\hich\af1\dbch\af23\loch\f1 based on the Library, and copy and
\par \hich\af1\dbch\af23\loch\f1 distribute such modifications or work under the terms of Section 1
\par \hich\af1\dbch\af23\loch\f1 above, provided that you also meet all of these conditions:
\par
\par \hich\af1\dbch\af23\loch\f1 a) The modified work must itself be a software library.
\par
\par \hich\af1\dbch\af23\loch\f1 b) You must cause the files\hich\af1\dbch\af23\loch\f1 modified to carry prominent notices
\par \hich\af1\dbch\af23\loch\f1 stating that you changed the files and the date of any change.
\par
\par \hich\af1\dbch\af23\loch\f1 c) You must cause the whole of the work to be licensed at no
\par \hich\af1\dbch\af23\loch\f1 charge to all third parties under the terms of this License.
\par
\par \hich\af1\dbch\af23\loch\f1 d) If a facility\hich\af1\dbch\af23\loch\f1 in the modified Library refers to a function or a
\par \hich\af1\dbch\af23\loch\f1 table of data to be supplied by an application program that uses
\par \hich\af1\dbch\af23\loch\f1 the facility, other than as an argument passed when the facility
\par \hich\af1\dbch\af23\loch\f1 is invoked, then you must make a good faith effort to ensure that,
\par \hich\af1\dbch\af23\loch\f1 in the event an application does not supply such function or
\par \hich\af1\dbch\af23\loch\f1 table, the facility still operates, and performs whatever part of
\par \hich\af1\dbch\af23\loch\f1 its purpose remains meaningful.
\par
\par \hich\af1\dbch\af23\loch\f1 (For exam\hich\af1\dbch\af23\loch\f1 ple, a function in a library to compute square roots has
\par \hich\af1\dbch\af23\loch\f1 a purpose that is entirely well-defined independent of the
\par \hich\af1\dbch\af23\loch\f1 application. Therefore, Subsection 2d requires that any
\par \hich\af1\dbch\af23\loch\f1 application-supplied function or table used by this function must
\par \hich\af1\dbch\af23\loch\f1 b\hich\af1\dbch\af23\loch\f1 e optional: if the application does not supply it, the square
\par \hich\af1\dbch\af23\loch\f1 root function must still compute square roots.)
\par
\par \hich\af1\dbch\af23\loch\f1 These requirements apply to the modified work as a whole. If
\par \hich\af1\dbch\af23\loch\f1 identifiable sections of that work are not derived from the Library,
\par \hich\af1\dbch\af23\loch\f1 and can be\hich\af1\dbch\af23\loch\f1 reasonably considered independent and separate works in
\par \hich\af1\dbch\af23\loch\f1 themselves, then this License, and its terms, do not apply to those
\par \hich\af1\dbch\af23\loch\f1 sections when you distribute them as separate works. But when you
\par \hich\af1\dbch\af23\loch\f1 distribute the same sections as part of a whole which is a work \hich\af1\dbch\af23\loch\f1 based
\par \hich\af1\dbch\af23\loch\f1 on the Library, the distribution of the whole must be on the terms of
\par \hich\af1\dbch\af23\loch\f1 this License, whose permissions for other licensees extend to the
\par \hich\af1\dbch\af23\loch\f1 entire whole, and thus to each and every part regardless of who wrote
\par \hich\af1\dbch\af23\loch\f1 it.
\par
\par \hich\af1\dbch\af23\loch\f1 Thus, it is not the intent of this sect\hich\af1\dbch\af23\loch\f1 ion to claim rights or contest
\par \hich\af1\dbch\af23\loch\f1 your rights to work written entirely by you; rather, the intent is to
\par \hich\af1\dbch\af23\loch\f1 exercise the right to control the distribution of derivative or
\par \hich\af1\dbch\af23\loch\f1 collective works based on the Library.
\par
\par \hich\af1\dbch\af23\loch\f1 In addition, mere aggregation of another work not based on the Library
\par \hich\af1\dbch\af23\loch\f1 with the Library (or with a work based on the Library) on a volume of
\par \hich\af1\dbch\af23\loch\f1 a storage or distribution medium does not bring the other work under
\par \hich\af1\dbch\af23\loch\f1 the scope of this License.
\par
\par \hich\af1\dbch\af23\loch\f1 3. You may opt t\hich\af1\dbch\af23\loch\f1 o apply the terms of the ordinary GNU General Public
\par \hich\af1\dbch\af23\loch\f1 License instead of this License to a given copy of the Library. To do
\par \hich\af1\dbch\af23\loch\f1 this, you must alter all the notices that refer to this License, so
\par \hich\af1\dbch\af23\loch\f1 that they refer to the ordinary GNU General Public License, vers\hich\af1\dbch\af23\loch\f1 ion 2,
\par \hich\af1\dbch\af23\loch\f1 instead of to this License. (If a newer version than version 2 of the
\par \hich\af1\dbch\af23\loch\f1 ordinary GNU General Public License has appeared, then you can specify
\par \hich\af1\dbch\af23\loch\f1 that version instead if you wish.) Do not make any other change in
\par \hich\af1\dbch\af23\loch\f1 these notices.
\par \page
\par \hich\af1\dbch\af23\loch\f1 Once this change is \hich\af1\dbch\af23\loch\f1 made in a given copy, it is irreversible for
\par \hich\af1\dbch\af23\loch\f1 that copy, so the ordinary GNU General Public License applies to all
\par \hich\af1\dbch\af23\loch\f1 subsequent copies and derivative works made from that copy.
\par
\par \hich\af1\dbch\af23\loch\f1 This option is useful when you wish to copy part of the code of
\par \hich\af1\dbch\af23\loch\f1 the Library int\hich\af1\dbch\af23\loch\f1 o a program that is not a library.
\par
\par \hich\af1\dbch\af23\loch\f1 4. You may copy and distribute the Library (or a portion or
\par \hich\af1\dbch\af23\loch\f1 derivative of it, under Section 2) in object code or executable form
\par \hich\af1\dbch\af23\loch\f1 under the terms of Sections 1 and 2 above provided that you accompany
\par \hich\af1\dbch\af23\loch\f1 it with the complet\hich\af1\dbch\af23\loch\f1 e corresponding machine-readable source code, which
\par \hich\af1\dbch\af23\loch\f1 must be distributed under the terms of Sections 1 and 2 above on a
\par \hich\af1\dbch\af23\loch\f1 medium customarily used for software interchange.
\par
\par \hich\af1\dbch\af23\loch\f1 If distribution of object code is made by offering access to copy
\par \hich\af1\dbch\af23\loch\f1 from a designated place, then offering equivalent access to copy the
\par \hich\af1\dbch\af23\loch\f1 source code from the same place satisfies the requirement to
\par \hich\af1\dbch\af23\loch\f1 distribute the source code, even though third parties are not
\par \hich\af1\dbch\af23\loch\f1 compelled to copy the source along with the object code.
\par
\par \hich\af1\dbch\af23\loch\f1 5. A\hich\af1\dbch\af23\loch\f1 program that contains no derivative of any portion of the
\par \hich\af1\dbch\af23\loch\f1 Library, but is designed to work with the Library by being compiled or
\par \hich\af1\dbch\af23\loch\f1 linked with it, is called a "work that uses the Library". Such a
\par \hich\af1\dbch\af23\loch\f1 work, in isolation, is not a derivative work of the Library,\hich\af1\dbch\af23\loch\f1 and
\par \hich\af1\dbch\af23\loch\f1 therefore falls outside the scope of this License.
\par
\par \hich\af1\dbch\af23\loch\f1 However, linking a "work that uses the Library" with the Library
\par \hich\af1\dbch\af23\loch\f1 creates an executable that is a derivative of the Library (because it
\par \hich\af1\dbch\af23\loch\f1 contains portions of the Library), rather than a "work that us\hich\af1\dbch\af23\loch\f1 es the
\par \hich\af1\dbch\af23\loch\f1 library". The executable is therefore covered by this License.
\par \hich\af1\dbch\af23\loch\f1 Section 6 states terms for distribution of such executables.
\par
\par \hich\af1\dbch\af23\loch\f1 When a "work that uses the Library" uses material from a header file
\par \hich\af1\dbch\af23\loch\f1 that is part of the Library, the object code for the\hich\af1\dbch\af23\loch\f1 work may be a
\par \hich\af1\dbch\af23\loch\f1 derivative work of the Library even though the source code is not.
\par \hich\af1\dbch\af23\loch\f1 Whether this is true is especially significant if the work can be
\par \hich\af1\dbch\af23\loch\f1 linked without the Library, or if the work is itself a library. The
\par \hich\af1\dbch\af23\loch\f1 threshold for this to be true is not pr\hich\af1\dbch\af23\loch\f1 ecisely defined by law.
\par
\par \hich\af1\dbch\af23\loch\f1 If such an object file uses only numerical parameters, data
\par \hich\af1\dbch\af23\loch\f1 structure layouts and accessors, and small macros and small inline
\par \hich\af1\dbch\af23\loch\f1 functions (ten lines or less in length), then the use of the object
\par \hich\af1\dbch\af23\loch\f1 file is unrestricted, regardless o\hich\af1\dbch\af23\loch\f1 f whether it is legally a derivative
\par \hich\af1\dbch\af23\loch\f1 work. (Executables containing this object code plus portions of the
\par \hich\af1\dbch\af23\loch\f1 Library will still fall under Section 6.)
\par
\par \hich\af1\dbch\af23\loch\f1 Otherwise, if the work is a derivative of the Library, you may
\par \hich\af1\dbch\af23\loch\f1 distribute \hich\af1\dbch\af23\loch\f1 the object code for the work under the terms of Section 6.
\par \hich\af1\dbch\af23\loch\f1 Any executables containing that work also fall under Section 6,
\par \hich\af1\dbch\af23\loch\f1 whether or not they are linked directly with the Library itself.
\par \page
\par \hich\af1\dbch\af23\loch\f1 6. As an exception to the Sections above, you may also combine o\hich\af1\dbch\af23\loch\f1 r
\par \hich\af1\dbch\af23\loch\f1 link a "work that uses the Library" with the Library to produce a
\par \hich\af1\dbch\af23\loch\f1 work containing portions of the Library, and distribute that work
\par \hich\af1\dbch\af23\loch\f1 under terms of your choice, provided that the terms permit
\par \hich\af1\dbch\af23\loch\f1 modification of the work for the customer's own use and reverse
\par \hich\af1\dbch\af23\loch\f1 engineering for debugging such modifications.
\par
\par \hich\af1\dbch\af23\loch\f1 You must give prominent notice with each copy of the work that the
\par \hich\af1\dbch\af23\loch\f1 Library is used in it and that the Library and its use are covered by
\par \hich\af1\dbch\af23\loch\f1 this License. You must supply a copy of this License. If the work
\par \hich\af1\dbch\af23\loch\f1 d\hich\af1\dbch\af23\loch\f1 uring execution displays copyright notices, you must include the
\par \hich\af1\dbch\af23\loch\f1 copyright notice for the Library among them, as well as a reference
\par \hich\af1\dbch\af23\loch\f1 directing the user to the copy of this License. Also, you must do one
\par \hich\af1\dbch\af23\loch\f1 of these things:
\par
\par \hich\af1\dbch\af23\loch\f1 a) Accompany the work with the\hich\af1\dbch\af23\loch\f1 complete corresponding
\par \hich\af1\dbch\af23\loch\f1 machine-readable source code for the Library including whatever
\par \hich\af1\dbch\af23\loch\f1 changes were used in the work (which must be distributed under
\par \hich\af1\dbch\af23\loch\f1 Sections 1 and 2 above); and, if the work is an executable linked
\par \hich\af1\dbch\af23\loch\f1 with the Library, with \hich\af1\dbch\af23\loch\f1 the complete machine-readable "work that
\par \hich\af1\dbch\af23\loch\f1 uses the Library", as object code and/or source code, so that the
\par \hich\af1\dbch\af23\loch\f1 user can modify the Library and then relink to produce a modified
\par \hich\af1\dbch\af23\loch\f1 executable containing the modified Library. (It is understood
\par \hich\af1\dbch\af23\loch\f1 that the user who changes the contents of definitions files in the
\par \hich\af1\dbch\af23\loch\f1 Library will not necessarily be able to recompile the application
\par \hich\af1\dbch\af23\loch\f1 to use the modified definitions.)
\par
\par \hich\af1\dbch\af23\loch\f1 b) Use a suitable shared library mechanism for linking with the
\par \hich\af1\dbch\af23\loch\f1 Libr\hich\af1\dbch\af23\loch\f1 ary. A suitable mechanism is one that (1) uses at run time a
\par \hich\af1\dbch\af23\loch\f1 copy of the library already present on the user's computer system,
\par \hich\af1\dbch\af23\loch\f1 rather than copying library functions into the executable, and (2)
\par \hich\af1\dbch\af23\loch\f1 will operate properly with a modified version of\hich\af1\dbch\af23\loch\f1 the library, if
\par \hich\af1\dbch\af23\loch\f1 the user installs one, as long as the modified version is
\par \hich\af1\dbch\af23\loch\f1 interface-compatible with the version that the work was made with.
\par
\par \hich\af1\dbch\af23\loch\f1 c) Accompany the work with a written offer, valid for at
\par \hich\af1\dbch\af23\loch\f1 least three years, to give the same user\hich\af1\dbch\af23\loch\f1 the materials
\par \hich\af1\dbch\af23\loch\f1 specified in Subsection 6a, above, for a charge no more
\par \hich\af1\dbch\af23\loch\f1 than the cost of performing this distribution.
\par
\par \hich\af1\dbch\af23\loch\f1 d) If distribution of the work is made by offering access to copy
\par \hich\af1\dbch\af23\loch\f1 from a designated place, offer equivalent access to cop\hich\af1\dbch\af23\loch\f1 y the above
\par \hich\af1\dbch\af23\loch\f1 specified materials from the same place.
\par
\par \hich\af1\dbch\af23\loch\f1 e) Verify that the user has already received a copy of these
\par \hich\af1\dbch\af23\loch\f1 materials or that you have already sent this user a copy.
\par
\par \hich\af1\dbch\af23\loch\f1 For an executable, the required form of the "work that uses the
\par \hich\af1\dbch\af23\loch\f1 Libr\hich\af1\dbch\af23\loch\f1 ary" must include any data and utility programs needed for
\par \hich\af1\dbch\af23\loch\f1 reproducing the executable from it. However, as a special exception,
\par \hich\af1\dbch\af23\loch\f1 the materials to be distributed need not include anything that is
\par \hich\af1\dbch\af23\loch\f1 normally distributed (in either source or binary form) with the major
\par \hich\af1\dbch\af23\loch\f1 components (compiler, kernel, and so on) of the operating system on
\par \hich\af1\dbch\af23\loch\f1 which the executable runs, unless that component itself accompanies
\par \hich\af1\dbch\af23\loch\f1 the executable.
\par
\par \hich\af1\dbch\af23\loch\f1 It may happen that this require\hich\af1\dbch\af23\loch\f1 ment contradicts the license
\par \hich\af1\dbch\af23\loch\f1 restrictions of other proprietary libraries that do not normally
\par \hich\af1\dbch\af23\loch\f1 accompany the operating system. Such a contradiction means you cannot
\par \hich\af1\dbch\af23\loch\f1 use both them and the Library together in an executable that you
\par \hich\af1\dbch\af23\loch\f1 distribute.
\par \page
\par \hich\af1\dbch\af23\loch\f1 7. You may\hich\af1\dbch\af23\loch\f1 place library facilities that are a work based on the
\par \hich\af1\dbch\af23\loch\f1 Library side-by-side in a single library together with other library
\par \hich\af1\dbch\af23\loch\f1 facilities not covered by this License, and distribute such a combined
\par \hich\af1\dbch\af23\loch\f1 library, provided that the separate distribution of the work \hich\af1\dbch\af23\loch\f1 based on
\par \hich\af1\dbch\af23\loch\f1 the Library and of the other library facilities is otherwise
\par \hich\af1\dbch\af23\loch\f1 permitted, and provided that you do these two things:
\par
\par \hich\af1\dbch\af23\loch\f1 a) Accompany the combined library with a copy of the same work
\par \hich\af1\dbch\af23\loch\f1 based on the Library, uncombined with any other library
\par \hich\af1\dbch\af23\loch\f1 \hich\af1\dbch\af23\loch\f1 facilities. This must be distributed under the terms of the
\par \hich\af1\dbch\af23\loch\f1 Sections above.
\par
\par \hich\af1\dbch\af23\loch\f1 b) Give prominent notice with the combined library of the fact
\par \hich\af1\dbch\af23\loch\f1 that part of it is a work based on the Library, and explaining
\par \hich\af1\dbch\af23\loch\f1 where to find the accompanying uncom\hich\af1\dbch\af23\loch\f1 bined form of the same work.
\par
\par \hich\af1\dbch\af23\loch\f1 8. You may not copy, modify, sublicense, link with, or distribute
\par \hich\af1\dbch\af23\loch\f1 the Library except as expressly provided under this License. Any
\par \hich\af1\dbch\af23\loch\f1 attempt otherwise to copy, modify, sublicense, link with, or
\par \hich\af1\dbch\af23\loch\f1 distribute the Library is void, and will automatically terminate your
\par \hich\af1\dbch\af23\loch\f1 rights under this License. However, parties who have received copies,
\par \hich\af1\dbch\af23\loch\f1 or rights, from you under this License will not have their licenses
\par \hich\af1\dbch\af23\loch\f1 terminated so long as such parties remain in fu\hich\af1\dbch\af23\loch\f1 ll compliance.
\par
\par \hich\af1\dbch\af23\loch\f1 9. You are not required to accept this License, since you have not
\par \hich\af1\dbch\af23\loch\f1 signed it. However, nothing else grants you permission to modify or
\par \hich\af1\dbch\af23\loch\f1 distribute the Library or its derivative works. These actions are
\par \hich\af1\dbch\af23\loch\f1 prohibited by law if you do not acc\hich\af1\dbch\af23\loch\f1 ept this License. Therefore, by
\par \hich\af1\dbch\af23\loch\f1 modifying or distributing the Library (or any work based on the
\par \hich\af1\dbch\af23\loch\f1 Library), you indicate your acceptance of this License to do so, and
\par \hich\af1\dbch\af23\loch\f1 all its terms and conditions for copying, distributing or modifying
\par \hich\af1\dbch\af23\loch\f1 the Library or works b\hich\af1\dbch\af23\loch\f1 ased on it.
\par
\par \hich\af1\dbch\af23\loch\f1 10. Each time you redistribute the Library (or any work based on the
\par \hich\af1\dbch\af23\loch\f1 Library), the recipient automatically receives a license from the
\par \hich\af1\dbch\af23\loch\f1 original licensor to copy, distribute, link with or modify the Library
\par \hich\af1\dbch\af23\loch\f1 subject to these terms and conditio\hich\af1\dbch\af23\loch\f1 ns. You may not impose any further
\par \hich\af1\dbch\af23\loch\f1 restrictions on the recipients' exercise of the rights granted herein.
\par \hich\af1\dbch\af23\loch\f1 You are not responsible for enforcing compliance by third parties with
\par \hich\af1\dbch\af23\loch\f1 this License.
\par \page
\par \hich\af1\dbch\af23\loch\f1 11. If, as a consequence of a court judgment or allegation o\hich\af1\dbch\af23\loch\f1 f patent
\par \hich\af1\dbch\af23\loch\f1 infringement or for any other reason (not limited to patent issues),
\par \hich\af1\dbch\af23\loch\f1 conditions are imposed on you (whether by court order, agreement or
\par \hich\af1\dbch\af23\loch\f1 otherwise) that contradict the conditions of this License, they do not
\par \hich\af1\dbch\af23\loch\f1 excuse you from the conditions of this \hich\af1\dbch\af23\loch\f1 License. If you cannot
\par \hich\af1\dbch\af23\loch\f1 distribute so as to satisfy simultaneously your obligations under this
\par \hich\af1\dbch\af23\loch\f1 License and any other pertinent obligations, then as a consequence you
\par \hich\af1\dbch\af23\loch\f1 may not distribute the Library at all. For example, if a patent
\par \hich\af1\dbch\af23\loch\f1 license would not permit royalty-free redistribution of the Library by
\par \hich\af1\dbch\af23\loch\f1 all those who receive copies directly or indirectly through you, then
\par \hich\af1\dbch\af23\loch\f1 the only way you could satisfy both it and this License would be to
\par \hich\af1\dbch\af23\loch\f1 refrain entirely from distribution of the Libra\hich\af1\dbch\af23\loch\f1 ry.
\par
\par \hich\af1\dbch\af23\loch\f1 If any portion of this section is held invalid or unenforceable under any
\par \hich\af1\dbch\af23\loch\f1 particular circumstance, the balance of the section is intended to apply,
\par \hich\af1\dbch\af23\loch\f1 and the section as a whole is intended to apply in other circumstances.
\par
\par \hich\af1\dbch\af23\loch\f1 It is not the purpose of this \hich\af1\dbch\af23\loch\f1 section to induce you to infringe any
\par \hich\af1\dbch\af23\loch\f1 patents or other property right claims or to contest validity of any
\par \hich\af1\dbch\af23\loch\f1 such claims; this section has the sole purpose of protecting the
\par \hich\af1\dbch\af23\loch\f1 integrity of the free software distribution system which is
\par \hich\af1\dbch\af23\loch\f1 implemented by public li\hich\af1\dbch\af23\loch\f1 cense practices. Many people have made
\par \hich\af1\dbch\af23\loch\f1 generous contributions to the wide range of software distributed
\par \hich\af1\dbch\af23\loch\f1 through that system in reliance on consistent application of that
\par \hich\af1\dbch\af23\loch\f1 system; it is up to the author/donor to decide if he or she is willing
\par \hich\af1\dbch\af23\loch\f1 to distribute \hich\af1\dbch\af23\loch\f1 software through any other system and a licensee cannot
\par \hich\af1\dbch\af23\loch\f1 impose that choice.
\par
\par \hich\af1\dbch\af23\loch\f1 This section is intended to make thoroughly clear what is believed to
\par \hich\af1\dbch\af23\loch\f1 be a consequence of the rest of this License.
\par
\par \hich\af1\dbch\af23\loch\f1 12. If the distribution and/or use of the Library is restric\hich\af1\dbch\af23\loch\f1 ted in
\par \hich\af1\dbch\af23\loch\f1 certain countries either by patents or by copyrighted interfaces, the
\par \hich\af1\dbch\af23\loch\f1 original copyright holder who places the Library under this License may add
\par \hich\af1\dbch\af23\loch\f1 an explicit geographical distribution limitation excluding those countries,
\par \hich\af1\dbch\af23\loch\f1 so that distribution is permitted only in or among countries not thus
\par \hich\af1\dbch\af23\loch\f1 excluded. In such case, this License incorporates the limitation as if
\par \hich\af1\dbch\af23\loch\f1 written in the body of this License.
\par
\par \hich\af1\dbch\af23\loch\f1 13. The Free Software Foundation may publish revised and/or new
\par \hich\af1\dbch\af23\loch\f1 versions o\hich\af1\dbch\af23\loch\f1 f the Lesser General Public License from time to time.
\par \hich\af1\dbch\af23\loch\f1 Such new versions will be similar in spirit to the present version,
\par \hich\af1\dbch\af23\loch\f1 but may differ in detail to address new problems or concerns.
\par
\par \hich\af1\dbch\af23\loch\f1 Each version is given a distinguishing version number. If the Library
\par \hich\af1\dbch\af23\loch\f1 specifies a version number of this License which applies to it and
\par \hich\af1\dbch\af23\loch\f1 "any later version", you have the option of following the terms and
\par \hich\af1\dbch\af23\loch\f1 conditions either of that version or of any later version published by
\par \hich\af1\dbch\af23\loch\f1 the Free Software Foundation. If the Library doe\hich\af1\dbch\af23\loch\f1 s not specify a
\par \hich\af1\dbch\af23\loch\f1 license version number, you may choose any version ever published by
\par \hich\af1\dbch\af23\loch\f1 the Free Software Foundation.
\par \page
\par \hich\af1\dbch\af23\loch\f1 14. If you wish to incorporate parts of the Library into other free
\par \hich\af1\dbch\af23\loch\f1 programs whose distribution conditions are incompatible with these,
\par \hich\af1\dbch\af23\loch\f1 w\hich\af1\dbch\af23\loch\f1 rite to the author to ask for permission. For software which is
\par \hich\af1\dbch\af23\loch\f1 copyrighted by the Free Software Foundation, write to the Free
\par \hich\af1\dbch\af23\loch\f1 Software Foundation; we sometimes make exceptions for this. Our
\par \hich\af1\dbch\af23\loch\f1 decision will be guided by the two goals of preserving the free\hich\af1\dbch\af23\loch\f1 status
\par \hich\af1\dbch\af23\loch\f1 of all derivatives of our free software and of promoting the sharing
\par \hich\af1\dbch\af23\loch\f1 and reuse of software generally.
\par
\par \tab \tab \tab \hich\af1\dbch\af23\loch\f1 NO WARRANTY
\par
\par \hich\af1\dbch\af23\loch\f1 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
\par \hich\af1\dbch\af23\loch\f1 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
\par \hich\af1\dbch\af23\loch\f1 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
\par \hich\af1\dbch\af23\loch\f1 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
\par \hich\af1\dbch\af23\loch\f1 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NO\hich\af1\dbch\af23\loch\f1 T LIMITED TO, THE
\par \hich\af1\dbch\af23\loch\f1 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\par \hich\af1\dbch\af23\loch\f1 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
\par \hich\af1\dbch\af23\loch\f1 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
\par \hich\af1\dbch\af23\loch\f1 THE COST OF ALL NECESSARY SERVICING\hich\af1\dbch\af23\loch\f1 , REPAIR OR CORRECTION.
\par
\par \hich\af1\dbch\af23\loch\f1 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
\par \hich\af1\dbch\af23\loch\f1 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
\par \hich\af1\dbch\af23\loch\f1 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
\par \hich\af1\dbch\af23\loch\f1 FOR DAMAGES, INCLUDING AN\hich\af1\dbch\af23\loch\f1 Y GENERAL, SPECIAL, INCIDENTAL OR
\par \hich\af1\dbch\af23\loch\f1 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
\par \hich\af1\dbch\af23\loch\f1 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
\par \hich\af1\dbch\af23\loch\f1 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
\par \hich\af1\dbch\af23\loch\f1 FAILURE OF THE LIBR\hich\af1\dbch\af23\loch\f1 ARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
\par \hich\af1\dbch\af23\loch\f1 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
\par \hich\af1\dbch\af23\loch\f1 DAMAGES.
\par
\par \tab \tab \hich\af1\dbch\af23\loch\f1 END OF TERMS AND CONDITIONS
\par \page
\par \hich\af1\dbch\af23\loch\f1 How to Apply These Terms to Your New Libraries
\par
\par \hich\af1\dbch\af23\loch\f1 If you develop a new library\hich\af1\dbch\af23\loch\f1 , and you want it to be of the greatest
\par \hich\af1\dbch\af23\loch\f1 possible use to the public, we recommend making it free software that
\par \hich\af1\dbch\af23\loch\f1 everyone can redistribute and change. You can do so by permitting
\par \hich\af1\dbch\af23\loch\f1 redistribution under these terms (or, alternatively, under the terms of the
\par \hich\af1\dbch\af23\loch\f1 ordinary General Public License).
\par
\par \hich\af1\dbch\af23\loch\f1 To apply these terms, attach the following notices to the library. It is
\par \hich\af1\dbch\af23\loch\f1 safest to attach them to the start of each source file to most effectively
\par \hich\af1\dbch\af23\loch\f1 convey the exclusion of warranty; and each file should have at least t\hich\af1\dbch\af23\loch\f1 he
\par \hich\af1\dbch\af23\loch\f1 "copyright" line and a pointer to where the full notice is found.
\par
\par \hich\af1\dbch\af23\loch\f1 <one line to give the library's name and a brief idea of what it does.>
\par \hich\af1\dbch\af23\loch\f1 Copyright (C) <year> <name of author>
\par
\par \hich\af1\dbch\af23\loch\f1 This library is free software; you can redistribute it and/or
\par \hich\af1\dbch\af23\loch\f1 modify it under the terms of the GNU Lesser General Public
\par \hich\af1\dbch\af23\loch\f1 License as published by the Free Software Foundation; either
\par \hich\af1\dbch\af23\loch\f1 version 2.1 of the License, or (at your option) any later version.
\par
\par \hich\af1\dbch\af23\loch\f1 This library is distributed in the hope that it will\hich\af1\dbch\af23\loch\f1 be useful,
\par \hich\af1\dbch\af23\loch\f1 but WITHOUT ANY WARRANTY; without even the implied warranty of
\par \hich\af1\dbch\af23\loch\f1 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\par \hich\af1\dbch\af23\loch\f1 Lesser General Public License for more details.
\par
\par \hich\af1\dbch\af23\loch\f1 You should have received a copy of the GNU Lesser \hich\af1\dbch\af23\loch\f1 General Public
\par \hich\af1\dbch\af23\loch\f1 License along with this library; if not, write to the Free Software
\par \hich\af1\dbch\af23\loch\f1 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\par
\par \hich\af1\dbch\af23\loch\f1 Also add information on how to contact you by electronic and paper mail.
\par
\par \hich\af1\dbch\af23\loch\f1 You should also \hich\af1\dbch\af23\loch\f1 get your employer (if you work as a programmer) or your
\par \hich\af1\dbch\af23\loch\f1 school, if any, to sign a "copyright disclaimer" for the library, if
\par \hich\af1\dbch\af23\loch\f1 necessary. Here is a sample; alter the names:
\par
\par \hich\af1\dbch\af23\loch\f1 Yoyodyne, Inc., hereby disclaims all copyright interest in the
\par \hich\af1\dbch\af23\loch\f1 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
\par
\par \hich\af1\dbch\af23\loch\f1 <signature of Ty Coon>, 1 April 1990
\par \hich\af1\dbch\af23\loch\f1 Ty Coon, President of Vice
\par
\par \hich\af1\dbch\af23\loch\f1 That's all there is to it!
\par
\par
\par
\par
\par }}

50
installer/make.bat Normal file
View File

@ -0,0 +1,50 @@
@echo off
set wix_dir="%WIX%bin"
echo wix_dir=%wix_dir%
REM Values to change include VERSION and SUBLOC, both below.
REM The subdirectory to install into
SET SUBLOC="0901"
if NOT "%1"=="" SET VERSION="%1"
if NOT "%1"=="" GOTO GOT_VERSION
REM The full version number of the build in XXXX.XX.XX format
SET VERSION="09.01.0200"
echo.
echo Version not specified - defaulting to %VERSION%
echo.
:GOT_VERSION
echo.
echo Building psqlODBC merge module...
%wix_dir%\candle.exe -nologo -dVERSION=%VERSION% -dSUBLOC=%SUBLOC% -dPROGRAMFILES="%ProgramFiles%" -dSYSTEM32DIR="%SystemRoot%/system32" psqlodbcm.wxs
IF ERRORLEVEL 1 GOTO ERR_HANDLER
%wix_dir%\light -nologo -out psqlodbc.msm psqlodbcm.wixobj
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo.
echo Building psqlODBC installer database...
%wix_dir%\candle.exe -nologo -dVERSION=%VERSION% -dSUBLOC=%SUBLOC% -dPROGRAMFILES="%ProgramFiles%" -dPROGRAMCOM="%ProgramFiles%/Common Files/Merge Modules" psqlodbc.wxs
IF ERRORLEVEL 1 GOTO ERR_HANDLER
%wix_dir%\light -nologo -ext WixUIExtension -cultures:en-us psqlodbc.wixobj
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo.
echo Done!
GOTO EXIT
:ERR_HANDLER
echo.
echo Aborting build!
GOTO EXIT
:EXIT

133
installer/makex64.bat Normal file
View File

@ -0,0 +1,133 @@
@echo off
setlocal
rem
rem The 64bit installer
rem
set CPUTYPE=x64
rem
rem Set yes when clean operations are needed
rem
set CLEANUP=no
rem
rem Set yes so as to build dlls before making the installer
rem
set DLLBUILD=no
:getparam
set para=%1
echo para="%para%"
if /i "%para:~1%" == "Drivers" (
if "%para:~0,1%" == "+" set DLLBUILD=yes
shift
goto getparam
) else if /i "%para%" == "clean" (
set CLEANUP=yes
shift
goto getparam
)
if "%CLEANUP%" == "yes" GOTO CLEAN
rem
rem psqlodbc dlls build options
rem
SET USE_LIBPQ=no
SET USE_GSS=yes
SET USE_SSPI=yes
rem
rem Please specify the foler name where you placed libpq related dlls.
rem Currently not used.
rem
rem SET LIBPQBINDIR=
echo LIBPQBINDIR=%LIBPQBINDIR%
rem
rem Please specify the foler name where you placed GSSAPI related dlls.
rem
SET GSSBINDIR="c:/cygwin/develop/bin/AMD64"
rem
rem Build binaries if necessary
rem
set origdir=%CD%
if "%DLLBUILD%" == "yes" (
cd ..
nmake /f win64.mak USE_LIBPQ=%USE_LIBPQ% USE_SSPI=%USE_SSPI% USE_GSS=%USE_GSS%
nmake /f win64.mak ANSI_VERSION=yes USE_LIBPQ=%USE_LIBPQ% USE_SSPI=%USE_SSPI% USE_GSS=%USE_GSS%
)
cd %origdir%
set wix_dir="%WIX%bin"
echo wix_dir=%wix_dir%
rem Values to change include VERSION and SUBLOC, both below.
rem The subdirectory to install into
SET SUBLOC="0901"
if NOT "%1"=="" SET VERSION="%1"
if NOT "%1"=="" GOTO GOT_VERSION
GOTO NORMAL_EXEC
:CLEAN
echo.
echo cleaning derived files
echo.
del %CPUTYPE%\psqlodbc*.wix* %CPUTYPE%\psqlodbc*.ms*
if "%DLLBUILD%" == "yes" (
cd ..
nmake /f win64.mak clean
nmake /f win64.mak ANSI_VERSION=yes clean
)
GOTO EXIT
:NORMAL_EXEC
REM The full version number of the build in XXXX.XX.XX format
SET VERSION="09.01.0200"
echo.
echo Version not specified - defaulting to %VERSION%
echo.
:GOT_VERSION
if not exist %CPUTYPE%\ mkdir %CPUTYPE%
echo.
echo Building psqlODBC merge module...
%wix_dir%\candle.exe -nologo -dPlatform="%CPUTYPE%" -dVERSION=%VERSION% -dSUBLOC=%SUBLOC% -dLIBPQBINDIR=%LIBPQBINDIR% -dGSSBINDIR=%GSSBINDIR% -o %CPUTYPE%\psqlodbcm.wixobj psqlodbcm_cpu.wxs
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo Linking psqlODBC merge module...
%wix_dir%\light -nologo -o %CPUTYPE%\psqlodbc_%CPUTYPE%.msm %CPUTYPE%\psqlodbcm.wixobj
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo.
echo Building psqlODBC installer database...
%wix_dir%\candle.exe -nologo -dPlatform="%CPUTYPE%" -dVERSION=%VERSION% -dSUBLOC=%SUBLOC% -o %CPUTYPE%\psqlodbc.wixobj psqlodbc_cpu.wxs
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo Linking psqlODBC installer database...
%wix_dir%\light -nologo -ext WixUIExtension -cultures:en-us -o %CPUTYPE%\psqlodbc_%CPUTYPE%.msi %CPUTYPE%\psqlodbc.wixobj
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo.
echo Modifying psqlODBC installer database...
cscript modify_msi.vbs %CPUTYPE%\psqlodbc_%CPUTYPE%.msi
IF ERRORLEVEL 1 GOTO ERR_HANDLER
echo.
echo Done!
GOTO EXIT
:ERR_HANDLER
echo.
echo Aborting build!
GOTO EXIT
:EXIT

45
installer/modify_msi.vbs Normal file
View File

@ -0,0 +1,45 @@
'
' When the dll name of the driver is not of 8.3-format
' the modification of the FileName is needed
'
option Explicit
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Dim msiPath : msiPath = Wscript.Arguments(0)
Dim installer
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim database
Set database = installer.OpenDatabase(msiPath, msiOpenDatabaseModeTransact)
Dim query
query = "Select * FROM File"
Dim view
Set view = database.OpenView(query)
view.Execute
Dim record
Set record = view.Fetch
Dim gFile, pos
Do While not record Is Nothing
gFile = record.StringData(1)
If Left(gFile, 8) = "psqlodbc" Then
gFile = record.StringData(3)
' Check if the FileName field is ShortName|LongName
pos = InStr(record.StringData(3), "|")
If pos > 0 Then
' Omit the ShortName part
gFile = Mid(record.StringData(3), pos + 1)
WScript.echo record.StringData(3) & " -> " & gFile
' And update the field
record.StringData(3) = gFile
view.Modify msiViewModifyUpdate, record
End If
End If
Set record = view.Fetch
Loop
database.Commit

View File

@ -0,0 +1,22 @@
!IF "$(POSTGRESDRIVERVERSION)" == "09.02.0100"
PRODUCTCODE="3E42F836-9204-4c42-B3C3-8680A0434875"
SUBLOC=0902
!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0100"
PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
SUBLOC=0903
!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0200"
PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
SUBLOC=0903
!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0210"
PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
SUBLOC=0903
!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0300"
PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
SUBLOC=0903
!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.05.0100"
PRODUCTCODE="4C4C4544-004D-5210-8035-B4C04F4B5731"
SUBLOC=0905
!ELSE
!MESSAGE Driver version $(POSTGRESDRIVERVERSION) is not listed in productcodes.mak
EXIT
!ENDIF

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="psqlodbc"
Version="$(var.VERSION)"
Manufacturer="PostgreSQL Global Development Group"
UpgradeCode="7f9f14ee-2f3a-4120-a300-ee3fbd585627">
<BootstrapperApplicationRef
Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
SuppressOptionsUI="yes"
ShowVersion="yes"
LicenseFile="..\lgpl.rtf"
/>
</BootstrapperApplicationRef>
<Chain>
<!-- TODO: Define the list of chained packages. -->
<?if $(var.withRedist) = yes ?>
<PackageGroupRef Id="vcredist"/>
<?endif ?>
<MsiPackage SourceFile="..\x86\psqlodbc_x86.msi"
DisplayInternalUI="$(var.withUI)" />
<MsiPackage SourceFile="..\x64\psqlodbc_x64.msi"
DisplayInternalUI="$(var.withUI)"
InstallCondition="VersionNT64" />
</Chain>
</Bundle>
</Wix>

View File

@ -0,0 +1,11 @@
::
:: Build bootstrapper program of psqlodbc project
::
@echo off
if "%1" == "/?" (
powershell Get-Help '%~dp0\buildBootstrapper.ps1' -detailed
) else if "%1" == "-?" (
powershell Get-Help '%~dp0\buildBootstrapper.ps1' %2 %3 %4 %5 %6 %7 %8 %9
) else (
powershell "& '%~dp0\buildBootstrapper.ps1' %*"
)

View File

@ -0,0 +1,97 @@
<#
.SYNOPSIS
Build a bootstrapper application of psqlodbc drivers.
.DESCRIPTION
Build psqlodbc-setup.exe
.PARAMETER version
Specify when you'd like to specify the version explicitly.
.PARAMETER UI
Specify when you'd like to show UIs of each MSIs.
.PARAMETER withRedist
Specify when you have to include vcredist.
.PARAMETER BuildConfigPath
Specify the configuration xml file name if you want to use
the configuration file other than standard one.
The relative path is relative to the current directory.
.EXAMPLE
> .\buildBootstrapper
Build the bootstrapper.
.EXAMPLE
> .\buildBootstrapper -w(ithRedist)
Build the bootstrapper with vcredist.
.NOTES
Author: Hiroshi Inoue
Date: October 8, 2014
#>
# build bootstrapper of psqlodbc drivers
#
Param(
[string]$version,
[switch]$UI,
[switch]$withRedist,
[string]$BuildConfigPath
)
write-host "Building bootstrapper program`n"
$scriptPath = (Split-Path $MyInvocation.MyCommand.Path)
if ("$version" -eq "") {
# $configInfo = & "$scriptPath\..\..\winbuild\configuration.ps1" "$BuildConfigPath"
$scriptPath = (Split-Path $MyInvocation.MyCommand.Path)
$modulePath="${scriptPath}\..\..\winbuild"
Import-Module ${modulePath}\Psqlodbc-config.psm1
$defaultConfigDir=$modulePath
$configInfo = LoadConfiguration $BuildConfigPath $defaultConfigDir
$version = GetPackageVersion $configInfo "$scriptPath/../.."
Remove-Module Psqlodbc-config
}
if ("$env:WIX" -eq "") {
throw "Please install WIX"
}
$wix_dir="${env:WIX}bin"
$pgmname="psqlodbc-setup"
$build_config="Release"
$objdir="obj\${build_config}"
$bindir="bin\${build_config}"
$modules=@("Bundle.wxs")
$wRedist="no"
$objs=@("${objdir}\Bundle.wixobj")
if ($withRedist) {
$modules += "vcredist.wxs"
$objs += "${objdir}\vcredist.wixobj"
$wRedist = "yes"
write-host "with Redistributable"
}
$wUI = "no"
if ($UI) {
$wUI = "yes"
}
try {
pushd "$scriptPath"
& ${wix_dir}\candle.exe -v "-dVERSION=$version" "-dwithRedist=$wRedist" "-dwithUI=$wUI" "-dConfiguration=${build_config}" "-dOutDir=${bindir}\" -dPlatform=x86 "-dProjectDir=.\" "-dProjectExt=.wixproj" "-dProjectFileName=${pgmname}.wixproj" "-dProjectName=${pgmname}" "-dProjectPath=${pgmname}.wixproj" "-dTargetDir=${bindir}\" "-dTargetExt=.exe" "-dTargetFileName=${pgmname}.exe" "-dTargetName=${pgmname}" "-dTargetPath=${bindir}\${pgmname}.exe" -out "${objdir}\" -arch x86 -ext ${wix_dir}\WixUtilExtension.dll -ext ${wix_dir}\WixBalExtension.dll $modules
# $candle_cmd = "& `"${wix_dir}\candle.exe`" -v `"-dVERSION=$version`" -dwithRedist=$wRedist -dwithUI=$wUI -dConfiguration=${build_config} `"-dOutDir=${bindir}\`" -dPlatform=x86 `"-dProjectDir=.\`" `"-dProjectExt=.wixproj`" `"-dProjectFileName=${pgmname}.wixproj`" -dProjectName=${pgmname} `"-dProjectPath=${pgmname}.wixproj`" -dTargetDir=${bindir}\ `"-dTargetExt=.exe`" `"-dTargetFileName=${pgmname}.exe`" -dTargetName=${pgmname} `"-dTargetPath=${bindir}\${pgmname}.exe`" -out `"${objdir}\`" -arch x86 -ext `"${wix_dir}\WixUtilExtension.dll`" -ext `"${wix_dir}\WixBalExtension.dll`" $modules"
#write-debug "candle_cmd = ${candle_cmd}"
# compile
#invoke-expression $candle_cmd
if ($LASTEXITCODE -ne 0) {
throw "Failed to compile $modules"
}
# link
# invoke-expression "& `"${wix_dir}\Light.exe`" -out ${bindir}\${pgmname}.exe -pdbout ${bindir}\${pgmname}.wixpdb -ext `"${wix_dir}\\WixUtilExtension.dll`" -ext `"${wix_dir}\\WixBalExtension.dll`" -contentsfile ${objdir}\${pgmname}.wixproj.BindContentsFileList.txt -outputsfile ${objdir}\${pgmname}.wixproj.BindOutputsFileList.txt -builtoutputsfile ${objdir}\${pgmname}.wixproj.BindBuiltOutputsFileList.txt -wixprojectfile ${pgmname}.wixproj ${objs}"
& ${wix_dir}\Light.exe -out ${bindir}\${pgmname}.exe -pdbout ${bindir}\${pgmname}.wixpdb -ext ${wix_dir}\\WixUtilExtension.dll -ext ${wix_dir}\\WixBalExtension.dll -contentsfile ${objdir}\${pgmname}.wixproj.BindContentsFileList.txt -outputsfile ${objdir}\${pgmname}.wixproj.BindOutputsFileList.txt -builtoutputsfile ${objdir}\${pgmname}.wixproj.BindBuiltOutputsFileList.txt -wixprojectfile "${pgmname}.wixproj" ${objs}
if ($LASTEXITCODE -ne 0) {
throw "Failed to link bootstrapper"
}
}
catch [Exception] {
Write-Host ".`Aborting build!"
throw $error[0]
}
finally {
popd
}

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.6</ProductVersion>
<ProjectGuid>{748caa18-f40d-4308-bc52-2605d09c38b1}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>psqlodbc-setup</OutputName>
<OutputType>Bundle</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Bundle.wxs" />
<Compile Include="vcredist.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUtilExtension">
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
<Name>WixUtilExtension</Name>
</WixExtension>
<WixExtension Include="WixBalExtension">
<HintPath>$(WixExtDir)\WixBalExtension.dll</HintPath>
<Name>WixBalExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<?ifndef VCVER?>
<?define VCVER = 14?>
<?endif?>
<!-- ?define vcredist_x86 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe ?>
<?define vcredist_x64 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x64.exe ? -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<!-- TODO: Put your code here. -->
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\$(var.VCVER).0\VC\VCRedist\x86" Value="Installed" Variable="vc$(var.VCVER)0_redist_x86" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\$(var.VCVER).0\VC\VCRedist\x64" Value="Installed" Variable="vc$(var.VCVER)0_redist_x64" Win64="yes"/>
<PackageGroup Id="vcredist">
<ExePackage Id="vc$(var.VCVER)0_redist_x86"
Cache="no"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
Name="vc$(var.VCVER)0_redist_x86.exe"
SourceFile="Redist\vc$(var.VCVER)0_redist_x86.exe"
InstallCommand="/q"
DetectCondition="vc$(var.VCVER)0_redist_x86 AND (vc$(var.VCVER)0_redist_x86 &gt;= 1)">
<ExitCode Value ="3010" Behavior="forceReboot" />
</ExePackage>
<ExePackage Id="vc$(var.VCVER)0_redist_x64"
Cache="no"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
Name="vc$(var.VCVER)0_redist_x64.exe"
SourceFile="Redist\vc$(var.VCVER)0_redist_x64.exe"
InstallCommand="/q"
InstallCondition="VersionNT64"
DetectCondition="vc$(var.VCVER)0_redist_x64 AND (vc$(var.VCVER)0_redist_x64 &gt;= 1)">
<ExitCode Value ="3010" Behavior="forceReboot" />
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>

65
installer/psqlodbc.wxs Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Product details -->
<Product
Manufacturer="PostgreSQL Global Development Group"
Id="838E187D-8B7A-473d-B93C-C8E970B15D2B"
UpgradeCode="24BCA538-75A2-4a7f-B236-C99EFC2145DE"
Name="psqlODBC"
Version="$(var.VERSION)"
Language="1033">
<!-- Package details -->
<Package
Keywords="PostgreSQL, ODBC"
Comments="PostgreSQL ODBC Driver"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="300"
Languages="1033"
Compressed="yes"
SummaryCodepage="1252" />
<!-- Directories -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="BASEDIR" Name="psqlODBC">
<Component Id="registration" Guid="4F0C04EB-ADCB-4fa8-B6A3-E9F74EA693F8">
<RegistryValue KeyPath="yes" Type="string" Root="HKLM" Key="Software\psqlODBC" Name="Version" Value="$(var.VERSION)" />
</Component>
<Merge Id="psqlodbcm" DiskId="1" Language="1033" SourceFile="psqlodbc.msm" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="." SourceName="Programs">
</Directory>
</Directory>
<!-- Features -->
<Feature Id="psqlodbc" Title="psqlODBC" Level="1" Description="psqlODBC - The PostgreSQL ODBC Driver" ConfigurableDirectory="BASEDIR" Display="expand">
<Feature Id="binaries" Title="ODBC Driver" Level="1" Description="The ODBC driver and supporting libraries.">
<ComponentRef Id="registration" />
<MergeRef Id="psqlodbcm" />
</Feature>
</Feature>
<Media Id="1" EmbedCab="yes" Cabinet="psqlodbc.cab"/>
<!-- Properties -->
<Property Id="ALLUSERS">2</Property>
<Property Id="WIXUI_INSTALLDIR" Value="BASEDIR" />
<!-- UI -->
<UIRef Id="WixUI_FeatureTree" />
<WixVariable Id="WixUILicenseRtf" Value="lgpl.rtf" />
<WixVariable Id="WixUIDialogBmp" Value="background.bmp" />
<WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
</Product>
</Wix>

107
installer/psqlodbc_cpu.wxs Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?ifdef var.Platform ?>
<?define PKGNAME = "psqlODBC_$(var.Platform)" ?>
<?define MERGEM = "$(var.Platform)\psqlodbc_$(var.Platform).msm" ?>
<?if $(var.Platform) = x64 ?>
<?define BIT64 = "yes" ?>
<?define PGFOLDER = "ProgramFiles64Folder" ?>
<?define PRODID = "3E42F836-9204-4c42-B3C3-8680A0434875" ?>
<?define CIDREG = "4D361F28-8F75-4c86-9A37-6C279967413D" ?>
<?define CIDDOC = "0C745A85-4E55-4bab-BBF1-DCF51D92FCC5" ?>
<?define CIDSMD = "{E6410EE8-96DC-4d84-8D07-94F8093BF3EF}" ?>
<?define UPGCOD = "BBD29DF5-89F6-4b8b-BDC9-C3EA3A4AFDBB" ?>
<?else?>
<?define BIT64 = "no" ?>
<?define PGFOLDER = "ProgramFilesFolder" ?>
<?define PRODID = "838E187D-8B7A-473d-B93C-C8E970B15D2D" ?>
<?define CIDREG = "4F0C04EB-ADCB-4fa8-B6A3-E9F74EA693FA" ?>
<?define CIDDOC = "89DDBC52-9F0D-4846-91DC-09EECC87E430" ?>
<?define CIDSMD = "{22288E09-B3B6-4181-907F-676099C20127}" ?>
<?define UPGCOD = "24BCA538-75A2-4a7f-B236-C99EFC2145E0" ?>
<?endif?>
<?else?>
<?define Platform = "x86" ?>
<?define PKGNAME = "psqlODBC" ?>
<?define MERGEM = "psqlodbc.msm" ?>
<?define BIT64 = "no" ?>
<?define PGFOLDER = "ProgramFilesFolder" ?>
<?define PRODID = "838E187D-8B7A-473d-B93C-C8E970B15D2B" ?>
<?define CIDREG = "4F0C04EB-ADCB-4fa8-B6A3-E9F74EA693F8" ?>
<?define CIDDOC = "89DDBC52-9F0D-4846-91DC-09EECC87E42E" ?>
<?define CIDSMD = "{22288E09-B3B6-4181-907F-676099C20125}" ?>
<?define UPGCOD = "24BCA538-75A2-4a7f-B236-C99EFC2145DE" ?>
<?endif?>
<!-- Product details -->
<Product
Manufacturer="PostgreSQL Global Development Group"
Id="$(var.PRODID)"
UpgradeCode="$(var.UPGCOD)"
Name="$(var.PKGNAME)"
Version="$(var.VERSION)"
Language="1033">
<!-- Package details -->
<Package
Keywords="PostgreSQL, ODBC"
Comments="PostgreSQL ODBC Driver"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="300"
Platform="$(var.Platform)"
Languages="1033"
Compressed="yes"
SummaryCodepage="1252" />
<!-- Directories -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PGFOLDER)" Name="PFiles">
<Directory Id="BASEDIR" Name="psqlODBC">
<Component Id="registration" Guid="$(var.CIDREG)" Win64="$(var.BIT64)">
<RegistryValue KeyPath="yes" Type="string" Root="HKLM" Key="Software\$(var.PKGNAME)" Name="Version" Value="$(var.VERSION)" />
</Component>
<Merge Id="psqlodbcm" DiskId="1" Language="1033" SourceFile="$(var.MERGEM)" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="." SourceName="Programs">
<Directory Id="SMDir" Name="$(var.PKGNAME)">
<Component Id="smdir" Guid="$(var.CIDSMD)" Win64="$(var.BIT64)">
<RegistryValue KeyPath="yes" Type="string" Root="HKCU" Key="Software\$(var.PKGNAME)\SMDir Created" Value="y" />
<RemoveFolder Id="SMDir" On="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
<!-- Features -->
<Feature Id="psqlodbc" Title="$(var.PKGNAME)" Level="1" Description="psqlODBC - The PostgreSQL ODBC Driver" ConfigurableDirectory="BASEDIR" Display="expand">
<Feature Id="binaries" Title="ODBC Driver" Level="1" Description="The ODBC driver and supporting libraries.">
<ComponentRef Id="registration" />
<MergeRef Id="psqlodbcm" />
</Feature>
<Feature Id="docs" Title="Documentation" Level="4" Description="Documentation, FAQs and HOWTOs.">
<ComponentRef Id="smdir" />
</Feature>
</Feature>
<Media Id="1" EmbedCab="yes" Cabinet="psqlodbc.cab"/>
<!-- Properties -->
<Property Id="ALLUSERS">2</Property>
<Property Id="WIXUI_INSTALLDIR" Value="BASEDIR" />
<!-- UI -->
<UIRef Id="WixUI_FeatureTree" />
<WixVariable Id="WixUILicenseRtf" Value="lgpl.rtf" />
<WixVariable Id="WixUIDialogBmp" Value="background.bmp" />
<WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
</Product>
</Wix>

45
installer/psqlodbcm.wxs Normal file
View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Module
Id="psqlODBC"
Version="$(var.VERSION)"
Language="1033">
<Package
Id="ACF10866-5C01-46f0-90F0-D5618638CA48"
Description="PostgreSQL ODBC Driver"
Keywords="PostgreSQL, ODBC"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="150"
Platforms="Intel"
Languages="1033"
SummaryCodepage="1252" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="BINDIR" Name=".">
<Component Id="psqlodbc.files" Guid="00A1ACE3-B7C2-41b8-A1F1-DB565990DA4E">
<!-- PostgreSQL -->
<File Id="psqlodbc35w.dll" Name="psqlodbc35w.dll" Source="../Release-x86/psqlodbc35w.dll" />
<File Id="libpq.dll" Name="libpq.dll" Source="../../Code/Release/libpq/libpq.dll" KeyPath="yes" />
<File Id="MSVCR100.DLL" Name="MSVCR100.DLL" Source="x86/MSVCR100.DLL" KeyPath="no" />
<File Id="MSVCR100D.DLL" Name="MSVCR100D.DLL" Source="x86/MSVCR100D.DLL" KeyPath="no" />
<!-- Note, installing the driver properly (IE, using ODBCDriver) has proven unreliable -->
<!-- so we install the registry keys manually ourselves. -->
<RegistryValue Id="psqlodbc35w.reg.1" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" Name="PostgreSQL Unicode" Type="string" Value="Installed" />
<RegistryValue Id="psqlodbc35w.reg.2" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="APILevel" Type="string" Value="1" />
<RegistryValue Id="psqlodbc35w.reg.3" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="ConnectFunctions" Type="string" Value="YYN" />
<RegistryValue Id="psqlodbc35w.reg.4" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="Driver" Type="string" Value="[#psqlodbc35w.dll]" />
<RegistryValue Id="psqlodbc35w.reg.5" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="DriverODBCVer" Type="string" Value="03.51" />
<RegistryValue Id="psqlodbc35w.reg.6" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="FileUsage" Type="string" Value="0" />
<RegistryValue Id="psqlodbc35w.reg.7" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="Setup" Type="string" Value="[#psqlodbc35w.dll]" />
<RegistryValue Id="psqlodbc35w.reg.8" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="SQLLevel" Type="string" Value="1" />
<RegistryValue Id="psqlodbc35w.reg.9" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="UsageCount" Type="integer" Value="1" />
</Component>
</Directory>
</Directory>
</Module>
</Wix>

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?ifdef var.Platform ?>
<?define ModuleName = "psqlODBC_$(var.Platform)" ?>
<?if $(var.Platform) = x64 ?>
<?define BIT64 = "yes" ?>
<?define ANSIFOLDER = "AMD64ANSI" ?>
<?define UNICODEFOLDER = "AMD64" ?>
<?define Module_PackageId = "970B6E07-7105-4d66-80FA-9E208952FB96" ?>
<?define CIDPFILES = "5C9A19B5-D7C6-4bb4-BBBC-88C2A67A59B0" ?>
<?else?>
<?define BIT64 = "no" ?>
<?define ANSIFOLDER = "MultibyteRelease" ?>
<?define UNICODEFOLDER = "Release" ?>
<?define Module_PackageId = "ACF10866-5C01-46f0-90F0-D5618638CA4A" ?>
<?define CIDPFILES = "00A1ACE3-B7C2-41b8-A1F1-DB565990DA50" ?>
<?endif?>
<?else?>
<?define BIT64 = "no" ?>
<?define Platform = "x86" ?>
<?define ModuleName = "psqlODBC" ?>
<?define ANSIFOLDER = "MultibyteRelease" ?>
<?define UNICODEFOLDER = "Release" ?>
<?define Module_PackageId = "ACF10866-5C01-46f0-90F0-D5618638CA48" ?>
<?define CIDPFILES = "00A1ACE3-B7C2-41b8-A1F1-DB565990DA4E" ?>
<?endif?>
<Module
Id="$(var.ModuleName)"
Version="$(var.VERSION)"
Language="1033">
<Package
Id="$(var.Module_PackageId)"
Description="PostgreSQL ODBC Driver"
Keywords="PostgreSQL, ODBC"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="300"
Platform="$(var.Platform)"
Languages="1033"
SummaryCodepage="1252" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="BINDIR" Name=".">
<Component Id="psqlodbc.files" Guid="$(var.CIDPFILES)" Win64="$(var.BIT64)">
<File Id="psqlodbc35w.dll" Name="psqlodbc35w.dll" Source="../Release-x64/psqlodbc35w.dll" >
<ODBCDriver Id="Psqlodbc_9.0_Driver" Name="PostgreSQL Unicode($(var.Platform))" />
</File>
<File Id="libpq.dll" Name="libpq.dll" Source="../../Code/Release/libpq/libpq.dll" KeyPath="yes" />
<File Id="MSVCR100.DLL" Name="MSVCR100.DLL" Source="x64/MSVCR100.DLL" KeyPath="no" />
<File Id="MSVCR100D.DLL" Name="MSVCR100D.DLL" Source="x64/MSVCR100D.DLL" KeyPath="no" />
<!-- Note, installing the driver properly (IE, using ODBCDriver) has proven unreliable -->
<!-- so we install the registry keys manually ourselves. -->
<RegistryValue Id="psqlodbc35w.reg.1" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" Name="PostgreSQL Unicode($(var.Platform))" Type="string" Value="Installed" />
<RegistryValue Id="psqlodbc35w.reg.2" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="APILevel" Type="string" Value="1" />
<RegistryValue Id="psqlodbc35w.reg.3" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="ConnectFunctions" Type="string" Value="YYN" />
<RegistryValue Id="psqlodbc35w.reg.4" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="Driver" Type="string" Value="[#psqlodbc35w.dll]" />
<RegistryValue Id="psqlodbc35w.reg.5" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="DriverODBCVer" Type="string" Value="03.51" />
<RegistryValue Id="psqlodbc35w.reg.6" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="FileUsage" Type="string" Value="0" />
<RegistryValue Id="psqlodbc35w.reg.7" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="Setup" Type="string" Value="[#psqlodbc35w.dll]" />
<RegistryValue Id="psqlodbc35w.reg.8" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="SQLLevel" Type="string" Value="1" />
<RegistryValue Id="psqlodbc35w.reg.9" Root="HKLM" Key="SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" Name="UsageCount" Type="integer" Value="1" />
</Component>
</Directory>
</Directory>
</Module>
</Wix>

23
installer/upgrade.bat Normal file
View File

@ -0,0 +1,23 @@
@echo off
cls
echo This file will upgrade your psqlODBC installation.
echo.
echo You must have psqlODBC 09.01.xxxx installed
echo from the official MSI installation to use this upgrade path.
echo.
echo If psqlODBC or any of it's components are in use
echo a reboot will be required once the upgrade is completed.
echo.
echo.
echo Press Ctrl-C to abort the upgrade or
pause
REM Parameters described:
REM /i psqlodbc.msi - pick MSI file to install. All properties
REM will be read from existing installation.
REM REINSTALLMODE=vamus - reinstall all files, regardless of version.
REM This makes sure documentation and other
REM non-versioned files are updated.
REM REINSTALL=ALL - Reinstall all features that were previously
REM installed with the new version.
msiexec /i psqlodbc.msi REINSTALLMODE=vamus REINSTALL=ALL /qr

23
installer/upgrade_x64.bat Normal file
View File

@ -0,0 +1,23 @@
@echo off
cls
echo This file will upgrade your psqlODBC installation.
echo.
echo You must have psqlODBC 09.01.xxxx installed
echo from the official MSI installation to use this upgrade path.
echo.
echo If psqlODBC or any of it's components are in use
echo a reboot will be required once the upgrade is completed.
echo.
echo.
echo Press Ctrl-C to abort the upgrade or
pause
REM Parameters described:
REM /i psqlodbc_x64.msi - pick MSI file to install. All properties
REM will be read from existing installation.
REM REINSTALLMODE=vamus - reinstall all files, regardless of version.
REM This makes sure documentation and other
REM non-versioned files are updated.
REM REINSTALL=ALL - Reinstall all features that were previously
REM installed with the new version.
msiexec /i psqlodbc_x64.msi REINSTALLMODE=vamus REINSTALL=ALL /qr

962
license.txt Normal file
View File

@ -0,0 +1,962 @@
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!

286
loadlib.c Normal file
View File

@ -0,0 +1,286 @@
/*------
* Module: loadlib.c
*
* Description: This module contains routines related to
* delay load import libraries.
*
* Comments: See "readme.txt" for copyright and license information.
*-------
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef WIN32
#include <errno.h>
#endif /* WIN32 */
#include "loadlib.h"
#include "pgenlist.h"
#include "misc.h"
#ifdef WIN32
#ifdef _MSC_VER
#pragma comment(lib, "Delayimp")
#ifdef _HANDLE_ENLIST_IN_DTC_
#ifdef UNICODE_SUPPORT
#pragma comment(lib, "pgenlist")
#else
#pragma comment(lib, "pgenlista")
#endif /* UNICODE_SUPPORT */
#endif /* _HANDLE_ENLIST_IN_DTC_ */
// The followings works under VC++6.0 but doesn't work under VC++7.0.
// Please add the equivalent linker options using command line etc.
#if (_MSC_VER == 1200) && defined(DYNAMIC_LOAD) // VC6.0
#ifdef UNICODE_SUPPORT
#pragma comment(linker, "/Delayload:pgenlist.dll")
#else
#pragma comment(linker, "/Delayload:pgenlista.dll")
#endif /* UNICODE_SUPPORT */
#pragma comment(linker, "/Delay:UNLOAD")
#endif /* _MSC_VER */
#endif /* _MSC_VER */
#if defined(DYNAMIC_LOAD)
#define WIN_DYN_LOAD
#ifdef UNICODE_SUPPORT
CSTR pgenlist = "pgenlist";
CSTR pgenlistdll = "pgenlist.dll";
CSTR psqlodbc = "psqlodbc35w";
CSTR psqlodbcdll = "psqlodbc35w.dll";
#else
CSTR pgenlist = "pgenlista";
CSTR pgenlistdll = "pgenlista.dll";
CSTR psqlodbc = "psqlodbc30a";
CSTR psqlodbcdll = "psqlodbc30a.dll";
#endif /* UNICODE_SUPPORT */
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#define _MSC_DELAY_LOAD_IMPORT
#endif /* MSC_VER */
#endif /* DYNAMIC_LOAD */
#endif /* WIN32 */
#if defined(_MSC_DELAY_LOAD_IMPORT)
/*
* Error hook function for delay load import.
* Try to load a DLL based on psqlodbc path.
*/
#if (_MSC_VER >= 1900) /* vc14 or later */
#define TRY_DLI_HOOK \
__try {
#define RELEASE_NOTIFY_HOOK
#elif (_MSC_VER < 1300) /* vc6 */
extern PfnDliHook __pfnDliFailureHook;
extern PfnDliHook __pfnDliNotifyHook;
#define TRY_DLI_HOOK \
__try { \
__pfnDliFailureHook = DliErrorHook; \
__pfnDliNotifyHook = DliErrorHook;
#define RELEASE_NOTIFY_HOOK \
__pfnDliNotifyHook = NULL;
#else /* vc7 ~ 12 */
extern PfnDliHook __pfnDliFailureHook2;
extern PfnDliHook __pfnDliNotifyHook2;
#define TRY_DLI_HOOK \
__try { \
__pfnDliFailureHook2 = DliErrorHook; \
__pfnDliNotifyHook2 = DliErrorHook;
#define RELEASE_NOTIFY_HOOK \
__pfnDliNotifyHook2 = NULL;
#endif /* _MSC_VER */
#else
#define TRY_DLI_HOOK \
__try {
#define RELEASE_NOTIFY_HOOK
#endif /* _MSC_DELAY_LOAD_IMPORT */
#if defined(_MSC_DELAY_LOAD_IMPORT)
static BOOL loaded_pgenlist = FALSE;
static HMODULE enlist_module = NULL;
static BOOL loaded_psqlodbc = FALSE;
/*
* Load a DLL based on psqlodbc path.
*/
HMODULE MODULE_load_from_psqlodbc_path(const char *module_name)
{
extern HINSTANCE s_hModule;
HMODULE hmodule = NULL;
char szFileName[MAX_PATH];
if (GetModuleFileName(s_hModule, szFileName, sizeof(szFileName)) > 0)
{
char drive[_MAX_DRIVE], dir[_MAX_DIR], sysdir[MAX_PATH];
_splitpath(szFileName, drive, dir, NULL, NULL);
GetSystemDirectory(sysdir, MAX_PATH);
SPRINTF_FIXED(szFileName, "%s%s%s.dll", drive, dir, module_name);
if (_strnicmp(szFileName, sysdir, strlen(sysdir)) != 0)
{
hmodule = LoadLibraryEx(szFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
MYLOG(0, "psqlodbc path based %s loaded module=%p\n", module_name, hmodule);
}
}
return hmodule;
}
static FARPROC WINAPI
DliErrorHook(unsigned dliNotify,
PDelayLoadInfo pdli)
{
HMODULE hmodule = NULL;
const char* call_module = NULL;
MYLOG(0, "Dli%sHook %s Notify=%d\n", (dliFailLoadLib == dliNotify || dliFailGetProc == dliNotify) ? "Error" : "Notify", NULL != pdli->szDll ? pdli->szDll : pdli->dlp.szProcName, dliNotify);
switch (dliNotify)
{
case dliNotePreLoadLibrary:
case dliFailLoadLib:
RELEASE_NOTIFY_HOOK
if (_strnicmp(pdli->szDll, pgenlist, strlen(pgenlist)) == 0)
call_module = pgenlist;
else if (_strnicmp(pdli->szDll, psqlodbc, strlen(psqlodbc)) == 0)
call_module = psqlodbc;
if (call_module)
{
if (hmodule = MODULE_load_from_psqlodbc_path(call_module), NULL == hmodule)
hmodule = LoadLibrary(call_module);
if (NULL != hmodule)
{
if (pgenlist == call_module)
loaded_pgenlist = TRUE;
else if (psqlodbc == call_module)
loaded_psqlodbc = TRUE;
}
}
break;
}
return (FARPROC) hmodule;
}
void AlreadyLoadedPsqlodbc(void)
{
loaded_psqlodbc = TRUE;
}
/*
* unload delay loaded libraries.
*/
typedef BOOL (WINAPI *UnloadFunc)(LPCSTR);
void CleanupDelayLoadedDLLs(void)
{
BOOL success;
#if (_MSC_VER < 1300) /* VC6 DELAYLOAD IMPORT */
UnloadFunc func = __FUnloadDelayLoadedDLL;
#else
UnloadFunc func = __FUnloadDelayLoadedDLL2;
#endif
/* The dll names are case sensitive for the unload helper */
if (loaded_pgenlist)
{
if (enlist_module != NULL)
{
MYLOG(0, "Freeing Library %s\n", pgenlistdll);
FreeLibrary(enlist_module);
}
MYLOG(0, "%s unloading\n", pgenlistdll);
success = (*func)(pgenlistdll);
MYLOG(0, "%s unloaded success=%d\n", pgenlistdll, success);
loaded_pgenlist = FALSE;
}
if (loaded_psqlodbc)
{
MYLOG(0, "%s unloading\n", psqlodbcdll);
success = (*func)(psqlodbcdll);
MYLOG(0, "%s unloaded success=%d\n", psqlodbcdll, success);
loaded_psqlodbc = FALSE;
}
return;
}
#else
void CleanupDelayLoadedDLLs(void)
{
return;
}
#endif /* _MSC_DELAY_LOAD_IMPORT */
#ifdef _HANDLE_ENLIST_IN_DTC_
RETCODE CALL_EnlistInDtc(ConnectionClass *conn, void *pTra, int method)
{
RETCODE ret;
BOOL loaded = TRUE;
#if defined(_MSC_DELAY_LOAD_IMPORT)
if (!loaded_pgenlist)
{
TRY_DLI_HOOK
ret = EnlistInDtc(conn, pTra, method);
}
__except ((GetExceptionCode() & 0xffff) == ERROR_MOD_NOT_FOUND ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
if (enlist_module = MODULE_load_from_psqlodbc_path(pgenlist), NULL == enlist_module)
loaded = FALSE;
else
ret = EnlistInDtc(conn, pTra, method);
}
if (loaded)
loaded_pgenlist = TRUE;
RELEASE_NOTIFY_HOOK
}
else
ret = EnlistInDtc(conn, pTra, method);
#else
ret = EnlistInDtc(conn, pTra, method);
loaded_pgenlist = TRUE;
#endif /* _MSC_DELAY_LOAD_IMPORT */
return ret;
}
RETCODE CALL_DtcOnDisconnect(ConnectionClass *conn)
{
if (loaded_pgenlist)
return DtcOnDisconnect(conn);
return FALSE;
}
RETCODE CALL_IsolateDtcConn(ConnectionClass *conn, BOOL continueConnection)
{
if (loaded_pgenlist)
return IsolateDtcConn(conn, continueConnection);
return FALSE;
}
void *CALL_GetTransactionObject(HRESULT *hres)
{
void *ret = NULL;
BOOL loaded = TRUE;
#if defined(_MSC_DELAY_LOAD_IMPORT)
if (!loaded_pgenlist)
{
TRY_DLI_HOOK
ret = GetTransactionObject(hres);
}
__except ((GetExceptionCode() & 0xffff) == ERROR_MOD_NOT_FOUND ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
if (enlist_module = MODULE_load_from_psqlodbc_path(pgenlist), NULL == enlist_module)
loaded = FALSE;
else
ret = GetTransactionObject(hres);
}
if (loaded)
loaded_pgenlist = TRUE;
RELEASE_NOTIFY_HOOK
}
else
ret = GetTransactionObject(hres);
#else
ret = GetTransactionObject(hres);
loaded_pgenlist = TRUE;
#endif /* _MSC_DELAY_LOAD_IMPORT */
return ret;
}
void CALL_ReleaseTransactionObject(void *pObj)
{
if (loaded_pgenlist)
ReleaseTransactionObject(pObj);
return;
}
#endif /* _HANDLE_ENLIST_IN_DTC_ */

42
loadlib.h Normal file
View File

@ -0,0 +1,42 @@
/* File: loadlib.h
*
* Description: See "loadlib.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __LOADLIB_H__
#define __LOADLIB_H__
#include "psqlodbc.h"
#ifdef HAVE_LIBLTDL
#include <ltdl.h>
#else
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif /* HAVE_DLFCN_H */
#endif /* HAVE_LIBLTDL */
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _HANDLE_ENLIST_IN_DTC_
RETCODE CALL_EnlistInDtc(ConnectionClass *conn, void * pTra, int method);
RETCODE CALL_DtcOnDisconnect(ConnectionClass *);
RETCODE CALL_IsolateDtcConn(ConnectionClass *, BOOL);
void *CALL_GetTransactionObject(HRESULT *);
void CALL_ReleaseTransactionObject(void *);
#endif /* _HANDLE_ENLIST_IN_DTC_ */
void CleanupDelayLoadedDLLs(void);
#ifdef WIN32
HMODULE MODULE_load_from_psqlodbc_path(const char *module_name);
void AlreadyLoadedPsqlodbc(void);
#endif /* WIN32 */
#ifdef __cplusplus
}
#endif
#endif /* __LOADLIB_H__ */

227
lobj.c Normal file
View File

@ -0,0 +1,227 @@
/*--------
* Module: lobj.c
*
* Description: This module contains routines related to manipulating
* large objects.
*
* Classes: none
*
* API functions: none
*
* Comments: See "readme.txt" for copyright and license information.
*--------
*/
#include "lobj.h"
#include "connection.h"
OID
odbc_lo_creat(ConnectionClass *conn, int mode)
{
LO_ARG argv[1];
Int4 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 (OID) retval;
}
int
odbc_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 && odbc_lo_lseek64(conn, fd, 0L, SEEK_SET) < 0)
return -1;
return fd;
}
int
odbc_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;
}
Int4
odbc_lo_read(ConnectionClass *conn, int fd, char *buf, Int4 len)
{
LO_ARG argv[2];
Int4 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, "loread", (int *) buf, &result_len, 0, argv, 2))
return -1;
else
return result_len;
}
Int4
odbc_lo_write(ConnectionClass *conn, int fd, char *buf, Int4 len)
{
LO_ARG argv[2];
Int4 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, "lowrite", &retval, &result_len, 1, argv, 2))
return -1;
else
return retval;
}
Int4
odbc_lo_lseek(ConnectionClass *conn, int fd, int offset, Int4 whence)
{
LO_ARG argv[3];
Int4 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;
/* We use lo_lseek64 */
if (!CC_send_function(conn, "lo_lseek", &retval, &result_len, 1, argv, 3))
return -1;
else
return retval;
}
Int4
odbc_lo_tell(ConnectionClass *conn, int fd)
{
LO_ARG argv[1];
Int4 retval, result_len;
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
/* We use lo_tell64 */
if (!CC_send_function(conn, "lo_tell", &retval, &result_len, 1, argv, 1))
return -1;
else
return retval;
}
Int8
odbc_lo_lseek64(ConnectionClass *conn, int fd, Int8 offset, Int4 whence)
{
LO_ARG argv[3];
Int8 retval;
Int4 result_len;
if (PG_VERSION_LT(conn, 9.3))
{
Int4 offset32;
offset32 = (Int4) offset;
if (offset != (Int8) offset32)
{
CC_set_error(conn, CONN_VALUE_OUT_OF_RANGE, "large object lseek64 is unavailable for the server", __FUNCTION__);
return -1;
}
return (Int8) odbc_lo_lseek(conn, fd, offset32, whence);
}
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
argv[1].isint = 2;
argv[1].len = sizeof(offset);
argv[1].u.integer64 = offset;
argv[2].isint = 1;
argv[2].len = 4;
argv[2].u.integer = whence;
if (!CC_send_function(conn, "lo_lseek64", &retval, &result_len, 2, argv, 3))
return -1;
else
return retval;
}
Int8
odbc_lo_tell64(ConnectionClass *conn, int fd)
{
LO_ARG argv[1];
Int8 retval;
Int4 result_len;
if (PG_VERSION_LT(conn, 9.3))
return (Int8) odbc_lo_tell(conn, fd);
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = fd;
if (!CC_send_function(conn, "lo_tell64", &retval, &result_len, 2, argv, 1))
return -1;
else
return retval;
}

40
lobj.h Normal file
View File

@ -0,0 +1,40 @@
/* File: lobj.h
*
* Description: See "lobj.c"
*
* Comments: See "readme.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;
Int8 integer64;
} u;
};
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
OID odbc_lo_creat(ConnectionClass *conn, int mode);
int odbc_lo_open(ConnectionClass *conn, int lobjId, int mode);
int odbc_lo_close(ConnectionClass *conn, int fd);
Int4 odbc_lo_read(ConnectionClass *conn, int fd, char *buf, Int4 len);
Int4 odbc_lo_write(ConnectionClass *conn, int fd, char *buf, Int4 len);
Int4 odbc_lo_lseek(ConnectionClass *conn, int fd, int offset, Int4 len);
Int4 odbc_lo_tell(ConnectionClass *conn, int fd);
Int8 odbc_lo_lseek64(ConnectionClass *conn, int fd, Int8 offset, Int4 len);
Int8 odbc_lo_tell64(ConnectionClass *conn, int fd);
#endif

314
misc.c Normal file
View File

@ -0,0 +1,314 @@
/*-------
* 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 "readme.txt" for copyright and license information.
*-------
*/
#include "psqlodbc.h"
#include "misc.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#ifndef WIN32
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#else
#include <process.h> /* Byron: is this where Windows keeps def.
* of getpid ? */
#endif
/*
* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied
* (not including null term)
*/
ssize_t
my_strcpy(char *dst, ssize_t dst_len, const char *src, ssize_t 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.
*/
size_t
strncpy_null(char *dst, const char *src, ssize_t len)
{
int i;
if (NULL != dst && len > 0)
{
for (i = 0; src[i] && i < len - 1; i++)
dst[i] = src[i];
dst[i] = '\0';
}
else
return 0;
if (src[i])
return strlen(src);
return i;
}
/*------
* 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 SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize)
{
size_t length;
char *str;
if (!s || SQL_NULL_DATA == len)
return NULL;
if (len >= 0)
length =len;
else if (SQL_NTS == len)
length = strlen((char *) s);
else
{
MYLOG(0, "invalid length=%d\n", len);
return NULL;
}
if (buf)
{
strncpy_null(buf, (char *) s, bufsize > length ? length + 1 : bufsize);
return buf;
}
MYLOG(DETAIL_LOG_LEVEL, "malloc size=" FORMAT_SIZE_T "\n", length);
str = malloc(length + 1);
MYLOG(DETAIL_LOG_LEVEL, "str=%p\n", str);
if (!str)
return NULL;
strncpy_null(str, (char *) s, length + 1);
return str;
}
char *
my_trim(char *s)
{
char *last;
for (last = s + strlen(s) - 1; last >= s; last--)
{
if (*last == ' ')
*last = '\0';
else
break;
}
return s;
}
/*
* snprintfcat is a extension to snprintf
* It add format to buf at given pos
*/
#ifdef POSIX_SNPRINTF_REQUIRED
static posix_vsnprintf(char *str, size_t size, const char *format, va_list ap);
#define vsnprintf posix_vsnprintf
#endif /* POSIX_SNPRINTF_REQUIRED */
int
snprintfcat(char *buf, size_t size, const char *format, ...)
{
int len;
size_t pos = strlen(buf);
va_list arglist;
va_start(arglist, format);
len = vsnprintf(buf + pos, size - pos, format, arglist);
va_end(arglist);
return len + pos;
}
/*
* snprintf_len is a extension to snprintf
* It returns strlen of buf every time (not -1 when truncated)
*/
size_t
snprintf_len(char *buf, size_t size, const char *format, ...)
{
ssize_t len;
va_list arglist;
va_start(arglist, format);
if ((len = vsnprintf(buf, size, format, arglist)) < 0)
len = size;
va_end(arglist);
return (size_t)len;
}
/*
* Windows doesn't have snprintf(). It has _snprintf() which is similar,
* but it behaves differently wrt. truncation. This is a compatibility
* function that uses _snprintf() to provide POSIX snprintf() behavior.
*
* Our strategy, if the output doesn't fit, is to create a temporary buffer
* and call _snprintf() on that. If it still doesn't fit, enlarge the buffer
* and repeat.
*/
#ifdef POSIX_SNPRINTF_REQUIRED
static int
posix_vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
int len;
char *tmp;
size_t newsize;
len = _vsnprintf(str, size, format, ap);
if (len < 0)
{
if (size == 0)
newsize = 100;
else
newsize = size;
do
{
newsize *= 2;
tmp = malloc(newsize);
if (!tmp)
return -1;
len = _vsnprintf(tmp, newsize, format, ap);
if (len >= 0)
memcpy(str, tmp, size);
free(tmp);
} while (len < 0);
}
if (len >= size && size > 0)
{
/* Ensure the buffer is NULL-terminated */
str[size - 1] = '\0';
}
return len;
}
int
posix_snprintf(char *buf, size_t size, const char *format, ...)
{
int len;
va_list arglist;
va_start(arglist, format);
len = posix_vsnprintf(buf, size, format, arglist);
va_end(arglist);
return len;
}
#endif /* POSIX_SNPRINTF_REQUIRED */
#ifndef HAVE_STRLCAT
size_t
strlcat(char *dst, const char *src, size_t size)
{
size_t ttllen;
char *pd = dst;
const char *ps= src;
for (ttllen = 0; ttllen < size; ttllen++, pd++)
{
if (0 == *pd)
break;
}
if (ttllen >= size - 1)
return ttllen + strlen(src);
for (; ttllen < size - 1; ttllen++, pd++, ps++)
{
if (0 == (*pd = *ps))
return ttllen;
}
*pd = 0;
for (; *ps; ttllen++, ps++)
;
return ttllen;
}
#endif /* HAVE_STRLCAT */
/*
* Proprly quote and escape a possibly schema-qualified table name.
*/
char *
quote_table(const pgNAME schema, const pgNAME table, char *buf, int buf_size)
{
const char *ptr;
int i;
i = 0;
if (NAME_IS_VALID(schema))
{
buf[i++] = '"';
for (ptr = SAFE_NAME(schema); *ptr != '\0' && i < buf_size - 6; ptr++)
{
buf[i++] = *ptr;
if (*ptr == '"')
buf[i++] = '"'; /* escape quotes by doubling them */
}
buf[i++] = '"';
buf[i++] = '.';
}
buf[i++] = '"';
for (ptr = SAFE_NAME(table); *ptr != '\0' && i < buf_size - 3; ptr++)
{
buf[i++] = *ptr;
if (*ptr == '"')
buf[i++] = '"'; /* escape quotes by doubling them */
}
buf[i++] = '"';
buf[i] = '\0';
return buf;
}

106
misc.h Normal file
View File

@ -0,0 +1,106 @@
/* File: misc.h
*
* Description: See "misc.c"
*
* Comments: See "readme.txt" for copyright and license information.
*
*/
#ifndef __MISC_H__
#define __MISC_H__
#include <stdio.h>
#ifndef WIN32
#include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
size_t strncpy_null(char *dst, const char *src, ssize_t len);
#ifndef HAVE_STRLCAT
size_t strlcat(char *, const char *, size_t);
#endif /* HAVE_STRLCAT */
int snprintfcat(char *buf, size_t size, const char *format, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
size_t snprintf_len(char *buf, size_t size, const char *format, ...);
char *my_trim(char *string);
char *make_string(const SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize);
char *quote_table(const pgNAME schema, const pgNAME table, char *buf, int nuf_size);
#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)
ssize_t my_strcpy(char *dst, ssize_t dst_len, const char *src, ssize_t src_len);
/*
* Macros to safely strcpy, strcat or sprintf to fixed arrays.
*
*/
/*
* With GCC, the macro CHECK_NOT_CHAR_P() causes a compilation error
* when the target is pointer not a fixed array.
*/
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
#define FUNCTION_BEGIN_MACRO ({
#define FUNCTION_END_MACRO ;})
#define CHECK_NOT_CHAR_P(t) \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wunused-variable\"") \
if (0) { typeof(t) dummy_for_check = {};} \
_Pragma ("GCC diagnostic pop")
#else
#define FUNCTION_BEGIN_MACRO
#define FUNCTION_END_MACRO
#define CHECK_NOT_CHAR_P(t)
#endif
/* macro to safely strcpy() to fixed arrays. */
#define STRCPY_FIXED(to, from) \
FUNCTION_BEGIN_MACRO \
CHECK_NOT_CHAR_P(to) \
strncpy_null((to), (from), sizeof(to)) \
FUNCTION_END_MACRO
/* macro to safely strcat() to fixed arrays. */
#define STRCAT_FIXED(to, from) \
FUNCTION_BEGIN_MACRO \
CHECK_NOT_CHAR_P(to) \
strlcat((to), (from), sizeof(to)) \
FUNCTION_END_MACRO
#pragma GCC diagnostic push
/* macro to safely sprintf() to fixed arrays. */
#define SPRINTF_FIXED(to, ...) \
FUNCTION_BEGIN_MACRO \
CHECK_NOT_CHAR_P(to) \
snprintf((to), sizeof(to), __VA_ARGS__) \
FUNCTION_END_MACRO
#pragma GCC diagnostic pop
/* macro to safely sprintf() & cat to fixed arrays. */
#define SPRINTFCAT_FIXED(to, ...) \
FUNCTION_BEGIN_MACRO \
CHECK_NOT_CHAR_P(to) \
snprintfcat((to), sizeof(to), __VA_ARGS__) \
FUNCTION_END_MACRO
#define ITOA_FIXED(to, from) \
FUNCTION_BEGIN_MACRO \
CHECK_NOT_CHAR_P(to) \
snprintf((to), sizeof(to), "%d", from) \
FUNCTION_END_MACRO
#ifdef __cplusplus
}
#endif
#endif /* __MISC_H__ */

1324
msdtc_enlist.cpp Normal file

File diff suppressed because it is too large Load Diff

540
multibyte.c Normal file
View File

@ -0,0 +1,540 @@
/*--------
* Module : multibyte.c
*
* Description: New Multibyte related additional function.
*
* Create 2001-03-03 Eiji Tokuya
* New Create 2001-09-16 Eiji Tokuya
*--------
*/
#include "multibyte.h"
#include "misc.h"
#include "connection.h"
#include "pgapifunc.h"
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <locale.h>
#endif
#ifndef TRUE
#define TRUE 1
#endif
typedef struct pg_CS
{
char *name;
int code;
} pg_CS;
static 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 }, /* since 7.3 */
{ "UTF8", UTF8 }, /* since 7.2 */
{ "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 }, /* Arabic since 7.3 */
{ "WIN1258", WIN1258 }, /* Vietnamese since 8.1 */
{ "WIN866", WIN866 }, /* since 8.1 */
{ "WIN874", WIN874 }, /* Thai since 7.3 */
{ "KOI8", KOI8R },
{ "WIN1251", WIN1251 }, /* Cyrillic */
{ "WIN1252", WIN1252 }, /* Western Europe since 8.1 */
{ "ISO_8859_5", ISO_8859_5 },
{ "ISO_8859_6", ISO_8859_6 },
{ "ISO_8859_7", ISO_8859_7 },
{ "ISO_8859_8", ISO_8859_8 },
{ "WIN1250", WIN1250 }, /* Central Europe */
{ "WIN1253", WIN1253 }, /* Greek since 8.2 */
{ "WIN1254", WIN1254 }, /* Turkish since 8.2 */
{ "WIN1255", WIN1255 }, /* Hebrew since 8.2 */
{ "WIN1257", WIN1257 }, /* Baltic(North Europe) since 8.2 */
{ "EUC_JIS_2004", EUC_JIS_2004}, /* EUC for SHIFT-JIS-2004 Japanese, since 8.3 */
{ "SJIS", SJIS },
{ "BIG5", BIG5 },
{ "GBK", GBK }, /* since 7.3 */
{ "UHC", UHC }, /* since 7.3 */
{ "GB18030", GB18030 }, /* since 7.3 */
{ "SHIFT_JIS_2004", SHIFT_JIS_2004 }, /* SHIFT-JIS-2004 Japanese, standard JIS X 0213, since 8.3 */
{ "OTHER", OTHER }
};
static pg_CS CS_Alias[] =
{
{ "UNICODE", UTF8 },
{ "TCVN", WIN1258 },
{ "ALT", WIN866 },
{ "WIN", WIN1251 },
{ "KOI8R", KOI8R },
{ "OTHER", OTHER }
};
int
pg_CS_code(const char *characterset_string)
{
int i, c = -1;
for(i = 0; CS_Table[i].code != OTHER; i++)
{
if (0 == stricmp(characterset_string, CS_Table[i].name))
{
c = CS_Table[i].code;
break;
}
}
if (c < 0)
{
for(i = 0; CS_Alias[i].code != OTHER; i++)
{
if (0 == stricmp(characterset_string, CS_Alias[i].name))
{
c = CS_Alias[i].code;
break;
}
}
}
if (c < 0)
c = OTHER;
return (c);
}
char *
check_client_encoding(const pgNAME conn_settings)
{
const char *cptr, *sptr = NULL;
char *rptr;
BOOL allowed_cmd = TRUE, in_quote = FALSE;
int step = 0;
size_t len = 0;
if (NAME_IS_NULL(conn_settings))
return NULL;
for (cptr = SAFE_NAME(conn_settings); *cptr; cptr++)
{
if (in_quote)
{
if (LITERAL_QUOTE == *cptr)
{
in_quote = FALSE;
continue;
}
}
if (';' == *cptr)
{
allowed_cmd = TRUE;
step = 0;
continue;
}
if (!allowed_cmd)
continue;
if (isspace((unsigned char) *cptr))
continue;
switch (step)
{
case 0:
if (0 != strnicmp(cptr, "set", 3))
{
allowed_cmd = FALSE;
continue;
}
step++;
cptr += 3;
break;
case 1:
if (0 != strnicmp(cptr, "client_encoding", 15))
{
allowed_cmd = FALSE;
continue;
}
step++;
cptr += 15;
if ('=' == *cptr)
cptr--;
break;
case 2:
if (0 == strnicmp(cptr, "to", 2))
cptr += 2;
else if (0 == strnicmp(cptr, "=", 1))
;
else
{
allowed_cmd = FALSE;
continue;
}
step++;
break;
case 3:
if (LITERAL_QUOTE == *cptr)
{
cptr++;
for (sptr = cptr; *cptr && *cptr != LITERAL_QUOTE; cptr++) ;
}
else
{
for (sptr = cptr; ';' != *cptr && IS_NOT_SPACE(*cptr); cptr++) ;
}
len = cptr - sptr;
if (';' == *cptr)
cptr--;
step++;
break;
}
}
if (!sptr)
return NULL;
rptr = malloc(len + 1);
if (!rptr)
return NULL;
memcpy(rptr, sptr, len);
rptr[len] = '\0';
MYLOG(0, "extracted a client_encoding '%s' from conn_settings\n", rptr);
return rptr;
}
int
pg_mb_maxlen(int characterset_code)
{
switch (characterset_code)
{
case UTF8:
return 4;
case EUC_TW:
return 4;
case EUC_JIS_2004:
case EUC_JP:
case GB18030:
return 3;
case SHIFT_JIS_2004:
case SJIS:
case BIG5:
case GBK:
case UHC:
case EUC_CN:
case EUC_KR:
case JOHAB:
return 2;
default:
return 1;
}
}
static 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_2004 Support. */
case SHIFT_JIS_2004:
{
if (stat < 2 &&
character >= 0x81 && character <= 0x9f)
stat = 2;
else if (stat < 2 &&
character >= 0xe0 && character <= 0xef)
stat = 2;
else if (stat < 2 &&
character >= 0xf0 && character <= 0xfc)
stat = 2;
else if (stat == 2)
stat = 1;
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;
case EUC_JIS_2004:
/* 0x8f is JIS X 0212 + JIS X 0213(2) 3 byte */
/* 0x8e is JIS X 0201 2 byte */
/* 0xa0-0xff is JIS X 0213(1) 2 byte */
case EUC_JP:
/* 0x8f is JIS X 0212 3 byte */
/* 0x8e is JIS X 0201 2 byte */
/* 0xa0-0xff is JIS X 0208 2 byte */
{
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;
}
/*
* This function is used to know the encoding corresponding to
* the current locale.
*/
const char *
derive_locale_encoding(const char *dbencoding)
{
const char *wenc = NULL;
#ifdef WIN32
int acp;
#else
const char *loc, *ptr;
#endif /* WIN32 */
if (wenc = getenv("PGCLIENTENCODING"), NULL != wenc) /* environmnt variable */
return wenc;
#ifdef WIN32
acp = GetACP();
if (acp >= 1251 && acp <= 1258)
{
if (stricmp(dbencoding, "SQL_ASCII") == 0)
return wenc;
}
switch (acp)
{
case 932:
wenc = "SJIS";
break;
case 936:
wenc = "GBK";
break;
case 949:
wenc = "UHC";
break;
case 950:
wenc = "BIG5";
break;
case 1250:
wenc = "WIN1250";
break;
case 1251:
wenc = "WIN1251";
break;
case 1256:
wenc = "WIN1256";
break;
case 1252:
if (strnicmp(dbencoding, "LATIN", 5) == 0)
break;
wenc = "WIN1252";
break;
case 1258:
wenc = "WIN1258";
break;
case 1253:
wenc = "WIN1253";
break;
case 1254:
wenc = "WIN1254";
break;
case 1255:
wenc = "WIN1255";
break;
case 1257:
wenc = "WIN1257";
break;
}
#else
/*
* Derive the encoding from the codeset part of the current locale.
*/
loc = setlocale(LC_CTYPE, "");
if (loc && (ptr = strchr(loc, '.')))
{
int enc_no;
ptr++;
if ((enc_no= pg_char_to_encoding(ptr)) >= 0)
wenc = pg_encoding_to_char(enc_no);
MYLOG(0, "locale=%s enc=%s\n", loc, wenc ? wenc : "(null)");
}
#endif /* WIN32 */
return wenc;
}
void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str)
{
encstr->ccsc = ccsc;
encstr->encstr = (const UCHAR *) str;
encstr->pos = -1;
encstr->ccst = 0;
}
int encoded_nextchar(encoded_str *encstr)
{
int chr;
if (encstr->pos >= 0 && !encstr->encstr[encstr->pos])
return 0;
chr = encstr->encstr[++encstr->pos];
encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc);
return chr;
}
ssize_t encoded_position_shift(encoded_str *encstr, size_t shift)
{
encstr->pos += shift;
return encstr->pos;
}
int encoded_byte_check(encoded_str *encstr, size_t abspos)
{
int chr;
chr = encstr->encstr[encstr->pos = abspos];
encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc);
return chr;
}

79
multibyte.h Normal file
View File

@ -0,0 +1,79 @@
#ifndef __MULTIBUYTE_H__
#define __MULTIBUYTE_H__
/*
*
* Multibyte library header ( psqlODBC Only )
*
*/
#include "psqlodbc.h"
#include "qresult.h"
/* PostgreSQL client encoding */
enum {
SQL_ASCII = 0 /* SQL/ASCII */
,EUC_JP /* EUC for Japanese */
,EUC_CN /* EUC for Chinese */
,EUC_KR /* EUC for Korean */
,EUC_TW /* EUC for Taiwan */
,JOHAB
,UTF8 /* Unicode UTF-8 */
,MULE_INTERNAL /* Mule internal code */
,LATIN1 /* ISO-8859 Latin 1 */
,LATIN2 /* ISO-8859 Latin 2 */
,LATIN3 /* ISO-8859 Latin 3 */
,LATIN4 /* ISO-8859 Latin 4 */
,LATIN5 /* ISO-8859 Latin 5 */
,LATIN6 /* ISO-8859 Latin 6 */
,LATIN7 /* ISO-8859 Latin 7 */
,LATIN8 /* ISO-8859 Latin 8 */
,LATIN9 /* ISO-8859 Latin 9 */
,LATIN10 /* ISO-8859 Latin 10 */
,WIN1256 /* Arabic Windows */
,WIN1258 /* Vietnamese Windows */
,WIN866 /* Alternativny Variant (MS-DOS CP866) */
,WIN874 /* Thai Windows */
,KOI8R /* KOI8-R/U */
,WIN1251 /* Cyrillic Windows */
,WIN1252 /* Western Europe Windows */
,ISO_8859_5 /* ISO-8859-5 */
,ISO_8859_6 /* ISO-8859-6 */
,ISO_8859_7 /* ISO-8859-7 */
,ISO_8859_8 /* ISO-8859-8 */
,WIN1250 /* Central Europe Windows */
,WIN1253 /* Greek Windows */
,WIN1254 /* Turkish Windows */
,WIN1255 /* Hebrew Windows */
,WIN1257 /* Baltic(North Europe) Windows */
,EUC_JIS_2004 /* EUC for SHIFT-JIS-2004 Japanese */
,SJIS /* Shift JIS */
,BIG5 /* Big5 */
,GBK /* GBK */
,UHC /* UHC */
,GB18030 /* GB18030 */
,SHIFT_JIS_2004 /* SHIFT-JIS-2004 Japanese, JIS X 0213 */
,OTHER = -1
};
extern int pg_CS_code(const char *stat_string);
/* Old Type Compatible */
typedef struct
{
int ccsc;
const UCHAR *encstr;
ssize_t pos;
int ccst;
} encoded_str;
#define ENCODE_STATUS(enc) ((enc).ccst)
#define ENCODE_PTR(enc) ((enc).encstr + (enc).pos)
#define MBCS_NON_ASCII(enc) (0 != (enc).ccst || (enc).encstr[(enc).pos] >= 0x80)
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 ssize_t encoded_position_shift(encoded_str *encstr, size_t shift);
extern int encoded_byte_check(encoded_str *encstr, size_t abspos);
char *check_client_encoding(const pgNAME sql_string);
const char *derive_locale_encoding(const char *dbencoding);
int pg_mb_maxlen(int characterset_code);
#endif /* __MULTIBUYTE_H__ */

604
mylog.c Normal file
View File

@ -0,0 +1,604 @@
/*-------
* Module: mylog.c
*
* Description: This module contains miscellaneous routines
* such as for debugging/logging and string functions.
*
* Classes: n/a
*
* API functions: none
*
* Comments: See "readme.txt" for copyright and license information.
*-------
*/
#define _MYLOG_FUNCS_IMPLEMENT_
#include "psqlodbc.h"
#include "dlg_specific.h"
#include "misc.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#ifndef WIN32
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#define GENERAL_ERRNO (errno)
#define GENERAL_ERRNO_SET(e) (errno = e)
#else
#define GENERAL_ERRNO (GetLastError())
#define GENERAL_ERRNO_SET(e) SetLastError(e)
#include <process.h> /* Byron: is this where Windows keeps def.
* of getpid ? */
#endif
#ifdef WIN32
#define DIRSEPARATOR "\\"
#define PG_BINARY O_BINARY
#define PG_BINARY_R "rb"
#define PG_BINARY_W "wb"
#define PG_BINARY_A "ab"
#else
#define DIRSEPARATOR "/"
#define PG_BINARY 0
#define PG_BINARY_R "r"
#define PG_BINARY_W "w"
#define PG_BINARY_A "a"
#endif /* WIN32 */
static char *logdir = NULL;
void
generate_filename(const char *dirname, const char *prefix, char *filename, size_t filenamelen)
{
const char *exename = GetExeProgramName();
#ifdef WIN32
int pid;
pid = _getpid();
#else
pid_t pid;
struct passwd *ptr;
ptr = getpwuid(getuid());
if (NULL == ptr)
return;
pid = getpid();
#endif
if (dirname == 0 || filename == 0)
return;
snprintf(filename, filenamelen, "%s%s", dirname, DIRSEPARATOR);
if (prefix != 0)
strlcat(filename, prefix, filenamelen);
if (exename[0])
snprintfcat(filename, filenamelen, "%s_", exename);
#ifndef WIN32
if (ptr)
strlcat(filename, ptr->pw_name, filenamelen);
#endif
snprintfcat(filename, filenamelen, "%u%s", pid, ".log");
return;
}
static void
generate_homefile(const char *prefix, char *filename, size_t filenamelen)
{
char dir[PATH_MAX];
#ifdef WIN32
const char *ptr;
dir[0] = '\0';
if (ptr=getenv("HOMEDRIVE"), NULL != ptr)
strlcat(dir, ptr, filenamelen);
if (ptr=getenv("HOMEPATH"), NULL != ptr)
strlcat(dir, ptr, filenamelen);
#else
STRCPY_FIXED(dir, "~");
#endif /* WIN32 */
generate_filename(dir, prefix, filename, filenamelen);
return;
}
#ifdef WIN32
static char exename[_MAX_FNAME];
#elif defined MAXNAMELEN
static char exename[MAXNAMELEN];
#else
static char exename[256];
#endif
const char *GetExeProgramName()
{
static int init = 1;
if (init)
{
UCHAR *p;
#ifdef WIN32
char pathname[_MAX_PATH];
if (GetModuleFileName(NULL, pathname, sizeof(pathname)) > 0)
_splitpath(pathname, NULL, NULL, exename, NULL);
#else
CSTR flist[] = {"/proc/self/exe", "/proc/curproc/file", "/proc/curproc/exe" };
int i;
char path_name[256];
for (i = 0; i < sizeof(flist) / sizeof(flist[0]); i++)
{
if (readlink(flist[i], path_name, sizeof(path_name)) > 0)
{
STRCPY_FIXED(exename, po_basename(path_name));
break;
}
}
#endif /* WIN32 */
for (p = (UCHAR *) exename; '\0' != *p; p++)
{
if (isalnum(*p))
continue;
switch (*p)
{
case '_':
case '-':
continue;
}
*p = '\0'; /* avoid multi bytes for safety */
break;
}
init = 0;
}
return exename;
}
#if defined(WIN_MULTITHREAD_SUPPORT)
static CRITICAL_SECTION qlog_cs, mylog_cs;
#elif defined(POSIX_MULTITHREAD_SUPPORT)
static pthread_mutex_t qlog_cs, mylog_cs;
#endif /* WIN_MULTITHREAD_SUPPORT */
static int mylog_on = 0, qlog_on = 0;
#if defined(WIN_MULTITHREAD_SUPPORT)
#define INIT_QLOG_CS InitializeCriticalSection(&qlog_cs)
#define ENTER_QLOG_CS EnterCriticalSection(&qlog_cs)
#define LEAVE_QLOG_CS LeaveCriticalSection(&qlog_cs)
#define DELETE_QLOG_CS DeleteCriticalSection(&qlog_cs)
#define INIT_MYLOG_CS InitializeCriticalSection(&mylog_cs)
#define ENTER_MYLOG_CS EnterCriticalSection(&mylog_cs)
#define LEAVE_MYLOG_CS LeaveCriticalSection(&mylog_cs)
#define DELETE_MYLOG_CS DeleteCriticalSection(&mylog_cs)
#elif defined(POSIX_MULTITHREAD_SUPPORT)
#define INIT_QLOG_CS pthread_mutex_init(&qlog_cs,0)
#define ENTER_QLOG_CS pthread_mutex_lock(&qlog_cs)
#define LEAVE_QLOG_CS pthread_mutex_unlock(&qlog_cs)
#define DELETE_QLOG_CS pthread_mutex_destroy(&qlog_cs)
#define INIT_MYLOG_CS pthread_mutex_init(&mylog_cs,0)
#define ENTER_MYLOG_CS pthread_mutex_lock(&mylog_cs)
#define LEAVE_MYLOG_CS pthread_mutex_unlock(&mylog_cs)
#define DELETE_MYLOG_CS pthread_mutex_destroy(&mylog_cs)
#else
#define INIT_QLOG_CS
#define ENTER_QLOG_CS
#define LEAVE_QLOG_CS
#define DELETE_QLOG_CS
#define INIT_MYLOG_CS
#define ENTER_MYLOG_CS
#define LEAVE_MYLOG_CS
#define DELETE_MYLOG_CS
#endif /* WIN_MULTITHREAD_SUPPORT */
#define MYLOGFILE "mylog_"
#ifndef WIN32
#define MYLOGDIR "/tmp"
#else
#define MYLOGDIR "c:"
#endif /* WIN32 */
#define QLOGFILE "psqlodbc_"
#ifndef WIN32
#define QLOGDIR "/tmp"
#else
#define QLOGDIR "c:"
#endif /* WIN32 */
int get_mylog(void)
{
return mylog_on;
}
int get_qlog(void)
{
return qlog_on;
}
const char *po_basename(const char *path)
{
char *p;
if (p = strrchr(path, DIRSEPARATOR[0]), NULL != p)
return p + 1;
return path;
}
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;
ENTER_MYLOG_CS;
if (mylog_onoff)
mylog_on_count += cnopen;
else
mylog_off_count += cnopen;
if (mylog_on_count > 0)
{
if (mylog_onoff > mylog_on)
mylog_on = mylog_onoff;
else if (mylog_on < 1)
mylog_on = 1;
}
else if (mylog_off_count > 0)
mylog_on = 0;
else if (getGlobalDebug() > 0)
mylog_on = getGlobalDebug();
LEAVE_MYLOG_CS;
ENTER_QLOG_CS;
if (qlog_onoff)
qlog_on_count += cnopen;
else
qlog_off_count += cnopen;
if (qlog_on_count > 0)
{
if (qlog_onoff > qlog_on)
qlog_on = qlog_onoff;
else if (qlog_on < 1)
qlog_on = 1;
}
else if (qlog_off_count > 0)
qlog_on = 0;
else if (getGlobalCommlog() > 0)
qlog_on = getGlobalCommlog();
LEAVE_QLOG_CS;
MYLOG(0, "mylog_on=%d qlog_on=%d\n", mylog_on, qlog_on);
}
#ifdef WIN32
#define LOGGING_PROCESS_TIME
#include <direct.h>
#endif /* WIN32 */
#ifdef LOGGING_PROCESS_TIME
#include <mmsystem.h>
static DWORD start_time = 0;
#endif /* LOGGING_PROCESS_TIME */
static FILE *MLOGFP = NULL;
static void MLOG_open()
{
char filebuf[80], errbuf[160];
BOOL open_error = FALSE;
if (MLOGFP) return;
generate_filename(logdir ? logdir : MYLOGDIR, MYLOGFILE, filebuf, sizeof(filebuf));
MLOGFP = fopen(filebuf, PG_BINARY_A);
if (!MLOGFP)
{
int lasterror = GENERAL_ERRNO;
open_error = TRUE;
SPRINTF_FIXED(errbuf, "%s open error %d\n", filebuf, lasterror);
generate_homefile(MYLOGFILE, filebuf, sizeof(filebuf));
MLOGFP = fopen(filebuf, PG_BINARY_A);
}
if (MLOGFP)
{
setbuf(MLOGFP, NULL);
if (open_error)
fputs(errbuf, MLOGFP);
}
}
static int
mylog_misc(unsigned int option, const char *fmt, va_list args)
{
// va_list args;
int gerrno;
BOOL log_threadid = option;
gerrno = GENERAL_ERRNO;
ENTER_MYLOG_CS;
#ifdef LOGGING_PROCESS_TIME
if (!start_time)
start_time = timeGetTime();
#endif /* LOGGING_PROCESS_TIME */
if (!MLOGFP)
{
MLOG_open();
if (!MLOGFP)
mylog_on = 0;
}
if (MLOGFP)
{
if (log_threadid)
{
#ifdef WIN_MULTITHREAD_SUPPORT
#ifdef LOGGING_PROCESS_TIME
DWORD proc_time = timeGetTime() - start_time;
fprintf(MLOGFP, "[%u-%d.%03d]", GetCurrentThreadId(), proc_time / 1000, proc_time % 1000);
#else
fprintf(MLOGFP, "[%u]", GetCurrentThreadId());
#endif /* LOGGING_PROCESS_TIME */
#endif /* WIN_MULTITHREAD_SUPPORT */
#if defined(POSIX_MULTITHREAD_SUPPORT)
fprintf(MLOGFP, "[%lx]", (unsigned long int) pthread_self());
#endif /* POSIX_MULTITHREAD_SUPPORT */
}
vfprintf(MLOGFP, fmt, args);
}
LEAVE_MYLOG_CS;
GENERAL_ERRNO_SET(gerrno);
return 1;
}
DLL_DECLARE int
mylog(const char *fmt,...)
{
int ret = 0;
unsigned int option = 1;
va_list args;
if (!mylog_on) return ret;
va_start(args, fmt);
ret = mylog_misc(option, fmt, args);
va_end(args);
return ret;
}
DLL_DECLARE int
myprintf(const char *fmt,...)
{
int ret = 0;
va_list args;
va_start(args, fmt);
ret = mylog_misc(0, fmt, args);
va_end(args);
return ret;
}
static void mylog_initialize(void)
{
INIT_MYLOG_CS;
}
static void mylog_finalize(void)
{
ENTER_MYLOG_CS;
mylog_on = 0;
if (MLOGFP)
{
fclose(MLOGFP);
MLOGFP = NULL;
}
DELETE_MYLOG_CS;
}
static FILE *QLOGFP = NULL;
static int
qlog_misc(unsigned int option, const char *fmt, va_list args)
{
char filebuf[80];
int gerrno;
if (!qlog_on) return 0;
gerrno = GENERAL_ERRNO;
ENTER_QLOG_CS;
#ifdef LOGGING_PROCESS_TIME
if (!start_time)
start_time = timeGetTime();
#endif /* LOGGING_PROCESS_TIME */
if (!QLOGFP)
{
generate_filename(logdir ? logdir : QLOGDIR, QLOGFILE, filebuf, sizeof(filebuf));
QLOGFP = fopen(filebuf, PG_BINARY_A);
if (!QLOGFP)
{
generate_homefile(QLOGFILE, filebuf, sizeof(filebuf));
QLOGFP = fopen(filebuf, PG_BINARY_A);
}
if (QLOGFP)
setbuf(QLOGFP, NULL);
else
qlog_on = 0;
}
if (QLOGFP)
{
if (option)
{
#ifdef LOGGING_PROCESS_TIME
DWORD proc_time = timeGetTime() - start_time;
fprintf(QLOGFP, "[%d.%03d]", proc_time / 1000, proc_time % 1000);
#endif /* LOGGING_PROCESS_TIME */
}
vfprintf(QLOGFP, fmt, args);
}
LEAVE_QLOG_CS;
GENERAL_ERRNO_SET(gerrno);
return 1;
}
int
qlog(char *fmt,...)
{
int ret = 0;
unsigned int option = 1;
va_list args;
if (!qlog_on) return ret;
va_start(args, fmt);
ret = qlog_misc(option, fmt, args);
va_end(args);
return ret;
}
int
qprintf(char *fmt,...)
{
int ret = 0;
va_list args;
va_start(args, fmt);
ret = qlog_misc(0, fmt, args);
va_end(args);
return ret;
}
static void qlog_initialize(void)
{
INIT_QLOG_CS;
}
static void qlog_finalize(void)
{
ENTER_QLOG_CS;
qlog_on = 0;
if (QLOGFP)
{
fclose(QLOGFP);
QLOGFP = NULL;
}
DELETE_QLOG_CS;
}
static int globalDebug = -1;
int
getGlobalDebug()
{
char temp[16];
if (globalDebug >=0)
return globalDebug;
/* Debug is stored in the driver section */
SQLGetPrivateProfileString(DBMS_NAME, INI_DEBUG, "", temp, sizeof(temp), ODBCINST_INI);
if (temp[0])
globalDebug = atoi(temp);
else
globalDebug = DEFAULT_DEBUG;
return globalDebug;
}
int
setGlobalDebug(int val)
{
return (globalDebug = val);
}
static int globalCommlog = -1;
int
getGlobalCommlog()
{
char temp[16];
if (globalCommlog >= 0)
return globalCommlog;
/* Commlog is stored in the driver section */
SQLGetPrivateProfileString(DBMS_NAME, INI_COMMLOG, "", temp, sizeof(temp), ODBCINST_INI);
if (temp[0])
globalCommlog = atoi(temp);
else
globalCommlog = DEFAULT_COMMLOG;
return globalCommlog;
}
int
setGlobalCommlog(int val)
{
return (globalCommlog = val);
}
int
writeGlobalLogs()
{
char temp[10];
ITOA_FIXED(temp, globalDebug);
SQLWritePrivateProfileString(DBMS_NAME, INI_DEBUG, temp, ODBCINST_INI);
ITOA_FIXED(temp, globalCommlog);
SQLWritePrivateProfileString(DBMS_NAME, INI_COMMLOG, temp, ODBCINST_INI);
return 0;
}
int
getLogDir(char *dir, int dirmax)
{
return SQLGetPrivateProfileString(DBMS_NAME, INI_LOGDIR, "", dir, dirmax, ODBCINST_INI);
}
int
setLogDir(const char *dir)
{
return SQLWritePrivateProfileString(DBMS_NAME, INI_LOGDIR, dir, ODBCINST_INI);
}
/*
* This function starts a logging out of connections according the ODBCINST.INI
* portion of the DBMS_NAME registry.
*/
static void
start_logging()
{
/*
* GlobalDebug or GlobalCommlog means whether take mylog or commlog
* out of the connection time or not but doesn't mean the default of
* ci->drivers.debug(commlog).
*/
logs_on_off(0, 0, 0);
mylog("\t%s:Global.debug&commlog=%d&%d\n", __FUNCTION__, getGlobalDebug(), getGlobalCommlog());
}
void InitializeLogging(void)
{
char dir[PATH_MAX];
getLogDir(dir, sizeof(dir));
if (dir[0])
logdir = strdup(dir);
mylog_initialize();
qlog_initialize();
start_logging();
}
void FinalizeLogging(void)
{
mylog_finalize();
qlog_finalize();
if (logdir)
{
free(logdir);
logdir = NULL;
}
}

90
mylog.h Normal file
View File

@ -0,0 +1,90 @@
/* File: mylog.h
*
* Description: See "mylog.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __MYLOG_H__
#define __MYLOG_H__
#undef DLL_DECLARE
#ifdef WIN32
#ifdef _MYLOG_FUNCS_IMPLEMENT_
#define DLL_DECLARE _declspec(dllexport)
#else
#ifdef _MYLOG_FUNCS_IMPORT_
#define DLL_DECLARE _declspec(dllimport)
#else
#define DLL_DECLARE
#endif /* _MYLOG_FUNCS_IMPORT_ */
#endif /* _MYLOG_FUNCS_IMPLEMENT_ */
#else
#define DLL_DECLARE
#endif /* WIN32 */
#include <stdio.h>
#ifndef WIN32
#include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __GNUC__
#define __attribute__(x)
#endif
DLL_DECLARE int mylog(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
DLL_DECLARE int myprintf(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
extern int qlog(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
extern int qprintf(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
const char *po_basename(const char *path);
#define PREPEND_FMT "%10.10s[%s]%d: "
#define PREPEND_ITEMS ,po_basename(__FILE__), __FUNCTION__, __LINE__
#define QLOG_MARK "[QLOG]"
#ifdef __GNUC__
#define MYLOG(level, fmt, ...) (level < get_mylog() ? mylog(PREPEND_FMT fmt PREPEND_ITEMS, ##__VA_ARGS__) : 0)
#define MYPRINTF(level, fmt, ...) (level < get_mylog() ? myprintf((fmt), ##__VA_ARGS__) : 0)
#define QLOG(level, fmt, ...) ((level < get_qlog() ? qlog((fmt), ##__VA_ARGS__) : 0), MYLOG(level, QLOG_MARK fmt, ##__VA_ARGS__))
#define QPRINTF(level, fmt, ...) ((level < get_qlog() ? qprintf((fmt), ##__VA_ARGS__) : 0), MYPRINTF(level, (fmt), ##__VA_ARGS__))
#elif defined WIN32 /* && _MSC_VER > 1800 */
#define MYLOG(level, fmt, ...) (level < get_mylog() ? mylog(PREPEND_FMT fmt PREPEND_ITEMS, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__)))
#define MYPRINTF(level, fmt, ...) (level < get_mylog() ? myprintf(fmt, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__)))
#define QLOG(level, fmt, ...) ((level < get_qlog() ? qlog((fmt), __VA_ARGS__) : (printf || printf(fmt, __VA_ARGS__))), MYLOG(level, QLOG_MARK fmt, __VA_ARGS__))
#define QPRINTF(level, fmt, ...) ((level < get_qlog() ? qprintf(fmt, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__))), MYPRINTF(level, (fmt), __VA_ARGS__))
#else
#define MYLOG(level, ...) (level < get_mylog() ? (mylog(PREPEND_FMT PREPEND_ITEMS), myprintf(__VA_ARGS__)) : 0)
#define MYPRINTF(level, ...) (level < get_mylog() ? myprintf(__VA_ARGS__) : 0)
#define QLOG(level, ...) ((level < get_qlog() ? qlog(__VA_ARGS__) : 0), MYLOG(level, QLOG_MARK), MYPRINTF(level, __VA_ARGS__))
#define QPRINTF(level, ...) ((level < get_qlog() ? qprintf(__VA_ARGS__) : 0), MYPRINTF(level, __VA_ARGS__))
#endif /* __GNUC__ */
#define MIN_LOG_LEVEL 0
#define TUPLE_LOG_LEVEL 1
#define DETAIL_LOG_LEVEL 2
int get_qlog(void);
int get_mylog(void);
int getGlobalDebug();
int setGlobalDebug(int val);
int getGlobalCommlog();
int setGlobalCommlog(int val);
int writeGlobalLogs();
int getLogDir(char *dir, int dirmax);
int setLogDir(const char *dir);
void InitializeLogging(void);
void FinalizeLogging(void);
#ifdef __cplusplus
}
#endif
#endif /* __MYLOG_H__ */

36
odbc-drop.sql Normal file
View File

@ -0,0 +1,36 @@
DROP FUNCTION "char"(integer);
DROP FUNCTION concat(text, text);
DROP FUNCTION insert(text, integer, integer, text);
DROP FUNCTION lcase(text);
DROP FUNCTION left(text, integer);
DROP FUNCTION locate(text, text);
DROP FUNCTION locate(text, text, integer);
DROP FUNCTION right(text, integer);
DROP FUNCTION space(integer);
DROP FUNCTION ucase(text);
DROP FUNCTION ceiling(numeric);
DROP FUNCTION log10(double precision);
DROP FUNCTION log10(numeric);
DROP FUNCTION power(double precision, double precision);
DROP FUNCTION power(numeric, numeric);
DROP FUNCTION rand();
DROP FUNCTION rand(double precision);
DROP FUNCTION truncate(numeric, integer);
DROP FUNCTION curdate();
DROP FUNCTION curtime();
DROP FUNCTION odbc_timestamp();
DROP FUNCTION dayname(timestamp);
DROP FUNCTION dayofmonth(timestamp);
DROP FUNCTION dayofweek(timestamp);
DROP FUNCTION dayofyear(timestamp);
DROP FUNCTION hour(timestamp);
DROP FUNCTION minute(timestamp);
DROP FUNCTION month(timestamp);
DROP FUNCTION monthname(timestamp);
DROP FUNCTION quarter(timestamp);
DROP FUNCTION second(timestamp);
DROP FUNCTION week(timestamp);
DROP FUNCTION year(timestamp);
DROP FUNCTION odbc_user();
DROP FUNCTION odbc_current_user();
DROP FUNCTION odbc_session_user();

6
odbc-test-gauss/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
!expected/*.log
odbc.ini
regression.diff
results.log
log/

View File

@ -0,0 +1,54 @@
--Author:o00231432 Date:2013-07-27
--update the jdbcconfig.properties
/*
\! sed -i '/user/d' sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcconfig.properties
\! sed -i '/^port/d' sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcconfig.properties
\! sed -i "/dbname/a user=$USER" sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcconfig.properties
\! port=`sed -n '/^port =/p' $GAUSSCN/postgresql.conf |awk -F "=" '{print $2}' |awk '{print $1}'`;sed -i "/dbname/a port=$port" sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcconfig.properties
--update the jdbcboolconfig.properties
\! sed -i '/user/d' sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcboolconfig.properties
\! sed -i '/^port/d' sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcboolconfig.properties
\! sed -i "/dbname/a user=$USER" sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcboolconfig.properties
\! port=`sed -n '/^port =/p' $GAUSSCN/postgresql.conf |awk -F "=" '{print $2}' |awk '{print $1}'`;sed -i "/dbname/a port=$port" sql/MPP_NEW_FEATURE/Interface/JDBC/lib/jdbcboolconfig.properties
create schema FVT_INTERFACE;
--update the odbc.ini and odbcinst.ini
\! sed -i '/Username/d' sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbc.ini
\! sed -i '/^port/d' sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbc.ini
\! sed -i "/Database/a Username=$USER" sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbc.ini
\! port=`sed -n '/^port =/p' $GAUSSCN/postgresql.conf |awk -F "=" '{print $2}' |awk '{print $1}'`;sed -i "/Password/a port=$port" sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbc.ini
\! sed -i '/^Driver64/d' sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbcinst.ini
\! sed -i '/^setup/d' sql/MPP_NEW_FEATURE/Interface/ODBC/lib/odbcinst.ini
\! cd sql/MPP_NEW_FEATURE/Interface/ODBC/lib;odbcpath=`pwd`;sed -i "/Driver/a Driver64=$odbcpath/psqlodbcw.so" odbcinst.ini
\! cd sql/MPP_NEW_FEATURE/Interface/ODBC/lib;odbcpath=`pwd`;sed -i "/Driver64/a setup=$odbcpath/psqlodbcw.so" odbcinst.ini
--prepared for TSjdbc3SavePointTest
\! java junit.textui.TestRunner -m Graft.TSjdbc3SavePointTest.TSjdbc3SavePointTest_pre_000
--prepared for testResultSetTest
\! java junit.textui.TestRunner -m Graft.testResultSetTest.testResultSet_pre_000
-- This file creates some tables to be used in the tests
*/
create schema info_dev_sys_view;
create schema FVT_INTERFACE;
CREATE TABLE testtab1 (id integer, t varchar(20));
INSERT INTO testtab1 VALUES (1, 'foo');
INSERT INTO testtab1 VALUES (2, 'bar');
INSERT INTO testtab1 VALUES (3, 'foobar');
CREATE TABLE byteatab (id integer, t bytea);
INSERT INTO byteatab VALUES (1, E'\\001\\002\\003\\004\\005\\006\\007\\010'::bytea);
INSERT INTO byteatab VALUES (2, 'bar');
INSERT INTO byteatab VALUES (3, 'foobar');
INSERT INTO byteatab VALUES (4, 'foo');
INSERT INTO byteatab VALUES (5, 'barf');
CREATE TABLE intervaltable(id integer, iv interval, d varchar(100));
INSERT INTO intervaltable VALUES (1, '1 day', 'one day');
INSERT INTO intervaltable VALUES (2, '10 seconds', 'ten secs');
INSERT INTO intervaltable VALUES (3, '100 years', 'hundred years');
CREATE TABLE booltab (id integer, t varchar(5), b boolean);
INSERT INTO booltab VALUES (1, 'yeah', true);
INSERT INTO booltab VALUES (2, 'yes', true);
INSERT INTO booltab VALUES (3, 'true', true);
INSERT INTO booltab VALUES (4, 'false', false);
INSERT INTO booltab VALUES (5, 'not', false);

101
odbc-test-gauss/Makefile Normal file
View File

@ -0,0 +1,101 @@
CC=gcc
deps:=common.o
ifndef cases
cases:= arraybinding-test \
boolsaschar-test \
odbc_capital_01 \
odbc_capital_02 \
odbc_capital_03 \
odbc_capital_04 \
odbc_capital_05 \
odbc_capital_06 \
odbc_capital_07 \
odbc_null_adapt_01 \
odbc_null_adapt_02 \
odbc_null_adapt_03 \
odbc_null_adapt_04 \
odbc_null_adapt_05 \
odbc_null_adapt_06 \
odbc_nvarchar2_01_SQLGetData \
odbc_nvarchar2_02_SQLColAttribute \
odbc_nvarchar2_03_SQLColumns \
odbc_nvarchar2_04_SQLPrimaryKeys \
odbc_nvarchar2_07_SQLDescribeCol \
odbc_nvarchar2_09_SQLProcedureColumns \
odbc_nvarchar2_10_manycol \
odbc_nvarchar2_11_out \
odbc_sha256 \
odbc_smalldatetime_01_SQLPrimaryKeys \
odbc_smalldatetime_02_SQLColumn \
odbc_smalldatetime_03_SQLBindParameter \
odbc_smalldatetime_04_SQLColAttribute \
odbc_smalldatetime_05_SQLGetData \
odbc_smalldatetime_06_SQLDescribeCol \
odbc_smalldatetime_07_SQLProcedureColumns \
odbc_SQLAllocConnect \
odbc_SQLAllocEnv \
odbc_SQLCancel \
odbc_SQLDescribeParam \
odbc_SQLExtendedFetch \
odbc_SQLGetConnectAttr \
odbc_SQLGetConnectOption \
odbc_SQLGetDescField \
odbc_SQLGetDiagField \
odbc_SQLGetEnvAttr \
odbc_SQLGetFunction \
odbc_SQLGetInfo \
odbc_SQLGetStmtAttr \
odbc_SQLNumParams \
odbc_SQLSetDescField \
odbc_SQLStatistics \
odbc_SQLTables \
odbc_stmt_timeout_01_pg_sleep \
odbc_stmt_timeout_02_select \
odbc_stmt_timeout_03_procedure \
odbc_stmt_timeout_04 \
odbc_stmt_timeout_05 \
odbc_stmt_timeout_06 \
odbc_tinyint_01_SQLBindCol \
odbc_tinyint_02_SQLColumn \
odbc_tinyint_03_SQLBindParameter \
odbc_tinyint_04_SQLColAttribute \
odbc_tinyint_05_SQLGetData \
odbc_tinyint_06_SQLGetTypeInfo \
odbc_tinyint_07_SQLPrimaryKeys \
odbc_tinyint_08_SQLDescribeCol \
odbc_tinyint_09_SQLProcedureColumns \
odbc_tinyint_10_manycol \
odbc_transaction_01 \
odbc_transaction_02 \
odbc_transaction_03 \
notice-test \
dataatexecution-test \
odbc_getresult-test \
params-test \
prepare-test \
insertreturning-test \
select-test \
connect-test \
cvtnulldate-test \
stmthandles-test \
odbc_batch_insert \
odbc_connection_info \
odbc_DTS2019070108437 \
odbc_transaction_for_extension_connector \
odbc_DTS2019071815351
endif
all: $(cases)
%: %.c
$(CC) -l odbc -O0 -g -o $@ $< $(deps)
$(deps):common.c common.h
$(CC) -O0 -g -c -o common.o common.c
clean:
rm -f $(cases) *.o *.diff && rm -rf log
test: all
time -p bash ./run.sh $(cases)

View File

@ -0,0 +1,240 @@
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#define ARRAY_SIZE 10000
#define ARRAY_SIZE_SMALL 5
int main(int argc, char **argv)
{
SQLRETURN rc;
HSTMT hstmt = SQL_NULL_HSTMT;
char *sql;
int i;
SQLUINTEGER int_array[ARRAY_SIZE];
SQLCHAR str_array[ARRAY_SIZE][30];
SQLCHAR str_array2[ARRAY_SIZE][6];
SQLLEN int_ind_array[ARRAY_SIZE];
SQLLEN str_ind_array[ARRAY_SIZE];
SQLUSMALLINT status_array[ARRAY_SIZE];
SQLULEN nprocessed;
test_connect();
rc = SQLAllocStmt(conn, &hstmt);
if (!SQL_SUCCEEDED(rc))
{
print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
exit(1);
}
sql = "CREATE TABLE FVT_INTERFACE.tmptable (i int4, t text)";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt);
sql = "set current_schema='FVT_INTERFACE'";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed while set current_schema", hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/****
* 1. Test column-wise binding
*/
for (i = 0; i < ARRAY_SIZE; i++)
{
int_array[i] = i;
int_ind_array[i] = 0;
sprintf(str_array[i], "columnwise %d", i);
str_ind_array[i] = SQL_NTS;
}
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &nprocessed, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) ARRAY_SIZE, 0);
/* Bind the parameter arrays. */
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0,
int_array, 0, int_ind_array);
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 29, 0,
str_array, 30, str_ind_array);
/* Execute */
sql = "INSERT INTO FVT_INTERFACE.tmptable VALUES (?, ?)";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
/* Fetch results */
printf("Parameter Status\n");
for (i = 0; i < nprocessed; i++)
{
switch (status_array[i])
{
case SQL_PARAM_SUCCESS:
case SQL_PARAM_SUCCESS_WITH_INFO:
break;
case SQL_PARAM_ERROR:
{
printf("%d\tError\n", i);
return -1;
}
case SQL_PARAM_UNUSED:
{
printf("%d\tUnused\n", i);
return -1;
}
case SQL_PARAM_DIAG_UNAVAILABLE:
{
printf("%d\tDiag unavailable\n", i);
return -1;
}
}
}
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/*
* Free and allocate a new handle for the next SELECT statement, as we don't
* want to array bind that one. The parameters set with SQLSetStmtAttr
* survive SQLFreeStmt.
*/
rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
CHECK_STMT_RESULT(rc, "SQLFreeHandle failed", hstmt);
rc = SQLAllocStmt(conn, &hstmt);
if (!SQL_SUCCEEDED(rc))
{
print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
exit(1);
}
/* Check that all the rows were inserted */
sql = "SELECT COUNT(*) FROM FVT_INTERFACE.tmptable";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/* Check the contents of a few rows */
sql = "SELECT * FROM FVT_INTERFACE.tmptable WHERE i IN (0, 1, 100, 9999, 10000) ORDER BY i";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/****
* 2. Test column-wise binding. With a column_size=5 VARCHAR param - that
* causes the driver to do a server-side prepare, assuming BoolsAsChar=1.
*/
/* a small array will do for this test */
for (i = 0; i < ARRAY_SIZE_SMALL; i++)
{
sprintf(str_array2[i], "%d", 100+i);
str_ind_array[i] = SQL_NTS;
}
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &nprocessed, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) ARRAY_SIZE_SMALL, 0);
/* Bind the parameter array. */
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 5, 0,
str_array2, 6, str_ind_array);
/* Execute */
sql = "DELETE FROM FVT_INTERFACE.tmptable WHERE i = ? RETURNING (t)";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
/* Fetch results */
printf("Parameter Status\n");
for (i = 0; i < nprocessed; i++)
{
switch (status_array[i])
{
case SQL_PARAM_SUCCESS:
case SQL_PARAM_SUCCESS_WITH_INFO:
break;
case SQL_PARAM_ERROR:
printf("%d\tError\n", i);
break;
case SQL_PARAM_UNUSED:
printf("%d\tUnused\n", i);
break;
case SQL_PARAM_DIAG_UNAVAILABLE:
printf("%d\tDiag unavailable\n", i);
break;
}
}
printf ("Fetching result sets for array bound (%d results expected or 1 result if batch protocol is on)\n",
nprocessed);
for (i = 1; rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO; i++)
{
printf("%d: ", i);
print_result(hstmt);
rc = SQLMoreResults(hstmt);
}
if (rc != SQL_NO_DATA)
CHECK_STMT_RESULT(rc, "SQLMoreResults failed", hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/*
* Free and allocate a new handle for the next SELECT statement, as we don't
* want to array bind that one. The parameters set with SQLSetStmtAttr
* survive SQLFreeStmt.
*/
rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
CHECK_STMT_RESULT(rc, "SQLFreeHandle failed", hstmt);
rc = SQLAllocStmt(conn, &hstmt);
if (!SQL_SUCCEEDED(rc))
{
print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
exit(1);
}
/* Check that all the rows were inserted */
printf("Number of rows in table:\n");
sql = "SELECT COUNT(*) FROM FVT_INTERFACE.tmptable";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/* Check the contents of a few rows */
sql = "SELECT * FROM FVT_INTERFACE.tmptable WHERE i IN (0, 1, 100, 9999, 10000) ORDER BY i";
rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/* Clean up */
test_disconnect();
return 0;
}

View File

@ -0,0 +1,86 @@
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
int main(int argc, char **argv)
{
SQLRETURN rc;
HSTMT hstmt = SQL_NULL_HSTMT;
char *param1;
SQLLEN cbParam1;
long longparam;
SQL_INTERVAL_STRUCT intervalparam;
SQLSMALLINT colcount;
/* BoolsAsChar is the default, but just in case.. */
test_connect_ext("BoolsAsChar=1;UseServerSidePrepare=1");
rc = SQLAllocStmt(conn, &hstmt);
if (!SQL_SUCCEEDED(rc))
{
print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
exit(1);
}
/**** A simple query with one text param ****/
/* Prepare a statement */
rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t, b FROM booltab WHERE t = ? order by id", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
/* bind param */
param1 = "yes";
cbParam1 = SQL_NTS;
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_CHAR, /* value type */
SQL_VARCHAR, /* param type */
5, /* column size */
0, /* dec digits */
param1, /* param value ptr */
0, /* buffer len */
&cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* Execute */
rc = SQLExecute(hstmt);
CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt);
/* Fetch result */
print_result_meta(hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/**** A simple query with one boolean param (passed as varchar) ****/
/* bind param */
param1 = "true";
cbParam1 = SQL_NTS;
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_CHAR, /* value type */
SQL_VARCHAR, /* param type */
5, /* column size */
0, /* dec digits */
param1, /* param value ptr */
0, /* buffer len */
&cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* Execute */
rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, t, b FROM booltab WHERE b = ? order by id", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
/* Fetch result */
print_result_meta(hstmt);
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/* Clean up */
test_disconnect();
return 0;
}

253
odbc-test-gauss/common.c Normal file
View File

@ -0,0 +1,253 @@
#include "common.h"
SQLHENV env;
SQLHDBC conn;
void
print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle)
{
char sqlstate[32];
char message[1000];
SQLINTEGER nativeerror;
SQLSMALLINT textlen;
SQLRETURN ret;
if (msg)
printf("%s\n", msg);
ret = SQLGetDiagRec(htype, handle, 1, sqlstate, &nativeerror,
message, 256, &textlen);
if (ret != SQL_ERROR)
printf("%s=%s\n", (CHAR *)sqlstate, (CHAR *)message);
}
void
test_connect_ext(char *extraparams)
{
SQLRETURN ret;
SQLCHAR str[1024];
SQLSMALLINT strl;
SQLCHAR dsn[1024];
snprintf(dsn, sizeof(dsn), "DSN=gaussdb;username=odbc;password=Gauss@123;%s",
extraparams ? extraparams : "");
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, env, &conn);
ret = SQLDriverConnect(conn, NULL, dsn, SQL_NTS,
str, sizeof(str), &strl,
SQL_DRIVER_COMPLETE);
if (SQL_SUCCEEDED(ret)) {
printf("connected\n");
} else {
print_diag("SQLDriverConnect failed.", SQL_HANDLE_DBC, conn);
exit(1);
}
}
void
test_connect(void)
{
test_connect_ext(NULL);
}
void
test_disconnect(void)
{
SQLRETURN rc;
printf("disconnecting\n");
rc = SQLDisconnect(conn);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLDisconnect failed", SQL_HANDLE_DBC, conn);
exit(1);
}
rc = SQLFreeConnect(conn);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLFreeConnect failed", SQL_HANDLE_DBC, conn);
exit(1);
}
conn = NULL;
rc = SQLFreeEnv(env);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLFreeEnv failed", SQL_HANDLE_ENV, env);
exit(1);
}
env = NULL;
}
static const char *
datatype_str(SQLSMALLINT datatype)
{
static char buf[100];
switch (datatype)
{
case SQL_CHAR:
return "CHAR";
case SQL_VARCHAR:
return "VARCHAR";
case SQL_LONGVARCHAR:
return "LONGVARCHAR";
case SQL_WCHAR:
return "WCHAR";
case SQL_WVARCHAR:
return "WVARCHAR";
case SQL_WLONGVARCHAR:
return "WLONGVARCHAR";
case SQL_DECIMAL:
return "DECIMAL";
case SQL_NUMERIC:
return "NUMERIC";
case SQL_SMALLINT:
return "SMALLINT";
case SQL_INTEGER:
return "INTEGER";
case SQL_REAL:
return "REAL";
case SQL_FLOAT:
return "FLOAT";
case SQL_DOUBLE:
return "DOUBLE";
case SQL_BIT:
return "BIT";
case SQL_TINYINT:
return "TINYINT";
case SQL_BIGINT:
return "BIGINT";
case SQL_BINARY:
return "BINARY";
case SQL_VARBINARY:
return "VARBINARY";
case SQL_LONGVARBINARY:
return "LONGVARBINARY";
case SQL_TYPE_DATE:
return "TYPE_DATE";
case SQL_TYPE_TIME:
return "TYPE_TIME";
case SQL_TYPE_TIMESTAMP:
return "TYPE_TIMESTAMP";
case SQL_GUID:
return "GUID";
default:
snprintf(buf, sizeof(buf), "unknown sql type %d", datatype);
return buf;
}
}
static const char *nullable_str(SQLSMALLINT nullable)
{
static char buf[100];
switch(nullable)
{
case SQL_NO_NULLS:
return "not nullable";
case SQL_NULLABLE:
return "nullable";
case SQL_NULLABLE_UNKNOWN:
return "nullable_unknown";
default:
snprintf(buf, sizeof(buf), "unknown nullable value %d", nullable);
return buf;
}
}
void
print_result_meta(HSTMT hstmt)
{
SQLRETURN rc;
SQLSMALLINT numcols;
int i;
rc = SQLNumResultCols(hstmt, &numcols);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt);
return;
}
printf("Result set metadata:\n");
for (i = 1; i <= numcols; i++)
{
SQLCHAR colname[50];
SQLSMALLINT colnamelen;
SQLSMALLINT datatype;
SQLULEN colsize;
SQLSMALLINT decdigits;
SQLSMALLINT nullable;
rc = SQLDescribeCol(hstmt, i,
colname, sizeof(colname),
&colnamelen,
&datatype,
&colsize,
&decdigits,
&nullable);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLDescribeCol failed", SQL_HANDLE_STMT, hstmt);
return;
}
printf("%s: %s(%d) digits: %d, %s\n",
colname, datatype_str(datatype), colsize,
decdigits, nullable_str(nullable));
}
}
void
print_result(HSTMT hstmt)
{
SQLRETURN rc;
SQLSMALLINT numcols;
rc = SQLNumResultCols(hstmt, &numcols);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt);
return;
}
printf("Result set:\n");
while(1)
{
rc = SQLFetch(hstmt);
if (rc == SQL_NO_DATA)
break;
if (rc == SQL_SUCCESS)
{
char buf[40];
int i;
SQLLEN ind;
for (i = 1; i <= numcols; i++)
{
rc = SQLGetData(hstmt,i, SQL_C_CHAR, buf, sizeof(buf), &ind);
if (!SQL_SUCCEEDED(rc))
{
print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt);
return;
}
if (ind == SQL_NULL_DATA)
strcpy(buf, "NULL");
printf("%s%s", (i > 1) ? "\t" : "", buf);
}
printf("\n");
}
else
{
print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt);
exit(1);
}
}
}

31
odbc-test-gauss/common.h Normal file
View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>
#ifdef WIN32
#define snprintf _snprintf
#endif
extern SQLHENV env;
extern SQLHDBC conn;
#define CHECK_STMT_RESULT(rc, msg, hstmt) \
if (!SQL_SUCCEEDED(rc)) \
{ \
print_diag(msg, SQL_HANDLE_STMT, hstmt); \
exit(1); \
}
extern void print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle);
extern void test_connect_ext(char *extraparams);
extern void test_connect(void);
extern void test_disconnect(void);
extern void print_result_meta(HSTMT hstmt);
extern void print_result(HSTMT hstmt);

View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
int main(int argc, char **argv)
{
test_connect();
test_disconnect();
}

Some files were not shown because too many files have changed in this diff Show More