diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8286bff --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,108 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +PROJECT(PSQLODBC) + +SET(CMAKE_VERBOSE_MAKEFILEON ON) + +MESSAGE(STATUS "Building PSQLODBC Library.") + +IF(NOT DEFINED OPENSSL_DIR) + set(OPENSSL_DIR "D:\\Program_Files\\OpenSSL-Win32") +ENDIF(NOT DEFINED OPENSSL_DIR) +IF(NOT DEFINED MINGW_DIR) + set(MINGW_DIR "D:\\buildtools\\mingw-8.1.0\\msys32\\mingw32") +ENDIF(NOT DEFINED MINGW_DIR) + +SET(PWD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +SET(LIBPQ_DIR ${PWD_DIR}/libpq) +SET(MINGW32_DIR ${MINGW_DIR}/"i686-w64-mingw32") +SET(LIBRARY_OUTPUT_PATH ${PWD_DIR}/output) + +SET(DEF_FILE ${PWD_DIR}/psqlodbc.def) +SET(RC_FILE ${PWD_DIR}/psqlodbc.rc) + +SET(CMAKE_CXX_COMPILER "${MINGW_DIR}/bin/i686-w64-mingw32-gcc") +SET(CMAKE_SHARED_LINKER_FLAGS "-static -Wl,--enable-stdcall-fixup") #-static-libgcc -static-libstdc++ + +IF(NOT DEFINED RELEASE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=gnu++11 -DWIN32 -D_MINGW32 -DUNICODE_SUPPORT -DWIN_MULTITHREAD_SUPPORT -DDRIVER_CURSOR_IMPLEMENT -fpermissive -fPIC -m32 -Wno-dev -w") +ELSE(NOT DEFINED RELEASE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu++11 -DWIN32 -D_MINGW32 -DUNICODE_SUPPORT -DWIN_MULTITHREAD_SUPPORT -DDRIVER_CURSOR_IMPLEMENT -fpermissive -fPIC -m32 -Wno-dev -w") +ENDIF(NOT DEFINED RELEASE) + +SET(CMAKE_RC_COMPILER "${MINGW_DIR}/bin/windres") +SET(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -Jrc -I${CMAKE_CURRENT_SOURCE_DIR} ") + +INCLUDE_DIRECTORIES(${PWD_DIR} + ${LIBPQ_DIR}/include + ${LIBPQ_DIR}/include/libpq + ${MINGW_DIR}/include + ${MINGW32_DIR}/include) + +SET(SRC_LIST ${PWD_DIR}/bind.c + ${PWD_DIR}/columninfo.c + ${PWD_DIR}/connection.c + ${PWD_DIR}/convert.c + ${PWD_DIR}/descriptor.c + ${PWD_DIR}/dlg_specific.c + ${PWD_DIR}/dlg_wingui.c + ${PWD_DIR}/drvconn.c + ${PWD_DIR}/environ.c + ${PWD_DIR}/execute.c + ${PWD_DIR}/info.c + ${PWD_DIR}/inouealc.c + ${PWD_DIR}/loadlib.c + ${PWD_DIR}/lobj.c + ${PWD_DIR}/misc.c + ${PWD_DIR}/multibyte.c + ${PWD_DIR}/mylog.c + ${PWD_DIR}/odbcapi.c + ${PWD_DIR}/odbcapi30.c + ${PWD_DIR}/odbcapi30w.c + ${PWD_DIR}/odbcapiw.c + ${PWD_DIR}/options.c + ${PWD_DIR}/parse.c + ${PWD_DIR}/pgapi30.c + ${PWD_DIR}/pgtypes.c + ${PWD_DIR}/psqlodbc.c + ${PWD_DIR}/qresult.c + ${PWD_DIR}/results.c + ${PWD_DIR}/setup.c + ${PWD_DIR}/statement.c + ${PWD_DIR}/tuple.c + ${PWD_DIR}/win_unicode.c + ${RC_FILE}) + +LINK_DIRECTORIES(${MINGW_DIR}/bin + ${MINGW_DIR}/lib + ${MINGW32_DIR}/lib) + +ADD_LIBRARY(OBJ_PSQLODBC OBJECT ${SRC_LIST}) +SET_PROPERTY(TARGET OBJ_PSQLODBC PROPERTY POSITION_INDEPENDENT_CODE 1) + +ADD_LIBRARY(LIB_PSQLODBC STATIC $) +SET_TARGET_PROPERTIES(LIB_PSQLODBC PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(LIB_PSQLODBC PROPERTIES OUTPUT_NAME "psqlodbc35w") +SET_TARGET_PROPERTIES(LIB_PSQLODBC PROPERTIES SUFFIX ".lib") + +ADD_LIBRARY(DLL_PSQLODBC SHARED $ ${DEF_FILE}) +SET_TARGET_PROPERTIES(DLL_PSQLODBC PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(DLL_PSQLODBC PROPERTIES OUTPUT_NAME "psqlodbc35w") + +FIND_LIBRARY(LIB_CRYPTO NAMES crypto PATHS ${OPENSSL_DIR}/lib) +FIND_LIBRARY(LIB_SSL NAMES ssl PATHS ${OPENSSL_DIR}/lib) +FIND_LIBRARY(LIB_SECUREC NAMES securec PATHS ${LIBPQ_DIR}/lib) +FIND_LIBRARY(LIB_LIBPQ NAMES pq PATHS ${LIBPQ_DIR}/lib) + +TARGET_LINK_LIBRARIES(DLL_PSQLODBC + ${LIB_LIBPQ} + -lodbc32 + -lodbccp32 + -lwsock32 + -lws2_32 + -lsecur32 + -lwinmm + -lsecurity + -lgdi32 + ${LIB_CRYPTO} + ${LIB_SSL} + ${LIB_SECUREC}) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d19fb6f --- /dev/null +++ b/Makefile @@ -0,0 +1,167 @@ +################################################################# +## Makefile for building ODBC library on Windows using MinGW ## +################################################################# + +ifndef $(OPENSSL_DIR) + OPENSSL_DIR:=/d/Program_Files/OpenSSL-Win32 +endif + +ifndef $(MINGW_DIR) + MINGW_DIR:=/d/buildtools/mingw-8.1.0/msys32/mingw32 +endif + +PWD_DIR:=$(shell pwd) +LIBPQ_DIR:=$(PWD_DIR)/libpq +MINGW32_DIR:=$(MINGW_DIR)/i686-w64-mingw32 + +OUT_DIR:=$(PWD_DIR)/output +OBJ_DIR:=$(PWD_DIR)/obj + +DLL_TARGET:=$(OUT_DIR)/psqlodbc35w.dll +LIB_TARGET:=$(OUT_DIR)/psqlodbc35w.lib + +CC:=$(MINGW_DIR)/bin/i686-w64-mingw32-gcc +AR:=$(MINGW_DIR)/bin/i686-w64-mingw32-gcc-ar +RC_CC:=$(MINGW_DIR)/bin/windres + +MD:=mkdir -p +RM:=rm -rf + +DEFFILE:=$(PWD_DIR)/psqlodbc.def + +CCFLAG:=-std=gnu++11 \ + -DWIN32 \ + -D_MINGW32 \ + -DUNICODE_SUPPORT \ + -DWIN_MULTITHREAD_SUPPORT \ + -DDRIVER_CURSOR_IMPLEMENT \ + -fpermissive \ + -fPIC \ + -w \ + -m32 + +ifdef RELEASE + CCFLAG:=$(CCFLAG) -O2 +else + CCFLAG:=$(CCFLAG) -g +endif + +LFLAG:=-L$(OPENSSL_DIR)/lib \ + -L$(LIBPQ_DIR)/lib \ + -L$(MINGW_DIR)/bin \ + -L$(MINGW32_DIR)/lib \ + -llibpq \ + -lodbc32 \ + -lodbccp32 \ + -lwinmm \ + -lws2_32 \ + -llibsecurec \ + -lsecurity \ + -llibcrypto \ + -llibssl \ + -lgdi32 \ + -Wl,--enable-stdcall-fixup,--out-implib,$(DLL_TARGET) + +RC_SRC:=$(PWD_DIR)/psqlodbc.rc +RC_OBJ:=$(OBJ_DIR)/psqlodbc_rc.o + +INC:=-I$(PWD_DIR) \ + -I$(LIBPQ_DIR)/include \ + -I$(LIBPQ_DIR)/include/libpq \ + -I$(MINGW_DIR)/include \ + -I$(MINGW32_DIR)/include + +SRC:=$(PWD_DIR)/bind.c \ + $(PWD_DIR)/columninfo.c \ + $(PWD_DIR)/connection.c \ + $(PWD_DIR)/convert.c \ + $(PWD_DIR)/descriptor.c \ + $(PWD_DIR)/dlg_specific.c \ + $(PWD_DIR)/dlg_wingui.c \ + $(PWD_DIR)/drvconn.c \ + $(PWD_DIR)/environ.c \ + $(PWD_DIR)/execute.c \ + $(PWD_DIR)/info.c \ + $(PWD_DIR)/inouealc.c \ + $(PWD_DIR)/loadlib.c \ + $(PWD_DIR)/lobj.c \ + $(PWD_DIR)/misc.c \ + $(PWD_DIR)/multibyte.c \ + $(PWD_DIR)/mylog.c \ + $(PWD_DIR)/odbcapi.c \ + $(PWD_DIR)/odbcapi30.c \ + $(PWD_DIR)/odbcapi30w.c \ + $(PWD_DIR)/odbcapiw.c \ + $(PWD_DIR)/options.c \ + $(PWD_DIR)/parse.c \ + $(PWD_DIR)/pgapi30.c \ + $(PWD_DIR)/pgtypes.c \ + $(PWD_DIR)/psqlodbc.c \ + $(PWD_DIR)/qresult.c \ + $(PWD_DIR)/results.c \ + $(PWD_DIR)/setup.c \ + $(PWD_DIR)/statement.c \ + $(PWD_DIR)/tuple.c \ + $(PWD_DIR)/win_unicode.c + +OBJ:=$(OBJ_DIR)/bind.o \ + $(OBJ_DIR)/columninfo.o \ + $(OBJ_DIR)/connection.o \ + $(OBJ_DIR)/convert.o \ + $(OBJ_DIR)/descriptor.o \ + $(OBJ_DIR)/dlg_specific.o \ + $(OBJ_DIR)/dlg_wingui.o \ + $(OBJ_DIR)/drvconn.o \ + $(OBJ_DIR)/environ.o \ + $(OBJ_DIR)/execute.o \ + $(OBJ_DIR)/info.o \ + $(OBJ_DIR)/inouealc.o \ + $(OBJ_DIR)/loadlib.o \ + $(OBJ_DIR)/lobj.o \ + $(OBJ_DIR)/misc.o \ + $(OBJ_DIR)/multibyte.o \ + $(OBJ_DIR)/mylog.o \ + $(OBJ_DIR)/odbcapi.o \ + $(OBJ_DIR)/odbcapi30.o \ + $(OBJ_DIR)/odbcapi30w.o \ + $(OBJ_DIR)/odbcapiw.o \ + $(OBJ_DIR)/options.o \ + $(OBJ_DIR)/parse.o \ + $(OBJ_DIR)/pgapi30.o \ + $(OBJ_DIR)/pgtypes.o \ + $(OBJ_DIR)/psqlodbc.o \ + $(OBJ_DIR)/qresult.o \ + $(OBJ_DIR)/results.o \ + $(OBJ_DIR)/setup.o \ + $(OBJ_DIR)/statement.o \ + $(OBJ_DIR)/tuple.o \ + $(OBJ_DIR)/win_unicode.o + +SRC_TO_OBJ=$(OBJ_DIR)/$(patsubst %.c,%.o, $(notdir $(1))) + +define BUILD_OBJ +$(call SRC_TO_OBJ,$(1)):$(1) + $(CC) $(CCFLAG) $(INC) -c $$^ -o $$@ +endef + +#$(RC_OBJ):$(RC_SRC) +# $(RC_CC) -Jrc -I$(PWD_DIR) $(RC_SRC) -o $(RC_OBJ) + +all:dirs $(OBJ) + $(RC_CC) -Jrc -I$(PWD_DIR) $(RC_SRC) -o $(RC_OBJ) + $(CC) $(OBJ) $(RC_OBJ) $(DEFFILE) -static -shared -o $(DLL_TARGET) $(LFLAG) + $(AR) rcs $(LIB_TARGET) $(OBJ) $(RC_OBJ) +dirs: + $(MD) $(OBJ_DIR) + $(MD) $(OUT_DIR) + +clean: + $(RM) $(OBJ_DIR) + $(RM) $(OUT_DIR) + +$(foreach c,$(SRC),$(eval $(call BUILD_OBJ,$(c)))) + +.PHONY: all clean dirs +################################################################# +## THE END OF PSQLODBC MINGW32 Makefile ## +################################################################# diff --git a/build.sh b/build.sh index 794f016..50c0fe6 100755 --- a/build.sh +++ b/build.sh @@ -29,6 +29,9 @@ elif [ -f "/etc/openEuler-release" ]; then elif [ -f "/etc/centos-release" ]; then kernel=$(cat /etc/centos-release | awk -F ' ' '{print $1}' | tr A-Z a-z) version=$(cat /etc/centos-release | awk -F '(' '{print $2}'| awk -F ')' '{print $1}' | tr A-Z a-z) +elif [ -f "/etc/kylin-release" ]; then + kernel=$(cat /etc/kylin-release | awk -F ' ' '{print $1}' | tr A-Z a-z) + version=$(cat /etc/kylin-release | awk '{print $6}' | tr A-Z a-z) else kernel=$(lsb_release -d | awk -F ' ' '{print $2}'| tr A-Z a-z) version=$(lsb_release -r | awk -F ' ' '{print $2}') @@ -40,25 +43,20 @@ elif [ X"$kernel" == X"centos" ]; then dist_version="CENTOS" elif [ X"$kernel" == X"openeuler" ]; then dist_version="OPENEULER" +elif [ X"$kernel" == X"kylin" ]; then + dist_version="KYLIN" +elif [ X"$kernel" == X"suse" ]; then + dist_version="SUSE" else - echo "We only support EulerOS, OPENEULER(aarch64) and CentOS platform." + echo "We only support EulerOS, OPENEULER(aarch64), SUSE and CentOS platform." echo "Kernel is $kernel" exit 1 fi -NOTICE_FILE='Copyright Notice.doc' - -plat=$(uname -p) -if [ x$kernel$version$plat != x"eulerossp5x86_64" ] && [ x$kernel$version$plat != x"eulerossp8aarch64" ] && [ x$kernel$version$plat != x"eulerossp2x86_64" ] -then - echo "WARN: Building unixODBC platform other than EulerOS_SP5_x86_64 and EulerOS_SP8_aarch64 is experimental" -fi - - ##default install version storage path declare mppdb_version='GaussDB Kernel' declare mppdb_name_for_package="$(echo ${mppdb_version} | sed 's/ /-/g')" -declare version_number='V500R001C20' +declare version_number='V500R002C10' ####################################################################### ## print help information ####################################################################### @@ -102,6 +100,15 @@ while [ $# -gt 0 ]; do serverlib_dir=$2 shift 2 ;; + -ud|--unixodbc_dir) + if [ "$2"X = X ]; then + echo "no given unixodbc directory values" + exit 1 + fi + UNIX_ODBC=$2 + shift 2 + ;; + *) echo "Internal Error: option processing error: $1" 1>&2 echo "please input right paramtenter, the following command may help you" @@ -132,7 +139,6 @@ SERVERLIBS_PATH="${serverlib_dir}" ################################## COMPLIE_TYPE="comm" echo "[makeodbc] $(date +%y-%m-%d' '%T): Work root dir : ${LOCAL_DIR}" -UNIX_ODBC="${LOCAL_DIR}/third_party/unixodbc/install_comm/unixODBC-2.3.9" ####################################################################### # Print log. ####################################################################### @@ -170,10 +176,6 @@ function clean_environment() ####################################################################### function install_odbc() { - echo "Begin make odbc..." >> "$LOG_FILE" 2>&1 - - cd ${LOCAL_DIR}/third_party/unixodbc/ - sh ./build_unixodbc.sh -m build >> "$LOG_FILE" 2>&1 cd ${LOCAL_DIR} export GAUSSHOME=$SERVERLIBS_PATH @@ -242,7 +244,7 @@ function target_file_copy() cp $SERVERLIBS_PATH/lib/libpgport_tool* ${BUILD_DIR}/lib cp $SERVERLIBS_PATH/lib/libcom_err_gauss* ${BUILD_DIR}/lib - cp $LOCAL_DIR/third_party/unixodbc/install_comm/unixODBC-2.3.9/lib/libodbcinst* ${BUILD_DIR}/lib + cp $UNIX_ODBC/lib/libodb* ${BUILD_DIR}/lib } ####################################################################### @@ -256,10 +258,9 @@ function make_package() target_file_copy select_package_command - cp ${LOCAL_DIR}/"${NOTICE_FILE}" ./ echo "packaging odbc..." - $package_command "${odbc_package_name}" ./lib ./odbc "${NOTICE_FILE}" >>"$LOG_FILE" 2>&1 + $package_command "${odbc_package_name}" ./lib ./odbc >>"$LOG_FILE" 2>&1 if [ $? -ne 0 ]; then die "$package_command ${odbc_package_name} failed" fi diff --git a/connection.c b/connection.c index 940b8d9..b70658a 100644 --- a/connection.c +++ b/connection.c @@ -19,16 +19,18 @@ #define _WIN32_WINNT 0x0400 #endif /* _WIN32_WINNT */ -#include "connection.h" -#include "misc.h" - -#include -#include #include +#include +#include +#include +#include +#include +#include /* for htonl */ #ifdef WIN32 #include +#include #else #include #endif @@ -45,6 +47,8 @@ #include #endif +#include "connection.h" +#include "misc.h" #include "environ.h" #include "statement.h" #include "qresult.h" @@ -58,15 +62,427 @@ #define SAFE_STR(s) (NULL != (s) ? (s) : "(null)") -#define STMT_INCREMENT 16 /* how many statement holders to allocate - * at a time */ +/* how many statement holders to allocate + * at a time + */ +#define STMT_INCREMENT 16 + +#define MAX_CN 128 /* the maximum number of CN is 128 */ +#define EMPTY 0 +#define CORRECT 1 +#define WRONG 2 +#define lenNameType 63 + +BOOL conn_inited = FALSE; +BOOL conn_precheck = FALSE; +pthread_rwlock_t init_lock = PTHREAD_RWLOCK_INITIALIZER; +int refresh_flag = 0; +unsigned long int pgxc_node_thread_id; + +typedef struct CnEntry { + char ip_list[MAX_CN][MEDIUM_REGISTRY_LEN]; /* a char array to store IPs */ + int ip_status[MAX_CN]; /* an integer array that indicates the status of IPs */ + char port_list[MAX_CN][SMALL_REGISTRY_LEN]; /* a char array that stores port */ + int port_status[MAX_CN]; /* an integer array that indicates the status of IPs */ + int ip_count; /* define integer to record the number of IPs stored in the IP_list */ + int port_count; /* + * define integer to record the number of IPs stored in the IP_list + * this should be equal to IP_count + */ + int step[MAX_CN]; /* record the offset for roundRobin when autobalance is on */ + BOOL is_usable; + pthread_rwlock_t ip_list_lock; /* define a lock to isolate read and write to ip_list */ + pthread_rwlock_t step_lock[MAX_CN]; /* define a lock to isolate read and write to step */ +} CnEntry; + +typedef struct dsn_time { + char *DSN; + int timeinterval; +} dsn_time; + +CnEntry orig_entry; +CnEntry pgxc_entry; + +static int LIBPQ_connect(ConnectionClass *self); + +#ifdef WIN32 +DWORD WINAPI read_pgxc_node(LPVOID arg) +#else +static void *read_pgxc_node(void *arg) +#endif +{ + dsn_time read_cn; + read_cn = *(dsn_time *) arg; + char *DSN = malloc(strlen(read_cn.DSN) + 1); + if (DSN == NULL) { + exit(1); + } + strncpy_null(DSN, read_cn.DSN, strlen(read_cn.DSN) + 1); + read_cn.DSN = DSN; + int time = read_cn.timeinterval; +#ifdef WIN32 + pgxc_node_thread_id = GetCurrentThreadId(); +#else + pgxc_node_thread_id = pthread_self(); +#endif + int refresh_count = 0; + /* read CNs' IP from pgxc_node */ + for (;;) { + MYLOG(0, "REFRESH starts\n"); + SQLHENV hEnv = SQL_NULL_HENV; + SQLHDBC hDbc = SQL_NULL_HDBC; + SQLHSTMT hStmt = SQL_NULL_HSTMT; + SQLRETURN rc = SQL_SUCCESS; + SQLINTEGER RETCODE = 0; + char node_port[SMALL_REGISTRY_LEN]; + char node_host[lenNameType]; + SQLLEN lenPort=0, lenHost=0; + RETCODE = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv); + if (RETCODE != SQL_SUCCESS) { + continue; + } + SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3, 0); + RETCODE = SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hDbc); + if (RETCODE != SQL_SUCCESS) { + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + continue; + } + RETCODE = SQLConnect(hDbc, // Connect handle + (SQLCHAR *)DSN, //DSN + SQL_NTS, // DSN is nul-terminated + NULL, // Null UID + 0 , + NULL, // Null Auth string + 0); + if (RETCODE != SQL_SUCCESS) { + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + continue; + } + RETCODE = SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt); + if (RETCODE != SQL_SUCCESS) { + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + continue; + } + RETCODE = SQLExecDirect(hStmt,"select node_port, node_host from pgxc_node where node_type = 'C' and nodeis_active order by node_name",SQL_NTS); + if (RETCODE != SQL_SUCCESS) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + SQLDisconnect(hDbc); + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + continue; + } + RETCODE = SQLBindCol(hStmt, 1, SQL_C_CHAR, node_port, SMALL_REGISTRY_LEN, &lenPort); + RETCODE = SQLBindCol(hStmt, 2, SQL_C_CHAR, node_host, lenNameType + 1, &lenHost); + if (RETCODE != SQL_SUCCESS) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + SQLDisconnect(hDbc); + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + continue; + } + int count = 0; + char IP_list_temp[MAX_CN][MEDIUM_REGISTRY_LEN]; + char port_list_temp[MAX_CN][SMALL_REGISTRY_LEN]; + char port_temp[SMALL_REGISTRY_LEN]; + while ((rc = SQLFetch(hStmt)) == SQL_SUCCESS) { + refresh_flag = 1; + STRCPY_FIXED(IP_list_temp[count], node_host); + STRCPY_FIXED(port_list_temp[count++], node_port); + pgxc_entry.ip_count = count; + } + refresh_count++; + + if (refresh_count > 10 && rc == SQL_ERROR) { + refresh_flag = 1; + MYLOG(0, "Refresh failed for ten times, change signal and unlock other threads.\n"); + } + + int i; + if (count != 0 && pthread_rwlock_wrlock(&pgxc_entry.ip_list_lock) == 0) { + for (i = 0; i < pgxc_entry.ip_count; i++) { + STRCPY_FIXED(pgxc_entry.ip_list[i], IP_list_temp[i]); + STRCPY_FIXED(pgxc_entry.port_list[i], port_list_temp[i]); + MYLOG(0, "ip = %s, port = %s\n", pgxc_entry.ip_list[i], pgxc_entry.port_list[i]); + } + MYLOG(0, "CN list has been refreshed.\n"); + if (pthread_rwlock_unlock(&pgxc_entry.ip_list_lock) != 0) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + SQLDisconnect(hDbc); + SQLFreeHandle(SQL_HANDLE_DBC, hDbc); + SQLFreeHandle(SQL_HANDLE_ENV, hEnv); + MYLOG(0, "Unlock failed. Exit process.\n"); + exit(1); + } + } + SQLDisconnect(hDbc); + sleep(time); + } +} + +static BOOL check_IP_connection(ConnectionClass *conn, CnEntry *entry) +{ + int i; + int pqret; + BOOL ret = FALSE; + ConnInfo *ci = &conn->connInfo; + + if (conn == NULL) { + return FALSE; + } + MYLOG(0, "Start checking the connection for each pair of IP and PORT.\n"); + if (entry == &pgxc_entry) { + pthread_rwlock_rdlock(&entry->ip_list_lock); + } + for (i = 0; i < entry->ip_count; i++) { + STRCPY_FIXED(ci->server, entry->ip_list[i]); + STRCPY_FIXED(ci->port, entry->port_list[i]); + if ((pqret = LIBPQ_connect(conn)) <= 0) { + /* connection failed, kick out the wrong IP from IP_list and write the wrong IP into log */ + MYLOG(0, "Cannot establish connection via IP: %s\n", entry->ip_list[i]); + entry->ip_status[i] = WRONG; + } else { + /* connection successful, current IP remains in IP_list but disconnect */ + entry->ip_status[i] = CORRECT; + PQfinish(conn->pqconn); + ret = TRUE; + } + } + MYLOG(0, "Check finished.\n"); + if (entry == &pgxc_entry) { + pthread_rwlock_unlock(&entry->ip_list_lock); + } + return ret; +} + +static void start_new_thread(dsn_time *read_cn) +{ +#ifdef WIN32 + CreateThread(NULL, 0, read_pgxc_node, (LPVOID)(read_cn), 0, NULL); +#else + pthread_t ntid; + pthread_create(&ntid, NULL, read_pgxc_node, read_cn); +#endif +} + +static RETCODE init_conn(ConnectionClass *conn) +{ + RETCODE ret = SQL_SUCCESS; + ConnInfo *ci = &conn->connInfo; + if (conn == NULL) { + return SQL_ERROR; + } + + /* initialize */ + memset(&pgxc_entry, 0, sizeof(CnEntry)); + memset(&orig_entry, 0, sizeof(CnEntry)); + pgxc_entry.is_usable = TRUE; + orig_entry.is_usable = TRUE; + + int i; + for (i = 0; i < MAX_CN; i++) { + pthread_rwlock_init(&pgxc_entry.step_lock[i], NULL); + pthread_rwlock_init(&orig_entry.step_lock[i], NULL); + } + pthread_rwlock_init(&pgxc_entry.ip_list_lock, NULL); + pthread_rwlock_init(&orig_entry.ip_list_lock, NULL); + + /* make a copy of ci->server and ci->port to prevent changing the original conn when parsing it */ + char server[LARGE_REGISTRY_LEN]; + STRCPY_FIXED(server, ci->server); + char port[LARGE_REGISTRY_LEN]; + STRCPY_FIXED(port, ci->port); + + /* parsing ci->server to seperate IPs and store them into IP_list */ + char *p = strtok(server, ","); + while (p != NULL) { + STRCPY_FIXED(orig_entry.ip_list[orig_entry.ip_count++], p); + STRCPY_FIXED(pgxc_entry.ip_list[pgxc_entry.ip_count++], p); + p = strtok(NULL, ","); + } + + /* parsing ci->port to seperate PORTs and store them into port_list */ + p = strtok(port, ","); + while (p != NULL) { + STRCPY_FIXED(orig_entry.port_list[orig_entry.port_count++], p); + STRCPY_FIXED(pgxc_entry.port_list[pgxc_entry.port_count++], p); + p = strtok(NULL, ","); + } + + /* if only one port was configured, then each CN has the same port by default */ + if (orig_entry.port_count == 1) { + for (i = 1; i < orig_entry.ip_count; i++) { + STRCPY_FIXED(orig_entry.port_list[orig_entry.port_count++], orig_entry.port_list[0]); + STRCPY_FIXED(pgxc_entry.port_list[pgxc_entry.port_count++], pgxc_entry.port_list[0]); + } + } + + /* if serverl ports were configured, the number of ports has to be equal to the number of IPs */ + if (orig_entry.ip_count != orig_entry.port_count) { + MYLOG(0, "The number of IP %d does not match the number of Port %d.\n", orig_entry.ip_count, orig_entry.port_count); + return SQL_ERROR; + } + + /* check the connection of each pair of IP and port and update the list and status */ + if (!check_IP_connection(conn, &orig_entry)) { + return SQL_ERROR; + } + memcpy(pgxc_entry.ip_status, orig_entry.ip_status, sizeof(orig_entry.ip_status)); + + /* start new thread to connect to datbase and select node_port from pgxc_node */ + dsn_time read_cn; + read_cn.DSN = ci->dsn; + if (ci->refreshcnlisttime == 0) { + read_cn.timeinterval = 10; + } else { + read_cn.timeinterval = ci->refreshcnlisttime; + } + start_new_thread(&read_cn); + return ret; +} + +int get_location(BOOL *visited, CnEntry *entry, int *visited_count) +{ + if (visited == NULL || entry == NULL || visited_count == NULL) { + return -1; + } + /* select random IP from ip_list */ + srand(pthread_self()); + unsigned int ind = rand() % entry->ip_count; + + /* record the offset of each IP for roundRobin */ + int *offset = &entry->step[ind]; + pthread_rwlock_t *offset_lock = &entry->step_lock[ind]; + + /* + * if the selected IP can be connected and has not been visited, connect to this IP + * else enter the while loop to choose another IP for connect + * use visited_count to record the number of IPs that have been visited + * visited_count equals to ip_count means reaching the limit + */ + while ((entry->ip_status[ind] == WRONG || visited[ind] == TRUE) && (*visited_count) != entry->ip_count) { + if (visited[ind] == FALSE) { + visited[ind] = TRUE; + (*visited_count)++; + } + + pthread_rwlock_wrlock(offset_lock); + while (visited[ind] == TRUE && (*visited_count) != entry->ip_count) { + ind = ind + *offset; + (*offset)++; + ind = ind % entry->ip_count; + } + pthread_rwlock_unlock(offset_lock); + } + + /* + * the selected IP after the while loop should not have been visited + * if it has been visited, return error + */ + if (visited[ind] == TRUE) { + return -1; + } + + visited[ind] = TRUE; + (*visited_count)++; + return ind; +} + +static RETCODE connect_random_IP(ConnectionClass *conn, CnEntry *entry) +{ + RETCODE ret = SQL_ERROR; + ConnInfo *ci = &conn->connInfo; + CSTR func = "PGAPI_Connect"; + char fchar; + BOOL visited[MAX_CN] = {FALSE}; + int visited_count = 0; + BOOL check_ret = check_IP_connection(conn, entry); + + /* only connection successful and all connection failed will break the while loop */ + while (ret == SQL_ERROR) { + if (entry == &pgxc_entry && pthread_rwlock_rdlock(&entry->ip_list_lock) != 0) { + return SQL_ERROR; + } + + int ind = get_location(visited, entry, &visited_count); + if (ind == -1) { + pthread_rwlock_unlock(&entry->ip_list_lock); + return SQL_ERROR; + } + + STRCPY_FIXED(ci->server, entry->ip_list[ind]); + STRCPY_FIXED(ci->port, entry->port_list[ind]); + while (entry == &pgxc_entry && pthread_rwlock_unlock(&entry->ip_list_lock) != 0); + if ((fchar = CC_connect(conn, NULL)) <= 0) { + /* Error messages are filled in */ + CC_log_error(func, "Error on CC_connect", conn); + ret = SQL_ERROR; + } else { + ret = SQL_SUCCESS; + } + } + if (ret == SQL_SUCCESS && fchar == 2) { + ret = SQL_SUCCESS_WITH_INFO; + } + MYLOG(0, "leaving..%d.\n", ret); + /* Empty the password stored in memory to avoid password leak */ + if (NAME_IS_VALID(ci->password)) + memset(ci->password.name, 0, strlen(ci->password.name)); + return ret; +} + +static RETCODE connect_IP(ConnectionClass *conn) +{ + if (conn->connInfo.priority == 1 && orig_entry.is_usable && connect_random_IP(conn, &orig_entry) != SQL_ERROR) { + return SQL_SUCCESS; + } + + return connect_random_IP(conn, &pgxc_entry); +} + +static RETCODE check_and_init(ConnectionClass *conn) +{ + if (conn_precheck) { + return SQL_SUCCESS; + } + if (pthread_rwlock_rdlock(&init_lock)) { + return SQL_ERROR; + } + + if (conn_inited) { + pthread_rwlock_unlock(&init_lock); + return SQL_SUCCESS; + } + + pthread_rwlock_unlock(&init_lock); + + if (pthread_rwlock_wrlock(&init_lock)) { + return SQL_ERROR; + } + + if (conn_inited) { + pthread_rwlock_unlock(&init_lock); + return SQL_SUCCESS; + } + + if (init_conn(conn) != SQL_SUCCESS) { + pthread_rwlock_unlock(&init_lock); + return SQL_ERROR; + } else { + conn_inited = TRUE; + } + + pthread_rwlock_unlock(&init_lock); + conn_precheck = TRUE; + return SQL_SUCCESS; +} static SQLRETURN CC_lookup_lo(ConnectionClass *self); static int CC_close_eof_cursors(ConnectionClass *self); static void LIBPQ_update_transaction_status(ConnectionClass *self); - static void CC_set_error_if_not_set(ConnectionClass *self, int errornumber, const char *errormsg, const char *func) { int errornum = CC_get_errornumber(self); @@ -141,8 +557,6 @@ PGAPI_Connect(HDBC hdbc, RETCODE ret = SQL_SUCCESS; char fchar, *tmpstr; - MYLOG(0, "entering..cbDSN=%hi.\n", cbDSN); - if (!conn) { CC_log_error(func, "", NULL); @@ -161,6 +575,8 @@ PGAPI_Connect(HDBC hdbc, /* initialize pg_version from connInfo.protocol */ CC_initialize_pg_version(conn); + MYLOG(0, "entering..cbDSN=%hi.\n", cbDSN); + /* * override values from DSN info with UID and authStr(pwd) This only * occurs if the values are actually there. @@ -179,20 +595,40 @@ PGAPI_Connect(HDBC hdbc, MYLOG(0, "conn = %p (DSN='%s', UID='%s', PWD='%s')\n", conn, ci->dsn, ci->username, NAME_IS_VALID(ci->password) ? "xxxxx" : ""); - if ((fchar = CC_connect(conn, NULL)) <= 0) - { - /* Error messages are filled in */ - CC_log_error(func, "Error on CC_connect", conn); - ret = SQL_ERROR; + if (ci->autobalance == 1) { + if (check_and_init(conn) != SQL_SUCCESS) { + return SQL_ERROR; + } + +#ifdef WIN32 + if (GetCurrentThreadId() != pgxc_node_thread_id) +#else + if (pthread_self() != pgxc_node_thread_id) +#endif + { + while (refresh_flag != 1) { +#ifdef WIN32 + sleep(10); +#else + usleep(10000); +#endif + } + } + ret = connect_IP(conn); + } + else { + if ((fchar = CC_connect(conn, NULL)) <= 0) { + CC_log_error(func, "Error on CC_connect", conn); + ret = SQL_ERROR; + } + if (SQL_SUCCESS == ret && 2 == fchar) { + ret = SQL_SUCCESS_WITH_INFO; + } + MYLOG(0, "leaving..%d.\n", ret); + if (NAME_IS_VALID(ci->password)) { + memset(ci->password.name, 0, strlen(ci->password.name)); + } } - if (SQL_SUCCESS == ret && 2 == fchar) - ret = SQL_SUCCESS_WITH_INFO; - - MYLOG(0, "leaving..%d.\n", ret); - /* Empty the password stored in memory to avoid password leak */ - if (NAME_IS_VALID(ci->password)) - memset(ci->password.name, 0, strlen(ci->password.name)); - return ret; } @@ -1055,7 +1491,6 @@ static int handle_show_results(const QResultClass *res); #define TRANSACTION_ISOLATION "transaction_isolation" #define ISOLATION_SHOW_QUERY "show " TRANSACTION_ISOLATION -static int LIBPQ_connect(ConnectionClass *self); static char LIBPQ_CC_connect(ConnectionClass *self, char *salt_para) { @@ -3003,6 +3438,10 @@ LIBPQ_connect(ConnectionClass *self) } opts[cnt] = "connection_info"; vals[cnt++] = local_conninfo; } + + opts[cnt] = "target_session_attrs"; + vals[cnt++] = "primary"; + if (conninfoOption != NULL) { const char *keyword, *val; @@ -3032,17 +3471,25 @@ LIBPQ_connect(ConnectionClass *self) } } } + opts[cnt] = vals[cnt] = NULL; /* Ok, we're all set to connect */ if (get_qlog() > 0 || get_mylog() > 0) { const char **popt, **pval; + const char* pwdKey = "password"; QLOG(0, "PQconnectdbParams:"); - for (popt = opts, pval = vals; *popt; popt++, pval++) - QPRINTF(0, " %s='%s'", *popt, *pval); - QPRINTF(0, "\n"); + + for (popt = opts, pval = vals; *popt; popt++, pval++) { + if (strcmp(pwdKey, *popt) == 0) { + QPRINTF(0, " %s='xxxxx'", *popt); + } else { + QPRINTF(0, " %s='%s'", *popt, *pval); + } + } + QPRINTF(0, "\n"); } pqconn = PQconnectdbParams(opts, vals, FALSE); if (!pqconn) @@ -3084,7 +3531,7 @@ MYLOG(DETAIL_LOG_LEVEL, "status=%d\n", pqret); memset(pwd, 0, strlen(pwd)); } - MYLOG(0, "libpq connection to the database established.\n"); + MYLOG(0, "libpq connection to the database established.(IP: %s)\n", PQhost(pqconn)); pversion = PQprotocolVersion(pqconn); if (pversion < 3) { diff --git a/dlg_specific.c b/dlg_specific.c index ae650c8..c8d428c 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -674,6 +674,12 @@ copyConnAttributes(ConnInfo *ci, const char *attribute, char *value) ci->keepalive_idle = atoi(value); else if (stricmp(attribute, INI_KEEPALIVEINTERVAL) == 0 || stricmp(attribute, ABBR_KEEPALIVEINTERVAL) == 0) ci->keepalive_interval = atoi(value); + else if (stricmp(attribute, INI_AUTOBALANCE) == 0 || stricmp(attribute, ABBR_AUTOBALANCE) == 0) + ci->autobalance = atoi(value); + else if (stricmp(attribute, INI_REFRESHCNLISTTIME) == 0 || stricmp(attribute, ABBR_REFRESHCNLISTTIME) == 0) + ci->refreshcnlisttime = atoi(value); + else if (stricmp(attribute, INI_PRIORITY) == 0 || stricmp(attribute, ABBR_PRIORITY) == 0) + ci->priority = atoi(value); else if (stricmp(attribute, INI_SSLMODE) == 0 || stricmp(attribute, ABBR_SSLMODE) == 0) { switch (value[0]) @@ -862,6 +868,7 @@ static void Global_defset(GLOBAL_VALUES *comval) comval->bools_as_char = DEFAULT_BOOLSASCHAR; STRCPY_FIXED(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES); STRCPY_FIXED(comval->protocol, DEFAULT_PROTOCOL); + comval->for_extension_connector = DEFAULT_FOREXTENSIONCONNECTOR; } static void @@ -1075,6 +1082,21 @@ MYLOG(0, "drivername=%s\n", drivername); MYLOG(0, "force_abbrev=%d bde=%d cvt_null_date=%d\n", ci->force_abbrev_connstr, ci->bde_environment, ci->cvt_null_date_string); } + if (SQLGetPrivateProfileString(DSN, INI_AUTOBALANCE, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) { + ci->autobalance = atoi(temp); + } + + if (SQLGetPrivateProfileString(DSN, INI_REFRESHCNLISTTIME, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) { + ci->refreshcnlisttime = atoi(temp); + } + + if (SQLGetPrivateProfileString(DSN, INI_PRIORITY, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) { + ci->priority = atoi(temp); + if (ci->priority != 1) { + ci->priority = 0; + } + } + /* Allow override of odbcinst.ini parameters here */ get_Ci_Drivers(DSN, ODBC_INI, &(ci->drivers)); STR_TO_NAME(ci->drivers.drivername, drivername); @@ -1352,6 +1374,22 @@ writeDSNinfo(const ConnInfo *ci) ITOA_FIXED(temp, ci->xa_opt); SQLWritePrivateProfileString(DSN, INI_XAOPT, temp, ODBC_INI); #endif /* _HANDLE_ENLIST_IN_DTC_ */ + + ITOA_FIXED(temp, ci->autobalance); + SQLWritePrivateProfileString(DSN, + INI_AUTOBALANCE, + temp, + ODBC_INI); + ITOA_FIXED(temp, ci->refreshcnlisttime); + SQLWritePrivateProfileString(DSN, + INI_REFRESHCNLISTTIME, + temp, + ODBC_INI); + ITOA_FIXED(temp, ci->priority); + SQLWritePrivateProfileString(DSN, + INI_PRIORITY, + temp, + ODBC_INI); } @@ -1862,6 +1900,9 @@ CC_copy_conninfo(ConnInfo *ci, const ConnInfo *sci) CORR_VALCPY(extra_opts); CORR_VALCPY(keepalive_idle); CORR_VALCPY(keepalive_interval); + CORR_VALCPY(autobalance); + CORR_VALCPY(refreshcnlisttime); + CORR_VALCPY(priority); #ifdef _HANDLE_ENLIST_IN_DTC_ CORR_VALCPY(xa_opt); #endif diff --git a/dlg_specific.h b/dlg_specific.h index 68ba1e1..0a2e412 100644 --- a/dlg_specific.h +++ b/dlg_specific.h @@ -178,6 +178,12 @@ extern "C" { /* Whether to use batch protocol ('U' message) while batch executing. */ #define INI_USEBATCHPROTOCOL "UseBatchProtocol" +#define INI_AUTOBALANCE "AutoBalance" /* Control the switch of autobalance */ +#define ABBR_AUTOBALANCE "AuB" +#define INI_REFRESHCNLISTTIME "RefreshCNListTime" +#define ABBR_REFRESHCNLISTTIME "RT" +#define INI_PRIORITY "Priority" +#define ABBR_PRIORITY "PR" #define SSLMODE_DISABLE "disable" #define SSLMODE_ALLOW "allow" #define SSLMODE_PREFER "prefer" @@ -233,7 +239,7 @@ extern "C" { #define DEFAULT_PROTOCOL "7.4" /* the latest protocol is * the default */ #define DEFAULT_USEDECLAREFETCH 0 -#define DEFAULT_FOREXTENSIONCONNECTOR 0 +#define DEFAULT_FOREXTENSIONCONNECTOR 1 #define DEFAULT_TEXTASLONGVARCHAR 1 #define DEFAULT_UNKNOWNSASLONGVARCHAR 0 #define DEFAULT_BOOLSASCHAR 1 diff --git a/dlg_wingui.c b/dlg_wingui.c index a4f0b49..02a9e3c 100644 --- a/dlg_wingui.c +++ b/dlg_wingui.c @@ -72,6 +72,20 @@ SetDlgStuff(HWND hdlg, const ConnInfo *ci) SetDlgItemText(hdlg, IDC_PASSWORD, SAFE_NAME(ci->password)); SetDlgItemText(hdlg, IDC_PORT, ci->port); + char buf[128]; + if (ci->autobalance > 0) { + ITOA_FIXED(buf, ci->autobalance); + SetDlgItemText(hdlg, IDC_AB, buf); + } + if (ci->refreshcnlisttime > 0) { + ITOA_FIXED(buf, ci->refreshcnlisttime); + SetDlgItemText(hdlg, IDC_RT, buf); + } + if (ci->priority > 0) { + ITOA_FIXED(buf, ci->priority); + SetDlgItemText(hdlg, IDC_PR, buf); + } + dsplevel = 0; /* @@ -124,6 +138,21 @@ GetDlgStuff(HWND hdlg, ConnInfo *ci) 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); + + char temp[64]; + int val; + + GetDlgItemText(hdlg, IDC_AB, temp, sizeof(temp)); + val = atoi(temp); + ci->autobalance = val; + + GetDlgItemText(hdlg, IDC_RT, temp, sizeof(temp)); + val = atoi(temp); + ci->refreshcnlisttime = val; + + GetDlgItemText(hdlg, IDC_PR, temp, sizeof(temp)); + val = atoi(temp); + ci->priority = val; } static void diff --git a/drvconn.c b/drvconn.c index 39b56f6..b3c7ff1 100644 --- a/drvconn.c +++ b/drvconn.c @@ -406,6 +406,12 @@ dconn_FDriverConnectProc( SetFocus(GetDlgItem(hdlg, IDC_PORT)); else if (ci->username[0] == '\0') SetFocus(GetDlgItem(hdlg, IDC_USER)); + else if (ci->autobalance == 0) + SetFocus(GetDlgItem(hdlg, IDC_AB)); + else if (ci->refreshcnlisttime == 0) + SetFocus(GetDlgItem(hdlg, IDC_RT)); + else if (ci->priority == 0) + SetFocus(GetDlgItem(hdlg, IDC_PR)); break; case WM_COMMAND: diff --git a/info.c b/info.c index 901f0c3..ffe98ba 100644 --- a/info.c +++ b/info.c @@ -5108,7 +5108,7 @@ MYLOG(0, "atttypid=%s\n", atttypid ? atttypid : "(null)"); params = QR_get_value_backend_text(tres, i, ext_pos + 2); if ('{' == *proargmodes) proargmodes++; - if ('{' == *params) + if (params != NULL && '{' == *params) params++; } else diff --git a/installer/psqlodbcm.wxs b/installer/psqlodbcm.wxs index 926201c..f2f9f8a 100644 --- a/installer/psqlodbcm.wxs +++ b/installer/psqlodbcm.wxs @@ -19,11 +19,9 @@ - - - - - + + + diff --git a/mylog.h b/mylog.h index 2a2e734..9a4ffaf 100644 --- a/mylog.h +++ b/mylog.h @@ -12,10 +12,18 @@ #undef DLL_DECLARE #ifdef WIN32 #ifdef _MYLOG_FUNCS_IMPLEMENT_ +#ifdef _MINGW32 +#define DLL_DECLARE __declspec(dllexport) +#else #define DLL_DECLARE _declspec(dllexport) +#endif #else #ifdef _MYLOG_FUNCS_IMPORT_ +#ifdef _MINGW32 +#define DLL_DECLARE __declspec(dllimport) +#else #define DLL_DECLARE _declspec(dllimport) +#endif #else #define DLL_DECLARE #endif /* _MYLOG_FUNCS_IMPORT_ */ diff --git a/pgapi30.c b/pgapi30.c index e7a8b0f..a2b7233 100644 --- a/pgapi30.c +++ b/pgapi30.c @@ -398,6 +398,11 @@ PGAPI_GetConnectAttr(HDBC ConnectionHandle, ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret = SQL_SUCCESS; SQLINTEGER len = 4; + + if (Value == NULL) { + CC_set_error(conn, CONN_VALUE_OUT_OF_RANGE, "Invalid Connection value", "PGAPI_GetConnectOption"); + return SQL_ERROR; + } MYLOG(0, "entering %d\n", Attribute); switch (Attribute) diff --git a/psqlodbc.def b/psqlodbc.def index 69fc9b8..f019330 100644 --- a/psqlodbc.def +++ b/psqlodbc.def @@ -47,7 +47,7 @@ SQLNumParams @63 ;SQLProcedureColumns @66 ;SQLProcedures @67 SQLSetPos @68 -SQLSetScrollOptions @69 +;SQLSetScrollOptions @69 ;SQLTablePrivileges @70 SQLBindParameter @72 diff --git a/psqlodbc.h b/psqlodbc.h index cdf4cfd..b081d73 100644 --- a/psqlodbc.h +++ b/psqlodbc.h @@ -121,8 +121,12 @@ extern const char *odbcVersionString; #define ULONG_PTR ULONG #define LONG_PTR LONG #define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam) +#ifdef _MINGW32 +#define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER) +#else #define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER); #endif +#endif #else #include "iodbc.h" #include "isql.h" @@ -604,11 +608,11 @@ typedef struct char dsn[MEDIUM_REGISTRY_LEN]; char desc[MEDIUM_REGISTRY_LEN]; char drivername[MEDIUM_REGISTRY_LEN]; - char server[MEDIUM_REGISTRY_LEN]; + char server[LARGE_REGISTRY_LEN]; char database[MEDIUM_REGISTRY_LEN]; char username[MEDIUM_REGISTRY_LEN]; pgNAME password; - char port[SMALL_REGISTRY_LEN]; + char port[LARGE_REGISTRY_LEN]; char sslmode[16]; char onlyread[SMALL_REGISTRY_LEN]; char fake_oid_index[SMALL_REGISTRY_LEN]; @@ -665,6 +669,9 @@ typedef struct signed char xa_opt; #endif /* _HANDLE_ENLIST_IN_DTC_ */ GLOBAL_VALUES drivers; /* moved from driver's option */ + Int4 autobalance; /* whether use autobalance */ + Int4 refreshcnlisttime; /* how long to refresh the IP_list */ + Int4 priority; } ConnInfo; #define SUPPORT_DESCRIBE_PARAM(conninfo_) (conninfo_->use_server_side_prepare) diff --git a/psqlodbc.rc b/psqlodbc.rc index 7433a3b..6296aeb 100644 --- a/psqlodbc.rc +++ b/psqlodbc.rc @@ -40,7 +40,8 @@ CAPTION "PostgreSQL ANSI ODBC #endif FONT 9, "MS ゴシック", 0, 0, 0x1 BEGIN - RTEXT "デ−タソ−ス名:(&N)",IDC_DSNAMETEXT,2,9,63,17,NOT +// RTEXT "デ−タソ−ス名:(&N)",IDC_DSNAMETEXT,2,9,63,17,NOT + RTEXT ":(&N)",IDC_DSNAMETEXT,2,9,63,17,NOT WS_GROUP,WS_EX_TRANSPARENT | WS_EX_RIGHT EDITTEXT IDC_DSNAME,72,12,188,13,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT @@ -67,7 +68,8 @@ BEGIN GROUPBOX "オプション (高度な設定)",IDC_OPTIONS,249,119,99,59, BS_CENTER PUSHBUTTON "全体設定",IDC_DRIVER,269,155,53,15 - PUSHBUTTON "デ−タソ−ス",IDC_DATASOURCE,269,132,53,15 +// PUSHBUTTON "デ−タソ−ス",IDC_DATASOURCE,269,132,53,15 + PUSHBUTTON "",IDC_DATASOURCE,269,132,53,15 GROUPBOX "既定の認証",IDC_STATIC,11,119,235,59 LTEXT "PostgreSQL Ver7.3 Copyright (C) 1998-2006; Insight Distribution Systems", IDC_STATIC,36,186,302,9 @@ -85,7 +87,8 @@ END DLG_OPTIONS_DRV DIALOG DISCARDABLE 0, 0, 350, 241 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "高度な設定 (データソース1)" +//CAPTION "高度な設定 (データソース1)" +CAPTION "" FONT 9, "MS ゴシック" BEGIN PUSHBUTTON "設定2",ID2NDPAGE,5,5,40,15 @@ -96,7 +99,8 @@ BEGIN WS_EX_TRANSPARENT CONTROL "ユニ−クインデックスを使う(&I)",DRV_UNIQUEINDEX,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,129,10 - CONTROL "ステ−トメントの構文解析を行なう(&a)",DRV_PARSE,"Button", +// CONTROL "ステ−トメントの構文解析を行なう(&a)",DRV_PARSE,"Button", + CONTROL "(&a)",DRV_PARSE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,167,40,152,10 CONTROL "Declare〜Fetchを使用する(&U)",DRV_USEDECLAREFETCH, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,71,138,10 @@ -141,22 +145,26 @@ END DLG_OPTIONS_DS DIALOG DISCARDABLE 0, 0, 306, 260 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "高度な設定 (データソース2)" +//CAPTION "高度な設定 (データソース2)" +CAPTION "" FONT 9, "MS ゴシック" BEGIN PUSHBUTTON "設定3",ID3RDPAGE,49,5,40,15 PUSHBUTTON "設定1",ID1STPAGE,5,5,40,15 CONTROL "リ−ドオンリィ(&R)",DS_READONLY,"Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,26,102,10 - CONTROL "バ−ジョン列表示(&V)",DS_ROWVERSIONING,"Button", +// CONTROL "バ−ジョン列表示(&V)",DS_ROWVERSIONING,"Button", + CONTROL "(&V)",DS_ROWVERSIONING,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,139,25,114,10 - CONTROL "システムテ−ブルを表示(&T)",DS_SHOWSYSTEMTABLES,"Button", +// CONTROL "システムテ−ブルを表示(&T)",DS_SHOWSYSTEMTABLES,"Button", + CONTROL "(&T)",DS_SHOWSYSTEMTABLES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,41,111,10 CONTROL "LF <-> CR/LF 変換を行う",DS_LFCONVERSION,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,106,10 CONTROL "-1 を真値(True)とする",DS_TRUEISMINUS1,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,139,55,98,10 - CONTROL "更新可能カーソル",DS_UPDATABLECURSORS,"Button", +// CONTROL "更新可能カーソル",DS_UPDATABLECURSORS,"Button", + CONTROL "",DS_UPDATABLECURSORS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,71,87,10 CONTROL "サーバー側 Prepare(7.3以後)",DS_SERVERSIDEPREPARE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,70,122,10 @@ -183,7 +191,8 @@ BEGIN CONTROL "文単位",DS_STATEMENT_ROLLBACK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,250,140,35,10 GROUPBOX "OID オプション",IDC_STATIC,5,158,206,25 - CONTROL "カラム列表示(&C)",DS_SHOWOIDCOLUMN,"Button", +// CONTROL "カラム列表示(&C)",DS_SHOWOIDCOLUMN,"Button", + CONTROL "(&C)",DS_SHOWOIDCOLUMN,"Button", BS_AUTOCHECKBOX | WS_GROUP,16,169,72,10 CONTROL "インデックスを装う(&I)",DS_FAKEOIDINDEX,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,107,169,95,10 @@ -220,7 +229,8 @@ END DLG_OPTIONS_DS3 DIALOG DISCARDABLE 0, 0, 306, 243 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "高度な設定 (データソース3)" +//CAPTION "高度な設定 (データソース3)" +CAPTION "" FONT 9, "MS ゴシック" BEGIN PUSHBUTTON "設定2",ID2NDPAGE,49,5,40,15 @@ -276,7 +286,8 @@ END DLG_DRIVER_CHANGE DIALOG DISCARDABLE 0, 0, 306, 87 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "ドライバ アップ/ダウン" +//CAPTION "ドライバ アップ/ダウン" +CAPTION "" FONT 10, "Terminal" BEGIN DEFPUSHBUTTON "OK",IDOK,82,68,50,14,WS_GROUP @@ -502,6 +513,12 @@ BEGIN EDITTEXT IDC_USER,57,69,72,12,ES_AUTOHSCROLL RTEXT "Pass&word",IDC_STATIC,154,72,34,9 EDITTEXT IDC_PASSWORD,192,70,72,12,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "Auto&Balance",IDC_STATIC,4,85,49,12,NOT WS_GROUP + EDITTEXT IDC_AB,57,84,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP + RTEXT "&Refresh Time",IDC_STATIC,95,85,49,12,NOT WS_GROUP + EDITTEXT IDC_RT,148,84,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP + RTEXT "Priority",IDC_STATIC,186,85,30,12,NOT WS_GROUP + EDITTEXT IDC_PR,220,84,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP // DEFPUSHBUTTON "OK",IDOK,12,114,44,15,WS_GROUP // PUSHBUTTON "Cancel",IDCANCEL,66,114,44,15 // GROUPBOX "Options",IDC_OPTIONS,121,101,177,35,BS_LEFT @@ -893,4 +910,3 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED -P diff --git a/readme_winbuild.txt b/readme_winbuild.txt index 86b7527..887c851 100644 --- a/readme_winbuild.txt +++ b/readme_winbuild.txt @@ -9,3 +9,9 @@ winbuild folder. See docs\win32-compilation.html and winbuild\readme.txt for Windows compilation instructions. For info on building installers, see installer\README.txt + +windows 邇ッ蠅菫。諱ッ隸エ譏: + 迚ゥ逅譛コIPシ10.110.51.213 + 陌壽供譛コIPシ10.110.51.65 + 髟懷ワ蜷咲ァーシ2012R2_std_patch_201911.iso + 譫蟒コ蟾・蜈キ閾ェ蜉ィ蛹門ョ芽」閼壽悽シ哦aussDBKernel/ci/script/utils/install_tools.bat diff --git a/resource.h b/resource.h index fb3e9a6..7a8a739 100644 --- a/resource.h +++ b/resource.h @@ -32,6 +32,9 @@ #define IDC_NOTICE_USER 414 #define IDS_SSLREQUEST_VERIFY_CA 415 #define IDS_SSLREQUEST_VERIFY_FULL 416 +#define IDC_AB 417 +#define IDC_RT 418 +#define IDC_PR 419 #define DLG_CONFIG 1001 #define IDC_PORT 1002 #define DLG_DRIVER_CHANGE 1002 diff --git a/results.c b/results.c index 43c85bf..81a501b 100644 --- a/results.c +++ b/results.c @@ -161,6 +161,10 @@ PGAPI_NumResultCols(HSTMT hstmt, return SQL_INVALID_HANDLE; } + if (pccol == NULL) { + return SQL_ERROR; + } + SC_clear_error(stmt); #define return DONT_CALL_RETURN_FROM_HERE??? diff --git a/windows/build/odbc.bat b/windows/build/odbc.bat new file mode 100644 index 0000000..4ba79de --- /dev/null +++ b/windows/build/odbc.bat @@ -0,0 +1,75 @@ +REM Copyright Huawei Technologies Co., Ltd. 2010-2018. All rights reserved. +@echo off +setlocal + +set WD=%__CD__% +set LIB_SECURITY_DIR=%WD%\..\..\..\..\platform\Huawei_Secure_C\Huawei_Secure_C_V100R001C01SPC010B002 +set LIB_GAUSSDB_DIR=%WD%\..\..\..\..\..\server +set LIB_ODBC_DIR=%WD%\..\.. + +set MINGW_DIR=C:\buildtools\mingw-8.1.0\msys32\mingw32 +set CMAKE_DIR=C:\buildtools\cmake +set OPENSSL_DIR=D:\GaussDBKernel\open_source\output\openssl-win + + +REM Build libsecurec.lib +cp win32/libpq/CMakeLists-huawei-securec.txt %LIB_SECURITY_DIR%/CMakeLists.txt +cd %LIB_SECURITY_DIR% +rm -rf build +mkdir build +cd build +cmake -DMINGW_DIR="%MINGW_DIR%" -D"CMAKE_MAKE_PROGRAM:PATH=%MINGW_DIR%/bin/make.exe" -G "MinGW Makefiles" .. +make +cd %WD% + +REM Build libpq.lib +rm -rf %LIB_GAUSSDB_DIR%/libpq-win32 +cp -r win32/libpq %LIB_GAUSSDB_DIR%/libpq-win32 +cd %LIB_GAUSSDB_DIR%/libpq-win32 +cp -r %LIB_SECURITY_DIR%/output ./lib +bash -l %LIB_GAUSSDB_DIR%/libpq-win32/project.sh +rm -rf build +mkdir build +cd build +cmake -DMINGW_DIR="%MINGW_DIR%" -DOPENSSL_DIR="%OPENSSL_DIR%" -D"CMAKE_MAKE_PROGRAM:PATH=%MINGW_DIR%/bin/make.exe" -G "MinGW Makefiles" .. +make +cd %WD% + +REM Build psqlodbc35w.lib +cd %LIB_ODBC_DIR% +rm -rf libpq +cp -r %LIB_GAUSSDB_DIR%/libpq-win32/libpq-export ./libpq +cp -r %LIB_GAUSSDB_DIR%/libpq-win32/lib/* ./libpq/lib +cp -r %LIB_GAUSSDB_DIR%/libpq-win32/output/libpq.lib ./libpq/lib +rm -rf build +mkdir build +cd build +cmake -DMINGW_DIR="%MINGW_DIR%" -DOPENSSL_DIR="%OPENSSL_DIR%" -D"CMAKE_MAKE_PROGRAM:PATH=%MINGW_DIR%/bin/make.exe" -G "MinGW Makefiles" .. +make +cd %WD% + +REM Build psqlodbc.exe +cd psqlodbc-installer +rm -rf win32_dll +mkdir win32_dll +cp %LIB_ODBC_DIR%/output/psqlodbc35w.dll ./win32_dll +cp "%OPENSSL_DIR%"/libssl-1_1.dll ./win32_dll +cp "%OPENSSL_DIR%"/libcrypto-1_1.dll ./win32_dll +makensis odbc-installer.nsi + +cd %WD% +rm -rf odbc_output +mkdir odbc_output +cp psqlodbc-installer/psqlodbc.exe odbc_output +rm -rf psqlodbc-installer/psqlodbc.exe + + +cd odbc_output +%p7zip%\7z.exe a GaussDB-Kernel-V500R002C10-Windows-Odbc-X86.tar * +%p7zip%\7z.exe a -tgzip GaussDB-Kernel-V500R002C10-Windows-Odbc-X86.tar.gz *.tar +del *.tar + +set OUTPUT_DIR=%LIB_ODBC_DIR%/output +mkdir "%OUTPUT_DIR%" +cp GaussDB-Kernel-V500R002C00-Windows-Odbc-X86.tar.gz %OUTPUT_DIR% + diff --git a/windows/build/psqlodbc-installer/odbc-installer.nsi b/windows/build/psqlodbc-installer/odbc-installer.nsi new file mode 100644 index 0000000..df971ca --- /dev/null +++ b/windows/build/psqlodbc-installer/odbc-installer.nsi @@ -0,0 +1,133 @@ +; psqlODBC.nsi +; +; This script is refered to example2.nsi and created for install psqlODBC. +; It will install odbc library into a directory that the user selects. +; +;-------------------------------- + +; The name of the installer +Name "psqlODBC" + +; The file to write +OutFile "psqlODBC.exe" + +; Request application privileges for Windows Vista and higher +RequestExecutionLevel admin + +; Build Unicode installer +Unicode True + +; The default installation directory +InstallDir $PROGRAMFILES\psqlODBC + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "Software\psqlODBC.ODBC.Driver" "Install_Dir" + +;InstallDirRegKey HKLM "SOFTWARE\ODBC\ODBCINST.INI" "PostgreSQL Unicode" + +;-------------------------------- + +; Pages + +Page components +Page directory +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- + +; The stuff to install +Section "ODBC Driver (required)" + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR + + ; Put file there + File "win32_dll\libcrypto-1_1.dll" + File "win32_dll\libssl-1_1.dll" + File "win32_dll\psqlodbc35w.dll" + + SetRegView 32 + ; Write the installation path into the registry + WriteRegStr HKLM "SOFTWARE\psqlODBC.ODBC.Driver" "Install_Dir" "$INSTDIR" + + ; Write ODBC Driver information into the registry + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "PostgreSQL Unicode" "Installed" + + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "APILevel" "1" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "ConnectFunctions" "YYN" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "Driver" "$INSTDIR\psqlodbc35w.dll" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "DriverODBCVer" "03.51" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "FileUsage" "0" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "Setup" "$INSTDIR\psqlodbc35w.dll" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "SQLLevel" "1" + WriteRegDWORD HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "UsageCount" 1 + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "DisplayName" "psqlODBC" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "NoRepair" 1 + + SetRegView 64 + ; Write the installation path into the registry + WriteRegStr HKLM "SOFTWARE\psqlODBC.ODBC.Driver" "Install_Dir" "$INSTDIR" + + ; Write ODBC Driver information into the registry + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "PostgreSQL Unicode" "Installed" + + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "APILevel" "1" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "ConnectFunctions" "YYN" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "Driver" "$INSTDIR\psqlodbc35w.dll" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "DriverODBCVer" "03.51" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "FileUsage" "0" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "Setup" "$INSTDIR\psqlodbc35w.dll" + WriteRegStr HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "SQLLevel" "1" + WriteRegDWORD HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" "UsageCount" 1 + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "DisplayName" "psqlODBC" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" "NoRepair" 1 + + WriteUninstaller "$INSTDIR\uninstall.exe" +SectionEnd + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + + SetRegView 32 + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" + + DeleteRegKey HKLM "SOFTWARE\psqlODBC.ODBC.Driver" + DeleteRegValue HKLM "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "PostgreSQL Unicode" + DeleteRegKey HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" + + SetRegView 64 + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\psqlODBC" + + DeleteRegKey HKLM "SOFTWARE\psqlODBC.ODBC.Driver" + DeleteRegValue HKLM "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" "PostgreSQL Unicode" + DeleteRegKey HKLM "SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode" + + ; Remove files and uninstaller + Delete $INSTDIR\libcrypto-1_1.dll + Delete $INSTDIR\libssl-1_1.dll + Delete $INSTDIR\psqlodbc35w.dll + Delete "$INSTDIR\uninstall.exe" + + ; Remove directories + RMDir "$INSTDIR" + +SectionEnd diff --git a/windows/build/win32/libpq/CMakeLists-huawei-securec.txt b/windows/build/win32/libpq/CMakeLists-huawei-securec.txt new file mode 100644 index 0000000..5116304 --- /dev/null +++ b/windows/build/win32/libpq/CMakeLists-huawei-securec.txt @@ -0,0 +1,73 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +PROJECT(LIBSECUREC) + +SET(CMAKE_VERBOSE_MAKEFILEON ON) +MESSAGE(STATUS "Building LIBSECUREC Library.") + +IF(NOT DEFINED MINGW_DIR) + set(MINGW_DIR "D:\\msys32\\mingw32") +ENDIF(NOT DEFINED MINGW_DIR) + +SET(PWD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +SET(MINGW32_DIR ${MINGW_DIR}/"i686-w64-mingw32") +SET(LIBRARY_OUTPUT_PATH ${PWD_DIR}/output) +SET(CMAKE_C_COMPILER "${MINGW_DIR}/bin/i686-w64-mingw32-gcc") + +IF(NOT DEFINED RELEASE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=gnu++11 -D_MINGW32 -fPIC -fPIE -pie -m32 -w") +ELSE(NOT DEFINED RELEASE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu++11 -D_MINGW32 -fPIC -fPIE -pie -m32 -w") +ENDIF(NOT DEFINED RELEASE) + +INCLUDE_DIRECTORIES(${PWD_DIR}/include) + +SET(SRC_LIST ${PWD_DIR}/src/fscanf_s.c + ${PWD_DIR}/src/memmove_s.c + ${PWD_DIR}/src/snprintf_s.c + ${PWD_DIR}/src/strncpy_s.c + ${PWD_DIR}/src/vscanf_s.c + ${PWD_DIR}/src/vwscanf_s.c + ${PWD_DIR}/src/wmemcpy_s.c + ${PWD_DIR}/src/fwscanf_s.c + ${PWD_DIR}/src/memset_s.c + ${PWD_DIR}/src/secureinput_a.c + ${PWD_DIR}/src/sprintf_s.c + ${PWD_DIR}/src/strtok_s.c + ${PWD_DIR}/src/vsnprintf_s.c + ${PWD_DIR}/src/wcscat_s.c + ${PWD_DIR}/src/wmemmove_s.c + ${PWD_DIR}/src/gets_s.c + ${PWD_DIR}/src/secureinput_w.c + ${PWD_DIR}/src/sscanf_s.c + ${PWD_DIR}/src/swprintf_s.c + ${PWD_DIR}/src/vsprintf_s.c + ${PWD_DIR}/src/wcscpy_s.c + ${PWD_DIR}/src/wscanf_s.c + ${PWD_DIR}/src/scanf_s.c + ${PWD_DIR}/src/strcat_s.c + ${PWD_DIR}/src/swscanf_s.c + ${PWD_DIR}/src/vsscanf_s.c + ${PWD_DIR}/src/wcsncat_s.c + ${PWD_DIR}/src/secureprintoutput_a.c + ${PWD_DIR}/src/strcpy_s.c + ${PWD_DIR}/src/vfscanf_s.c + ${PWD_DIR}/src/vswprintf_s.c + ${PWD_DIR}/src/wcsncpy_s.c + ${PWD_DIR}/src/securecutil.c + ${PWD_DIR}/src/secureprintoutput_w.c + ${PWD_DIR}/src/strncat_s.c + ${PWD_DIR}/src/vfwscanf_s.c + ${PWD_DIR}/src/vswscanf_s.c + ${PWD_DIR}/src/wcstok_s.c) +# ${PWD_DIR}/src/memcpy_s.o + + +ADD_LIBRARY(OBJ_LIBSECUREC OBJECT ${SRC_LIST}) +SET_PROPERTY(TARGET OBJ_LIBSECUREC PROPERTY POSITION_INDEPENDENT_CODE 1) + +ADD_LIBRARY(LIB_LIBSECUREC STATIC $) +SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES OUTPUT_NAME "libsecurec") +SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES SUFFIX ".lib") + + diff --git a/windows/build/win32/libpq/CMakeLists.txt b/windows/build/win32/libpq/CMakeLists.txt new file mode 100644 index 0000000..e7525f2 --- /dev/null +++ b/windows/build/win32/libpq/CMakeLists.txt @@ -0,0 +1,113 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +PROJECT(LIBPQ) + +SET(CMAKE_VERBOSE_MAKEFILEON ON) + +MESSAGE(STATUS "Building LIBPQ Library.") + +IF(NOT DEFINED OPENSSL_DIR) + set(OPENSSL_DIR "D:\\Program_Files\\OpenSSL-Win32") +ENDIF(NOT DEFINED OPENSSL_DIR) +IF(NOT DEFINED MINGW_DIR) + set(MINGW_DIR "D:\\buildtools\\mingw-8.1.0\\msys32\\mingw32") +ENDIF(NOT DEFINED MINGW_DIR) + +SET(MINGW32_DIR ${MINGW_DIR}/"i686-w64-mingw32") +SET(PWD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +SET(LIBRARY_OUTPUT_PATH ${PWD_DIR}/output) + +SET(CMAKE_CXX_COMPILER "${MINGW_DIR}/bin/i686-w64-mingw32-c++") +SET(CMAKE_SHARED_LINKER_FLAGS "-static -fstack-protector-all") #-static-libgcc -static-libstdc++" + +IF(NOT DEFINED RELEASE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DWIN32 -DFRONTEND -D_MINGW32 -fPIC -fPIE -pie -fpermissive -no-pthread -m32 -w") +ELSE(NOT DEFINED RELEASE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -DWIN32 -DFRONTEND -D_MINGW32 -fPIC -fPIE -pie -fpermissive -no-pthread -m32 -w") +ENDIF(NOT DEFINED RELEASE) + +SET(DEF_FILE ${PWD_DIR}/src/common/interfaces/libpq/libpqdll.def) + +INCLUDE_DIRECTORIES(${PWD_DIR}/include + ${PWD_DIR}/include/port + ${PWD_DIR}/include/port/win32 + ${PWD_DIR}/src + ${PWD_DIR}/src/common/interfaces/libpq/client_logic_processor + ${PWD_DIR}/src/common/interfaces/libpq/client_logic_hooks + ${PWD_DIR}/src/common/interfaces/libpq/client_logic_common + ${PWD_DIR}/src/common/interfaces/libpq/client_logic_cache + ${PWD_DIR}/src/common/port + ${PWD_DIR}/src/common/interfaces/libpq + ${PWD_DIR}/src/common/interfaces/libpq/frontend_parser + ${OPENSSL_DIR}/include + ${MINGW_DIR}/include + ${MINGW32_DIR}/include) + +SET(SRC_LIST ${PWD_DIR}/src/common/port/win32setlocale.cpp + ${PWD_DIR}/src/common/port/win32env.cpp + ${PWD_DIR}/src/common/port/strlcpy.cpp + ${PWD_DIR}/src/common/port/pgstrcasecmp.cpp + ${PWD_DIR}/src/common/port/noblock.cpp + ${PWD_DIR}/src/common/port/inet_aton.cpp + ${PWD_DIR}/src/common/port/gs_strerror.cpp + ${PWD_DIR}/src/common/port/gs_env_r.cpp + ${PWD_DIR}/src/common/port/dirmod.cpp + ${PWD_DIR}/src/common/port/cipher.cpp + ${PWD_DIR}/src/common/port/win32error.cpp + ${PWD_DIR}/src/common/port/thread.cpp + ${PWD_DIR}/src/common/port/pgsleep.cpp + ${PWD_DIR}/src/common/port/path.cpp + ${PWD_DIR}/src/common/port/inet_net_ntop.cpp + ${PWD_DIR}/src/common/port/gs_syscall_lock.cpp + ${PWD_DIR}/src/common/port/gs_readdir.cpp + ${PWD_DIR}/src/common/port/getaddrinfo.cpp + ${PWD_DIR}/src/common/port/dirent.cpp + ${PWD_DIR}/src/common/port/chklocale.cpp + ${PWD_DIR}/src/common/interfaces/libpq/pthread-win32.cpp + ${PWD_DIR}/src/common/interfaces/libpq/pqexpbuffer.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-protocol3.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-misc.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-connect.cpp + ${PWD_DIR}/src/common/interfaces/libpq/win32.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-protocol2.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-lobj.cpp + ${PWD_DIR}/src/common/interfaces/libpq/pqsignal.cpp + ${PWD_DIR}/src/common/interfaces/libpq/libpq-events.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-secure.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-print.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-exec.cpp + ${PWD_DIR}/src/common/interfaces/libpq/fe-auth.cpp + ${PWD_DIR}/src/common/backend/utils/mb/encnames.cpp + ${PWD_DIR}/src/common/backend/utils/mb/wchar.cpp + ${PWD_DIR}/src/common/backend/libpq/sha2.cpp + ${PWD_DIR}/src/common/backend/libpq/md5.cpp + ${PWD_DIR}/src/common/backend/libpq/ip.cpp) + +LINK_DIRECTORIES(${MINGW_DIR}/bin + ${MINGW_DIR}/lib + ${MINGW32_DIR}/lib) + +ADD_LIBRARY(OBJ_LIBPQ OBJECT ${SRC_LIST}) +SET_PROPERTY(TARGET OBJ_LIBPQ PROPERTY POSITION_INDEPENDENT_CODE 1) + +ADD_LIBRARY(LIB_LIBPQ STATIC $) +SET_TARGET_PROPERTIES(LIB_LIBPQ PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(LIB_LIBPQ PROPERTIES OUTPUT_NAME "libpq") +SET_TARGET_PROPERTIES(LIB_LIBPQ PROPERTIES SUFFIX ".lib") + +ADD_LIBRARY(DLL_LIBPQ SHARED $ ${DEF_FILE}) +SET_TARGET_PROPERTIES(DLL_LIBPQ PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(DLL_LIBPQ PROPERTIES OUTPUT_NAME "libpq") + +FIND_LIBRARY(LIB_CRYPTO NAMES crypto PATHS ${OPENSSL_DIR}/lib) +FIND_LIBRARY(LIB_SSL NAMES ssl PATHS ${OPENSSL_DIR}/lib) +FIND_LIBRARY(LIB_SECUREC NAMES securec PATHS ${PWD_DIR}/lib) + +TARGET_LINK_LIBRARIES(DLL_LIBPQ + -lwsock32 + -lws2_32 + -lsecur32 + -lsecurity + -lpthread + ${LIB_CRYPTO} ${LIB_SSL} + ${LIB_SECUREC}) + diff --git a/windows/build/win32/libpq/Makefile b/windows/build/win32/libpq/Makefile new file mode 100644 index 0000000..ce6182e --- /dev/null +++ b/windows/build/win32/libpq/Makefile @@ -0,0 +1,177 @@ +################################################################# +## Makefile for building libpq library on Windows using MinGW ## +################################################################# + +ifndef $(OPENSSL_DIR) +OPENSSL_DIR:=/d/Program_Files/OpenSSL-Win32 +endif + +ifndef $(MINGW_DIR) +MINGW_DIR:=/d/msys32/mingw32 +endif + +PWD_DIR:=$(shell pwd) +MINGW32_DIR:=$(MINGW_DIR)/i686-w64-mingw32 +OUT_DIR:=$(PWD_DIR)/output +OBJ_DIR:=$(PWD_DIR)/obj + +DLL_TARGET:=$(OUT_DIR)/libpq.dll +LIB_TARGET:=$(OUT_DIR)/libpq.lib + +CC:=$(MINGW_DIR)/bin/i686-w64-mingw32-c++ +AR:=$(MINGW_DIR)/bin/i686-w64-mingw32-gcc-ar + +MD:=mkdir -p +RM:=rm -rf + +DEFFILE:=$(PWD_DIR)/src/common/interfaces/libpq/libpqdll.def + +CCFLAG:=-DWIN32 \ + -DFRONTEND \ + -D_MINGW32 \ + -fpermissive \ + -no-pthread \ + -m32 \ + -w \ + -fstack-protector-all \ + --dynamicbase + +ifdef $(RELEASE) + CCFLAG:=$(CCFLAG) -O2 +else + CCFLAG:=$(CCFLAG) -g +endif + +LFLAG:=-L$(OPENSSL_DIR)/lib \ + -L$(PWD_DIR)/lib \ + -L$(MINGW_DIR)/bin \ + -L$(MINGW32_DIR)/lib \ + -llibcrypto \ + -llibssl \ + -lwsock32 \ + -lws2_32 \ + -lsecur32 \ + -lsecurity \ + -lopenssl \ + -llibsecurec + +INCLUDE:=-I$(PWD_DIR)/include \ + -I$(PWD_DIR)/include/port \ + -I$(PWD_DIR)/include/port/win32 \ + -I$(PWD_DIR)/src \ + -I$(PWD_DIR)/src/common/interfaces/libpq/client_logic_processor \ + -I$(PWD_DIR)/src/common/interfaces/libpq/client_logic_hooks \ + -I$(PWD_DIR)/src/common/interfaces/libpq/client_logic_common \ + -I$(PWD_DIR)/src/common/interfaces/libpq/client_logic_cache \ + -I$(PWD_DIR)/src/common/port \ + -I$(PWD_DIR)/src/common/interfaces/libpq \ + -I$(PWD_DIR)/src/common/interfaces/libpq/frontend_parser \ + -I$(OPENSSL_DIR)/include \ + -I$(MINGW_DIR)/include \ + -I$(MINGW32_DIR)/include + +SRC:=$(PWD_DIR)/src/common/port/win32setlocale.cpp \ + $(PWD_DIR)/src/common/port/win32env.cpp \ + $(PWD_DIR)/src/common/port/strlcpy.cpp \ + $(PWD_DIR)/src/common/port/pgstrcasecmp.cpp \ + $(PWD_DIR)/src/common/port/noblock.cpp \ + $(PWD_DIR)/src/common/port/inet_aton.cpp \ + $(PWD_DIR)/src/common/port/gs_strerror.cpp \ + $(PWD_DIR)/src/common/port/gs_env_r.cpp \ + $(PWD_DIR)/src/common/port/dirmod.cpp \ + $(PWD_DIR)/src/common/port/cipher.cpp \ + $(PWD_DIR)/src/common/port/win32error.cpp \ + $(PWD_DIR)/src/common/port/thread.cpp \ + $(PWD_DIR)/src/common/port/pgsleep.cpp \ + $(PWD_DIR)/src/common/port/path.cpp \ + $(PWD_DIR)/src/common/port/inet_net_ntop.cpp \ + $(PWD_DIR)/src/common/port/gs_syscall_lock.cpp \ + $(PWD_DIR)/src/common/port/gs_readdir.cpp \ + $(PWD_DIR)/src/common/port/getaddrinfo.cpp \ + $(PWD_DIR)/src/common/port/dirent.cpp \ + $(PWD_DIR)/src/common/port/chklocale.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/pthread-win32.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/pqexpbuffer.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-protocol3.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-misc.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-connect.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/win32.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-protocol2.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-lobj.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/pqsignal.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/libpq-events.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-secure.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-print.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-exec.cpp \ + $(PWD_DIR)/src/common/interfaces/libpq/fe-auth.cpp \ + $(PWD_DIR)/src/common/backend/utils/mb/encnames.cpp \ + $(PWD_DIR)/src/common/backend/utils/mb/wchar.cpp \ + $(PWD_DIR)/src/common/backend/libpq/sha2.cpp \ + $(PWD_DIR)/src/common/backend/libpq/md5.cpp \ + $(PWD_DIR)/src/common/backend/libpq/ip.cpp + +OBJ:=$(OBJ_DIR)/win32setlocale.o \ + $(OBJ_DIR)/win32env.o \ + $(OBJ_DIR)/strlcpy.o \ + $(OBJ_DIR)/pgstrcasecmp.o\ + $(OBJ_DIR)/noblock.o \ + $(OBJ_DIR)/inet_aton.o \ + $(OBJ_DIR)/gs_strerror.o \ + $(OBJ_DIR)/gs_env_r.o \ + $(OBJ_DIR)/dirmod.o \ + $(OBJ_DIR)/cipher.o \ + $(OBJ_DIR)/win32error.o \ + $(OBJ_DIR)/thread.o \ + $(OBJ_DIR)/pgsleep.o \ + $(OBJ_DIR)/path.o \ + $(OBJ_DIR)/inet_net_ntop.o \ + $(OBJ_DIR)/gs_syscall_lock.o \ + $(OBJ_DIR)/gs_readdir.o \ + $(OBJ_DIR)/getaddrinfo.o \ + $(OBJ_DIR)/dirent.o \ + $(OBJ_DIR)/chklocale.o \ + $(OBJ_DIR)/pthread-win32.o \ + $(OBJ_DIR)/pqexpbuffer.o \ + $(OBJ_DIR)/fe-protocol3.o \ + $(OBJ_DIR)/fe-misc.o \ + $(OBJ_DIR)/fe-connect.o \ + $(OBJ_DIR)/win32.o \ + $(OBJ_DIR)/fe-protocol2.o \ + $(OBJ_DIR)/fe-lobj.o \ + $(OBJ_DIR)/pqsignal.o \ + $(OBJ_DIR)/libpq-events.o \ + $(OBJ_DIR)/fe-secure.o \ + $(OBJ_DIR)/fe-print.o \ + $(OBJ_DIR)/fe-exec.o \ + $(OBJ_DIR)/fe-auth.o \ + $(OBJ_DIR)/encnames.o \ + $(OBJ_DIR)/wchar.o \ + $(OBJ_DIR)/sha2.o \ + $(OBJ_DIR)/md5.o \ + $(OBJ_DIR)/ip.o + +SRC_TO_OBJ=$(OBJ_DIR)/$(patsubst %.cpp,%.o, $(notdir $(1))) + +define BUILD_OBJ +$(call SRC_TO_OBJ,$(1)):$(1) + $(CC) $(CCFLAG) $(INCLUDE) -c $$^ -o $$@ +endef + +all:dirs $(OBJ) + $(CC) $(OBJ) $(DEFFILE) -static -shared -o $(DLL_TARGET) $(LFLAG) + $(AR) rcs $(LIB_TARGET) $(OBJ) + +dirs: + $(MD) $(OBJ_DIR) + $(MD) $(OUT_DIR) + +clean: + $(RM) $(OBJ_DIR) + $(RM) $(OUT_DIR) + +$(foreach c,$(SRC),$(eval $(call BUILD_OBJ,$(c)))) + +.PHONY: all clean dirs +################################################################# +## THE END OF LIBPQ MINGW32 Makefile ## +################################################################# diff --git a/windows/build/win32/libpq/include/errcodes.h b/windows/build/win32/libpq/include/errcodes.h new file mode 100644 index 0000000..9ef0fb9 --- /dev/null +++ b/windows/build/win32/libpq/include/errcodes.h @@ -0,0 +1,467 @@ +/* autogenerated from src/backend/utils/errcodes.txt, do not edit */ +/* there is deliberately not an #ifndef ERRCODES_H here */ + +/* Class 00 - Successful Completion */ +#define ERRCODE_SUCCESSFUL_COMPLETION MAKE_SQLSTATE('0','0','0','0','0') + +/* Class 01 - Warning */ +#define ERRCODE_WARNING MAKE_SQLSTATE('0','1','0','0','0') +#define ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','1','0','0','C') +#define ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING MAKE_SQLSTATE('0','1','0','0','8') +#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1','0','0','3') +#define ERRCODE_WARNING_PRIVILEGE_NOT_GRANTED MAKE_SQLSTATE('0','1','0','0','7') +#define ERRCODE_WARNING_PRIVILEGE_NOT_REVOKED MAKE_SQLSTATE('0','1','0','0','6') +#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1','0','0','4') +#define ERRCODE_WARNING_DEPRECATED_FEATURE MAKE_SQLSTATE('0','1','P','0','1') + +/* Class 02 - No Data (this is also a warning class per the SQL standard) */ +#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2','0','0','0') +#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2','0','0','1') +#define ERRCODE_INVALID_OPTION MAKE_SQLSTATE('0','2','0','0','2') + +/* Class 03 - SQL Statement Not Yet Complete */ +#define ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE MAKE_SQLSTATE('0','3','0','0','0') + +/* Class 08 - Connection Exception */ +#define ERRCODE_CONNECTION_EXCEPTION MAKE_SQLSTATE('0','8','0','0','0') +#define ERRCODE_CONNECTION_DOES_NOT_EXIST MAKE_SQLSTATE('0','8','0','0','3') +#define ERRCODE_CONNECTION_FAILURE MAKE_SQLSTATE('0','8','0','0','6') +#define ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION MAKE_SQLSTATE('0','8','0','0','1') +#define ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION MAKE_SQLSTATE('0','8','0','0','4') +#define ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN MAKE_SQLSTATE('0','8','0','0','7') +#define ERRCODE_PROTOCOL_VIOLATION MAKE_SQLSTATE('0','8','P','0','1') + +/* Class 09 - Triggered Action Exception */ +#define ERRCODE_TRIGGERED_ACTION_EXCEPTION MAKE_SQLSTATE('0','9','0','0','0') + +/* Class 0A - Feature Not Supported */ +#define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0','A','0','0','0') +#define ERRCODE_STREAM_NOT_SUPPORTED MAKE_SQLSTATE('0','A','1','0','0') + +/* Class 0B - Invalid Transaction Initiation */ +#define ERRCODE_INVALID_TRANSACTION_INITIATION MAKE_SQLSTATE('0','B','0','0','0') + +/* Class 0F - Locator Exception */ +#define ERRCODE_LOCATOR_EXCEPTION MAKE_SQLSTATE('0','F','0','0','0') +#define ERRCODE_L_E_INVALID_SPECIFICATION MAKE_SQLSTATE('0','F','0','0','1') + +/* Class 0L - Invalid Grantor */ +#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L','0','0','0') +#define ERRCODE_INVALID_GRANT_OPERATION MAKE_SQLSTATE('0','L','P','0','1') + +/* Class 0P - Invalid Role Specification */ +#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P','0','0','0') + +/* Class 0Z - Diagnostics Exception */ +#define ERRCODE_DIAGNOSTICS_EXCEPTION MAKE_SQLSTATE('0','Z','0','0','0') +#define ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER MAKE_SQLSTATE('0','Z','0','0','2') + +/* Class 20 - Case Not Found */ +#define ERRCODE_CASE_NOT_FOUND MAKE_SQLSTATE('2','0','0','0','0') + +/* Class 21 - Cardinality Violation */ +#define ERRCODE_CARDINALITY_VIOLATION MAKE_SQLSTATE('2','1','0','0','0') + +/* Class 22 - Data Exception */ +#define ERRCODE_DATA_EXCEPTION MAKE_SQLSTATE('2','2','0','0','0') +#define ERRCODE_ARRAY_ELEMENT_ERROR MAKE_SQLSTATE('2','2','0','0','E') +#define ERRCODE_ARRAY_SUBSCRIPT_ERROR MAKE_SQLSTATE('2','2','0','2','E') +#define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE MAKE_SQLSTATE('2','2','0','2','1') +#define ERRCODE_DATETIME_FIELD_OVERFLOW MAKE_SQLSTATE('2','2','0','0','8') +#define ERRCODE_DATETIME_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2','2','0','2','0') +#define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2','2','0','1','2') +#define ERRCODE_ERROR_IN_ASSIGNMENT MAKE_SQLSTATE('2','2','0','0','5') +#define ERRCODE_ESCAPE_CHARACTER_CONFLICT MAKE_SQLSTATE('2','2','0','0','B') +#define ERRCODE_INDICATOR_OVERFLOW MAKE_SQLSTATE('2','2','0','2','2') +#define ERRCODE_INTERVAL_FIELD_OVERFLOW MAKE_SQLSTATE('2','2','0','1','5') +#define ERRCODE_INVALID_ARGUMENT_FOR_LOG MAKE_SQLSTATE('2','2','0','1','E') +#define ERRCODE_INVALID_ARGUMENT_FOR_NTILE MAKE_SQLSTATE('2','2','0','1','4') +#define ERRCODE_INVALID_ARGUMENT_FOR_NTH_VALUE MAKE_SQLSTATE('2','2','0','1','6') +#define ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION MAKE_SQLSTATE('2','2','0','1','F') +#define ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION MAKE_SQLSTATE('2','2','0','1','G') +#define ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST MAKE_SQLSTATE('2','2','0','1','8') +#define ERRCODE_INVALID_DATETIME_FORMAT MAKE_SQLSTATE('2','2','0','0','7') +#define ERRCODE_INVALID_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2','0','1','9') +#define ERRCODE_INVALID_ESCAPE_OCTET MAKE_SQLSTATE('2','2','0','0','D') +#define ERRCODE_INVALID_ESCAPE_SEQUENCE MAKE_SQLSTATE('2','2','0','2','5') +#define ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2','P','0','6') +#define ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE MAKE_SQLSTATE('2','2','0','1','0') +#define ERRCODE_INVALID_PARAMETER_VALUE MAKE_SQLSTATE('2','2','0','2','3') +#define ERRCODE_INVALID_REGULAR_EXPRESSION MAKE_SQLSTATE('2','2','0','1','B') +#define ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE MAKE_SQLSTATE('2','2','0','1','W') +#define ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE MAKE_SQLSTATE('2','2','0','1','X') +#define ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE MAKE_SQLSTATE('2','2','0','0','9') +#define ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2','0','0','C') +#define ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH MAKE_SQLSTATE('2','2','0','0','G') +#define ERRCODE_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('2','2','0','0','4') +#define ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER MAKE_SQLSTATE('2','2','0','0','2') +#define ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2','2','0','0','3') +#define ERRCODE_DOP_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2','2','0','1','7') +#define ERRCODE_STRING_DATA_LENGTH_MISMATCH MAKE_SQLSTATE('2','2','0','2','6') +#define ERRCODE_REGEXP_MISMATCH MAKE_SQLSTATE('2','2','0','2','8') +#define ERRCODE_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('2','2','0','0','1') +#define ERRCODE_SUBSTRING_ERROR MAKE_SQLSTATE('2','2','0','1','1') +#define ERRCODE_TRIM_ERROR MAKE_SQLSTATE('2','2','0','2','7') +#define ERRCODE_UNTERMINATED_C_STRING MAKE_SQLSTATE('2','2','0','2','4') +#define ERRCODE_ZERO_LENGTH_CHARACTER_STRING MAKE_SQLSTATE('2','2','0','0','F') +#define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2','2','P','0','1') +#define ERRCODE_INVALID_TEXT_REPRESENTATION MAKE_SQLSTATE('2','2','P','0','2') +#define ERRCODE_INVALID_BINARY_REPRESENTATION MAKE_SQLSTATE('2','2','P','0','3') +#define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2','2','P','0','4') +#define ERRCODE_UNTRANSLATABLE_CHARACTER MAKE_SQLSTATE('2','2','P','0','5') +#define ERRCODE_NOT_AN_XML_DOCUMENT MAKE_SQLSTATE('2','2','0','0','L') +#define ERRCODE_INVALID_XML_DOCUMENT MAKE_SQLSTATE('2','2','0','0','M') +#define ERRCODE_INVALID_XML_CONTENT MAKE_SQLSTATE('2','2','0','0','N') +#define ERRCODE_INVALID_XML_ERROR_CONTEXT MAKE_SQLSTATE('2','2','0','0','O') +#define ERRCODE_INVALID_XML_COMMENT MAKE_SQLSTATE('2','2','0','0','S') +#define ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION MAKE_SQLSTATE('2','2','0','0','T') + +/* Class 23 - Integrity Constraint Violation */ +#define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('2','3','0','0','0') +#define ERRCODE_RESTRICT_VIOLATION MAKE_SQLSTATE('2','3','0','0','1') +#define ERRCODE_NOT_NULL_VIOLATION MAKE_SQLSTATE('2','3','5','0','2') +#define ERRCODE_FOREIGN_KEY_VIOLATION MAKE_SQLSTATE('2','3','5','0','3') +#define ERRCODE_UNIQUE_VIOLATION MAKE_SQLSTATE('2','3','5','0','5') +#define ERRCODE_CHECK_VIOLATION MAKE_SQLSTATE('2','3','5','1','4') +#define ERRCODE_EXCLUSION_VIOLATION MAKE_SQLSTATE('2','3','P','0','1') + +/* Class 24 - Invalid Cursor State */ +#define ERRCODE_INVALID_CURSOR_STATE MAKE_SQLSTATE('2','4','0','0','0') + +/* Class 25 - Invalid Transaction State */ +#define ERRCODE_INVALID_TRANSACTION_STATE MAKE_SQLSTATE('2','5','0','0','0') +#define ERRCODE_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5','0','0','1') +#define ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE MAKE_SQLSTATE('2','5','0','0','2') +#define ERRCODE_HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL MAKE_SQLSTATE('2','5','0','0','8') +#define ERRCODE_INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5','0','0','3') +#define ERRCODE_INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5','0','0','4') +#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5','0','0','5') +#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5','0','0','6') +#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5','0','0','7') +#define ERRCODE_RUN_TRANSACTION_DURING_RECOVERY MAKE_SQLSTATE('2','5','0','0','9') +#define ERRCODE_GXID_DOES_NOT_EXIST MAKE_SQLSTATE('2','5','0','1','0') +#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5','P','0','1') +#define ERRCODE_IN_FAILED_SQL_TRANSACTION MAKE_SQLSTATE('2','5','P','0','2') + +/* Class 26 - Invalid SQL Statement Name */ +#define ERRCODE_INVALID_SQL_STATEMENT_NAME MAKE_SQLSTATE('2','6','0','0','0') +#define ERRCODE_SLOW_QUERY MAKE_SQLSTATE('2','6','0','0','1') +#define ERRCODE_ACTIVE_SESSION_PROFILE MAKE_SQLSTATE('2','6','0','0','2') + +/* Class 27 - Triggered Data Change Violation */ +#define ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION MAKE_SQLSTATE('2','7','0','0','0') +#define ERRCODE_TRIGGERED_INVALID_TUPLE MAKE_SQLSTATE('2','7','0','0','1') + +/* Class 28 - Invalid Authorization Specification */ +#define ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION MAKE_SQLSTATE('2','8','0','0','0') +#define ERRCODE_INVALID_PASSWORD MAKE_SQLSTATE('2','8','P','0','1') +#define ERRCODE_INITIAL_PASSWORD_NOT_MODIFIED MAKE_SQLSTATE('2','8','P','0','2') + +/* Class 29 - Invalid or Unexpected Status */ +#define ERRCODE_INVALID_STATUS MAKE_SQLSTATE('2','9','0','0','0') +#define ERRCODE_INVALID_TABLESAMPLE_ARGUMENT MAKE_SQLSTATE('2','9','0','0','1') +#define ERRCODE_INVALID_TABLESAMPLE_REPEAT MAKE_SQLSTATE('2','9','0','0','2') +#define ERRORCODE_ASSERT_FAILED MAKE_SQLSTATE('2','9','0','0','3') +#define ERRCODE_CACHE_LOOKUP_FAILED MAKE_SQLSTATE('2','9','P','0','1') +#define ERRCODE_FETCH_DATA_FAILED MAKE_SQLSTATE('2','9','P','0','2') +#define ERRCODE_FLUSH_DATA_SIZE_MISMATCH MAKE_SQLSTATE('2','9','P','0','3') +#define ERRCODE_RELATION_OPEN_ERROR MAKE_SQLSTATE('2','9','P','0','4') +#define ERRCODE_RELATION_CLOSE_ERROR MAKE_SQLSTATE('2','9','P','0','5') +#define ERRCODE_INVALID_CACHE_PLAN MAKE_SQLSTATE('2','9','P','0','6') + +/* Class 2B - Dependent Privilege Descriptors Still Exist */ +#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B','0','0','0') +#define ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST MAKE_SQLSTATE('2','B','P','0','1') + +/* Class 2D - Invalid Transaction Termination */ +#define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D','0','0','0') + +/* Class 2F - SQL Routine Exception */ +#define ERRCODE_SQL_ROUTINE_EXCEPTION MAKE_SQLSTATE('2','F','0','0','0') +#define ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT MAKE_SQLSTATE('2','F','0','0','5') +#define ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F','0','0','2') +#define ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('2','F','0','0','3') +#define ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F','0','0','4') + +/* Class 34 - Invalid Cursor Name */ +#define ERRCODE_INVALID_CURSOR_NAME MAKE_SQLSTATE('3','4','0','0','0') + +/* Class 38 - External Routine Exception */ +#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION MAKE_SQLSTATE('3','8','0','0','0') +#define ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED MAKE_SQLSTATE('3','8','0','0','1') +#define ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8','0','0','2') +#define ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('3','8','0','0','3') +#define ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8','0','0','4') + +/* Class 39 - External Routine Invocation Exception */ +#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION MAKE_SQLSTATE('3','9','0','0','0') +#define ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED MAKE_SQLSTATE('3','9','0','0','1') +#define ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('3','9','0','0','4') +#define ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9','P','0','1') +#define ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9','P','0','2') + +/* Class 3B - Savepoint Exception */ +#define ERRCODE_SAVEPOINT_EXCEPTION MAKE_SQLSTATE('3','B','0','0','0') +#define ERRCODE_S_E_INVALID_SPECIFICATION MAKE_SQLSTATE('3','B','0','0','1') + +/* Class 3D - Invalid Catalog Name */ +#define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3','D','0','0','0') + +/* Class 3F - Invalid Schema Name */ +#define ERRCODE_INVALID_SCHEMA_NAME MAKE_SQLSTATE('3','F','0','0','0') + +/* Class 40 - Transaction Rollback */ +#define ERRCODE_TRANSACTION_ROLLBACK MAKE_SQLSTATE('4','0','0','0','0') +#define ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('4','0','0','0','2') +#define ERRCODE_T_R_SERIALIZATION_FAILURE MAKE_SQLSTATE('4','0','0','0','1') +#define ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN MAKE_SQLSTATE('4','0','0','0','3') +#define ERRCODE_T_R_DEADLOCK_DETECTED MAKE_SQLSTATE('4','0','P','0','1') + +/* Class 42 - Syntax Error or Access Rule Violation */ +#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2','0','0','0') +#define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4','2','6','0','1') +#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2','5','0','1') +#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2','8','4','6') +#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2','8','0','3') +#define ERRCODE_WINDOWING_ERROR MAKE_SQLSTATE('4','2','P','2','0') +#define ERRCODE_INVALID_RECURSION MAKE_SQLSTATE('4','2','P','1','9') +#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2','8','3','0') +#define ERRCODE_INVALID_NAME MAKE_SQLSTATE('4','2','6','0','2') +#define ERRCODE_NAME_TOO_LONG MAKE_SQLSTATE('4','2','6','2','2') +#define ERRCODE_RESERVED_NAME MAKE_SQLSTATE('4','2','9','3','9') +#define ERRCODE_DATATYPE_MISMATCH MAKE_SQLSTATE('4','2','8','0','4') +#define ERRCODE_INDETERMINATE_DATATYPE MAKE_SQLSTATE('4','2','P','3','8') +#define ERRCODE_COLLATION_MISMATCH MAKE_SQLSTATE('4','2','P','2','1') +#define ERRCODE_INDETERMINATE_COLLATION MAKE_SQLSTATE('4','2','P','2','2') +#define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4','2','8','0','9') +#define ERRCODE_PARTITION_ERROR MAKE_SQLSTATE('4','2','P','2','3') +#define ERRCODE_INVALID_ATTRIBUTE MAKE_SQLSTATE('4','2','P','2','4') +#define ERRCODE_INVALID_AGG MAKE_SQLSTATE('4','2','P','2','5') +#define ERRCODE_RESOURCE_POOL_ERROR MAKE_SQLSTATE('4','2','P','2','6') +#define ERRCODE_PLAN_PARENT_NOT_FOUND MAKE_SQLSTATE('4','2','P','2','7') +#define ERRCODE_MODIFY_CONFLICTS MAKE_SQLSTATE('4','2','P','2','8') +#define ERRCODE_DISTRIBUTION_ERROR MAKE_SQLSTATE('4','2','P','2','9') +#define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4','2','7','0','3') +#define ERRCODE_UNDEFINED_CURSOR MAKE_SQLSTATE('3','4','0','0','1') +#define ERRCODE_UNDEFINED_DATABASE MAKE_SQLSTATE('3','D','0','0','0') +#define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4','2','8','8','3') +#define ERRCODE_UNDEFINED_PACKAGE MAKE_SQLSTATE('4','2','8','8','4') +#define ERRCODE_UNDEFINED_PSTATEMENT MAKE_SQLSTATE('2','6','0','1','0') +#define ERRCODE_UNDEFINED_SCHEMA MAKE_SQLSTATE('3','F','0','0','1') +#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2','P','0','1') +#define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4','2','P','0','2') +#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2','7','0','4') +#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2','7','0','1') +#define ERRCODE_DUPLICATE_CURSOR MAKE_SQLSTATE('4','2','P','0','3') +#define ERRCODE_DUPLICATE_DATABASE MAKE_SQLSTATE('4','2','P','0','4') +#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2','7','2','3') +#define ERRCODE_DUPLICATE_PACKAGE MAKE_SQLSTATE('4','2','7','2','4') +#define ERRCODE_DUPLICATE_PSTATEMENT MAKE_SQLSTATE('4','2','P','0','5') +#define ERRCODE_DUPLICATE_SCHEMA MAKE_SQLSTATE('4','2','P','0','6') +#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2','P','0','7') +#define ERRCODE_DUPLICATE_ALIAS MAKE_SQLSTATE('4','2','7','1','2') +#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2','7','1','0') +#define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4','2','7','0','2') +#define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4','2','7','2','5') +#define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4','2','P','0','8') +#define ERRCODE_AMBIGUOUS_ALIAS MAKE_SQLSTATE('4','2','P','0','9') +#define ERRCODE_INVALID_COLUMN_REFERENCE MAKE_SQLSTATE('4','2','P','1','0') +#define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4','2','6','1','1') +#define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4','2','P','1','1') +#define ERRCODE_INVALID_DATABASE_DEFINITION MAKE_SQLSTATE('4','2','P','1','2') +#define ERRCODE_INVALID_FUNCTION_DEFINITION MAKE_SQLSTATE('4','2','P','1','3') +#define ERRCODE_INVALID_PSTATEMENT_DEFINITION MAKE_SQLSTATE('4','2','P','1','4') +#define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4','2','P','1','5') +#define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4','2','P','1','6') +#define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4','2','P','1','7') +#define ERRCODE_INVALID_TEMP_OBJECTS MAKE_SQLSTATE('4','2','P','1','8') +#define ERRCODE_INVALID_PACKAGE_DEFINITION MAKE_SQLSTATE('4','2','P','1','9') +#define ERRCODE_UNDEFINED_KEY MAKE_SQLSTATE('4','2','7','0','5') +#define ERRCODE_DUPLICATE_KEY MAKE_SQLSTATE('4','2','7','1','1') +#define ERRCODE_UNDEFINED_CL_COLUMN MAKE_SQLSTATE('4','2','7','1','3') +#define ERRCODE_CL_FUNCTION_UPDATE MAKE_SQLSTATE('4','2','7','1','4') + +/* Class 44 - WITH CHECK OPTION Violation */ +#define ERRCODE_WITH_CHECK_OPTION_VIOLATION MAKE_SQLSTATE('4','4','0','0','0') + +/* Class 53 - Insufficient Resources */ +#define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5','3','0','0','0') +#define ERRCODE_DISK_FULL MAKE_SQLSTATE('5','3','1','0','0') +#define ERRCODE_OUT_OF_MEMORY MAKE_SQLSTATE('5','3','2','0','0') +#define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5','3','3','0','0') +#define ERRCODE_CONFIGURATION_LIMIT_EXCEEDED MAKE_SQLSTATE('5','3','4','0','0') +#define ERRCODE_OUT_OF_BUFFER MAKE_SQLSTATE('5','3','5','0','0') + +/* Class 54 - Program Limit Exceeded */ +#define ERRCODE_PROGRAM_LIMIT_EXCEEDED MAKE_SQLSTATE('5','4','0','0','0') +#define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5','4','0','0','1') +#define ERRCODE_TOO_MANY_COLUMNS MAKE_SQLSTATE('5','4','0','1','1') +#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('5','4','0','2','3') + +/* Class 55 - Object Not In Prerequisite State */ +#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5','0','0','0') +#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5','0','0','6') +#define ERRCODE_CANT_CHANGE_RUNTIME_PARAM MAKE_SQLSTATE('5','5','P','0','2') +#define ERRCODE_LOCK_NOT_AVAILABLE MAKE_SQLSTATE('5','5','P','0','3') + +/* Class 57 - Operator Intervention */ +#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7','0','0','0') +#define ERRCODE_QUERY_CANCELED MAKE_SQLSTATE('5','7','0','1','4') +#define ERRCODE_QUERY_INTERNAL_CANCEL MAKE_SQLSTATE('5','7','0','1','5') +#define ERRCODE_ADMIN_SHUTDOWN MAKE_SQLSTATE('5','7','P','0','1') +#define ERRCODE_CRASH_SHUTDOWN MAKE_SQLSTATE('5','7','P','0','2') +#define ERRCODE_CANNOT_CONNECT_NOW MAKE_SQLSTATE('5','7','P','0','3') +#define ERRCODE_DATABASE_DROPPED MAKE_SQLSTATE('5','7','P','0','4') +#define ERRCODE_RU_STOP_QUERY MAKE_SQLSTATE('5','7','P','0','5') + +/* Class 58 - System Error (errors external to PostgreSQL itself) */ +#define ERRCODE_SYSTEM_ERROR MAKE_SQLSTATE('5','8','0','0','0') +#define ERRCODE_IO_ERROR MAKE_SQLSTATE('5','8','0','3','0') +#define ERRCODE_UNDEFINED_FILE MAKE_SQLSTATE('5','8','P','0','1') +#define ERRCODE_DUPLICATE_FILE MAKE_SQLSTATE('5','8','P','0','2') +#define ERRCODE_FILE_READ_FAILED MAKE_SQLSTATE('5','8','P','0','3') +#define ERRCODE_FILE_WRITE_FAILED MAKE_SQLSTATE('5','8','P','0','4') +#define ERRCODE_INVALID_ENCRYPTED_COLUMN_DATA MAKE_SQLSTATE('2','2','0','0','Z') + +/* Class 59 - Recycle Object Operation Error */ +#define ERRCODE_RBIN_LOCK_NOT_AVAILABLE MAKE_SQLSTATE('5','9','0','0','0') +#define ERRCODE_RBIN_UNDEFINED_OBJECT MAKE_SQLSTATE('5','9','0','0','1') + +/* Class F0 - Configuration File Error */ +#define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F','0','0','0','0') +#define ERRCODE_LOCK_FILE_EXISTS MAKE_SQLSTATE('F','0','0','0','1') + +/* Class HV - Foreign Data Wrapper Error (SQL/MED) */ +#define ERRCODE_FDW_ERROR MAKE_SQLSTATE('H','V','0','0','0') +#define ERRCODE_FDW_COLUMN_NAME_NOT_FOUND MAKE_SQLSTATE('H','V','0','0','5') +#define ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED MAKE_SQLSTATE('H','V','0','0','2') +#define ERRCODE_FDW_FUNCTION_SEQUENCE_ERROR MAKE_SQLSTATE('H','V','0','1','0') +#define ERRCODE_FDW_INCONSISTENT_DESCRIPTOR_INFORMATION MAKE_SQLSTATE('H','V','0','2','1') +#define ERRCODE_FDW_INVALID_ATTRIBUTE_VALUE MAKE_SQLSTATE('H','V','0','2','4') +#define ERRCODE_FDW_INVALID_COLUMN_NAME MAKE_SQLSTATE('H','V','0','0','7') +#define ERRCODE_FDW_INVALID_COLUMN_NUMBER MAKE_SQLSTATE('H','V','0','0','8') +#define ERRCODE_FDW_INVALID_DATA_TYPE MAKE_SQLSTATE('H','V','0','0','4') +#define ERRCODE_FDW_INVALID_DATA_TYPE_DESCRIPTORS MAKE_SQLSTATE('H','V','0','0','6') +#define ERRCODE_FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER MAKE_SQLSTATE('H','V','0','9','1') +#define ERRCODE_FDW_INVALID_HANDLE MAKE_SQLSTATE('H','V','0','0','B') +#define ERRCODE_FDW_INVALID_OPTION_INDEX MAKE_SQLSTATE('H','V','0','0','C') +#define ERRCODE_FDW_INVALID_OPTION_NAME MAKE_SQLSTATE('H','V','0','0','D') +#define ERRCODE_FDW_INVALID_OPTOIN_DATA MAKE_SQLSTATE('H','V','0','0','E') +#define ERRCODE_FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH MAKE_SQLSTATE('H','V','0','9','0') +#define ERRCODE_FDW_INVALID_STRING_FORMAT MAKE_SQLSTATE('H','V','0','0','A') +#define ERRCODE_FDW_INVALID_USE_OF_NULL_POINTER MAKE_SQLSTATE('H','V','0','0','9') +#define ERRCODE_FDW_TOO_MANY_HANDLES MAKE_SQLSTATE('H','V','0','1','4') +#define ERRCODE_FDW_OUT_OF_MEMORY MAKE_SQLSTATE('H','V','0','0','1') +#define ERRCODE_FDW_NO_SCHEMAS MAKE_SQLSTATE('H','V','0','0','P') +#define ERRCODE_FDW_OPTION_NAME_NOT_FOUND MAKE_SQLSTATE('H','V','0','0','J') +#define ERRCODE_FDW_REPLY_HANDLE MAKE_SQLSTATE('H','V','0','0','K') +#define ERRCODE_FDW_SCHEMA_NOT_FOUND MAKE_SQLSTATE('H','V','0','0','Q') +#define ERRCODE_FDW_TABLE_NOT_FOUND MAKE_SQLSTATE('H','V','0','0','R') +#define ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION MAKE_SQLSTATE('H','V','0','0','L') +#define ERRCODE_FDW_UNABLE_TO_CREATE_REPLY MAKE_SQLSTATE('H','V','0','0','M') +#define ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION MAKE_SQLSTATE('H','V','0','0','N') +#define ERRCODE_FDW_INVALID_LIST_LENGTH MAKE_SQLSTATE('H','V','0','0','O') +#define ERRCODE_FDW_INVALID_SERVER_TYPE MAKE_SQLSTATE('H','V','0','0','S') +#define ERRCODE_FDW_OPERATION_NOT_SUPPORTED MAKE_SQLSTATE('H','V','0','2','5') +#define ERRCODE_FDW_CROSS_STORAGE_ENGINE_TRANSACTION_NOT_SUPPORTED MAKE_SQLSTATE('H','V','0','2','6') +#define ERRCODE_FDW_CROSS_STORAGE_ENGINE_QUERY_NOT_SUPPORTED MAKE_SQLSTATE('H','V','0','2','7') +#define ERRCODE_FDW_UPDATE_INDEXED_FIELD_NOT_SUPPORTED MAKE_SQLSTATE('H','V','0','2','8') +#define ERRCODE_FDW_TOO_MANY_INDEXES MAKE_SQLSTATE('H','V','0','2','9') +#define ERRCODE_FDW_KEY_SIZE_EXCEEDS_MAX_ALLOWED MAKE_SQLSTATE('H','V','0','3','0') +#define ERRCODE_FDW_DDL_IN_TRANSACTION_NOT_ALLOWED MAKE_SQLSTATE('H','V','0','3','1') +#define ERRCODE_FDW_TOO_MANY_INDEX_COLUMNS MAKE_SQLSTATE('H','V','0','3','2') +#define ERRCODE_FDW_INDEX_ON_NULLABLE_COLUMN_NOT_ALLOWED MAKE_SQLSTATE('H','V','0','3','3') +#define ERRCODE_FDW_TOO_MANY_DDL_CHANGES_IN_TRANSACTION_NOT_ALLOWED MAKE_SQLSTATE('H','V','0','3','4') + +/* Class P0 - PL/pgSQL Error */ +#define ERRCODE_PLPGSQL_ERROR MAKE_SQLSTATE('P','0','0','0','0') +#define ERRCODE_RAISE_EXCEPTION MAKE_SQLSTATE('P','0','0','0','1') +#define ERRCODE_NO_DATA_FOUND MAKE_SQLSTATE('P','0','0','0','2') +#define ERRCODE_TOO_MANY_ROWS MAKE_SQLSTATE('P','0','0','0','3') +#define ERRCODE_FORALL_NEED_DML MAKE_SQLSTATE('P','0','0','0','4') + +/* Class XX - Internal Error */ +#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X','0','0','0') +#define ERRCODE_DATA_CORRUPTED MAKE_SQLSTATE('X','X','0','0','1') +#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('X','X','0','0','2') +#define ERRCODE_STREAM_REMOTE_CLOSE_SOCKET MAKE_SQLSTATE('X','X','0','0','3') +#define ERRCODE_UNRECOGNIZED_NODE_TYPE MAKE_SQLSTATE('X','X','0','0','4') +#define ERRCODE_UNEXPECTED_NULL_VALUE MAKE_SQLSTATE('X','X','0','0','5') +#define ERRCODE_UNEXPECTED_NODE_STATE MAKE_SQLSTATE('X','X','0','0','6') +#define ERRCODE_NULL_JUNK_ATTRIBUTE MAKE_SQLSTATE('X','X','0','0','7') +#define ERRCODE_OPTIMIZER_INCONSISTENT_STATE MAKE_SQLSTATE('X','X','0','0','8') +#define ERRCODE_STREAM_DUPLICATE_QUERY_ID MAKE_SQLSTATE('X','X','0','0','9') +#define ERRCODE_INVALID_BUFFER MAKE_SQLSTATE('X','X','0','1','0') +#define ERRCODE_INVALID_BUFFER_REFERENCE MAKE_SQLSTATE('X','X','0','1','1') +#define ERRCODE_NODE_ID_MISSMATCH MAKE_SQLSTATE('X','X','0','1','2') +#define ERRCODE_CANNOT_MODIFY_XIDBASE MAKE_SQLSTATE('X','X','0','1','3') +#define ERRCODE_UNEXPECTED_CHUNK_VALUE MAKE_SQLSTATE('X','X','0','1','4') +#define ERRCODE_CN_RETRY_STUB MAKE_SQLSTATE('X','X','0','1','5') + +/* Class CG - CodeGen Error */ +#define ERRCODE_CODEGEN_ERROR MAKE_SQLSTATE('C','G','0','0','0') +#define ERRCODE_LOAD_IR_FUNCTION_FAILED MAKE_SQLSTATE('C','G','0','0','1') +#define ERRCODE_LOAD_INTRINSIC_FUNCTION_FAILED MAKE_SQLSTATE('C','G','0','0','2') + +/* Class YY - SQL Retry Error */ +#define ERRCODE_CONNECTION_RESET_BY_PEER MAKE_SQLSTATE('Y','Y','0','0','1') +#define ERRCODE_STREAM_CONNECTION_RESET_BY_PEER MAKE_SQLSTATE('Y','Y','0','0','2') +#define ERRCODE_LOCK_WAIT_TIMEOUT MAKE_SQLSTATE('Y','Y','0','0','3') +#define ERRCODE_CONNECTION_TIMED_OUT MAKE_SQLSTATE('Y','Y','0','0','4') +#define ERRCODE_SET_QUERY MAKE_SQLSTATE('Y','Y','0','0','5') +#define ERRCODE_OUT_OF_LOGICAL_MEMORY MAKE_SQLSTATE('Y','Y','0','0','6') +#define ERRCODE_SCTP_MEMORY_ALLOC MAKE_SQLSTATE('Y','Y','0','0','7') +#define ERRCODE_SCTP_NO_DATA_IN_BUFFER MAKE_SQLSTATE('Y','Y','0','0','8') +#define ERRCODE_SCTP_RELEASE_MEMORY_CLOSE MAKE_SQLSTATE('Y','Y','0','0','9') +#define ERRCODE_SCTP_TCP_DISCONNECT MAKE_SQLSTATE('Y','Y','0','1','0') +#define ERRCODE_SCTP_DISCONNECT MAKE_SQLSTATE('Y','Y','0','1','1') +#define ERRCODE_SCTP_REMOTE_CLOSE MAKE_SQLSTATE('Y','Y','0','1','2') +#define ERRCODE_SCTP_WAIT_POLL_UNKNOW MAKE_SQLSTATE('Y','Y','0','1','3') +#define ERRCODE_SNAPSHOT_INVALID MAKE_SQLSTATE('Y','Y','0','1','4') +#define ERRCODE_CONNECTION_RECEIVE_WRONG MAKE_SQLSTATE('Y','Y','0','1','5') +#define ERRCODE_STREAM_CONCURRENT_UPDATE MAKE_SQLSTATE('Y','Y','0','1','6') + +/* Class SI - SPI Interface Error */ +#define ERRCODE_SPI_ERROR MAKE_SQLSTATE('S','P','0','0','0') +#define ERRCODE_SPI_CONNECTION_FAILURE MAKE_SQLSTATE('S','P','0','0','1') +#define ERRCODE_SPI_FINISH_FAILURE MAKE_SQLSTATE('S','P','0','0','2') +#define ERRCODE_SPI_PREPARE_FAILURE MAKE_SQLSTATE('S','P','0','0','3') +#define ERRCODE_SPI_CURSOR_OPEN_FAILURE MAKE_SQLSTATE('S','P','0','0','4') +#define ERRCODE_SPI_EXECUTE_FAILURE MAKE_SQLSTATE('S','P','0','0','5') +#define ERRORCODE_SPI_IMPROPER_CALL MAKE_SQLSTATE('S','P','0','0','6') +#define ERRCODE_PLDEBUGGER_ERROR MAKE_SQLSTATE('D','0','0','0','0') +#define ERRCODE_DUPLICATE_BREAKPOINT MAKE_SQLSTATE('D','0','0','0','1') +#define ERRCODE_FUNCTION_HASH_NOT_INITED MAKE_SQLSTATE('D','0','0','0','2') +#define ERRCODE_BREAKPOINT_NOT_PRESENT MAKE_SQLSTATE('D','0','0','0','3') +#define ERRCODE_TARGET_SERVER_ALREADY_ATTACHED MAKE_SQLSTATE('D','0','0','0','4') +#define ERRCODE_TARGET_SERVER_NOT_ATTACHED MAKE_SQLSTATE('D','0','0','0','5') +#define ERRCODE_DEBUG_SERVER_ALREADY_SYNC MAKE_SQLSTATE('D','0','0','0','6') +#define ERRCODE_DEBUG_TARGET_SERVERS_NOT_IN_SYNC MAKE_SQLSTATE('D','0','0','0','7') +#define ERRCODE_TARGET_SERVER_ALREADY_SYNC MAKE_SQLSTATE('D','0','0','0','8') +#define ERRCODE_NONEXISTANT_VARIABLE MAKE_SQLSTATE('D','0','0','0','9') +#define ERRCODE_INVALID_TARGET_SESSION_ID MAKE_SQLSTATE('D','0','0','1','0') +#define ERRCODE_INVALID_OPERATION MAKE_SQLSTATE('D','0','0','1','1') +#define ERRCODE_MAX_DEBUG_SESSIONS_REACHED MAKE_SQLSTATE('D','0','0','1','2') +#define ERRCODE_MAX_BREAKPOINTS_REACHED MAKE_SQLSTATE('D','0','0','1','3') +#define ERRCODE_INITIALIZE_FAILED MAKE_SQLSTATE('D','0','0','1','4') +#define ERRCODE_RBTREE_INVALID_NODE_STATE MAKE_SQLSTATE('R','B','0','0','1') +#define ERRCODE_RBTREE_INVALID_ITERATOR_ORDER MAKE_SQLSTATE('R','B','0','0','2') +#define ERRCODE_DEBUG MAKE_SQLSTATE('D','B','0','0','1') +#define ERRCODE_LOG MAKE_SQLSTATE('D','B','0','1','0') +#define ERRCODE_OPERATE_FAILED MAKE_SQLSTATE('O','P','0','0','1') +#define ERRCODE_OPERATE_RESULT_NOT_EXPECTED MAKE_SQLSTATE('O','P','0','0','2') +#define ERRCODE_OPERATE_NOT_SUPPORTED MAKE_SQLSTATE('O','P','0','0','3') +#define ERRCODE_OPERATE_INVALID_PARAM MAKE_SQLSTATE('O','P','0','A','3') +#define ERRCODE_INDEX_OPERATOR_MISMATCH MAKE_SQLSTATE('O','P','0','0','4') +#define ERRCODE_NO_FUNCTION_PROVIDED MAKE_SQLSTATE('O','P','0','0','5') +#define ERRCODE_LOGICAL_DECODE_ERROR MAKE_SQLSTATE('L','L','0','0','1') +#define ERRCODE_RELFILENODEMAP MAKE_SQLSTATE('L','L','0','0','2') + +/* Class TS - Timeseries Error */ +#define ERRCODE_TS_COMMON_ERROR MAKE_SQLSTATE('T','S','0','0','0') +#define ERRCODE_TS_KEYTYPE_MISMATCH MAKE_SQLSTATE('T','S','0','0','1') + +/* Class SE - Security Error */ +#define ERRCODE_DUPLICATE_POLICY MAKE_SQLSTATE('4','2','7','1','4') +#define ERRCODE_DUPLICATE_LABEL MAKE_SQLSTATE('4','2','7','1','5') +#define ERRCODE_INVALID_AUDIT_LOG MAKE_SQLSTATE('S','E','0','0','1') diff --git a/windows/build/win32/libpq/include/libpqdll.def b/windows/build/win32/libpq/include/libpqdll.def new file mode 100644 index 0000000..e0e856f --- /dev/null +++ b/windows/build/win32/libpq/include/libpqdll.def @@ -0,0 +1,161 @@ +; DEF file for MS VC++ +LIBRARY LIBPQ +EXPORTS + PQconnectdb @ 1 + PQsetdbLogin @ 2 + PQconndefaults @ 3 + PQfinish @ 4 + PQreset @ 5 + PQrequestCancel @ 6 + PQdb @ 7 + PQuser @ 8 + PQpass @ 9 + PQhost @ 10 + PQport @ 11 + PQtty @ 12 + PQoptions @ 13 + PQstatus @ 14 + PQerrorMessage @ 15 + PQsocket @ 16 + PQbackendPID @ 17 + PQtrace @ 18 + PQuntrace @ 19 + PQsetNoticeProcessor @ 20 + PQexec @ 21 + PQnotifies @ 22 + PQsendQuery @ 23 + PQgetResult @ 24 + PQisBusy @ 25 + PQconsumeInput @ 26 + PQgetline @ 27 + PQputline @ 28 + PQgetlineAsync @ 29 + PQputnbytes @ 30 + PQendcopy @ 31 + PQfn @ 32 + PQresultStatus @ 33 + PQntuples @ 34 + PQnfields @ 35 + PQbinaryTuples @ 36 + PQfname @ 37 + PQfnumber @ 38 + PQftype @ 39 + PQfsize @ 40 + PQfmod @ 41 + PQcmdStatus @ 42 + PQoidStatus @ 43 + PQcmdTuples @ 44 + PQgetvalue @ 45 + PQgetlength @ 46 + PQgetisnull @ 47 + PQclear @ 48 + PQmakeEmptyPGresult @ 49 + PQprint @ 50 + PQdisplayTuples @ 51 + PQprintTuples @ 52 + lo_open @ 53 + lo_close @ 54 + lo_read @ 55 + lo_write @ 56 + lo_lseek @ 57 + lo_creat @ 58 + lo_tell @ 59 + lo_unlink @ 60 + lo_import @ 61 + lo_export @ 62 + pgresStatus @ 63 + PQmblen @ 64 + PQresultErrorMessage @ 65 + PQresStatus @ 66 + termPQExpBuffer @ 67 + appendPQExpBufferChar @ 68 + initPQExpBuffer @ 69 + resetPQExpBuffer @ 70 + PQoidValue @ 71 + PQclientEncoding @ 72 + PQenv2encoding @ 73 + appendBinaryPQExpBuffer @ 74 + appendPQExpBufferStr @ 75 + destroyPQExpBuffer @ 76 + createPQExpBuffer @ 77 + PQconninfoFree @ 78 + PQconnectPoll @ 79 + PQconnectStart @ 80 + PQflush @ 81 + PQisnonblocking @ 82 + PQresetPoll @ 83 + PQresetStart @ 84 + PQsetClientEncoding @ 85 + PQsetnonblocking @ 86 + PQfreeNotify @ 87 + PQescapeString @ 88 + PQescapeBytea @ 89 + printfPQExpBuffer @ 90 + appendPQExpBuffer @ 91 + PQexecParamsBatch @ 92 + PQexecPreparedBatch @ 93 + PQunescapeBytea @ 94 + PQfreemem @ 95 + PQtransactionStatus @ 96 + PQparameterStatus @ 97 + PQprotocolVersion @ 98 + PQsetErrorVerbosity @ 99 + PQsetNoticeReceiver @ 100 + PQexecParams @ 101 + PQsendQueryParams @ 102 + PQputCopyData @ 103 + PQputCopyEnd @ 104 + PQgetCopyData @ 105 + PQresultErrorField @ 106 + PQftable @ 107 + PQftablecol @ 108 + PQfformat @ 109 + PQexecPrepared @ 110 + PQsendQueryPrepared @ 111 + PQdsplen @ 112 + PQserverVersion @ 113 + PQgetssl @ 114 + ;pqsignal @ 115 + PQprepare @ 116 + PQsendPrepare @ 117 + PQgetCancel @ 118 + PQfreeCancel @ 119 + PQcancel @ 120 + lo_create @ 121 + PQinitSSL @ 122 + PQregisterThreadLock @ 123 + PQescapeStringConn @ 124 + PQescapeByteaConn @ 125 + PQencryptPassword @ 126 + PQisthreadsafe @ 127 + enlargePQExpBuffer @ 128 + PQnparams @ 129 + PQparamtype @ 130 + PQdescribePrepared @ 131 + PQdescribePortal @ 132 + PQsendDescribePrepared @ 133 + PQsendDescribePortal @ 134 + lo_truncate @ 135 + PQconnectionUsedPassword @ 136 + PQconnectionNeedsPassword @ 137 + lo_import_with_oid @ 138 + PQcopyResult @ 139 + PQsetResultAttrs @ 140 + PQsetvalue @ 141 + PQresultAlloc @ 142 + PQregisterEventProc @ 143 + PQinstanceData @ 144 + PQsetInstanceData @ 145 + PQresultInstanceData @ 146 + PQresultSetInstanceData @ 147 + PQfireResultCreateEvents @ 148 + PQconninfoParse @ 149 + PQinitOpenSSL @ 150 + PQescapeLiteral @ 151 + PQescapeIdentifier @ 152 + PQconnectdbParams @ 153 + PQconnectStartParams @ 154 + PQping @ 155 + PQpingParams @ 156 + PQlibVersion @ 157 + PQsetSingleRowMode @ 158 diff --git a/windows/build/win32/libpq/include/pg_config.h b/windows/build/win32/libpq/include/pg_config.h new file mode 100644 index 0000000..cdbfac2 --- /dev/null +++ b/windows/build/win32/libpq/include/pg_config.h @@ -0,0 +1,912 @@ +/* src/include/pg_config.h. Generated from pg_config.h.in by configure. */ +/* src/include/pg_config.h.in. Generated from configure.in by autoheader. */ + +/* Define to the type of arg 1 of 'accept' */ +#define ACCEPT_TYPE_ARG1 unsigned int + +/* Define to the type of arg 2 of 'accept' */ +#define ACCEPT_TYPE_ARG2 struct sockaddr * + +/* Define to the type of arg 3 of 'accept' */ +#define ACCEPT_TYPE_ARG3 socklen_t + +/* Define to the return type of 'accept' */ +#define ACCEPT_TYPE_RETURN unsigned int PASCAL + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* The normal alignment of `double', in bytes. */ +#define ALIGNOF_DOUBLE 8 + +/* The normal alignment of `int', in bytes. */ +#define ALIGNOF_INT 4 + +/* The normal alignment of `long', in bytes. */ +#define ALIGNOF_LONG 4 + +/* The normal alignment of `long long int', in bytes. */ +#define ALIGNOF_LONG_LONG_INT 8 + +/* The normal alignment of `short', in bytes. */ +#define ALIGNOF_SHORT 2 + +/* Size of a disk block --- this also limits the size of a tuple. You can set + it bigger if you need bigger tuples (although TOAST should reduce the need + to have large tuples, since fields can be spread across multiple tuples). + BLCKSZ must be a power of 2. The maximum possible value of BLCKSZ is + currently 2^15 (32768). This is determined by the 15-bit widths of the + lp_off and lp_len fields in ItemIdData (see include/storage/item/itemid.h). + Changing BLCKSZ requires an initdb. */ +#define BLCKSZ 8192 + +/* Define to the default TCP port number on which the server listens and to + which clients will try to connect. This can be overridden at run-time, but + it's convenient if your clients have the right default compiled in. + (--with-pgport=PORTNUM) */ +#define DEF_PGPORT 5432 + +/* Define to the default TCP port number as a string constant. */ +#define DEF_PGPORT_STR "5432" + +/* Define to build with GSSAPI support. (--with-gssapi) */ +//#define ENABLE_GSS 1 + +/* Define to build with PYTHON support. (--with-python) */ +/* #undef ENABLE_PYTHON2 */ +/* #undef ENABLE_PYTHON3 */ + +/* Define to 1 if you want National Language Support. (--enable-nls) */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you want to generate gauss product as single node. (--enable-privategauss) */ +/* #undef ENABLE_PRIVATEGAUSS */ + +/* Define to 1 if you want to generate gauss product as multiple nodes. (--enable-multiple-nodes) */ +/* #undef ENABLE_MULTIPLE_NODES */ + +/* Define to 1 if you want MOT support. (--enable-mot). + Supported only in single_node mode, not supported with (--enable-multiple-nodes) */ +/* #undef ENABLE_MOT */ + +/* Define to 1 if you want to check memory. (--enable-memory-check) */ +/* #undef ENABLE_MEMORY_CHECK */ + +/* Define to 1 if you want to check thread. (--enable-thread-check) */ +/* #undef ENABLE_THREAD_CHECK */ + +/* Define to 1 if you want to use default gcc. (--enable-default-gcc) */ +/* #undef ENABLE_DEFAULT_GCC */ + +/* Define to 1 to build client libraries as thread-safe code. + (--enable-thread-safety) */ +#define ENABLE_THREAD_SAFETY 1 + +/* Define to nothing if C supports flexible array members, and to 1 if it does + not. That way, with a declaration like `struct s { int n; double + d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99 + compilers. When computing the size of such an object, don't use 'sizeof + (struct s)' as it overestimates the size. Use 'offsetof (struct s, d)' + instead. Don't use 'offsetof (struct s, d[0])', as this doesn't work with + MSVC and with C++ compilers. */ +#define FLEXIBLE_ARRAY_MEMBER /**/ + +/* float4 values are passed by value if 'true', by reference if 'false' */ +#define FLOAT4PASSBYVAL true + +/* float8, int8, and related values are passed by value if 'true', by + reference if 'false' */ +#define FLOAT8PASSBYVAL false + +/* Define to 1 if getpwuid_r() takes a 5th argument. */ +/* #undef GETPWUID_R_5ARG */ + +/* Define to 1 if gettimeofday() takes only 1 argument. */ +/* #undef GETTIMEOFDAY_1ARG */ + +#ifdef GETTIMEOFDAY_1ARG +# define gettimeofday(a,b) gettimeofday(a) +#endif + +/* Define to 1 if you have the `append_history' function. */ +/* #undef HAVE_APPEND_HISTORY */ + +/* Define to 1 if you have the `cbrt' function. */ +#define HAVE_CBRT 1 + +/* Define to 1 if you have the `class' function. */ +/* #undef HAVE_CLASS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRTDEFS_H */ + +/* Define to 1 if you have the `crypt' function. */ +/* #undef HAVE_CRYPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* Define to 1 if you have the declaration of `fdatasync', and to 0 if you + don't. */ +#define HAVE_DECL_FDATASYNC 0 + +/* Define to 1 if you have the declaration of `F_FULLFSYNC', and to 0 if you + don't. */ +#define HAVE_DECL_F_FULLFSYNC 0 + +/* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you + don't. */ +#define HAVE_DECL_POSIX_FADVISE 0 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `strlcat', and to 0 if you + don't. */ +#define HAVE_DECL_STRLCAT 0 + +/* Define to 1 if you have the declaration of `strlcpy', and to 0 if you + don't. */ +#define HAVE_DECL_STRLCPY 0 + +/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you + don't. */ +#define HAVE_DECL_SYS_SIGLIST 0 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLD_H */ + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_READLINE_H */ + +/* Define to 1 if you have the `fdatasync' function. */ +/* #undef HAVE_FDATASYNC */ + +/* Define to 1 if you have the `fls' function. */ +/* #undef HAVE_FLS */ + +/* Define to 1 if you have the `fpclass' function. */ +/* #undef HAVE_FPCLASS */ + +/* Define to 1 if you have the `fp_class' function. */ +/* #undef HAVE_FP_CLASS */ + +/* Define to 1 if you have the `fp_class_d' function. */ +/* #undef HAVE_FP_CLASS_D */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FP_CLASS_H */ + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if your compiler understands __func__. */ +#define HAVE_FUNCNAME__FUNC 1 + +/* Define to 1 if your compiler understands __FUNCTION__. */ +/* #undef HAVE_FUNCNAME__FUNCTION */ + +/* Define to 1 if you have __sync_lock_test_and_set(int *) and friends. */ +#define HAVE_GCC_INT_ATOMICS 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +/* #undef HAVE_GETADDRINFO */ + +/* Define to 1 if you have the `gethostbyname_r' function. */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define to 1 if you have the `getifaddrs' function. */ +/* #undef HAVE_GETIFADDRS */ + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if you have the `getpeereid' function. */ +#define HAVE_GETPEEREID 1 + +/* Define to 1 if you have the `getpeerucred' function. */ +/* #undef HAVE_GETPEERUCRED */ + +/* Define to 1 if you have the `getpwuid_r' function. */ +/* #undef HAVE_GETPWUID_R */ + +/* Define to 1 if you have the `getrlimit' function. */ +/* #undef HAVE_GETRLIMIT */ + +/* Define to 1 if you have the `getrusage' function. */ +/* #undef HAVE_GETRUSAGE */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GSSAPI_GSSAPI_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GSSAPI_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_HISTORY_H */ + +/* Define to 1 if you have the `history_truncate_file' function. */ +/* #undef HAVE_HISTORY_TRUNCATE_FILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IFADDRS_H */ + +/* Define to 1 if you have the `inet_aton' function. */ +/* #undef HAVE_INET_ATON */ + +/* Define to 1 if the system has the type `int64'. */ +/* #undef HAVE_INT64 */ + +/* Define to 1 if the system has the type `int8'. */ +/* #undef HAVE_INT8 */ + +/* Define to 1 if the system has the type `intptr_t'. */ +#define HAVE_INTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the global variable 'int opterr'. */ +#define HAVE_INT_OPTERR 1 + +/* Define to 1 if you have the global variable 'int optreset'. */ +/* #undef HAVE_INT_OPTRESET */ + +/* Define to 1 if you have the global variable 'int timezone'. */ +#define HAVE_INT_TIMEZONE /**/ + +/* Define to 1 if you have support for IPv6. */ +#define HAVE_IPV6 1 + +/* Define to 1 if you have isinf(). */ +#define HAVE_ISINF 1 + +/* Define to 1 if `e_data' is member of `krb5_error'. */ +/* #undef HAVE_KRB5_ERROR_E_DATA */ + +/* Define to 1 if `text.data' is member of `krb5_error'. */ +/* #undef HAVE_KRB5_ERROR_TEXT_DATA */ + +/* Define to 1 if you have krb5_free_unparsed_name. */ +/* #undef HAVE_KRB5_FREE_UNPARSED_NAME */ + +/* Define to 1 if `client' is member of `krb5_ticket'. */ +/* #undef HAVE_KRB5_TICKET_CLIENT */ + +/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */ +/* #undef HAVE_KRB5_TICKET_ENC_PART2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LANGINFO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LDAP_H */ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +/* #undef HAVE_LIBCRYPTO */ + +/* Define to 1 if you have the `ldap' library (-lldap). */ +/* #undef HAVE_LIBLDAP */ + +/* Define to 1 if you have the `ldap_r' library (-lldap_r). */ +/* #undef HAVE_LIBLDAP_R */ + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Define to 1 if you have the `pam' library (-lpam). */ +/* #undef HAVE_LIBPAM */ + +/* Define if you have a function readline library */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `selinux' library (-lselinux). */ +/* #undef HAVE_LIBSELINUX */ + +/* Define to 1 if you have the `ssl' library (-lssl). */ +/* #undef HAVE_LIBSSL */ + +/* Define to 1 if you have the `wldap32' library (-lwldap32). */ +/* #undef HAVE_LIBWLDAP32 */ + +/* Define to 1 if you have the `xml2' library (-lxml2). */ +/* #undef HAVE_LIBXML2 */ + +/* Define to 1 if you have the `xslt' library (-lxslt). */ +/* #undef HAVE_LIBXSLT */ + +/* Define to 1 if you have the `z' library (-lz). */ +/* #undef HAVE_LIBZ */ + +/* Define to 1 if constants of type 'long long int' should have the suffix LL. + */ +#define HAVE_LL_CONSTANTS 1 + +/* Define to 1 if the system has the type `locale_t'. */ +#define HAVE_LOCALE_T 1 + +/* Define to 1 if `long int' works and is 64 bits. */ +/* #undef HAVE_LONG_INT_64 */ + +/* Define to 1 if the system has the type `long long int'. */ +#define HAVE_LONG_LONG_INT 1 + +/* Define to 1 if `long long int' works and is 64 bits. */ +#define HAVE_LONG_LONG_INT_64 1 + +/* Define to 1 if you have the `mbstowcs_l' function. */ +/* #undef HAVE_MBSTOWCS_L */ + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if the system has the type `MINIDUMP_TYPE'. */ +/* #undef HAVE_MINIDUMP_TYPE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_TCP_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_IF_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OSSP_UUID_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PAM_PAM_APPL_H */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef HAVE_POLL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_POLL_H */ + +/* Define to 1 if you have the `posix_fadvise' function. */ +/* #undef HAVE_POSIX_FADVISE */ + +/* Define to 1 if you have the POSIX signal interface. */ +/* #undef HAVE_POSIX_SIGNALS */ + +/* Define to 1 if the assembler supports PPC's LWARX mutex hint bit. */ +/* #undef HAVE_PPC_LWARX_MUTEX_HINT */ + +/* Define to 1 if you have the `pstat' function. */ +/* #undef HAVE_PSTAT */ + +/* Define to 1 if the PS_STRINGS thing exists. */ +/* #undef HAVE_PS_STRINGS */ + +/* Define if you have POSIX threads libraries and header files. */ +/* #undef HAVE_PTHREAD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `random' function. */ +/* #undef HAVE_RANDOM */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_READLINE_H */ + +/* Define to 1 if you have the `readlink' function. */ +/* #undef HAVE_READLINK */ + +/* Define to 1 if you have the `rint' function. */ +#define HAVE_RINT 1 + +/* Define to 1 if you have the global variable + 'rl_completion_append_character'. */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define to 1 if you have the `rl_completion_matches' function. */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define to 1 if you have the `rl_filename_completion_function' function. */ +/* #undef HAVE_RL_FILENAME_COMPLETION_FUNCTION */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SECURITY_PAM_APPL_H */ + +/* Define to 1 if you have the `setproctitle' function. */ +/* #undef HAVE_SETPROCTITLE */ + +/* Define to 1 if you have the `setsid' function. */ +/* #undef HAVE_SETSID */ + +/* Define to 1 if you have the `sigprocmask' function. */ +/* #undef HAVE_SIGPROCMASK */ + +/* Define to 1 if you have sigsetjmp(). */ +/* #undef HAVE_SIGSETJMP */ + +/* Define to 1 if the system has the type `sig_atomic_t'. */ +#define HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if you have the `snprintf' function. */ +/* #undef HAVE_SNPRINTF */ + +/* Define to 1 if you have spinlocks. */ +#define HAVE_SPINLOCKS 1 + +/* Define to 1 if you have the `srandom' function. */ +/* #undef HAVE_SRANDOM */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +/* #undef HAVE_STRERROR_R */ + +/* Define to 1 if cpp supports the ANSI # stringizing operator. */ +#define HAVE_STRINGIZE 1 + +/* Define to 1 if you have the header file. */ +// #define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +/* #undef HAVE_STRLCAT */ + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef HAVE_STRLCPY */ + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +/* #undef HAVE_STRTOQ */ + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the `strtouq' function. */ +/* #undef HAVE_STRTOUQ */ + +/* Define to 1 if the system has the type `struct addrinfo'. */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if the system has the type `struct cmsgcred'. */ +/* #undef HAVE_STRUCT_CMSGCRED */ + +/* Define to 1 if the system has the type `struct option'. */ +#define HAVE_STRUCT_OPTION 1 + +/* Define to 1 if `sa_len' is member of `struct sockaddr'. */ +/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */ + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 + +/* Define to 1 if `ss_len' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */ + +/* Define to 1 if `__ss_family' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if `__ss_len' is member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN */ + +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +/* #undef HAVE_STRUCT_TM_TM_ZONE */ + +/* Define to 1 if you have the `symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sync_file_range' function. */ +/* #undef HAVE_SYNC_FILE_RANGE */ + +/* Define to 1 if you have the syslog interface. */ +/* #undef HAVE_SYSLOG */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IPC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_POLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PSTAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_RESOURCE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SEM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SHM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TAS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UCRED_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERMIOS_H */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +/* #undef HAVE_TM_ZONE */ + +/* Define to 1 if you have the `towlower' function. */ +#define HAVE_TOWLOWER 1 + +/* Define to 1 if you have the external array `tzname'. */ +#define HAVE_TZNAME 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UCRED_H */ + +/* Define to 1 if the system has the type `uint64'. */ +/* #undef HAVE_UINT64 */ + +/* Define to 1 if the system has the type `uint8'. */ +/* #undef HAVE_UINT8 */ + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if the system has the type `union semun'. */ +/* #undef HAVE_UNION_SEMUN */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have unix sockets. */ +/* #undef HAVE_UNIX_SOCKETS */ + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the `utimes' function. */ +/* #undef HAVE_UTIMES */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_H */ + +/* Define to 1 if you have the `vsnprintf' function. */ +/* #undef HAVE_VSNPRINTF */ + +/* Define to 1 if you have the `waitpid' function. */ +/* #undef HAVE_WAITPID */ + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcstombs' function. */ +#define HAVE_WCSTOMBS 1 + +/* Define to 1 if you have the `wcstombs_l' function. */ +/* #undef HAVE_WCSTOMBS_L */ + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINLDAP_H */ + +/* Define to the appropriate snprintf format for 64-bit ints. */ +#define INT64_FORMAT "%lld" + +/* Define to build with Kerberos 5 support. (--with-krb5) */ +/* #undef KRB5 */ + +/* Define to 1 if you have __cpuid. */ +/* #undef HAVE__CPUID */ + +/* Define to 1 if you have __get_cpuid. */ +#define HAVE__GET_CPUID 1 + +/* Define to 1 if `locale_t' requires . */ +/* #undef LOCALE_T_IN_XLOCALE */ + +/* Define as the maximum alignment requirement of any C data type. */ +#define MAXIMUM_ALIGNOF 8 + +/* Define bytes to use libc memset(). */ +#define MEMSET_LOOP_LIMIT 1024 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "community@opengauss.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "Postgres-XC" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "Postgres-XC 1.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "postgres-xc" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.1" + +/* Define to the name of the default PostgreSQL service principal in Kerberos. + (--with-krb-srvnam=NAME) */ +#define PG_KRB_SRVNAM "postgres" + +/* PostgreSQL major version as a string */ +#define PG_MAJORVERSION "9.2" + +/* PostgreSQL version as a string */ +#define PG_VERSION "9.2.4" + +/* Gaussdb version as a string*/ +#define DEF_GS_VERSION "(GaussDB Kernel V500R001C20 build ) compiled at 2021-05-18 17:44:23 commit 0 last mr " + +/* PostgreSQL version as a number */ +#define PG_VERSION_NUM 90204 + +/* Postgres-XC major version as a string */ +#define PGXC_MAJORVERSION "1.1" + +/* Postgres-XC version as a string */ +#define PGXC_VERSION "1.1" + +/* Postgres-XC version as a number */ +#define PGXC_VERSION_NUM + +/* A string containing the version number, platform, and C compiler */ +#define PG_VERSION_STR "PostgreSQL 9.2.4 (GaussDB Kernel V500R001C20 build ) compiled at 2021-05-18 17:44:23 commit 0 last mr on i686-pc-mingw32, compiled by gcc.exe (GCC) 5.3.0, 32-bit" + +/* A string containing the version number of Postgres-XC, platform, and C compiler */ +#define PGXC_VERSION_STR "Postgres-XC 1.1 on i686-pc-mingw32, based on PostgreSQL 9.2.4, compiled by gcc.exe (GCC) 5.3.0, 32-bit" + +/* Define to 1 to allow profiling output to be saved separately for each + process. */ +/* #undef PROFILE_PID_DIR */ + +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* RELSEG_SIZE is the maximum number of blocks allowed in one disk file. Thus, + the maximum size of a single file is RELSEG_SIZE * BLCKSZ; relations bigger + than that are divided into multiple files. RELSEG_SIZE * BLCKSZ must be + less than your OS' limit on file size. This is often 2 GB or 4GB in a + 32-bit operating system, unless you have large file support enabled. By + default, we make the limit 1 GB to avoid any possible integer-overflow + problems within the OS. A limit smaller than necessary only means we divide + a large relation into more chunks than necessary, so it seems best to err + in the direction of a small limit. A power-of-2 value is recommended to + save a few cycles in md.c, but is not absolutely required. Changing + RELSEG_SIZE requires an initdb. */ +#define RELSEG_SIZE 131072 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if strerror_r() returns a int. */ +/* #undef STRERROR_R_INT */ + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define to the appropriate snprintf format for unsigned 64-bit ints. */ +#define UINT64_FORMAT "%llu" + +/* Define to 1 to build with assertion checks. (--enable-cassert) */ +/* #undef USE_ASSERT_CHECKING */ + +/* Define to 1 to enable llt test. (--enable-llt) */ +/* #undef ENABLE_LLT */ + +/* Define to 1 to enable llvm test. (--enable-llvm) */ +#define ENABLE_LLVM_COMPILE 1 + +/* Define to 1 to enable ut test. (--enable-ut) */ +/* #undef ENABLE_UT */ + +/* Define to 1 to enable qunit test. (--enable-qunit) */ +/* #undef ENABLE_QUNIT */ + +/* Define to 1 to build with Bonjour support. (--with-bonjour) */ +/* #undef USE_BONJOUR */ + +/* Define to 1 if you want float4 values to be passed by value. + (--enable-float4-byval) */ +#define USE_FLOAT4_BYVAL 1 + +/* Define to 1 if you want float8, int8, etc values to be passed by value. + (--enable-float8-byval) */ +/* #undef USE_FLOAT8_BYVAL */ + +/* Define to 1 if "static inline" works without unwanted warnings from + compilations where static inline functions are defined but not called. */ +#define USE_INLINE 1 + +/* Define to 1 if you want 64-bit integer timestamp and interval support. + (--enable-integer-datetimes) */ +#define USE_INTEGER_DATETIMES 1 + +/* Define to 1 to build with LDAP support. (--with-ldap) */ +/* #undef USE_LDAP */ + +/* Define to 1 to build with XML support. (--with-libxml) */ +/* #undef USE_LIBXML */ + +/* Define to 1 to use XSLT support when building contrib/xml2. + (--with-libxslt) */ +/* #undef USE_LIBXSLT */ + +/* Define to select named POSIX semaphores. */ +/* #undef USE_NAMED_POSIX_SEMAPHORES */ + +/* Define to 1 to build with PAM support. (--with-pam) */ +/* #undef USE_PAM */ + +/* Use replacement snprintf() functions. */ +#define USE_REPL_SNPRINTF 1 + +/* Define to 1 to use slicing-by-8 algorithm. */ +/* #undef USE_SLICING_BY_8_CRC32C */ + +/* Define to 1 use Intel SSE 4.2 CRC instructions. */ +/* #undef USE_SSE42_CRC32C */ + +/* Define to 1 to use Intel SSSE 4.2 CRC instructions with a runtime check. */ +#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK 1 + +/* Define to build with (Open)SSL support. (--with-openssl) */ +#define USE_SSL 1 + +/* Define to select SysV-style semaphores. */ +/* #undef USE_SYSV_SEMAPHORES */ + +/* Define to select SysV-style shared memory. */ +/* #undef USE_SYSV_SHARED_MEMORY */ + +/* Define to select unnamed POSIX semaphores. */ +/* #undef USE_UNNAMED_POSIX_SEMAPHORES */ + +/* Define to select Win32-style semaphores. */ +#define USE_WIN32_SEMAPHORES 1 + +/* Define to select Win32-style shared memory. */ +#define USE_WIN32_SHARED_MEMORY 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Size of a WAL file block. This need have no particular relation to BLCKSZ. + XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O, + XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O + buffers, else direct I/O may fail. Changing XLOG_BLCKSZ requires an initdb. + */ +#define XLOG_BLCKSZ 8192 + +/* XLOG_SEG_SIZE is the size of a single WAL file. This must be a power of 2 + and larger than XLOG_BLCKSZ (preferably, a great deal larger than + XLOG_BLCKSZ). Changing XLOG_SEG_SIZE requires an initdb. */ +#define XLOG_SEG_SIZE (16 * 1024 * 1024) + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type wide enough to hold a pointer, + if such a type exists, and if the system does not define it. */ +/* #undef intptr_t */ + +/* Define to empty if the C compiler does not understand signed types. */ +/* #undef signed */ + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +/* #undef uintptr_t */ + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +/* #undef volatile */ diff --git a/windows/build/win32/libpq/include/pg_config_os.h b/windows/build/win32/libpq/include/pg_config_os.h new file mode 100644 index 0000000..6bd7754 --- /dev/null +++ b/windows/build/win32/libpq/include/pg_config_os.h @@ -0,0 +1,498 @@ +/* src/include/port/win32.h */ + +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define WIN32_ONLY_COMPILER +#endif + +/* + * Make sure _WIN32_WINNT has the minimum required value. + * Leave a higher value in place. + */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501 +#undef _WIN32_WINNT +#endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif +/* + * Always build with SSPI support. Keep it as a #define in case + * we want a switch to disable it sometime in the future. + */ +#ifndef __BORLANDC__ +#define ENABLE_SSPI 1 +#endif + +/* undefine and redefine after #include */ +#undef mkdir + +#undef ERROR + +/* + * The Mingw64 headers choke if this is already defined - they + * define it themselves. + */ +#if !defined(__MINGW64_VERSION_MAJOR) || defined(WIN32_ONLY_COMPILER) +#define _WINSOCKAPI_ +#endif +#include +#include +#define _WINSOCKAPI_ +#include +#undef small +#include +#include +#include +#include +#ifndef __BORLANDC__ +#include /* for non-unicode version */ +#endif +#undef near + +/* Must be here to avoid conflicting with prototype in windows.h */ +#define mkdir(a, b) mkdir(a) + +#define ftruncate(a, b) chsize(a, b) + +/* Windows doesn't have fsync() as such, use _commit() */ +#define fsync(fd) _commit(fd) + +/* + * For historical reasons, we allow setting wal_sync_method to + * fsync_writethrough on Windows, even though it's really identical to fsync + * (both code paths wind up at _commit()). + */ +#define HAVE_FSYNC_WRITETHROUGH +#define FSYNC_WRITETHROUGH_IS_FSYNC + +#define USES_WINSOCK + +/* defines for dynamic linking on Win32 platform */ +#if defined(WIN32) || defined(__CYGWIN__) + +#if __GNUC__ && !defined(__declspec) +#error You need egcs 1.1 or newer for compiling! +#endif + +#ifdef BUILDING_DLL +#define PGDLLIMPORT __declspec(dllexport) +#else /* not BUILDING_DLL */ +#define PGDLLIMPORT __declspec(dllimport) +#endif + +#ifdef _MSC_VER +#define PGDLLEXPORT __declspec(dllexport) +#else +#define PGDLLEXPORT +#endif +#else /* not CYGWIN, not MSVC, not MingW */ +#define PGDLLIMPORT +#define PGDLLEXPORT +#endif + +/* + * IPC defines + */ +#undef HAVE_UNION_SEMUN +#define HAVE_UNION_SEMUN 1 + +#define IPC_RMID 256 +#define IPC_CREAT 512 +#define IPC_EXCL 1024 +#define IPC_PRIVATE 234564 +#define IPC_NOWAIT 2048 +#define IPC_STAT 4096 + +#define EACCESS 2048 +#ifndef EIDRM +#define EIDRM 4096 +#endif + +#define SETALL 8192 +#define GETNCNT 16384 +#define GETVAL 65536 +#define SETVAL 131072 +#define GETPID 262144 + +/* + * Signal stuff + * + * For WIN32, there is no wait() call so there are no wait() macros + * to interpret the return value of system(). Instead, system() + * return values < 0x100 are used for exit() termination, and higher + * values are used to indicated non-exit() termination, which is + * similar to a unix-style signal exit (think SIGSEGV == + * STATUS_ACCESS_VIOLATION). Return values are broken up into groups: + * + * http://msdn2.microsoft.com/en-gb/library/aa489609.aspx + * + * NT_SUCCESS 0 - 0x3FFFFFFF + * NT_INFORMATION 0x40000000 - 0x7FFFFFFF + * NT_WARNING 0x80000000 - 0xBFFFFFFF + * NT_ERROR 0xC0000000 - 0xFFFFFFFF + * + * Effectively, we don't care on the severity of the return value from + * system(), we just need to know if it was because of exit() or generated + * by the system, and it seems values >= 0x100 are system-generated. + * See this URL for a list of WIN32 STATUS_* values: + * + * Wine (URL used in our error messages) - + * http://source.winehq.org/source/include/ntstatus.h + * Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt + * MS SDK - http://www.nologs.com/ntstatus.html + * + * It seems the exception lists are in both ntstatus.h and winnt.h, but + * ntstatus.h has a more comprehensive list, and it only contains + * exception values, rather than winnt, which contains lots of other + * things: + * + * http://www.microsoft.com/msj/0197/exception/exception.aspx + * + * The ExceptionCode parameter is the number that the operating system + * assigned to the exception. You can see a list of various exception codes + * in WINNT.H by searching for #defines that start with "STATUS_". For + * example, the code for the all-too-familiar STATUS_ACCESS_VIOLATION is + * 0xC0000005. A more complete set of exception codes can be found in + * NTSTATUS.H from the Windows NT DDK. + * + * Some day we might want to print descriptions for the most common + * exceptions, rather than printing an include file name. We could use + * RtlNtStatusToDosError() and pass to FormatMessage(), which can print + * the text of error values, but MinGW does not support + * RtlNtStatusToDosError(). + */ +#define WIFEXITED(w) (((w)&0XFFFFFF00) == 0) +#define WIFSIGNALED(w) (!WIFEXITED(w)) +#define WEXITSTATUS(w) (w) +#define WTERMSIG(w) (w) + +#define sigmask(sig) (1 << ((sig)-1)) + +/* Signal function return values */ +#undef SIG_DFL +#undef SIG_ERR +#undef SIG_IGN +#define SIG_DFL ((pqsigfunc)0) +#define SIG_ERR ((pqsigfunc)-1) +#define SIG_IGN ((pqsigfunc)1) + +/* Some extra signals */ +#define SIGHUP 1 +#define SIGQUIT 3 +#define SIGTRAP 5 +#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */ +#define SIGKILL 9 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGSTOP 17 +#define SIGTSTP 18 +#define SIGCONT 19 +#define SIGCHLD 20 +#define SIGTTIN 21 +#define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */ +#define SIGWINCH 28 +#ifndef __BORLANDC__ +#define SIGUSR1 30 +#define SIGUSR2 31 +#endif + +/* + * New versions of mingw have gettimeofday() and also declare + * struct timezone to support it. + */ +#ifndef HAVE_GETTIMEOFDAY +struct timezone { + int tz_minuteswest; /* Minutes west of GMT. */ + int tz_dsttime; /* Nonzero if DST is ever in effect. */ +}; +#endif + +/* for setitimer in backend/port/win32/timer.c */ +#define ITIMER_REAL 0 +struct itimerval { + struct timeval it_interval; + struct timeval it_value; +}; + +int setitimer(int which, const struct itimerval* value, struct itimerval* ovalue); + +/* + * WIN32 does not provide 64-bit off_t, but does provide the functions operating + * with 64-bit offsets. + */ +#define pgoff_t __int64 +#ifdef WIN32_ONLY_COMPILER +#define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin) +#define ftello(stream) _ftelli64(stream) +#else +#ifndef fseeko +#define fseeko(stream, offset, origin) fseeko64(stream, offset, origin) +#endif +#ifndef ftello +#define ftello(stream) ftello64(stream) +#endif +#endif + +/* + * Supplement to . + * + * Perl already has typedefs for uid_t and gid_t. + */ +#ifndef PLPERL_HAVE_UID_GID +typedef int uid_t; +typedef int gid_t; +#endif +typedef long key_t; + +#ifdef WIN32_ONLY_COMPILER +typedef int pid_t; +#endif + +/* + * Supplement to . + */ +#define lstat(path, sb) stat((path), (sb)) + +/* + * Supplement to . + * This is the same value as _O_NOINHERIT in the MS header file. This is + * to ensure that we don't collide with a future definition. It means + * we cannot use _O_NOINHERIT ourselves. + */ +#define O_DSYNC 0x0080 + +/* + * Supplement to . + */ +#ifndef _MINGW32 +#undef EAGAIN +#undef EINTR +#define EINTR WSAEINTR +#define EAGAIN WSAEWOULDBLOCK +#ifndef EMSGSIZE +#define EMSGSIZE WSAEMSGSIZE +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif +#ifndef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif +#ifndef ECONNRESET +#define ECONNRESET WSAECONNRESET +#endif +#ifndef EINPROGRESS +#define EINPROGRESS WSAEINPROGRESS +#endif +#ifndef ENOBUFS +#define ENOBUFS WSAENOBUFS +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#endif +#ifndef EBADFD +#define EBADFD WSAENOTSOCK +#endif +#ifndef EOPNOTSUPP +#define EOPNOTSUPP WSAEOPNOTSUPP +#endif +#else // defined(_MINGW32) +#undef EINTR +#undef EAGAIN +#undef EMSGSIZE +#undef EAFNOSUPPORT +#undef EWOULDBLOCK +#undef ECONNRESET +#undef EINPROGRESS +#undef ENOBUFS +#undef EPROTONOSUPPORT +#undef ECONNREFUSED +#undef EBADFD +#undef EOPNOTSUPP + +#define EINTR WSAEINTR +#define EAGAIN WSAEWOULDBLOCK +#define EMSGSIZE WSAEMSGSIZE +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EWOULDBLOCK WSAEWOULDBLOCK +#define ECONNRESET WSAECONNRESET +#define EINPROGRESS WSAEINPROGRESS +#define ENOBUFS WSAENOBUFS +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define ECONNREFUSED WSAECONNREFUSED +#define EBADFD WSAENOTSOCK +#define EOPNOTSUPP WSAEOPNOTSUPP +#endif + + +/* + * For Microsoft Visual Studio 2010 and above we intentionally redefine + * the regular Berkeley error constants and set them to the WSA constants. + * Note that this will break if those constants are used for anything else + * than Windows Sockets errors. + */ +#if _MSC_VER >= 1600 +#pragma warning(disable : 4005) +#define EMSGSIZE WSAEMSGSIZE +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define ECONNRESET WSAECONNRESET +#define EINPROGRESS WSAEINPROGRESS +#define ENOBUFS WSAENOBUFS +#define ECONNREFUSED WSAECONNREFUSED +#define EOPNOTSUPP WSAEOPNOTSUPP +#pragma warning(default : 4005) +#endif + +/* + * Extended locale functions with gratuitous underscore prefixes. + * (These APIs are nevertheless fully documented by Microsoft.) + */ +#define locale_t _locale_t +#define tolower_l _tolower_l +#define toupper_l _toupper_l +#define towlower_l _towlower_l +#define towupper_l _towupper_l +#define isdigit_l _isdigit_l +#define iswdigit_l _iswdigit_l +#define isalpha_l _isalpha_l +#define iswalpha_l _iswalpha_l +#define isalnum_l _isalnum_l +#define iswalnum_l _iswalnum_l +#define isupper_l _isupper_l +#define iswupper_l _iswupper_l +#define islower_l _islower_l +#define iswlower_l _iswlower_l +#define isgraph_l _isgraph_l +#define iswgraph_l _iswgraph_l +#define isprint_l _isprint_l +#define iswprint_l _iswprint_l +#define ispunct_l _ispunct_l +#define iswpunct_l _iswpunct_l +#define isspace_l _isspace_l +#define iswspace_l _iswspace_l +#define strcoll_l _strcoll_l +#define wcscoll_l _wcscoll_l +#define wcstombs_l _wcstombs_l +#define mbstowcs_l _mbstowcs_l + +/* In backend/port/win32/signal.c */ +extern PGDLLIMPORT volatile int pg_signal_queue; +extern PGDLLIMPORT int pg_signal_mask; +extern HANDLE pgwin32_signal_event; +extern HANDLE pgwin32_initial_signal_pipe; + +#define UNBLOCKED_SIGNAL_QUEUE() (pg_signal_queue & ~pg_signal_mask) + +void pgwin32_signal_initialize(void); +HANDLE pgwin32_create_signal_listener(pid_t pid); +void pgwin32_dispatch_queued_signals(void); +void pg_queue_signal(int signum); + +/* In backend/port/win32/socket.c */ +#ifndef FRONTEND +#define socket(af, type, protocol) pgwin32_socket(af, type, protocol) +#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen) +#define connect(s, name, namelen) pgwin32_connect(s, name, namelen) +#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout) +#define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags) +#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags) + +SOCKET pgwin32_socket(int af, int type, int protocol); +SOCKET pgwin32_accept(SOCKET s, struct sockaddr* addr, int* addrlen); +int pgwin32_connect(SOCKET s, const struct sockaddr* name, int namelen); +int pgwin32_select(int nfds, fd_set* readfs, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout); +int pgwin32_recv(SOCKET s, char* buf, int len, int flags); +int pgwin32_send(SOCKET s, const void* buf, int len, int flags); + +const char* pgwin32_socket_strerror(int err); +int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout); + +extern int pgwin32_noblock; + +/* in backend/port/win32/security.c */ +extern int pgwin32_is_admin(void); +extern int pgwin32_is_service(void); +#endif + +/* in backend/port/win32_shmem.c */ +extern int pgwin32_ReserveSharedMemoryRegion(HANDLE); + +/* in backend/port/win32/crashdump.c */ +extern void pgwin32_install_crashdump_handler(void); + +/* in port/win32error.c */ +extern void _dosmaperr(unsigned long); + +/* in port/win32env.c */ +extern int pgwin32_putenv(const char*); +extern void pgwin32_unsetenv(const char*); + +#define putenv(x) pgwin32_putenv(x) +#define unsetenv(x) pgwin32_unsetenv(x) + +/* Things that exist in MingW headers, but need to be added to MSVC & BCC */ +#ifdef WIN32_ONLY_COMPILER + +#ifndef _WIN64 +typedef long ssize_t; +#else +typedef __int64 ssize_t; +#endif + +#ifndef __BORLANDC__ +typedef unsigned short mode_t; + +#define S_IRUSR _S_IREAD +#define S_IWUSR _S_IWRITE +#define S_IXUSR _S_IEXEC +#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +/* see also S_IRGRP etc below */ +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#endif /* __BORLANDC__ */ + +#define F_OK 0 +#define X_OK 1 /* test for execute or search permission */ +#define W_OK 2 +#define R_OK 4 + +#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF)) +#define isnan(x) _isnan(x) + +/* Pulled from Makefile.port in mingw */ +#define DLSUFFIX ".dll" + +#ifdef __BORLANDC__ + +/* for port/dirent.c */ +#ifndef INVALID_FILE_ATTRIBUTES +#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +#endif + +/* for port/open.c */ +#ifndef O_RANDOM +#define O_RANDOM 0x0010 /* File access is primarily random */ +#define O_SEQUENTIAL 0x0020 /* File access is primarily sequential */ +#define O_TEMPORARY 0x0040 /* Temporary file bit */ +#define O_SHORT_LIVED 0x1000 /* Temporary storage file, try not to flush */ +#define _O_SHORT_LIVED O_SHORT_LIVED +#endif /* ifndef O_RANDOM */ +#endif /* __BORLANDC__ */ +#endif /* WIN32_ONLY_COMPILER */ + +/* These aren't provided by either MingW or MSVC */ +#ifndef __BORLANDC__ +#define S_IRGRP 0 +#define S_IWGRP 0 +#define S_IXGRP 0 +#define S_IRWXG 0 +#define S_IROTH 0 +#define S_IWOTH 0 +#define S_IXOTH 0 +#define S_IRWXO 0 + +#endif /* __BORLANDC__ */ diff --git a/windows/build/win32/libpq/include/pg_config_paths.h b/windows/build/win32/libpq/include/pg_config_paths.h new file mode 100644 index 0000000..e708380 --- /dev/null +++ b/windows/build/win32/libpq/include/pg_config_paths.h @@ -0,0 +1,12 @@ +#define PGBINDIR "" +#define PGSHAREDIR "" +#define SYSCONFDIR "" +#define INCLUDEDIR "" +#define PKGINCLUDEDIR "" +#define INCLUDEDIRSERVER "" +#define LIBDIR "" +#define PKGLIBDIR "" +#define LOCALEDIR "" +#define DOCDIR "" +#define HTMLDIR "" +#define MANDIR "" diff --git a/windows/build/win32/libpq/project.sh b/windows/build/win32/libpq/project.sh new file mode 100644 index 0000000..f25f536 --- /dev/null +++ b/windows/build/win32/libpq/project.sh @@ -0,0 +1,446 @@ +# Copyright Huawei Technologies Co., Ltd. 2010-2018. All rights reserved. +#!/bin/bash +MD="mkdir -p" +RM="rm -rf" +CP="cp -r" +ROOT_DIR=$LIB_GAUSSDB_DIR +#ROOT_DIR=`pwd`/.. +SRC_DIR=$ROOT_DIR/../open_source/opengauss/src +LIBPQ_WIN32_DIR=$ROOT_DIR/libpq-win32 +PREPARED_DIR=$LIBPQ_WIN32_DIR +EXPORT_DIR=$LIBPQ_WIN32_DIR/libpq-export + +### function ### +function copy_file() +{ +file=$1 #file name +src=$2 #source directory +dst=$3 #target directory +if [ ! -f "$src"/"$file" ];then + echo "Error: $src/$file doesn't exist, exit." + exit -1 +fi +if [ ! -d $dst ];then + $MD $dst +fi +#echo "Copy $src/$file to $dst/$file" +$CP $src/$file $dst/$file +} + +### function ### +function init_win_project() +{ + if [ ! -f "$PREPARED_DIR"/include/pg_config.h ]; then + echo "Error: Header file pg_config.h for Windows lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/include/pg_config_os.h ]; then + echo "Error: Header file pg_config_os.h for Windows lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/include/pg_config_paths.h ]; then + echo "Error: Header file pg_config_paths.h for Windows lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/include/errcodes.h ]; then + echo "Error: Header file errcodes.h for Windows lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/include/libpqdll.def ]; then + echo "Error: Interface definition file libpqdll.def for Windows lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/Makefile ];then + echo "Error: Makefile for MinGW complier lost, exit." + exit -1 + fi + if [ ! -f "$PREPARED_DIR"/CMakeLists.txt ];then + echo "Error: CMakeLists.txt for CMake && MinGW complier lost, exit." + exit -1 + fi +# $RM $LIBPQ_WIN32_DIR/include + $RM $LIBPQ_WIN32_DIR/src + if [ ! -d "$LIBPQ_WIN32_DIR"/lib ];then + $MD $LIBPQ_WIN32_DIR/lib + fi +} + +### function ### +function copy_headers() +{ # copy header files +# copy form prepared directory +copy_file securec.h $LIB_SECURITY_DIR/include $LIBPQ_WIN32_DIR/include +copy_file securectype.h $LIB_SECURITY_DIR/include $LIBPQ_WIN32_DIR/include +#copy_file pg_config.h $PREPARED_DIR $LIBPQ_WIN32_DIR/include +#copy_file pg_config_os.h $PREPARED_DIR $LIBPQ_WIN32_DIR/include +# include +copy_file c.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file cipher.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file datatypes.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file getaddrinfo.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file gs_thread.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file gs_threadlocal.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file pg_config_manual.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file port.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file postgres.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file postgres_ext.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file postgres_fe.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +copy_file securec_check.h $SRC_DIR/include $LIBPQ_WIN32_DIR/include +# include/access +copy_file attnum.h $SRC_DIR/include/access $LIBPQ_WIN32_DIR/include/access +copy_file tupdesc.h $SRC_DIR/include/access $LIBPQ_WIN32_DIR/include/access +# include/catlog +copy_file genbki.h $SRC_DIR/include/catalog $LIBPQ_WIN32_DIR/include/catalog +copy_file pg_attribute.h $SRC_DIR/include/catalog $LIBPQ_WIN32_DIR/include/catalog +# include/client_logic +copy_file cache.h $SRC_DIR/include/client_logic $LIBPQ_WIN32_DIR/include/client_logic +copy_file client_logic.h $SRC_DIR/include/client_logic $LIBPQ_WIN32_DIR/include/client_logic +copy_file client_logic_enums.h $SRC_DIR/include/client_logic $LIBPQ_WIN32_DIR/include/client_logic +copy_file cstrings_map.h $SRC_DIR/include/client_logic $LIBPQ_WIN32_DIR/include/client_logic +# include/gstrace +copy_file gstrace_infra.h $SRC_DIR/include/gstrace $LIBPQ_WIN32_DIR/include/gstrace +copy_file gstrace_infra_int.h $SRC_DIR/include/gstrace $LIBPQ_WIN32_DIR/include/gstrace +copy_file gstrace_tool.h $SRC_DIR/include/gstrace $LIBPQ_WIN32_DIR/include/gstrace +# include/libcomm +#copy_file libcomm.h $SRC_DIR/include/libcomm $LIBPQ_WIN32_DIR/include/libcomm +# include/libpq +copy_file auth.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file be-fsstubs.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file cl_state.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file crypt.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file guc_vars.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file hba.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file ip.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq-be.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq-events.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq-fe.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq-fs.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file libpq-int.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file md5.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file pqcomm.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file pqexpbuffer.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file pqformat.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file pqsignal.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +copy_file sha2.h $SRC_DIR/include/libpq $LIBPQ_WIN32_DIR/include/libpq +# include/mb +copy_file pg_wchar.h $SRC_DIR/include/mb $LIBPQ_WIN32_DIR/include/mb +# include/nodes +copy_file nodes.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +copy_file params.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +copy_file parsenodes_common.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +copy_file pg_list.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +copy_file primnodes.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +copy_file value.h $SRC_DIR/include/nodes $LIBPQ_WIN32_DIR/include/nodes +# include/parser +copy_file backslash_quotes.h $SRC_DIR/include/parser $LIBPQ_WIN32_DIR/include/parser +# include/port/win32 +copy_file dlfcn.h $SRC_DIR/include/port/win32 $LIBPQ_WIN32_DIR/include/port/win32 +copy_file grp.h $SRC_DIR/include/port/win32 $LIBPQ_WIN32_DIR/include/port/win32 +copy_file netdb.h $SRC_DIR/include/port/win32 $LIBPQ_WIN32_DIR/include/port/win32 +copy_file pwd.h $SRC_DIR/include/port/win32 $LIBPQ_WIN32_DIR/include/port/win32 +# include/port/win32/arpa +copy_file inet.h $SRC_DIR/include/port/win32/arpa $LIBPQ_WIN32_DIR/include/port/win32/arpa +# include/port/win32/netinet +copy_file in.h $SRC_DIR/include/port/win32/netinet $LIBPQ_WIN32_DIR/include/port/win32/netinet +# include/port/win32/sys +copy_file socket.h $SRC_DIR/include/port/win32/sys $LIBPQ_WIN32_DIR/include/port/win32/sys +copy_file wait.h $SRC_DIR/include/port/win32/sys $LIBPQ_WIN32_DIR/include/port/win32/sys +# include/port/win32_msvc +copy_file dirent.h $SRC_DIR/include/port/win32_msvc $LIBPQ_WIN32_DIR/include/port/win32_msvc +copy_file unistd.h $SRC_DIR/include/port/win32_msvc $LIBPQ_WIN32_DIR/include/port/win32_msvc +copy_file utime.h $SRC_DIR/include/port/win32_msvc $LIBPQ_WIN32_DIR/include/port/win32_msvc +# include/port/win32_msvc/sys +copy_file file.h $SRC_DIR/include/port/win32_msvc/sys $LIBPQ_WIN32_DIR/include/port/win32_msvc/sys +copy_file param.h $SRC_DIR/include/port/win32_msvc/sys $LIBPQ_WIN32_DIR/include/port/win32_msvc/sys +copy_file time.h $SRC_DIR/include/port/win32_msvc/sys $LIBPQ_WIN32_DIR/include/port/win32_msvc/sys +# include/storage +copy_file spin.h $SRC_DIR/include/storage $LIBPQ_WIN32_DIR/include/storage +# include/storage/lock +copy_file pg_sema.h $SRC_DIR/include/storage/lock $LIBPQ_WIN32_DIR/include/storage/lock +copy_file s_lock.h $SRC_DIR/include/storage/lock $LIBPQ_WIN32_DIR/include/storage/lock +# include/utils +copy_file be_module.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +copy_file elog.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +copy_file palloc.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +copy_file pg_crc.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +copy_file pg_crc_tables.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +copy_file syscall_lock.h $SRC_DIR/include/utils $LIBPQ_WIN32_DIR/include/utils +# copy from prepared directory +copy_file errcodes.h $PREPARED_DIR/include $LIBPQ_WIN32_DIR/include/utils # !!!! special source directory +} + +function copy_codes() +{ +# src/common/backend/libpq +copy_file ip.cpp $SRC_DIR/common/backend/libpq $LIBPQ_WIN32_DIR/src/common/backend/libpq +copy_file md5.cpp $SRC_DIR/common/backend/libpq $LIBPQ_WIN32_DIR/src/common/backend/libpq +copy_file sha2.cpp $SRC_DIR/common/backend/libpq $LIBPQ_WIN32_DIR/src/common/backend/libpq +# src/common/backend/utils/mb +copy_file encnames.cpp $SRC_DIR/common/backend/utils/mb $LIBPQ_WIN32_DIR/src/common/backend/utils/mb +copy_file wchar.cpp $SRC_DIR/common/backend/utils/mb $LIBPQ_WIN32_DIR/src/common/backend/utils/mb +# src/common/interfaces/libpq +copy_file fe-auth.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-auth.h $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-connect.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-exec.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-lobj.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-misc.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-print.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-protocol2.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-protocol3.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file fe-secure.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file libpq-events.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file pqexpbuffer.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file pqsignal.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file pqsignal.h $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file pthread-win32.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file win32.cpp $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +copy_file win32.h $SRC_DIR/common/interfaces/libpq $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +# copy interface definition file from prepared directory +copy_file libpqdll.def $PREPARED_DIR/include $LIBPQ_WIN32_DIR/src/common/interfaces/libpq +# src/common/interfaces/libpq/client_logic_cache +copy_file cache_loader.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cache_loader.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_column_manager.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_global_setting.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file column_settings_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file global_settings_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file icached_columns.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file types_to_oid.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cache_refresh_type.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_column_setting.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_setting.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file columns_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file icached_column.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file schemas_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_column.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file cached_columns.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file column_hook_executors_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file dataTypes.def \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file icached_column_manager.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +copy_file search_path_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_cache \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_cache +# src/common/interfaces/libpq/client_logic_common +copy_file client_logic_utils.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +copy_file col_full_name.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +copy_file cstring_oid_map.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +copy_file pg_client_logic_params.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +copy_file statement_data.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +copy_file table_full_name.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_common \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_common +# src/common/interfaces/libpq/client_logic_hooks +copy_file abstract_hook_executor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +copy_file column_hook_executor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +copy_file global_hook_executor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +copy_file hook_resource.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +copy_file hooks_factory.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +copy_file hooks_manager.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_hooks \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_hooks +# src/common/interfaces/libpq/client_logic_processor +copy_file create_stmt_processor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file prepared_statement.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file processor_utils.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file raw_values_cont.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file stmt_processor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file where_clause_processor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file encryption_pre_process.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file prepared_statements_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file raw_value.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file raw_values_list.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +copy_file values_processor.h \ + $SRC_DIR/common/interfaces/libpq/client_logic_processor \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/client_logic_processor +# src/common/interfaces/libpq/frontend_parser +copy_file datatypes.h \ + $SRC_DIR/common/interfaces/libpq/frontend_parser \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/frontend_parser +copy_file Parser.h \ + $SRC_DIR/common/interfaces/libpq/frontend_parser \ + $LIBPQ_WIN32_DIR/src/common/interfaces/libpq/frontend_parser +# src/common/port +copy_file chklocale.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file dirent.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file getaddrinfo.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file gs_readdir.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file gs_syscall_lock.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file inet_net_ntop.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file path.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file pgsleep.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file pthread-win32.h $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file thread.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file win32error.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file cipher.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file dirmod.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file gs_env_r.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file gs_strerror.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file inet_aton.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file noblock.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file pgstrcasecmp.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file strlcpy.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file win32env.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +copy_file win32setlocale.cpp $SRC_DIR/common/port $LIBPQ_WIN32_DIR/src/common/port +# copy from prepared directory +copy_file pg_config_paths.h $PREPARED_DIR/include $LIBPQ_WIN32_DIR/src/common/port +} + +function copy_makefiles() +{ +copy_file Makefile $PREPARED_DIR $LIBPQ_WIN32_DIR +copy_file CMakeLists.txt $PREPARED_DIR $LIBPQ_WIN32_DIR +} + +function generate_libpq_export_files() +{ +copy_file auth.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file be-fsstubs.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file guc_vars.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq-be.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq-int.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file pqformat.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file be-fsstubs.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file hba.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq-events.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file md5.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file pqsignal.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file cl_state.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file ip.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq-fe.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file pqcomm.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file sha2.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file crypt.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file libpq-fs.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file pqexpbuffer.h $LIBPQ_WIN32_DIR/include/libpq $EXPORT_DIR/include/libpq +copy_file gs_thread.h $LIBPQ_WIN32_DIR/include $EXPORT_DIR/include +copy_file postgres_ext.h $LIBPQ_WIN32_DIR/include $EXPORT_DIR/include +copy_file gs_threadlocal.h $LIBPQ_WIN32_DIR/include $EXPORT_DIR/include + +if [ ! -d "$EXPORT_DIR"/lib ];then + $MD $EXPORT_DIR/lib +fi +} + +### function ### +function __main__() +{ +echo "Start." +echo -n "Step[1] - initialize libpq project directory for Windows ... " +init_win_project +echo "done." +echo -n "Step[2] - copy libpq header files ... " +copy_headers +echo "done." +echo -n "Step[3] - copy libpq source code files ... " +copy_codes +echo "done." +echo -n "Step[4] - prepare Makefile && CMakeLists.txt files for compilation ... " +copy_makefiles +echo "done." +echo -n "Step[5] - generate export directory and files ... " +generate_libpq_export_files +echo "done." +echo "Done." +} + +function __clean__() +{ +$RM $LIBPQ_WIN32_DIR/include +$RM $LIBPQ_WIN32_DIR/lib +$RM $LIBPQ_WIN32_DIR/libpq-export +$RM $LIBPQ_WIN32_DIR/src +$RM $LIBPQ_WIN32_DIR/CMakeLists.txt +$RM $LIBPQ_WIN32_DIR/Makefile +} +### main ### +if [ $# -eq 0 ];then +__main__ +exit 0 +fi +if [ $# -eq 1 -a "x$1" = "xclean" ];then +__clean__ +exit 0 +fi + +echo "Usage: \"sh $0\" for initialization or \"sh $0 clean\" for cleaning."