diff --git a/.github/workflows/configuration.xml b/.github/workflows/configuration.xml
new file mode 100644
index 00000000..d807aa81
--- /dev/null
+++ b/.github/workflows/configuration.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ d:\postgresql86\include
+ d:\postgresql86\lib
+ d:\postgresql86\bin
+
+
+
+
+
+
+
+
+
+
+ c:\Program Files\PostgreSQL\16\include
+ c:\Program Files\PostgreSQL\16\lib
+ c:\Program Files\PostgreSQL\16\bin
+
+
+
+
+
+
+
+
+
+ 03/04/2024 10:49:13
+ 17.0
+ v143
+ Current
+ arm64
+
+
\ No newline at end of file
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..83bc006b
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,326 @@
+name: MSBuild
+run-name: psql ODBC CI - ${{ github.event.head_commit.message }}
+
+on:
+ push:
+ branches: [ "main" ]
+ tags:
+ - 'REL-*'
+ pull_request:
+ branches: [ "main" ]
+
+env:
+ # Path to the solution file relative to the root of the project.
+ SOLUTION_FILE_PATH: .
+
+ # Configuration type to build.
+ # You can convert this to a build matrix if you need coverage of multiple configuration types.
+ # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
+ BUILD_CONFIGURATION: Release
+
+permissions:
+ contents: read
+
+jobs:
+ build_and_test:
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ repository: "postgres/postgres.git"
+ ref: 'master'
+ - name: 'get meson'
+ run: |
+ python -m pip install meson
+ python -m pip install ninja
+ - name: Cache Postgres directory
+ uses: actions/cache@v4
+ id: cachePostgres
+ with:
+ path: d:\postgresql
+ key: postgresql
+ - name: Cache Postgres86 directory
+ uses: actions/cache@v4
+ id: cachePostgres86
+ with:
+ path: d:\postgresql86
+ key: postgresql86
+ - name: Cache GNU diffutils for Test on PostgreSQL for Windows
+ uses: actions/cache@v4
+ id: cacheDiffutilsZip
+ with:
+ path: C:\OTHERBIN\diffutils
+ key: diffutils-2.8.7-1-bin.zip
+ env:
+ SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
+ - name: Cache PostgreSQL installer
+ uses: actions/cache@v4
+ id: cachePostgresInstaller
+ with:
+ path: C:\OTHERBIN\postgresql_install.exe
+ key: postgresql_installer
+ - name: Cache pkgconfiglite for Compile using msvc and meson
+ uses: actions/cache@v4
+ id: cachePkgConfigLiteZip
+ with:
+ path: C:\OTHERBIN\pkgconfiglite
+ key: pkg-config-lite-0.28-1_bin-win32.zip
+ env:
+ SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
+ - name: Cache Win32OpenSSL32 for Win32Compile
+ uses: actions/cache@v4
+ id: cacheWin32OpenSSL-3_3
+ with:
+ path: C:\OTHERBIN\openssl32
+ key: Win32OpenSSL-3_3_0.exe
+ - name: Cache winflexbison for Compile using msvc
+ uses: actions/cache@v4
+ id: cacheWinFlexBisonZip
+ with:
+ path: C:\OTHERBIN\winflexbison
+ key: win_flex_bison-2.5.24.zip
+ env:
+ SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
+ - name: Download GNU diffutils for Test on PostgreSQL for Windows
+ if: ${{steps.cacheDiffutilsZip.outputs.cache-hit != 'true'}}
+ uses: suisei-cn/actions-download-file@v1.6.0
+ id: downloadDiffutilsZip
+ with:
+ retry-times: 5
+ url: https://zenlayer.dl.sourceforge.net/project/gnuwin32/diffutils/2.8.7-1/diffutils-2.8.7-1-bin.zip
+
+ - name: Download openssl32 for win32 compile
+ if: ${{steps.cacheWin32OpenSSL.outputs.cache-hit != 'true'}}
+ uses: suisei-cn/actions-download-file@v1.6.0
+ id: downloadWin32OpenSSL3_3_3
+ with:
+ retry-times: 5
+ url: https://slproweb.com/download/Win32OpenSSL-3_3_0.exe
+
+ - name: Download pkgconfiglite for Compile using msvc and meson
+ if: ${{steps.cachePkgConfigLiteZip.outputs.cache-hit != 'true'}}
+ uses: suisei-cn/actions-download-file@v1.6.0
+ id: downloadPkgConfigLiteZip
+ with:
+ retry-times: 5
+ url: http://downloads.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip
+
+ - name: Download winflexbison for Compile using msvc
+ if: ${{steps.cacheWinFlexBisonZip.outputs.cache-hit != 'true'}}
+ uses: suisei-cn/actions-download-file@v1.6.0
+ id: downloadWinFlexBisonZip
+ with:
+ retry-times: 5
+ url: https://sourceforge.net/projects/winflexbison/files/win_flex_bison-2.5.24.zip
+
+ - name: Download postgresql install from EDB
+ uses: suisei-cn/actions-download-file@v1.6.0
+ if: ${{steps.cachePostgresInstaller.outputs.cache-hit != 'true'}}
+ id: downloadPostgresInstaller
+ with:
+ retry-times: 5
+ url: https://sbp.enterprisedb.com/getfile.jsp?fileid=1258893
+ target: c:\OTHERBIN
+ filename: postgresql_install.exe
+
+ - name: Extract Diffuntils and add Diffuntils bin directory to the PATH for Test on PostgreSQL for Windows
+ shell: cmd
+ run: |
+ rem MKDIR creates any intermediate directories in the path, if needed.
+ mkdir "C:\OTHERBIN\diffutils"
+ rem 7z is provided by Github Actions
+ 7z x diffutils-2.8.7-1-bin.zip -o"C:\OTHERBIN\diffutils"
+ copy diffutils-2.8.7-1-bin.zip "C:\OTHERBIN\diffutils"
+ dir "C:\OTHERBIN\diffutils"
+ rem - man7.org/linux/man-pages/man1/printf.1.html
+ printf "C:\\OTHERBIN\\diffutils\\bin" >> %GITHUB_PATH%
+
+ - name: Extract pkgconfiglite and add pkgconfiglite bin directory to the PATH for Compile using msvc and meson
+ shell: cmd
+ run: |
+ rem MKDIR creates any intermediate directories in the path, if needed.
+ mkdir "C:\OTHERBIN\pkgconfiglite"
+ rem 7z is provided by Github Actions
+ 7z x pkg-config-lite-0.28-1_bin-win32.zip -o"C:\OTHERBIN\pkgconfiglite"
+ copy pkg-config-lite-0.28-1_bin-win32.zip "C:\OTHERBIN\pkgconfiglite"
+ dir "C:\OTHERBIN\pkgconfiglite"
+ rem - man7.org/linux/man-pages/man1/printf.1.html
+ printf "C:\\OTHERBIN\\pkgconfiglite\\pkg-config-lite-0.28-1\\bin" >> %GITHUB_PATH%
+
+ - name: Install Win32OpenSSL
+ shell: cmd
+ run: Win32OpenSSL-3_3_0.exe /sp /silent /dir=c:\openssl32
+
+ # Choco Install winflexbison
+ # BUT the "crazy-max/ghaction-chocolatey@v2" "install pkgconfiglite" file download often times-out
+ - name: Extract winflexbison and add the winflexbison directory to the PATH for Compile using msvc
+ shell: cmd
+ run: |
+ rem MKDIR creates any intermediate directories in the path, if needed.
+ mkdir "C:\OTHERBIN\winflexbison"
+ rem 7z is provided by Github Actions
+ 7z x win_flex_bison-2.5.24.zip -o"C:\OTHERBIN\winflexbison"
+ copy win_flex_bison-2.5.24.zip "C:\OTHERBIN\winflexbison"
+ dir "C:\OTHERBIN\winflexbison"
+ rem - man7.org/linux/man-pages/man1/printf.1.html
+ printf "C:\OTHERBIN\\winflexbison" >> %GITHUB_PATH%
+ - name: 'setup msvc x86'
+ if: ${{steps.cachePostgres86.outputs.cache-hit != 'true'}}
+ uses: TheMrMilchmann/setup-msvc-dev@v3
+ with:
+ arch: x86
+ - name: 'build postgresx86'
+ if: ${{steps.cachePostgres86.outputs.cache-hit != 'true'}}
+ run: |
+ meson setup buildx86 -Dssl=openssl -Dextra_lib_dirs=c:\openssl32\lib\VC\x86\MT -Dextra_include_dirs=c:\openssl32\include --prefix=d:\postgresql86
+ cd buildx86
+ ninja -v
+ ninja -v install
+ cp c:\openssl32\*.dll d:\postgresql86\bin
+ - name: 'setup msvc x64'
+ if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}}
+ uses: TheMrMilchmann/setup-msvc-dev@v3
+ with:
+ arch: x64
+ - name : 'build postgres x64'
+ if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}}
+ run: |
+ meson setup build --prefix=d:\postgresql
+ cd build
+ ninja
+ ninja install
+ - name: install postgresql binary
+ shell: cmd
+ run: |
+ echo on
+ C:\OTHERBIN\postgresql_install.exe --mode unattended --unattendedmodeui none --superpassword password --enable-components server
+ - name: start postgresql
+ shell: cmd
+ run: |
+ echo on
+ sc config "postgresql-x64-14" start= auto
+ - name: get psqlodbc
+ uses: actions/checkout@v4
+ with:
+ submodules: true
+ - name: 'setup msvc for psqlodbc'
+ uses: TheMrMilchmann/setup-msvc-dev@v3
+ with:
+ arch: x86
+
+ - name: build psqlodbc standard
+ shell: powershell
+ run: |
+ copy .github\workflows\configuration.xml winbuild
+ winbuild\BuildAll.ps1
+ installer\buildInstallers.ps1
+ env:
+ PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\standard
+ - name: test psqlodbc standard
+ shell: powershell
+ run: |
+ winbuild\regress.ps1 -DsnInfo "SERVER=localhost|DATABASE=contrib_regression|PORT=5432|UID=postgres|PWD=password"
+ standard\test_x86\RegisterRegdsn.exe uninstall_driver postgres_devw
+ standard\test_x64\RegisterRegdsn.exe uninstall_driver postgres_devw
+ env:
+ PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\standard
+
+ - name: build psqlodbc mimalloc
+ shell: powershell
+ run: |
+ copy .github\workflows\configuration.xml winbuild
+ winbuild\BuildAll.ps1 -UseMimalloc
+ installer\buildInstallers.ps1
+ env:
+ PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\mimalloc
+ - name: test psqlodbc mimalloc
+ shell: powershell
+ run: |
+ winbuild\regress.ps1 -DsnInfo "SERVER=localhost|DATABASE=contrib_regression|PORT=5432|UID=postgres|PWD=password" -ExpectMimalloc
+ mimalloc\test_x86\RegisterRegdsn.exe uninstall_driver postgres_devw
+ mimalloc\test_x64\RegisterRegdsn.exe uninstall_driver postgres_devw
+ env:
+ PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\mimalloc
+
+ - name: Upload standard x64 merge module
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC Standard x64 Merge Module
+ path: winbuild/standard/installer/x64/*.msm
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload standard x64 installer package
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC Standard x64 Installer
+ path: winbuild/standard/installer/x64/*.msi
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload standard x86 merge module
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC Standard x86 Merge Module
+ path: winbuild/standard/installer/x86/*.msm
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload standard x86 installer package
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC Standard x86 Installer
+ path: winbuild/standard/installer/x86/*.msi
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload standard x64 setup
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC Standard x64 Setup
+ path: winbuild/standard/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe
+ retention-days: 5
+ if-no-files-found: error
+
+ - name: Upload mimalloc x64 merge module
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC mimalloc x64 Merge Module
+ path: winbuild/mimalloc/installer/x64/*.msm
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload mimalloc x64 installer package
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC mimalloc x64 Installer
+ path: winbuild/mimalloc/installer/x64/*.msi
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload mimalloc x86 merge module
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC mimalloc x86 Merge Module
+ path: winbuild/mimalloc/installer/x86/*.msm
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload mimalloc x86 installer package
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC mimalloc x86 Installer
+ path: winbuild/mimalloc/installer/x86/*.msi
+ retention-days: 5
+ if-no-files-found: error
+ - name: Upload mimalloc x64 setup
+ uses: actions/upload-artifact@v4
+ with:
+ name: psqlODBC mimalloc x64 Setup
+ path: winbuild/mimalloc/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe
+ retention-days: 5
+ if-no-files-found: error
+
+ - name: Create Release
+ if: startsWith(github.ref, 'refs/tags/REL-')
+ uses: ncipollo/release-action@v1.14.0
+ id: create_release
+ with:
+ draft: false
+ prerelease: false
+ token: ${{secrets.RELEASE_TOKEN}}
+ artifacts: "winbuild/standard/installer/x64/*.ms?,winbuild/standard/installer/x86/*.ms?,winbuild/standard/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe"
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..0b66fd3b
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "libs/mimalloc"]
+ path = libs/mimalloc
+ url = https://github.com/microsoft/mimalloc
+ branch = master
diff --git a/environ.c b/environ.c
index b3e13fd6..d2bfc260 100644
--- a/environ.c
+++ b/environ.c
@@ -193,7 +193,8 @@ ER_ReturnError(PG_ErrorInfo *pgerror,
PG_ErrorInfo *error;
BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0);
const char *msg;
- SWORD msglen, stapos, wrtlen, pcblen;
+ UWORD msglen, wrtlen, pcblen;
+ UInt4 stapos;
if (!pgerror)
return SQL_NO_DATA_FOUND;
diff --git a/inouealc.c b/inouealc.c
index 977990a5..a7d21918 100644
--- a/inouealc.c
+++ b/inouealc.c
@@ -1,6 +1,7 @@
#undef _MEMORY_DEBUG_
#include "psqlodbc.h"
+#ifndef _MIMALLOC_
#ifdef WIN32
#ifdef _DEBUG
/* #include */
@@ -10,6 +11,7 @@
#include
#endif /* _DEBUG */
#endif /* WIN32 */
+#endif /* _MIMALLOC_ */
#include
#include "misc.h"
@@ -26,20 +28,20 @@ CSTR ALCERR = "alcerr";
void * pgdebug_alloc(size_t size)
{
void * alloced;
- alloced = malloc(size);
+ alloced = pg_malloc(size);
MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size);
if (alloced)
{
if (!alsize)
{
alsize = 100;
- altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
+ altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
- if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
+ if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
@@ -53,20 +55,20 @@ MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size);
}
void * pgdebug_calloc(size_t n, size_t size)
{
- void * alloced = calloc(n, size);
+ void * alloced = pg_calloc(n, size);
if (alloced)
{
if (!alsize)
{
alsize = 100;
- altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
+ altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
- if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
+ if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
@@ -85,7 +87,7 @@ void * pgdebug_realloc(void * ptr, size_t size)
if (!ptr)
return pgdebug_alloc(size);
- alloced = realloc(ptr, size);
+ alloced = pg_realloc(ptr, size);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
@@ -109,7 +111,7 @@ void * pgdebug_realloc(void * ptr, size_t size)
}
char * pgdebug_strdup(const char * ptr)
{
- char * alloced = strdup(ptr);
+ char * alloced = pg_strdup(ptr);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
@@ -119,13 +121,13 @@ char * pgdebug_strdup(const char * ptr)
if (!alsize)
{
alsize = 100;
- altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
+ altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
- if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
+ if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
@@ -168,7 +170,7 @@ void pgdebug_free(void * ptr)
}
else
MYLOG(2, "ptr=%p\n", ptr);
- free(ptr);
+ pg_free(ptr);
}
static BOOL out_check(void *out, size_t len, const char *name)
@@ -253,7 +255,7 @@ void debug_memory_check(void)
if (0 == tbsize)
{
MYLOG(0, "no memry leak found and max count allocated so far is %d\n", alsize);
- free(altbl);
+ pg_free(altbl);
alsize = 0;
}
else
diff --git a/installer/buildInstallers.ps1 b/installer/buildInstallers.ps1
index 5a307968..6373db61 100644
--- a/installer/buildInstallers.ps1
+++ b/installer/buildInstallers.ps1
@@ -278,7 +278,7 @@ function buildInstaller([string]$CPUTYPE)
}
Write-Host ".`nLinking psqlODBC merge module..."
- light -nologo -o $INSTBASE\psqlodbc_$CPUTYPE.msm $INSTBASE\psqlodbcm.wixobj
+ light -sval -nologo -o $INSTBASE\psqlodbc_$CPUTYPE.msm $INSTBASE\psqlodbcm.wixobj
if ($LASTEXITCODE -ne 0) {
throw "Failed to link merge module"
}
@@ -291,7 +291,7 @@ function buildInstaller([string]$CPUTYPE)
}
Write-Host ".`nLinking psqlODBC installer database..."
- light -nologo -ext WixUIExtension -cultures:en-us -o $INSTBASE\psqlodbc_$CPUTYPE.msi $INSTBASE\psqlodbc.wixobj
+ light -sval -nologo -ext WixUIExtension -cultures:en-us -o $INSTBASE\psqlodbc_$CPUTYPE.msi $INSTBASE\psqlodbc.wixobj
if ($LASTEXITCODE -ne 0) {
throw "Failed to link installer database"
}
diff --git a/libs/mimalloc b/libs/mimalloc
new file mode 160000
index 00000000..229ec9cb
--- /dev/null
+++ b/libs/mimalloc
@@ -0,0 +1 @@
+Subproject commit 229ec9cbdc81cf1ffb705cbd8a07503589847426
diff --git a/psqlodbc.h b/psqlodbc.h
index bf259608..5b40b586 100644
--- a/psqlodbc.h
+++ b/psqlodbc.h
@@ -24,6 +24,9 @@
#endif
#include "version.h"
+#ifdef _MIMALLOC_
+#include
+#else /* _MIMALLOC_ */
#ifdef WIN32
#ifdef _DEBUG
#ifndef _MEMORY_DEBUG_
@@ -41,6 +44,11 @@
#else /* WIN32 */
#include
#endif /* WIN32 */
+#endif /* _MIMALLOC_ */
+
+#ifdef WIN32
+#include
+#endif /* WIN32 */
#ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */
/*
@@ -61,6 +69,21 @@
#endif /* __GNUC__ || __IBMC__ */
#endif /* __INCLUDE_POSTGRES_FE_H__ */
+#ifdef _MIMALLOC_
+#include
+#define pg_malloc mi_malloc
+#define pg_realloc mi_realloc
+#define pg_calloc mi_calloc
+#define pg_strdup mi_strdup
+#define pg_free mi_free
+#else /* _MIMALLOC_ */
+#define pg_malloc malloc
+#define pg_realloc realloc
+#define pg_calloc calloc
+#define pg_strdup _strdup
+#define pg_free free
+#endif /* _MIMALLOC_ */
+
#ifdef _MEMORY_DEBUG_
void *pgdebug_alloc(size_t);
void *pgdebug_calloc(size_t, size_t);
@@ -87,6 +110,15 @@ void debug_memory_check(void);
/* #define strncpy_null pgdebug_strncpy_null */
#define memcpy pgdebug_memcpy
#define memset pgdebug_memset
+#else /* _MEMORY_DEBUG_ */
+#ifdef WIN32
+#undef strdup
+#endif /* WIN32 */
+#define malloc pg_malloc
+#define realloc pg_realloc
+#define calloc pg_calloc
+#define strdup pg_strdup
+#define free pg_free
#endif /* _MEMORY_DEBUG_ */
#ifdef WIN32
diff --git a/psqlodbc.sln b/psqlodbc.sln
index b515cd30..eb5222fd 100644
--- a/psqlodbc.sln
+++ b/psqlodbc.sln
@@ -1,7 +1,9 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "psqlODBC", "psqlodbc.vcproj", "{C45ECB41-8473-4F11-8186-E5574CFBADCF}"
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34408.163
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "psqlODBC", "psqlodbc.vcxproj", "{C45ECB41-8473-4F11-8186-E5574CFBADCF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {D4D16229-1A47-43D4-B881-F1D072436145}
+ EndGlobalSection
EndGlobal
diff --git a/readme.txt b/readme.txt
index 7f646576..8e5afb85 100644
--- a/readme.txt
+++ b/readme.txt
@@ -5,7 +5,7 @@
Copyright (C) 1998 Insight Distribution Systems
- Copyright (C) 1998 - 2023 The PostgreSQL Global Development Group
+ Copyright (C) 1998 - 2024 The PostgreSQL Global Development Group
Multibyte support was added by Sankyo Unyu Service, (C) 2001.
diff --git a/statement.c b/statement.c
index f45cd798..69c4ec10 100644
--- a/statement.c
+++ b/statement.c
@@ -296,7 +296,10 @@ PGAPI_FreeStmt(HSTMT hstmt,
if (stmt->execute_parent)
stmt->execute_parent->execute_delegate = NULL;
/* Destroy the statement and free any results, cursors, etc. */
- SC_Destructor(stmt);
+ //SC_Destructor(stmt);
+ /*if the connection was give up,return SQL_ERROR.*/
+ if(SC_Destructor(stmt) == FALSE)
+ return SQL_ERROR;
}
else if (fOption == SQL_UNBIND)
SC_unbind_cols(stmt);
@@ -477,6 +480,7 @@ SC_Constructor(ConnectionClass *conn)
char
SC_Destructor(StatementClass *self)
{
+ char cRet = TRUE;
CSTR func = "SC_Destructor";
QResultClass *res = SC_get_Result(self);
@@ -498,6 +502,12 @@ SC_Destructor(StatementClass *self)
SC_initialize_stmts(self, TRUE);
+ if(self->hdbc && !self->hdbc->pqconn)
+ {
+ SC_set_error(self, STMT_COMMUNICATION_ERROR, "connection error.", func);
+ cRet = FALSE;
+ }
+
/* Free the parsed table information */
SC_initialize_cols_info(self, FALSE, TRUE);
@@ -525,7 +535,7 @@ SC_Destructor(StatementClass *self)
MYLOG(0, "leaving\n");
- return TRUE;
+ return cRet;
}
void
@@ -2362,6 +2372,7 @@ MYLOG(DETAIL_LOG_LEVEL, "!!SC_fetch return =%d\n", ret);
else
QR_Destructor(rhold.first);
}
+
}
}
cleanup:
diff --git a/version.h b/version.h
index 500d6e7e..67cca3f9 100644
--- a/version.h
+++ b/version.h
@@ -14,7 +14,7 @@
* and PG_DRVFILE_VERSION via winbuild/psqlodbc.vcxproj.
*/
#ifndef POSTGRESDRIVERVERSION
-#define POSTGRESDRIVERVERSION "16.00.0000"
+#define POSTGRESDRIVERVERSION "16.00.0005"
#endif
#ifndef POSTGRES_RESOURCE_VERSION
#define POSTGRES_RESOURCE_VERSION POSTGRESDRIVERVERSION
diff --git a/winbuild/BuildAll.ps1 b/winbuild/BuildAll.ps1
index 3deed985..ac8bc70d 100755
--- a/winbuild/BuildAll.ps1
+++ b/winbuild/BuildAll.ps1
@@ -30,6 +30,9 @@
Specify the configuration xml file name if you want to use
the configuration file other than standard one.
The relative path is relative to the current directory.
+.PARAMETER UseMimalloc
+ Specify whether to use the mimalloc allocator for improved performance.
+ Requires a toolset of v141, v142 or later.
.EXAMPLE
> .\BuildAll
Build with default or automatically selected parameters.
@@ -65,7 +68,8 @@ Param(
[ValidateSet("Debug", "Release")]
[String]$Configuration="Release",
[string]$BuildConfigPath,
-[switch]$AlongWithInstallers
+[switch]$AlongWithInstallers,
+[switch]$UseMimalloc
)
function buildPlatform([xml]$configInfo, [string]$Platform)
@@ -100,7 +104,27 @@ function buildPlatform([xml]$configInfo, [string]$Platform)
$BUILD_MACROS = $BUILD_MACROS -replace '"', '`"'
$macroList = iex "write-output $BUILD_MACROS"
}
- & ${msbuildexe} ./platformbuild.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion} /p:DRIVERVERSION=$DRIVERVERSION /p:PG_INC=$PG_INC /p:PG_LIB=$PG_LIB /p:PG_BIN=$PG_BIN $macroList
+
+ if ($UseMimalloc) {
+ $mimallocProperty = "yes"
+
+ switch ($VCVersion) {
+ "10.0" { $mimallocIdeDir = "vs2017" }
+ "11.0" { $mimallocIdeDir = "vs2017" }
+ "12.0" { $mimallocIdeDir = "vs2017" }
+ "14.0" { $mimallocIdeDir = "vs2017" }
+ "15.0" { $mimallocIdeDir = "vs2017" }
+ "16.0" { $mimallocIdeDir = "vs2019" }
+ "17.0" { $mimallocIdeDir = "vs2022" }
+ default { throw "Unable to resolve mimalloc IDE directory for VC ${VCVersion}."}
+ }
+
+ # build mimalloc dependency
+ & ${msbuildexe} ..\libs\mimalloc\ide\$mimallocIdeDir\mimalloc.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion}
+ }
+
+ # build psqlodbc
+ & ${msbuildexe} ./platformbuild.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion} /p:DRIVERVERSION=$DRIVERVERSION /p:PG_INC=$PG_INC /p:PG_LIB=$PG_LIB /p:PG_BIN=$PG_BIN /p:MIMALLOC=$mimallocProperty $macroList
}
$scriptPath = (Split-Path $MyInvocation.MyCommand.Path)
diff --git a/winbuild/MSProgram-Get.psm1 b/winbuild/MSProgram-Get.psm1
index 4e9711d6..2ea0610d 100644
--- a/winbuild/MSProgram-Get.psm1
+++ b/winbuild/MSProgram-Get.psm1
@@ -44,6 +44,8 @@ function Find-MSBuild
$VisualStudioVersion = "15.0"
} elseif ((Find-VSDir 16) -ne "") { # VC16 is installed
$VisualStudioVersion = "16.0"
+ } elseif ((Find-VSDir 17) -ne "") { #VC 17 is installed
+ $VisualStudioVersion = "17.0"
} elseif ("${env:VS140COMNTOOLS}" -ne "") { # VC14 is installed
$VisualStudioVersion = "14.0"
} elseif ("${env:VS120COMNTOOLS}" -ne "") { # VC12 is installed
@@ -67,7 +69,8 @@ function Find-MSBuild
"14.0" { $toolsout = 14 }
"15.0" { $toolsout = 15 }
"16.0" { $toolsout = 16 }
- default { throw "Selected Visual Stuidio is Version ${VisualStudioVersion}. Please use VC10 or later"}
+ "17.0" { $toolsout = 17 }
+ default { throw "Selected Visual Studio is Version ${VisualStudioVersion}. Please use VC10 or later"}
}
#
# Determine ToolsVersion
@@ -112,6 +115,7 @@ function Find-MSBuild
}
} catch {}
if ("$msbuildexe" -eq "") {
+ Write-Debug "tools version $toolsnum"
if ($toolsnum -gt 14) { # VC15 ~ VC16
$msbuildexe = msbfind_15_xx $toolsnum
} else { # VC10 ~ VC14
@@ -149,6 +153,7 @@ function Find-MSBuild
"14.0" {$Toolsetv="v140_xp"}
"15.0" {$Toolsetv="v141_xp"}
"16.0" {$Toolsetv="v142"}
+ "17.0" {$Toolsetv="v143"}
}
}
# avoid a bug of Windows7.1SDK PlatformToolset
@@ -270,7 +275,6 @@ function Find-Dumpbin
}
}
- Write-Host "Dumpbin=$dumpbinexe"
Set-Variable -Name dumpbinexe -Value $dumpbinexe -Scope 1
Set-Variable -Name addPath -Value $addPath -Scope 1
if ("$addPath" -ne "") {
@@ -400,7 +404,7 @@ function find_vs_installation
return $vsdir
}
-$vsarray = @{VC15 = "2017"; VC16 = "2019"}
+$vsarray = @{VC15 = "2017"; VC16 = "2019"; VC17 = "2022"}
# find VS dir for VC15 ~ VC16
function find_default_msbuild_path
{
@@ -413,12 +417,13 @@ function find_default_msbuild_path
if ($vsdir -eq "")
{
$toolsnum = [int]$toolsver
- if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
+ if ($env:PROCESSOR_ARCHITECTURE -eq "x86" -or $env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$pgmfs = "$env:ProgramFiles"
} else {
$pgmfs = "${env:ProgramFiles(x86)}"
}
$vsverdir = $vsarray["VC$toolsnum"]
+ Write-Debug "$pgmfs\Microsoft Visual Studio\$vsverdir\*\MSBuild\*\Bin\MSBuild.exe"
$lslist = @(Get-ChildItem "$pgmfs\Microsoft Visual Studio\$vsverdir\*\MSBuild\*\Bin\MSBuild.exe" -ErrorAction SilentlyContinue)
} else {
$lslist = @(Get-ChildItem "$vsdir\MSBuild\*\Bin\MSBuild.exe" -ErrorAction SilentlyContinue)
diff --git a/winbuild/psqlodbc.vcxproj b/winbuild/psqlodbc.vcxproj
index 5d1d9e81..9eeeeabd 100755
--- a/winbuild/psqlodbc.vcxproj
+++ b/winbuild/psqlodbc.vcxproj
@@ -131,6 +131,13 @@
$(ADD_DEFINES);_MEMORY_DEBUG_
+
+
+ $(ADD_DEFINES);_MIMALLOC_
+ $(ADD_INC);..\libs\mimalloc\include
+ $(ADD_LIBPATH);..\libs\mimalloc\out\msvc-$(Platform)\$(Configuration)
+ $(CALL_LIB);mimalloc-static.lib
+
true
@@ -158,7 +165,7 @@
$(DELAY_LOAD_DLLS);%(DelayLoadDLLs)
$(ADD_LIBPATH);$(OutDir);%(AdditionalLibraryDirectories)
- libpq.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;wsock32.lib;ws2_32.lib;secur32.lib;winmm.lib;%(AdditionalDependencies)
+ $(CALL_LIB);libpq.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;wsock32.lib;ws2_32.lib;secur32.lib;winmm.lib;%(AdditionalDependencies)
$(MAINDEF)
true
@@ -177,7 +184,7 @@
$(DELAY_LOAD_DLLS);%(DelayLoadDLLs)
$(ADD_LIBPATH);$(OutDir);%(AdditionalLibraryDirectories)
- libpq.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;wsock32.lib;ws2_32.lib;secur32.lib;winmm.lib;%(AdditionalDependencies)
+ $(CALL_LIB);libpq.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;wsock32.lib;ws2_32.lib;secur32.lib;winmm.lib;%(AdditionalDependencies)
$(MAINDEF)
true
@@ -196,7 +203,7 @@
$(DELAY_LOAD_DLLS);%(DelayLoadDLLs)
$(ADD_LIBPATH);$(OutDir);%(AdditionalLibraryDirectories)
- libpq.lib;winmm.lib;wsock32.lib;ws2_32.lib;secur32.lib;%(AdditionalDependencies)
+ $(CALL_LIB);libpq.lib;winmm.lib;wsock32.lib;ws2_32.lib;secur32.lib;%(AdditionalDependencies)
$(MAINDEF)
true
@@ -215,7 +222,7 @@
$(DELAY_LOAD_DLLS);%(DelayLoadDLLs)
$(ADD_LIBPATH);$(OutDir);%(AdditionalLibraryDirectories)
- libpq.lib;winmm.lib;wsock32.lib;ws2_32.lib;secur32.lib;%(AdditionalDependencies)
+ $(CALL_LIB);libpq.lib;winmm.lib;wsock32.lib;ws2_32.lib;secur32.lib;%(AdditionalDependencies)
$(MAINDEF)
true
diff --git a/winbuild/regress.ps1 b/winbuild/regress.ps1
index 1dd65cd2..be33df0e 100644
--- a/winbuild/regress.ps1
+++ b/winbuild/regress.ps1
@@ -1,6 +1,6 @@
<#
.SYNOPSIS
- Run regressin test on Windows.
+ Run regression test on Windows.
.DESCRIPTION
Build test programs and run them.
.PARAMETER Target
@@ -13,6 +13,8 @@
Specify this switch in case of testing Ansi drivers.
.PARAMETER DeclareFetch
Specify Use Declare/Fetch mode. "On"(default), "off" or "both" is available.
+.PARAMETER DsnInfo
+ Specify the dsn info "SERVER=${server}|DATABASE=${database}|PORT=${port}|UID=${uid}|PWD=${passwd}"
.PARAMETER VCVersion
Used Visual Studio version is determined automatically unless this
option is specified.
@@ -23,7 +25,7 @@
option is specified. Currently "v100", "Windows7.1SDK", "v110",
"v110_xp", "v120", "v120_xp", "v140" or "v140_xp" is available.
.PARAMETER MSToolsVersion
- This option is deprecated. MSBuild ToolsVersion is detemrined
+ This option is deprecated. MSBuild ToolsVersion is determined
automatically unless this option is specified. Currently "4.0",
"12.0" or "14.0" is available.
.PARAMETER Configuration
@@ -36,6 +38,8 @@
The relative path is relative to the current directory.
.PARAMETER ReinstallDriver
Reinstall the driver in any case.
+.PARAMETER ExpectMimalloc
+ Specify whether usage of the mimalloc allocator is expected.
.EXAMPLE
> .\regress
Build with default or automatically selected parameters
@@ -44,7 +48,7 @@
> .\regress Clean
Clean all generated files.
.EXAMPLE
- > .\regress -TestList connect, deprected
+ > .\regress -TestList connect, deprecated
Build and run connect-test and deprecated-test.
.EXAMPLE
> .\regress -Ansi
@@ -81,8 +85,10 @@ Param(
[string]$BuildConfigPath,
[ValidateSet("off", "on", "both")]
[string]$DeclareFetch="on",
+[string]$DsnInfo,
[string]$SpecificDsn,
-[switch]$ReinstallDriver
+[switch]$ReinstallDriver,
+[switch]$ExpectMimalloc
)
@@ -204,6 +210,8 @@ function vcxfile_make($testnames, $dirnames, $vcxfile)
function RunTest($scriptPath, $Platform, $testexes)
{
+ $originalErrorActionPreference = $ErrorActionPreference
+
# Run regression tests
if ($Platform -eq "x64") {
$targetdir="test_x64"
@@ -234,6 +242,9 @@ function RunTest($scriptPath, $Platform, $testexes)
if ($cnstr.length -eq 0) {
$cnstr += $null
}
+ # Temporarily set $ErrorActionPreference to "Continue" because MIMALLOC_VERBOSE writes to stderr
+ $ErrorActionPreference = "Continue"
+ $env:MIMALLOC_VERBOSE = 1
for ($i = 0; $i -lt $cnstr.length; $i++)
{
$env:COMMON_CONNECTION_STRING_FOR_REGRESSION_TEST = $cnstr[$i]
@@ -241,16 +252,23 @@ function RunTest($scriptPath, $Platform, $testexes)
$env:COMMON_CONNECTION_STRING_FOR_REGRESSION_TEST += ";Database=contrib_regression;ConnSettings={set lc_messages='C'}"
}
write-host "`n`tSetting by env variable:$env:COMMON_CONNECTION_STRING_FOR_REGRESSION_TEST"
- .\runsuite $testexes --inputdir=$origdir
+ .\runsuite $testexes --inputdir=$origdir 2>&1 | Tee-Object -Variable runsuiteOutput
+
+ # Check whether mimalloc ran by searching for a verbose message from mimalloc
+ if ($ExpectMimalloc -xor ($runsuiteOutput -match "mimalloc: process done")) {
+ throw "`tmimalloc usage was expected to be $ExpectMimalloc"
+ }
}
} catch [Exception] {
throw $error[0]
} finally {
$env:COMMON_CONNECTION_STRING_FOR_REGRESSION_TEST = $null
+ $env:MIMALLOC_VERBOSE = $null
+ $ErrorActionPreference = $originalErrorActionPreference
}
}
-function SpecialDsn($testdsn, $testdriver)
+function SpecialDsn($testdsn, $testdriver, $dsninfo)
{
function input-dsninfo($server="localhost", $uid="postgres", $passwd="postgres", $port="5432", $database="contrib_regression")
{
@@ -280,7 +298,11 @@ function SpecialDsn($testdsn, $testdriver)
switch ($LastExitCode) {
-1 {
Write-Host "`tAdding System DSN=$testdsn Driver=$testdriver"
- $prop = input-dsninfo
+ if ($dsninfo.Length -eq 0) {
+ $prop = input-dsninfo
+ } else {
+ $prop = $dsninfo
+ }
$prop += "|Debug=0|Commlog=0|ConnSettings=set+lc_messages='C'"
$proc = Start-Process $regProgram -Verb runas -Wait -PassThru -ArgumentList "register_dsn $testdriver $testdsn $prop `"$dlldir`" Driver=${dllname}|Setup=${setup}"
if ($proc.ExitCode -ne 0) {
@@ -383,6 +405,10 @@ if ($DriverConfiguration -ieq "Debug") {
$testdriver += "_debug"
$testdsn += "_debug"
}
+if ("$DsnInfo" -ne "") {
+ Write-Host "`tDsn Info=$DsnInfo"
+ $dsninfo=$DsnInfo
+}
if ("$SpecificDsn" -ne "") {
Write-Host "`tSpecific DSN=$SpecificDsn"
$testdsn=$SpecificDsn
@@ -414,7 +440,7 @@ foreach ($pl in $pary) {
$env:PSQLODBC_TEST_DSN = $testdsn
try {
- SpecialDsn $testdsn $testdriver
+ SpecialDsn $testdsn $testdriver $dsninfo
RunTest $scriptPath $pl $TESTEXES
} catch [Exception] {
throw $error[0]