pax_global_header00006660000000000000000000000064146240610360014514gustar00rootroot0000000000000052 comment=6ca29b7042cec545cedbbc69d17ac769a9ead5fd psqlodbc-REL-16_00_0005/000077500000000000000000000000001462406103600144765ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/.github/000077500000000000000000000000001462406103600160365ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/.github/workflows/000077500000000000000000000000001462406103600200735ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/.github/workflows/configuration.xml000066400000000000000000000017241462406103600234700ustar00rootroot00000000000000 d:\postgresql86\include d:\postgresql86\lib d:\postgresql86\bin d:\postgresql\include d:\postgresql\lib d:\postgresql\bin 03/04/2024 10:49:13 17.0 v143 Current arm64 psqlodbc-REL-16_00_0005/.github/workflows/main.yml000066400000000000000000000404561462406103600215530ustar00rootroot00000000000000name: 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 # Workflow versions. Increment these when you make changes to a build step in the workflow and # you want the step to run, but the corresponding cache is causing the step to be skipped. WORKFLOW_VERSION_POSTGRESQL: '1' # for build steps related to the 'cachePostgres' cache # Software versions. POSTGRESQL_SOURCE_TAG: 'REL_16_3' POSTGRESQL_PACKAGE_FILEID: '1259019' OPENSSL_VERSION: '3_3_0' PKGCONFIGLITE_VERSION: '0.28-1' WINFLEXBISON_VERSION: '2.5.24' DIFFUTILS_VERSION: '2.8.7-1' permissions: contents: read jobs: build_and_test: runs-on: windows-latest steps: - name: Cache Postgres build output uses: actions/cache@v4 id: cachePostgres with: path: | d:\postgresql d:\postgresql86 key: postgresql-${{env.POSTGRESQL_SOURCE_TAG}}_openssl-${{env.OPENSSL_VERSION}}_pkgconfiglite-${{env.PKGCONFIGLITE_VERSION}}_winflexbison-${{env.WINFLEXBISON_VERSION}}_workflow-${{env.WORKFLOW_VERSION_POSTGRESQL}} - name: Cache Postgres source if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: actions/cache@v4 id: cachePostgresSource with: path: postgres key: postgres-source-${{env.POSTGRESQL_SOURCE_TAG}} - name: Get Postgres source uses: actions/checkout@v4 if: ${{steps.cachePostgresSource.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} with: repository: "postgres/postgres.git" ref: ${{env.POSTGRESQL_SOURCE_TAG}} path: postgres - name: 'get meson' if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} run: | python -m pip install meson python -m pip install ninja - name: Cache GNU diffutils for Test on PostgreSQL for Windows uses: actions/cache@v4 id: cacheDiffutilsZip with: path: C:\OTHERBIN\diffutils key: diff_utils-${{env.DIFFUTILS_VERSION}} 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-${{env.POSTGRESQL_PACKAGE_FILEID}} - name: Cache pkgconfiglite for Compile using msvc and meson if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: actions/cache@v4 id: cachePkgConfigLiteZip with: path: C:\OTHERBIN\pkgconfiglite key: pkg-config-lite-${{env.PKGCONFIGLITE_VERSION}}-win32 env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 - name: Cache Win32OpenSSL32 for Win32Compile if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: actions/cache@v4 id: cacheWin32OpenSSL with: path: C:\OTHERBIN\openssl32 key: Win32OpenSSL-${{env.OPENSSL_VERSION}} - name: Cache Win64OpenSSL64 for Win64Compile if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: actions/cache@v4 id: cacheWin64OpenSSL with: path: C:\OTHERBIN\openssl64 key: Win64OpenSSL-${{env.OPENSSL_VERSION}} - name: Cache winflexbison for Compile using msvc if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: actions/cache@v4 id: cacheWinFlexBisonZip with: path: C:\OTHERBIN\winflexbison key: winflexbison-${{env.WINFLEXBISON_VERSION}} 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/${{env.DIFFUTILS_VERSION}}/diffutils-${{env.DIFFUTILS_VERSION}}-bin.zip filename: diffutils-bin.zip - name: Download openssl32 for win32 compile if: ${{steps.cacheWin32OpenSSL.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} uses: suisei-cn/actions-download-file@v1.6.0 id: downloadWin32OpenSSL with: retry-times: 5 url: https://slproweb.com/download/Win32OpenSSL-${{env.OPENSSL_VERSION}}.exe filename: Win32OpenSSL.exe - name: Download openssl64 for win64 compile if: ${{steps.cacheWin64OpenSSL.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} uses: suisei-cn/actions-download-file@v1.6.0 id: downloadWin64OpenSSL with: retry-times: 5 url: https://slproweb.com/download/Win64OpenSSL-${{env.OPENSSL_VERSION}}.exe filename: Win64OpenSSL.exe - name: Download pkgconfiglite for Compile using msvc and meson if: ${{steps.cachePkgConfigLiteZip.outputs.cache-hit != 'true' && steps.cachePostgres.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/${{env.PKGCONFIGLITE_VERSION}}/pkg-config-lite-${{env.PKGCONFIGLITE_VERSION}}_bin-win32.zip filename: pkg-config-lite_bin-win32.zip - name: Download winflexbison for Compile using msvc if: ${{steps.cacheWinFlexBisonZip.outputs.cache-hit != 'true' && steps.cachePostgres.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-${{env.WINFLEXBISON_VERSION}}.zip filename: win_flex_bison.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=${{env.POSTGRESQL_PACKAGE_FILEID}} target: c:\OTHERBIN filename: postgresql_install.exe - name: Extract Diffutils for Test on PostgreSQL for Windows if: ${{steps.cacheDiffutilsZip.outputs.cache-hit != 'true'}} 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-bin.zip -o"C:\OTHERBIN\diffutils" - name: Add Diffutils bin directory to the PATH for Test on PostgreSQL for Windows shell: cmd run: | rem - man7.org/linux/man-pages/man1/printf.1.html printf "C:\\OTHERBIN\\diffutils\\bin" >> %GITHUB_PATH% - name: Extract pkgconfiglite for Compile using msvc and meson if: ${{steps.cachePkgConfigLiteZip.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} 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_bin-win32.zip -o"C:\OTHERBIN\pkgconfiglite" - name: Add pkgconfiglite bin directory to the PATH for Compile using msvc and meson if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} shell: cmd run: | rem - man7.org/linux/man-pages/man1/printf.1.html printf "C:\\OTHERBIN\\pkgconfiglite\\pkg-config-lite-%PKGCONFIGLITE_VERSION%\\bin" >> %GITHUB_PATH% - name: Install Win32OpenSSL if: ${{steps.cacheWin32OpenSSL.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} shell: cmd run: Win32OpenSSL.exe /sp /silent /dir=c:\OTHERBIN\openssl32 - name: Install Win64OpenSSL if: ${{steps.cacheWin64OpenSSL.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} shell: cmd run: Win64OpenSSL.exe /sp /silent /dir=c:\OTHERBIN\openssl64 # Choco Install winflexbison # BUT the "crazy-max/ghaction-chocolatey@v2" "install pkgconfiglite" file download often times-out - name: Extract winflexbison for Compile using msvc if: ${{steps.cacheWinFlexBisonZip.outputs.cache-hit != 'true' && steps.cachePostgres.outputs.cache-hit != 'true'}} 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.zip -o"C:\OTHERBIN\winflexbison" - name: Add the winflexbison directory to the PATH for Compile using msvc if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} shell: cmd run: | rem - man7.org/linux/man-pages/man1/printf.1.html printf "C:\OTHERBIN\\winflexbison" >> %GITHUB_PATH% - name: 'setup msvc x86' if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} uses: TheMrMilchmann/setup-msvc-dev@v3 with: arch: x86 - name: 'build postgresx86' if: ${{steps.cachePostgres.outputs.cache-hit != 'true'}} working-directory: postgres run: | meson setup buildx86 -Dssl=openssl -Dextra_lib_dirs=c:\OTHERBIN\openssl32\lib\VC\x86\MT -Dextra_include_dirs=c:\OTHERBIN\openssl32\include --prefix=d:\postgresql86 cd buildx86 ninja -v ninja -v install cp c:\OTHERBIN\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'}} working-directory: postgres run: | meson setup build -Dssl=openssl -Dextra_lib_dirs=c:\OTHERBIN\openssl64\lib\VC\x64\MT -Dextra_include_dirs=c:\OTHERBIN\openssl64\include --prefix=d:\postgresql cd build ninja ninja install cp c:\OTHERBIN\openssl64\*.dll d:\postgresql\bin - 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: path: psqlodbc submodules: true - name: 'setup msvc for psqlodbc' uses: TheMrMilchmann/setup-msvc-dev@v3 with: arch: x86 - name: build psqlodbc standard shell: powershell working-directory: psqlodbc run: | copy .github\workflows\configuration.xml winbuild winbuild\BuildAll.ps1 installer\buildInstallers.ps1 env: PSQLODBC_OBJBASE: ${{ github.workspace }}\psqlodbc\winbuild\standard - name: test psqlodbc standard shell: powershell working-directory: psqlodbc 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 }}\psqlodbc\winbuild\standard - name: build psqlodbc mimalloc shell: powershell working-directory: psqlodbc run: | copy .github\workflows\configuration.xml winbuild winbuild\BuildAll.ps1 -UseMimalloc installer\buildInstallers.ps1 env: PSQLODBC_OBJBASE: ${{ github.workspace }}\psqlodbc\winbuild\mimalloc - name: test psqlodbc mimalloc shell: powershell working-directory: psqlodbc 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 }}\psqlodbc\winbuild\mimalloc - name: Upload standard x64 merge module uses: actions/upload-artifact@v4 with: name: psqlODBC Standard x64 Merge Module path: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/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: psqlodbc/winbuild/mimalloc/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe retention-days: 5 if-no-files-found: error - name: Create mimalloc Release if: startsWith(github.ref, 'refs/tags/REL-') uses: ncipollo/release-action@v1.14.0 id: create_mimalloc_release with: tag: ${{github.ref_name}}-mimalloc commit: ${{github.sha}} body: A build of ${{github.ref_name}} that uses the mimalloc allocator for improved performance. makeLatest: false draft: false prerelease: false token: ${{secrets.RELEASE_TOKEN}} artifacts: "psqlodbc/winbuild/mimalloc/installer/x64/*.ms?,psqlodbc/winbuild/mimalloc/installer/x86/*.ms?,psqlodbc/winbuild/mimalloc/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe" - name: Create Standard Release if: startsWith(github.ref, 'refs/tags/REL-') uses: ncipollo/release-action@v1.14.0 id: create_standard_release with: makeLatest: true draft: false prerelease: false token: ${{secrets.RELEASE_TOKEN}} artifacts: "psqlodbc/winbuild/standard/installer/x64/*.ms?,psqlodbc/winbuild/standard/installer/x86/*.ms?,psqlodbc/winbuild/standard/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe" psqlodbc-REL-16_00_0005/.gitignore000066400000000000000000000157371462406103600165030ustar00rootroot00000000000000# Global excludes across all subdirectories *.o *.so *.so.[0-9] *.so.[0-9].[0-9] *.sl *.sl.[0-9] *.sl.[0-9].[0-9] *.dylib *.dll *.a *.mo *.lo .deps/ .libs/ *.gcno *.gcda *.gcov *.gcov.out lcov.info *.vcproj *.vcxproj *.vcxproj.* !winbuild/*.vcxproj win32ver.rc *.exe lib*dll.def lib*.pc # Build configuration files winbuild/configuration.xml windows-local.mak # Files generated during compilation /Makefile /Makefile.in /aclocal.m4 /autom4te.cache/ /config/ /config.h /config.h.in /config.log /config.status /configure /libtool /psqlodbcw.la /stamp-h1 # Folders generated by Windows build /x86_ANSI_Release /x86_ANSI_Debug /x86_Unicode_Release /x86_Unicode_Debug /x64_ANSI_Release /x64_ANSI_Debug /x64_Unicode_Release /x64_Unicode_Debug # VC build tools (nmake, cl, link,lib etc) generate *.obj *.lib *.exp *.idb *.res *.pdb *.tlog *.manifest *.lastbuildstate # WIX tools (candle, light) generate *.wix* !*.wixproj *.msm *.msi ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.rsuser *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Mono auto generated files mono_crash.* # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ [Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUnit *.VisualState.xml TestResult.xml nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ # .NET Core project.lock.json project.fragment.lock.json artifacts/ # ASP.NET Scaffolding ScaffoldingReadMe.txt # StyleCop StyleCopReport.xml # Files built by Visual Studio *_i.c *_p.c *_h.h *.ilk *.meta *.obj *.iobj *.pch *.pdb *.ipdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *_wpftmp.csproj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files *.e2e # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool .axoCover/* !.axoCover/settings.json # Coverlet is a free, cross platform Code Coverage Tool coverage*[.json, .xml, .info] # Visual Studio code coverage results *.coverage *.coveragexml # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # NuGet Symbol Packages *.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx *.appxbundle *.appxupload # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !?*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.jfm *.pfx *.publishsettings orleans.codegen.cs # Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak # SQL Server files *.mdf *.ldf *.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings *.rptproj.rsuser *- [Bb]ackup.rdl *- [Bb]ackup ([0-9]).rdl *- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # CodeRush personal settings .cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc # Cake - Uncomment if you are using it # tools/** # !tools/packages.config # Tabs Studio *.tss # Telerik's JustMock configuration file *.jmconfig # BizTalk build output *.btp.cs *.btm.cs *.odx.cs *.xsd.cs # OpenCover UI analysis results OpenCover/ # Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log *.binlog # NVidia Nsight GPU debugger configuration file *.nvuser # MFractors (Xamarin productivity tool) working folder .mfractor/ # Local History for Visual Studio .localhistory/ # BeatPulse healthcheck temp database healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ # Fody - auto-generated XML schema FodyWeavers.xsd psqlodbc-REL-16_00_0005/.gitmodules000066400000000000000000000001601462406103600166500ustar00rootroot00000000000000[submodule "libs/mimalloc"] path = libs/mimalloc url = https://github.com/microsoft/mimalloc branch = master psqlodbc-REL-16_00_0005/BuildAll.bat000077500000000000000000000004451462406103600166640ustar00rootroot00000000000000:: :: Build all dlls of psqlodbc project :: @echo off if "%1" == "/?" ( powershell Get-Help '%~dp0\winbuild\BuildAll.ps1' -detailed ) else if "%1" == "-?" ( powershell Get-Help '%~dp0\winbuild\BuildAll.ps1' %2 %3 %4 %5 %6 %7 %8 %9 ) else ( powershell "& '%~dp0\winbuild\BuildAll.ps1' %*" ) psqlodbc-REL-16_00_0005/Makefile.am000066400000000000000000000064571462406103600165460ustar00rootroot00000000000000#------------------------------------------------------------------------- # # Makefile.am for psqlodbc30w (PostgreSQL ODBC driver) # #------------------------------------------------------------------------- AUTOMAKE_OPTIONS = 1.8 foreign ACLOCAL_AMFLAGS = -I config lib_LTLIBRARIES = psqlodbcw.la psqlodbca.la AM_LDFLAGS = -module -no-undefined -avoid-version -export-symbols-regex '^SQL' psqlodbcw_la_CFLAGS = -DUNICODE_SUPPORT # -DUNICODE_SUPPORTXX psqlodbca_la_SOURCES = \ info.c bind.c columninfo.c connection.c convert.c drvconn.c \ environ.c execute.c lobj.c misc.c options.c \ pgtypes.c psqlodbc.c qresult.c results.c parse.c \ statement.c tuple.c dlg_specific.c \ multibyte.c odbcapi.c descriptor.c \ odbcapi30.c pgapi30.c mylog.c \ \ bind.h catfunc.h columninfo.h connection.h convert.h \ descriptor.h dlg_specific.h environ.h unicode_support.h \ lobj.h misc.h multibyte.h pgapifunc.h pgtypes.h \ psqlodbc.h qresult.h resource.h statement.h tuple.h \ version.h pgenlist.h mylog.h xalibname.h psqlodbcw_la_SOURCES = $(psqlodbca_la_SOURCES) \ odbcapi30w.c odbcapiw.c win_unicode.c EXTRA_DIST = license.txt readme.txt readme_winbuild.txt \ psqlodbc.def psqlodbca.def editConfiguration.bat BuildAll.bat \ windows-defaults.mak buildInstallers.bat regress.bat \ pgenlist.def pgenlista.def connexp.h \ dlg_wingui.c loadlib.c loadlib.h inouealc.c win_setup.h \ psqlsetup.c setup.c win_unicode.c psqlodbc.rc win64.mak \ psqlodbc.reg psqlodbc.dsp psqlodbc.vcproj \ psqlodbc.sln msdtc_enlist.cpp pgxalib.cpp xalibname.c \ pgxalib.def psqlsetup.def psqlsetupa.def odbc.sql odbc-drop.sql \ \ docs/config-opt.html \ docs/config.html \ docs/README.txt \ docs/release-7.3.html \ docs/release.html \ docs/unix-compilation.html \ docs/win32-compilation.html \ docs/msdtc_pgxalib_tracing_enable.reg \ docs/msdtc_pgxalib_tracing_disable.reg \ docs/msdtc_pgxalib_tracing_README.txt \ docs/editConfiguration.jpg \ \ installer/background.bmp \ installer/banner.bmp \ installer/buildInstallers.ps1 \ installer/installer.mak \ installer/lgpl.rtf \ installer/modify_msi.vbs \ installer/productcodes.mak \ installer/psqlodbc-setup \ installer/README.txt \ installer/psqlodbcm_cpu.wxs \ installer/psqlodbc_cpu.wxs \ installer/psqlodbc-setup/buildBootstrapper.ps1 \ installer/psqlodbc-setup/Bundle.wxs \ installer/psqlodbc-setup/Make.bat \ installer/psqlodbc-setup/psqlodbc-setup.wixproj \ installer/psqlodbc-setup/vcredist.wxs \ \ winbuild/BuildAll.ps1 \ winbuild/platformbuild.vcxproj \ winbuild/MSProgram-Get.psm1 \ winbuild/psqlodbc.Cpp.props \ winbuild/Psqlodbc-config.psm1 \ winbuild/psqlodbc.vcxproj \ winbuild/configuration_template.xml \ winbuild/psqlsetup.vcxproj \ winbuild/editConfiguration.ps1 \ winbuild/readme.txt \ winbuild/pgenlist.vcxproj \ winbuild/regress.ps1 \ winbuild/pguser.Cpp.props \ winbuild/regress_one.vcxproj \ winbuild/pgxalib.vcxproj \ winbuild/std_dbmsname.Cpp.props \ \ test/Makefile.in \ test/odbcini-gen.sh \ test/README.txt \ test/RegisterRegdsn.c \ test/reset-db.c \ test/runsuite.c \ test/sampletables.sql \ test/tests \ test/win.mak \ test/expected \ test/src MAINTAINERCLEANFILES = \ Makefile.in config/config.guess config.h.in config/config.sub configure \ config/install-sh config/missing aclocal.m4 config/ltmain.sh \ config/depcomp psqlodbc-REL-16_00_0005/bind.c000066400000000000000000000630131462406103600155610ustar00rootroot00000000000000/*------- * Module: bind.c * * Description: This module contains routines related to binding * columns and parameters. * * Classes: BindInfoClass, ParameterInfoClass * * API functions: SQLBindParameter, SQLBindCol, SQLDescribeParam, SQLNumParams, * SQLParamOptions * * Comments: See "readme.txt" for copyright and license information. *------- */ /* #include */ #include #include #include "bind.h" #include "misc.h" #include "environ.h" #include "statement.h" #include "descriptor.h" #include "qresult.h" #include "pgtypes.h" #include "multibyte.h" #include "pgapifunc.h" /* Bind parameters on a statement handle */ RETCODE SQL_API PGAPI_BindParameter(HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fParamType, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, PTR rgbValue, SQLLEN cbValueMax, SQLLEN * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; CSTR func = "PGAPI_BindParameter"; APDFields *apdopts; IPDFields *ipdopts; PutDataInfo *pdata_info; MYLOG(0, "entering...\n"); if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } SC_clear_error(stmt); apdopts = SC_get_APDF(stmt); if (apdopts->allocated < ipar) extend_parameter_bindings(apdopts, ipar); ipdopts = SC_get_IPDF(stmt); if (ipdopts->allocated < ipar) extend_iparameter_bindings(ipdopts, ipar); pdata_info = SC_get_PDTI(stmt); if (pdata_info->allocated < ipar) extend_putdata_info(pdata_info, ipar, FALSE); /* use zero based column numbers for the below part */ ipar--; /* store the given info */ apdopts->parameters[ipar].buflen = cbValueMax; apdopts->parameters[ipar].buffer = rgbValue; apdopts->parameters[ipar].used = apdopts->parameters[ipar].indicator = pcbValue; apdopts->parameters[ipar].CType = fCType; ipdopts->parameters[ipar].SQLType = fSqlType; ipdopts->parameters[ipar].paramType = fParamType; ipdopts->parameters[ipar].column_size = cbColDef; ipdopts->parameters[ipar].decimal_digits = ibScale; ipdopts->parameters[ipar].precision = 0; ipdopts->parameters[ipar].scale = 0; switch (fCType) { case SQL_C_NUMERIC: if (cbColDef > 0) ipdopts->parameters[ipar].precision = (UInt2) cbColDef; if (ibScale > 0) ipdopts->parameters[ipar].scale = ibScale; break; case SQL_C_TYPE_TIMESTAMP: if (ibScale > 0) ipdopts->parameters[ipar].precision = ibScale; break; case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: case SQL_C_INTERVAL_SECOND: ipdopts->parameters[ipar].precision = 6; break; } apdopts->parameters[ipar].precision = ipdopts->parameters[ipar].precision; apdopts->parameters[ipar].scale = ipdopts->parameters[ipar].scale; /* * If rebinding a parameter that had data-at-exec stuff in it, then * free that stuff */ if (pdata_info->pdata[ipar].EXEC_used) { free(pdata_info->pdata[ipar].EXEC_used); pdata_info->pdata[ipar].EXEC_used = NULL; } if (pdata_info->pdata[ipar].EXEC_buffer) { free(pdata_info->pdata[ipar].EXEC_buffer); pdata_info->pdata[ipar].EXEC_buffer = NULL; } if (pcbValue && apdopts->param_offset_ptr) pcbValue = LENADDR_SHIFT(pcbValue, *apdopts->param_offset_ptr); #ifdef NOT_USED /* evaluation of pcbValue here is dangerous */ /* Data at exec macro only valid for C char/binary data */ if (pcbValue && (*pcbValue == SQL_DATA_AT_EXEC || *pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET)) apdopts->parameters[ipar].data_at_exec = TRUE; else apdopts->parameters[ipar].data_at_exec = FALSE; #endif /* NOT_USED */ /* Clear premature result */ if (stmt->status == STMT_DESCRIBED) SC_recycle_statement(stmt); MYLOG(0, "ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=" FORMAT_ULEN ", ibScale=%d,", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale); MYPRINTF(0, "rgbValue=%p(" FORMAT_LEN "), pcbValue=%p\n", rgbValue, cbValueMax, pcbValue); return SQL_SUCCESS; } /* Associate a user-supplied buffer with a database column. */ RETCODE SQL_API PGAPI_BindCol(HSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, PTR rgbValue, SQLLEN cbValueMax, SQLLEN * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; CSTR func = "PGAPI_BindCol"; ARDFields *opts; GetDataInfo *gdata_info; BindInfoClass *bookmark; RETCODE ret = SQL_SUCCESS; MYLOG(0, "entering...\n"); MYLOG(0, "**** : stmt = %p, icol = %d\n", stmt, icol); MYLOG(0, "**** : fCType=%d rgb=%p valusMax=" FORMAT_LEN " pcb=%p\n", fCType, rgbValue, cbValueMax, pcbValue); if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } opts = SC_get_ARDF(stmt); if (stmt->status == STMT_EXECUTING) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Can't bind columns while statement is still executing.", func); return SQL_ERROR; } #define return DONT_CALL_RETURN_FROM_HERE ??? SC_clear_error(stmt); /* If the bookmark column is being bound, then just save it */ if (icol == 0) { bookmark = opts->bookmark; if (rgbValue == NULL) { if (bookmark) { bookmark->buffer = NULL; bookmark->used = bookmark->indicator = NULL; } } else { /* Make sure it is the bookmark data type */ switch (fCType) { case SQL_C_BOOKMARK: case SQL_C_VARBOOKMARK: break; default: SC_set_error(stmt, STMT_PROGRAM_TYPE_OUT_OF_RANGE, "Bind column 0 is not of type SQL_C_BOOKMARK", func); MYLOG(DETAIL_LOG_LEVEL, "Bind column 0 is type %d not of type SQL_C_BOOKMARK\n", fCType); ret = SQL_ERROR; goto cleanup; } bookmark = ARD_AllocBookmark(opts); bookmark->buffer = rgbValue; bookmark->used = bookmark->indicator = pcbValue; bookmark->buflen = cbValueMax; bookmark->returntype = fCType; } goto cleanup; } /* * Allocate enough bindings if not already done. Most likely, * execution of a statement would have setup the necessary bindings. * But some apps call BindCol before any statement is executed. */ if (icol > opts->allocated) extend_column_bindings(opts, icol); gdata_info = SC_get_GDTI(stmt); if (icol > gdata_info->allocated) extend_getdata_info(gdata_info, icol, FALSE); /* check to see if the bindings were allocated */ if (!opts->bindings || !gdata_info->gdata) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for bindings.", func); ret = SQL_ERROR; goto cleanup; } /* use zero based col numbers from here out */ icol--; /* Reset for SQLGetData */ GETDATA_RESET(gdata_info->gdata[icol]); if (rgbValue == NULL) { /* we have to unbind the column */ opts->bindings[icol].buflen = 0; opts->bindings[icol].buffer = NULL; opts->bindings[icol].used = opts->bindings[icol].indicator = NULL; opts->bindings[icol].returntype = SQL_C_CHAR; opts->bindings[icol].precision = 0; opts->bindings[icol].scale = 0; if (gdata_info->gdata[icol].ttlbuf) free(gdata_info->gdata[icol].ttlbuf); gdata_info->gdata[icol].ttlbuf = NULL; gdata_info->gdata[icol].ttlbuflen = 0; gdata_info->gdata[icol].ttlbufused = 0; } else { /* ok, bind that column */ opts->bindings[icol].buflen = cbValueMax; opts->bindings[icol].buffer = rgbValue; opts->bindings[icol].used = opts->bindings[icol].indicator = pcbValue; opts->bindings[icol].returntype = fCType; opts->bindings[icol].precision = 0; switch (fCType) { case SQL_C_NUMERIC: opts->bindings[icol].precision = 32; break; case SQL_C_TIMESTAMP: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: case SQL_C_INTERVAL_SECOND: opts->bindings[icol].precision = 6; break; } opts->bindings[icol].scale = 0; MYLOG(0, " bound buffer[%d] = %p\n", icol, opts->bindings[icol].buffer); } cleanup: #undef return return ret; } /* * Returns the description of a parameter marker. * This function is listed as not being supported by SQLGetFunctions() because it is * used to describe "parameter markers" (not bound parameters), in which case, * the dbms should return info on the markers. Since Postgres doesn't support that, * it is best to say this function is not supported and let the application assume a * data type (most likely varchar). */ RETCODE SQL_API PGAPI_DescribeParam(HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT * pfSqlType, SQLULEN * pcbParamDef, SQLSMALLINT * pibScale, SQLSMALLINT * pfNullable) { StatementClass *stmt = (StatementClass *) hstmt; CSTR func = "PGAPI_DescribeParam"; IPDFields *ipdopts; RETCODE ret = SQL_SUCCESS; int num_params; OID pgtype; ConnectionClass *conn; MYLOG(0, "entering...%d\n", ipar); if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } conn = SC_get_conn(stmt); SC_clear_error(stmt); ipdopts = SC_get_IPDF(stmt); /*if ((ipar < 1) || (ipar > ipdopts->allocated))*/ num_params = stmt->num_params; if (num_params < 0) { SQLSMALLINT num_p; PGAPI_NumParams(stmt, &num_p); num_params = num_p; } if ((ipar < 1) || (ipar > num_params)) { MYLOG(DETAIL_LOG_LEVEL, "num_params=%d\n", stmt->num_params); SC_set_error(stmt, STMT_BAD_PARAMETER_NUMBER_ERROR, "Invalid parameter number for PGAPI_DescribeParam.", func); return SQL_ERROR; } extend_iparameter_bindings(ipdopts, stmt->num_params); #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(stmt); */ if (NOT_YET_PREPARED == stmt->prepared) { decideHowToPrepare(stmt, FALSE); MYLOG(DETAIL_LOG_LEVEL, "howTo=%d\n", SC_get_prepare_method(stmt)); switch (SC_get_prepare_method(stmt)) { case NAMED_PARSE_REQUEST: case PARSE_TO_EXEC_ONCE: case PARSE_REQ_FOR_INFO: if (ret = prepareParameters(stmt, FALSE), SQL_ERROR == ret) goto cleanup; } } ipar--; pgtype = PIC_get_pgtype(ipdopts->parameters[ipar]); /* * This implementation is not very good, since it is supposed to * describe */ /* parameter markers, not bound parameters. */ if (pfSqlType) { MYLOG(DETAIL_LOG_LEVEL, "[%d].SQLType=%d .PGType=%d\n", ipar, ipdopts->parameters[ipar].SQLType, pgtype); if (ipdopts->parameters[ipar].SQLType) *pfSqlType = ipdopts->parameters[ipar].SQLType; else if (pgtype) *pfSqlType = pgtype_attr_to_concise_type(conn, pgtype, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET); else { ret = SQL_ERROR; SC_set_error(stmt, STMT_EXEC_ERROR, "Unfortunately couldn't get this paramater's info", func); goto cleanup; } } if (pcbParamDef) { *pcbParamDef = 0; if (ipdopts->parameters[ipar].SQLType) *pcbParamDef = ipdopts->parameters[ipar].column_size; if (0 == *pcbParamDef && pgtype) *pcbParamDef = pgtype_attr_column_size(conn, pgtype, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET); } if (pibScale) { *pibScale = 0; if (ipdopts->parameters[ipar].SQLType) *pibScale = ipdopts->parameters[ipar].decimal_digits; else if (pgtype) *pibScale = pgtype_scale(stmt, pgtype, -1); } if (pfNullable) *pfNullable = pgtype_nullable(SC_get_conn(stmt), ipdopts->parameters[ipar].paramType); cleanup: #undef return return ret; } /* * This function should really talk to the dbms to determine the number of * "parameter markers" (not bound parameters) in the statement. But, since * Postgres doesn't support that, the driver should just count the number of markers * and return that. The reason the driver just can't say this function is unsupported * like it does for SQLDescribeParam is that some applications don't care and try * to call it anyway. * If the statement does not have parameters, it should just return 0. */ RETCODE SQL_API PGAPI_NumParams(HSTMT hstmt, SQLSMALLINT * pcpar) { StatementClass *stmt = (StatementClass *) hstmt; CSTR func = "PGAPI_NumParams"; MYLOG(0, "entering...\n"); if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } if (pcpar) *pcpar = 0; else { SC_set_error(stmt, STMT_EXEC_ERROR, "parameter count address is null", func); return SQL_ERROR; } MYLOG(DETAIL_LOG_LEVEL, "num_params=%d,%d\n", stmt->num_params, stmt->proc_return); if (stmt->num_params >= 0) *pcpar = stmt->num_params; else if (!stmt->statement) { /* no statement has been allocated */ SC_set_error(stmt, STMT_SEQUENCE_ERROR, "PGAPI_NumParams called with no statement ready.", func); return SQL_ERROR; } else { po_ind_t multi = FALSE, proc_return = 0; stmt->proc_return = 0; SC_scanQueryAndCountParams(stmt->statement, SC_get_conn(stmt), NULL, pcpar, &multi, &proc_return); stmt->num_params = *pcpar; stmt->proc_return = proc_return; stmt->multi_statement = multi; } MYLOG(DETAIL_LOG_LEVEL, "num_params=%d,%d\n", stmt->num_params, stmt->proc_return); return SQL_SUCCESS; } /* * Bindings Implementation */ static BindInfoClass * create_empty_bindings(int num_columns) { BindInfoClass *new_bindings; int i; new_bindings = (BindInfoClass *) malloc(num_columns * sizeof(BindInfoClass)); if (!new_bindings) return NULL; for (i = 0; i < num_columns; i++) { new_bindings[i].buflen = 0; new_bindings[i].buffer = NULL; new_bindings[i].used = new_bindings[i].indicator = NULL; } return new_bindings; } void extend_parameter_bindings(APDFields *self, int num_params) { ParameterInfoClass *new_bindings; MYLOG(0, "entering ... self=%p, parameters_allocated=%d, num_params=%d,%p\n", self, self->allocated, num_params, self->parameters); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_params) { new_bindings = (ParameterInfoClass *) realloc(self->parameters, sizeof(ParameterInfoClass) * num_params); if (!new_bindings) { MYLOG(0, "unable to create %d new bindings from %d old bindings\n", num_params, self->allocated); if (self->parameters) free(self->parameters); self->parameters = NULL; self->allocated = 0; return; } memset(&new_bindings[self->allocated], 0, sizeof(ParameterInfoClass) * (num_params - self->allocated)); self->parameters = new_bindings; self->allocated = num_params; } MYLOG(0, "leaving %p\n", self->parameters); } void extend_iparameter_bindings(IPDFields *self, int num_params) { ParameterImplClass *new_bindings; MYLOG(0, "entering ... self=%p, parameters_allocated=%d, num_params=%d\n", self, self->allocated, num_params); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_params) { new_bindings = (ParameterImplClass *) realloc(self->parameters, sizeof(ParameterImplClass) * num_params); if (!new_bindings) { MYLOG(0, "unable to create %d new bindings from %d old bindings\n", num_params, self->allocated); if (self->parameters) free(self->parameters); self->parameters = NULL; self->allocated = 0; return; } memset(&new_bindings[self->allocated], 0, sizeof(ParameterImplClass) * (num_params - self->allocated)); self->parameters = new_bindings; self->allocated = num_params; } MYLOG(0, "leaving %p\n", self->parameters); } void reset_a_parameter_binding(APDFields *self, int ipar) { MYLOG(0, "entering ... self=%p, parameters_allocated=%d, ipar=%d\n", self, self->allocated, ipar); if (ipar < 1 || ipar > self->allocated) return; ipar--; self->parameters[ipar].buflen = 0; self->parameters[ipar].buffer = NULL; self->parameters[ipar].used = self->parameters[ipar].indicator = NULL; self->parameters[ipar].CType = 0; self->parameters[ipar].data_at_exec = FALSE; self->parameters[ipar].precision = 0; self->parameters[ipar].scale = 0; } void reset_a_iparameter_binding(IPDFields *self, int ipar) { MYLOG(0, "entering ... self=%p, parameters_allocated=%d, ipar=%d\n", self, self->allocated, ipar); if (ipar < 1 || ipar > self->allocated) return; ipar--; NULL_THE_NAME(self->parameters[ipar].paramName); self->parameters[ipar].paramType = 0; self->parameters[ipar].SQLType = 0; self->parameters[ipar].column_size = 0; self->parameters[ipar].decimal_digits = 0; self->parameters[ipar].precision = 0; self->parameters[ipar].scale = 0; PIC_set_pgtype(self->parameters[ipar], 0); } int CountParameters(const StatementClass *self, Int2 *inputCount, Int2 *ioCount, Int2 *outputCount) { IPDFields *ipdopts = SC_get_IPDF(self); int i, num_params, valid_count; if (inputCount) *inputCount = 0; if (ioCount) *ioCount = 0; if (outputCount) *outputCount = 0; if (!ipdopts) return -1; num_params = self->num_params; if (ipdopts->allocated < num_params) num_params = ipdopts->allocated; for (i = 0, valid_count = 0; i < num_params; i++) { if (SQL_PARAM_OUTPUT == ipdopts->parameters[i].paramType) { if (outputCount) { (*outputCount)++; valid_count++; } } else if (SQL_PARAM_INPUT_OUTPUT == ipdopts->parameters[i].paramType) { if (ioCount) { (*ioCount)++; valid_count++; } } else if (inputCount) { (*inputCount)++; valid_count++; } } return valid_count; } /* * Free parameters and free the memory. */ void APD_free_params(APDFields *apdopts, char option) { MYLOG(0, "entering self=%p\n", apdopts); if (!apdopts->parameters) return; if (option == STMT_FREE_PARAMS_ALL) { free(apdopts->parameters); apdopts->parameters = NULL; apdopts->allocated = 0; } MYLOG(0, "leaving\n"); } void PDATA_free_params(PutDataInfo *pdata, char option) { int i; MYLOG(0, "entering self=%p\n", pdata); if (!pdata->pdata) return; for (i = 0; i < pdata->allocated; i++) { if (pdata->pdata[i].EXEC_used) { free(pdata->pdata[i].EXEC_used); pdata->pdata[i].EXEC_used = NULL; } if (pdata->pdata[i].EXEC_buffer) { free(pdata->pdata[i].EXEC_buffer); pdata->pdata[i].EXEC_buffer = NULL; } } if (option == STMT_FREE_PARAMS_ALL) { free(pdata->pdata); pdata->pdata = NULL; pdata->allocated = 0; } MYLOG(0, "leaving\n"); } /* * Free parameters and free the memory. */ void IPD_free_params(IPDFields *ipdopts, char option) { MYLOG(0, "entering self=%p\n", ipdopts); if (!ipdopts->parameters) return; if (option == STMT_FREE_PARAMS_ALL) { for (int i = 0; i < ipdopts->allocated; ++i) NULL_THE_NAME(ipdopts->parameters[i].paramName); free(ipdopts->parameters); ipdopts->parameters = NULL; ipdopts->allocated = 0; } MYLOG(0, "leaving\n"); } void extend_column_bindings(ARDFields *self, int num_columns) { BindInfoClass *new_bindings; int i; MYLOG(0, "entering ... self=%p, bindings_allocated=%d, num_columns=%d\n", self, self->allocated, num_columns); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_columns) { new_bindings = create_empty_bindings(num_columns); if (!new_bindings) { MYLOG(0, "unable to create %d new bindings from %d old bindings\n", num_columns, self->allocated); if (self->bindings) { free(self->bindings); self->bindings = NULL; } self->allocated = 0; return; } if (self->bindings) { for (i = 0; i < self->allocated; i++) new_bindings[i] = self->bindings[i]; free(self->bindings); } self->bindings = new_bindings; self->allocated = num_columns; } /* * There is no reason to zero out extra bindings if there are more * than needed. If an app has allocated extra bindings, let it worry * about it by unbinding those columns. */ /* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */ /* SQLExecDirect(...) # returns 5 cols */ /* SQLExecDirect(...) # returns 10 cols (now OK) */ MYLOG(0, "leaving %p\n", self->bindings); } void reset_a_column_binding(ARDFields *self, int icol) { BindInfoClass *bookmark; MYLOG(0, "entering ... self=%p, bindings_allocated=%d, icol=%d\n", self, self->allocated, icol); if (icol > self->allocated) return; /* use zero based col numbers from here out */ if (0 == icol) { if (bookmark = self->bookmark, bookmark != NULL) { bookmark->buffer = NULL; bookmark->used = bookmark->indicator = NULL; } } else { icol--; /* we have to unbind the column */ self->bindings[icol].buflen = 0; self->bindings[icol].buffer = NULL; self->bindings[icol].used = self->bindings[icol].indicator = NULL; self->bindings[icol].returntype = SQL_C_CHAR; } } void ARD_unbind_cols(ARDFields *self, BOOL freeall) { Int2 lf; MYLOG(DETAIL_LOG_LEVEL, "freeall=%d allocated=%d bindings=%p\n", freeall, self->allocated, self->bindings); for (lf = 1; lf <= self->allocated; lf++) reset_a_column_binding(self, lf); if (freeall) { if (self->bindings) free(self->bindings); self->bindings = NULL; self->allocated = 0; } } void GDATA_unbind_cols(GetDataInfo *self, BOOL freeall) { Int2 lf; MYLOG(DETAIL_LOG_LEVEL, "freeall=%d allocated=%d gdata=%p\n", freeall, self->allocated, self->gdata); if (self->fdata.ttlbuf) { free(self->fdata.ttlbuf); self->fdata.ttlbuf = NULL; } self->fdata.ttlbuflen = self->fdata.ttlbufused = 0; GETDATA_RESET(self->fdata); for (lf = 1; lf <= self->allocated; lf++) reset_a_getdata_info(self, lf); if (freeall) { if (self->gdata) free(self->gdata); self->gdata = NULL; self->allocated = 0; } } void GetDataInfoInitialize(GetDataInfo *gdata_info) { GETDATA_RESET(gdata_info->fdata); gdata_info->fdata.ttlbuf = NULL; gdata_info->fdata.ttlbuflen = gdata_info->fdata.ttlbufused = 0; gdata_info->allocated = 0; gdata_info->gdata = NULL; } static GetDataClass * create_empty_gdata(int num_columns) { GetDataClass *new_gdata; int i; new_gdata = (GetDataClass *) malloc(num_columns * sizeof(GetDataClass)); if (!new_gdata) return NULL; for (i = 0; i < num_columns; i++) { GETDATA_RESET(new_gdata[i]); new_gdata[i].ttlbuf = NULL; new_gdata[i].ttlbuflen = 0; new_gdata[i].ttlbufused = 0; } return new_gdata; } void extend_getdata_info(GetDataInfo *self, int num_columns, BOOL shrink) { GetDataClass *new_gdata; MYLOG(0, "entering ... self=%p, gdata_allocated=%d, num_columns=%d\n", self, self->allocated, num_columns); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_columns) { new_gdata = create_empty_gdata(num_columns); if (!new_gdata) { MYLOG(0, "unable to create %d new gdata from %d old gdata\n", num_columns, self->allocated); if (self->gdata) { free(self->gdata); self->gdata = NULL; } self->allocated = 0; return; } if (self->gdata) { size_t i; for (i = 0; i < self->allocated; i++) new_gdata[i] = self->gdata[i]; free(self->gdata); } self->gdata = new_gdata; self->allocated = num_columns; } else if (shrink && self->allocated > num_columns) { int i; for (i = self->allocated; i > num_columns; i--) reset_a_getdata_info(self, i); self->allocated = num_columns; if (0 == num_columns) { free(self->gdata); self->gdata = NULL; } } /* * There is no reason to zero out extra gdata if there are more * than needed. If an app has allocated extra gdata, let it worry * about it by unbinding those columns. */ MYLOG(0, "leaving %p\n", self->gdata); } void reset_a_getdata_info(GetDataInfo *gdata_info, int icol) { if (icol < 1 || icol > gdata_info->allocated) return; icol--; if (gdata_info->gdata[icol].ttlbuf) { free(gdata_info->gdata[icol].ttlbuf); gdata_info->gdata[icol].ttlbuf = NULL; } gdata_info->gdata[icol].ttlbuflen = gdata_info->gdata[icol].ttlbufused = 0; GETDATA_RESET(gdata_info->gdata[icol]); } void PutDataInfoInitialize(PutDataInfo *pdata_info) { pdata_info->allocated = 0; pdata_info->pdata = NULL; } void extend_putdata_info(PutDataInfo *self, int num_params, BOOL shrink) { PutDataClass *new_pdata; MYLOG(0, "entering ... self=%p, parameters_allocated=%d, num_params=%d\n", self, self->allocated, num_params); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_params) { if (self->allocated <= 0 && self->pdata) { MYLOG(0, "??? pdata is not null while allocated == 0\n"); self->pdata = NULL; } new_pdata = (PutDataClass *) realloc(self->pdata, sizeof(PutDataClass) * num_params); if (!new_pdata) { MYLOG(0, "unable to create %d new pdata from %d old pdata\n", num_params, self->allocated); self->pdata = NULL; self->allocated = 0; return; } memset(&new_pdata[self->allocated], 0, sizeof(PutDataClass) * (num_params - self->allocated)); self->pdata = new_pdata; self->allocated = num_params; } else if (shrink && self->allocated > num_params) { int i; for (i = self->allocated; i > num_params; i--) reset_a_putdata_info(self, i); self->allocated = num_params; if (0 == num_params) { free(self->pdata); self->pdata = NULL; } } MYLOG(0, "leaving %p\n", self->pdata); } void reset_a_putdata_info(PutDataInfo *pdata_info, int ipar) { if (ipar < 1 || ipar > pdata_info->allocated) return; ipar--; if (pdata_info->pdata[ipar].EXEC_used) { free(pdata_info->pdata[ipar].EXEC_used); pdata_info->pdata[ipar].EXEC_used = NULL; } if (pdata_info->pdata[ipar].EXEC_buffer) { free(pdata_info->pdata[ipar].EXEC_buffer); pdata_info->pdata[ipar].EXEC_buffer = NULL; } pdata_info->pdata[ipar].lobj_oid = 0; } void SC_param_next(const StatementClass *stmt, int *param_number, ParameterInfoClass **apara, ParameterImplClass **ipara) { int next; IPDFields *ipdopts = SC_get_IPDF(stmt); if (*param_number < 0) next = stmt->proc_return; else next = *param_number + 1; if (stmt->discard_output_params) { for (;next < ipdopts->allocated && SQL_PARAM_OUTPUT == ipdopts->parameters[next].paramType; next++) ; } *param_number = next; if (ipara) { if (next < ipdopts->allocated) *ipara = ipdopts->parameters + next; else *ipara = NULL; } if (apara) { APDFields *apdopts = SC_get_APDF(stmt); if (next < apdopts->allocated) *apara = apdopts->parameters + next; else *apara = NULL; } } psqlodbc-REL-16_00_0005/bind.h000066400000000000000000000105151462406103600155650ustar00rootroot00000000000000/* File: bind.h * * Description: See "bind.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __BIND_H__ #define __BIND_H__ #include "psqlodbc.h" #include "descriptor.h" /* * BindInfoClass -- stores information about a bound column */ struct BindInfoClass_ { SQLLEN buflen; /* size of buffer */ char *buffer; /* pointer to the buffer */ SQLLEN *used; /* used space in the buffer (for strings * not counting the '\0') */ SQLLEN *indicator; /* indicator == used in many cases ? */ SQLSMALLINT returntype; /* kind of conversion to be applied when * returning (SQL_C_DEFAULT, * SQL_C_CHAR... etc) */ SQLSMALLINT precision; /* the precision for numeric or timestamp type */ SQLSMALLINT scale; /* the scale for numeric type */ /* area for work variables */ char dummy_data; /* currently not used */ }; /* struct for SQLGetData */ typedef struct { /* for BLOBs which don't hold the data */ struct GetBlobDataClass { Int8 data_left64; /* amount of large object data left to read before conversion */ } blob; /* for non-BLOBs which hold the data in ttlbuf after conversion */ char *ttlbuf; /* to save the large result */ SQLLEN ttlbuflen; /* the buffer length */ SQLLEN ttlbufused; /* used length of the buffer */ SQLLEN data_left; /* amount of data left to read */ } GetDataClass; #define GETDATA_RESET(gdc) ((gdc).blob.data_left64 = (gdc).data_left = -1) /* * ParameterInfoClass -- stores information about a bound parameter */ struct ParameterInfoClass_ { SQLLEN buflen; char *buffer; SQLLEN *used; SQLLEN *indicator; /* indicator == used in many cases ? */ SQLSMALLINT CType; SQLSMALLINT precision; /* the precision for numeric or timestamp type */ SQLSMALLINT scale; /* the scale for numeric type */ /* area for work variables */ char data_at_exec; }; typedef struct { SQLLEN *EXEC_used; /* amount of data */ char *EXEC_buffer; /* the data */ OID lobj_oid; } PutDataClass; /* * ParameterImplClass -- stores implementation information about a parameter */ struct ParameterImplClass_ { pgNAME paramName; /* this is unavailable even in 8.1 */ SQLSMALLINT paramType; SQLSMALLINT SQLType; OID PGType; SQLULEN column_size; SQLSMALLINT decimal_digits; SQLSMALLINT precision; /* the precision for numeric or timestamp type */ SQLSMALLINT scale; /* the scale for numeric type */ }; typedef struct { GetDataClass fdata; SQLSMALLINT allocated; GetDataClass *gdata; } GetDataInfo; typedef struct { SQLSMALLINT allocated; PutDataClass *pdata; } PutDataInfo; #define PARSE_PARAM_CAST FALSE #define EXEC_PARAM_CAST TRUE #define SIMPLE_PARAM_CAST TRUE #define CALC_BOOKMARK_ADDR(book, offset, bind_size, index) \ (book->buffer + offset + \ (bind_size > 0 ? bind_size : (SQL_C_VARBOOKMARK == book->returntype ? book->buflen : sizeof(UInt4))) * index) /* Macros to handle pgtype of parameters */ #define PIC_get_pgtype(pari) ((pari).PGType) #define PIC_set_pgtype(pari, type) ((pari).PGType = (type)) #define PIC_dsp_pgtype(conn, pari) ((pari).PGType ? (pari).PGType : sqltype_to_pgtype(conn, (pari).SQLType)) void extend_column_bindings(ARDFields *opts, int num_columns); void reset_a_column_binding(ARDFields *opts, int icol); void extend_parameter_bindings(APDFields *opts, int num_params); void extend_iparameter_bindings(IPDFields *opts, int num_params); void reset_a_parameter_binding(APDFields *opts, int ipar); void reset_a_iparameter_binding(IPDFields *opts, int ipar); int CountParameters(const StatementClass *stmt, Int2 *inCount, Int2 *ioCount, Int2 *outputCount); void GetDataInfoInitialize(GetDataInfo *gdata); void extend_getdata_info(GetDataInfo *gdata, int num_columns, BOOL shrink); void reset_a_getdata_info(GetDataInfo *gdata, int icol); void GDATA_unbind_cols(GetDataInfo *gdata, BOOL freeall); void PutDataInfoInitialize(PutDataInfo *pdata); void extend_putdata_info(PutDataInfo *pdata, int num_params, BOOL shrink); void reset_a_putdata_info(PutDataInfo *pdata, int ipar); void PDATA_free_params(PutDataInfo *pdata, char option); void SC_param_next(const StatementClass*, int *param_number, ParameterInfoClass **, ParameterImplClass **); RETCODE prepareParameters(StatementClass *stmt, BOOL fake_params); RETCODE prepareParametersNoDesc(StatementClass *stmt, BOOL fake_params, BOOL param_cast); int decideHowToPrepare(StatementClass *stmt, BOOL force); #endif psqlodbc-REL-16_00_0005/bootstrap000077500000000000000000000000301462406103600164320ustar00rootroot00000000000000#!/bin/sh autoreconf -i psqlodbc-REL-16_00_0005/buildInstallers.bat000077500000000000000000000004771462406103600203410ustar00rootroot00000000000000:: :: Build installers of psqlodbc project :: @echo off if "%1" == "/?" ( powershell Get-Help '%~dp0\installer\buildInstallers.ps1' -detailed ) else if "%1" == "-?" ( powershell Get-Help '%~dp0\installer\buildInstallers.ps1' %2 %3 %4 %5 %6 %7 %8 %9 ) else ( powershell "& '%~dp0\installer\buildInstallers.ps1' %*" ) psqlodbc-REL-16_00_0005/catfunc.h000066400000000000000000000107271462406103600163010ustar00rootroot00000000000000/* File: catfunc.h * * Description: See "info.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __CATFUNC_H__ #define __CATFUNC_H__ #include "psqlodbc.h" /* SQLTables field position */ enum { TABLES_CATALOG_NAME = 0 ,TABLES_SCHEMA_NAME ,TABLES_TABLE_NAME ,TABLES_TABLE_TYPE ,TABLES_REMARKS ,NUM_OF_TABLES_FIELDS }; /* SQLColumns field position */ enum { COLUMNS_CATALOG_NAME = 0 ,COLUMNS_SCHEMA_NAME ,COLUMNS_TABLE_NAME ,COLUMNS_COLUMN_NAME ,COLUMNS_DATA_TYPE ,COLUMNS_TYPE_NAME ,COLUMNS_PRECISION ,COLUMNS_LENGTH ,COLUMNS_SCALE ,COLUMNS_RADIX ,COLUMNS_NULLABLE ,COLUMNS_REMARKS ,COLUMNS_COLUMN_DEF /* ODBC 3.0 but always use it */ ,COLUMNS_SQL_DATA_TYPE ,COLUMNS_SQL_DATETIME_SUB ,COLUMNS_CHAR_OCTET_LENGTH ,COLUMNS_ORDINAL_POSITION ,COLUMNS_IS_NULLABLE ,COLUMNS_DISPLAY_SIZE ,COLUMNS_FIELD_TYPE ,COLUMNS_AUTO_INCREMENT ,COLUMNS_PHYSICAL_NUMBER ,COLUMNS_TABLE_OID ,COLUMNS_BASE_TYPEID ,COLUMNS_ATTTYPMOD ,COLUMNS_TABLE_INFO ,NUM_OF_COLUMNS_FIELDS }; /* SQLPrimaryKeys field position */ enum { PKS_TABLE_CAT = 0 ,PKS_TABLE_SCHEM ,PKS_TABLE_NAME ,PKS_COLUMN_NAME ,PKS_KEY_SQ ,PKS_PK_NAME ,NUM_OF_PKS_FIELDS }; /* SQLForeignKeys field position */ enum { FKS_PKTABLE_CAT = 0 ,FKS_PKTABLE_SCHEM ,FKS_PKTABLE_NAME ,FKS_PKCOLUMN_NAME ,FKS_FKTABLE_CAT ,FKS_FKTABLE_SCHEM ,FKS_FKTABLE_NAME ,FKS_FKCOLUMN_NAME ,FKS_KEY_SEQ ,FKS_UPDATE_RULE ,FKS_DELETE_RULE ,FKS_FK_NAME ,FKS_PK_NAME ,FKS_DEFERRABILITY ,FKS_TRIGGER_NAME ,NUM_OF_FKS_FIELDS }; /* SQLColAttribute */ enum { COLATTR_DESC_COUNT = -1 ,COLATTR_DESC_AUTO_UNIQUE_VALUE = 0 ,COLATTR_DESC_BASE_COLUMN_NAME ,COLATTR_DESC_BASE_TABLE_NAME ,COLATTR_DESC_CASE_SENSITIVE ,COLATTR_DESC_CATALOG_NAME ,COLATTR_DESC_CONCISE_TYPE ,COLATTR_DESC_DISPLAY_SIZE ,COLATTR_DESC_FIXED_PREC_SCALE ,COLATTR_DESC_LABEL ,COLATTR_DESC_LENGTH ,COLATTR_DESC_LITERAL_PREFIX ,COLATTR_DESC_LITERAL_SUFFIX ,COLATTR_DESC_LOCAL_TYPE_NAME ,COLATTR_DESC_NAME ,COLATTR_DESC_NULLABLE ,COLATTR_DESC_NUM_PREX_RADIX ,COLATTR_DESC_OCTET_LENGTH ,COLATTR_DESC_PRECISION ,COLATTR_DESC_SCALE ,COLATTR_DESC_SCHEMA_NAME ,COLATTR_DESC_SEARCHABLE ,COLATTR_DESC_TABLE_NAME ,COLATTR_DESC_TYPE ,COLATTR_DESC_TYPE_NAME ,COLATTR_DESC_UNNAMED ,COLATTR_DESC_UNSIGNED ,COLATTR_DESC_UPDATABLE }; /* SQLStatistics field position */ enum { STATS_CATALOG_NAME = 0 ,STATS_SCHEMA_NAME ,STATS_TABLE_NAME ,STATS_NON_UNIQUE ,STATS_INDEX_QUALIFIER ,STATS_INDEX_NAME ,STATS_TYPE ,STATS_SEQ_IN_INDEX ,STATS_COLUMN_NAME ,STATS_COLLATION ,STATS_CARDINALITY ,STATS_PAGES ,STATS_FILTER_CONDITION ,NUM_OF_STATS_FIELDS }; /* SQLProcedureColumns field position */ enum { PROCOLS_PROCEDURE_CAT = 0 ,PROCOLS_PROCEDURE_SCHEM ,PROCOLS_PROCEDURE_NAME ,PROCOLS_COLUMN_NAME ,PROCOLS_COLUMN_TYPE ,PROCOLS_DATA_TYPE ,PROCOLS_TYPE_NAME ,PROCOLS_COLUMN_SIZE ,PROCOLS_BUFFER_LENGTH ,PROCOLS_DECIMAL_DIGITS ,PROCOLS_NUM_PREC_RADIX ,PROCOLS_NULLABLE ,PROCOLS_REMARKS ,PROCOLS_COLUMN_DEF ,PROCOLS_SQL_DATA_TYPE ,PROCOLS_SQL_DATETIME_SUB ,PROCOLS_CHAR_OCTET_LENGTH ,PROCOLS_ORDINAL_POSITION ,PROCOLS_IS_NULLABLE ,NUM_OF_PROCOLS_FIELDS }; /* SQLGetTypeInfo field position */ enum { GETTYPE_TYPE_NAME = 0 ,GETTYPE_DATA_TYPE ,GETTYPE_COLUMN_SIZE ,GETTYPE_LITERAL_PREFIX ,GETTYPE_LITERAL_SUFFIX ,GETTYPE_CREATE_PARAMS ,GETTYPE_NULLABLE ,GETTYPE_CASE_SENSITIVE ,GETTYPE_SEARCHABLE ,GETTYPE_UNSIGNED_ATTRIBUTE ,GETTYPE_FIXED_PREC_SCALE ,GETTYPE_AUTO_UNIQUE_VALUE ,GETTYPE_LOCAL_TYPE_NAME ,GETTYPE_MINIMUM_SCALE ,GETTYPE_MAXIMUM_SCALE ,GETTYPE_SQL_DATA_TYPE ,GETTYPE_SQL_DATETIME_SUB ,GETTYPE_NUM_PREC_RADIX ,GETTYPE_INTERVAL_PRECISION ,NUM_OF_GETTYPE_FIELDS }; /* SQLSpecialColumns field position */ enum { SPECOLS_SCOPE = 0 ,SPECOLS_COLUMN_NAME ,SPECOLS_DATA_TYPE ,SPECOLS_TYPE_NAME ,SPECOLS_COLUMN_SIZE ,SPECOLS_BUFFER_LENGTH ,SPECOLS_DECIMAL_DIGITS ,SPECOLS_PSEUDO_COLUMN ,NUM_OF_SPECOLS_FIELDS }; /* SQLTablePrivileges field position */ enum { TABPRIV_TABLE_CAT = 0 ,TABPRIV_TABLE_SCHEM ,TABPRIV_TABLE_NAME ,TABPRIV_GRANTOR ,TABPRIV_GRANTEE ,TABPRIV_PRIVILEGE ,TABPRIV_IS_GRANTABLE ,NUM_OF_TABPRIV_FIELDS }; #endif /* __CARFUNC_H__ */ psqlodbc-REL-16_00_0005/columninfo.c000066400000000000000000000072471462406103600170250ustar00rootroot00000000000000/*------- * Module: columninfo.c * * Description: This module contains routines related to * reading and storing the field information from a query. * * Classes: ColumnInfoClass (Functions prefix: "CI_") * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "pgtypes.h" #include "columninfo.h" #include "connection.h" #include #include #include "pgapifunc.h" #include ColumnInfoClass * CI_Constructor(void) { ColumnInfoClass *rv; rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass)); if (rv) { rv->refcount = 0; rv->num_fields = 0; rv->coli_array = NULL; } return rv; } void CI_Destructor(ColumnInfoClass *self) { CI_free_memory(self); free(self); } /* * Read in field descriptions from a libpq result set. * If self is not null, then also store the information. * If self is null, then just read, don't store. */ BOOL CI_read_fields_from_pgres(ColumnInfoClass *self, PGresult *pgres) { Int2 lf; int new_num_fields; OID new_adtid, new_relid = 0, new_attid = 0; Int2 new_adtsize; Int4 new_atttypmod = -1; char *new_field_name; /* at first read in the number of fields that are in the query */ new_num_fields = PQnfields(pgres); QLOG(0, "\tnFields: %d\n", new_num_fields); if (self) { /* according to that allocate memory */ CI_set_num_fields(self, new_num_fields); if (new_num_fields > 0 && NULL == self->coli_array) return FALSE; } /* now read in the descriptions */ for (lf = 0; lf < new_num_fields; lf++) { new_field_name = PQfname(pgres, lf); new_relid = PQftable(pgres, lf); new_attid = PQftablecol(pgres, lf); new_adtid = PQftype(pgres, lf); new_adtsize = PQfsize(pgres, lf); MYLOG(0, "READING ATTTYPMOD\n"); new_atttypmod = PQfmod(pgres, lf); /* Subtract the header length */ switch (new_adtid) { case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIME: case PG_TYPE_TIME_WITH_TMZONE: break; default: new_atttypmod -= 4; } if (new_atttypmod < 0) new_atttypmod = -1; QLOG(0, "\tfieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d (rel,att)=(%d,%d)\n", new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid); if (self) CI_set_field_info(self, lf, new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid); } return TRUE; } void CI_free_memory(ColumnInfoClass *self) { register Int2 lf; int num_fields = self->num_fields; /* Safe to call even if null */ self->num_fields = 0; if (self->coli_array) { for (lf = 0; lf < num_fields; lf++) { if (self->coli_array[lf].name) { free(self->coli_array[lf].name); self->coli_array[lf].name = NULL; } } free(self->coli_array); self->coli_array = NULL; } } void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) { CI_free_memory(self); /* always safe to call */ self->num_fields = new_num_fields; self->coli_array = (struct srvr_info *) calloc(sizeof(struct srvr_info), self->num_fields); } void CI_set_field_info(ColumnInfoClass *self, int field_num, const char *new_name, OID new_adtid, Int2 new_adtsize, Int4 new_atttypmod, OID new_relid, OID new_attid) { /* check bounds */ if ((field_num < 0) || (field_num >= self->num_fields)) return; /* store the info */ self->coli_array[field_num].name = strdup(new_name); self->coli_array[field_num].adtid= new_adtid; self->coli_array[field_num].adtsize = new_adtsize; self->coli_array[field_num].atttypmod = new_atttypmod; self->coli_array[field_num].display_size = PG_ADT_UNSET; self->coli_array[field_num].relid = new_relid; self->coli_array[field_num].attid = new_attid; } psqlodbc-REL-16_00_0005/columninfo.h000066400000000000000000000033631462406103600170250ustar00rootroot00000000000000/* File: columninfo.h * * Description: See "columninfo.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __COLUMNINFO_H__ #define __COLUMNINFO_H__ #include "psqlodbc.h" #include struct ColumnInfoClass_ { UInt4 refcount; /* reference count. A ColumnInfo can be shared by * several qresults. */ Int2 num_fields; struct srvr_info { char *name; /* field name */ OID adtid; /* type oid */ Int2 adtsize; /* type size */ Int4 display_size; /* the display size (longest row) */ Int4 atttypmod; /* the length of bpchar/varchar */ OID relid; /* the relation id */ Int2 attid; /* the attribute number */ } *coli_array; }; #define CI_get_num_fields(self) (self->num_fields) #define CI_get_oid(self, col) (self->coli_array[col].adtid) #define CI_get_fieldname(self, col) (self->coli_array[col].name) #define CI_get_fieldsize(self, col) (self->coli_array[col].adtsize) #define CI_get_display_size(self, col) (self->coli_array[col].display_size) #define CI_get_atttypmod(self, col) (self->coli_array[col].atttypmod) #define CI_get_relid(self, col) (self->coli_array[col].relid) #define CI_get_attid(self, col) (self->coli_array[col].attid) ColumnInfoClass *CI_Constructor(void); void CI_Destructor(ColumnInfoClass *self); void CI_free_memory(ColumnInfoClass *self); BOOL CI_read_fields_from_pgres(ColumnInfoClass *self, PGresult *pgres); /* functions for setting up the fields from within the program, */ /* without reading from a socket */ void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields); void CI_set_field_info(ColumnInfoClass *self, int field_num, const char *new_name, OID new_adtid, Int2 new_adtsize, Int4 atttypmod, OID new_relid, OID new_attid); #endif psqlodbc-REL-16_00_0005/config/000077500000000000000000000000001462406103600157435ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/config/c-library.m4000066400000000000000000000044451462406103600201000ustar00rootroot00000000000000# Macros that test various C library quirks # $PostgreSQL: pgsql/config/c-library.m4,v 1.31 2005/02/24 01:34:45 tgl Exp $ # PGAC_FUNC_GETTIMEOFDAY_1ARG # --------------------------- # Check if gettimeofday() has only one arguments. (Normal is two.) # If so, define GETTIMEOFDAY_1ARG. AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG], [AC_CACHE_CHECK(whether gettimeofday takes only one argument, pgac_cv_func_gettimeofday_1arg, [AC_TRY_COMPILE([#include ], [struct timeval *tp; struct timezone *tzp; gettimeofday(tp,tzp);], [pgac_cv_func_gettimeofday_1arg=no], [pgac_cv_func_gettimeofday_1arg=yes])]) if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then AC_DEFINE(GETTIMEOFDAY_1ARG,, [Define to 1 if gettimeofday() takes only 1 argument.]) fi AH_VERBATIM(GETTIMEOFDAY_1ARG_, [@%:@ifdef GETTIMEOFDAY_1ARG @%:@ define gettimeofday(a,b) gettimeofday(a) @%:@endif])dnl ])# PGAC_FUNC_GETTIMEOFDAY_1ARG # PGAC_FUNC_GETPWUID_R_5ARG # --------------------------- # Check if getpwuid_r() takes a fifth argument (later POSIX standard, not draft version) # If so, define GETPWUID_R_5ARG AC_DEFUN([PGAC_FUNC_GETPWUID_R_5ARG], [AC_CACHE_CHECK(whether getpwuid_r takes a fifth argument, pgac_func_getpwuid_r_5arg, [AC_TRY_COMPILE([#include #include ], [uid_t uid; struct passwd *space; char *buf; size_t bufsize; struct passwd **result; getpwuid_r(uid, space, buf, bufsize, result);], [pgac_func_getpwuid_r_5arg=yes], [pgac_func_getpwuid_r_5arg=no])]) if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then AC_DEFINE(GETPWUID_R_5ARG,, [Define to 1 if getpwuid_r() takes a 5th argument.]) fi ])# PGAC_FUNC_GETPWUID_R_5ARG # PGAC_FUNC_STRERROR_R_INT # --------------------------- # Check if strerror_r() returns an int (SUSv3) rather than a char * (GNU libc) # If so, define STRERROR_R_INT AC_DEFUN([PGAC_FUNC_STRERROR_R_INT], [AC_CACHE_CHECK(whether strerror_r returns int, pgac_func_strerror_r_int, [AC_TRY_COMPILE([#include ], [#ifndef _AIX int strerror_r(int, char *, size_t); #else /* Older AIX has 'int' for the third argument so we don't test the args. */ int strerror_r(); #endif], [pgac_func_strerror_r_int=yes], [pgac_func_strerror_r_int=no])]) if test x"$pgac_func_strerror_r_int" = xyes ; then AC_DEFINE(STRERROR_R_INT,, [Define to 1 if strerror_r() returns a int.]) fi ])# PGAC_FUNC_STRERROR_R_INT psqlodbc-REL-16_00_0005/config/general.m4000066400000000000000000000113201462406103600176170ustar00rootroot00000000000000# $PostgreSQL: pgsql/config/general.m4,v 1.9 2006/11/30 22:21:23 tgl Exp $ # This file defines new macros to process configure command line # arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE. # The flaw in these is particularly that they only differentiate # between "given" and "not given" and do not provide enough help to # process arguments that only accept "yes/no", that require an # argument (other than "yes/no"), etc. # # The point of this implementation is to reduce code size and # redundancy in configure.in and to improve robustness and consistency # in the option evaluation code. # Convert type and name to shell variable name (e.g., "enable_long_strings") m4_define([pgac_arg_to_variable], [$1[]_[]patsubst($2, -, _)]) # PGAC_ARG(TYPE, NAME, HELP-STRING, # [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG], # [ACTION-IF-OMITTED]) # ---------------------------------------------------------- # This is the base layer. TYPE is either "with" or "enable", depending # on what you like. NAME is the rest of the option name, HELP-STRING # as usual. ACTION-IF-YES is executed if the option is given without # an argument (or "yes", which is the same); similar for ACTION-IF-NO. AC_DEFUN([PGAC_ARG], [ pgac_args="$pgac_args pgac_arg_to_variable([$1],[$2])" m4_case([$1], enable, [ AC_ARG_ENABLE([$2], [$3], [ case [$]enableval in yes) m4_default([$4], :) ;; no) m4_default([$5], :) ;; *) $6 ;; esac ], [$7])[]dnl AC_ARG_ENABLE ], with, [ AC_ARG_WITH([$2], [$3], [ case [$]withval in yes) m4_default([$4], :) ;; no) m4_default([$5], :) ;; *) $6 ;; esac ], [$7])[]dnl AC_ARG_WITH ], [m4_fatal([first argument of $0 must be 'enable' or 'with', not '$1'])] ) ])# PGAC_ARG # PGAC_ARG_CHECK() # ---------------- # Checks if the user passed any --with/without/enable/disable # arguments that were not defined. Just prints out a warning message, # so this should be called near the end, so the user will see it. AC_DEFUN([PGAC_ARG_CHECK], [for pgac_var in `set | sed 's/=.*//' | $EGREP 'with_|enable_'`; do for pgac_arg in $pgac_args with_gnu_ld; do if test "$pgac_var" = "$pgac_arg"; then continue 2 fi done pgac_txt=`echo $pgac_var | sed 's/_/-/g'` AC_MSG_WARN([option ignored: --$pgac_txt]) done])# PGAC_ARG_CHECK # PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING, # [ACTION-IF-YES], [ACTION-IF-NO]) # ----------------------------------------------- # Accept a boolean option, that is, one that only takes yes or no. # ("no" is equivalent to "disable" or "without"). DEFAULT is what # should be done if the option is omitted; it should be "yes" or "no". # (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always # execute.) AC_DEFUN([PGAC_ARG_BOOL], [PGAC_ARG([$1], [$2], [$4], [$5], [$6], [AC_MSG_ERROR([no argument expected for --$1-$2 option])], [m4_case([$3], yes, [pgac_arg_to_variable([$1], [$2])=yes $5], no, [pgac_arg_to_variable([$1], [$2])=no $6], [m4_fatal([third argument of $0 must be 'yes' or 'no', not '$3'])])])[]dnl ])# PGAC_ARG_BOOL # PGAC_ARG_REQ(TYPE, NAME, HELP-STRING, [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN]) # ------------------------------------------------------------------------------- # This option will require an argument; "yes" or "no" will not be # accepted. AC_DEFUN([PGAC_ARG_REQ], [PGAC_ARG([$1], [$2], [$3], [AC_MSG_ERROR([argument required for --$1-$2 option])], [AC_MSG_ERROR([argument required for --$1-$2 option])], [$4], [$5])])# PGAC_ARG_REQ # PGAC_ARG_OPTARG(TYPE, NAME, HELP-STRING, [DEFAULT-ACTION], [ARG-ACTION] # [ACTION-ENABLED], [ACTION-DISABLED]) # ----------------------------------------------------------------------- # This will create an option that behaves as follows: If omitted, or # called with "no", then set the enable_variable to "no" and do # nothing else. If called with "yes", then execute DEFAULT-ACTION. If # called with argument, set enable_variable to "yes" and execute # ARG-ACTION. Additionally, execute ACTION-ENABLED if we ended up with # "yes" either way, else ACTION-DISABLED. # # The intent is to allow enabling a feature, and optionally pass an # additional piece of information. AC_DEFUN([PGAC_ARG_OPTARG], [PGAC_ARG([$1], [$2], [$3], [$4], [], [pgac_arg_to_variable([$1], [$2])=yes $5], [pgac_arg_to_variable([$1], [$2])=no]) dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED. m4_ifval([$6[]$7], [ if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then m4_default([$6], :) m4_ifval([$7], [else $7 ])[]dnl fi ])[]dnl ])# PGAC_ARG_OPTARG psqlodbc-REL-16_00_0005/configure.ac000066400000000000000000000175741462406103600170020ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. AC_INIT(psqlodbc, 16.00.0000, [pgsql-odbc@postgresql.org]) AC_PREREQ(2.57) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([bind.c]) AM_CONFIG_HEADER([config.h]) AM_MAINTAINER_MODE # 0. Options processing AC_PROG_CC AM_CONDITIONAL([GCC], [test -n "$GCC"]) # All AC_CHECK_SIZEOF() or AC_CHECK_TYPES() calls were move from 4. # unixODBC wants the following to get sane behavior for ODBCINT64 AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long int) # for unixODBC AC_CHECK_SIZEOF(void *) AC_CHECK_TYPES([long long]) AC_CHECK_TYPES([signed char]) AC_CHECK_TYPES([ssize_t]) AC_CHECK_SIZEOF([bool], [], [#ifdef HAVE_STDBOOL_H #include #endif]) dnl We use if we have it and it declares type bool as having dnl size 1. Otherwise, c.h will fall back to declaring bool as unsigned char. if test "$ac_cv_header_stdbool_h" = yes -a "$ac_cv_sizeof_bool" = 1; then AC_DEFINE([PG_USE_STDBOOL], 1, [Define to 1 to use to define type bool.]) fi AC_TYPE_SIZE_T # Check if "-Wall" is valid if test -n "$GCC" && test "$ac_test_CFLAGS" != set; then AC_MSG_CHECKING(-Wall is a valid compile option) CFLAGS_SAVE="${CFLAGS}" CFLAGS="${CFLAGS} -Wall" AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], [])], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) CFLAGS="${CFLAGS_SAVE}"]) fi # # Whether unixODBC driver manager is used # AC_ARG_WITH(unixodbc, [ --with-unixodbc[[=DIR]] [[default=yes]] DIR is the unixODBC base install directory or the path to odbc_config], [], [with_unixodbc=yes]) # # Whether iODBC driver manager is used # AC_ARG_WITH(iodbc, [ --with-iodbc[[=DIR]] [[default=no]] DIR is the iODBC base install directory or the path to iodbc-config], [], [with_iodbc=no]) if test "$with_iodbc" != no; then with_unixodbc=no AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support]) if test "$with_iodbc" = yes; then AC_PATH_PROGS(ODBC_CONFIG, iodbc-config) else ODBC_CONFIG=$with_iodbc fi if test ! -x "${ODBC_CONFIG}/bin/iodbc-config"; then if test ! -x "${ODBC_CONFIG}"; then AC_MSG_ERROR([iodbc-config not found (required for iODBC build)]) fi else ODBC_CONFIG=${ODBC_CONFIG}/bin/iodbc-config fi fi wo_odbc_config=__without_odbc_config if test "$with_unixodbc" != no; then AC_DEFINE(WITH_UNIXODBC, 1, [Define to 1 to build with unixODBC support]) if test "$with_unixodbc" = yes; then AC_PATH_PROGS(ODBC_CONFIG, odbc_config) else ODBC_CONFIG=$with_unixodbc fi if test "${ODBC_CONFIG}" = "${wo_odbc_config}"; then : elif test ! -x "${ODBC_CONFIG}/bin/odbc_config"; then if test ! -x "${ODBC_CONFIG}"; then AC_MSG_ERROR([odbc_config not found (required for unixODBC build)]) fi else ODBC_CONFIG=${ODBC_CONFIG}/bin/odbc_config fi fi # # ODBC include and library # if test "$ODBC_CONFIG" != ""; then if test "$with_iodbc" != no; then ODBC_INCLUDE=`${ODBC_CONFIG} --cflags` CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}" # Linking libiodoc is rather problematic [ODBC_LIBDIR=`${ODBC_CONFIG} --libs | sed -e "s/^\(-L\|.*[ \t]-L\)\([^ \n\r\f\t]*\).*$/-L\2/"`] LDFLAGS="$LDFLAGS ${ODBC_LIBDIR}" LIBODBC=`${ODBC_CONFIG} --libs` # for regression test elif test "${ODBC_CONFIG}" = "${wo_odbc_config}"; then ODBC_INCLUDE=/usr/include CPPFLAGS="$CPPFLAGS -I${ODBC_INCLUDE}" ODBC_LIBDiR="" LIBODBC="-lodbc" # for regression test else ODBC_INCLUDE=`${ODBC_CONFIG} --include-prefix` CPPFLAGS="$CPPFLAGS -I${ODBC_INCLUDE}" # Linking libodbc is rather problematic ODBC_LIBDIR=`${ODBC_CONFIG} --lib-prefix` if test "${ODBC_LIBDIR}" != ""; then LDFLAGS="$LDFLAGS -L${ODBC_LIBDIR}" fi LIBODBC=`${ODBC_CONFIG} --libs` # for regression test fi AC_MSG_NOTICE([using $ODBC_INCLUDE $ODBC_LIBDIR]) AC_MSG_NOTICE([using $LIBODBC for regression test]) fi AC_SUBST(LIBODBC) # # SQLCOLATTRIBUTE_SQLLEN check # AC_MSG_CHECKING(last argument to SQLColAttribute is SQLLEN *) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include SQLRETURN SQL_API SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLLEN *NumericAttribute) { SQLLEN t = 1; *NumericAttribute = t; return 0; } ]])], [AC_DEFINE(SQLCOLATTRIBUTE_SQLLEN, 1, [Define to 1 if SQLColAttribute use SQLLEN]) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) # # Whether libpq functionalities are used # AC_ARG_WITH(libpq, [ --with-libpq[[=DIR]] DIR is the PostgreSQL base install directory or the path to pg_config], [], [with_libpq=yes]) if test "$with_libpq" = no; then AC_MSG_ERROR([libpq is mandatory, --without-libpq is no longer supported]) fi if test "$with_libpq" != yes; then if test -d "$with_libpq"; then PATH="$with_libpq/bin:$PATH" CPPFLAGS="$CPPFLAGS -I$with_libpq/include -I$with_libpq/include/postgresql/internal" LDFLAGS="$LDFLAGS -L$with_libpq/lib" else if test -x "$with_libpq"; then PG_CONFIG=$with_libpq else AC_MSG_ERROR([specified pg_config not found]) fi fi fi # # Pthreads # PGAC_ARG_BOOL(enable, pthreads, yes, [ --disable-pthreads do not build with POSIX threads], [AC_DEFINE(POSIX_MULTITHREAD_SUPPORT, 1, [Define to 1 to build with pthreads support (--enable-pthreads)]) AC_DEFINE(_REENTRANT, 1, [Define _REENTRANT for several platforms])]) # # Find libpq headers and libraries # if test -z "$PG_CONFIG"; then AC_PATH_PROGS(PG_CONFIG, pg_config) fi if test -n "$PG_CONFIG"; then pg_includedir=`"$PG_CONFIG" --includedir` pg_pkg_includedir=`"$PG_CONFIG" --pkgincludedir` pg_libdir=`"$PG_CONFIG" --libdir` CPPFLAGS="$CPPFLAGS -I$pg_includedir -I$pg_pkg_includedir/internal" LDFLAGS="$LDFLAGS -L$pg_libdir" fi # 1. Programs # 'prove' is used to pretty-print regression test results, if available. AC_CHECK_PROGS(PROVE, prove) # 2. Libraries AC_LIBTOOL_WIN32_DLL AC_DISABLE_STATIC AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL if test "$with_unixodbc" != no; then AC_SEARCH_LIBS(SQLGetPrivateProfileString, odbcinst, [], [AC_MSG_ERROR([unixODBC library "odbcinst" not found])]) fi if test "$with_iodbc" != no; then AC_SEARCH_LIBS(SQLGetPrivateProfileString, iodbcinst, [], [AC_MSG_ERROR([iODBC library "iodbcinst" not found])]) fi if test "$enable_pthreads" = yes; then AC_CHECK_LIB(pthreads, pthread_create, [], [AC_CHECK_LIB(pthread, pthread_create)]) fi AC_CHECK_LIB(pq, PQsetSingleRowMode, [], [AC_MSG_ERROR([libpq library version >= 9.2 is required])]) # 3. Header files AC_CHECK_HEADERS(locale.h sys/time.h uchar.h) AC_CHECK_HEADER(libpq-fe.h,,[AC_MSG_ERROR([libpq header not found])]) AC_HEADER_TIME AC_HEADER_STDBOOL # 4. Types(all members were moved to 0.) # 5. Structures AC_STRUCT_TM # 6. Compiler characteristics AC_C_CONST # 7. Functions, global variables AC_FUNC_STRERROR_R AC_CHECK_FUNCS(strtoul strtoll strlcat mbstowcs wcstombs mbrtoc16 c16rtomb) AC_CHECK_FUNCS(PQsslInUse) if test "$enable_pthreads" = yes; then AC_CHECK_FUNCS(localtime_r strtok_r pthread_mutexattr_settype) if test x"$ac_cv_func_pthread_mutexattr_settype" = xyes; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_MUTEX_RECURSIVE;]])], [AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE, [Define if you have PTHREAD_MUTEX_RECURSIVE])], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_MUTEX_RECURSIVE_NP;]])], [AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE_NP, [Define if you have PTHREAD_MUTEX_RECURSIVE_NP])])]) fi fi # 8. Libltdl This release doesn't need libltdl # AC_CHECK_LIB(ltdl, lt_dlopen) AC_CONFIG_FILES([Makefile test/Makefile]) AC_OUTPUT psqlodbc-REL-16_00_0005/connection.c000066400000000000000000002542431462406103600170130ustar00rootroot00000000000000/*------ * Module: connection.c * * Description: This module contains routines related to * connecting to and disconnecting from the Postgres DBMS. * * Classes: ConnectionClass (Functions prefix: "CC_") * * API functions: SQLAllocConnect, SQLConnect, SQLDisconnect, SQLFreeConnect, * SQLBrowseConnect(NI) * * Comments: See "readme.txt" for copyright and license information. *------- */ /* Multibyte support Eiji Tokuya 2001-03-15 */ /* TryEnterCritiaclSection needs the following #define */ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif /* _WIN32_WINNT */ #include "connection.h" #include "misc.h" #include #include #include /* for htonl */ #ifdef WIN32 #include #else #include #endif #include "environ.h" #include "statement.h" #include "qresult.h" #include "lobj.h" #include "dlg_specific.h" #include "loadlib.h" #include "multibyte.h" #include "pgapifunc.h" #define SAFE_STR(s) (NULL != (s) ? (s) : "(null)") #define STMT_INCREMENT 16 /* how many statement holders to allocate * at a time */ 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); const char *errmsg = CC_get_errormsg(self); if (errornumber == 0) return; if (errornumber > 0) { if (errornum <= 0) CC_set_error(self, errornumber, errormsg, func); else if (!errmsg) CC_set_errormsg(self, errormsg); } else if (errornum == 0) CC_set_error(self, errornumber, errormsg, func); else if (errornum < 0 && !errmsg) CC_set_errormsg(self, errormsg); } RETCODE SQL_API PGAPI_AllocConnect(HENV henv, HDBC * phdbc) { EnvironmentClass *env = (EnvironmentClass *) henv; ConnectionClass *conn; CSTR func = "PGAPI_AllocConnect"; MYLOG(0, "entering...\n"); conn = CC_Constructor(); MYLOG(0, "**** henv = %p, conn = %p\n", henv, conn); if (!conn) { env->errormsg = "Couldn't allocate memory for Connection object."; env->errornumber = ENV_ALLOC_ERROR; *phdbc = SQL_NULL_HDBC; EN_log_error(func, "", env); return SQL_ERROR; } if (!EN_add_connection(env, conn)) { env->errormsg = "Maximum number of connections exceeded."; env->errornumber = ENV_ALLOC_ERROR; CC_Destructor(conn); *phdbc = SQL_NULL_HDBC; EN_log_error(func, "", env); return SQL_ERROR; } if (phdbc) *phdbc = (HDBC) conn; return SQL_SUCCESS; } RETCODE SQL_API PGAPI_Connect(HDBC hdbc, const SQLCHAR * szDSN, SQLSMALLINT cbDSN, const SQLCHAR * szUID, SQLSMALLINT cbUID, const SQLCHAR * szAuthStr, SQLSMALLINT cbAuthStr) { ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci; CSTR func = "PGAPI_Connect"; RETCODE ret = SQL_SUCCESS; char fchar, *tmpstr; MYLOG(0, "entering..cbDSN=%hi.\n", cbDSN); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } ci = &conn->connInfo; CC_conninfo_init(ci, INIT_GLOBALS); make_string(szDSN, cbDSN, ci->dsn, sizeof(ci->dsn)); /* get the values for the DSN from the registry */ getDSNinfo(ci, NULL); logs_on_off(1, ci->drivers.debug, ci->drivers.commlog); /* initialize pg_version from connInfo.protocol */ CC_initialize_pg_version(conn); /* * override values from DSN info with UID and authStr(pwd) This only * occurs if the values are actually there. */ fchar = ci->username[0]; /* save the first byte */ make_string(szUID, cbUID, ci->username, sizeof(ci->username)); if ('\0' == ci->username[0]) /* an empty string is specified */ ci->username[0] = fchar; /* restore the original username */ tmpstr = make_string(szAuthStr, cbAuthStr, NULL, 0); if (tmpstr) { if (tmpstr[0]) /* non-empty string is specified */ STR_TO_NAME(ci->password, tmpstr); free(tmpstr); } 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 (SQL_SUCCESS == ret && 2 == fchar) ret = SQL_SUCCESS_WITH_INFO; MYLOG(0, "leaving..%d.\n", ret); return ret; } RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc, const SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT * pcbConnStrOut) { CSTR func = "PGAPI_BrowseConnect"; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "entering...\n"); CC_set_error(conn, CONN_NOT_IMPLEMENTED_ERROR, "Function not implemented", func); return SQL_ERROR; } /* Drop any hstmts open on hdbc and disconnect from database */ RETCODE SQL_API PGAPI_Disconnect(HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; CSTR func = "PGAPI_Disconnect"; MYLOG(0, "entering...\n"); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } if (conn->status == CONN_EXECUTING) { CC_set_error(conn, CONN_IN_USE, "A transaction is currently being executed", func); return SQL_ERROR; } logs_on_off(-1, conn->connInfo.drivers.debug, conn->connInfo.drivers.commlog); MYLOG(0, "about to CC_cleanup\n"); /* Close the connection and free statements */ CC_cleanup(conn, FALSE); MYLOG(0, "done CC_cleanup\n"); MYLOG(0, "leaving...\n"); return SQL_SUCCESS; } RETCODE SQL_API PGAPI_FreeConnect(HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; CSTR func = "PGAPI_FreeConnect"; EnvironmentClass *env; MYLOG(0, "entering...hdbc=%p\n", hdbc); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } /* Remove the connection from the environment */ if (NULL != (env = CC_get_env(conn)) && !EN_remove_connection(env, conn)) { CC_set_error(conn, CONN_IN_USE, "A transaction is currently being executed", func); return SQL_ERROR; } CC_Destructor(conn); MYLOG(0, "leaving...\n"); return SQL_SUCCESS; } /* * IMPLEMENTATION CONNECTION CLASS */ static void reset_current_schema(ConnectionClass *self) { if (self->current_schema) { free(self->current_schema); self->current_schema = NULL; } self->current_schema_valid = FALSE; } static ConnectionClass * CC_alloc(void) { return (ConnectionClass *) calloc(sizeof(ConnectionClass), 1); } static void CC_lockinit(ConnectionClass *self) { INIT_CONNLOCK(self); INIT_CONN_CS(self); } static ConnectionClass * CC_initialize(ConnectionClass *rv, BOOL lockinit) { size_t clear_size; #if defined(WIN_MULTITHREAD_SUPPORT) || defined(POSIX_THREADMUTEX_SUPPORT) clear_size = (char *)&(rv->cs) - (char *)rv; #else clear_size = sizeof(ConnectionClass); #endif /* WIN_MULTITHREAD_SUPPORT */ memset(rv, 0, clear_size); rv->status = CONN_NOT_CONNECTED; rv->transact_status = CONN_IN_AUTOCOMMIT; /* autocommit by default */ rv->unnamed_prepared_stmt = NULL; rv->stmts = (StatementClass **) malloc(sizeof(StatementClass *) * STMT_INCREMENT); if (!rv->stmts) goto cleanup; memset(rv->stmts, 0, sizeof(StatementClass *) * STMT_INCREMENT); rv->num_stmts = STMT_INCREMENT; rv->descs = (DescriptorClass **) malloc(sizeof(DescriptorClass *) * STMT_INCREMENT); if (!rv->descs) goto cleanup; memset(rv->descs, 0, sizeof(DescriptorClass *) * STMT_INCREMENT); rv->num_descs = STMT_INCREMENT; rv->lobj_type = PG_TYPE_LO_UNDEFINED; if (isMsAccess()) rv->ms_jet = 1; rv->isolation = 0; // means initially unknown server's default isolation rv->mb_maxbyte_per_char = 1; rv->max_identifier_length = -1; rv->autocommit_public = SQL_AUTOCOMMIT_ON; /* Initialize statement options to defaults */ /* Statements under this conn will inherit these options */ InitializeStatementOptions(&rv->stmtOptions); InitializeARDFields(&rv->ardOptions); InitializeAPDFields(&rv->apdOptions); #ifdef _HANDLE_ENLIST_IN_DTC_ rv->asdum = NULL; rv->gTranInfo = 0; #endif /* _HANDLE_ENLIST_IN_DTC_ */ if (lockinit) CC_lockinit(rv); return rv; cleanup: CC_Destructor(rv); return NULL; } ConnectionClass * CC_Constructor() { ConnectionClass *rv, *retrv = NULL; if (rv = CC_alloc(), NULL != rv) retrv = CC_initialize(rv, TRUE); return retrv; } char CC_Destructor(ConnectionClass *self) { MYLOG(0, "entering self=%p\n", self); if (self->status == CONN_EXECUTING) return 0; CC_cleanup(self, FALSE); /* cleanup socket and statements */ MYLOG(0, "after CC_Cleanup\n"); /* Free up statement holders */ if (self->stmts) { free(self->stmts); self->stmts = NULL; } if (self->descs) { free(self->descs); self->descs = NULL; } MYLOG(0, "after free statement holders\n"); NULL_THE_NAME(self->schemaIns); NULL_THE_NAME(self->tableIns); CC_conninfo_release(&self->connInfo); if (self->__error_message) free(self->__error_message); DELETE_CONN_CS(self); DELETE_CONNLOCK(self); free(self); MYLOG(0, "leaving\n"); return 1; } /* Return how many cursors are opened on this connection */ int CC_cursor_count(ConnectionClass *self) { StatementClass *stmt; int i, count = 0; QResultClass *res; MYLOG(0, "self=%p, num_stmts=%d\n", self, self->num_stmts); CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { stmt = self->stmts[i]; if (stmt && (res = SC_get_Result(stmt)) && QR_get_cursor(res)) count++; } CONNLOCK_RELEASE(self); MYLOG(0, "leaving %d\n", count); return count; } void CC_clear_error(ConnectionClass *self) { if (!self) return; CONNLOCK_ACQUIRE(self); self->__error_number = 0; if (self->__error_message) { free(self->__error_message); self->__error_message = NULL; } self->sqlstate[0] = '\0'; CONNLOCK_RELEASE(self); } void CC_examine_global_transaction(ConnectionClass *self) { if (!self) return; #ifdef _HANDLE_ENLIST_IN_DTC_ if (CC_is_in_global_trans(self)) CALL_IsolateDtcConn(self, TRUE); #endif /* _HANDLE_ENLIST_IN_DTC_ */ } CSTR bgncmd = "BEGIN"; CSTR cmtcmd = "COMMIT"; CSTR rbkcmd = "ROLLBACK"; CSTR svpcmd = "SAVEPOINT"; CSTR per_query_svp = "_per_query_svp_"; CSTR rlscmd = "RELEASE"; /* * Used to begin a transaction. */ char CC_begin(ConnectionClass *self) { char ret = TRUE; if (!CC_is_in_trans(self)) { QResultClass *res = CC_send_query(self, bgncmd, NULL, 0, NULL); MYLOG(0, " sending BEGIN!\n"); ret = QR_command_maybe_successful(res); QR_Destructor(res); } return ret; } /* * Used to commit a transaction. * We are almost always in the middle of a transaction. */ char CC_commit(ConnectionClass *self) { char ret = TRUE; if (CC_is_in_trans(self)) { if (!CC_is_in_error_trans(self)) CC_close_eof_cursors(self); if (CC_is_in_trans(self)) { QResultClass *res = CC_send_query(self, cmtcmd, NULL, 0, NULL); MYLOG(0, " sending COMMIT!\n"); ret = QR_command_maybe_successful(res); QR_Destructor(res); } } return ret; } /* * Used to cancel a transaction. * We are almost always in the middle of a transaction. */ char CC_abort(ConnectionClass *self) { char ret = TRUE; if (CC_is_in_trans(self)) { QResultClass *res = CC_send_query(self, rbkcmd, NULL, 0, NULL); MYLOG(0, " sending ABORT!\n"); ret = QR_command_maybe_successful(res); QR_Destructor(res); } return ret; } /* This is called by SQLSetConnectOption etc also */ char CC_set_autocommit(ConnectionClass *self, BOOL on) { BOOL currsts = CC_is_in_autocommit(self); if ((on && currsts) || (!on && !currsts)) return on; MYLOG(0, " %d->%d\n", currsts, on); if (CC_is_in_trans(self)) CC_commit(self); if (on) self->transact_status |= CONN_IN_AUTOCOMMIT; else self->transact_status &= ~CONN_IN_AUTOCOMMIT; return on; } /* Clear cached table info */ static void CC_clear_col_info(ConnectionClass *self, BOOL destroy) { if (self->col_info) { int i; COL_INFO *coli; for (i = 0; i < self->ntables; i++) { /* Going through COL_INFO cache table and releasing coli objects. */ if (coli = self->col_info[i], NULL != coli) { coli->refcnt--; if (coli->refcnt <= 0) { /* Last reference to coli object disappeared. Now destroying it. */ free_col_info_contents(coli); free(coli); self->col_info[i] = NULL; } else { /* coli object have another reference to it, so it will be destroyed somewhere else. */ coli->acc_time = 0; } } } self->ntables = 0; /* Now we have cleared COL_INFO cached objects table. */ if (destroy) { /* We destroying COL_INFO cache completely. */ free(self->col_info); self->col_info = NULL; self->coli_allocated = 0; } } } static void CC_set_locale_encoding(ConnectionClass *self, const char * encoding) { char *currenc = self->locale_encoding; if (encoding) self->locale_encoding = strdup(encoding); else self->locale_encoding = NULL; if (currenc) free(currenc); } static void CC_determine_locale_encoding(ConnectionClass *self) { const char *dbencoding = PQparameterStatus(self->pqconn, "client_encoding"); const char *encoding; QLOG(0, "PQparameterStatus(%p, \"client_encoding\")=%s\n", self->pqconn, SAFE_STR(dbencoding)); if (self->locale_encoding) /* already set */ return; encoding = derive_locale_encoding(dbencoding); if (!encoding) encoding = "SQL_ASCII"; CC_set_locale_encoding(self, encoding); } static void CC_set_client_encoding(ConnectionClass *self, const char * encoding) { char *currenc = self->original_client_encoding; if (encoding) { self->original_client_encoding = strdup(encoding); self->ccsc = pg_CS_code(encoding); } else { self->original_client_encoding = NULL; self->ccsc = SQL_ASCII; } self->mb_maxbyte_per_char = pg_mb_maxlen(self->ccsc); if (currenc) free(currenc); } int CC_send_client_encoding(ConnectionClass *self, const char * encoding) { const char *dbencoding = PQparameterStatus(self->pqconn, "client_encoding"); if (encoding && (!dbencoding || stricmp(encoding, dbencoding))) { char query[64]; QResultClass *res; BOOL cmd_success; SPRINTF_FIXED(query, "set client_encoding to '%s'", encoding); res = CC_send_query(self, query, NULL, 0, NULL); cmd_success = QR_command_maybe_successful(res); QR_Destructor(res); if (!cmd_success) return SQL_ERROR; } CC_set_client_encoding(self, encoding); return SQL_SUCCESS; } /* This is called by SQLDisconnect also */ char CC_cleanup(ConnectionClass *self, BOOL keepCommunication) { int i; StatementClass *stmt; DescriptorClass *desc; if (self->status == CONN_EXECUTING) return FALSE; MYLOG(0, "entering self=%p\n", self); ENTER_CONN_CS(self); /* Cancel an ongoing transaction */ /* We are always in the middle of a transaction, */ /* even if we are in auto commit. */ if (self->pqconn) { QLOG(0, "PQfinish: %p\n", self->pqconn); PQfinish(self->pqconn); self->pqconn = NULL; } MYLOG(0, "after PQfinish\n"); /* Free all the stmts on this connection */ for (i = 0; i < self->num_stmts; i++) { stmt = self->stmts[i]; if (stmt) { stmt->hdbc = NULL; /* prevent any more dbase interactions */ SC_Destructor(stmt); self->stmts[i] = NULL; } } /* Free all the descs on this connection */ for (i = 0; i < self->num_descs; i++) { desc = self->descs[i]; if (desc) { DC_get_conn(desc) = NULL; /* prevent any more dbase interactions */ DC_Destructor(desc); free(desc); self->descs[i] = NULL; } } /* Check for translation dll */ #ifdef WIN32 if (!keepCommunication && self->translation_handle) { FreeLibrary(self->translation_handle); self->translation_handle = NULL; } #endif if (!keepCommunication) { self->status = CONN_NOT_CONNECTED; self->transact_status = CONN_IN_AUTOCOMMIT; self->unnamed_prepared_stmt = NULL; } if (!keepCommunication) { CC_conninfo_init(&(self->connInfo), CLEANUP_FOR_REUSE); if (self->original_client_encoding) { free(self->original_client_encoding); self->original_client_encoding = NULL; } if (self->locale_encoding) { free(self->locale_encoding); self->locale_encoding = NULL; } if (self->server_encoding) { free(self->server_encoding); self->server_encoding = NULL; } reset_current_schema(self); } /* Free cached table info */ CC_clear_col_info(self, TRUE); if (self->num_discardp > 0 && self->discardp) { for (i = 0; i < self->num_discardp; i++) free(self->discardp[i]); self->num_discardp = 0; } if (self->discardp) { free(self->discardp); self->discardp = NULL; } LEAVE_CONN_CS(self); MYLOG(0, "leaving\n"); return TRUE; } int CC_set_translation(ConnectionClass *self) { #ifdef WIN32 CSTR func = "CC_set_translation"; if (self->translation_handle != NULL) { FreeLibrary(self->translation_handle); self->translation_handle = NULL; } if (self->connInfo.translation_dll[0] == 0) return TRUE; self->translation_option = atoi(self->connInfo.translation_option); self->translation_handle = LoadLibrary(self->connInfo.translation_dll); if (self->translation_handle == NULL) { CC_set_error(self, CONN_UNABLE_TO_LOAD_DLL, "Could not load the translation DLL.", func); return FALSE; } self->DataSourceToDriver = (DataSourceToDriverProc) GetProcAddress(self->translation_handle, "SQLDataSourceToDriver"); self->DriverToDataSource = (DriverToDataSourceProc) GetProcAddress(self->translation_handle, "SQLDriverToDataSource"); if (self->DataSourceToDriver == NULL || self->DriverToDataSource == NULL) { CC_set_error(self, CONN_UNABLE_TO_LOAD_DLL, "Could not find translation DLL functions.", func); return FALSE; } #endif return TRUE; } #ifndef PG_DIAG_SEVERITY_NONLOCALIZED #define PG_DIAG_SEVERITY_NONLOCALIZED 'V' #endif void handle_pgres_error(ConnectionClass *self, const PGresult *pgres, const char *comment, QResultClass *res, BOOL error_not_a_notice) { char *errseverity; char *errseverity_nonloc = NULL; char *errprimary = NULL; char *errdetail = NULL; char *errhint = NULL; char *errstatementposition = NULL; char *errinternalquery = NULL; char *errcontext = NULL; char *errschemaname = NULL; char *errtablename = NULL; char *errcolumnname = NULL; char *errdatatypename = NULL; char *errmsg = NULL; char *sqlstate = NULL; int level = MIN_LOG_LEVEL; int display_error_level = (self->connInfo).optional_errors ? 3 : 1; PQExpBufferData errbuf = {0}; MYLOG(DETAIL_LOG_LEVEL, "entering\n"); sqlstate = PQresultErrorField(pgres, PG_DIAG_SQLSTATE); if (res && pgres) { if (sqlstate) STRCPY_FIXED(res->sqlstate, sqlstate); } if (NULL == pgres && NULL == self->pqconn) { const char *errmsg = "The connection has been lost"; MYLOG(0, "setting error message=%s\n", errmsg); QLOG(0, "\t%ssetting error message=%s\n", __FUNCTION__, errmsg); if (CC_get_errornumber(self) <= 0) CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, errmsg, comment); if (res) { QR_set_rstatus(res, PORES_FATAL_ERROR); QR_set_message(res, errmsg); } goto cleanup; } /* * The full message with details and context and everything could * be obtained with PQresultErrorMessage(). I think that would be * more user-friendly, but for now, construct a message with * severity and primary message, which is backwards compatible. */ errseverity = PQresultErrorField(pgres, PG_DIAG_SEVERITY); if (PG_VERSION_GE(self, 9.6)) { errseverity_nonloc = PQresultErrorField(pgres, PG_DIAG_SEVERITY_NONLOCALIZED); MYLOG(0, "PG_DIAG_SEVERITY_NONLOCALIZED=%s\n", SAFE_STR(errseverity_nonloc)); } if (!error_not_a_notice) { if (errseverity_nonloc) { if (stricmp(errseverity_nonloc, "NOTICE") != 0) level = 1; } else if (errseverity) { if (stricmp(errseverity, "NOTICE") != 0) level = 1; } } errprimary = PQresultErrorField(pgres, PG_DIAG_MESSAGE_PRIMARY); if (errseverity_nonloc) QLOG(level, "\t%s(%s) %s '%s'\n", errseverity_nonloc, SAFE_STR(errseverity), SAFE_STR(sqlstate), SAFE_STR(errprimary)); else QLOG(level, "\t(%s) %s '%s'\n", SAFE_STR(errseverity), SAFE_STR(sqlstate), SAFE_STR(errprimary)); if (errprimary == NULL) { /* Hmm. got no primary message. Check if there's a connection error */ if (self->pqconn) errprimary = PQerrorMessage(self->pqconn); if (errprimary == NULL) errprimary = "no error information"; } else if (display_error_level > 0) { errdetail = PQresultErrorField(pgres, PG_DIAG_MESSAGE_DETAIL); errhint = PQresultErrorField(pgres, PG_DIAG_MESSAGE_HINT); errstatementposition = PQresultErrorField(pgres, PG_DIAG_STATEMENT_POSITION); errinternalquery = PQresultErrorField(pgres, PG_DIAG_INTERNAL_POSITION); errcontext = PQresultErrorField(pgres, PG_DIAG_CONTEXT); errschemaname = PQresultErrorField(pgres, PG_DIAG_SCHEMA_NAME); errtablename = PQresultErrorField(pgres, PG_DIAG_TABLE_NAME); errcolumnname = PQresultErrorField(pgres, PG_DIAG_COLUMN_NAME); errdatatypename = PQresultErrorField(pgres, PG_DIAG_DATATYPE_NAME); } initPQExpBuffer(&errbuf); if (errseverity && errprimary) { printfPQExpBuffer(&errbuf, "%s: %s", errseverity, errprimary); if (display_error_level > 0 && errdetail) appendPQExpBuffer(&errbuf, "\nDETAIL: %s", errdetail); if (display_error_level > 1) { if (errhint) appendPQExpBuffer(&errbuf, "\nHINT: %s", errhint); } if (display_error_level > 2) { if (errstatementposition) appendPQExpBuffer(&errbuf, "\nSTATEMENT_POSITION: %s", errstatementposition); if (errinternalquery) appendPQExpBuffer(&errbuf, "\nINTERNAL_QUERY: %s", errinternalquery); if (errcontext) appendPQExpBuffer(&errbuf, "\nCONTEXT: %s", errcontext); if (errschemaname) appendPQExpBuffer(&errbuf, "\nSCHEMA_NAME: %s", errschemaname); if (errtablename) appendPQExpBuffer(&errbuf, "\nTABLE_NAME: %s", errtablename); if (errcolumnname) appendPQExpBuffer(&errbuf, "\nCOLUMN_NAME: %s", errcolumnname); if (errdatatypename) appendPQExpBuffer(&errbuf, "\nDATATYPE_NAME :%s", errdatatypename); } errmsg = errbuf.data; } if (errmsg == NULL) errmsg = errprimary; if (!error_not_a_notice) /* warning, notice, log etc */ { MYLOG(0, "notice message %s\n", errmsg); if (res) { if (QR_command_successful(res)) QR_set_rstatus(res, PORES_NONFATAL_ERROR); /* notice or warning */ QR_add_notice(res, errmsg); /* will dup this string */ } goto cleanup; } MYLOG(0, "error message=%s(" FORMAT_SIZE_T ")\n", errmsg, strlen(errmsg)); if (res) { QR_set_rstatus(res, PORES_FATAL_ERROR); /* error or fatal */ if (errmsg[0]) QR_set_message(res, errmsg); QR_set_aborted(res, TRUE); } /* * If the error is continuable after rollback? */ if (PQstatus(self->pqconn) == CONNECTION_BAD) { CC_set_errornumber(self, CONNECTION_COMMUNICATION_ERROR); CC_on_abort(self, CONN_DEAD); /* give up the connection */ } else if ((errseverity_nonloc && strcmp(errseverity_nonloc, "FATAL") == 0) || (NULL == errseverity_nonloc && errseverity && strcmp(errseverity, "FATAL") == 0)) /* no */ { CC_set_errornumber(self, CONNECTION_SERVER_REPORTED_SEVERITY_FATAL); CC_on_abort(self, CONN_DEAD); /* give up the connection */ } else /* yes */ { CC_set_errornumber(self, CONNECTION_SERVER_REPORTED_SEVERITY_ERROR); if (CC_is_in_trans(self)) CC_set_in_error_trans(self); } cleanup: if (!PQExpBufferDataBroken(errbuf)) termPQExpBuffer(&errbuf); LIBPQ_update_transaction_status(self); } void receive_libpq_notice(void *arg, const PGresult *pgres) { if (arg != NULL) { notice_receiver_arg *nrarg = (notice_receiver_arg *) arg; if (NULL != nrarg->stmt) nrarg->stmt->has_notice = 1; handle_pgres_error(nrarg->conn, pgres, nrarg->comment, nrarg->res, FALSE); } } static char CC_initial_log(ConnectionClass *self, const char *func) { const ConnInfo *ci = &self->connInfo; char *encoding, vermsg[128]; snprintf(vermsg, sizeof(vermsg), "Driver Version='%s,%s'" #ifdef WIN32 " linking %d" #ifdef _MT #ifdef _DLL " dynamic" #else " static" #endif /* _DLL */ " Multithread" #else " Singlethread" #endif /* _MT */ #ifdef _DEBUG " Debug" #endif /* DEBUG */ " library" #endif /* WIN32 */ "\n", POSTGRESDRIVERVERSION, __DATE__ #ifdef _MSC_VER , _MSC_VER #endif /* _MSC_VER */ ); QLOG(0, "%s", vermsg); MYLOG(DETAIL_LOG_LEVEL, "Global Options: fetch=%d, unknown_sizes=%d, max_varchar_size=%d, max_longvarchar_size=%d\n", ci->drivers.fetch_max, ci->drivers.unknown_sizes, ci->drivers.max_varchar_size, ci->drivers.max_longvarchar_size); MYLOG(DETAIL_LOG_LEVEL, " unique_index=%d, use_declarefetch=%d\n", ci->drivers.unique_index, ci->drivers.use_declarefetch); MYLOG(DETAIL_LOG_LEVEL, " text_as_longvarchar=%d, unknowns_as_longvarchar=%d, bools_as_char=%d NAMEDATALEN=%d\n", ci->drivers.text_as_longvarchar, ci->drivers.unknowns_as_longvarchar, ci->drivers.bools_as_char, TABLE_NAME_STORAGE_LEN); if (NULL == self->locale_encoding) { encoding = check_client_encoding(ci->conn_settings); CC_set_locale_encoding(self, encoding); MYLOG(DETAIL_LOG_LEVEL, " extra_systable_prefixes='%s', conn_settings='%s' conn_encoding='%s'\n", ci->drivers.extra_systable_prefixes, PRINT_NAME(ci->conn_settings), encoding ? encoding : ""); } if (self->status == CONN_DOWN) { CC_set_error_if_not_set(self, CONN_OPENDB_ERROR, "Connection broken.", func); return 0; } else if (self->status != CONN_NOT_CONNECTED) { CC_set_error_if_not_set(self, CONN_OPENDB_ERROR, "Already connected.", func); return 0; } MYLOG(0, "DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->username, NAME_IS_VALID(ci->password) ? "xxxxx" : ""); return 1; } 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) { int ret; CSTR func = "LIBPQ_CC_connect"; QResultClass *res; MYLOG(0, "entering...\n"); if (0 == CC_initial_log(self, func)) return 0; if (ret = LIBPQ_connect(self), ret <= 0) return ret; res = CC_send_query(self, "SET DateStyle = 'ISO';SET extra_float_digits = 2;" ISOLATION_SHOW_QUERY, NULL, READ_ONLY_QUERY, NULL); if (QR_command_maybe_successful(res)) { handle_show_results(res); ret = 1; } else ret = 0; QR_Destructor(res); return ret; } char CC_connect(ConnectionClass *self, char *salt_para) { ConnInfo *ci = &(self->connInfo); CSTR func = "CC_connect"; char ret, *saverr = NULL, retsend; const char *errmsg = NULL; MYLOG(0, "entering...sslmode=%s\n", self->connInfo.sslmode); ret = LIBPQ_CC_connect(self, salt_para); if (ret <= 0) return ret; CC_set_translation(self); /* * Send any initial settings */ /* * Since these functions allocate statements, and since the connection * is not established yet, it would violate odbc state transition * rules. Therefore, these functions call the corresponding local * function instead. */ /* Per Datasource settings */ retsend = CC_send_settings(self, GET_NAME(self->connInfo.conn_settings)); if (CONN_DOWN == self->status) { ret = 0; goto cleanup; } if (CC_get_errornumber(self) > 0 && NULL != (errmsg = CC_get_errormsg(self))) saverr = strdup(errmsg); CC_clear_error(self); /* clear any error */ if (!SQL_SUCCEEDED(CC_lookup_lo(self))) /* a hack to get the oid of our large object oid type */ { ret = 0; goto cleanup; } /* * Multibyte handling * * Send 'UTF8' when required Unicode behavior, otherwise send * locale encodings. */ CC_clear_error(self); CC_determine_locale_encoding(self); /* determine the locale_encoding */ #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(self)) { if (!SQL_SUCCEEDED(CC_send_client_encoding(self, "UTF8"))) { ret = 0; goto cleanup; } } else /* for unicode drivers require ANSI behavior */ #endif /* UNICODE_SUPPORT */ { if (!SQL_SUCCEEDED(CC_send_client_encoding(self, self->locale_encoding))) { ret = 0; goto cleanup; } } CC_clear_error(self); if (self->server_isolation != self->isolation) if (!CC_set_transact(self, self->isolation)) { ret = 0; goto cleanup; } ci_updatable_cursors_set(ci); if (CC_get_errornumber(self) > 0) CC_clear_error(self); /* clear any initial command errors */ self->status = CONN_CONNECTED; if (CC_is_in_unicode_driver(self) && (CC_is_in_ansi_app(self) || 0 < ci->bde_environment)) self->unicode |= CONN_DISALLOW_WCHAR; MYLOG(0, "conn->unicode=%d Client Encoding='%s' (Code %d)\n", self->unicode, self->original_client_encoding, self->ccsc); ret = 1; cleanup: MYLOG(0, "leaving...%d\n", ret); if (NULL != saverr) { if (ret > 0 && CC_get_errornumber(self) <= 0) CC_set_error(self, -1, saverr, func); free(saverr); } if (1 == ret && FALSE == retsend) ret = 2; return ret; } char CC_add_statement(ConnectionClass *self, StatementClass *stmt) { int i; char ret = TRUE; MYLOG(0, "self=%p, stmt=%p\n", self, stmt); CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { if (!self->stmts[i]) { stmt->hdbc = self; self->stmts[i] = stmt; break; } } if (i >= self->num_stmts) /* no more room -- allocate more memory */ { StatementClass **newstmts; Int2 new_num_stmts; new_num_stmts = STMT_INCREMENT + self->num_stmts; if (new_num_stmts > 0) newstmts = (StatementClass **) realloc(self->stmts, sizeof(StatementClass *) * new_num_stmts); else newstmts = NULL; /* num_stmts overflowed */ if (!newstmts) ret = FALSE; else { self->stmts = newstmts; memset(&self->stmts[self->num_stmts], 0, sizeof(StatementClass *) * STMT_INCREMENT); stmt->hdbc = self; self->stmts[self->num_stmts] = stmt; self->num_stmts = new_num_stmts; } } CONNLOCK_RELEASE(self); return ret; } static void CC_set_error_statements(ConnectionClass *self) { int i; MYLOG(0, "entering self=%p\n", self); for (i = 0; i < self->num_stmts; i++) { if (NULL != self->stmts[i]) SC_ref_CC_error(self->stmts[i]); } } char CC_remove_statement(ConnectionClass *self, StatementClass *stmt) { int i; char ret = FALSE; CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { if (self->stmts[i] == stmt && stmt->status != STMT_EXECUTING) { self->stmts[i] = NULL; ret = TRUE; break; } } CONNLOCK_RELEASE(self); return ret; } char CC_get_escape(const ConnectionClass *self) { const char *scf; static const ConnectionClass *conn = NULL; scf = PQparameterStatus(self->pqconn, "standard_conforming_strings"); if (self != conn) { QLOG(0, "PQparameterStatus(%p, \"standard_conforming_strings\")=%s\n", self->pqconn, SAFE_STR(scf)); conn = self; } if (scf == NULL) { /* we're connected to a pre-8.1 server, and E'' is not supported */ return '\0'; } if (strcmp(scf, "on") != 0) return ESCAPE_IN_LITERAL; else return '\0'; } int CC_get_max_idlen(ConnectionClass *self) { int len = self->max_identifier_length; if (len < 0) { QResultClass *res; res = CC_send_query(self, "show max_identifier_length", NULL, READ_ONLY_QUERY, NULL); if (QR_command_maybe_successful(res)) len = self->max_identifier_length = QR_get_value_backend_int(res, 0, 0, FALSE); QR_Destructor(res); } MYLOG(0, "max_identifier_length=%d\n", len); return len < 0 ? 0 : len; } static SQLINTEGER isolation_str_to_enum(const char *str_isolation) { SQLINTEGER isolation = 0; if (strnicmp(str_isolation, "seri", 4) == 0) isolation = SQL_TXN_SERIALIZABLE; else if (strnicmp(str_isolation, "repe", 4) == 0) isolation = SQL_TXN_REPEATABLE_READ; else if (strnicmp(str_isolation, "read com", 8) == 0) isolation = SQL_TXN_READ_COMMITTED; else if (strnicmp(str_isolation, "read unc", 8) == 0) isolation = SQL_TXN_READ_UNCOMMITTED; return isolation; } static int handle_show_results(const QResultClass *res) { int count = 0; const QResultClass *qres; ConnectionClass *conn = QR_get_conn(res); for (qres = res; qres; qres = QR_nextr(qres)) { if (!qres->command || stricmp(qres->command, "SHOW") != 0) continue; if (strcmp(QR_get_fieldname(qres, 0), TRANSACTION_ISOLATION) == 0) { conn->server_isolation = isolation_str_to_enum(QR_get_value_backend_text(qres, 0, 0)); MYLOG(0, "isolation " FORMAT_UINTEGER " to be " FORMAT_UINTEGER "\n", conn->server_isolation, conn->isolation); if (0 == conn->isolation) conn->isolation = conn->server_isolation; if (0 == conn->default_isolation) conn->default_isolation = conn->server_isolation; count++; } } return count; } /* * This function may not be called as long as ISOLATION_SHOW_QUERY is * issued in LIBPQ_CC_connect. */ SQLUINTEGER CC_get_isolation(ConnectionClass *self) { SQLUINTEGER isolation = 0; QResultClass *res; res = CC_send_query(self, ISOLATION_SHOW_QUERY, NULL, READ_ONLY_QUERY, NULL); if (QR_command_maybe_successful(res)) { handle_show_results(res); isolation = self->server_isolation; } QR_Destructor(res); MYLOG(0, "isolation=" FORMAT_UINTEGER "\n", isolation); return isolation; } void CC_set_error(ConnectionClass *self, int number, const char *message, const char *func) { CONNLOCK_ACQUIRE(self); if (self->__error_message) free(self->__error_message); self->__error_number = number; self->__error_message = message ? strdup(message) : NULL; if (0 != number) CC_set_error_statements(self); if (func && number != 0) CC_log_error(func, "", self); CONNLOCK_RELEASE(self); } void CC_set_errormsg(ConnectionClass *self, const char *message) { CONNLOCK_ACQUIRE(self); if (self->__error_message) free(self->__error_message); self->__error_message = message ? strdup(message) : NULL; CONNLOCK_RELEASE(self); } char CC_get_error(ConnectionClass *self, int *number, char **message) { int rv; MYLOG(0, "entering\n"); CONNLOCK_ACQUIRE(self); if (CC_get_errornumber(self)) { *number = CC_get_errornumber(self); *message = CC_get_errormsg(self); } rv = (CC_get_errornumber(self) != 0); CONNLOCK_RELEASE(self); MYLOG(0, "leaving\n"); return rv; } static int CC_close_eof_cursors(ConnectionClass *self) { int i, ccount = 0; StatementClass *stmt; QResultClass *res; if (!self->ncursors) return ccount; CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { if (stmt = self->stmts[i], NULL == stmt) continue; if (res = SC_get_Result(stmt), NULL == res) continue; if (NULL != QR_get_cursor(res) && QR_is_withhold(res) && QR_once_reached_eof(res)) { if (QR_get_num_cached_tuples(res) >= QR_get_num_total_tuples(res) || SQL_CURSOR_FORWARD_ONLY == stmt->options.cursor_type) { QR_close(res); ccount++; } } } CONNLOCK_RELEASE(self); return ccount; } static void CC_clear_cursors(ConnectionClass *self, BOOL on_abort) { int i; StatementClass *stmt; QResultClass *res; if (!self->ncursors) return; CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { stmt = self->stmts[i]; if (stmt && (res = SC_get_Result(stmt)) && (NULL != QR_get_cursor(res))) { /* * non-holdable cursors are automatically closed * at commit time. * all non-permanent cursors are automatically closed * at rollback time. */ if ((on_abort && !QR_is_permanent(res)) || !QR_is_withhold(res)) { QR_on_close_cursor(res); } else if (!QR_is_permanent(res)) { QResultClass *wres; char cmd[64]; if (QR_needs_survival_check(res)) { SPRINTF_FIXED(cmd, "MOVE 0 in \"%s\"", QR_get_cursor(res)); CONNLOCK_RELEASE(self); wres = CC_send_query(self, cmd, NULL, ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN | READ_ONLY_QUERY, NULL); QR_set_no_survival_check(res); if (QR_command_maybe_successful(wres) && CONN_ERROR_IGNORED != CC_get_errornumber(self)) QR_set_permanent(res); else QR_set_cursor(res, NULL); QR_Destructor(wres); CONNLOCK_ACQUIRE(self); MYLOG(DETAIL_LOG_LEVEL, "%p->permanent -> %d %p\n", res, QR_is_permanent(res), QR_get_cursor(res)); } else QR_set_permanent(res); } } } CONNLOCK_RELEASE(self); } static void CC_mark_cursors_doubtful(ConnectionClass *self) { int i; StatementClass *stmt; QResultClass *res; if (!self->ncursors) return; CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) { stmt = self->stmts[i]; if (NULL != stmt && NULL != (res = SC_get_Result(stmt)) && NULL != QR_get_cursor(res) && !QR_is_permanent(res)) QR_set_survival_check(res); } CONNLOCK_RELEASE(self); } void CC_on_commit(ConnectionClass *conn) { if (conn->on_commit_in_progress) return; conn->on_commit_in_progress = 1; CONNLOCK_ACQUIRE(conn); if (CC_is_in_trans(conn)) { CC_set_no_trans(conn); CC_set_no_manual_trans(conn); } CC_svp_init(conn); CC_start_stmt(conn); CC_clear_cursors(conn, FALSE); CONNLOCK_RELEASE(conn); CC_discard_marked_objects(conn); CONNLOCK_ACQUIRE(conn); if (conn->result_uncommitted) { CONNLOCK_RELEASE(conn); ProcessRollback(conn, FALSE, FALSE); CONNLOCK_ACQUIRE(conn); conn->result_uncommitted = 0; } CONNLOCK_RELEASE(conn); conn->on_commit_in_progress = 0; } void CC_on_abort(ConnectionClass *conn, unsigned int opt) { BOOL set_no_trans = FALSE; MYLOG(0, "entering opt=%x\n", opt); CONNLOCK_ACQUIRE(conn); if (0 != (opt & CONN_DEAD)) /* CONN_DEAD implies NO_TRANS also */ opt |= NO_TRANS; if (CC_is_in_trans(conn)) { if (0 != (opt & NO_TRANS)) { CC_set_no_trans(conn); CC_set_no_manual_trans(conn); set_no_trans = TRUE; } } CC_svp_init(conn); CC_start_stmt(conn); CC_clear_cursors(conn, TRUE); if (0 != (opt & CONN_DEAD)) { conn->status = CONN_DOWN; if (conn->pqconn) { CONNLOCK_RELEASE(conn); QLOG(0, "PQfinish: %p\n", conn->pqconn); PQfinish(conn->pqconn); CONNLOCK_ACQUIRE(conn); conn->pqconn = NULL; } } else if (set_no_trans) { CONNLOCK_RELEASE(conn); CC_discard_marked_objects(conn); CONNLOCK_ACQUIRE(conn); } if (conn->result_uncommitted) { CONNLOCK_RELEASE(conn); ProcessRollback(conn, TRUE, FALSE); CONNLOCK_ACQUIRE(conn); conn->result_uncommitted = 0; } CONNLOCK_RELEASE(conn); } void CC_on_abort_partial(ConnectionClass *conn) { MYLOG(0, "entering\n"); CONNLOCK_ACQUIRE(conn); ProcessRollback(conn, TRUE, TRUE); CC_discard_marked_objects(conn); CONNLOCK_RELEASE(conn); } static BOOL is_setting_search_path(const char *query) { const char *q = query; if (strnicmp(q, "set", 3) != 0) return FALSE; q += 3; while (isspace(*q)) q++; for (; *q;) { if (IS_NOT_SPACE(*q)) { if (strnicmp(q, "search_path", 11) == 0) return TRUE; q++; while (IS_NOT_SPACE(*q)) q++; } else q++; } return FALSE; } static BOOL CC_from_PGresult(QResultClass *res, StatementClass *stmt, ConnectionClass *conn, const char *cursor, PGresult **pgres) { BOOL success = TRUE; if (!QR_from_PGresult(res, stmt, conn, cursor, pgres)) { QLOG(0, "\tGetting result from PGresult failed\n"); success = FALSE; if (0 >= CC_get_errornumber(conn)) { switch (QR_get_rstatus(res)) { case PORES_NO_MEMORY_ERROR: CC_set_error(conn, CONN_NO_MEMORY_ERROR, NULL, __FUNCTION__); break; case PORES_BAD_RESPONSE: CC_set_error(conn, CONNECTION_COMMUNICATION_ERROR, "communication error occurred", __FUNCTION__); break; default: CC_set_error(conn, CONN_EXEC_ERROR, QR_get_message(res), __FUNCTION__); break; } } } return success; } int CC_internal_rollback(ConnectionClass *self, int rollback_type, BOOL ignore_abort) { int ret = 0; char cmd[128]; PGresult *pgres = NULL; if (!CC_is_in_error_trans(self)) return 1; switch (rollback_type) { case PER_STATEMENT_ROLLBACK: GenerateSvpCommand(self, INTERNAL_ROLLBACK_OPERATION, cmd, sizeof(cmd)); QLOG(0, "PQexec: %p '%s'\n", self->pqconn, cmd); pgres = PQexec(self->pqconn, cmd); switch (PQresultStatus(pgres)) { case PGRES_COMMAND_OK: QLOG(0, "\tok: - 'C' - %s\n", PQcmdStatus(pgres)); case PGRES_NONFATAL_ERROR: ret = 1; if (ignore_abort) CC_set_no_error_trans(self); LIBPQ_update_transaction_status(self); break; default: handle_pgres_error(self, pgres, __FUNCTION__, NULL, TRUE); break; } break; case PER_QUERY_ROLLBACK: SPRINTF_FIXED(cmd, "%s TO %s;%s %s" , rbkcmd, per_query_svp , rlscmd, per_query_svp); QLOG(0, "PQsendQuery: %p '%s'\n", self->pqconn, cmd); PQsendQuery(self->pqconn, cmd); ret = 0; while (self->pqconn && (pgres = PQgetResult(self->pqconn)) != NULL) { switch (PQresultStatus(pgres)) { case PGRES_COMMAND_OK: QLOG(0, "\tok: - 'C' - %s\n", PQcmdTuples(pgres)); ret = 1; break; case PGRES_NONFATAL_ERROR: ret = 1; default: handle_pgres_error(self, pgres, __FUNCTION__, NULL, !ret); } } if (!ret) { if (ignore_abort) CC_set_no_error_trans(self); else MYLOG(0, " return error\n"); } LIBPQ_update_transaction_status(self); break; } if (pgres) PQclear(pgres); return ret; } /* * The "result_in" is only used by QR_next_tuple() to fetch another group of rows into * the same existing QResultClass (this occurs when the tuple cache is depleted and * needs to be re-filled). * * The "cursor" is used by SQLExecute to associate a statement handle as the cursor name * (i.e., C3326857) for SQL select statements. This cursor is then used in future * 'declare cursor C3326857 for ...' and 'fetch 100 in C3326857' statements. * * * If issue_begin, send "BEGIN" * * if needed, send "SAVEPOINT ..." * * Send "query", read result * * Send appendq, read result. * */ QResultHold CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UDWORD flag, StatementClass *stmt, const char *appendq) { CSTR func = "CC_send_query"; QResultHold rhold = {0}; QResultClass *cmdres = NULL, *retres = NULL, *res = NULL; BOOL ignore_abort_on_conn = ((flag & IGNORE_ABORT_ON_CONN) != 0), create_keyset = ((flag & CREATE_KEYSET) != 0), issue_begin = ((flag & GO_INTO_TRANSACTION) != 0 && !CC_is_in_trans(self)), rollback_on_error, query_rollback, end_with_commit, read_only, prepend_savepoint = FALSE, ignore_roundtrip_time = ((self->connInfo.extra_opts & BIT_IGNORE_ROUND_TRIP_TIME) != 0); char *ptr; BOOL ReadyToReturn = FALSE, query_completed = FALSE, aborted = FALSE, used_passed_result_object = FALSE, discard_next_begin = FALSE, discard_next_savepoint = FALSE, discard_next_release = FALSE, consider_rollback; BOOL discardTheRest = FALSE; int func_cs_count = 0; PQExpBufferData query_buf = {0}; size_t query_len; /* QR_set_command() dups this string so doesn't need static */ char *cmdbuffer; PGresult *pgres = NULL; notice_receiver_arg nrarg; if (appendq) { MYLOG(0, "conn=%p, query='%s'+'%s'\n", self, query, appendq); } else { MYLOG(0, "conn=%p, query='%s'\n", self, query); } if (!self->pqconn) { PQExpBufferData pbuf = {0}; initPQExpBuffer(&pbuf); appendPQExpBuffer(&pbuf, "The connection is down\nFailed to send '%s'", query); CC_set_error(self, CONNECTION_COULD_NOT_SEND, pbuf.data, func); termPQExpBuffer(&pbuf); return rhold; } ENTER_INNER_CONN_CS(self, func_cs_count); /* Indicate that we are sending a query to the backend */ if ((NULL == query) || (query[0] == '\0')) { CLEANUP_FUNC_CONN_CS(func_cs_count, self); return rhold; } /* * In case the round trip time can be ignored, the query * and the appended query would be issued separately. * Otherwise a multiple command query would be issued. */ if (appendq && ignore_roundtrip_time) { QResultHold rholda; rhold = CC_send_query_append(self, query, qi, flag, stmt, NULL); if (QR_command_maybe_successful(rhold.first)) { rholda = CC_send_query_append(self, appendq, qi, flag & (~(GO_INTO_TRANSACTION)), stmt, NULL); if (QR_command_maybe_successful(rholda.first)) QR_concat(rhold.last, rholda.first); else { QR_Destructor(rhold.first); rhold = rholda; } } CLEANUP_FUNC_CONN_CS(func_cs_count, self); return rhold; } rollback_on_error = (flag & ROLLBACK_ON_ERROR) != 0; end_with_commit = (flag & END_WITH_COMMIT) != 0; read_only = (flag & READ_ONLY_QUERY) != 0; #define return DONT_CALL_RETURN_FROM_HERE??? consider_rollback = (issue_begin || (CC_is_in_trans(self) && !CC_is_in_error_trans(self)) || strnicmp(query, "begin", 5) == 0); if (rollback_on_error) rollback_on_error = consider_rollback; query_rollback = (rollback_on_error && !end_with_commit && PG_VERSION_GE(self, 8.0)); if (!query_rollback && consider_rollback && !end_with_commit) { if (stmt) { StatementClass *astmt = SC_get_ancestor(stmt); unsigned int svpopt = 0; if (read_only) svpopt |= SVPOPT_RDONLY; if (!ignore_roundtrip_time) svpopt |= SVPOPT_REDUCE_ROUNDTRIP; if (!CC_started_rbpoint(self)) { if (SQL_ERROR == SetStatementSvp(astmt, svpopt)) { SC_set_error(stmt, STMT_INTERNAL_ERROR, "internal savepoint error", func); goto cleanup; } } } } /* prepend internal savepoint command ? */ if (PREPEND_IN_PROGRESS == self->internal_op) prepend_savepoint = TRUE; /* append all these together, to avoid round-trips */ query_len = strlen(query); MYLOG(0, "query_len=" FORMAT_SIZE_T "\n", query_len); initPQExpBuffer(&query_buf); /* issue_begin, query_rollback and prepend_savepoint are exclusive */ if (issue_begin) { appendPQExpBuffer(&query_buf, "%s;", bgncmd); discard_next_begin = TRUE; } else if (query_rollback) { appendPQExpBuffer(&query_buf, "%s %s;", svpcmd, per_query_svp); discard_next_savepoint = TRUE; } else if (prepend_savepoint) { char prepend_cmd[128]; GenerateSvpCommand(self, INTERNAL_SAVEPOINT_OPERATION, prepend_cmd, sizeof(prepend_cmd)); appendPQExpBuffer(&query_buf, "%s;", prepend_cmd); self->internal_op = SAVEPOINT_IN_PROGRESS; } appendPQExpBufferStr(&query_buf, query); if (appendq) { appendPQExpBuffer(&query_buf, ";%s", appendq); } if (query_rollback) { appendPQExpBuffer(&query_buf, ";%s %s", rlscmd, per_query_svp); } if (PQExpBufferDataBroken(query_buf)) { CC_set_error(self, CONN_NO_MEMORY_ERROR, "Couldn't alloc buffer for query.", ""); goto cleanup; } /* Set up notice receiver */ nrarg.conn = self; nrarg.comment = func; nrarg.res = NULL; nrarg.stmt = stmt; PQsetNoticeReceiver(self->pqconn, receive_libpq_notice, &nrarg); QLOG(0, "PQsendQuery: %p '%s'\n", self->pqconn, query_buf.data); if (!PQsendQuery(self->pqconn, query_buf.data)) { char *errmsg = PQerrorMessage(self->pqconn); QLOG(0, "\nCommunication Error: %s\n", SAFE_STR(errmsg)); CC_set_error(self, CONNECTION_COMMUNICATION_ERROR, errmsg, func); goto cleanup; } PQsetSingleRowMode(self->pqconn); cmdres = qi ? qi->result_in : NULL; if (cmdres) used_passed_result_object = TRUE; else { cmdres = QR_Constructor(); if (!cmdres) { CC_set_error(self, CONNECTION_COULD_NOT_RECEIVE, "Could not create result info in send_query.", func); goto cleanup; } } res = cmdres; if (qi) { res->cmd_fetch_size = qi->fetch_size; res->cache_size = qi->row_size; } nrarg.res = res; while (self->pqconn && (pgres = PQgetResult(self->pqconn)) != NULL) { int status = PQresultStatus(pgres); if (discardTheRest) continue; switch (status) { case PGRES_COMMAND_OK: /* portal query command, no tuples returned */ /* read in the return message from the backend */ cmdbuffer = PQcmdStatus(pgres); QLOG(0, "\tok: - 'C' - %s\n", cmdbuffer); if (query_completed) /* allow for "show" style notices */ { QR_concat(res, QR_Constructor()); if (!QR_nextr(res)) { CC_set_error(self, CONNECTION_COULD_NOT_RECEIVE, "Could not create result info in send_query.", func); ReadyToReturn = TRUE; retres = NULL; break; } res = QR_nextr(res); nrarg.res = res; } MYLOG(0, " setting cmdbuffer = '%s'\n", cmdbuffer); my_trim(cmdbuffer); /* get rid of trailing space */ if (strnicmp(cmdbuffer, bgncmd, strlen(bgncmd)) == 0) { CC_set_in_trans(self); if (discard_next_begin) /* discard the automatically issued BEGIN */ { discard_next_begin = FALSE; break; /* discard the result */ } } /* * There are 2 risks to RELEASE an internal savepoint. * One is to RELEASE the savepoint invalitated * due to manually issued ROLLBACK or RELEASE. * Another is to invalitate manual SAVEPOINTs unexpectedly * by RELEASing the internal savepoint. */ else if (strnicmp(cmdbuffer, svpcmd, strlen(svpcmd)) == 0) { if (discard_next_savepoint) { discard_next_savepoint = FALSE; discard_next_release = TRUE; MYLOG(DETAIL_LOG_LEVEL, "Discarded a SAVEPOINT result\n"); break; /* discard the result */ } if (SAVEPOINT_IN_PROGRESS == self->internal_op) { CC_start_rbpoint(self); self->internal_op = 0; break; /* discard the result */ } /* Don't release the internal savepoint */ self->internal_svp = 0; } else if (strnicmp(cmdbuffer, rbkcmd, strlen(rbkcmd)) == 0) { CC_mark_cursors_doubtful(self); CC_set_in_error_trans(self); /* mark the transaction error in case of manual rollback */ self->internal_svp = 0; /* possibly an internal savepoint is invalid */ self->opt_previous = 0; /* unknown */ CC_init_opt_in_progress(self); } else if (strnicmp(cmdbuffer, rlscmd, strlen(rlscmd)) == 0) { if (discard_next_release) { MYLOG(DETAIL_LOG_LEVEL, "Discarded a RELEASE result\n"); discard_next_release = FALSE; break; /* discard the result */ } self->internal_svp = 0; if (SAVEPOINT_IN_PROGRESS == self->internal_op) break; /* discard the result */ } /* * DROP TABLE or ALTER TABLE may change * the table definition. So clear the * col_info cache though it may be too simple. */ else if (strnicmp(cmdbuffer, "DROP TABLE", 10) == 0 || strnicmp(cmdbuffer, "ALTER TABLE", 11) == 0) CC_clear_col_info(self, FALSE); else { ptr = strrchr(cmdbuffer, ' '); if (ptr) res->recent_processed_row_count = atoi(ptr + 1); else res->recent_processed_row_count = -1; if (self->current_schema_valid && strnicmp(cmdbuffer, "SET", 3) == 0) { if (is_setting_search_path(query)) reset_current_schema(self); } } if (QR_command_successful(res)) QR_set_rstatus(res, PORES_COMMAND_OK); QR_set_command(res, cmdbuffer); query_completed = TRUE; MYLOG(0, " returning res = %p\n", res); break; case PGRES_EMPTY_QUERY: /* We return the empty query */ QR_set_rstatus(res, PORES_EMPTY_QUERY); break; case PGRES_NONFATAL_ERROR: handle_pgres_error(self, pgres, "send_query", res, FALSE); if (stmt) stmt->has_notice = 1; break; case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: handle_pgres_error(self, pgres, "send_query", res, TRUE); /* We should report that an error occurred. Zoltan */ aborted = TRUE; query_completed = TRUE; break; case PGRES_TUPLES_OK: QLOG(0, "\tok: - 'T' - %s\n", PQcmdStatus(pgres)); case PGRES_SINGLE_TUPLE: if (query_completed) { QR_concat(res, QR_Constructor()); if (!QR_nextr(res)) { CC_set_error(self, CONNECTION_COULD_NOT_RECEIVE, "Could not create result info in send_query.", func); ReadyToReturn = TRUE; retres = NULL; break; } if (create_keyset) { QR_set_haskeyset(QR_nextr(res)); if (stmt) { if (stmt->num_key_fields < 0) /* for safety */ CheckPgClassInfo(stmt); QR_nextr(res)->num_key_fields = stmt->num_key_fields; } } MYLOG(0, " 'T' no result_in: res = %p\n", QR_nextr(res)); res = QR_nextr(res); nrarg.res = res; if (qi) { QR_set_cache_size(res, qi->row_size); res->cmd_fetch_size = qi->fetch_size; } } if (!used_passed_result_object) { const char *cursor = qi ? qi->cursor : NULL; if (create_keyset) { QR_set_haskeyset(res); if (stmt) { if (stmt->num_key_fields < 0) /* for safety */ CheckPgClassInfo(stmt); res->num_key_fields = stmt->num_key_fields; } if (cursor && cursor[0]) QR_set_synchronize_keys(res); } if (CC_from_PGresult(res, stmt, self, cursor, &pgres)) query_completed = TRUE; else { aborted = TRUE; if (QR_command_maybe_successful(res)) retres = NULL; else retres = cmdres; } } else { /* next fetch, so reuse an existing result */ const char *cursor = res->cursor_name; /* * called from QR_next_tuple and must return * immediately. */ if (!CC_from_PGresult(res, stmt, NULL, cursor, &pgres)) { retres = NULL; break; } retres = cmdres; } if (res->rstatus == PORES_TUPLES_OK && res->notice) { QR_set_rstatus(res, PORES_NONFATAL_ERROR); } else if (PORES_NO_MEMORY_ERROR == QR_get_rstatus(res)) { PGcancel *cancel; char dummy[8]; discardTheRest = TRUE; if (NULL != (cancel = PQgetCancel(self->pqconn))) { PQcancel(cancel, dummy, sizeof(dummy)); PQfreeCancel(cancel); } else goto cleanup; } break; case PGRES_COPY_OUT: /* XXX: We used to read from stdin here. Does that make any sense? */ case PGRES_COPY_IN: if (query_completed) { QR_concat(res, QR_Constructor()); if (!QR_nextr(res)) { CC_set_error(self, CONNECTION_COULD_NOT_RECEIVE, "Could not create result info in send_query.", func); ReadyToReturn = TRUE; retres = NULL; break; } res = QR_nextr(res); nrarg.res = res; } QR_set_rstatus(res, PORES_COPY_IN); ReadyToReturn = TRUE; retres = cmdres; break; case PGRES_COPY_BOTH: default: /* skip the unexpected response if possible */ CC_set_error(self, CONNECTION_BACKEND_CRAZY, "Unexpected result status (send_query)", func); handle_pgres_error(self, pgres, "send_query", res, TRUE); CC_on_abort(self, CONN_DEAD); MYLOG(0, " error - %s\n", CC_get_errormsg(self)); ReadyToReturn = TRUE; retres = NULL; break; } if (pgres) { PQclear(pgres); pgres = NULL; } } cleanup: if (self->pqconn) PQsetNoticeReceiver(self->pqconn, receive_libpq_notice, NULL); if (pgres != NULL) { PQclear(pgres); pgres = NULL; } MYLOG(DETAIL_LOG_LEVEL, " rollback_on_error=%d CC_is_in_trans=%d discard_next_savepoint=%d query_rollback=%d\n", rollback_on_error, CC_is_in_trans(self), discard_next_savepoint, query_rollback); if (rollback_on_error && CC_is_in_trans(self) && !discard_next_savepoint) { if (query_rollback) { if (!CC_internal_rollback(self, PER_QUERY_ROLLBACK, ignore_abort_on_conn)) ignore_abort_on_conn = FALSE; } else if (CC_is_in_error_trans(self)) { QLOG(0, "PQexec: %p '%s'\n", self->pqconn, rbkcmd); pgres = PQexec(self->pqconn, rbkcmd); } /* * XXX: we don't check the result here. Should we? We're rolling back, * so it's not clear what else we can do on error. Giving an error * message to the application would be nice though. */ if (pgres != NULL) { PQclear(pgres); pgres = NULL; } } CLEANUP_FUNC_CONN_CS(func_cs_count, self); #undef return /* * Break before being ready to return. */ if (!ReadyToReturn) retres = cmdres; if (!PQExpBufferDataBroken(query_buf)) termPQExpBuffer(&query_buf); /* * Cleanup garbage results before returning. */ if (cmdres && retres != cmdres && !used_passed_result_object) QR_Destructor(cmdres); /* * Cleanup the aborted result if specified */ if (retres) { if (aborted) { /** if (ignore_abort_on_conn) { if (!used_passed_result_object) { QR_Destructor(retres); retres = NULL; } } **/ if (retres) { /* * discard results other than errors. */ QResultClass *qres; for (qres = retres; QR_nextr(qres); qres = retres) { if (QR_get_aborted(qres)) break; retres = QR_nextr(qres); QR_detach(qres); QR_Destructor(qres); } /* * If error message isn't set */ if (ignore_abort_on_conn) { CC_set_errornumber(self, CONN_ERROR_IGNORED); if (retres) QR_set_rstatus(retres, PORES_NONFATAL_ERROR); MYLOG(DETAIL_LOG_LEVEL, " ignored abort_on_conn\n"); } else if (retres) { if (NULL == CC_get_errormsg(self) || !CC_get_errormsg(self)[0]) CC_set_errormsg(self, QR_get_message(retres)); if (!self->sqlstate[0]) STRCPY_FIXED(self->sqlstate, retres->sqlstate); } } } } /* * Update our copy of the transaction status. * * XXX: Once we stop using the socket directly, and do everything with * libpq, we can get rid of the transaction_status field altogether * and always ask libpq for it. */ LIBPQ_update_transaction_status(self); if (retres) QR_set_conn(retres, self); rhold.first = retres; rhold.last = res; return rhold; } #define MAX_SEND_FUNC_ARGS 3 static const char *func_param_str[MAX_SEND_FUNC_ARGS + 1] = { "()", "($1)", "($1, $2)", "($1, $2, $3)" }; static Int8 odbc_hton64(Int8 h64) { union { Int8 n64; UInt4 i32[2]; } u; u.i32[0] = htonl((UInt4) (h64 >> 32)); u.i32[1] = htonl((UInt4) h64); return u.n64; } static Int8 odbc_ntoh64(Int8 n64) { union { Int8 h64; UInt4 i32[2]; } u; Int8 result; u.h64 = n64; result = ntohl(u.i32[0]); result <<= 32; result |= ntohl(u.i32[1]); return result; } int CC_send_function(ConnectionClass *self, const char *fn_name, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *args, int nargs) { int i; int ret = FALSE; int func_cs_count = 0; char sqlbuffer[1000]; PGresult *pgres = NULL; Oid paramTypes[MAX_SEND_FUNC_ARGS]; char *paramValues[MAX_SEND_FUNC_ARGS]; int paramLengths[MAX_SEND_FUNC_ARGS]; int paramFormats[MAX_SEND_FUNC_ARGS]; Int4 intParamBufs[MAX_SEND_FUNC_ARGS]; Int8 int8ParamBufs[MAX_SEND_FUNC_ARGS]; MYLOG(0, "conn=%p, fn_name=%s, result_is_int=%d, nargs=%d\n", self, fn_name, result_is_int, nargs); /* Finish the pending extended query first */ #define return DONT_CALL_RETURN_FROM_HERE??? ENTER_INNER_CONN_CS(self, func_cs_count); SPRINTF_FIXED(sqlbuffer, "SELECT pg_catalog.%s%s", fn_name, func_param_str[nargs]); for (i = 0; i < nargs; ++i) { MYLOG(0, " arg[%d]: len = %d, isint = %d, integer = " FORMATI64 ", ptr = %p\n", i, args[i].len, args[i].isint, args[i].isint == 2 ? args[i].u.integer64 : args[i].u.integer, args[i].u.ptr); /* integers are sent as binary, others as text */ if (args[i].isint == 2) { paramTypes[i] = PG_TYPE_INT8; int8ParamBufs[i] = odbc_hton64(args[i].u.integer64); paramValues[i] = (char *) &int8ParamBufs[i]; paramLengths[i] = 8; paramFormats[i] = 1; } else if (args[i].isint) { paramTypes[i] = PG_TYPE_INT4; intParamBufs[i] = htonl(args[i].u.integer); paramValues[i] = (char *) &intParamBufs[i]; paramLengths[i] = 4; paramFormats[i] = 1; } else { paramTypes[i] = 0; paramValues[i] = args[i].u.ptr; paramLengths[i] = args[i].len; paramFormats[i] = 1; } } QLOG(0, "PQexecParams: %p '%s' nargs=%d\n", self->pqconn, sqlbuffer, nargs); pgres = PQexecParams(self->pqconn, sqlbuffer, nargs, paramTypes, (const char * const *) paramValues, paramLengths, paramFormats, 1); MYLOG(0, "done sending function\n"); if (PQresultStatus(pgres) == PGRES_TUPLES_OK) QLOG(0, "\tok: - 'T' - %s\n", PQcmdStatus(pgres)); else { handle_pgres_error(self, pgres, "send_query", NULL, TRUE); goto cleanup; } if (PQnfields(pgres) != 1 || PQntuples(pgres) != 1) { CC_set_errormsg(self, "unexpected result set from large_object function"); goto cleanup; } *actual_result_len = PQgetlength(pgres, 0, 0); QLOG(0, "\tgot result with length: %d\n", *actual_result_len); if (*actual_result_len > 0) { char *value = PQgetvalue(pgres, 0, 0); if (result_is_int == 2) { Int8 int8val; memcpy(&int8val, value, sizeof(Int8)); int8val = odbc_ntoh64(int8val); memcpy(result_buf, &int8val, sizeof(Int8)); MYLOG(0, "int8 result=" FORMATI64 "\n", int8val); } else if (result_is_int) { Int4 int4val; memcpy(&int4val, value, sizeof(Int4)); int4val = ntohl(int4val); memcpy(result_buf, &int4val, sizeof(Int4)); } else memcpy(result_buf, value, *actual_result_len); } ret = TRUE; cleanup: #undef return CLEANUP_FUNC_CONN_CS(func_cs_count, self); if (pgres) PQclear(pgres); return ret; } char CC_send_settings(ConnectionClass *self, const char *set_query) { HSTMT hstmt; RETCODE result; char status = TRUE; char *cs, *ptr; #ifdef HAVE_STRTOK_R char *last; #endif /* HAVE_STRTOK_R */ CSTR func = "CC_send_settings"; MYLOG(0, "entering...\n"); if (set_query == NULL) return TRUE; /* * This function must use the local odbc API functions since the odbc state * has not transitioned to "connected" yet. */ result = PGAPI_AllocStmt(self, &hstmt, 0); if (!SQL_SUCCEEDED(result)) return FALSE; /* non-external handle ensures no BEGIN/COMMIT/ABORT stuff */ cs = strdup(set_query); if (cs == NULL) { CC_set_error(self, CONN_NO_MEMORY_ERROR, "Couldn't alloc buffer for query.", func); return FALSE; } #ifdef HAVE_STRTOK_R ptr = strtok_r(cs, ";", &last); #else ptr = strtok(cs, ";"); #endif /* HAVE_STRTOK_R */ while (ptr) { result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) ptr, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; MYLOG(0, "result %d, status %d from '%s'\n", result, status, ptr); #ifdef HAVE_STRTOK_R ptr = strtok_r(NULL, ";", &last); #else ptr = strtok(NULL, ";"); #endif /* HAVE_STRTOK_R */ } free(cs); PGAPI_FreeStmt(hstmt, SQL_DROP); return status; } /* * This function is just a hack to get the oid of our Large Object oid type. * If a real Large Object oid type is made part of Postgres, this function * will go away and the define 'PG_TYPE_LO' will be updated. */ static SQLRETURN CC_lookup_lo(ConnectionClass *self) { SQLRETURN ret = SQL_SUCCESS; QResultClass *res; MYLOG(0, "entering...\n"); res = CC_send_query(self, "select oid, typbasetype from pg_type where typname = '" PG_TYPE_LO_NAME "'", NULL, READ_ONLY_QUERY, NULL); if (!QR_command_maybe_successful(res)) ret = SQL_ERROR; else if (QR_command_maybe_successful(res) && QR_get_num_cached_tuples(res) > 0) { OID basetype; self->lobj_type = QR_get_value_backend_int(res, 0, 0, NULL); basetype = QR_get_value_backend_int(res, 0, 1, NULL); if (PG_TYPE_OID == basetype) self->lo_is_domain = 1; else if (0 != basetype) self->lobj_type = 0; } QR_Destructor(res); MYLOG(0, "Got the large object oid: %d\n", self->lobj_type); return ret; } /* * This function initializes the version of PostgreSQL from * connInfo.protocol that we're connected to. * h-inoue 01-2-2001 */ void CC_initialize_pg_version(ConnectionClass *self) { STRCPY_FIXED(self->pg_version, "7.4"); self->pg_version_major = 7; self->pg_version_minor = 4; } void CC_log_error(const char *func, const char *desc, const ConnectionClass *self) { #define NULLCHECK(a) (a ? a : "(NULL)") if (self) { MYLOG(0, "CONN ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->__error_number, NULLCHECK(self->__error_message)); MYLOG(DETAIL_LOG_LEVEL, " ------------------------------------------------------------\n"); MYLOG(DETAIL_LOG_LEVEL, " henv=%p, conn=%p, status=%u, num_stmts=%d\n", self->henv, self, self->status, self->num_stmts); MYLOG(DETAIL_LOG_LEVEL, " pqconn=%p, stmts=%p, lobj_type=%d\n", self->pqconn, self->stmts, self->lobj_type); } else { MYLOG(0, "INVALID CONNECTION HANDLE ERROR: func=%s, desc='%s'\n", func, desc); } } /* * This doesn't really return the CURRENT SCHEMA * but there's no alternative. */ const char * CC_get_current_schema(ConnectionClass *conn) { if (!conn->current_schema_valid) { QResultClass *res; if (res = CC_send_query(conn, "select current_schema()", NULL, READ_ONLY_QUERY, NULL), QR_command_maybe_successful(res)) { if (QR_get_num_total_tuples(res) == 1) { char *curschema = QR_get_value_backend_text(res, 0, 0); if (curschema) conn->current_schema = strdup(curschema); } if (conn->current_schema) conn->current_schema_valid = TRUE; } QR_Destructor(res); } return (const char *) conn->current_schema; } int CC_mark_a_object_to_discard(ConnectionClass *conn, int type, const char *plan) { int cnt = conn->num_discardp + 1, plansize; char *pname; CC_REALLOC_return_with_error(conn->discardp, char *, (cnt * sizeof(char *)), conn, "Couldn't alloc discardp.", -1); plansize = strlen(plan) + 2; CC_MALLOC_return_with_error(pname, char, plansize, conn, "Couldn't alloc discardp mem.", -1); pname[0] = (char) type; /* 's':prepared statement 'p':cursor */ strncpy_null(pname + 1, plan, plansize - 1); conn->discardp[conn->num_discardp++] = pname; return 1; } int CC_discard_marked_objects(ConnectionClass *conn) { int i, cnt; QResultClass *res; char *pname, cmd[64]; if ((cnt = conn->num_discardp) <= 0) return 0; for (i = cnt - 1; i >= 0; i--) { pname = conn->discardp[i]; if ('s' == pname[0]) SPRINTF_FIXED(cmd, "DEALLOCATE \"%s\"", pname + 1); else SPRINTF_FIXED(cmd, "CLOSE \"%s\"", pname + 1); res = CC_send_query(conn, cmd, NULL, ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN | READ_ONLY_QUERY, NULL); QR_Destructor(res); free(conn->discardp[i]); conn->num_discardp--; } return 1; } static void LIBPQ_update_transaction_status(ConnectionClass *self) { if (!self->pqconn) return; MYLOG(DETAIL_LOG_LEVEL, "transactionStatus=%d\n", PQtransactionStatus(self->pqconn)); switch (PQtransactionStatus(self->pqconn)) { case PQTRANS_IDLE: // correspond to 'I' in ReadyForQuery message if (CC_is_in_trans(self)) { if (CC_is_in_error_trans(self)) CC_on_abort(self, NO_TRANS); else CC_on_commit(self); } break; case PQTRANS_INTRANS: // correspond to 'T' in ReadyForQuery message CC_set_in_trans(self); if (CC_is_in_error_trans(self)) { CC_set_no_error_trans(self); CC_on_abort_partial(self); } break; case PQTRANS_INERROR: // correspond to 'E' in ReadyForQuery message CC_set_in_trans(self); CC_set_in_error_trans(self); break; case PQTRANS_ACTIVE: // no correspondence in ReadyForQuery message /* * A query is still executing. It's not necessary to consider this status. */ // CC_set_in_trans(self); break; default: /* unknown status */ break; } } #define PROTOCOL3_OPTS_MAX 30 static int LIBPQ_connect(ConnectionClass *self) { CSTR func = "LIBPQ_connect"; ConnInfo *ci = &(self->connInfo); char ret = 0; void *pqconn = NULL; int pqret; int pversion; const char *opts[PROTOCOL3_OPTS_MAX], *vals[PROTOCOL3_OPTS_MAX]; PQconninfoOption *conninfoOption = NULL, *pqopt; int i, cnt; char login_timeout_str[20]; char keepalive_idle_str[20]; char keepalive_interval_str[20]; char *errmsg = NULL; MYLOG(0, "connecting to the database using %s as the server and pqopt={%s}\n", self->connInfo.server, SAFE_NAME(ci->pqopt)); if (NULL == (conninfoOption = PQconninfoParse(SAFE_NAME(ci->pqopt), &errmsg))) { char emsg[200]; if (errmsg != NULL) SPRINTF_FIXED(emsg, "libpq connection parameter error:%s", errmsg); else STRCPY_FIXED(emsg, "memory error? in PQconninfoParse"); CC_set_error(self, CONN_OPENDB_ERROR, emsg, func); goto cleanup; } /* Build arrays of keywords & values, for PQconnectDBParams */ cnt = 0; if (ci->server[0]) { opts[cnt] = "host"; vals[cnt++] = ci->server; } if (ci->port[0]) { opts[cnt] = "port"; vals[cnt++] = ci->port; } if (ci->database[0]) { opts[cnt] = "dbname"; vals[cnt++] = ci->database; } if (ci->username[0]) { opts[cnt] = "user"; vals[cnt++] = ci->username; } switch (ci->sslmode[0]) { case '\0': break; case SSLLBYTE_VERIFY: opts[cnt] = "sslmode"; switch (ci->sslmode[1]) { case 'f': vals[cnt++] = SSLMODE_VERIFY_FULL; break; case 'c': vals[cnt++] = SSLMODE_VERIFY_CA; break; default: vals[cnt++] = ci->sslmode; } break; default: opts[cnt] = "sslmode"; vals[cnt++] = ci->sslmode; } if (NAME_IS_VALID(ci->password)) { opts[cnt] = "password"; vals[cnt++] = SAFE_NAME(ci->password); } if (ci->disable_keepalive) { opts[cnt] = "keepalives"; vals[cnt++] = "0"; } if (self->login_timeout > 0) { SPRINTF_FIXED(login_timeout_str, "%u", (unsigned int) self->login_timeout); opts[cnt] = "connect_timeout"; vals[cnt++] = login_timeout_str; } if (self->connInfo.keepalive_idle > 0) { ITOA_FIXED(keepalive_idle_str, self->connInfo.keepalive_idle); opts[cnt] = "keepalives_idle"; vals[cnt++] = keepalive_idle_str; } if (self->connInfo.keepalive_interval > 0) { ITOA_FIXED(keepalive_interval_str, self->connInfo.keepalive_interval); opts[cnt] = "keepalives_interval"; vals[cnt++] = keepalive_interval_str; } if (conninfoOption != NULL) { const char *keyword, *val; int j; for (i = 0, pqopt = conninfoOption; (keyword = pqopt->keyword) != NULL; i++, pqopt++) { if ((val = pqopt->val) != NULL) { for (j = 0; j < cnt; j++) { if (stricmp(opts[j], keyword) == 0) { char emsg[100]; if (vals[j] != NULL && strcmp(vals[j], val) == 0) continue; SPRINTF_FIXED(emsg, "%s parameter in pqopt option conflicts with other ordinary option", keyword); CC_set_error(self, CONN_OPENDB_ERROR, emsg, func); goto cleanup; } } if (j >= cnt && cnt < PROTOCOL3_OPTS_MAX - 1) { opts[cnt] = keyword; vals[cnt++] = val; } } } } opts[cnt] = vals[cnt] = NULL; /* Ok, we're all set to connect */ if (get_qlog() > 0 || get_mylog() > 0) { const char **popt, **pval; QLOG(0, "PQconnectdbParams:"); for (popt = opts, pval = vals; *popt; popt++, pval++) QPRINTF(0, " %s='%s'", *popt, *pval); QPRINTF(0, "\n"); } pqconn = PQconnectdbParams(opts, vals, FALSE); if (!pqconn) { CC_set_error(self, CONN_OPENDB_ERROR, "PQconnectdb error", func); goto cleanup; } self->pqconn = pqconn; pqret = PQstatus(pqconn); if (pqret == CONNECTION_BAD && PQconnectionNeedsPassword(pqconn)) { const char *errmsg; MYLOG(0, "password retry\n"); errmsg = PQerrorMessage(pqconn); CC_set_error(self, CONNECTION_SERVER_NOT_REACHED, errmsg, func); QLOG(0, "PQfinish: %p\n", pqconn); PQfinish(pqconn); self->pqconn = NULL; self->connInfo.password_required = TRUE; ret = -1; goto cleanup; } if (CONNECTION_OK != pqret) { const char *errmsg; MYLOG(DETAIL_LOG_LEVEL, "status=%d\n", pqret); errmsg = PQerrorMessage(pqconn); CC_set_error(self, CONNECTION_SERVER_NOT_REACHED, errmsg, func); MYLOG(0, "Could not establish connection to the database; LIBPQ returned -> %s\n", errmsg); goto cleanup; } MYLOG(0, "libpq connection to the database established.\n"); pversion = PQprotocolVersion(pqconn); if (pversion < 3) { MYLOG(0, "Protocol version %d is not supported\n", pversion); goto cleanup; } MYLOG(0, "protocol=%d\n", pversion); pversion = PQserverVersion(pqconn); self->pg_version_major = pversion / 10000; self->pg_version_minor = (pversion % 10000) / 100; SPRINTF_FIXED(self->pg_version, "%d.%d.%d", self->pg_version_major, self->pg_version_minor, pversion % 100); MYLOG(0, "Server version=%s\n", self->pg_version); if (!CC_get_username(self)[0]) { MYLOG(0, "PQuser=%s\n", PQuser(pqconn)); STRCPY_FIXED(self->connInfo.username, PQuser(pqconn)); } ret = 1; cleanup: if (errmsg != NULL) free(errmsg); PQconninfoFree(conninfoOption); if (ret != 1) { if (self->pqconn) { QLOG(0, "PQfinish: %p\n", self->pqconn); PQfinish(self->pqconn); } self->pqconn = NULL; } MYLOG(0, "leaving %d\n", ret); return ret; } int CC_send_cancel_request(const ConnectionClass *conn) { int ret = 0; char errbuf[256]; void *cancel; /* Check we have an open connection */ if (!conn || !conn->pqconn) return FALSE; cancel = PQgetCancel(conn->pqconn); if (!cancel) return FALSE; ret = PQcancel(cancel, errbuf, sizeof(errbuf)); PQfreeCancel(cancel); if (1 == ret) return TRUE; else return FALSE; } const char *CurrCat(const ConnectionClass *conn) { /* * Returning the database name causes problems in MS Query. It * generates query like: "SELECT DISTINCT a FROM byronnbad3 * bad3" */ if (isMsQuery()) /* MS Query */ return NULL; return conn->connInfo.database; } const char *CurrCatString(const ConnectionClass *conn) { const char *cat = CurrCat(conn); if (!cat) cat = NULL_STRING; return cat; } /*------ * Create a null terminated lower-case string if the * original string contains upper-case characters. * The SQL_NTS length is considered. *------ */ SQLCHAR * make_lstring_ifneeded(ConnectionClass *conn, const SQLCHAR *s, ssize_t len, BOOL ifallupper) { ssize_t length = len; char *str = NULL; const char *ccs = (const char *) s; if (s && (len > 0 || (len == SQL_NTS && (length = strlen(ccs)) > 0))) { int i; UCHAR tchar; encoded_str encstr; make_encoded_str(&encstr, conn, ccs); for (i = 0; i < length; i++) { tchar = encoded_nextchar(&encstr); if (MBCS_NON_ASCII(encstr)) continue; if (ifallupper && islower(tchar)) { if (str) { free(str); str = NULL; } break; } if (tolower(tchar) != tchar) { if (!str) { str = malloc(length + 1); if (!str) return NULL; memcpy(str, s, length); str[length] = '\0'; } str[i] = tolower(tchar); } } } return (SQLCHAR *) str; } /* * Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing. * "fmt" must contain somewhere in it the single form '%.*s'. * This is heavily used in creating queries for info routines (SQLTables, SQLColumns). * This routine could be modified to use vsprintf() to handle multiple arguments. */ static int my_str(char *buf, int buflen, const char *fmt, const char *s, ssize_t len) { if (s && (len > 0 || (len == SQL_NTS && *s != 0))) { size_t length = (len > 0) ? len : strlen(s); return snprintf(buf, buflen, fmt, length, s); } buf[0] = '\0'; return 0; } int schema_str(char *buf, int buflen, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn) { CSTR fmt = "%.*s"; buf[0] = '\0'; if (!s || 0 == len) { /* * Note that this driver assumes the implicit schema is * the CURRENT_SCHEMA() though it doesn't worth the * naming. */ if (table_is_valid) return my_str(buf, buflen, fmt, CC_get_current_schema(conn), SQL_NTS); return 0; } return my_str(buf, buflen, fmt, (char *) s, len); } static void my_appendPQExpBuffer(PQExpBufferData *buf, const char *fmt, const char *s, ssize_t len) { if (s && (len > 0 || (len == SQL_NTS && *s != 0))) { size_t length = (len > 0) ? len : strlen(s); appendPQExpBuffer(buf, fmt, length, s); } } /* * my_appendPQExpBuffer1 is a extension of my_appendPQExpBuffer. * It can have 1 more parameter than my_appendPQExpBuffer. */ static void my_appendPQExpBuffer1(PQExpBufferData *buf, const char *fmt, const char *s1, const char *s) { if (s && s[0] != '\0') { ssize_t length = strlen(s); if (s1) appendPQExpBuffer(buf, fmt, s1, length, s); else appendPQExpBuffer(buf, fmt, length, s); } } void schema_appendPQExpBuffer(PQExpBufferData *buf, const char *fmt, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn) { if (!s || 0 == len) { /* * Note that this driver assumes the implicit schema is * the CURRENT_SCHEMA() though it doesn't worth the * naming. */ if (table_is_valid) my_appendPQExpBuffer(buf, fmt, CC_get_current_schema(conn), SQL_NTS); return; } my_appendPQExpBuffer(buf, fmt, (char *) s, len); } void schema_appendPQExpBuffer1(PQExpBufferData *buf, const char *fmt, const char *s1, const char *s, BOOL table_is_valid, ConnectionClass *conn) { if (!s || s[0] == '\0') { if (table_is_valid) my_appendPQExpBuffer1(buf, fmt, s1, CC_get_current_schema(conn)); return; } my_appendPQExpBuffer1(buf, fmt, s1, s); } #ifdef _HANDLE_ENLIST_IN_DTC_ /* * Export the following functions so that the pgenlist dll * can handle ConnectionClass objects as opaque ones. */ #define _PGDTC_FUNCS_IMPLEMENT_ #include "connexp.h" #define SYNC_AUTOCOMMIT(conn) \ (SQL_AUTOCOMMIT_OFF != conn->autocommit_public ? \ (conn->transact_status |= CONN_IN_AUTOCOMMIT) : \ (conn->transact_status &= ~CONN_IN_AUTOCOMMIT)) DLL_DECLARE void PgDtc_create_connect_string(void *self, char *connstr, int strsize) { ConnectionClass *conn = (ConnectionClass *) self; ConnInfo *ci = &(conn->connInfo); const char *drivername = ci->drivername; char xaOptStr[32]; #if defined(_WIN32) && !defined(_WIN64) /* * If this is an x86 driver running on an x64 host then the driver name * passed to MSDTC must be the (x64) driver but the client app will be * using the 32-bit driver name. So MSDTC.exe will fail to find the driver * and we'll fail to recover XA transactions. * * IsWow64Process(...) would be the ideal function for this, but is only * available on Windows 6+ (Vista/2k8). We'd use GetNativeSystemInfo, which * is supported on XP and 2k3, instead, but that won't link with older * SDKs. * * It's impler to just test the PROCESSOR_ARCHITEW6432 environment * variable. * * See http://www.postgresql.org/message-id/53A45B59.70303@2ndquadrant.com * for details on this issue. */ const char * const procenv = getenv("PROCESSOR_ARCHITEW6432"); if (procenv != NULL && strcmp(procenv, "AMD64") == 0) { /* * We're a 32-bit binary running under SysWow64 on a 64-bit host and need * to pass a different driver name. * * To avoid playing memory management games, just return a different * string constant depending on the unicode-ness of the driver. * * It probably doesn't matter whether we use the Unicode or ANSI driver * for the XA transaction manager, but pick the same as the client driver * to keep things as similar as possible. */ if (strcmp(drivername, DBMS_NAME) == 0) #ifdef UNICODE_SUPPORT drivername = DBMS_NAME_UNICODE"(x64)"; #else drivername = DBMS_NAME_ANSI"(x64)"; #endif } #endif // _WIN32 && !_WIN64 if (0 >= ci->xa_opt) return; switch (ci->xa_opt) { case DTC_CHECK_LINK_ONLY: case DTC_CHECK_BEFORE_LINK: SPRINTF_FIXED(xaOptStr, KEYWORD_DTC_CHECK "=0;"); break; case DTC_CHECK_RM_CONNECTION: SPRINTF_FIXED(xaOptStr, KEYWORD_DTC_CHECK "=1;"); break; default: *xaOptStr = '\0'; break; } snprintf(connstr, strsize, "DRIVER={%s};%s" "SERVER=%s;PORT=%s;DATABASE=%s;" "UID=%s;PWD=%s;" ABBR_SSLMODE "=%s", drivername, xaOptStr, ci->server, ci->port, ci->database, ci->username, SAFE_NAME(ci->password), ci->sslmode ); return; } #define SECURITY_WIN32 #include DLL_DECLARE int PgDtc_is_recovery_available(void *self, char *reason, int rsize) { ConnectionClass *conn = (ConnectionClass *) self; ConnInfo *ci = &(conn->connInfo); int ret = -1; // inknown LONG nameSize; char loginUser[256]; BOOL outReason = FALSE; BOOL doubtRootCert = TRUE, doubtCert = TRUE; const char *delim; /* * Root certificate is used? */ if (NULL != reason && rsize > 0) outReason = TRUE; /* * Root certificate is used? */ doubtRootCert = FALSE; if (0 == stricmp(ci->sslmode, SSLMODE_VERIFY_CA) || 0 == stricmp(ci->sslmode, SSLMODE_VERIFY_FULL)) { if (outReason) strncpy_null(reason, "sslmode verify-[ca|full]", rsize); return 0; } /* * Did we use SSL client certificate, SSPI, Kerberos or similar * authentication methods? */ doubtCert = FALSE; #ifdef HAVE_PQSSLINUSE if (PQsslInUse(conn->pqconn)) #else if (PQgetssl(conn->pqconn) != NULL) #endif doubtCert = TRUE; nameSize = sizeof(loginUser); if (GetUserNameEx(NameUserPrincipal, loginUser, &nameSize)) { MYLOG(0, "loginUser=%s\n", loginUser); } else { int err = GetLastError(); switch (err) { case ERROR_NONE_MAPPED: MYLOG(0, "The user name is unavailable in the specified format\n"); break; case ERROR_NO_SUCH_DOMAIN: MYLOG(0, "The domain controller is unavailable to perform the lookup\n"); break; case ERROR_MORE_DATA: MYLOG(0, "The buffer is too small\n"); break; default: MYLOG(0, "GetUserNameEx error=%d\n", err); break; } } ret = 1; if (outReason) *reason = '\0'; delim = ""; if (doubtRootCert) { if (outReason) snprintf(reason, rsize, "%s%ssslmode verify-[ca|full]", reason, delim); delim = ", "; ret = -1; } if (doubtCert) { if (outReason) snprintf(reason, rsize, "%s%scertificate", reason, delim); delim = ", "; ret = -1; } return ret; } DLL_DECLARE void PgDtc_set_async(void *self, void *async) { ConnectionClass *conn = (ConnectionClass *) self; if (!conn) return; CONNLOCK_ACQUIRE(conn); if (NULL != async) CC_set_autocommit(conn, FALSE); else SYNC_AUTOCOMMIT(conn); conn->asdum = async; CONNLOCK_RELEASE(conn); } DLL_DECLARE void *PgDtc_get_async(void *self) { ConnectionClass *conn = (ConnectionClass *) self; return conn->asdum; } DLL_DECLARE void PgDtc_set_property(void *self, int property, void *value) { ConnectionClass *conn = (ConnectionClass *) self; CONNLOCK_ACQUIRE(conn); switch (property) { case inprogress: if (NULL != value) CC_set_dtc_executing(conn); else CC_no_dtc_executing(conn); break; case enlisted: if (NULL != value) CC_set_dtc_enlisted(conn); else CC_no_dtc_enlisted(conn); break; case prepareRequested: if (NULL != value) CC_set_dtc_prepareRequested(conn); else CC_no_dtc_prepareRequested(conn); break; } CONNLOCK_RELEASE(conn); } DLL_DECLARE void PgDtc_set_error(void *self, const char *message, const char *func) { ConnectionClass *conn = (ConnectionClass *) self; CC_set_error(conn, CONN_UNSUPPORTED_OPTION, message, func); } DLL_DECLARE int PgDtc_get_property(void *self, int property) { ConnectionClass *conn = (ConnectionClass *) self; int ret; CONNLOCK_ACQUIRE(conn); switch (property) { case inprogress: ret = CC_is_dtc_executing(conn); break; case enlisted: ret = CC_is_dtc_enlisted(conn); break; case inTrans: ret = CC_is_in_trans(conn); break; case errorNumber: ret = CC_get_errornumber(conn); break; case idleInGlobalTransaction: ret = CC_is_idle_in_global_transaction(conn); break; case connected: ret = (CONN_CONNECTED == conn->status); break; case prepareRequested: ret = CC_is_dtc_prepareRequested(conn); break; } CONNLOCK_RELEASE(conn); return ret; } DLL_DECLARE BOOL PgDtc_connect(void *self) { CSTR func = "PgDtc_connect"; ConnectionClass *conn = (ConnectionClass *) self; if (CONN_CONNECTED == conn->status) return TRUE; if (CC_connect(conn, NULL) <= 0) { /* Error messages are filled in */ CC_log_error(func, "Error on CC_connect", conn); return FALSE; } return TRUE; } DLL_DECLARE void PgDtc_free_connect(void *self) { ConnectionClass *conn = (ConnectionClass *) self; PGAPI_FreeConnect(conn); } DLL_DECLARE BOOL PgDtc_one_phase_operation(void *self, int operation) { ConnectionClass *conn = (ConnectionClass *) self; BOOL ret, is_in_progress = CC_is_dtc_executing(conn); if (!is_in_progress) CC_set_dtc_executing(conn); switch (operation) { case ONE_PHASE_COMMIT: ret = CC_commit(conn); break; default: ret = CC_abort(conn); break; } if (!is_in_progress) CC_no_dtc_executing(conn); return ret; } DLL_DECLARE BOOL PgDtc_two_phase_operation(void *self, int operation, const char *gxid) { ConnectionClass *conn = (ConnectionClass *) self; QResultClass *qres; BOOL ret = TRUE; char cmd[512]; switch (operation) { case PREPARE_TRANSACTION: SPRINTF_FIXED(cmd, "PREPARE TRANSACTION '%s'", gxid); break; case COMMIT_PREPARED: SPRINTF_FIXED(cmd, "COMMIT PREPARED '%s'", gxid); break; case ROLLBACK_PREPARED: SPRINTF_FIXED(cmd, "ROLLBACK PREPARED '%s'", gxid); break; } qres = CC_send_query(conn, cmd, NULL, 0, NULL); if (!QR_command_maybe_successful(qres)) ret = FALSE; QR_Destructor(qres); return ret; } DLL_DECLARE BOOL PgDtc_lock_cntrl(void *self, BOOL acquire, BOOL bTrial) { ConnectionClass *conn = (ConnectionClass *) self; BOOL ret = TRUE; if (acquire) if (bTrial) ret = TRY_ENTER_CONN_CS(conn); else ENTER_CONN_CS(conn); else LEAVE_CONN_CS(conn); return ret; } static ConnectionClass * CC_Copy(const ConnectionClass *conn) { ConnectionClass *newconn = CC_alloc(); if (newconn) { memcpy(newconn, conn, sizeof(ConnectionClass)); CC_lockinit(newconn); } return newconn; } DLL_DECLARE void * PgDtc_isolate(void *self, DWORD option) { BOOL disposingConn = (0 != (disposingConnection & option)); ConnectionClass *sconn = (ConnectionClass *) self, *newconn = NULL; if (0 == (useAnotherRoom & option)) { HENV henv = sconn->henv; CC_cleanup(sconn, TRUE); if (newconn = CC_Copy(sconn), NULL == newconn) return newconn; MYLOG(0, "newconn=%p from %p\n", newconn, sconn); CC_initialize(sconn, FALSE); if (!disposingConn) CC_copy_conninfo(&sconn->connInfo, &newconn->connInfo); CC_initialize_pg_version(sconn); sconn->henv = henv; newconn->henv = NULL; SYNC_AUTOCOMMIT(sconn); return newconn; } newconn = CC_Constructor(); if (!newconn) return NULL; CC_copy_conninfo(&newconn->connInfo, &sconn->connInfo); CC_initialize_pg_version(newconn); newconn->asdum = sconn->asdum; newconn->gTranInfo = sconn->gTranInfo; CC_set_dtc_isolated(newconn); sconn->asdum = NULL; SYNC_AUTOCOMMIT(sconn); CC_set_dtc_clear(sconn); MYLOG(0, "generated connection=%p with %p\n", newconn, newconn->asdum); return newconn; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ BOOL CC_set_transact(ConnectionClass *self, UInt4 isolation) { char *query; QResultClass *res; BOOL bShow = FALSE; if (PG_VERSION_LT(self, 8.0) && (isolation == SQL_TXN_READ_UNCOMMITTED || isolation == SQL_TXN_REPEATABLE_READ)) { CC_set_error(self, CONN_NOT_IMPLEMENTED_ERROR, "READ_UNCOMMITTED or REPEATABLE_READ is not supported by the server", __FUNCTION__); return FALSE; } switch (isolation) { case SQL_TXN_SERIALIZABLE: query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE"; break; case SQL_TXN_REPEATABLE_READ: query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ"; break; case SQL_TXN_READ_UNCOMMITTED: query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED"; break; default: query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED"; break; } if (self->default_isolation == 0) bShow = TRUE; if (bShow) res = CC_send_query_append(self, ISOLATION_SHOW_QUERY, NULL, READ_ONLY_QUERY, NULL, query).first; else res = CC_send_query(self, query, NULL, READ_ONLY_QUERY, NULL); if (!QR_command_maybe_successful(res)) { CC_set_error(self, CONN_EXEC_ERROR, "ISOLATION change request to the server error", __FUNCTION__); QR_Destructor(res); return FALSE; } if (bShow) handle_show_results(res); QR_Destructor(res); self->server_isolation = isolation; return TRUE; } psqlodbc-REL-16_00_0005/connection.h000066400000000000000000000471431462406103600170170ustar00rootroot00000000000000/* File: connection.h * * Description: See "connection.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __CONNECTION_H__ #define __CONNECTION_H__ #include "psqlodbc.h" #include #include "pqexpbuffer.h" #include #include #include #include "descriptor.h" #if defined (POSIX_MULTITHREAD_SUPPORT) #include #endif #ifdef __cplusplus extern "C" { #endif typedef enum { CONN_NOT_CONNECTED, /* Connection has not been established */ CONN_CONNECTED, /* Connection is up and has been established */ CONN_DOWN, /* Connection is broken */ CONN_EXECUTING /* the connection is currently executing a * statement */ } CONN_Status; /* These errors have general sql error state */ #define CONNECTION_SERVER_NOT_REACHED 101 #define CONNECTION_MSG_TOO_LONG 103 #define CONNECTION_COULD_NOT_SEND 104 #define CONNECTION_NO_SUCH_DATABASE 105 #define CONNECTION_BACKEND_CRAZY 106 #define CONNECTION_NO_RESPONSE 107 #define CONNECTION_SERVER_REPORTED_SEVERITY_FATAL 108 #define CONNECTION_COULD_NOT_RECEIVE 109 #define CONNECTION_SERVER_REPORTED_SEVERITY_ERROR 110 #define CONNECTION_NEED_PASSWORD 112 #define CONNECTION_COMMUNICATION_ERROR 113 #define CONN_ERROR_IGNORED (-3) #define CONN_TRUNCATED (-2) #define CONN_OPTION_VALUE_CHANGED (-1) /* These errors correspond to specific SQL states */ #define CONN_INIREAD_ERROR 201 #define CONN_OPENDB_ERROR 202 #define CONN_STMT_ALLOC_ERROR 203 #define CONN_IN_USE 204 #define CONN_UNSUPPORTED_OPTION 205 /* Used by SetConnectoption to indicate unsupported options */ #define CONN_INVALID_ARGUMENT_NO 206 /* SetConnectOption: corresponds to ODBC--"S1009" */ #define CONN_TRANSACT_IN_PROGRES 207 #define CONN_NO_MEMORY_ERROR 208 #define CONN_NOT_IMPLEMENTED_ERROR 209 #define CONN_INVALID_AUTHENTICATION 210 #define CONN_AUTH_TYPE_UNSUPPORTED 211 #define CONN_UNABLE_TO_LOAD_DLL 212 #define CONN_ILLEGAL_TRANSACT_STATE 213 #define CONN_VALUE_OUT_OF_RANGE 214 #define CONN_OPTION_NOT_FOR_THE_DRIVER 216 #define CONN_EXEC_ERROR 217 /* Conn_status defines */ #define CONN_IN_AUTOCOMMIT 1L #define CONN_IN_TRANSACTION (1L<<1) #define CONN_IN_MANUAL_TRANSACTION (1L<<2) #define CONN_IN_ERROR_BEFORE_IDLE (1L<<3) /* not connected yet || already disconnected */ #define CC_not_connected(x) (!(x) || CONN_DOWN == (x)->status || CONN_NOT_CONNECTED == (x)->status) /* AutoCommit functions */ #define CC_is_in_autocommit(x) (x->transact_status & CONN_IN_AUTOCOMMIT) #define CC_does_autocommit(x) (CONN_IN_AUTOCOMMIT == ((x)->transact_status & (CONN_IN_AUTOCOMMIT | CONN_IN_MANUAL_TRANSACTION))) #define CC_loves_visible_trans(x) ((0 == ((x)->transact_status & CONN_IN_AUTOCOMMIT)) || (0 != ((x)->transact_status & CONN_IN_MANUAL_TRANSACTION))) /* Transaction in/not functions */ #define CC_set_in_trans(x) (x->transact_status |= CONN_IN_TRANSACTION) #define CC_set_no_trans(x) (x->transact_status &= ~(CONN_IN_TRANSACTION | CONN_IN_ERROR_BEFORE_IDLE)) #define CC_is_in_trans(x) (0 != (x->transact_status & CONN_IN_TRANSACTION)) /* Manual transaction in/not functions */ #define CC_set_in_manual_trans(x) (x->transact_status |= CONN_IN_MANUAL_TRANSACTION) #define CC_set_no_manual_trans(x) (x->transact_status &= ~CONN_IN_MANUAL_TRANSACTION) #define CC_is_in_manual_trans(x) (0 != (x->transact_status & CONN_IN_MANUAL_TRANSACTION)) /* Error waiting for ROLLBACK */ #define CC_set_in_error_trans(x) (x->transact_status |= CONN_IN_ERROR_BEFORE_IDLE) #define CC_set_no_error_trans(x) (x->transact_status &= ~CONN_IN_ERROR_BEFORE_IDLE) #define CC_is_in_error_trans(x) (x->transact_status & CONN_IN_ERROR_BEFORE_IDLE) #define CC_get_errornumber(x) (x->__error_number) #define CC_get_errormsg(x) (x->__error_message) #define CC_set_errornumber(x, n) (x->__error_number = n) /* Unicode handling */ #define CONN_UNICODE_DRIVER (1L) #define CONN_ANSI_APP (1L << 1) #define CONN_DISALLOW_WCHAR (1L << 2) #define CC_set_in_unicode_driver(x) (x->unicode |= CONN_UNICODE_DRIVER) #define CC_set_in_ansi_app(x) (x->unicode |= CONN_ANSI_APP) #define CC_is_in_unicode_driver(x) (0 != (x->unicode & CONN_UNICODE_DRIVER)) #define CC_is_in_ansi_app(x) (0 != (x->unicode & CONN_ANSI_APP)) #define CC_is_in_global_trans(x) (NULL != (x)->asdum) #define ALLOW_WCHAR(x) (0 != (x->unicode & CONN_UNICODE_DRIVER) && 0 == (x->unicode & CONN_DISALLOW_WCHAR)) #define CC_MALLOC_return_with_error(t, tp, s, x, m, ret) \ do { \ if (t = malloc(s), NULL == t) \ { \ CC_set_error(x, CONN_NO_MEMORY_ERROR, m, ""); \ return ret; \ } \ } while (0) #define CC_REALLOC_return_with_error(t, tp, s, x, m, ret) \ do { \ tp *tmp; \ if (tmp = (tp *) realloc(t, s), NULL == tmp) \ { \ CC_set_error(x, CONN_NO_MEMORY_ERROR, m, ""); \ return ret; \ } \ t = tmp; \ } while (0) /* For Multi-thread */ #if defined(WIN_MULTITHREAD_SUPPORT) #define INIT_CONN_CS(x) InitializeCriticalSection(&((x)->cs)) #define INIT_CONNLOCK(x) InitializeCriticalSection(&((x)->slock)) #define ENTER_CONN_CS(x) EnterCriticalSection(&((x)->cs)) #define CONNLOCK_ACQUIRE(x) EnterCriticalSection(&((x)->slock)) #define TRY_ENTER_CONN_CS(x) TryEnterCriticalSection(&((x)->cs)) #define ENTER_INNER_CONN_CS(x, entered) \ do { \ EnterCriticalSection(&((x)->cs)); \ entered++; \ } while (0) #define LEAVE_CONN_CS(x) LeaveCriticalSection(&((x)->cs)) #define CONNLOCK_RELEASE(x) LeaveCriticalSection(&((x)->slock)) #define DELETE_CONN_CS(x) DeleteCriticalSection(&((x)->cs)) #define DELETE_CONNLOCK(x) DeleteCriticalSection(&((x)->slock)) #elif defined(POSIX_THREADMUTEX_SUPPORT) #define INIT_CONN_CS(x) pthread_mutex_init(&((x)->cs), getMutexAttr()) #define INIT_CONNLOCK(x) pthread_mutex_init(&((x)->slock), getMutexAttr()) #define ENTER_CONN_CS(x) pthread_mutex_lock(&((x)->cs)) #define CONNLOCK_ACQUIRE(x) pthread_mutex_lock(&((x)->slock)) #define TRY_ENTER_CONN_CS(x) (0 == pthread_mutex_trylock(&((x)->cs))) #define ENTER_INNER_CONN_CS(x, entered) \ do { \ if (getMutexAttr()) \ { \ if (pthread_mutex_lock(&((x)->cs)) == 0) \ entered++; \ } \ } while (0) #define LEAVE_CONN_CS(x) pthread_mutex_unlock(&((x)->cs)) #define CONNLOCK_RELEASE(x) pthread_mutex_unlock(&((x)->slock)) #define DELETE_CONN_CS(x) pthread_mutex_destroy(&((x)->cs)) #define DELETE_CONNLOCK(x) pthread_mutex_destroy(&((x)->slock)) #else #define INIT_CONN_CS(x) #define INIT_CONNLOCK(x) #define TRY_ENTER_CONN_CS(x) (1) #define ENTER_CONN_CS(x) #define CONNLOCK_ACQUIRE(x) #define ENTER_INNER_CONN_CS(x, entered) #define LEAVE_CONN_CS(x) #define CONNLOCK_RELEASE(x) #define DELETE_CONN_CS(x) #define DELETE_CONNLOCK(x) #endif /* WIN_MULTITHREAD_SUPPORT */ #define LEAVE_INNER_CONN_CS(entered, conn) \ do { \ if (entered > 0) \ { \ LEAVE_CONN_CS(conn); \ entered--; \ } \ } while (0) #define CLEANUP_FUNC_CONN_CS(entered, conn) \ do { \ while (entered > 0) \ { \ LEAVE_CONN_CS(conn); \ entered--; \ } \ } while (0) /* * Macros to compare the server's version with a specified version * 1st parameter: pointer to a ConnectionClass object * 2nd parameter: major version number * 3rd parameter: minor version number */ #define SERVER_VERSION_GT(conn, major, minor) \ ((conn)->pg_version_major > major || \ ((conn)->pg_version_major == major && (conn)->pg_version_minor > minor)) #define SERVER_VERSION_GE(conn, major, minor) \ ((conn)->pg_version_major > major || \ ((conn)->pg_version_major == major && (conn)->pg_version_minor >= minor)) #define SERVER_VERSION_EQ(conn, major, minor) \ ((conn)->pg_version_major == major && (conn)->pg_version_minor == minor) #define STRING_AFTER_DOT(string) (strchr(#string, '.') + 1) /* * Simplified macros to compare the server's version with a * specified version * Note: Never pass a variable as the second parameter. * It must be a decimal constant of the form %d.%d . */ #define PG_VERSION_GT(conn, ver) \ (SERVER_VERSION_GT(conn, (int) ver, atoi(STRING_AFTER_DOT(ver)))) #define PG_VERSION_GE(conn, ver) \ (SERVER_VERSION_GE(conn, (int) ver, atoi(STRING_AFTER_DOT(ver)))) #define PG_VERSION_EQ(conn, ver) \ (SERVER_VERSION_EQ(conn, (int) ver, atoi(STRING_AFTER_DOT(ver)))) #define PG_VERSION_LE(conn, ver) (! PG_VERSION_GT(conn, ver)) #define PG_VERSION_LT(conn, ver) (! PG_VERSION_GE(conn, ver)) /* This is used to store cached table information in the connection */ struct col_info { Int2 refcnt; QResultClass *result; pgNAME schema_name; pgNAME table_name; OID table_oid; int table_info; time_t acc_time; }; enum { TBINFO_HASOIDS = 1L ,TBINFO_HASSUBCLASS = (1L << 1) }; #define free_col_info_contents(coli) \ { \ if (NULL != coli->result) \ QR_Destructor(coli->result); \ coli->result = NULL; \ NULL_THE_NAME(coli->schema_name); \ NULL_THE_NAME(coli->table_name); \ coli->table_oid = 0; \ coli->refcnt = 0; \ coli->acc_time = 0; \ } #define col_info_initialize(coli) (memset(coli, 0, sizeof(COL_INFO))) /* Translation DLL entry points */ #ifdef WIN32 #define DLLHANDLE HINSTANCE #else #define WINAPI CALLBACK #define DLLHANDLE void * #define HINSTANCE void * #endif typedef BOOL (WINAPI * DataSourceToDriverProc) (UDWORD, SWORD, PTR, SDWORD, PTR, SDWORD, SDWORD *, UCHAR *, SWORD, SWORD *); typedef BOOL (WINAPI * DriverToDataSourceProc) (UDWORD, SWORD, PTR, SDWORD, PTR, SDWORD, SDWORD *, UCHAR *, SWORD, SWORD *); /******* The Connection handle ************/ struct ConnectionClass_ { HENV henv; /* environment this connection was * created on */ SQLUINTEGER login_timeout; signed char autocommit_public; StatementOptions stmtOptions; ARDFields ardOptions; APDFields apdOptions; char *__error_message; int __error_number; char sqlstate[8]; CONN_Status status; ConnInfo connInfo; StatementClass **stmts; Int2 num_stmts; Int2 ncursors; PGconn *pqconn; Int4 lobj_type; Int2 coli_allocated; Int2 ntables; COL_INFO **col_info; long translation_option; HINSTANCE translation_handle; DataSourceToDriverProc DataSourceToDriver; DriverToDataSourceProc DriverToDataSource; char transact_status; /* Is a transaction is currently * in progress */ char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL * we're connected to - * DJP 25-1-2001 */ Int2 pg_version_major; Int2 pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char lo_is_domain; char current_schema_valid; /* is current_schema valid? TRUE when * current_schema == NULL means it's * really NULL, while FALSE means it's * unknown */ unsigned char on_commit_in_progress; /* for per statement rollback */ char internal_svp; /* is set? */ char internal_op; /* operation being executed as to internal savepoint */ unsigned char rbonerr; unsigned char opt_in_progress; unsigned char opt_previous; char *original_client_encoding; char *locale_encoding; char *server_encoding; Int2 ccsc; Int2 mb_maxbyte_per_char; SQLUINTEGER isolation; /* isolation level initially unknown */ SQLUINTEGER server_isolation; /* isolation at server initially unknown */ char *current_schema; StatementClass *unnamed_prepared_stmt; Int2 max_identifier_length; Int2 num_discardp; char **discardp; int num_descs; SQLUINTEGER default_isolation; /* server's default isolation initially unknown */ DescriptorClass **descs; pgNAME schemaIns; pgNAME tableIns; SQLULEN stmt_timeout_in_effect; #if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION cs; CRITICAL_SECTION slock; #elif defined(POSIX_THREADMUTEX_SUPPORT) pthread_mutex_t cs; pthread_mutex_t slock; #endif /* WIN_MULTITHREAD_SUPPORT */ #ifdef _HANDLE_ENLIST_IN_DTC_ UInt4 gTranInfo; void *asdum; #endif /* _HANDLE_ENLIST_IN_DTC_ */ }; /* Accessor functions */ #define CC_get_env(x) ((x)->henv) #define CC_get_database(x) (x->connInfo.database) #define CC_get_server(x) (x->connInfo.server) #define CC_get_DSN(x) (x->connInfo.dsn) #define CC_get_username(x) (x->connInfo.username) #define CC_is_onlyread(x) (x->connInfo.onlyread[0] == '1') #define CC_fake_mss(x) (/* 0 != (x)->ms_jet && */ 0 < (x)->connInfo.fake_mss) #define CC_accessible_only(x) (0 < (x)->connInfo.accessible_only) #define CC_default_is_c(x) (CC_is_in_ansi_app(x) || x->ms_jet /* not only */ || TRUE /* but for any other ? */) #ifdef _HANDLE_ENLIST_IN_DTC_ enum { DTC_IN_PROGRESS = 1L ,DTC_ENLISTED = (1L << 1) ,DTC_REQUEST_EXECUTING = (1L << 2) ,DTC_ISOLATED = (1L << 3) ,DTC_PREPARE_REQUESTED = (1L << 4) }; #define CC_set_dtc_clear(x) ((x)->gTranInfo = 0) #define CC_set_dtc_enlisted(x) ((x)->gTranInfo |= (DTC_IN_PROGRESS | DTC_ENLISTED)) #define CC_no_dtc_enlisted(x) ((x)->gTranInfo &= (~DTC_ENLISTED)) #define CC_is_dtc_enlisted(x) (0 != ((x)->gTranInfo & DTC_ENLISTED)) #define CC_set_dtc_executing(x) ((x)->gTranInfo |= DTC_REQUEST_EXECUTING) #define CC_no_dtc_executing(x) ((x)->gTranInfo &= (~DTC_REQUEST_EXECUTING)) #define CC_is_dtc_executing(x) (0 != ((x)->gTranInfo & DTC_REQUEST_EXECUTING)) #define CC_set_dtc_prepareRequested(x) ((x)->gTranInfo |= (DTC_PREPARE_REQUESTED)) #define CC_no_dtc_prepareRequested(x) ((x)->gTranInfo &= (~DTC_PREPARE_REQUESTED)) #define CC_is_dtc_prepareRequested(x) (0 != ((x)->gTranInfo & DTC_PREPARE_REQUESTED)) #define CC_is_dtc_executing(x) (0 != ((x)->gTranInfo & DTC_REQUEST_EXECUTING)) #define CC_set_dtc_isolated(x) ((x)->gTranInfo |= DTC_ISOLATED) #define CC_is_idle_in_global_transaction(x) (0 != ((x)->gTranInfo & DTC_PREPARE_REQUESTED) || (x)->gTranInfo == DTC_IN_PROGRESS) #endif /* _HANDLE_ENLIST_IN_DTC_ */ /* statement callback */ #define CC_start_stmt(a) ((a)->rbonerr = 0) #define CC_start_tc_stmt(a) ((a)->rbonerr = (1L << 1)) #define CC_is_tc_stmt(a) (((a)->rbonerr & (1L << 1)) != 0) #define CC_start_rb_stmt(a) ((a)->rbonerr = (1L << 2)) #define CC_is_rb_stmt(a) (((a)->rbonerr & (1L << 2)) != 0) #define CC_set_accessed_db(a) ((a)->rbonerr |= (1L << 3)) #define CC_accessed_db(a) (((a)->rbonerr & (1L << 3)) != 0) #define CC_start_rbpoint(a) ((a)->rbonerr |= (1L << 4), (a)->internal_svp = 1) #define CC_started_rbpoint(a) (((a)->rbonerr & (1L << 4)) != 0) /* prototypes */ ConnectionClass *CC_Constructor(void); char CC_Destructor(ConnectionClass *self); int CC_cursor_count(ConnectionClass *self); char CC_cleanup(ConnectionClass *self, BOOL keepCommunication); char CC_begin(ConnectionClass *self); char CC_commit(ConnectionClass *self); char CC_abort(ConnectionClass *self); char CC_set_autocommit(ConnectionClass *self, BOOL on); int CC_set_translation(ConnectionClass *self); char CC_connect(ConnectionClass *self, char *salt); char CC_add_statement(ConnectionClass *self, StatementClass *stmt); char CC_remove_statement(ConnectionClass *self, StatementClass *stmt) ; char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc); char CC_remove_descriptor(ConnectionClass *self, DescriptorClass *desc); void CC_set_error(ConnectionClass *self, int number, const char *message, const char *func); void CC_set_errormsg(ConnectionClass *self, const char *message); char CC_get_error(ConnectionClass *self, int *number, char **message); QResultHold CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UDWORD flag, StatementClass *stmt, const char *appendq); #define CC_send_query(self, query, qi, flag, stmt) CC_send_query_append(self, query, qi, flag, stmt, NULL).first void handle_pgres_error(ConnectionClass *self, const PGresult *pgres, const char *comment, QResultClass *res, BOOL error_not_a_notice); void CC_clear_error(ConnectionClass *self); int CC_send_function(ConnectionClass *conn, const char *fn_name, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs); char CC_send_settings(ConnectionClass *self, const char *set_query); void CC_initialize_pg_version(ConnectionClass *conn); void CC_log_error(const char *func, const char *desc, const ConnectionClass *self); int CC_send_cancel_request(const ConnectionClass *conn); void CC_on_commit(ConnectionClass *conn); void CC_on_abort(ConnectionClass *conn, unsigned int opt); void CC_on_abort_partial(ConnectionClass *conn); void ProcessRollback(ConnectionClass *conn, BOOL undo, BOOL partial); const char *CC_get_current_schema(ConnectionClass *conn); int CC_mark_a_object_to_discard(ConnectionClass *conn, int type, const char *plan); int CC_discard_marked_objects(ConnectionClass *conn); int CC_get_max_idlen(ConnectionClass *self); char CC_get_escape(const ConnectionClass *self); char * identifierEscape(const SQLCHAR *src, SQLLEN srclen, const ConnectionClass *conn, char *buf, size_t bufsize, BOOL double_quote); int findIdentifier(const UCHAR *str, int ccsc, const UCHAR **next_token); int eatTableIdentifiers(const UCHAR *str, int ccsc, pgNAME *table, pgNAME *schema); const char *CurrCat(const ConnectionClass *self); const char *CurrCatString(const ConnectionClass *self); SQLUINTEGER CC_get_isolation(ConnectionClass *self); SQLCHAR *make_lstring_ifneeded(ConnectionClass *, const SQLCHAR *s, ssize_t len, BOOL); #define TABLE_IS_VALID(tbname, tblen) ((tbname) && (tblen > 0 || SQL_NTS == tblen)) int schema_str(char *buf, int buflen, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn); char *schema_strcat(char *buf, int buflen, const char *fmt, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn); char *schema_strcat1(char *buf, int buflen, const char *fmt, const char *s1, const char *s, const SQLCHAR *, int, ConnectionClass *conn); void schema_appendPQExpBuffer(PQExpBufferData *buf, const char *fmt, const SQLCHAR *s, SQLLEN len, BOOL table_is_valid, ConnectionClass *conn); void schema_appendPQExpBuffer1(PQExpBufferData *buf, const char *fmt, const char *s1, const char *s, BOOL table_is_valid, ConnectionClass *conn); void CC_examine_global_transaction(ConnectionClass *self); BOOL CC_set_transact(ConnectionClass *self, UInt4 isolation); int CC_send_client_encoding(ConnectionClass *self, const char *encoding); /* CC_send_query options */ enum { IGNORE_ABORT_ON_CONN = 1L /* not set the error result even when */ ,CREATE_KEYSET = (1L << 1) /* create keyset for updatable cursors */ ,GO_INTO_TRANSACTION = (1L << 2) /* issue BEGIN in advance */ ,ROLLBACK_ON_ERROR = (1L << 3) /* rollback the query when an error occurs */ ,END_WITH_COMMIT = (1L << 4) /* the query ends with COMMIT command */ ,READ_ONLY_QUERY = (1L << 5) /* the query is read-only */ }; /* CC_on_abort options */ #define NO_TRANS 1L #define CONN_DEAD (1L << 1) /* connection is no longer valid */ /* * This is a libpq notice receiver callback, for handling incoming NOTICE * messages while processing a query. */ typedef struct { ConnectionClass *conn; const char *comment; QResultClass *res; StatementClass *stmt; } notice_receiver_arg; void receive_libpq_notice(void *arg, const PGresult *pgres); /* * internal savepoint related */ #define _RELEASE_INTERNAL_SAVEPOINT /* Internal rollback */ enum { PER_STATEMENT_ROLLBACK = 1 ,PER_QUERY_ROLLBACK }; int CC_internal_rollback(ConnectionClass *, int rollback_type, BOOL ignore_abort); /* Commands generated */ enum { INTERNAL_SAVEPOINT_OPERATION = 1 ,INTERNAL_ROLLBACK_OPERATION }; int GenerateSvpCommand(ConnectionClass *conn, int type, char *cmd, int bufsize); /* Operations in progress */ enum { SAVEPOINT_IN_PROGRESS = 1 ,PREPEND_IN_PROGRESS }; /* StatementSvp entry option */ enum { SVPOPT_RDONLY = 1L ,SVPOPT_REDUCE_ROUNDTRIP = (1L << 1) }; #define INIT_SVPOPT (SVPOPT_RDONLY) #define CC_svp_init(a) ((a)->internal_svp = (a)->internal_op = 0, (a)->opt_in_progress = (a)->opt_previous = INIT_SVPOPT) #define CC_init_opt_in_progress(a) ((a)->opt_in_progress = INIT_SVPOPT) #define CC_init_opt_previous(a) ((a)->opt_previous = INIT_SVPOPT) #ifdef __cplusplus } #endif #endif /* __CONNECTION_H__ */ psqlodbc-REL-16_00_0005/connexp.h000066400000000000000000000042271462406103600163260ustar00rootroot00000000000000/* File: connexp.h * * Description: See "connection.c" * * Comments: See "notice.txt" for copyright and license information. * */ #ifndef __CONNEXPORT_H__ #define __CONNEXPORT_H__ /* * The psqlodbc dll exports functions below used in the pgenlist dll. * */ #undef DLL_DECLARE #ifdef _PGDTC_FUNCS_IMPLEMENT_ #define DLL_DECLARE _declspec(dllexport) #else #ifdef _PGDTC_FUNCS_IMPORT_ #define DLL_DECLARE _declspec(dllimport) #else #define DLL_DECLARE #endif /* _PGDTC_FUNC_IMPORT_ */ #endif /* _PGDTC_FUNCS_IMPLEMENT_ */ #ifdef __cplusplus extern "C" { #endif #define KEYWORD_DTC_CHECK "dtchk" #define DTC_CHECK_LINK_ONLY 1 #define DTC_CHECK_BEFORE_LINK 2 #define DTC_CHECK_RM_CONNECTION 3 /* Property */ enum { inprogress ,enlisted ,inTrans /* read-only */ ,errorNumber /* read_only */ ,idleInGlobalTransaction /* read-only */ ,connected /* read-only */ ,prepareRequested }; /* PgDtc_isolate option */ enum { disposingConnection = 1L ,useAnotherRoom = (1L << 1) }; /* One phase commit operations */ enum { ONE_PHASE_COMMIT = 0 ,ONE_PHASE_ROLLBACK ,ABORT_GLOBAL_TRANSACTION ,SHUTDOWN_LOCAL_TRANSACTION }; /* Two phase commit operations */ enum { PREPARE_TRANSACTION = 0 ,COMMIT_PREPARED ,ROLLBACK_PREPARED }; DLL_DECLARE void PgDtc_create_connect_string(void *self, char *connstr, int strsize); DLL_DECLARE int PgDtc_is_recovery_available(void *self, char *reason, int rsize); DLL_DECLARE void PgDtc_set_async(void *self, void *async); DLL_DECLARE void *PgDtc_get_async(void *self); DLL_DECLARE void PgDtc_set_property(void *self, int property, void *value); DLL_DECLARE void PgDtc_set_error(void *self, const char *message, const char *func); DLL_DECLARE int PgDtc_get_property(void *self, int property); DLL_DECLARE BOOL PgDtc_connect(void *self); DLL_DECLARE void PgDtc_free_connect(void *self); DLL_DECLARE BOOL PgDtc_one_phase_operation(void *self, int operation); DLL_DECLARE BOOL PgDtc_two_phase_operation(void *self, int operation, const char *gxid); DLL_DECLARE BOOL PgDtc_lock_cntrl(void *self, BOOL acquire, BOOL bTrial); DLL_DECLARE void *PgDtc_isolate(void *self, DWORD option); #ifdef __cplusplus } #endif #endif /* __CONNEXPORT_H__ */ psqlodbc-REL-16_00_0005/convert.c000066400000000000000000004771111462406103600163350ustar00rootroot00000000000000/*------- * Module: convert.c * * Description: This module contains routines related to * converting parameters and columns into requested data types. * Parameters are converted from their SQL_C data types into * the appropriate postgres type. Columns are converted from * their postgres type (SQL type) into the appropriate SQL_C * data type. * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ /* Multibyte support Eiji Tokuya 2001-03-15 */ #include "convert.h" #include "unicode_support.h" #include "misc.h" #ifdef WIN32 #include #define HAVE_LOCALE_H #endif /* WIN32 */ #include #include #include #include "multibyte.h" #include #ifdef HAVE_LOCALE_H #include #endif #include #include #include #include "statement.h" #include "qresult.h" #include "bind.h" #include "pgtypes.h" #include "lobj.h" #include "connection.h" #include "catfunc.h" #include "pgapifunc.h" CSTR NAN_STRING = "NaN"; CSTR INFINITY_STRING = "Infinity"; CSTR MINFINITY_STRING = "-Infinity"; #if defined(WIN32) || defined(__CYGWIN__) #define TIMEZONE_GLOBAL _timezone #define TZNAME_GLOBAL _tzname #define DAYLIGHT_GLOBAL _daylight #elif defined(HAVE_INT_TIMEZONE) #define TIMEZONE_GLOBAL timezone #define TZNAME_GLOBAL tzname #define DAYLIGHT_GLOBAL daylight #endif /* * How to map ODBC scalar functions {fn func(args)} to Postgres. * This is just a simple substitution. List augmented from: * http://www.merant.com/datadirect/download/docs/odbc16/Odbcref/rappc.htm * - thomas 2000-04-03 */ static const struct { /* * There's a horrible hack in odbc_name field: if it begins with a %, * the digit after the % indicates the number of arguments. Otherwise, * the entry matches any number of args. */ char *odbc_name; char *pgsql_name; } mapFuncs[] = { /* { "ASCII", "ascii" }, built_in */ {"CHAR", "chr($*)" }, {"CONCAT", "concat($1::text, $2::text)" }, /* { "DIFFERENCE", "difference" }, how to ? */ {"INSERT", "substring($1 from 1 for $2 - 1) || $4 || substring($1 from $2 + $3)" }, {"LCASE", "lower($*)" }, /* {"LEFT", "left" }, built_in */ {"%2LOCATE", "strpos($2, $1)" }, /* 2 parameters */ {"%3LOCATE", "strpos(substring($2 from $3), $1) + $3 - 1" }, /* 3 parameters */ {"LENGTH", "char_length($*)"}, /* { "LTRIM", "ltrim" }, built_in */ /* {"RIGHT", "right" }, built_in */ {"SPACE", "repeat(' ', $1)" }, /* { "REPEAT", "repeat" }, built_in */ /* { "REPLACE", "replace" }, ??? */ /* { "RTRIM", "rtrim" }, built_in */ /* { "SOUNDEX", "soundex" }, how to ? */ {"SUBSTRING", "substr($*)" }, {"UCASE", "upper($*)" }, /* { "ABS", "abs" }, built_in */ /* { "ACOS", "acos" }, built_in */ /* { "ASIN", "asin" }, built_in */ /* { "ATAN", "atan" }, built_in */ /* { "ATAN2", "atan2" }, built_in */ {"CEILING", "ceil($*)" }, /* { "COS", "cos" }, built_in */ /* { "COT", "cot" }, built_in */ /* { "DEGREES", "degrees" }, built_in */ /* { "EXP", "exp" }, built_in */ /* { "FLOOR", "floor" }, built_in */ {"LOG", "ln($*)" }, {"LOG10", "log($*)" }, /* { "MOD", "mod" }, built_in */ /* { "PI", "pi" }, built_in */ /* {"POWER", "power" }, built_in */ /* { "RADIANS", "radians" }, built_in */ {"%0RAND", "random()" }, /* 0 parameters */ {"%1RAND", "(setseed($1) * .0 + random())" }, /* 1 parameters */ /* { "ROUND", "round" }, built_in */ /* { "SIGN", "sign" }, built_in */ /* { "SIN", "sin" }, built_in */ /* { "SQRT", "sqrt" }, built_in */ /* { "TAN", "tan" }, built_in */ {"TRUNCATE", "trunc($*)" }, {"CURRENT_DATE", "current_date" }, {"CURRENT_TIME", "current_time" }, {"CURRENT_TIMESTAMP", "current_timestamp" }, {"LOCALTIME", "localtime" }, {"LOCALTIMESTAMP", "localtimestamp" }, {"CURRENT_USER", "cast(current_user as text)" }, {"SESSION_USER", "cast(session_user as text)" }, {"CURDATE", "current_date" }, {"CURTIME", "current_time" }, {"DAYNAME", "to_char($1, 'Day')" }, {"DAYOFMONTH", "cast(extract(day from $1) as integer)" }, {"DAYOFWEEK", "(cast(extract(dow from $1) as integer) + 1)" }, {"DAYOFYEAR", "cast(extract(doy from $1) as integer)" }, {"HOUR", "cast(extract(hour from $1) as integer)" }, {"MINUTE", "cast(extract(minute from $1) as integer)" }, {"MONTH", "cast(extract(month from $1) as integer)" }, {"MONTHNAME", " to_char($1, 'Month')" }, /* { "NOW", "now" }, built_in */ {"QUARTER", "cast(extract(quarter from $1) as integer)" }, {"SECOND", "cast(extract(second from $1) as integer)" }, {"WEEK", "cast(extract(week from $1) as integer)" }, {"YEAR", "cast(extract(year from $1) as integer)" }, // TIMESTAMPADD() {"TIMESTAMPADD(SQL_TSI_YEAR", "($3+make_interval(years := $2))" }, {"TIMESTAMPADD(SQL_TSI_MONTH", "($3+make_interval(months := $2))" }, {"TIMESTAMPADD(SQL_TSI_WEEK", "($3+make_interval(weeks := $2))" }, {"TIMESTAMPADD(SQL_TSI_DAY", "($3+make_interval(days := $2))" }, {"TIMESTAMPADD(SQL_TSI_HOUR", "($3+make_interval(hours := $2))" }, {"TIMESTAMPADD(SQL_TSI_MINUTE", "($3+make_interval(mins := $2))" }, {"TIMESTAMPADD(SQL_TSI_SECOND", "($3+make_interval(secs := $2))" }, {"TIMESTAMPADD(SQL_TSI_FRAC_SECOND", "($3+make_interval(secs := $2::float / 1000000))" }, // TIMESTAMPDIFF() /* doesn't work properly? {"TIMESTAMPDIFF(SQL_TSI_YEAR", "cast(extract(year from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_MONTH", "cast(extract(month from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_QUARTER", "cast(extract(quarter from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_WEEK", "cast(extract(week from ($3 - $2)) as integer)" }, */ /* {"TIMESTAMPDIFF(SQL_TSI_DAY", "cast(extract(day from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_HOUR", "cast(extract(hour from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_HOUR", "(extract(epoch from $3) - extract(epoch from $2)) / 3600" }, {"TIMESTAMPDIFF(SQL_TSI_MINUTE", "cast(extract(minute from ($3 - $2)) as integer)" }, {"TIMESTAMPDIFF(SQL_TSI_SECOND", "cast(extract(second from ($3 - $2)) as integer)" }, */ {"TIMESTAMPDIFF(SQL_TSI_DAY", "cast((extract(epoch from $3) - extract(epoch from $2)) / (24*60*60) as int)" }, {"TIMESTAMPDIFF(SQL_TSI_HOUR", "cast((extract(epoch from $3) - extract(epoch from $2)) / 3600 as int)" }, {"TIMESTAMPDIFF(SQL_TSI_MINUTE", "cast((extract(epoch from $3) - extract(epoch from $2)) / 60 as int)" }, {"TIMESTAMPDIFF(SQL_TSI_SECOND", "cast((extract(epoch from $3) - extract(epoch from $2)) as int)" }, {"TIMESTAMPDIFF(SQL_TSI_FRAC_SECOND", "mod(cast(extract(second from ($3 - $2)) as numeric), 1.0) * 1000000" }, /* { "EXTRACT", "extract" }, built_in */ /* { "DATABASE", "database" }, */ {"IFNULL", "coalesce($*)" }, {"USER", "cast(current_user as text)" }, {0, 0} }; typedef struct { int infinity; int m; int d; int y; int hh; int mm; int ss; int fr; } SIMPLE_TIME; static const char *mapFunction(const char *func, int param_count, const char * keyword); static BOOL convert_money(const char *s, char *sout, size_t soutmax); static char parse_datetime(const char *buf, SIMPLE_TIME *st); size_t convert_linefeeds(const char *s, char *dst, size_t max, BOOL convlf, BOOL *changed); static size_t convert_from_pgbinary(const char *value, char *rgbValue, SQLLEN cbValueMax); static int convert_lo(StatementClass *stmt, const void *value, SQLSMALLINT fCType, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue); static int conv_from_octal(const char *s); static SQLLEN pg_bin2hex(const char *src, char *dst, SQLLEN length); #ifdef UNICODE_SUPPORT static SQLLEN pg_bin2whex(const char *src, SQLWCHAR *dst, SQLLEN length); #endif /* UNICODE_SUPPORT */ /*--------- * A Guide for date/time/timestamp conversions * * field_type fCType Output * ---------- ------ ---------- * PG_TYPE_DATE SQL_C_DEFAULT SQL_C_DATE * PG_TYPE_DATE SQL_C_DATE SQL_C_DATE * PG_TYPE_DATE SQL_C_TIMESTAMP SQL_C_TIMESTAMP (time = 0 (midnight)) * PG_TYPE_TIME SQL_C_DEFAULT SQL_C_TIME * PG_TYPE_TIME SQL_C_TIME SQL_C_TIME * PG_TYPE_TIME SQL_C_TIMESTAMP SQL_C_TIMESTAMP (date = current date) * PG_TYPE_ABSTIME SQL_C_DEFAULT SQL_C_TIMESTAMP * PG_TYPE_ABSTIME SQL_C_DATE SQL_C_DATE (time is truncated) * PG_TYPE_ABSTIME SQL_C_TIME SQL_C_TIME (date is truncated) * PG_TYPE_ABSTIME SQL_C_TIMESTAMP SQL_C_TIMESTAMP *--------- */ /* * Macros for unsigned long handling. */ #ifdef WIN32 #define ATOI32U(val) strtoul(val, NULL, 10) #elif defined(HAVE_STRTOUL) #define ATOI32U(val) strtoul(val, NULL, 10) #else /* HAVE_STRTOUL */ #define ATOI32U atol #endif /* WIN32 */ /* * Macros for BIGINT handling. */ #ifdef ODBCINT64 #ifdef WIN32 #define ATOI64(val) _strtoi64(val, NULL, 10) #define ATOI64U(val) _strtoui64(val, NULL, 10) #elif (SIZEOF_LONG == 8) #define ATOI64(val) strtol(val, NULL, 10) #define ATOI64U(val) strtoul(val, NULL, 10) #else #if defined(HAVE_STRTOLL) #define ATOI64(val) strtoll(val, NULL, 10) #define ATOI64U(val) strtoull(val, NULL, 10) #else static ODBCINT64 ATOI64(const char *val) { ODBCINT64 ll; sscanf(val, "%lld", &ll); return ll; } static unsigned ODBCINT64 ATOI64U(const char *val) { unsigned ODBCINT64 ll; sscanf(val, "%llu", &ll); return ll; } #endif /* HAVE_STRTOLL */ #endif /* WIN32 */ #endif /* ODBCINT64 */ static void ResolveNumericParam(const SQL_NUMERIC_STRUCT *ns, char *chrform); static void parse_to_numeric_struct(const char *wv, SQL_NUMERIC_STRUCT *ns, BOOL *overflow); /* * TIMESTAMP <-----> SIMPLE_TIME * precision support since 7.2. * time zone support is unavailable(the stuff is unreliable) */ static BOOL timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone) { char rest[64], bc[16], *ptr; int scnt, i; int y, m, d, hh, mm, ss; #ifdef TIMEZONE_GLOBAL long timediff; #endif BOOL withZone = *bZone; *bZone = FALSE; *zone = 0; st->fr = 0; st->infinity = 0; rest[0] = '\0'; bc[0] = '\0'; if ((scnt = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d%31s %15s", &y, &m, &d, &hh, &mm, &ss, rest, bc)) < 6) { if (scnt == 3) /* date */ { st->y = y; st->m = m; st->d = d; st->hh = 0; st->mm = 0; st->ss = 0; return TRUE; } if ((scnt = sscanf(str, "%2d:%2d:%2d%31s %15s", &hh, &mm, &ss, rest, bc)) < 3) return FALSE; else { st->hh = hh; st->mm = mm; st->ss = ss; if (scnt == 3) /* time */ return TRUE; } } else { st->y = y; st->m = m; st->d = d; st->hh = hh; st->mm = mm; st->ss = ss; if (scnt == 6) return TRUE; } switch (rest[0]) { case '+': *bZone = TRUE; *zone = atoi(&rest[1]); break; case '-': *bZone = TRUE; *zone = -atoi(&rest[1]); break; case '.': if ((ptr = strchr(rest, '+')) != NULL) { *bZone = TRUE; *zone = atoi(&ptr[1]); *ptr = '\0'; } else if ((ptr = strchr(rest, '-')) != NULL) { *bZone = TRUE; *zone = -atoi(&ptr[1]); *ptr = '\0'; } for (i = 1; i < 10; i++) { if (!isdigit((UCHAR) rest[i])) break; } for (; i < 10; i++) rest[i] = '0'; rest[i] = '\0'; st->fr = atoi(&rest[1]); break; case 'B': if (stricmp(rest, "BC") == 0) st->y *= -1; return TRUE; default: return TRUE; } if (stricmp(bc, "BC") == 0) { st->y *= -1; } if (!withZone || !*bZone || st->y < 1970) return TRUE; #ifdef TIMEZONE_GLOBAL if (!TZNAME_GLOBAL[0] || !TZNAME_GLOBAL[0][0]) { *bZone = FALSE; return TRUE; } timediff = TIMEZONE_GLOBAL + (*zone) * 3600; if (!DAYLIGHT_GLOBAL && timediff == 0) /* the same timezone */ return TRUE; else { struct tm tm, *tm2; time_t time0; *bZone = FALSE; tm.tm_year = st->y - 1900; tm.tm_mon = st->m - 1; tm.tm_mday = st->d; tm.tm_hour = st->hh; tm.tm_min = st->mm; tm.tm_sec = st->ss; tm.tm_isdst = -1; time0 = mktime(&tm); if (time0 < 0) return TRUE; if (tm.tm_isdst > 0) timediff -= 3600; if (timediff == 0) /* the same time zone */ return TRUE; time0 -= timediff; #ifdef HAVE_LOCALTIME_R if (time0 >= 0 && (tm2 = localtime_r(&time0, &tm)) != NULL) #else if (time0 >= 0 && (tm2 = localtime(&time0)) != NULL) #endif /* HAVE_LOCALTIME_R */ { st->y = tm2->tm_year + 1900; st->m = tm2->tm_mon + 1; st->d = tm2->tm_mday; st->hh = tm2->tm_hour; st->mm = tm2->tm_min; st->ss = tm2->tm_sec; *bZone = TRUE; } } #endif /* TIMEZONE_GLOBAL */ return TRUE; } static int stime2timestamp(const SIMPLE_TIME *st, char *str, size_t bufsize, BOOL bZone, int precision) { char precstr[16], zonestr[16]; int i; precstr[0] = '\0'; if (st->infinity > 0) { return snprintf(str, bufsize, "%s", INFINITY_STRING); } else if (st->infinity < 0) { return snprintf(str, bufsize, "%s", MINFINITY_STRING); } if (precision > 0 && st->fr) { SPRINTF_FIXED(precstr, ".%09d", st->fr); if (precision < 9) precstr[precision + 1] = '\0'; else if (precision > 9) precision = 9; for (i = precision; i > 0; i--) { if (precstr[i] != '0') break; precstr[i] = '\0'; } if (i == 0) precstr[i] = '\0'; } zonestr[0] = '\0'; #ifdef TIMEZONE_GLOBAL if (bZone && TZNAME_GLOBAL[0] && TZNAME_GLOBAL[0][0] && st->y >= 1970) { long zoneint; struct tm tm; time_t time0; zoneint = TIMEZONE_GLOBAL; if (DAYLIGHT_GLOBAL && st->y >= 1900) { tm.tm_year = st->y - 1900; tm.tm_mon = st->m - 1; tm.tm_mday = st->d; tm.tm_hour = st->hh; tm.tm_min = st->mm; tm.tm_sec = st->ss; tm.tm_isdst = -1; time0 = mktime(&tm); if (time0 >= 0 && tm.tm_isdst > 0) zoneint -= 3600; } if (zoneint > 0) SPRINTF_FIXED(zonestr, "-%02d", (int) zoneint / 3600); else SPRINTF_FIXED(zonestr, "+%02d", -(int) zoneint / 3600); } #endif /* TIMEZONE_GLOBAL */ if (st->y < 0) return snprintf(str, bufsize, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d%s%s BC", -st->y, st->m, st->d, st->hh, st->mm, st->ss, precstr, zonestr); else return snprintf(str, bufsize, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d%s%s", st->y, st->m, st->d, st->hh, st->mm, st->ss, precstr, zonestr); } static SQLINTERVAL interval2itype(SQLSMALLINT ctype) { SQLINTERVAL sqlitv = 0; switch (ctype) { case SQL_C_INTERVAL_YEAR: sqlitv = SQL_IS_YEAR; break; case SQL_C_INTERVAL_MONTH: sqlitv = SQL_IS_MONTH; break; case SQL_C_INTERVAL_YEAR_TO_MONTH: sqlitv = SQL_IS_YEAR_TO_MONTH; break; case SQL_C_INTERVAL_DAY: sqlitv = SQL_IS_DAY; break; case SQL_C_INTERVAL_HOUR: sqlitv = SQL_IS_HOUR; break; case SQL_C_INTERVAL_DAY_TO_HOUR: sqlitv = SQL_IS_DAY_TO_HOUR; break; case SQL_C_INTERVAL_MINUTE: sqlitv = SQL_IS_MINUTE; break; case SQL_C_INTERVAL_DAY_TO_MINUTE: sqlitv = SQL_IS_DAY_TO_MINUTE; break; case SQL_C_INTERVAL_HOUR_TO_MINUTE: sqlitv = SQL_IS_HOUR_TO_MINUTE; break; case SQL_C_INTERVAL_SECOND: sqlitv = SQL_IS_SECOND; break; case SQL_C_INTERVAL_DAY_TO_SECOND: sqlitv = SQL_IS_DAY_TO_SECOND; break; case SQL_C_INTERVAL_HOUR_TO_SECOND: sqlitv = SQL_IS_HOUR_TO_SECOND; break; case SQL_C_INTERVAL_MINUTE_TO_SECOND: sqlitv = SQL_IS_MINUTE_TO_SECOND; break; } return sqlitv; } /* * Interval data <-----> SQL_INTERVAL_STRUCT */ static int getPrecisionPart(int precision, const char * precPart) { char fraction[] = "000000000"; int fracs = sizeof(fraction) - 1; size_t cpys; if (precision < 0) precision = 6; /* default */ if (precision == 0) return 0; cpys = strlen(precPart); if (cpys > fracs) cpys = fracs; memcpy(fraction, precPart, cpys); fraction[precision] = '\0'; return atoi(fraction); } static BOOL interval2istruct(SQLSMALLINT ctype, int precision, const char *str, SQL_INTERVAL_STRUCT *st) { char lit1[64], lit2[64]; int scnt, years, mons, days, hours, minutes, seconds; BOOL sign; SQLINTERVAL itype = interval2itype(ctype); memset(st, 0, sizeof(SQL_INTERVAL_STRUCT)); if ((scnt = sscanf(str, "%d-%d", &years, &mons)) >=2) { if (SQL_IS_YEAR_TO_MONTH == itype) { sign = years < 0 ? SQL_TRUE : SQL_FALSE; st->interval_type = itype; st->interval_sign = sign; st->intval.year_month.year = sign ? (-years) : years; st->intval.year_month.month = mons; return TRUE; } return FALSE; } else if (scnt = sscanf(str, "%d %02d:%02d:%02d.%09s", &days, &hours, &minutes, &seconds, lit2), 5 == scnt || 4 == scnt) { sign = days < 0 ? SQL_TRUE : SQL_FALSE; st->interval_type = itype; st->interval_sign = sign; st->intval.day_second.day = sign ? (-days) : days; st->intval.day_second.hour = hours; st->intval.day_second.minute = minutes; st->intval.day_second.second = seconds; if (scnt > 4) st->intval.day_second.fraction = getPrecisionPart(precision, lit2); return TRUE; } else if ((scnt = sscanf(str, "%d %10s %d %10s", &years, lit1, &mons, lit2)) >=4) { if (strnicmp(lit1, "year", 4) == 0 && strnicmp(lit2, "mon", 2) == 0 && (SQL_IS_MONTH == itype || SQL_IS_YEAR_TO_MONTH == itype)) { sign = years < 0 ? SQL_TRUE : SQL_FALSE; st->interval_type = itype; st->interval_sign = sign; st->intval.year_month.year = sign ? (-years) : years; st->intval.year_month.month = sign ? (-mons) : mons; return TRUE; } return FALSE; } if ((scnt = sscanf(str, "%d %10s %d", &years, lit1, &days)) == 2) { sign = years < 0 ? SQL_TRUE : SQL_FALSE; if (SQL_IS_YEAR == itype && (stricmp(lit1, "year") == 0 || stricmp(lit1, "years") == 0)) { st->interval_type = itype; st->interval_sign = sign; st->intval.year_month.year = sign ? (-years) : years; return TRUE; } if (SQL_IS_MONTH == itype && (stricmp(lit1, "mon") == 0 || stricmp(lit1, "mons") == 0)) { st->interval_type = itype; st->interval_sign = sign; st->intval.year_month.month = sign ? (-years) : years; return TRUE; } if (SQL_IS_DAY == itype && (stricmp(lit1, "day") == 0 || stricmp(lit1, "days") == 0)) { st->interval_type = itype; st->interval_sign = sign; st->intval.day_second.day = sign ? (-years) : years; return TRUE; } return FALSE; } if (itype == SQL_IS_YEAR || itype == SQL_IS_MONTH || itype == SQL_IS_YEAR_TO_MONTH) { /* these formats should've been handled above already */ return FALSE; } scnt = sscanf(str, "%d %10s %02d:%02d:%02d.%09s", &days, lit1, &hours, &minutes, &seconds, lit2); if (scnt == 5 || scnt == 6) { if (strnicmp(lit1, "day", 3) != 0) return FALSE; sign = days < 0 ? SQL_TRUE : SQL_FALSE; st->interval_type = itype; st->interval_sign = sign; st->intval.day_second.day = sign ? (-days) : days; st->intval.day_second.hour = sign ? (-hours) : hours; st->intval.day_second.minute = minutes; st->intval.day_second.second = seconds; if (scnt > 5) st->intval.day_second.fraction = getPrecisionPart(precision, lit2); return TRUE; } scnt = sscanf(str, "%02d:%02d:%02d.%09s", &hours, &minutes, &seconds, lit2); if (scnt == 3 || scnt == 4) { sign = hours < 0 ? SQL_TRUE : SQL_FALSE; st->interval_type = itype; st->interval_sign = sign; st->intval.day_second.hour = sign ? (-hours) : hours; st->intval.day_second.minute = minutes; st->intval.day_second.second = seconds; if (scnt > 3) st->intval.day_second.fraction = getPrecisionPart(precision, lit2); return TRUE; } return FALSE; } #ifdef HAVE_LOCALE_H /* * Get the decimal point of the current locale. * * XXX: This isn't thread-safe, if another thread changes the locale with * setlocale() concurrently. There are two problems with that: * * 1. The pointer returned by localeconv(), or the lc->decimal_point string, * might be invalidated by calls in other threads. Until someone comes up * with a thread-safe version of localeconv(), there isn't much we can do * about that. (libc implementations that return a static buffer (like glibc) * happen to be safe from the lconv struct being invalidated, but the * decimal_point string might still not point to a static buffer). * * 2. The between the call to sprintf() and get_current_decimal_point(), the * decimal point might change. That would cause set_server_decimal_point() * to fail to recognize a decimal separator, and we might send a numeric * string to the server that the server won't recognize. This would cause * the query to fail in the server. * * XXX: we only take into account the first byte of the decimal separator. */ static char get_current_decimal_point(void) { struct lconv *lc = localeconv(); return lc->decimal_point[0]; } /* * Modify the string representation of a numeric/float value, converting the * decimal point from '.' to the correct decimal separator of the current * locale. */ static void set_server_decimal_point(char *num, SQLLEN len) { char current_decimal_point = get_current_decimal_point(); char *str; SQLLEN i; if ('.' == current_decimal_point) return; i = 0; for (str = num; '\0' != *str; str++) { if (*str == current_decimal_point) { *str = '.'; break; } if (len != SQL_NTS && i++ >= len) break; } } /* * Inverse of set_server_decimal_point. */ static void set_client_decimal_point(char *num) { char current_decimal_point = get_current_decimal_point(); char *str; if ('.' == current_decimal_point) return; for (str = num; '\0' != *str; str++) { if (*str == '.') { *str = current_decimal_point; break; } } } #else static void set_server_decimal_point(char *num) {} static void set_client_decimal_point(char *num, BOOL) {} #endif /* HAVE_LOCALE_H */ /* This is called by SQLFetch() */ int copy_and_convert_field_bindinfo(StatementClass *stmt, OID field_type, int atttypmod, void *value, int col) { ARDFields *opts = SC_get_ARDF(stmt); BindInfoClass *bic; SQLULEN offset = opts->row_offset_ptr ? *opts->row_offset_ptr : 0; if (opts->allocated <= col) extend_column_bindings(opts, col + 1); bic = &(opts->bindings[col]); SC_set_current_col(stmt, -1); return copy_and_convert_field(stmt, field_type, atttypmod, value, bic->returntype, bic->precision, (PTR) (bic->buffer + offset), bic->buflen, LENADDR_SHIFT(bic->used, offset), LENADDR_SHIFT(bic->indicator, offset)); } /* * Is 'str' a valid integer literal, consisting only of ASCII characters * 0-9 ? * * Also, *negative is set to TRUE if the value was negative. * * We don't check for overflow here. This is just to decide if we need to * quote the value. */ static BOOL valid_int_literal(const char *str, SQLLEN len, BOOL *negative) { SQLLEN i = 0; /* Check there is a minus sign in front */ if ((len == SQL_NTS || len > 0) && str[0] == '-') { i++; *negative = TRUE; } else *negative = FALSE; /* * Must begin with a digit. This also rejects empty strings and '-'. */ if (i == len || !(str[i] >= '0' && str[i] <= '9')) return FALSE; for (; str[i] && (len == SQL_NTS || i < len); i++) { if (!(str[i] >= '0' && str[i] <= '9')) return FALSE; } return TRUE; } static double get_double_value(const char *str) { if (stricmp(str, NAN_STRING) == 0) #ifdef NAN return (double) NAN; #else { double a = .0; return .0 / a; } #endif /* NAN */ else if (stricmp(str, INFINITY_STRING) == 0) #ifdef INFINITY return (double) INFINITY; #else return (double) (HUGE_VAL * HUGE_VAL); #endif /* INFINITY */ else if (stricmp(str, MINFINITY_STRING) == 0) #ifdef INFINITY return (double) -INFINITY; #else return (double) -(HUGE_VAL * HUGE_VAL); #endif /* INFINITY */ return atof(str); } static int char2guid(const char *str, SQLGUID *g) { /* * SQLGUID.Data1 is an "unsigned long" on some platforms, and * "unsigned int" on others. For format "%08X", it should be an * "unsigned int", so use a temporary variable for it. */ unsigned int Data1; if (sscanf(str, "%08X-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX", &Data1, &g->Data2, &g->Data3, &g->Data4[0], &g->Data4[1], &g->Data4[2], &g->Data4[3], &g->Data4[4], &g->Data4[5], &g->Data4[6], &g->Data4[7]) < 11) return COPY_GENERAL_ERROR; g->Data1 = Data1; return COPY_OK; } static int effective_fraction(int fraction, int *width) { for (*width = 9; fraction % 10 == 0; (*width)--, fraction /= 10) ; return fraction; } static int get_terminator_len(SQLSMALLINT fCType) { switch (fCType) { #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: return WCLEN; #endif /* UNICODE_SUPPORT */ case SQL_C_BINARY: return 0; } /* SQL_C_CHAR or INTERNAL_ASIS_TYPE */ return 1; } static SQLLEN get_adjust_len(SQLSMALLINT fCType, SQLLEN len) { switch (fCType) { #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: return (len / WCLEN) * WCLEN; #endif /* UNICODE_SUPPORT */ } return len; } #define BYTEA_PROCESS_ESCAPE 1 #define BYTEA_PROCESS_BINARY 2 static int setup_getdataclass(SQLLEN * const length_return, const char ** const ptr_return, int *needbuflen_return, GetDataClass * const pgdc, const char *neut_str, const OID field_type, const SQLSMALLINT fCType, const SQLLEN cbValueMax, const ConnectionClass * const conn) { SQLLEN len = (-2); const char *ptr = NULL; int needbuflen = 0; int result = COPY_OK; BOOL lf_conv = conn->connInfo.lf_conversion; int bytea_process_kind = 0; BOOL already_processed = FALSE; BOOL changed = FALSE; int len_for_wcs_term = 0; #ifdef UNICODE_SUPPORT char *allocbuf = NULL; int unicode_count = -1; BOOL localize_needed = FALSE; BOOL hybrid = FALSE; #endif /* UNICODE_SUPPORT */ if (PG_TYPE_BYTEA == field_type) { if (SQL_C_BINARY == fCType) bytea_process_kind = BYTEA_PROCESS_BINARY; else if (0 == strnicmp(neut_str, "\\x", 2)) /* hex format */ neut_str += 2; else bytea_process_kind = BYTEA_PROCESS_ESCAPE; } #ifdef UNICODE_SUPPORT if (0 == bytea_process_kind) { if (get_convtype() > 0) /* conversion between the current locale is available */ { BOOL wcs_debug = conn->connInfo.wcs_debug; BOOL same_encoding = (conn->ccsc == pg_CS_code(conn->locale_encoding)); BOOL is_utf8 = (UTF8 == conn->ccsc); switch (field_type) { case PG_TYPE_UNKNOWN: case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: case PG_TYPE_BPCHARARRAY: case PG_TYPE_VARCHARARRAY: case PG_TYPE_TEXTARRAY: if (SQL_C_CHAR == fCType || SQL_C_BINARY == fCType) localize_needed = (!same_encoding || wcs_debug); if (SQL_C_WCHAR == fCType) hybrid = (!is_utf8 || (same_encoding && wcs_debug)); } MYLOG(0, "localize=%d hybrid=%d is_utf8=%d same_encoding=%d wcs_debug=%d\n", localize_needed, hybrid, is_utf8, same_encoding, wcs_debug); } } if (fCType == SQL_C_WCHAR) { if (BYTEA_PROCESS_ESCAPE == bytea_process_kind) unicode_count = convert_from_pgbinary(neut_str, NULL, 0) * 2; else if (hybrid) { MYLOG(0, "hybrid estimate\n"); if ((unicode_count = bindcol_hybrid_estimate(neut_str, lf_conv, &allocbuf)) < 0) { result = COPY_INVALID_STRING_CONVERSION; goto cleanup; } } else /* normally */ { unicode_count = utf8_to_ucs2_lf(neut_str, SQL_NTS, lf_conv, NULL, 0, FALSE); } len = WCLEN * unicode_count; already_processed = changed = TRUE; } else if (localize_needed) { if ((len = bindcol_localize_estimate(neut_str, lf_conv, &allocbuf)) < 0) { result = COPY_INVALID_STRING_CONVERSION; goto cleanup; } already_processed = changed = TRUE; } #endif /* UNICODE_SUPPORT */ if (already_processed) /* skip */ ; else if (0 != bytea_process_kind) { len = convert_from_pgbinary(neut_str, NULL, 0); if (BYTEA_PROCESS_BINARY != bytea_process_kind) len *= 2; changed = TRUE; } else /* convert linefeeds to carriage-return/linefeed */ len = convert_linefeeds(neut_str, NULL, 0, lf_conv, &changed); /* just returns length info */ if (cbValueMax == 0) { result = COPY_RESULT_TRUNCATED; goto cleanup; } if (!pgdc->ttlbuf) pgdc->ttlbuflen = 0; needbuflen = len + get_terminator_len(fCType); if (SQL_C_BINARY == fCType) { /* * Though Binary doesn't have NULL terminator, * bindcol_localize_exec() needs output buffer * for NULL terminator. */ len_for_wcs_term = 1; } if (changed || needbuflen > cbValueMax) { if (needbuflen > (SQLLEN) pgdc->ttlbuflen) { pgdc->ttlbuf = realloc(pgdc->ttlbuf, needbuflen + len_for_wcs_term); pgdc->ttlbuflen = needbuflen; } already_processed = FALSE; #ifdef UNICODE_SUPPORT if (fCType == SQL_C_WCHAR) { if (BYTEA_PROCESS_ESCAPE == bytea_process_kind) { len = convert_from_pgbinary(neut_str, pgdc->ttlbuf, pgdc->ttlbuflen); len = pg_bin2whex(pgdc->ttlbuf, (SQLWCHAR *) pgdc->ttlbuf, len); } else { if (!hybrid) /* normally */ utf8_to_ucs2_lf(neut_str, SQL_NTS, lf_conv, (SQLWCHAR *) pgdc->ttlbuf, unicode_count, FALSE); else /* hybrid */ { MYLOG(0, "hybrid convert\n"); if (bindcol_hybrid_exec((SQLWCHAR *) pgdc->ttlbuf, neut_str, unicode_count + 1, lf_conv, &allocbuf) < 0) { result = COPY_INVALID_STRING_CONVERSION; goto cleanup; } } } already_processed = TRUE; } else if (localize_needed) { if (bindcol_localize_exec(pgdc->ttlbuf, len + 1, lf_conv, &allocbuf) < 0) { result = COPY_INVALID_STRING_CONVERSION; goto cleanup; } already_processed = TRUE; } #endif /* UNICODE_SUPPORT */ if (already_processed) ; else if (0 != bytea_process_kind) { len = convert_from_pgbinary(neut_str, pgdc->ttlbuf, pgdc->ttlbuflen); if (BYTEA_PROCESS_ESCAPE == bytea_process_kind) len = pg_bin2hex(pgdc->ttlbuf, pgdc->ttlbuf, len); } else convert_linefeeds(neut_str, pgdc->ttlbuf, pgdc->ttlbuflen, lf_conv, &changed); ptr = pgdc->ttlbuf; pgdc->ttlbufused = len; } else { if (pgdc->ttlbuf) { free(pgdc->ttlbuf); pgdc->ttlbuf = NULL; } ptr = neut_str; } cleanup: #ifdef UNICODE_SUPPORT if (allocbuf) free(allocbuf); #endif /* UNICODE_SUPPORT */ *length_return = len; *ptr_return = ptr; *needbuflen_return = needbuflen; return result; } /* gdata SC_get_GDTI(stmt) current_col stmt->current_col */ /* * fCType treated in the following function is * * SQL_C_CHAR, SQL_C_BINARY, SQL_C_WCHAR or INTERNAL_ASIS_TYPE */ static int convert_text_field_to_sql_c(GetDataInfo * const gdata, const int current_col, const char * const neut_str, const OID field_type, const SQLSMALLINT fCType, char * const rgbValueBindRow, const SQLLEN cbValueMax, const ConnectionClass * const conn, SQLLEN * const length_return) { int result = COPY_OK; SQLLEN len = (-2); GetDataClass *pgdc; int copy_len = 0, needbuflen = 0, i; const char *ptr; MYLOG(0, "field_type=%u type=%d\n", field_type, fCType); switch (field_type) { case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_NUMERIC: set_client_decimal_point((char *) neut_str); break; } if (current_col < 0) { pgdc = &(gdata->fdata); pgdc->data_left = -1; } else pgdc = &gdata->gdata[current_col]; if (pgdc->data_left < 0) { if (COPY_OK != (result = setup_getdataclass(&len, &ptr, &needbuflen, pgdc, neut_str, field_type, fCType, cbValueMax, conn))) goto cleanup; } else { ptr = pgdc->ttlbuf; len = pgdc->ttlbufused; } MYLOG(0, "DEFAULT: len = " FORMAT_LEN ", ptr = '%.*s'\n", len, (int) len, ptr); if (current_col >= 0) { if (pgdc->data_left > 0) { ptr += (len - pgdc->data_left); len = pgdc->data_left; needbuflen = len + (pgdc->ttlbuflen - pgdc->ttlbufused); } else pgdc->data_left = len; } if (cbValueMax > 0) { BOOL already_copied = FALSE; int terminatorlen; terminatorlen = get_terminator_len(fCType); if (terminatorlen >= cbValueMax) copy_len = 0; else if (len + terminatorlen > cbValueMax) copy_len = get_adjust_len(fCType, cbValueMax - terminatorlen); else copy_len = len; if (!already_copied) { /* Copy the data */ if (copy_len > 0) memcpy(rgbValueBindRow, ptr, copy_len); /* Add null terminator */ for (i = 0; i < terminatorlen && copy_len + i < cbValueMax; i++) rgbValueBindRow[copy_len + i] = '\0'; } /* Adjust data_left for next time */ if (current_col >= 0) pgdc->data_left -= copy_len; } /* * Finally, check for truncation so that proper status can * be returned */ if (cbValueMax > 0 && needbuflen > cbValueMax) result = COPY_RESULT_TRUNCATED; else { if (pgdc->ttlbuf != NULL) { free(pgdc->ttlbuf); pgdc->ttlbuf = NULL; } } #ifdef UNICODE_SUPPORT if (SQL_C_WCHAR == fCType) MYLOG(0, " SQL_C_WCHAR, default: len = " FORMAT_LEN ", cbValueMax = " FORMAT_LEN ", rgbValueBindRow = '%s'\n", len, cbValueMax, rgbValueBindRow); else #endif /* UNICODE_SUPPORT */ if (SQL_C_BINARY == fCType) MYLOG(0, " SQL_C_BINARY, default: len = " FORMAT_LEN ", cbValueMax = " FORMAT_LEN ", rgbValueBindRow = '%.*s'\n", len, cbValueMax, copy_len, rgbValueBindRow); else MYLOG(0, " SQL_C_CHAR, default: len = " FORMAT_LEN ", cbValueMax = " FORMAT_LEN ", rgbValueBindRow = '%s'\n", len, cbValueMax, rgbValueBindRow); cleanup: *length_return = len; return result; } /* This is called by SQLGetData() */ int copy_and_convert_field(StatementClass *stmt, OID field_type, int atttypmod, void *valuei, SQLSMALLINT fCType, int precision, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue, SQLLEN *pIndicator) { CSTR func = "copy_and_convert_field"; const char *value = valuei; ARDFields *opts = SC_get_ARDF(stmt); GetDataInfo *gdata = SC_get_GDTI(stmt); SQLLEN len = 0; SIMPLE_TIME std_time; #ifdef HAVE_LOCALTIME_R struct tm tm; #endif /* HAVE_LOCALTIME_R */ SQLLEN pcbValueOffset, rgbValueOffset; char *rgbValueBindRow = NULL; SQLLEN *pcbValueBindRow = NULL, *pIndicatorBindRow = NULL; SQLSETPOSIROW bind_row = stmt->bind_row; int bind_size = opts->bind_size; int result = COPY_OK; const ConnectionClass *conn = SC_get_conn(stmt); BOOL text_bin_handling; const char *neut_str = value; char booltemp[3]; char midtemp[64]; GetDataClass *pgdc; if (stmt->current_col >= 0) { if (stmt->current_col >= opts->allocated) { return SQL_ERROR; } if (gdata->allocated != opts->allocated) extend_getdata_info(gdata, opts->allocated, TRUE); pgdc = &gdata->gdata[stmt->current_col]; if (pgdc->data_left == -2) pgdc->data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be * * needed by ADO ? */ if (pgdc->data_left == 0) { if (pgdc->ttlbuf != NULL) { free(pgdc->ttlbuf); pgdc->ttlbuf = NULL; pgdc->ttlbuflen = 0; } pgdc->data_left = -2; /* needed by ADO ? */ return COPY_NO_DATA_FOUND; } } /*--------- * rgbValueOffset is *ONLY* for character and binary data. * pcbValueOffset is for computing any pcbValue location *--------- */ if (bind_size > 0) pcbValueOffset = rgbValueOffset = (bind_size * bind_row); else { pcbValueOffset = bind_row * sizeof(SQLLEN); rgbValueOffset = bind_row * cbValueMax; } /* * The following is applicable in case bind_size > 0 * or the fCType is of variable length. */ if (rgbValue) rgbValueBindRow = (char *) rgbValue + rgbValueOffset; if (pcbValue) pcbValueBindRow = LENADDR_SHIFT(pcbValue, pcbValueOffset); if (pIndicator) { pIndicatorBindRow = LENADDR_SHIFT(pIndicator, pcbValueOffset); *pIndicatorBindRow = 0; } memset(&std_time, 0, sizeof(SIMPLE_TIME)); MYLOG(0, "field_type = %d, fctype = %d, value = '%s', cbValueMax=" FORMAT_LEN "\n", field_type, fCType, (value == NULL) ? "" : value, cbValueMax); if (!value) { MYLOG(0, "null_cvt_date_string=%d\n", conn->connInfo.cvt_null_date_string); /* a speicial handling for FOXPRO NULL -> NULL_STRING */ if (conn->connInfo.cvt_null_date_string > 0 && (PG_TYPE_DATE == field_type || PG_TYPE_DATETIME == field_type || PG_TYPE_TIMESTAMP_NO_TMZONE == field_type) && (SQL_C_CHAR == fCType || #ifdef UNICODE_SUPPORT SQL_C_WCHAR == fCType || #endif /* UNICODE_SUPPORT */ SQL_C_DATE == fCType || SQL_C_TYPE_DATE == fCType || SQL_C_DEFAULT == fCType)) { if (pcbValueBindRow) *pcbValueBindRow = 0; switch (fCType) { case SQL_C_CHAR: if (rgbValueBindRow && cbValueMax > 0) *rgbValueBindRow = '\0'; else result = COPY_RESULT_TRUNCATED; break; case SQL_C_DATE: case SQL_C_TYPE_DATE: case SQL_C_DEFAULT: if (rgbValueBindRow && cbValueMax >= sizeof(DATE_STRUCT)) { memset(rgbValueBindRow, 0, cbValueMax); if (pcbValueBindRow) *pcbValueBindRow = sizeof(DATE_STRUCT); } else result = COPY_RESULT_TRUNCATED; break; #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: if (rgbValueBindRow && cbValueMax >= WCLEN) memset(rgbValueBindRow, 0, WCLEN); else result = COPY_RESULT_TRUNCATED; break; #endif /* UNICODE_SUPPORT */ } return result; } /* * handle a null just by returning SQL_NULL_DATA in pcbValue, and * doing nothing to the buffer. */ else if (pIndicator) { *pIndicatorBindRow = SQL_NULL_DATA; return COPY_OK; } else { SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT_INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was retrieved", func); return SQL_ERROR; } } if (stmt->hdbc->DataSourceToDriver != NULL) { size_t length = strlen(value); stmt->hdbc->DataSourceToDriver(stmt->hdbc->translation_option, SQL_CHAR, valuei, (SDWORD) length, valuei, (SDWORD) length, NULL, NULL, 0, NULL); } /* * First convert any specific postgres types into more useable data. * * NOTE: Conversions from PG char/varchar of a date/time/timestamp value * to SQL_C_DATE,SQL_C_TIME, SQL_C_TIMESTAMP not supported */ switch (field_type) { /* * $$$ need to add parsing for date/time/timestamp strings in * PG_TYPE_CHAR,VARCHAR $$$ */ case PG_TYPE_DATE: sscanf(value, "%4d-%2d-%2d", &std_time.y, &std_time.m, &std_time.d); break; case PG_TYPE_TIME: { BOOL bZone = FALSE; /* time zone stuff is unreliable */ int zone; timestamp2stime(value, &std_time, &bZone, &zone); } break; case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: std_time.fr = 0; std_time.infinity = 0; if (strnicmp(value, INFINITY_STRING, 8) == 0) { std_time.infinity = 1; std_time.m = 12; std_time.d = 31; std_time.y = 9999; std_time.hh = 23; std_time.mm = 59; std_time.ss = 59; } if (strnicmp(value, MINFINITY_STRING, 9) == 0) { std_time.infinity = -1; std_time.m = 1; std_time.d = 1; // std_time.y = -4713; std_time.y = -9999; std_time.hh = 0; std_time.mm = 0; std_time.ss = 0; } if (strnicmp(value, "invalid", 7) != 0) { BOOL bZone = field_type != PG_TYPE_TIMESTAMP_NO_TMZONE; int zone; /* * sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &std_time.y, &std_time.m, * &std_time.d, &std_time.hh, &std_time.mm, &std_time.ss); */ bZone = FALSE; /* time zone stuff is unreliable */ timestamp2stime(value, &std_time, &bZone, &zone); MYLOG(DETAIL_LOG_LEVEL, "2stime fr=%d\n", std_time.fr); } else { /* * The timestamp is invalid so set something conspicuous, * like the epoch */ struct tm *tim; time_t t = 0; #ifdef HAVE_LOCALTIME_R tim = localtime_r(&t, &tm); #else tim = localtime(&t); #endif /* HAVE_LOCALTIME_R */ std_time.m = tim->tm_mon + 1; std_time.d = tim->tm_mday; std_time.y = tim->tm_year + 1900; std_time.hh = tim->tm_hour; std_time.mm = tim->tm_min; std_time.ss = tim->tm_sec; } break; case PG_TYPE_BOOL: { /* change T/F to 1/0 */ const ConnInfo *ci = &(conn->connInfo); switch (((char *)value)[0]) { case 'f': case 'F': case 'n': case 'N': case '0': STRCPY_FIXED(booltemp, "0"); break; default: if (ci->true_is_minus1) STRCPY_FIXED(booltemp, "-1"); else STRCPY_FIXED(booltemp, "1"); } neut_str = booltemp; } break; /* This is for internal use by SQLStatistics() */ case PG_TYPE_INT2VECTOR: if (SQL_C_DEFAULT == fCType) { int i, nval, maxc; const char *vp; /* this is an array of eight integers */ short *short_array = (short *) rgbValueBindRow, shortv; maxc = 0; if (NULL != short_array) maxc = (int) cbValueMax / sizeof(short); vp = value; nval = 0; MYLOG(0, "index=("); for (i = 0;; i++) { if (sscanf(vp, "%hi", &shortv) != 1) break; MYPRINTF(0, " %hi", shortv); nval++; if (nval < maxc) short_array[i + 1] = shortv; /* skip the current token */ while (IS_NOT_SPACE(*vp)) vp++; /* and skip the space to the next token */ while ((*vp != '\0') && (isspace(*vp))) vp++; if (*vp == '\0') break; } MYPRINTF(0, ") nval = %i\n", nval); if (maxc > 0) short_array[0] = nval; /* There is no corresponding fCType for this. */ len = (nval + 1) * sizeof(short); if (pcbValue) *pcbValueBindRow = len; if (len <= cbValueMax) return COPY_OK; /* dont go any further or the data will be * trashed */ else return COPY_RESULT_TRUNCATED; } break; /* * This is a large object OID, which is used to store * LONGVARBINARY objects. */ case PG_TYPE_LO_UNDEFINED: return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, pcbValueBindRow); case 0: break; default: if (field_type == stmt->hdbc->lobj_type /* hack until permanent type available */ || (PG_TYPE_OID == field_type && SQL_C_BINARY == fCType && conn->lo_is_domain) ) return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, pcbValueBindRow); } /* Change default into something useable */ if (fCType == SQL_C_DEFAULT) { fCType = pgtype_attr_to_ctype(conn, field_type, atttypmod); #ifdef UNICODE_SUPPORT if (fCType == SQL_C_WCHAR && CC_default_is_c(conn)) fCType = SQL_C_CHAR; #endif MYLOG(0, ", SQL_C_DEFAULT: fCType = %d\n", fCType); } text_bin_handling = FALSE; switch (fCType) { case INTERNAL_ASIS_TYPE: #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: #endif /* UNICODE_SUPPORT */ case SQL_C_CHAR: text_bin_handling = TRUE; break; case SQL_C_BINARY: switch (field_type) { case PG_TYPE_UNKNOWN: case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: case PG_TYPE_XML: case PG_TYPE_BPCHARARRAY: case PG_TYPE_VARCHARARRAY: case PG_TYPE_TEXTARRAY: case PG_TYPE_XMLARRAY: case PG_TYPE_BYTEA: text_bin_handling = TRUE; break; } break; } if (text_bin_handling) { BOOL pre_convert = TRUE; int midsize = sizeof(midtemp); int i; /* Special character formatting as required */ /* * These really should return error if cbValueMax is not big * enough. */ switch (field_type) { case PG_TYPE_DATE: len = SPRINTF_FIXED(midtemp, "%.4d-%.2d-%.2d", std_time.y, std_time.m, std_time.d); break; case PG_TYPE_TIME: len = SPRINTF_FIXED(midtemp, "%.2d:%.2d:%.2d", std_time.hh, std_time.mm, std_time.ss); if (std_time.fr > 0) { int wdt; int fr = effective_fraction(std_time.fr, &wdt); len = SPRINTFCAT_FIXED(midtemp, ".%0*d", wdt, fr); } break; case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: len = stime2timestamp(&std_time, midtemp, midsize, FALSE, (int) (midsize - 19 - 2) ); break; case PG_TYPE_UUID: len = strlen(neut_str); for (i = 0; i < len && i < midsize - 2; i++) midtemp[i] = toupper((UCHAR) neut_str[i]); midtemp[i] = '\0'; MYLOG(0, "PG_TYPE_UUID: rgbValueBindRow = '%s'\n", rgbValueBindRow); break; /* * Currently, data is SILENTLY TRUNCATED for BYTEA and * character data types if there is not enough room in * cbValueMax because the driver can't handle multiple * calls to SQLGetData for these, yet. Most likely, the * buffer passed in will be big enough to handle the * maximum limit of postgres, anyway. * * LongVarBinary types are handled correctly above, observing * truncation and all that stuff since there is * essentially no limit on the large object used to store * those. */ case PG_TYPE_BYTEA:/* convert binary data to hex strings * (i.e, 255 = "FF") */ default: pre_convert = FALSE; } if (pre_convert) neut_str = midtemp; result = convert_text_field_to_sql_c(gdata, stmt->current_col, neut_str, field_type, fCType, rgbValueBindRow, cbValueMax, conn, &len); } else { SQLGUID g; /* * for SQL_C_CHAR, it's probably ok to leave currency symbols in. * But to convert to numeric types, it is necessary to get rid of * those. */ if (field_type == PG_TYPE_MONEY) { if (convert_money(neut_str, midtemp, sizeof(midtemp))) neut_str = midtemp; else { MYLOG(0, "couldn't convert money type to %d\n", fCType); return COPY_UNSUPPORTED_TYPE; } } switch (fCType) { case SQL_C_DATE: case SQL_C_TYPE_DATE: /* 91 */ len = 6; { DATE_STRUCT *ds; struct tm *tim; if (bind_size > 0) ds = (DATE_STRUCT *) rgbValueBindRow; else ds = (DATE_STRUCT *) rgbValue + bind_row; /* * Initialize date in case conversion destination * expects date part from this source time data. * A value may be partially set here, so do some * sanity checks on the existing values before * setting them. */ tim = SC_get_localtime(stmt); if (std_time.m == 0) std_time.m = tim->tm_mon + 1; if (std_time.d == 0) std_time.d = tim->tm_mday; if (std_time.y == 0) std_time.y = tim->tm_year + 1900; ds->year = std_time.y; ds->month = std_time.m; ds->day = std_time.d; } break; case SQL_C_TIME: case SQL_C_TYPE_TIME: /* 92 */ len = 6; { TIME_STRUCT *ts; if (bind_size > 0) ts = (TIME_STRUCT *) rgbValueBindRow; else ts = (TIME_STRUCT *) rgbValue + bind_row; ts->hour = std_time.hh; ts->minute = std_time.mm; ts->second = std_time.ss; } break; case SQL_C_TIMESTAMP: case SQL_C_TYPE_TIMESTAMP: /* 93 */ len = 16; { struct tm *tim; TIMESTAMP_STRUCT *ts; if (bind_size > 0) ts = (TIMESTAMP_STRUCT *) rgbValueBindRow; else ts = (TIMESTAMP_STRUCT *) rgbValue + bind_row; /* * Initialize date in case conversion destination * expects date part from this source time data. * A value may be partially set here, so do some * sanity checks on the existing values before * setting them. */ tim = SC_get_localtime(stmt); if (std_time.m == 0) std_time.m = tim->tm_mon + 1; if (std_time.d == 0) std_time.d = tim->tm_mday; if (std_time.y == 0) std_time.y = tim->tm_year + 1900; ts->year = std_time.y; ts->month = std_time.m; ts->day = std_time.d; ts->hour = std_time.hh; ts->minute = std_time.mm; ts->second = std_time.ss; ts->fraction = std_time.fr; } break; case SQL_C_BIT: len = 1; if (bind_size > 0) *((UCHAR *) rgbValueBindRow) = atoi(neut_str); else *((UCHAR *) rgbValue + bind_row) = atoi(neut_str); MYLOG(99, "SQL_C_BIT: bind_row = " FORMAT_POSIROW " val = %d, cb = " FORMAT_LEN ", rgb=%d\n", bind_row, atoi(neut_str), cbValueMax, *((UCHAR *)rgbValue)); break; case SQL_C_STINYINT: case SQL_C_TINYINT: len = 1; if (bind_size > 0) *((SCHAR *) rgbValueBindRow) = atoi(neut_str); else *((SCHAR *) rgbValue + bind_row) = atoi(neut_str); break; case SQL_C_UTINYINT: len = 1; if (bind_size > 0) *((UCHAR *) rgbValueBindRow) = atoi(neut_str); else *((UCHAR *) rgbValue + bind_row) = atoi(neut_str); break; case SQL_C_FLOAT: set_client_decimal_point((char *) neut_str); len = 4; if (bind_size > 0) *((SFLOAT *) rgbValueBindRow) = (float) get_double_value(neut_str); else *((SFLOAT *) rgbValue + bind_row) = (float) get_double_value(neut_str); break; case SQL_C_DOUBLE: set_client_decimal_point((char *) neut_str); len = 8; if (bind_size > 0) *((SDOUBLE *) rgbValueBindRow) = get_double_value(neut_str); else *((SDOUBLE *) rgbValue + bind_row) = get_double_value(neut_str); break; case SQL_C_NUMERIC: { SQL_NUMERIC_STRUCT *ns; BOOL overflowed; if (bind_size > 0) ns = (SQL_NUMERIC_STRUCT *) rgbValueBindRow; else ns = (SQL_NUMERIC_STRUCT *) rgbValue + bind_row; parse_to_numeric_struct(neut_str, ns, &overflowed); if (overflowed) result = COPY_RESULT_TRUNCATED; } break; case SQL_C_SSHORT: case SQL_C_SHORT: len = 2; if (bind_size > 0) *((SQLSMALLINT *) rgbValueBindRow) = atoi(neut_str); else *((SQLSMALLINT *) rgbValue + bind_row) = atoi(neut_str); break; case SQL_C_USHORT: len = 2; if (bind_size > 0) *((SQLUSMALLINT *) rgbValueBindRow) = atoi(neut_str); else *((SQLUSMALLINT *) rgbValue + bind_row) = atoi(neut_str); break; case SQL_C_SLONG: case SQL_C_LONG: len = 4; if (bind_size > 0) *((SQLINTEGER *) rgbValueBindRow) = atol(neut_str); else *((SQLINTEGER *) rgbValue + bind_row) = atol(neut_str); break; case SQL_C_ULONG: len = 4; if (bind_size > 0) *((SQLUINTEGER *) rgbValueBindRow) = ATOI32U(neut_str); else *((SQLUINTEGER *) rgbValue + bind_row) = ATOI32U(neut_str); break; #ifdef ODBCINT64 case SQL_C_SBIGINT: len = 8; if (bind_size > 0) *((SQLBIGINT *) rgbValueBindRow) = ATOI64(neut_str); else *((SQLBIGINT *) rgbValue + bind_row) = ATOI64(neut_str); break; case SQL_C_UBIGINT: len = 8; if (bind_size > 0) *((SQLUBIGINT *) rgbValueBindRow) = ATOI64U(neut_str); else *((SQLUBIGINT *) rgbValue + bind_row) = ATOI64U(neut_str); break; #endif /* ODBCINT64 */ case SQL_C_BINARY: /* The following is for SQL_C_VARBOOKMARK */ if (PG_TYPE_INT4 == field_type) { UInt4 ival = ATOI32U(neut_str); MYLOG(DETAIL_LOG_LEVEL, "SQL_C_VARBOOKMARK value=%d\n", ival); if (pcbValue) *pcbValueBindRow = sizeof(ival); if (cbValueMax >= sizeof(ival)) { memcpy(rgbValueBindRow, &ival, sizeof(ival)); return COPY_OK; } else return COPY_RESULT_TRUNCATED; } else if (PG_TYPE_UUID == field_type) { int rtn = char2guid(neut_str, &g); if (COPY_OK != rtn) return rtn; if (pcbValue) *pcbValueBindRow = sizeof(g); if (cbValueMax >= sizeof(g)) { memcpy(rgbValueBindRow, &g, sizeof(g)); return COPY_OK; } else return COPY_RESULT_TRUNCATED; } else { MYLOG(0, "couldn't convert the type %d to SQL_C_BINARY\n", field_type); return COPY_UNSUPPORTED_TYPE; } break; case SQL_C_GUID: result = char2guid(neut_str, &g); if (COPY_OK != result) { MYLOG(0, "Could not convert to SQL_C_GUID\n"); return COPY_UNSUPPORTED_TYPE; } len = sizeof(g); if (bind_size > 0) *((SQLGUID *) rgbValueBindRow) = g; else *((SQLGUID *) rgbValue + bind_row) = g; break; case SQL_C_INTERVAL_YEAR: case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_YEAR_TO_MONTH: case SQL_C_INTERVAL_DAY: case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_DAY_TO_HOUR: case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: interval2istruct(fCType, precision, neut_str, bind_size > 0 ? (SQL_INTERVAL_STRUCT *) rgbValueBindRow : (SQL_INTERVAL_STRUCT *) rgbValue + bind_row); break; default: MYLOG(0, "conversion to the type %d isn't supported\n", fCType); return COPY_UNSUPPORTED_TYPE; } } /* store the length of what was copied, if there's a place for it */ if (pcbValue) *pcbValueBindRow = len; if (result == COPY_OK && stmt->current_col >= 0) gdata->gdata[stmt->current_col].data_left = 0; return result; } /*-------------------------------------------------------------------- * Functions/Macros to get rid of query size limit. * * I always used the following macros to convert from * old_statement to new_statement. Please improve it * if you have a better way. Hiroshi 2001/05/22 *-------------------------------------------------------------------- */ #define FLGP_USING_CURSOR (1L << 1) #define FLGP_SELECT_INTO (1L << 2) #define FLGP_SELECT_FOR_UPDATE_OR_SHARE (1L << 3) #define FLGP_MULTIPLE_STATEMENT (1L << 5) #define FLGP_SELECT_FOR_READONLY (1L << 6) typedef struct _QueryParse { const char *statement; int statement_type; size_t opos; ssize_t from_pos; ssize_t where_pos; ssize_t stmt_len; int in_status; char escape_in_literal, prev_token_end; const char *dollar_tag; ssize_t taglen; char token_curr[64]; int token_len; size_t declare_pos; UInt4 flags, comment_level; encoded_str encstr; } QueryParse; static void QP_initialize(QueryParse *q, const StatementClass *stmt) { q->statement = stmt->statement; q->statement_type = stmt->statement_type; q->opos = 0; q->from_pos = -1; q->where_pos = -1; q->stmt_len = (q->statement) ? strlen(q->statement) : -1; q->in_status = 0; q->escape_in_literal = '\0'; q->dollar_tag = NULL; q->taglen = -1; q->token_curr[0] = '\0'; q->token_len = 0; q->prev_token_end = TRUE; q->declare_pos = 0; q->flags = 0; q->comment_level = 0; make_encoded_str(&q->encstr, SC_get_conn(stmt), q->statement); } enum { QP_IN_IDENT_KEYWORD = 1L /* identifier or keyword */ , QP_IN_DQUOTE_IDENTIFIER = (1L << 1) /* "" */ , QP_IN_LITERAL = (1L << 2) /* '' */ , QP_IN_ESCAPE = (1L << 3) /* \ in literal */ , QP_IN_DOLLAR_QUOTE = (1L << 4) /* $...$ $...$ */ , QP_IN_COMMENT_BLOCK = (1L << 5) /* slash asterisk */ , QP_IN_LINE_COMMENT = (1L << 6) /* -- */ }; #define QP_in_idle_status(qp) ((qp)->in_status == 0) #define QP_is_in(qp, status) (((qp)->in_status & status) != 0) #define QP_enter(qp, status) ((qp)->in_status |= status) #define QP_exit(qp, status) ((qp)->in_status &= (~status)) /* * ResolveOneParam can be work in these four modes: * * RPM_REPLACE_PARAMS * Replace parameter markers with their values. * * RPM_FAKE_PARAMS * The query is going to be sent to the server only to be able to * Describe the result set. Parameter markers are replaced with NULL * literals if we don't know their real values yet. * * RPM_BUILDING_PREPARE_STATEMENT * Building a query suitable for PREPARE statement, or server-side Parse. * Parameter markers are replaced with $n-style parameter markers. * * RPM_BUILDING_BIND_REQUEST * Building the actual parameter values to send to the server in a Bind * request. Return an unescaped value that will be accepted by the * server's input function. */ typedef enum { RPM_REPLACE_PARAMS, RPM_FAKE_PARAMS, RPM_BUILDING_PREPARE_STATEMENT, RPM_BUILDING_BIND_REQUEST } ResolveParamMode; #define FLGB_INACCURATE_RESULT (1L << 4) #define FLGB_CREATE_KEYSET (1L << 5) #define FLGB_KEYSET_DRIVEN (1L << 6) #define FLGB_CONVERT_LF (1L << 7) #define FLGB_DISCARD_OUTPUT (1L << 8) #define FLGB_BINARY_AS_POSSIBLE (1L << 9) #define FLGB_LITERAL_EXTENSION (1L << 10) #define FLGB_HEX_BIN_FORMAT (1L << 11) #define FLGB_PARAM_CAST (1L << 12) typedef struct _QueryBuild { char *query_statement; size_t str_alsize; size_t npos; SQLLEN current_row; Int2 param_number; Int2 dollar_number; Int2 num_io_params; Int2 num_output_params; Int2 num_discard_params; Int2 proc_return; Int2 brace_level; char parenthesize_the_first; APDFields *apdopts; IPDFields *ipdopts; PutDataInfo *pdata; size_t load_stmt_len; size_t load_from_pos; ResolveParamMode param_mode; UInt4 flags; int ccsc; int errornumber; const char *errormsg; ConnectionClass *conn; /* mainly needed for LO handling */ StatementClass *stmt; /* needed to set error info in ENLARGE_.. */ } QueryBuild; #define INIT_MIN_ALLOC 4096 static ssize_t QB_initialize(QueryBuild *qb, size_t size, StatementClass *stmt, ResolveParamMode param_mode) { size_t newsize = 0; qb->param_mode = param_mode; qb->flags = 0; qb->load_stmt_len = 0; qb->load_from_pos = 0; qb->stmt = stmt; qb->apdopts = NULL; qb->ipdopts = NULL; qb->pdata = NULL; qb->proc_return = 0; qb->num_io_params = 0; qb->num_output_params = 0; qb->num_discard_params = 0; qb->brace_level = 0; qb->parenthesize_the_first = FALSE; /* Copy options from statement */ qb->apdopts = SC_get_APDF(stmt); qb->ipdopts = SC_get_IPDF(stmt); qb->pdata = SC_get_PDTI(stmt); qb->conn = SC_get_conn(stmt); if (stmt->discard_output_params) qb->flags |= FLGB_DISCARD_OUTPUT; qb->num_io_params = CountParameters(stmt, NULL, NULL, &qb->num_output_params); qb->proc_return = stmt->proc_return; if (0 != (qb->flags & FLGB_DISCARD_OUTPUT)) qb->num_discard_params = qb->num_output_params; if (qb->num_discard_params < qb->proc_return) qb->num_discard_params = qb->proc_return; /* Copy options from connection */ if (qb->conn->connInfo.lf_conversion) qb->flags |= FLGB_CONVERT_LF; qb->ccsc = qb->conn->ccsc; if (CC_get_escape(qb->conn) && PG_VERSION_GE(qb->conn, 8.1)) qb->flags |= FLGB_LITERAL_EXTENSION; if (PG_VERSION_GE(qb->conn, 9.0)) qb->flags |= FLGB_HEX_BIN_FORMAT; newsize = INIT_MIN_ALLOC; while (newsize <= size) newsize *= 2; if ((qb->query_statement = malloc(newsize)) == NULL) { qb->str_alsize = 0; return -1; } qb->query_statement[0] = '\0'; qb->str_alsize = newsize; qb->npos = 0; qb->current_row = stmt->exec_current_row < 0 ? 0 : stmt->exec_current_row; qb->param_number = -1; qb->dollar_number = 0; qb->errornumber = 0; qb->errormsg = NULL; return newsize; } static int QB_initialize_copy(QueryBuild *qb_to, const QueryBuild *qb_from, UInt4 size) { memcpy(qb_to, qb_from, sizeof(QueryBuild)); if ((qb_to->query_statement = malloc(size)) == NULL) { qb_to->str_alsize = 0; return -1; } qb_to->query_statement[0] = '\0'; qb_to->str_alsize = size; qb_to->npos = 0; return size; } static void QB_replace_SC_error(StatementClass *stmt, const QueryBuild *qb, const char *func) { int number; if (0 == qb->errornumber) return; if ((number = SC_get_errornumber(stmt)) > 0) return; if (number < 0 && qb->errornumber < 0) return; SC_set_error(stmt, qb->errornumber, qb->errormsg, func); } static void QB_Destructor(QueryBuild *qb) { if (qb->query_statement) { free(qb->query_statement); qb->query_statement = NULL; qb->str_alsize = 0; } } /* * New macros (Aceto) *-------------------- */ #define F_OldChar(qp) ((qp)->statement[(qp)->opos]) #define F_OldPtr(qp) ((qp)->statement + (qp)->opos) #define F_OldNext(qp) (++(qp)->opos) #define F_OldPrior(qp) (--(qp)->opos) #define F_OldPos(qp) (qp)->opos #define F_ExtractOldTo(qp, buf, ch, maxsize) \ do { \ size_t c = 0; \ while ((qp)->statement[qp->opos] != '\0' && (qp)->statement[qp->opos] != ch) \ { \ if (c >= maxsize) \ break; \ buf[c++] = (qp)->statement[qp->opos++]; \ } \ if ((qp)->statement[qp->opos] == '\0') \ {retval = SQL_ERROR; goto cleanup;} \ buf[c] = '\0'; \ } while (0) #define F_NewChar(qb) (qb->query_statement[(qb)->npos]) #define F_NewPtr(qb) ((qb)->query_statement + (qb)->npos) #define F_NewNext(qb) (++(qb)->npos) #define F_NewPos(qb) ((qb)->npos) static int convert_escape(QueryParse *qp, QueryBuild *qb); static int inner_process_tokens(QueryParse *qp, QueryBuild *qb); static int ResolveOneParam(QueryBuild *qb, QueryParse *qp, BOOL *isnull, BOOL *usebinary, Oid *pgType); static int processParameters(QueryParse *qp, QueryBuild *qb, size_t *output_count, SQLLEN param_pos[][2]); static size_t convert_to_pgbinary(const char *in, char *out, size_t len, QueryBuild *qb); static BOOL convert_special_chars(QueryBuild *qb, const char *si, size_t used); /* * Enlarge qb->query_statement buffer so that it is at least newsize + 1 * in size. */ static ssize_t enlarge_query_statement(QueryBuild *qb, size_t newsize) { size_t newalsize = INIT_MIN_ALLOC; CSTR func = "enlarge_statement"; while (newalsize <= newsize) newalsize *= 2; if (!(qb->query_statement = realloc(qb->query_statement, newalsize))) { qb->str_alsize = 0; if (qb->stmt) { SC_set_error(qb->stmt, STMT_EXEC_ERROR, "Query buffer allocate error in copy_statement_with_parameters", func); } else { qb->errormsg = "Query buffer allocate error in copy_statement_with_parameters"; qb->errornumber = STMT_EXEC_ERROR; } return 0; } qb->str_alsize = newalsize; return newalsize; } /*---------- * Enlarge stmt_with_params if necessary. *---------- */ #define ENLARGE_NEWSTATEMENT(qb, newpos) \ do { \ if ((newpos) >= (qb)->str_alsize) \ { \ if (enlarge_query_statement(qb, newpos) <= 0) \ { \ retval = SQL_ERROR; \ goto cleanup; \ } \ } \ } while(0) /*---------- * Terminate the stmt_with_params string with NULL. *---------- */ #define CVT_TERMINATE(qb) \ do { \ if (NULL == (qb)->query_statement) \ { \ retval = SQL_ERROR; \ goto cleanup; \ } \ (qb)->query_statement[(qb)->npos] = '\0'; \ } while (0) /*---------- * Append a data. *---------- */ #define CVT_APPEND_DATA(qb, s, len) \ do { \ size_t newpos = (qb)->npos + len; \ ENLARGE_NEWSTATEMENT((qb), newpos); \ memcpy(&(qb)->query_statement[(qb)->npos], s, len); \ (qb)->npos = newpos; \ (qb)->query_statement[newpos] = '\0'; \ } while (0) /*---------- * Append a string. *---------- */ #define CVT_APPEND_STR(qb, s) \ do { \ size_t len = strlen(s); \ CVT_APPEND_DATA(qb, s, len); \ } while (0) /*---------- * Append a char. *---------- */ #define CVT_APPEND_CHAR(qb, c) \ do { \ ENLARGE_NEWSTATEMENT(qb, (qb)->npos + 1); \ (qb)->query_statement[(qb)->npos++] = c; \ } while (0) /*---------- * Append a binary data. * Newly required size may be overestimated currently. *---------- */ #define CVT_APPEND_BINARY(qb, buf, used) \ do { \ size_t newlimit; \ \ newlimit = (qb)->npos; \ if (qb->flags & FLGB_HEX_BIN_FORMAT) \ newlimit += 2 * used + 4; \ else \ newlimit += 5 * used; \ ENLARGE_NEWSTATEMENT(qb, newlimit); \ (qb)->npos += convert_to_pgbinary(buf, \ &qb->query_statement[(qb)->npos], \ used, qb); \ } while (0) /*---------- * *---------- */ #define CVT_SPECIAL_CHARS(qb, buf, used) \ do { \ if (!convert_special_chars(qb, buf, used)) \ { \ retval = SQL_ERROR; \ goto cleanup; \ } \ } while (0) static RETCODE QB_start_brace(QueryBuild *qb) { BOOL replace_by_parenthesis = TRUE; RETCODE retval = SQL_ERROR; if (0 == qb->brace_level) { if (0 == F_NewPos(qb)) { qb->parenthesize_the_first = FALSE; replace_by_parenthesis = FALSE; } else qb->parenthesize_the_first = TRUE; } if (replace_by_parenthesis) CVT_APPEND_CHAR(qb, '('); qb->brace_level++; retval = SQL_SUCCESS; cleanup: return retval; } static RETCODE QB_end_brace(QueryBuild *qb) { BOOL replace_by_parenthesis = TRUE; RETCODE retval = SQL_ERROR; if (qb->brace_level <= 1 && !qb->parenthesize_the_first) replace_by_parenthesis = FALSE; if (replace_by_parenthesis) CVT_APPEND_CHAR(qb, ')'); qb->brace_level--; retval = SQL_SUCCESS; cleanup: return retval; } static RETCODE QB_append_space_to_separate_identifiers(QueryBuild *qb, const QueryParse *qp) { unsigned char tchar = F_OldChar(qp); encoded_str encstr; BOOL add_space = FALSE; RETCODE retval = SQL_ERROR; if (ODBC_ESCAPE_END != tchar) return SQL_SUCCESS; encoded_str_constr(&encstr, qb->ccsc, F_OldPtr(qp) + 1); tchar = encoded_nextchar(&encstr); if (MBCS_NON_ASCII(encstr)) add_space = TRUE; else { if (isalnum(tchar)) add_space = TRUE; else { switch (tchar) { case '_': case '$': add_space = TRUE; } } } if (add_space) CVT_APPEND_CHAR(qb, ' '); retval = SQL_SUCCESS; cleanup: return retval; } /*---------- * Check if the statement is * SELECT ... INTO table FROM ..... * This isn't really a strict check but ... *---------- */ static BOOL into_table_from(const char *stmt) { if (strnicmp(stmt, "into", 4)) return FALSE; stmt += 4; while (isspace((UCHAR) *stmt)) stmt++; switch (*stmt) { case '\0': case ',': case LITERAL_QUOTE: case DOLLAR_QUOTE: return FALSE; case '-': case '/': return TRUE; case IDENTIFIER_QUOTE: /* double quoted table name ? */ do { do { ++stmt; } while (*stmt != IDENTIFIER_QUOTE && *stmt); if (*stmt) stmt++; } while (*stmt == IDENTIFIER_QUOTE); break; default: while (IS_NOT_SPACE(*stmt)) stmt++; break; } if (!*stmt) return FALSE; while (isspace((UCHAR) *stmt)) stmt++; if ('/' == *stmt || '-' == *stmt) return TRUE; if (strnicmp(stmt, "from", 4)) return FALSE; return TRUE; } /*---------- * Check if the statement is * SELECT ... FOR UPDATE ..... * This isn't really a strict check but ... *---------- */ static UInt4 table_for_update_or_share(const char *stmt, size_t *endpos) { const char *wstmt = stmt; int advance; UInt4 flag = 0, zeroflag = 0; while (isspace((UCHAR) *wstmt)) wstmt++; if (!*wstmt) return 0; if (0 == strnicmp(wstmt, "update", advance = 6)) flag |= FLGP_SELECT_FOR_UPDATE_OR_SHARE; else if (0 == strnicmp(wstmt, "share", advance = 5)) flag |= FLGP_SELECT_FOR_UPDATE_OR_SHARE; else if (0 == strnicmp(wstmt, "read", advance = 4)) flag |= FLGP_SELECT_FOR_READONLY; else { flag |= FLGP_SELECT_FOR_UPDATE_OR_SHARE; /* maybe */ return flag; } zeroflag = flag; /* returns flag anyway */ wstmt += advance; if (IS_NOT_SPACE(wstmt[0])) return zeroflag; else if (0 != (flag & FLGP_SELECT_FOR_READONLY)) { if (IS_NOT_SPACE(wstmt[0])) return zeroflag; while (isspace((UCHAR) *wstmt)) wstmt++; if (!*wstmt) return zeroflag; if (0 != strnicmp(wstmt, "only", advance = 4)) return zeroflag; wstmt += advance; } if (IS_NOT_SPACE(wstmt[0])) return zeroflag; *endpos = wstmt - stmt; return flag; } /*---------- * Check if the statement has OUTER JOIN * This isn't really a strict check but ... *---------- */ static BOOL check_join(StatementClass *stmt, const char *curptr, size_t curpos) { const char *wstmt; ssize_t stapos, endpos, tokenwd; const int backstep = 4; BOOL outerj = TRUE; for (endpos = curpos, wstmt = curptr; endpos >= 0 && isspace((UCHAR) *wstmt); endpos--, wstmt--) ; if (endpos < 0) return FALSE; for (endpos -= backstep, wstmt -= backstep; endpos >= 0 && isspace((UCHAR) *wstmt); endpos--, wstmt--) ; if (endpos < 0) return FALSE; for (stapos = endpos; stapos >= 0 && IS_NOT_SPACE(*wstmt); stapos--, wstmt--) ; if (stapos < 0 || 0 == *wstmt) return FALSE; wstmt++; switch (tokenwd = endpos - stapos) { case 4: if (strnicmp(wstmt, "FULL", tokenwd) == 0 || strnicmp(wstmt, "LEFT", tokenwd) == 0) break; return FALSE; case 5: if (strnicmp(wstmt, "OUTER", tokenwd) == 0 || strnicmp(wstmt, "RIGHT", tokenwd) == 0) break; if (strnicmp(wstmt, "INNER", tokenwd) == 0 || strnicmp(wstmt, "CROSS", tokenwd) == 0) { outerj = FALSE; break; } return FALSE; default: return FALSE; } if (stmt) { if (outerj) SC_set_outer_join(stmt); else SC_set_inner_join(stmt); } return TRUE; } /*---------- * Check if the statement is * INSERT INTO ... () VALUES () * This isn't really a strict check but ... *---------- */ static BOOL insert_without_target(const char *stmt, size_t *endpos) { const char *wstmt = stmt; while (isspace((UCHAR) *wstmt)) wstmt++; if (!*wstmt) return FALSE; if (strnicmp(wstmt, "VALUES", 6)) return FALSE; wstmt += 6; if (!wstmt[0] || IS_NOT_SPACE(wstmt[0])) return FALSE; while (isspace((UCHAR) *wstmt)) wstmt++; if (*wstmt != '(' || *(++wstmt) != ')') return FALSE; wstmt++; *endpos = wstmt - stmt; return !wstmt[0] || isspace((UCHAR) wstmt[0]) || ';' == wstmt[0]; } static ProcessedStmt * buildProcessedStmt(const char *srvquery, ssize_t endp, int num_params) { ProcessedStmt *pstmt; size_t qlen; qlen = (endp == SQL_NTS) ? strlen(srvquery) : endp; pstmt = malloc(sizeof(ProcessedStmt)); if (!pstmt) return NULL; pstmt->next = NULL; pstmt->query = malloc(qlen + 1); if (!pstmt->query) { free(pstmt); return NULL; } memcpy(pstmt->query, srvquery, qlen); pstmt->query[qlen] = '\0'; pstmt->num_params = num_params; return pstmt; } /* * Process the original SQL query for execution using server-side prepared * statements. * * Split a possible multi-statement query into parts, and replace ?-style * parameter markers with $n. The resulting queries are stored in a linked * list in stmt->processed_statements. * * If 'fake_params' is true, we will replace ?-style parameter markers with * fake parameter values instead. This is used when a query's result columns * have to be described (SQLPrepare+SQLDescribeCol) before executing the * query, in UseServerSidePrepare=0 mode. */ RETCODE prepareParametersNoDesc(StatementClass *stmt, BOOL fake_params, BOOL param_cast) { CSTR func = "process_statements"; RETCODE retval; ConnectionClass *conn = SC_get_conn(stmt); char plan_name[32]; po_ind_t multi; const char *orgquery = NULL, *srvquery = NULL; ssize_t endp1, endp2; SQLSMALLINT num_pa = 0, num_p1, num_p2; ProcessedStmt *pstmt; ProcessedStmt *last_pstmt; QueryParse query_org, *qp; QueryBuild query_crt, *qb; MYLOG(DETAIL_LOG_LEVEL, "entering\n"); qp = &query_org; QP_initialize(qp, stmt); qb = &query_crt; if (QB_initialize(qb, qp->stmt_len, stmt, fake_params ? RPM_FAKE_PARAMS : RPM_BUILDING_PREPARE_STATEMENT) < 0) { SC_set_errornumber(stmt, STMT_NO_MEMORY_ERROR); return SQL_ERROR; } if (param_cast) qb->flags |= FLGB_PARAM_CAST; for (qp->opos = 0; qp->opos < qp->stmt_len; qp->opos++) { retval = inner_process_tokens(qp, qb); if (SQL_ERROR == retval) { QB_replace_SC_error(stmt, qb, func); QB_Destructor(qb); return retval; } } CVT_TERMINATE(qb); retval = SQL_ERROR; #define return DONT_CALL_RETURN_FROM_HERE??? if (NAMED_PARSE_REQUEST == SC_get_prepare_method(stmt)) SPRINTF_FIXED(plan_name, "_PLAN%p", stmt); else plan_name[0] = '\0'; stmt->current_exec_param = 0; multi = stmt->multi_statement; orgquery = stmt->statement; srvquery = qb->query_statement; SC_scanQueryAndCountParams(orgquery, conn, &endp1, &num_p1, &multi, NULL); SC_scanQueryAndCountParams(srvquery, conn, &endp2, NULL, NULL, NULL); MYLOG(0, "parsed for the first command length=" FORMAT_SSIZE_T "(" FORMAT_SSIZE_T ") num_p=%d\n", endp2, endp1, num_p1); pstmt = buildProcessedStmt(srvquery, endp2 < 0 ? SQL_NTS : endp2, fake_params ? 0 : num_p1); if (!pstmt) { SC_set_errornumber(stmt, STMT_NO_MEMORY_ERROR); goto cleanup; } stmt->processed_statements = last_pstmt = pstmt; while (multi > 0) { orgquery += (endp1 + 1); srvquery += (endp2 + 1); num_pa += num_p1; SC_scanQueryAndCountParams(orgquery, conn, &endp1, &num_p1, &multi, NULL); SC_scanQueryAndCountParams(srvquery, conn, &endp2, &num_p2, NULL, NULL); MYLOG(0, "parsed for the subsequent command length=" FORMAT_SSIZE_T "(" FORMAT_SSIZE_T ") num_p=%d\n", endp2, endp1, num_p1); pstmt = buildProcessedStmt(srvquery, endp2 < 0 ? SQL_NTS : endp2, fake_params ? 0 : num_p1); if (!pstmt) { SC_set_errornumber(stmt, STMT_NO_MEMORY_ERROR); goto cleanup; } last_pstmt->next = pstmt; last_pstmt = pstmt; } SC_set_planname(stmt, plan_name); SC_set_prepared(stmt, plan_name[0] ? PREPARING_PERMANENTLY : PREPARING_TEMPORARILY); retval = SQL_SUCCESS; cleanup: #undef return stmt->current_exec_param = -1; QB_Destructor(qb); return retval; } /* * Describe the parameters and portal for given query. */ static RETCODE desc_params_and_sync(StatementClass *stmt) { CSTR func = "desc_params_and_sync"; RETCODE retval; ConnectionClass *conn = SC_get_conn(stmt); QResultClass *res; char *plan_name; int func_cs_count = 0; SQLSMALLINT num_pa = 0; ProcessedStmt *pstmt; MYLOG(DETAIL_LOG_LEVEL, "entering\n"); retval = SQL_ERROR; #define return DONT_CALL_RETURN_FROM_HERE??? ENTER_INNER_CONN_CS(conn, func_cs_count); plan_name = stmt->plan_name ? stmt->plan_name : ""; pstmt = stmt->processed_statements; stmt->current_exec_param = 0; res = ParseAndDescribeWithLibpq(stmt, plan_name, pstmt->query, pstmt->num_params, "prepare_and_describe", NULL); if (res == NULL) goto cleanup; // SC_set_Result(stmt, res); QR_Destructor(stmt->parsed); stmt->parsed = res; if (!QR_command_maybe_successful(res)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Error while preparing parameters", func); goto cleanup; } num_pa = pstmt->num_params; for (pstmt = pstmt->next; pstmt; pstmt = pstmt->next) { if (pstmt->num_params > 0) { stmt->current_exec_param = num_pa; res = ParseAndDescribeWithLibpq(stmt, plan_name, pstmt->query, pstmt->num_params, "prepare_and_describe", NULL); if (res == NULL) goto cleanup; QR_Destructor(res); num_pa += pstmt->num_params; } } retval = SQL_SUCCESS; cleanup: #undef return CLEANUP_FUNC_CONN_CS(func_cs_count, conn); stmt->current_exec_param = -1; return retval; } /* * Process the original SQL query, and and ask the server describe the * parameters. */ RETCODE prepareParameters(StatementClass *stmt, BOOL fake_params) { ConnectionClass *conn = SC_get_conn(stmt); switch (stmt->prepared) { case PREPARED_TEMPORARILY: if (conn->unnamed_prepared_stmt == stmt) return SQL_SUCCESS; else break; case NOT_YET_PREPARED: case PREPARING_PERMANENTLY: case PREPARING_TEMPORARILY: break; default: return SQL_SUCCESS; } MYLOG(DETAIL_LOG_LEVEL, "calling prepareParameters\n"); if (prepareParametersNoDesc(stmt, fake_params, PARSE_PARAM_CAST) == SQL_ERROR) return SQL_ERROR; return desc_params_and_sync(stmt); } /* * This function inserts parameters into an SQL statements. * It will also modify a SELECT statement for use with declare/fetch cursors. * This function does a dynamic memory allocation to get rid of query size limit! */ int copy_statement_with_parameters(StatementClass *stmt, BOOL buildPrepareStatement) { CSTR func = "copy_statement_with_parameters"; RETCODE retval; QueryParse query_org, *qp; QueryBuild query_crt, *qb; char *new_statement; ConnectionClass *conn = SC_get_conn(stmt); ConnInfo *ci = &(conn->connInfo); const char *bestitem = NULL; MYLOG(DETAIL_LOG_LEVEL, "entering prepared=%d\n", stmt->prepared); if (!stmt->statement) { SC_set_error(stmt, STMT_INTERNAL_ERROR, "No statement string", func); return SQL_ERROR; } qp = &query_org; QP_initialize(qp, stmt); if (stmt->statement_type != STMT_TYPE_SELECT) { stmt->options.cursor_type = SQL_CURSOR_FORWARD_ONLY; stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; } else if (stmt->options.cursor_type == SQL_CURSOR_FORWARD_ONLY) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) { if (SQL_CURSOR_DYNAMIC == stmt->options.cursor_type && 0 == (ci->updatable_cursors & ALLOW_DYNAMIC_CURSORS)) stmt->options.cursor_type = SQL_CURSOR_KEYSET_DRIVEN; if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type && 0 == (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) stmt->options.cursor_type = SQL_CURSOR_STATIC; switch (stmt->options.cursor_type) { case SQL_CURSOR_DYNAMIC: case SQL_CURSOR_KEYSET_DRIVEN: if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); if (SC_is_updatable(stmt) && stmt->ntab > 0) { if (bestitem = GET_NAME(stmt->ti[0]->bestitem), NULL == bestitem) stmt->options.cursor_type = SQL_CURSOR_STATIC; } break; } if (SQL_CURSOR_STATIC == stmt->options.cursor_type) { if (0 == (ci->updatable_cursors & ALLOW_STATIC_CURSORS)) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); } if (SC_parsed_status(stmt) == STMT_PARSE_FATAL) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) stmt->options.cursor_type = SQL_CURSOR_STATIC; } else if (!stmt->updatable) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; stmt->options.cursor_type = SQL_CURSOR_STATIC; } else { qp->from_pos = stmt->from_pos; qp->where_pos = stmt->where_pos; } MYLOG(DETAIL_LOG_LEVEL, "type=" FORMAT_UINTEGER " concur=" FORMAT_UINTEGER "\n", stmt->options.cursor_type, stmt->options.scroll_concurrency); } SC_miscinfo_clear(stmt); /* If the application hasn't set a cursor name, then generate one */ if (!SC_cursor_is_valid(stmt)) { char curname[32]; SPRINTF_FIXED(curname, "SQL_CUR%p", stmt); STRX_TO_NAME(stmt->cursor_name, curname); } if (stmt->stmt_with_params) { free(stmt->stmt_with_params); stmt->stmt_with_params = NULL; } SC_no_fetchcursor(stmt); qb = &query_crt; qb->query_statement = NULL; if (PREPARED_PERMANENTLY == stmt->prepared) { /* already prepared */ retval = SQL_SUCCESS; goto cleanup; } /* * If it's a simple read-only cursor, we use extended query protocol to * Parse it. */ if (buildPrepareStatement && SQL_CONCUR_READ_ONLY == stmt->options.scroll_concurrency) { /* Nothing to do here. It will be prepared before execution. */ char plan_name[32]; if (NAMED_PARSE_REQUEST == SC_get_prepare_method(stmt)) SPRINTF_FIXED(plan_name, "_PLAN%p", stmt); else plan_name[0] = '\0'; SC_set_planname(stmt, plan_name); SC_set_prepared(stmt, plan_name[0] ? PREPARING_PERMANENTLY : PREPARING_TEMPORARILY); retval = SQL_SUCCESS; goto cleanup; } /* Otherwise... */ if (QB_initialize(qb, qp->stmt_len, stmt, RPM_REPLACE_PARAMS) < 0) { retval = SQL_ERROR; goto cleanup; } if (SIMPLE_PARAM_CAST) qb->flags |= FLGB_PARAM_CAST; new_statement = qb->query_statement; /* For selects, prepend a declare cursor to the statement */ if (SC_may_use_cursor(stmt) && stmt->external) { const char *opt_scroll = NULL_STRING, *opt_hold = NULL_STRING; if (ci->drivers.use_declarefetch /** && SQL_CONCUR_READ_ONLY == stmt->options.scroll_concurrency **/ ) { SC_set_fetchcursor(stmt); if (SC_is_with_hold(stmt)) opt_hold = " with hold"; if (SQL_CURSOR_FORWARD_ONLY != stmt->options.cursor_type) opt_scroll = " scroll"; } if (SC_is_fetchcursor(stmt)) { snprintfcat(new_statement, qb->str_alsize, "declare \"%s\"%s cursor%s for ", SC_cursor_name(stmt), opt_scroll, opt_hold); qb->npos = strlen(new_statement); qp->flags |= FLGP_USING_CURSOR; qp->declare_pos = qb->npos; } if (SQL_CONCUR_READ_ONLY != stmt->options.scroll_concurrency) { qb->flags |= FLGB_CREATE_KEYSET; if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type) qb->flags |= FLGB_KEYSET_DRIVEN; } } for (qp->opos = 0; qp->opos < qp->stmt_len; qp->opos++) { retval = inner_process_tokens(qp, qb); if (SQL_ERROR == retval) { QB_replace_SC_error(stmt, qb, func); QB_Destructor(qb); return retval; } } /* make sure new_statement is always null-terminated */ CVT_TERMINATE(qb); new_statement = qb->query_statement; stmt->statement_type = qp->statement_type; if (0 == (qp->flags & FLGP_USING_CURSOR)) SC_no_fetchcursor(stmt); #ifdef NOT_USED /* this seems problematic */ else if (0 == (qp->flags & (FLGP_SELECT_FOR_UPDATE_OR_SHARE | FLGP_SELECT_FOR_READONLY)) && 0 == stmt->multi_statement && PG_VERSION_GE(conn, 8.3)) { BOOL semi_colon_found = FALSE; const UCHAR *ptr = NULL, semi_colon = ';'; int npos; if (npos = F_NewPos(qb) - 1, npos >= 0) ptr = F_NewPtr(qb) - 1; for (; npos >= 0 && isspace(*ptr); npos--, ptr--) ; if (npos >= 0 && semi_colon == *ptr) { qb->npos = npos; semi_colon_found = TRUE; } CVT_APPEND_STR(qb, " for read only"); if (semi_colon_found) CVT_APPEND_CHAR(qb, semi_colon); CVT_TERMINATE(qb); } #endif /* NOT_USED */ if (0 != (qp->flags & FLGP_SELECT_INTO) || 0 != (qp->flags & FLGP_MULTIPLE_STATEMENT)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; } if (0 != (qp->flags & FLGP_SELECT_FOR_UPDATE_OR_SHARE)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; } if (conn->DriverToDataSource != NULL) { size_t length = strlen(new_statement); conn->DriverToDataSource(conn->translation_option, SQL_CHAR, new_statement, (SDWORD) length, new_statement, (SDWORD) length, NULL, NULL, 0, NULL); } if (!stmt->load_statement && qp->from_pos >= 0) { size_t npos = qb->load_stmt_len; if (0 == npos) { npos = qb->npos; for (; npos > 0; npos--) { if (isspace((unsigned char) new_statement[npos - 1])) continue; if (';' != new_statement[npos - 1]) break; } if (0 != (qb->flags & FLGB_KEYSET_DRIVEN)) { qb->npos = npos; /* ---------- * 1st query is for field information * 2nd query is keyset gathering */ CVT_APPEND_STR(qb, " where ctid = '(0,0)';select \"ctid"); if (bestitem) { CVT_APPEND_STR(qb, "\", \""); CVT_APPEND_STR(qb, bestitem); } CVT_APPEND_STR(qb, "\" from "); CVT_APPEND_DATA(qb, qp->statement + qp->from_pos + 5, qp->stmt_len - qp->from_pos - 5); } } npos -= qp->declare_pos; stmt->load_statement = malloc(npos + 1); if (!stmt->load_statement) { retval = SQL_ERROR; goto cleanup; } memcpy(stmt->load_statement, qb->query_statement + qp->declare_pos, npos); stmt->load_from_pos = qb->load_from_pos - qp->declare_pos; stmt->load_statement[npos] = '\0'; } stmt->stmt_with_params = qb->query_statement; retval = SQL_SUCCESS; cleanup: return retval; } static void remove_declare_cursor(QueryBuild *qb, QueryParse *qp) { qp->flags &= ~FLGP_USING_CURSOR; if (qp->declare_pos <= 0) return; memmove(qb->query_statement, qb->query_statement + qp->declare_pos, qb->npos - qp->declare_pos); qb->npos -= qp->declare_pos; qp->declare_pos = 0; } /* * When 'tag' starts with dollar-quoted tag, e.g. "$foo$...", return * the length of the tag (e.g. 5, with the previous example). If there * is no end-dollar in the string, returns 0. The caller should've checked * that the string begins with a dollar. */ size_t findTag(const char *tag, int ccsc) { size_t taglen = 0; encoded_str encstr; UCHAR tchar; encoded_str_constr(&encstr, ccsc, tag + 1); for (tchar = encoded_nextchar(&encstr); tchar; tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) continue; if (DOLLAR_QUOTE == tchar) { taglen = encstr.pos + 2; break; } if (!isalnum(tchar)) break; } return taglen; } int findIdentifier(const UCHAR *str, int ccsc, const UCHAR **next_token) { int slen = -1; encoded_str encstr; UCHAR tchar; BOOL dquote = FALSE; *next_token = NULL; encoded_str_constr(&encstr, ccsc, (const char *) str); for (tchar = encoded_nextchar(&encstr); tchar; tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) continue; if (encstr.pos == 0) /* the first character */ { if (dquote = (IDENTIFIER_QUOTE == tchar), dquote) continue; if (!isalpha(tchar)) { slen = 0; if (IS_NOT_SPACE(tchar)) *next_token = ENCODE_PTR(encstr); break; } } if (dquote) { if (IDENTIFIER_QUOTE == tchar) { tchar = encoded_nextchar(&encstr); if (IDENTIFIER_QUOTE == tchar) continue; slen = encstr.pos; break; } } else { if (isalnum(tchar)) continue; switch (tchar) { case '_': case DOLLAR_QUOTE: continue; } slen = encstr.pos; if (IS_NOT_SPACE(tchar)) *next_token = ENCODE_PTR(encstr); break; } } if (slen < 0 && !dquote) slen = encstr.pos; if (NULL == *next_token) { for (; tchar; tchar = encoded_nextchar(&encstr)) { if (IS_NOT_SPACE((UCHAR) tchar)) { *next_token = ENCODE_PTR(encstr); break; } } } return slen; } static pgNAME lower_or_remove_dquote(pgNAME nm, const UCHAR *src, int srclen, int ccsc) { int i, outlen; char *tc; UCHAR tchar; BOOL idQuote; encoded_str encstr; if (nm.name) tc = realloc(nm.name, srclen + 1); else tc = malloc(srclen + 1); if (!tc) { NULL_THE_NAME(nm); return nm; } nm.name = tc; idQuote = (src[0] == IDENTIFIER_QUOTE); encoded_str_constr(&encstr, ccsc, (const char *) src); for (i = 0, tchar = encoded_nextchar(&encstr), outlen = 0; i < srclen; i++, tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) { tc[outlen++] = tchar; continue; } if (idQuote) { if (IDENTIFIER_QUOTE == tchar) { if (0 == i) continue; if (i == srclen - 1) continue; i++; tchar = encoded_nextchar(&encstr); } tc[outlen++] = tchar; } else { tc[outlen++] = tolower(tchar); } } tc[outlen] = '\0'; return nm; } int eatTableIdentifiers(const UCHAR *str, int ccsc, pgNAME *table, pgNAME *schema) { int len; const UCHAR *next_token; const UCHAR *tstr = str; while (isspace(*tstr)) tstr++; if ((len = findIdentifier(tstr, ccsc, &next_token)) <= 0) return len; /* table name doesn't exist */ if (table) { if (IDENTIFIER_QUOTE == *tstr) *table = lower_or_remove_dquote(*table, tstr, len, ccsc); else STRN_TO_NAME(*table, tstr, len); } if (!next_token || '.' != *next_token || (int) (next_token - tstr) != len) return (int) (next_token - str); /* table only */ tstr = next_token + 1; if ((len = findIdentifier(tstr, ccsc, &next_token)) <= 0) return -1; if (table) { if (schema) MOVE_NAME(*schema, *table); *table = lower_or_remove_dquote(*table, tstr, len, ccsc); } if (!next_token || '.' != *next_token || (int) (next_token - tstr) != len) return (int) (next_token - str); /* schema.table */ tstr = next_token + 1; if ((len = findIdentifier(tstr, ccsc, &next_token)) <= 0) return -1; if (table) { if (schema) MOVE_NAME(*schema, *table); *table = lower_or_remove_dquote(*table, tstr, len, ccsc); } return (int) (next_token - str); /* catalog.schema.table */ } static void token_start(QueryParse *qp, char oldchar) { qp->prev_token_end = FALSE; qp->token_curr[0] = oldchar; qp->token_len = 1; } static int token_finish(QueryParse *qp, char oldchar, char *finished_token) { int ret = -1; if (!qp->prev_token_end) { if (oldchar && qp->token_len + 1 < sizeof(qp->token_curr)) qp->token_curr[qp->token_len++] = oldchar; qp->prev_token_end = TRUE; qp->token_curr[qp->token_len] = '\0'; strncpy_null(finished_token, qp->token_curr, sizeof(qp->token_curr)); MYLOG(DETAIL_LOG_LEVEL, "finished token=%s\n", finished_token); ret = qp->token_len; } return ret; } static int token_restart(QueryParse *qp, char oldchar, char *finished_token) { int ret = token_finish(qp, 0, finished_token); if (IS_NOT_SPACE(oldchar)) token_start(qp, oldchar); return ret; } static int token_continue(QueryParse *qp, char oldchar) { if (qp->prev_token_end) token_start(qp, oldchar); else if (qp->token_len + 1 < sizeof(qp->token_curr)) qp->token_curr[qp->token_len++] = oldchar; return qp->token_len; } /* * ParseToken functions */ typedef struct { QueryParse *qp; int token_len; BOOL curchar_processed; unsigned int in_status; char finished_token[sizeof(((QueryParse *) NULL)->token_curr)]; } ParseToken; static void PT_initialize(ParseToken *pt, QueryParse *qp) { pt->qp = qp; pt->token_len = -1; pt->curchar_processed = FALSE; pt->in_status = 0; pt->finished_token[0] = '\0'; } static int PT_token_finish(ParseToken *pt, char oldchar) { int token_len_tmp; if (pt->curchar_processed) return pt->token_len; if ((token_len_tmp = token_finish(pt->qp, oldchar, pt->finished_token)) > 0) { pt->token_len = token_len_tmp; pt->in_status = pt->qp->in_status; } if (oldchar) pt->curchar_processed = TRUE; return pt->token_len; } static int PT_token_restart(ParseToken *pt, char oldchar) { int token_len_tmp; unsigned int in_status_save; if (pt->curchar_processed) return pt->token_len; in_status_save = pt->qp->in_status; if ((token_len_tmp = token_restart(pt->qp, oldchar, pt->finished_token)) > 0) { pt->token_len = token_len_tmp; pt->in_status = in_status_save; } pt->curchar_processed = TRUE; return pt->token_len; } static int PT_token_continue(ParseToken *pt, char oldchar) { if (pt->curchar_processed) return pt->token_len; token_continue(pt->qp, oldchar); pt->curchar_processed = TRUE; return pt->token_len; } #define PT_TOKEN_IGNORE(pt) ((pt)->curchar_processed = TRUE) static int inner_process_tokens(QueryParse *qp, QueryBuild *qb) { CSTR func = "inner_process_tokens"; BOOL lf_conv = ((qb->flags & FLGB_CONVERT_LF) != 0); const char *bestitem = NULL; RETCODE retval; Int4 opos; char oldchar; StatementClass *stmt = qb->stmt; BOOL isnull; BOOL isbinary; Oid dummy; ParseToken pts, *pt = &pts; PT_initialize(pt, qp); if (stmt->ntab > 0) bestitem = GET_NAME(stmt->ti[0]->bestitem); opos = (Int4) qp->opos; if (opos < 0) { qb->errornumber = STMT_SEQUENCE_ERROR; qb->errormsg = "Function call for inner_process_tokens sequence error"; return SQL_ERROR; } if (qp->from_pos == opos) { if (0 == (qb->flags & FLGB_CREATE_KEYSET)) { qb->errornumber = STMT_SEQUENCE_ERROR; qb->errormsg = "Should come here only when handling updatable cursors"; return SQL_ERROR; } CVT_APPEND_STR(qb, ", \"ctid"); if (bestitem) { CVT_APPEND_STR(qb, "\", \""); CVT_APPEND_STR(qb, bestitem); } CVT_APPEND_STR(qb, "\" "); qb->load_from_pos = qb->npos; } else if (qp->where_pos == opos) { qb->load_stmt_len = qb->npos; if (0 != (qb->flags & FLGB_KEYSET_DRIVEN)) { CVT_APPEND_STR(qb, "where ctid = '(0,0)';select \"ctid"); if (bestitem) { CVT_APPEND_STR(qb, "\", \""); CVT_APPEND_STR(qb, bestitem); } CVT_APPEND_STR(qb, "\" from "); CVT_APPEND_DATA(qb, qp->statement + qp->from_pos + 5, qp->where_pos - qp->from_pos - 5); } } oldchar = encoded_byte_check(&qp->encstr, qp->opos); if (MBCS_NON_ASCII(qp->encstr)) { if (QP_in_idle_status(qp)) { PT_token_restart(pt, oldchar); /* placed before QP_enter() */ QP_enter(qp, QP_IN_IDENT_KEYWORD); /* identifier */ } else if (qp->token_len > 0) PT_token_continue(pt, oldchar); CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } /* * From here we are guaranteed to handle a 1-byte character. */ if (QP_is_in(qp, QP_IN_IDENT_KEYWORD)) /* identifier or keyword */ { if (isalnum((UCHAR)oldchar) || DOLLAR_QUOTE == oldchar || '_' == oldchar) { CVT_APPEND_CHAR(qb, oldchar); PT_token_continue(pt, oldchar); return SQL_SUCCESS; } PT_token_finish(pt, 0); /* placed before QP_exit() */ QP_exit(qp, QP_IN_IDENT_KEYWORD); } if (QP_is_in(qp, QP_IN_ESCAPE)) /* escape in literal check */ { QP_exit(qp, QP_IN_ESCAPE); CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else if (QP_is_in(qp, QP_IN_DOLLAR_QUOTE)) /* dollar quote check */ { if (oldchar == DOLLAR_QUOTE) { if (strncmp(F_OldPtr(qp), qp->dollar_tag, qp->taglen) == 0) { CVT_APPEND_DATA(qb, F_OldPtr(qp), qp->taglen); qp->opos += (qp->taglen - 1); QP_exit(qp, QP_IN_DOLLAR_QUOTE); qp->dollar_tag = NULL; qp->taglen = -1; return SQL_SUCCESS; } } CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else if (QP_is_in(qp, QP_IN_LITERAL)) /* quote check */ { if (oldchar == LITERAL_QUOTE) { PT_token_finish(pt, oldchar); /* placed before QP_exit() */ QP_exit(qp, QP_IN_LITERAL); } else { PT_token_continue(pt, oldchar); if (oldchar == qp->escape_in_literal) QP_enter(qp, QP_IN_ESCAPE); /* escape in literal */ } CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else if (QP_is_in(qp, QP_IN_DQUOTE_IDENTIFIER)) /* double quote check */ { if (oldchar == IDENTIFIER_QUOTE) { PT_token_finish(pt, oldchar); /* placed before QP_exit() */ QP_exit(qp, QP_IN_DQUOTE_IDENTIFIER); } else PT_token_continue(pt, oldchar); CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else if (QP_is_in(qp, QP_IN_COMMENT_BLOCK)) /* comment_level check */ { if ('/' == oldchar && '*' == F_OldPtr(qp)[1]) { qp->comment_level++; QP_enter(qp, QP_IN_COMMENT_BLOCK); CVT_APPEND_CHAR(qb, oldchar); F_OldNext(qp); oldchar = F_OldChar(qp); } else if ('*' == oldchar && '/' == F_OldPtr(qp)[1]) { if (--qp->comment_level <= 0) QP_exit(qp, QP_IN_COMMENT_BLOCK); CVT_APPEND_CHAR(qb, oldchar); F_OldNext(qp); oldchar = F_OldChar(qp); } CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else if (QP_is_in(qp, QP_IN_LINE_COMMENT)) /* line comment check */ { if (PG_LINEFEED == oldchar) QP_exit(qp, QP_IN_LINE_COMMENT); CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } if (!QP_in_idle_status(qp)) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "logic error? not in QP_in_idle_status"; return SQL_ERROR; } /* * From here we are guaranteed to be in neither a literal_escape, * a LITREAL_QUOTE nor an IDENTIFIER_QUOTE. */ /* Squeeze carriage-return/linefeed pairs to linefeed only */ if (lf_conv && PG_CARRIAGE_RETURN == oldchar && qp->opos + 1 < qp->stmt_len && PG_LINEFEED == qp->statement[qp->opos + 1]) return SQL_SUCCESS; /* * Handle literals (date, time, timestamp) and ODBC scalar * functions */ if (oldchar == ODBC_ESCAPE_START) { PT_token_finish(pt, 0); if (SQL_ERROR == convert_escape(qp, qb)) { if (0 == qb->errornumber) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "ODBC escape convert error"; } MYLOG(0, "convert_escape error\n"); return SQL_ERROR; } PT_TOKEN_IGNORE(pt); return SQL_SUCCESS; } /* End of an escape sequence */ else if (oldchar == ODBC_ESCAPE_END) { PT_token_finish(pt, 0); PT_TOKEN_IGNORE(pt); return QB_end_brace(qb); } else if (oldchar == '@' && strnicmp(F_OldPtr(qp), "@@identity", 10) == 0) { ConnectionClass *conn = SC_get_conn(stmt); BOOL converted = FALSE; COL_INFO *coli; #ifdef NOT_USED /* lastval() isn't always appropriate */ if (PG_VERSION_GE(conn, 8.1)) { CVT_APPEND_STR(qb, "lastval()"); converted = TRUE; } else #endif /* NOT_USED */ if (NAME_IS_VALID(conn->tableIns)) { TABLE_INFO ti, *pti = &ti; memset(&ti, 0, sizeof(ti)); NAME_TO_NAME(ti.schema_name, conn->schemaIns); NAME_TO_NAME(ti.table_name, conn->tableIns); getCOLIfromTI(func, conn, qb->stmt, 0, &pti); coli = ti.col_info; NULL_THE_NAME(ti.schema_name); NULL_THE_NAME(ti.table_name); if (NULL != coli) { int i, num_fields = QR_NumResultCols(coli->result); const char *auto_increment; for (i = 0; i < num_fields; i++) { auto_increment = (const char *) QR_get_value_backend_text(coli->result, i, COLUMNS_AUTO_INCREMENT); if (auto_increment && auto_increment[0] == '1') { converted = TRUE; break; } } if (converted) { const char *column_def = (const char *) QR_get_value_backend_text(coli->result, i, COLUMNS_COLUMN_DEF); if (NULL != column_def && strncmp(column_def, "nextval", 7) == 0) { CVT_APPEND_STR(qb, "curr"); CVT_APPEND_STR(qb, column_def + 4); } else { char relcnv[128]; const char *column_name = (const char *) QR_get_value_backend_text(coli->result, i, COLUMNS_COLUMN_NAME); CVT_APPEND_STR(qb, "currval(pg_get_serial_sequence('"); if (NAME_IS_VALID(conn->schemaIns)) { CVT_APPEND_STR(qb, identifierEscape((const SQLCHAR *) SAFE_NAME(conn->schemaIns), SQL_NTS, conn, relcnv, sizeof(relcnv), TRUE)); CVT_APPEND_STR(qb, "."); } CVT_APPEND_STR(qb, identifierEscape((const SQLCHAR *) SAFE_NAME(conn->tableIns), SQL_NTS, conn, relcnv, sizeof(relcnv), TRUE)); CVT_APPEND_STR(qb, "','"); if (NULL != column_name) CVT_APPEND_STR(qb, identifierEscape((const SQLCHAR *) column_name, SQL_NTS, conn, relcnv, sizeof(relcnv), FALSE)); CVT_APPEND_STR(qb, "')::regclass)"); } } } TI_ClearObject(pti); } if (!converted) CVT_APPEND_STR(qb, "NULL"); qp->opos += 10; return SQL_SUCCESS; } /* * Can you have parameter markers inside of quotes? I dont think * so. All the queries I've seen expect the driver to put quotes * if needed. */ else if (oldchar != '?') { if (oldchar == DOLLAR_QUOTE) { PT_token_finish(pt, 0); qp->taglen = findTag(F_OldPtr(qp), qp->encstr.ccsc); if (qp->taglen > 0) { QP_enter(qp, QP_IN_DOLLAR_QUOTE); qp->dollar_tag = F_OldPtr(qp); CVT_APPEND_DATA(qb, F_OldPtr(qp), qp->taglen); qp->opos += (qp->taglen - 1); return SQL_SUCCESS; } } else if (oldchar == LITERAL_QUOTE) { PT_token_restart(pt, oldchar); /* placed before QP_enter() */ QP_enter(qp, QP_IN_LITERAL); qp->escape_in_literal = CC_get_escape(qb->conn); if (!qp->escape_in_literal) { if (LITERAL_EXT == F_OldPtr(qp)[-1]) qp->escape_in_literal = ESCAPE_IN_LITERAL; } } else if (oldchar == IDENTIFIER_QUOTE) { PT_token_restart(pt, oldchar); /* placed before QP_enter() */ QP_enter(qp, QP_IN_DQUOTE_IDENTIFIER); } else if ('/' == oldchar && '*' == F_OldPtr(qp)[1]) { qp->comment_level++; PT_token_finish(pt, 0); /* comments are excluded */ QP_enter(qp, QP_IN_COMMENT_BLOCK); PT_TOKEN_IGNORE(pt); } else if ('-' == oldchar && '-' == F_OldPtr(qp)[1]) { PT_token_finish(pt, 0); /* comments are excluded */ QP_enter(qp, QP_IN_LINE_COMMENT); PT_TOKEN_IGNORE(pt); } else if (oldchar == ';') { PT_token_restart(pt, 0); /* * can't parse multiple statement using protocol V3. * reset the dollar number here in case it is divided * to parse. */ qb->dollar_number = 0; if (0 != (qp->flags & FLGP_USING_CURSOR)) { const char *vp = &(qp->statement[qp->opos + 1]); while (*vp && isspace((unsigned char) *vp)) vp++; if (*vp) /* multiple statement */ { qp->flags |= FLGP_MULTIPLE_STATEMENT; qb->flags &= ~FLGB_KEYSET_DRIVEN; remove_declare_cursor(qb, qp); } } } else if (isalnum(oldchar)) { PT_token_restart(pt, oldchar); /* placed before QP_enter() */ QP_enter(qp, QP_IN_IDENT_KEYWORD); /* identifier or keyword */ } else { /* * a hack to handle boolean items in VBA * with MS Access. * VBA seems to transform the where condition * a_boolean_item=True * into * ("a_boolean_item" = 1) * which causes an ERROR:Operator does not exist boolean = integer . * So transforms it into * ("a_boolean_item"='1') * here. */ if (')' == oldchar && qb->conn->ms_jet && 1 == qp->token_len && '1' == qp->token_curr[0] && 8 <= F_OldPos(qp)) { const char *oldptr = F_OldPtr(qp); int oldpos = F_OldPos(qp); if (strncmp(oldptr - 5, "\" =", 3) == 0) { int i; for (i = 6; i < oldpos - 1; i++) { if (oldptr[-i] == '"') { if (oldptr[-(i+1)] == '(') { F_NewPtr(qb)[-4] = '='; F_NewPtr(qb)[-3] = '\''; F_NewPtr(qb)[-2] = '1'; F_NewPtr(qb)[-1] = '\''; } break; } } } } if (!isalnum((UCHAR) oldchar)) { PT_token_restart(pt, oldchar); } else PT_token_continue(pt, oldchar); } if (pt->token_len > 0) MYLOG(0, "token_len=%d status=%x token=%s\n", pt->token_len, pt->in_status, pt->finished_token); if (!pt->curchar_processed) { MYLOG(0, "Forgot to process ParseToken char=%c status=%u\n", oldchar, qp->in_status); #ifdef NOT_USED /* strict check for debugging */ qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "Forget to process ParseToken"; return SQL_ERROR; #endif /* NOT_USED */ } switch (pt->token_len) { case 4: if (0 != (qp->flags & FLGP_USING_CURSOR) && into_table_from(&qp->statement[qp->opos - pt->token_len])) { qp->flags |= FLGP_SELECT_INTO; qb->flags &= ~FLGB_KEYSET_DRIVEN; qp->statement_type = STMT_TYPE_CREATE; remove_declare_cursor(qb, qp); } else if (stricmp(pt->finished_token, "join") == 0) check_join(stmt, F_OldPtr(qp), F_OldPos(qp)); break; case 3: if (0 != (qp->flags & FLGP_USING_CURSOR) && strnicmp(pt->finished_token, "for", 3) == 0) { UInt4 flg; size_t endpos; flg = table_for_update_or_share(F_OldPtr(qp), &endpos); if (0 != (FLGP_SELECT_FOR_UPDATE_OR_SHARE & flg)) { qp->flags |= flg; remove_declare_cursor(qb, qp); } else qp->flags |= flg; } break; case 2: { size_t endpos; if (STMT_TYPE_INSERT == qp->statement_type && strnicmp(pt->finished_token, "()", 2) == 0 && insert_without_target(F_OldPtr(qp), &endpos)) { qb->npos -= 2; CVT_APPEND_STR(qb, "DEFAULT VALUES"); qp->opos += endpos; return SQL_SUCCESS; } break; } case 1: { size_t endpos; if (STMT_TYPE_INSERT == qp->statement_type && pt->finished_token[0] == '(' && oldchar == ')' && insert_without_target(F_OldPtr(qp)+1, &endpos)) { qb->npos --; CVT_APPEND_STR(qb, " DEFAULT VALUES"); qp->opos += endpos; return SQL_SUCCESS; } break; } } CVT_APPEND_CHAR(qb, oldchar); return SQL_SUCCESS; } else PT_token_restart(pt, oldchar); /* * It's a '?' parameter alright */ retval = ResolveOneParam(qb, qp, &isnull, &isbinary, &dummy); if (retval < 0) return retval; if (SQL_SUCCESS_WITH_INFO == retval) /* means discarding output parameter */ { } retval = SQL_SUCCESS; cleanup: return retval; } #define MIN_ALC_SIZE 128 /* * Build an array of parameters to pass to libpq's PQexecPrepared * function. */ BOOL build_libpq_bind_params(StatementClass *stmt, int *nParams, OID **paramTypes, char ***paramValues, int **paramLengths, int **paramFormats, int *resultFormat) { CSTR func = "build_libpq_bind_params"; QueryBuild qb; SQLSMALLINT num_p; int i, num_params; ConnectionClass *conn = SC_get_conn(stmt); BOOL ret = FALSE, discard_output; RETCODE retval; const IPDFields *ipdopts = SC_get_IPDF(stmt); *paramTypes = NULL; *paramValues = NULL; *paramLengths = NULL; *paramFormats = NULL; num_params = stmt->num_params; if (num_params < 0) { PGAPI_NumParams(stmt, &num_p); num_params = num_p; } if (ipdopts->allocated < num_params) { char tmp[100]; if (0 == ipdopts->allocated) STRCPY_FIXED(tmp, "Parameters exist but IPD isn't set. Please call SQLDescribeParam()"); else SPRINTF_FIXED(tmp, "The # of IPD parameters %d < %d the # of parameter markers", ipdopts->allocated, num_params); MYLOG(0, "%s\n", tmp); SC_set_error(stmt, STMT_COUNT_FIELD_INCORRECT, tmp, func); return FALSE; } if (QB_initialize(&qb, MIN_ALC_SIZE, stmt, RPM_BUILDING_BIND_REQUEST) < 0) return FALSE; if (num_params > 0) { *paramTypes = malloc(sizeof(OID) * num_params); if (*paramTypes == NULL) goto cleanup; *paramValues = malloc(sizeof(char *) * num_params); if (*paramValues == NULL) goto cleanup; memset(*paramValues, 0, sizeof(char *) * num_params); *paramLengths = malloc(sizeof(int) * num_params); if (*paramLengths == NULL) goto cleanup; *paramFormats = malloc(sizeof(int) * num_params); if (*paramFormats == NULL) goto cleanup; } qb.flags |= FLGB_BINARY_AS_POSSIBLE; MYLOG(DETAIL_LOG_LEVEL, "num_params=%d proc_return=%d\n", num_params, stmt->proc_return); num_p = num_params - qb.num_discard_params; MYLOG(DETAIL_LOG_LEVEL, "num_p=%d\n", num_p); discard_output = (0 != (qb.flags & FLGB_DISCARD_OUTPUT)); *nParams = 0; if (num_p > 0) { ParameterImplClass *parameters = ipdopts->parameters; int pno; BOOL isnull; BOOL isbinary; char *val_copy; OID pgType; /* * Now build the parameter values. */ for (i = 0, pno = 0; i < stmt->num_params; i++) { qb.npos = 0; retval = ResolveOneParam(&qb, NULL, &isnull, &isbinary, &pgType); if (SQL_ERROR == retval) { QB_replace_SC_error(stmt, &qb, func); ret = FALSE; goto cleanup; } MYLOG(DETAIL_LOG_LEVEL, "%dth parameter type oid is %u\n", i, PIC_dsp_pgtype(conn, parameters[i])); if (i < qb.proc_return) continue; if (SQL_PARAM_OUTPUT == parameters[i].paramType) { if (discard_output) continue; (*paramTypes)[pno] = PG_TYPE_VOID; (*paramValues)[pno] = NULL; (*paramLengths)[pno] = 0; (*paramFormats)[pno] = 0; pno++; continue; } if (!isnull) { val_copy = malloc(qb.npos + 1); if (!val_copy) goto cleanup; memcpy(val_copy, qb.query_statement, qb.npos); val_copy[qb.npos] = '\0'; (*paramTypes)[pno] = pgType; (*paramValues)[pno] = val_copy; if (qb.npos > INT_MAX) goto cleanup; (*paramLengths)[pno] = (int) qb.npos; } else { (*paramTypes)[pno] = pgType; (*paramValues)[pno] = NULL; (*paramLengths)[pno] = 0; } if (isbinary) MYLOG(0, "%dth parameter is of binary format\n", pno); (*paramFormats)[pno] = isbinary ? 1 : 0; pno++; } *nParams = pno; } /* result format is text */ *resultFormat = 0; ret = TRUE; cleanup: QB_Destructor(&qb); return ret; } /* * With SQL_MAX_NUMERIC_LEN = 16, the highest representable number is * 2^128 - 1, which fits in 39 digits. */ #define MAX_NUMERIC_DIGITS 39 /* * Convert a SQL_NUMERIC_STRUCT into string representation. */ static void ResolveNumericParam(const SQL_NUMERIC_STRUCT *ns, char *chrform) { Int4 i, vlen, len, newlen; const UCHAR *val = (const UCHAR *) ns->val; UCHAR vals[SQL_MAX_NUMERIC_LEN]; int lastnonzero; UCHAR calv[MAX_NUMERIC_DIGITS]; int precision; MYLOG(DETAIL_LOG_LEVEL, "C_NUMERIC [prec=%d scale=%d]", ns->precision, ns->scale); if (0 == ns->precision) { if (chrform) strncpy_null(chrform, "0", 2); return; } precision = ns->precision; if (precision > MAX_NUMERIC_DIGITS) precision = MAX_NUMERIC_DIGITS; /* * The representation in SQL_NUMERIC_STRUCT is 16 bytes with most * significant byte first. Make a working copy. */ memcpy(vals, val, SQL_MAX_NUMERIC_LEN); vlen = SQL_MAX_NUMERIC_LEN; len = 0; do { UInt2 d, r; /* * Divide the number by 10, and output the reminder as the next digit. * * Begin from the most-significant byte (last in the array), and at * each step, carry the remainder to the prev byte. */ r = 0; lastnonzero = -1; for (i = vlen - 1; i >= 0; i--) { UInt2 v; v = ((UInt2) vals[i]) + (r << 8); d = v / 10; r = v % 10; vals[i] = (UCHAR) d; if (d != 0 && lastnonzero == -1) lastnonzero = i; } /* output the remainder */ calv[len++] = (UCHAR) r; vlen = lastnonzero + 1; } while(lastnonzero >= 0 && len < precision); /* * calv now contains the digits in reverse order, i.e. least significant * digit is at calv[0] */ MYPRINTF(DETAIL_LOG_LEVEL, " len2=%d", len); /* build the final output string. */ newlen = 0; if (0 == ns->sign) chrform[newlen++] = '-'; i = len - 1; if (i < ns->scale) i = ns->scale; for (; i >= ns->scale; i--) { if (i >= len) chrform[newlen++] = '0'; else chrform[newlen++] = calv[i] + '0'; } if (ns->scale > 0) { chrform[newlen++] = '.'; for (; i >= 0; i--) { if (i >= len) chrform[newlen++] = '0'; else chrform[newlen++] = calv[i] + '0'; } } if (0 == len) chrform[newlen++] = '0'; chrform[newlen] = '\0'; MYLOG(DETAIL_LOG_LEVEL, " convval(2) len=%d %s\n", newlen, chrform); } /* * Convert a string representation of a numeric into SQL_NUMERIC_STRUCT. */ static void parse_to_numeric_struct(const char *wv, SQL_NUMERIC_STRUCT *ns, BOOL *overflow) { int i, nlen, dig; char calv[SQL_MAX_NUMERIC_LEN * 3]; BOOL dot_exist; *overflow = FALSE; /* skip leading space */ while (*wv && isspace((unsigned char) *wv)) wv++; /* sign */ ns->sign = 1; if (*wv == '-') { ns->sign = 0; wv++; } else if (*wv == '+') wv++; /* skip leading zeros */ while (*wv == '0') wv++; /* read the digits into calv */ ns->precision = 0; ns->scale = 0; for (nlen = 0, dot_exist = FALSE;; wv++) { if (*wv == '.') { if (dot_exist) break; dot_exist = TRUE; } else if (*wv == '\0' || !isdigit((unsigned char) *wv)) break; else { if (nlen >= sizeof(calv)) { if (dot_exist) break; else { ns->scale--; *overflow = TRUE; continue; } } if (dot_exist) ns->scale++; calv[nlen++] = *wv; } } ns->precision = nlen; /* Convert the decimal digits to binary */ memset(ns->val, 0, sizeof(ns->val)); for (dig = 0; dig < nlen; dig++) { UInt4 carry; /* multiply the current value by 10, and add the next digit */ carry = calv[dig] - '0'; for (i = 0; i < sizeof(ns->val); i++) { UInt4 t; t = ((UInt4) ns->val[i]) * 10 + carry; ns->val[i] = (unsigned char) (t & 0xFF); carry = (t >> 8); } if (carry != 0) *overflow = TRUE; } } static BOOL parameter_is_with_cast(const QueryParse *qp) { const char *str = F_OldPtr(qp); if ('?' != *str) return FALSE; while (isspace(*(++str))) ; if (strncmp(str, "::", 2) == 0) return TRUE; if (strnicmp(str, "as", 2) != 0) return FALSE; if (isspace(str[2])) return TRUE; return FALSE; } #ifdef UNICODE_SUPPORT enum { ErrorOutConversionErrors /* error out conversion errors */ , ReturnZeroLengthString /* simply returns zero length strings */ }; static int convert_err_flag = #ifdef WIN32 ReturnZeroLengthString; #else ErrorOutConversionErrors; #endif /* WIN32 */ static BOOL handle_lu_onvert_error(QueryBuild *qb, int flag, char *buffer, SQLLEN paralen) { int blen = paralen; if (!buffer) return FALSE; if (get_mylog() > 0 || ReturnZeroLengthString != flag) { const UCHAR *buf = (UCHAR *) buffer; int i; PQExpBufferData pbuf = {0}; if (SQL_NTS == blen) blen = strlen(buffer); initPQExpBuffer(&pbuf); appendPQExpBuffer(&pbuf, "Could not convert the current data '"); for (i = 0; i < blen; i++) { if (buf[i] >= 0x80) appendPQExpBuffer(&pbuf, "\\%03o", buf[i]); else if ('\\' == buf[i]) appendPQExpBuffer(&pbuf, "\\\\"); else appendPQExpBuffer(&pbuf, "%c", buf[i]); } appendPQExpBuffer(&pbuf, "' to wide chars"); MYLOG(0, "%s\n", pbuf.data); if (ReturnZeroLengthString != flag) { if (qb->stmt) SC_set_error(qb->stmt, STMT_EXEC_ERROR, pbuf.data, __FUNCTION__); else qb->errormsg = "could not convert the current data to wide chars"; } termPQExpBuffer(&pbuf); } switch (flag) { case ReturnZeroLengthString: if (qb->stmt) SC_set_error(qb->stmt, STMT_ERROR_IN_ROW, "conversion error to wide chars occurred", __FUNCTION__); return TRUE; default: qb->errornumber = STMT_EXEC_ERROR; return FALSE; } } #endif /* UNICODE_SUPPORT */ /* * Resolve one parameter. * * *isnull is set to TRUE if it was NULL. * *isbinary is set to TRUE, if the binary output format was used. (binary * output is only produced if the FLGB_BINARY_AS_POSSIBLE flag is set) * *pgType is set to the PostgreSQL type OID that should be used when binding * (or 0, to let the server decide) */ static int ResolveOneParam(QueryBuild *qb, QueryParse *qp, BOOL *isnull, BOOL *isbinary, OID *pgType) { ConnectionClass *conn = qb->conn; const APDFields *apdopts = qb->apdopts; const IPDFields *ipdopts = qb->ipdopts; PutDataInfo *pdata = qb->pdata; int param_number; char param_string[150], tmp[256]; char cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to handle the data in this function */ OID param_pgtype; SQLSMALLINT param_ctype, param_sqltype; SIMPLE_TIME st; struct tm *tim; SQLLEN used; const char *send_buf; char *buffer, *allocbuf = NULL, *lastadd = NULL; OID lobj_oid; int lobj_fd; SQLULEN offset = apdopts->param_offset_ptr ? *apdopts->param_offset_ptr : 0; size_t current_row = qb->current_row; BOOL handling_large_object = FALSE, req_bind; BOOL need_quotes = TRUE; BOOL add_parens = FALSE; BOOL negative; ParameterInfoClass *apara; ParameterImplClass *ipara; BOOL outputDiscard, valueOutput; SDOUBLE dbv; SFLOAT flv; SQL_INTERVAL_STRUCT *ivstruct; const char *ivsign; BOOL final_binary_convert = FALSE; RETCODE retval = SQL_ERROR; *isnull = FALSE; *isbinary = FALSE; *pgType = 0; outputDiscard = (0 != (qb->flags & FLGB_DISCARD_OUTPUT)); valueOutput = (qb->param_mode != RPM_FAKE_PARAMS && qb->param_mode != RPM_BUILDING_PREPARE_STATEMENT); req_bind = (qb->param_mode == RPM_BUILDING_BIND_REQUEST); if (qb->proc_return < 0 && qb->stmt) qb->proc_return = qb->stmt->proc_return; /* * It's a '?' parameter alright */ param_number = ++qb->param_number; MYLOG(DETAIL_LOG_LEVEL, "para:%d(%d,%d)\n", param_number, ipdopts->allocated, apdopts->allocated); apara = NULL; ipara = NULL; if (param_number < apdopts->allocated) apara = apdopts->parameters + param_number; if (param_number < ipdopts->allocated) ipara = ipdopts->parameters + param_number; if ((!apara || !ipara) && valueOutput) { MYLOG(0, "The # of (A|I)PD parameters (%d, %d) < %d the # of parameter markers\n", apdopts->allocated, ipdopts->allocated, param_number); qb->errormsg = "The # of binded parameters < the # of parameter markers"; qb->errornumber = STMT_COUNT_FIELD_INCORRECT; CVT_TERMINATE(qb); /* just in case */ return SQL_ERROR; } MYLOG(DETAIL_LOG_LEVEL, "ipara=%p paramName=%s paramType=%d %d proc_return=%d\n", ipara, ipara ? PRINT_NAME(ipara->paramName) : PRINT_NULL, ipara ? ipara->paramType : -1, PG_VERSION_LT(conn, 8.1), qb->proc_return); if (param_number < qb->proc_return) { if (ipara && SQL_PARAM_OUTPUT != ipara->paramType) { qb->errormsg = "The function return value isn't marked as output parameter"; qb->errornumber = STMT_EXEC_ERROR; CVT_TERMINATE(qb); /* just in case */ return SQL_ERROR; } return SQL_SUCCESS; } if (ipara && SQL_PARAM_OUTPUT == ipara->paramType) { if (PG_VERSION_LT(conn, 8.1)) { qb->errormsg = "Output parameter isn't available before 8.1 version"; qb->errornumber = STMT_INTERNAL_ERROR; CVT_TERMINATE(qb); /* just in case */ return SQL_ERROR; } if (outputDiscard) { ssize_t npos = 0; for (npos = qb->npos - 1; npos >= 0 && isspace((unsigned char) qb->query_statement[npos]) ; npos--) ; if (npos >= 0) { switch (qb->query_statement[npos]) { case ',': qb->npos = npos; qb->query_statement[npos] = '\0'; break; case '(': if (!qp) break; for (npos = qp->opos + 1; isspace((unsigned char) qp->statement[npos]); npos++) ; if (qp->statement[npos] == ',') qp->opos = npos; break; } } return SQL_SUCCESS_WITH_INFO; } } else { /* For procedures, use named notation if a parameter name is specified */ if (!req_bind && ipara && NAME_IS_VALID(ipara->paramName) && qp && qp->statement_type == STMT_TYPE_PROCCALL) { char named_notation[COLUMN_NAME_STORAGE_LEN + 7]; SPRINTF_FIXED(named_notation, "\"%s\" := ", GET_NAME(ipara->paramName)); CVT_APPEND_STR(qb, named_notation); } } if ((!apara || !ipara) && qb->param_mode == RPM_FAKE_PARAMS) { CVT_APPEND_STR(qb, "NULL"); qb->flags |= FLGB_INACCURATE_RESULT; return SQL_SUCCESS; } if (qb->param_mode == RPM_BUILDING_PREPARE_STATEMENT) { char pnum[16]; qb->dollar_number++; if (ipara && SQL_PARAM_OUTPUT != ipara->paramType && (qb->flags & FLGB_PARAM_CAST) != 0 && !parameter_is_with_cast(qp)) SPRINTF_FIXED(pnum, "$%d%s", qb->dollar_number, sqltype_to_pgcast(conn, ipara->SQLType)); else SPRINTF_FIXED(pnum, "$%d", qb->dollar_number); CVT_APPEND_STR(qb, pnum); return SQL_SUCCESS; } /* * After this point, we can assume apara and ipara to be set. The only * cases where we allow them to be NULL is when param_mode is * RPM_FAKE_PARAMS or RPM_BUILDING_PREPARE_STATEMENT, and we've now handled * those cases. */ /* Assign correct buffers based on data at exec param or not */ if (apara->data_at_exec) { if (pdata->allocated != apdopts->allocated) extend_putdata_info(pdata, apdopts->allocated, TRUE); used = pdata->pdata[param_number].EXEC_used ? *pdata->pdata[param_number].EXEC_used : SQL_NTS; buffer = pdata->pdata[param_number].EXEC_buffer; if (pdata->pdata[param_number].lobj_oid) handling_large_object = TRUE; } else { UInt4 bind_size = apdopts->param_bind_type; UInt4 ctypelen; BOOL bSetUsed = FALSE; buffer = apara->buffer + offset; if (current_row > 0) { if (bind_size > 0) buffer += (bind_size * current_row); else if (ctypelen = ctype_length(apara->CType), ctypelen > 0) buffer += current_row * ctypelen; else buffer += current_row * apara->buflen; } if (apara->used || apara->indicator) { SQLULEN p_offset; if (bind_size > 0) p_offset = offset + bind_size * current_row; else p_offset = offset + sizeof(SQLLEN) * current_row; if (apara->indicator) { used = *LENADDR_SHIFT(apara->indicator, p_offset); if (SQL_NULL_DATA == used) bSetUsed = TRUE; } if (!bSetUsed && apara->used) { used = *LENADDR_SHIFT(apara->used, p_offset); bSetUsed = TRUE; } } if (!bSetUsed) used = SQL_NTS; } /* Handle DEFAULT_PARAM parameter data. Should be NULL ? if (used == SQL_DEFAULT_PARAM) { return SQL_SUCCESS; } */ param_ctype = apara->CType; param_sqltype = ipara->SQLType; param_pgtype = PIC_dsp_pgtype(qb->conn, *ipara); /* XXX: should we use param_pgtype here instead? */ *pgType = sqltype_to_bind_pgtype(conn, param_sqltype); if (0 == param_sqltype) /* calling SQLSetStmtAttr(.., SQL_ATTR_APP_PARAM_DES, an ARD of another statement) may cause this */ { if (0 != param_pgtype) { param_sqltype = pgtype_attr_to_concise_type(conn, param_pgtype, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET); MYLOG(0, "convert from pgtype(%u) to sqltype(%d)\n", param_pgtype, param_sqltype); } } MYLOG(0, "from(fcType)=%d, to(fSqlType)=%d(%u), *pgType=%u\n", param_ctype, param_sqltype, param_pgtype, *pgType); /* Handle NULL parameter data */ if (SQL_PARAM_OUTPUT == ipara->paramType || used == SQL_NULL_DATA || used == SQL_DEFAULT_PARAM) { *isnull = TRUE; if (!req_bind) CVT_APPEND_STR(qb, "NULL"); return SQL_SUCCESS; } /* * If no buffer, and it's not null, then what the hell is it? Just * leave it alone then. */ if (!buffer) { if (qb->param_mode == RPM_FAKE_PARAMS) { CVT_APPEND_STR(qb, "NULL"); qb->flags |= FLGB_INACCURATE_RESULT; return SQL_SUCCESS; } else if (!handling_large_object) { /* shouldn't happen */ qb->errormsg = "unexpected NULL parameter value"; qb->errornumber = STMT_EXEC_ERROR; return SQL_ERROR; } } /* replace DEFAULT with something we can use */ if (param_ctype == SQL_C_DEFAULT) { param_ctype = sqltype_to_default_ctype(conn, param_sqltype); #ifdef UNICODE_SUPPORT if (param_ctype == SQL_C_WCHAR && CC_default_is_c(conn)) param_ctype =SQL_C_CHAR; #endif } allocbuf = NULL; send_buf = NULL; param_string[0] = '\0'; cbuf[0] = '\0'; memset(&st, 0, sizeof(st)); ivstruct = (SQL_INTERVAL_STRUCT *) buffer; /* Convert input C type to a neutral format */ #ifdef UNICODE_SUPPORT if (get_convtype() > 0) /* conversion between the current locale is available */ { BOOL wcs_debug = conn->connInfo.wcs_debug; BOOL is_utf8 = (UTF8 == conn->ccsc); BOOL same_encoding = (conn->ccsc == pg_CS_code(conn->locale_encoding)); switch (param_ctype) { case SQL_C_CHAR: if (!same_encoding || wcs_debug) { SQLLEN paralen = used; MYLOG(0, "locale param convert\n"); if ((used = bindpara_msg_to_utf8(buffer, &allocbuf, used)) < 0) { if (!handle_lu_onvert_error(qb, convert_err_flag, buffer, paralen)) goto cleanup; send_buf = NULL_STRING; used = 0; } else send_buf = allocbuf; } break; case SQL_C_WCHAR: if (!is_utf8 || (same_encoding && wcs_debug)) { MYLOG(0, "hybrid param convert\n"); if ((used = bindpara_wchar_to_msg((SQLWCHAR *) buffer, &allocbuf, used)) < 0) { qb->errormsg = "Could not convert from wide characters to the current locale"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } send_buf = allocbuf; } break; } } #endif /* UNICODE_SUPPORT */ switch (param_ctype) { case SQL_C_BINARY: send_buf = buffer; break; case SQL_C_CHAR: if (NULL == send_buf) send_buf = buffer; break; #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: MYLOG(0, " C_WCHAR=%d contents=%s(" FORMAT_LEN ")\n", param_ctype, buffer, used); if (NULL == send_buf) { allocbuf = ucs2_to_utf8((SQLWCHAR *) buffer, used > 0 ? used / WCLEN : used, &used, FALSE); send_buf = allocbuf; } break; #endif /* UNICODE_SUPPORT */ case SQL_C_DOUBLE: dbv = *((SDOUBLE *) buffer); #ifdef WIN32 if (_finite(dbv)) #endif /* WIN32 */ { SPRINTF_FIXED(param_string, "%.*g", PG_DOUBLE_DIGITS, dbv); set_server_decimal_point(param_string, SQL_NTS); } #ifdef WIN32 else if (_isnan(dbv)) STRCPY_FIXED(param_string, NAN_STRING); else if (dbv < .0) STRCPY_FIXED(param_string, MINFINITY_STRING); else STRCPY_FIXED(param_string, INFINITY_STRING); #endif /* WIN32 */ break; case SQL_C_FLOAT: flv = *((SFLOAT *) buffer); #ifdef WIN32 if (_finite(flv)) #endif /* WIN32 */ { SPRINTF_FIXED(param_string, "%.*g", PG_REAL_DIGITS, flv); set_server_decimal_point(param_string, SQL_NTS); } #ifdef WIN32 else if (_isnan(flv)) STRCPY_FIXED(param_string, NAN_STRING); else if (flv < .0) STRCPY_FIXED(param_string, MINFINITY_STRING); else STRCPY_FIXED(param_string, INFINITY_STRING); #endif /* WIN32 */ break; case SQL_C_SLONG: case SQL_C_LONG: SPRINTF_FIXED(param_string, FORMAT_INTEGER, *((SQLINTEGER *) buffer)); break; #ifdef ODBCINT64 case SQL_C_SBIGINT: case SQL_BIGINT: /* Is this needed ? */ SPRINTF_FIXED(param_string, FORMATI64, *((SQLBIGINT *) buffer)); break; case SQL_C_UBIGINT: SPRINTF_FIXED(param_string, FORMATI64U, *((SQLUBIGINT *) buffer)); break; #endif /* ODBCINT64 */ case SQL_C_SSHORT: case SQL_C_SHORT: ITOA_FIXED(param_string, *((SQLSMALLINT *) buffer)); break; case SQL_C_STINYINT: case SQL_C_TINYINT: ITOA_FIXED(param_string, *((SCHAR *) buffer)); break; case SQL_C_ULONG: SPRINTF_FIXED(param_string, FORMAT_UINTEGER, *((SQLUINTEGER *) buffer)); break; case SQL_C_USHORT: SPRINTF_FIXED(param_string, "%u", *((SQLUSMALLINT *) buffer)); break; case SQL_C_UTINYINT: SPRINTF_FIXED(param_string, "%u", *((UCHAR *) buffer)); break; case SQL_C_BIT: { int i = *((UCHAR *) buffer); ITOA_FIXED(param_string, i ? 1 : 0); break; } case SQL_C_DATE: case SQL_C_TYPE_DATE: /* 91 */ { DATE_STRUCT *ds = (DATE_STRUCT *) buffer; st.m = ds->month; st.d = ds->day; st.y = ds->year; break; } case SQL_C_TIME: case SQL_C_TYPE_TIME: /* 92 */ { TIME_STRUCT *ts = (TIME_STRUCT *) buffer; st.hh = ts->hour; st.mm = ts->minute; st.ss = ts->second; /* * Initialize date in case conversion destination * expects date part from this source time data. */ tim = SC_get_localtime(qb->stmt); st.m = tim->tm_mon + 1; st.d = tim->tm_mday; st.y = tim->tm_year + 1900; break; } case SQL_C_TIMESTAMP: case SQL_C_TYPE_TIMESTAMP: /* 93 */ { TIMESTAMP_STRUCT *tss = (TIMESTAMP_STRUCT *) buffer; st.m = tss->month; st.d = tss->day; st.y = tss->year; st.hh = tss->hour; st.mm = tss->minute; st.ss = tss->second; st.fr = tss->fraction; MYLOG(0, "m=%d,d=%d,y=%d,hh=%d,mm=%d,ss=%d\n", st.m, st.d, st.y, st.hh, st.mm, st.ss); break; } case SQL_C_NUMERIC: { ResolveNumericParam((SQL_NUMERIC_STRUCT *) buffer, param_string); break; } case SQL_C_INTERVAL_YEAR: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u years", ivsign, (unsigned int) ivstruct->intval.year_month.year); break; case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_YEAR_TO_MONTH: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u years %s%u mons", ivsign, (unsigned int) ivstruct->intval.year_month.year, ivsign, (unsigned int) ivstruct->intval.year_month.month); break; case SQL_C_INTERVAL_DAY: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u days", ivsign, (unsigned int) ivstruct->intval.day_second.day); break; case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_DAY_TO_HOUR: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u days %s%02u:00:00", ivsign, (unsigned int) ivstruct->intval.day_second.day, ivsign, (unsigned int) ivstruct->intval.day_second.hour); break; case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_DAY_TO_MINUTE: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u days %s%02u:%02u:00", ivsign, (unsigned int) ivstruct->intval.day_second.day, ivsign, (unsigned int) ivstruct->intval.day_second.hour, (unsigned int) ivstruct->intval.day_second.minute); break; case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: ivsign = ivstruct->interval_sign ? "-" : ""; SPRINTF_FIXED(param_string, "%s%u days %s%02u:%02u:%02u", ivsign, (unsigned int) ivstruct->intval.day_second.day, ivsign, (unsigned int) ivstruct->intval.day_second.hour, (unsigned int) ivstruct->intval.day_second.minute, (unsigned int) ivstruct->intval.day_second.second); if (ivstruct->intval.day_second.fraction > 0) { int fraction = ivstruct->intval.day_second.fraction, prec = apara->precision; while (fraction % 10 == 0) { fraction /= 10; prec--; } SPRINTFCAT_FIXED(param_string, ".%0*d", prec, fraction); } break; case SQL_C_GUID: { /* * SQLGUID.Data1 is an "unsigned long" on some platforms, and * "unsigned int" on others. */ SQLGUID *g = (SQLGUID *) buffer; SPRINTF_FIXED (param_string, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", (unsigned int) g->Data1, g->Data2, g->Data3, g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3], g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]); } break; default: /* error */ qb->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters"; qb->errornumber = STMT_NOT_IMPLEMENTED_ERROR; CVT_TERMINATE(qb); /* just in case */ goto cleanup; } /* * Now that the input data is in a neutral format, convert it to * the desired output format (sqltype) */ /* Special handling NULL string For FOXPRO */ MYLOG(0, "cvt_null_date_string=%d pgtype=%d send_buf=%p\n", conn->connInfo.cvt_null_date_string, param_pgtype, send_buf); if (conn->connInfo.cvt_null_date_string > 0 && (PG_TYPE_DATE == param_pgtype || PG_TYPE_DATETIME == param_pgtype || PG_TYPE_TIMESTAMP_NO_TMZONE == param_pgtype) && NULL != send_buf && ( (SQL_C_CHAR == param_ctype && '\0' == send_buf[0]) #ifdef UNICODE_SUPPORT || (SQL_C_WCHAR ==param_ctype && '\0' == send_buf[0] && '\0' == send_buf[1]) #endif /* UNICODE_SUPPORT */ )) { *isnull = TRUE; if (!req_bind) CVT_APPEND_STR(qb, "NULL"); retval = SQL_SUCCESS; goto cleanup; } /* * We now have the value we want to print in one of these three canonical * formats: * * 1. As a string in 'send_buf', with length indicated by 'used' (can be * SQL_NTS). * 2. As a null-terminated string in 'param_string'. * 3. Time-related fields in 'st'. */ /* * For simplicity, fold the param_string representation into 'send_buf'. */ if (!send_buf && param_string[0]) { send_buf = param_string; used = SQL_NTS; } /* * Do some further processing to create the final string we want to output. * This will use the fields in 'st' to create a string if it's a time/date * value, and do some other conversions. */ switch (param_sqltype) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: #ifdef UNICODE_SUPPORT case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: #endif /* UNICODE_SUPPORT */ case SQL_BIT: /* Special handling for some column types */ switch (param_pgtype) { case PG_TYPE_BOOL: /* * consider True is -1 case. * * FIXME: This actually matches anything that begins * with -1, like "-1234" or "-1foobar". Is that * intentional? */ if (NULL != send_buf && '-' == send_buf[0] && '1' == send_buf[1]) { send_buf = "1"; used = 1; } break; case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_NUMERIC: if (NULL != send_buf) set_server_decimal_point((char *) send_buf, used); break; } if (!send_buf) { /* it was date,time,timestamp -- use m,d,y,hh,mm,ss */ SPRINTF_FIXED(tmp, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", st.y, st.m, st.d, st.hh, st.mm, st.ss); send_buf = tmp; used = SQL_NTS; } break; case SQL_DATE: case SQL_TYPE_DATE: /* 91 */ if (send_buf) { /* copy char data to time */ my_strcpy(cbuf, sizeof(cbuf), send_buf, used); parse_datetime(cbuf, &st); } if (st.y < 0) SPRINTF_FIXED(tmp, "%.4d-%.2d-%.2d BC", -st.y, st.m, st.d); else SPRINTF_FIXED(tmp, "%.4d-%.2d-%.2d", st.y, st.m, st.d); lastadd = "::date"; send_buf = tmp; used = SQL_NTS; break; case SQL_TIME: case SQL_TYPE_TIME: /* 92 */ if (send_buf) { /* copy char data to time */ my_strcpy(cbuf, sizeof(cbuf), send_buf, used); parse_datetime(cbuf, &st); } if (st.fr > 0) { int wdt; int fr = effective_fraction(st.fr, &wdt); SPRINTF_FIXED(tmp, "%.2d:%.2d:%.2d.%0*d", st.hh, st.mm, st.ss, wdt, fr); } else SPRINTF_FIXED(tmp, "%.2d:%.2d:%.2d", st.hh, st.mm, st.ss); lastadd = "::time"; send_buf = tmp; used = SQL_NTS; break; case SQL_TIMESTAMP: case SQL_TYPE_TIMESTAMP: /* 93 */ if (send_buf) { my_strcpy(cbuf, sizeof(cbuf), send_buf, used); parse_datetime(cbuf, &st); } /* * SPRINTF_FIXED(tmp, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", st.y, * st.m, st.d, st.hh, st.mm, st.ss); */ /* Time zone stuff is unreliable */ stime2timestamp(&st, tmp, sizeof(tmp), USE_ZONE, 6); lastadd = "::timestamp"; send_buf = tmp; used = SQL_NTS; break; case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: switch (param_ctype) { case SQL_C_BINARY: break; case SQL_C_CHAR: #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: #endif /* UNICODE_SUPPORT */ switch (used) { case SQL_NTS: used = strlen(send_buf); break; } allocbuf = malloc(used / 2 + 1); if (allocbuf) { pg_hex2bin(send_buf, allocbuf, used); send_buf = allocbuf; used /= 2; } break; default: qb->errormsg = "Could not convert the ctype to binary type"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } if (param_pgtype == PG_TYPE_BYTEA) { if (0 != (qb->flags & FLGB_BINARY_AS_POSSIBLE)) { MYLOG(0, "sending binary data leng=" FORMAT_LEN "\n", used); *isbinary = TRUE; } else { /* non-ascii characters should be * converted to octal */ MYLOG(0, "SQL_VARBINARY: about to call convert_to_pgbinary, used = " FORMAT_LEN "\n", used); final_binary_convert = TRUE; } break; } if (PG_TYPE_OID == param_pgtype && conn->lo_is_domain) ; else if (param_pgtype != conn->lobj_type) { qb->errormsg = "Could not convert binary other than LO type"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } if (apara->data_at_exec) lobj_oid = pdata->pdata[param_number].lobj_oid; else { BOOL is_in_trans_at_entry = CC_is_in_trans(conn); int write_result; /* begin transaction if needed */ if (!is_in_trans_at_entry) { if (!CC_begin(conn)) { qb->errormsg = "Could not begin (in-line) a transaction"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } } /* store the oid */ lobj_oid = odbc_lo_creat(conn, INV_READ | INV_WRITE); if (lobj_oid == 0) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "Couldn't create (in-line) large object."; goto cleanup; } /* store the fd */ lobj_fd = odbc_lo_open(conn, lobj_oid, INV_WRITE); if (lobj_fd < 0) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "Couldn't open (in-line) large object for writing."; goto cleanup; } write_result = odbc_lo_write(conn, lobj_fd, buffer, (Int4) used); if (write_result < 0) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "Couldn't write to (in-line) large object."; goto cleanup; } odbc_lo_close(conn, lobj_fd); /* commit transaction if needed */ if (!is_in_trans_at_entry) { if (!CC_commit(conn)) { qb->errormsg = "Could not commit (in-line) a transaction"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } } } /* * the oid of the large object -- just put that in for the * parameter marker -- the data has already been sent to * the large object */ SPRINTF_FIXED(param_string, "%u", lobj_oid); lastadd = "::lo"; send_buf = param_string; used = SQL_NTS; break; /* * because of no conversion operator for bool and int4, * SQL_BIT */ /* must be quoted (0 or 1 is ok to use inside the quotes) */ case SQL_REAL: set_server_decimal_point((char *) send_buf, used); lastadd = "::float4"; break; case SQL_FLOAT: case SQL_DOUBLE: set_server_decimal_point((char *) send_buf, used); lastadd = "::float8"; break; case SQL_NUMERIC: break; /* * If it looks like a valid integer, we can pass it without quotes * and let the server interpret it. Arguably, it would always be * better to explicitly pass it as 'xxx'::integer or 'xxx'::smallint, * but historically we haven't done that, so let's avoid changing the * behaviour. * * If it's a negative number, we have to wrap it in parens. Otherwise * a query like "SELECT 0-?" would turn into "SELECT 0--123". */ case SQL_INTEGER: if (valid_int_literal(send_buf, used, &negative)) { need_quotes = FALSE; add_parens = negative; } else { /* * Doesn't look like a valid integer. The server will most * likely throw an error, unless it's in some format we don't * recognize but the server does. */ lastadd = "::int4"; } break; case SQL_SMALLINT: if (valid_int_literal(send_buf, used, &negative)) { need_quotes = FALSE; add_parens = negative; } else lastadd = "::smallint"; break; default: /* a numeric type or SQL_BIT */ break; } if (!send_buf) { qb->errormsg = "Could not convert parameter ctype to sqltype"; qb->errornumber = STMT_EXEC_ERROR; goto cleanup; } if (used == SQL_NTS) used = strlen(send_buf); /* * Ok, we now have the final string representation in 'send_buf', length 'used'. * We're ready to output the final string, with quotes and other * embellishments if necessary. * * In bind-mode, we don't need to do any quoting. */ if (req_bind) CVT_APPEND_DATA(qb, send_buf, used); else { if (add_parens) CVT_APPEND_CHAR(qb, '('); if (need_quotes) { if ((qb->flags & FLGB_LITERAL_EXTENSION) != 0) CVT_APPEND_CHAR(qb, LITERAL_EXT); CVT_APPEND_CHAR(qb, LITERAL_QUOTE); if (final_binary_convert) CVT_APPEND_BINARY(qb, send_buf, used); else CVT_SPECIAL_CHARS(qb, send_buf, used); CVT_APPEND_CHAR(qb, LITERAL_QUOTE); } else CVT_APPEND_DATA(qb, send_buf, used); if (add_parens) CVT_APPEND_CHAR(qb, ')'); if (lastadd && (FLGB_PARAM_CAST & qb->flags) != 0) CVT_APPEND_STR(qb, lastadd); } retval = SQL_SUCCESS; cleanup: if (allocbuf) free(allocbuf); return retval; } static const char * mapFunction(const char *func, int param_count, const char *keyword) { int i; const char *p1, *p2; for (i = 0; (p1 = mapFuncs[i].odbc_name) != NULL; i++) { if (p1[0] == '%') { if (p1[1] - '0' == param_count && !stricmp(p1 + 2, func)) return mapFuncs[i].pgsql_name; } else if (!stricmp(p1, func)) return mapFuncs[i].pgsql_name; else if (p2 = strchr(p1, (int) '('), NULL != p2) { int len = (int) (p2 - mapFuncs[i].odbc_name); if (strlen(func) == len && !strnicmp(p1, func, len) && !stricmp(p2 + 1, keyword)) return mapFuncs[i].pgsql_name; } } return NULL; } /* * processParameters() * Process function parameters and work with embedded escapes sequences. */ static int processParameters(QueryParse *qp, QueryBuild *qb, size_t *output_count, SQLLEN param_pos[][2]) { int retval, innerParenthesis, param_count; BOOL stop; /* begin with outer '(' */ innerParenthesis = 0; param_count = 0; if (NULL != output_count) *output_count = 0; stop = FALSE; for (; F_OldPos(qp) < qp->stmt_len; F_OldNext(qp)) { retval = inner_process_tokens(qp, qb); if (retval == SQL_ERROR) return retval; if (MBCS_NON_ASCII(qp->encstr)) continue; if (!QP_in_idle_status(qp)) continue; switch (F_OldChar(qp)) { case ',': if (1 == innerParenthesis) { param_pos[param_count][1] = F_NewPos(qb) - 2; param_count++; param_pos[param_count][0] = F_NewPos(qb); param_pos[param_count][1] = -1; } break; case '(': if (0 == innerParenthesis) { param_pos[param_count][0] = F_NewPos(qb); param_pos[param_count][1] = -1; } innerParenthesis++; break; case ')': innerParenthesis--; if (0 == innerParenthesis) { param_pos[param_count][1] = F_NewPos(qb) - 2; param_count++; param_pos[param_count][0] = param_pos[param_count][1] = -1; } if (output_count) *output_count = F_NewPos(qb); break; case ODBC_ESCAPE_END: stop = (0 == innerParenthesis); break; } if (stop) /* returns with the last } position */ break; } if (param_pos[param_count][0] >= 0) { MYLOG(0, "closing ) not found %d\n", innerParenthesis); qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "processParameters closing ) not found"; return SQL_ERROR; } else if (1 == param_count) /* the 1 parameter is really valid ? */ { BOOL param_exist = FALSE; SQLLEN i; for (i = param_pos[0][0]; i <= param_pos[0][1]; i++) { if (IS_NOT_SPACE(qb->query_statement[i])) { param_exist = TRUE; break; } } if (!param_exist) { param_pos[0][0] = param_pos[0][1] = -1; } } return SQL_SUCCESS; } /* * convert_escape() * This function doesn't return a pointer to static memory any longer ! */ static int convert_escape(QueryParse *qp, QueryBuild *qb) { RETCODE retval = SQL_SUCCESS; char buf[1024], buf_small[128], key[65]; UCHAR ucv; UInt4 prtlen; QueryBuild nqb; BOOL nqb_is_valid = FALSE; if (F_OldChar(qp) == ODBC_ESCAPE_START) /* skip the first { */ F_OldNext(qp); /* Separate off the key, skipping leading and trailing whitespace */ while ((ucv = F_OldChar(qp)) != '\0' && isspace(ucv)) F_OldNext(qp); /* * procedure calls */ /* '?=' to accept return values exists ? */ if (F_OldChar(qp) == '?') { qb->param_number++; qb->proc_return = 1; if (qb->stmt) qb->stmt->proc_return = 1; while (isspace((UCHAR) qp->statement[++qp->opos])); if (F_OldChar(qp) != '=') { F_OldPrior(qp); return SQL_SUCCESS; } while (isspace((UCHAR) qp->statement[++qp->opos])); } sscanf(F_OldPtr(qp), "%32s", key); while ((ucv = F_OldChar(qp)) != '\0' && (IS_NOT_SPACE(ucv))) F_OldNext(qp); while ((ucv = F_OldChar(qp)) != '\0' && isspace(ucv)) F_OldNext(qp); /* Avoid the concatenation of the function name with the previous word. Aceto */ if (stricmp(key, "call") == 0) { size_t funclen; const UCHAR *next_token; if (SQL_ERROR == QB_start_brace(qb)) { retval = SQL_ERROR; goto cleanup; } if (qb->num_io_params > 1 || (0 == qb->proc_return)) CVT_APPEND_STR(qb, "SELECT * FROM "); else CVT_APPEND_STR(qb, "SELECT "); funclen = findIdentifier((const UCHAR *) F_OldPtr(qp), qb->ccsc, &next_token); if (next_token && ODBC_ESCAPE_END == *next_token) { CVT_APPEND_DATA(qb, F_OldPtr(qp), funclen); CVT_APPEND_STR(qb, "()"); if (SQL_ERROR == QB_end_brace(qb)) { retval = SQL_ERROR; goto cleanup; } /* positioned at } */ qp->opos += ((const char *) next_token - F_OldPtr(qp)); } else { /* Continue at inner_process_tokens loop */ F_OldPrior(qp); return SQL_SUCCESS; } } else if (stricmp(key, "d") == 0) { /* Literal; return the escape part adding type cast */ F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small)); prtlen = SPRINTF_FIXED(buf, "%s::date", buf_small); CVT_APPEND_DATA(qb, buf, prtlen); retval = QB_append_space_to_separate_identifiers(qb, qp); } else if (stricmp(key, "t") == 0) { /* Literal; return the escape part adding type cast */ F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small)); prtlen = SPRINTF_FIXED(buf, "%s::time", buf_small); CVT_APPEND_DATA(qb, buf, prtlen); retval = QB_append_space_to_separate_identifiers(qb, qp); } else if (stricmp(key, "ts") == 0) { /* Literal; return the escape part adding type cast */ F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small)); prtlen = SPRINTF_FIXED(buf, "%s::timestamp", buf_small); CVT_APPEND_DATA(qb, buf, prtlen); retval = QB_append_space_to_separate_identifiers(qb, qp); } else if (stricmp(key, "oj") == 0) /* {oj syntax support for 7.1 * servers */ { if (qb->stmt) SC_set_outer_join(qb->stmt); retval = QB_start_brace(qb); /* Continue at inner_process_tokens loop */ F_OldPrior(qp); goto cleanup; } else if (stricmp(key, "escape") == 0) /* like escape syntax support for 7.1+ servers */ { /* Literal; return the escape part adding type cast */ F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small)); prtlen = SPRINTF_FIXED(buf, "%s %s", key, buf_small); CVT_APPEND_DATA(qb, buf, prtlen); retval = QB_append_space_to_separate_identifiers(qb, qp); } else if (stricmp(key, "fn") == 0) { const char *mapExpr; int i, param_count; SQLLEN from, to; size_t param_consumed; SQLLEN param_pos[16][2]; BOOL cvt_func = FALSE; /* Separate off the func name, skipping leading and trailing whitespace */ i = 0; while ((ucv = F_OldChar(qp)) != '\0' && ucv != '(' && (IS_NOT_SPACE(ucv))) { if (i < sizeof(key) - 1) key[i++] = ucv; F_OldNext(qp); } key[i] = '\0'; while ((ucv = F_OldChar(qp)) != '\0' && isspace(ucv)) F_OldNext(qp); /* * We expect left parenthesis here, else return fn body as-is * since it is one of those "function constants". */ if (F_OldChar(qp) != '(') { CVT_APPEND_STR(qb, key); goto cleanup; } /* * Process parameter list and inner escape * sequences * Aceto 2002-01-29 */ QB_initialize_copy(&nqb, qb, 1024); nqb_is_valid = TRUE; if (retval = processParameters(qp, &nqb, ¶m_consumed, param_pos), retval == SQL_ERROR) { qb->errornumber = nqb.errornumber; qb->errormsg = nqb.errormsg; goto cleanup; } for (param_count = 0;; param_count++) { if (param_pos[param_count][0] < 0) break; } if (param_count == 1 && param_pos[0][1] < param_pos[0][0]) param_count = 0; mapExpr = NULL; if (stricmp(key, "convert") == 0) cvt_func = TRUE; else { char keyword[64] = ""; if (param_count > 0) { int i, from, to; const char * p; for (i = param_pos[0][0], p = nqb.query_statement + i; i <= param_pos[0][1] && isspace(*p); i++, p++) ; from = i; for (; i <= param_pos[0][1] && IS_NOT_SPACE(*p); i++, p++) ; to = i - 1; if (to >= from) { int len = to - from + 1; if (len < sizeof(keyword)) { memcpy(keyword, nqb.query_statement + from, len); keyword[len] = '\0'; } } } mapExpr = mapFunction(key, param_count, keyword); } if (cvt_func) { if (2 == param_count) { BOOL add_cast = FALSE, add_quote = FALSE; const char *pptr; from = param_pos[0][0]; to = param_pos[0][1]; for (pptr = nqb.query_statement + from; *pptr && isspace((unsigned char) *pptr); pptr++) ; if (LITERAL_QUOTE == *pptr) ; else if ('-' == *pptr) add_quote = TRUE; else if (isdigit((unsigned char) *pptr)) add_quote = TRUE; else add_cast = TRUE; if (add_quote) CVT_APPEND_CHAR(qb, LITERAL_QUOTE); else if (add_cast) CVT_APPEND_CHAR(qb, '('); CVT_APPEND_DATA(qb, nqb.query_statement + from, to - from + 1); if (add_quote) CVT_APPEND_CHAR(qb, LITERAL_QUOTE); else if (add_cast) { const char *cast_form = NULL; char sqltype[32]; int typel; CVT_APPEND_CHAR(qb, ')'); from = param_pos[1][0]; to = param_pos[1][1]; typel = to - from + 1; if (typel < sizeof(sqltype)) { const char *type; memcpy(sqltype, nqb.query_statement + from, typel); sqltype[typel] = '\0'; MYLOG(0, FORMAT_LEN "-" FORMAT_LEN " SQLtype=%s SQL_BIT=%d\n", to, from, sqltype, SQL_BIT); for (type = sqltype; *type && isspace(*type); type++) ; if (strncmp(type, "SQL_", 4) == 0) { type += 4; if (strcmp(type, "INTEGER") == 0) cast_form = "int4"; else if (strcmp(type, "CHAR") == 0) cast_form = "varchar"; else if (strcmp(type, "VARCHAR") == 0) cast_form = "varchar"; else if (strcmp(type, "LONGVARCHAR") == 0) cast_form = "text"; else if (strcmp(type, "WCHAR") == 0) cast_form = "varchar"; else if (strcmp(type, "WVARCHAR") == 0) cast_form = "varchar"; else if (strcmp(type, "WLONGVARCHAR") == 0) cast_form = "text"; else if (strcmp(type, "NUMERIC") == 0) cast_form = "numeric"; else if (strcmp(type, "DOUBLE") == 0) cast_form = "float8"; else if (strcmp(type, "FLOAT") == 0) cast_form = "float8"; else if (strcmp(type, "REAL") == 0) cast_form = "float4"; else if (strcmp(type, "BIGINT") == 0) cast_form = "int8"; else if (strcmp(type, "DECIMAL") == 0) cast_form = "numeric"; else if (strcmp(type, "SMALLINT") == 0) cast_form = "int2"; else if (strcmp(type, "TYPE_DATE") == 0) cast_form = "date"; else if (strcmp(type, "TYPE_TIME") == 0) cast_form = "time"; else if (strcmp(type, "TYPE_TIMESTAMP") == 0) cast_form = "timestamp"; else if (strcmp(type, "BIT") == 0) cast_form = "bit"; } } if (NULL != cast_form) { CVT_APPEND_STR(qb, "::"); CVT_APPEND_STR(qb, cast_form); } } } else { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "convert param count must be 2"; retval = SQL_ERROR; } } else if (mapExpr == NULL) { CVT_APPEND_STR(qb, key); CVT_APPEND_DATA(qb, nqb.query_statement, nqb.npos); } else { const char *mapptr; SQLLEN paramlen; int pidx; for (mapptr = mapExpr; *mapptr; mapptr++) { if (*mapptr != '$') { CVT_APPEND_CHAR(qb, *mapptr); continue; } mapptr++; if (*mapptr == '*') { from = 1; to = param_consumed - 2; } else if (isdigit((unsigned char) *mapptr)) { pidx = *mapptr - '0' - 1; if (pidx < 0 || param_pos[pidx][0] < 0) { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "param not found"; MYLOG(0, "%dth param not found for the expression %s\n", pidx + 1, mapExpr); retval = SQL_ERROR; break; } from = param_pos[pidx][0]; to = param_pos[pidx][1]; } else { qb->errornumber = STMT_EXEC_ERROR; qb->errormsg = "internal expression error"; MYLOG(0, "internal expression error %s\n", mapExpr); retval = SQL_ERROR; break; } paramlen = to - from + 1; if (paramlen > 0) CVT_APPEND_DATA(qb, nqb.query_statement + from, paramlen); } } if (0 == qb->errornumber) { qb->errornumber = nqb.errornumber; qb->errormsg = nqb.errormsg; } if (SQL_ERROR != retval) { qb->param_number = nqb.param_number; qb->dollar_number = nqb.dollar_number; qb->flags = nqb.flags; } } else { /* Bogus key, leave untranslated */ retval = SQL_ERROR; } cleanup: if (nqb_is_valid) QB_Destructor(&nqb); return retval; } static BOOL convert_money(const char *s, char *sout, size_t soutmax) { char in, decp = 0; size_t i = 0, out = 0; int num_in = -1, period_in = -1, comma_in = -1; for (i = 0; s[i]; i++) { switch (in = s[i]) { case '.': if (period_in < 0) period_in = i; break; case ',': if (comma_in < 0) comma_in = i; break; default: if ('0' <= in && '9' >= in) num_in = i; break; } } if (period_in > comma_in) { if ( period_in >= num_in - 2) decp = '.'; } else if (comma_in >= 0 && comma_in >= num_in - 2) decp = ','; for (i = 0; s[i] && out + 1 < soutmax; i++) { switch (in = s[i]) { case '(': case '-': sout[out++] = '-'; break; default: if (in >= '0' && in <= '9') sout[out++] = in; else if (in == decp) sout[out++] = '.'; } } sout[out] = '\0'; return TRUE; } /* * This function parses a character string for date/time info and fills in SIMPLE_TIME * It does not zero out SIMPLE_TIME in case it is desired to initialize it with a value */ static char parse_datetime(const char *buf, SIMPLE_TIME *st) { int y, m, d, hh, mm, ss; int nf; BOOL bZone; int zone; y = m = d = hh = mm = ss = 0; st->fr = 0; st->infinity = 0; /* * Handle ODBC time/date/timestamp literals, e.g. * { d '2011-04-22' } * { t '12:34:56' } * { ts '2011-04-22 12:34:56' } */ if (buf[0] == ODBC_ESCAPE_START) { while (*(++buf) && *buf != LITERAL_QUOTE); if (!(*buf)) return FALSE; buf++; } bZone = FALSE; if (timestamp2stime(buf, st, &bZone, &zone)) return TRUE; if (buf[4] == '-') /* year first */ nf = sscanf(buf, "%4d-%2d-%2d %2d:%2d:%2d", &y, &m, &d, &hh, &mm, &ss); else nf = sscanf(buf, "%2d-%2d-%4d %2d:%2d:%2d", &m, &d, &y, &hh, &mm, &ss); if (nf == 5 || nf == 6) { st->y = y; st->m = m; st->d = d; st->hh = hh; st->mm = mm; st->ss = ss; return TRUE; } if (buf[4] == '-') /* year first */ nf = sscanf(buf, "%4d-%2d-%2d", &y, &m, &d); else nf = sscanf(buf, "%2d-%2d-%4d", &m, &d, &y); if (nf == 3) { st->y = y; st->m = m; st->d = d; return TRUE; } nf = sscanf(buf, "%2d:%2d:%2d", &hh, &mm, &ss); if (nf == 2 || nf == 3) { st->hh = hh; st->mm = mm; st->ss = ss; return TRUE; } return FALSE; } /* Change linefeed to carriage-return/linefeed */ size_t convert_linefeeds(const char *si, char *dst, size_t max, BOOL convlf, BOOL *changed) { size_t i = 0, out = 0; if (max == 0) max = 0xffffffff; *changed = FALSE; for (i = 0; si[i] && out < max - 1; i++) { if (convlf && si[i] == '\n') { /* Only add the carriage-return if needed */ if (i > 0 && PG_CARRIAGE_RETURN == si[i - 1]) { if (dst) dst[out++] = si[i]; else out++; continue; } *changed = TRUE; if (dst) { dst[out++] = PG_CARRIAGE_RETURN; dst[out++] = '\n'; } else out += 2; } else { if (dst) dst[out++] = si[i]; else out++; } } if (dst) dst[out] = '\0'; return out; } /* * Change carriage-return/linefeed to just linefeed * Plus, escape any special characters. */ static BOOL convert_special_chars(QueryBuild *qb, const char *si, size_t used) { size_t i = 0, max; char tchar; encoded_str encstr; BOOL convlf = (0 != (qb->flags & FLGB_CONVERT_LF)); BOOL double_special = (qb->param_mode != RPM_BUILDING_BIND_REQUEST); int ccsc = qb->ccsc; char escape_in_literal = CC_get_escape(qb->conn); if (used == SQL_NTS) max = strlen(si); else max = used; /* * Make sure there's room for the null-terminator, if the input is an * empty string. XXX: I don't think the null-termination is actually * even required, but better safe than sorry. */ if (!enlarge_query_statement(qb, qb->npos + 1)) return FALSE; encoded_str_constr(&encstr, ccsc, si); for (i = 0; i < max && si[i]; i++) { tchar = encoded_nextchar(&encstr); /* * Make sure there is room for three more bytes in the buffer. We * expand quotes to two bytes, plus null-terminate the end. */ if (qb->npos + 3 >= qb->str_alsize) { if (!enlarge_query_statement(qb, qb->npos + 3)) return FALSE; } if (MBCS_NON_ASCII(encstr)) { qb->query_statement[qb->npos++] = tchar; continue; } if (convlf && /* CR/LF -> LF */ PG_CARRIAGE_RETURN == tchar && PG_LINEFEED == si[i + 1]) continue; else if (double_special && /* double special chars ? */ (tchar == LITERAL_QUOTE || tchar == escape_in_literal)) { qb->query_statement[qb->npos++] = tchar; } qb->query_statement[qb->npos++] = tchar; } qb->query_statement[qb->npos] = '\0'; return TRUE; } static int conv_from_octal(const char *s) { ssize_t i; int y = 0; for (i = 1; i <= 3; i++) y += (s[i] - '0') << (3 * (3 - i)); return y; } /* convert octal escapes to bytes */ static size_t convert_from_pgbinary(const char *value, char *rgbValue, SQLLEN cbValueMax) { size_t i, ilen = strlen(value); size_t o = 0; for (i = 0; i < ilen;) { if (value[i] == BYTEA_ESCAPE_CHAR) { if (value[i + 1] == BYTEA_ESCAPE_CHAR) { if (rgbValue) rgbValue[o] = value[i]; o++; i += 2; } else if (value[i + 1] == 'x') { i += 2; if (i < ilen) { ilen -= i; if (rgbValue) pg_hex2bin(value + i, rgbValue + o, ilen); o += ilen / 2; } break; } else { if (rgbValue) rgbValue[o] = conv_from_octal(&value[i]); o++; i += 4; } } else { if (rgbValue) rgbValue[o] = value[i]; o++; i++; } /** if (rgbValue) MYLOG(0, "i=%d, rgbValue[%d] = %d, %c\n", i, o, rgbValue[o], rgbValue[o]); ***/ } if (rgbValue) rgbValue[o] = '\0'; /* extra protection */ MYLOG(0, "in=" FORMAT_SIZE_T ", out = " FORMAT_SIZE_T "\n", ilen, o); return o; } static UInt2 conv_to_octal(UCHAR val, char *octal, char escape_ch) { int i, pos = 0, len; if (escape_ch) octal[pos++] = escape_ch; octal[pos] = BYTEA_ESCAPE_CHAR; len = 4 + pos; octal[len] = '\0'; for (i = len - 1; i > pos; i--) { octal[i] = (val & 7) + '0'; val >>= 3; } return (UInt2) len; } static char * conv_to_octal2(UCHAR val, char *octal) { int i; octal[0] = BYTEA_ESCAPE_CHAR; octal[4] = '\0'; for (i = 3; i > 0; i--) { octal[i] = (val & 7) + '0'; val >>= 3; } return octal; } /* convert non-ascii bytes to octal escape sequences */ static size_t convert_to_pgbinary(const char *in, char *out, size_t len, QueryBuild *qb) { UCHAR inc; size_t i, o = 0; char escape_in_literal = CC_get_escape(qb->conn); BOOL esc_double = (qb->param_mode != RPM_BUILDING_BIND_REQUEST && 0 != escape_in_literal); /* use hex format for 9.0 or later servers */ if (0 != (qb->flags & FLGB_HEX_BIN_FORMAT)) { if (esc_double) out[o++] = escape_in_literal; out[o++] = '\\'; out[o++] = 'x'; o += pg_bin2hex(in, out + o, len); return o; } for (i = 0; i < len; i++) { inc = in[i]; MYLOG(DETAIL_LOG_LEVEL, "in[" FORMAT_SIZE_T "] = %d, %c\n", i, inc, inc); if (inc < 128 && (isalnum(inc) || inc == ' ')) out[o++] = inc; else { if (esc_double) { o += conv_to_octal(inc, &out[o], escape_in_literal); } else { conv_to_octal2(inc, &out[o]); o += 4; } } } MYLOG(0, "leaving " FORMAT_SIZE_T ", out='%.*s'\n", o, (int) o, out); return o; } static const char *hextbl = "0123456789ABCDEF"; #define def_bin2hex(type) \ (const char *src, type *dst, SQLLEN length) \ { \ const char *src_wk; \ UCHAR chr; \ type *dst_wk; \ BOOL backwards; \ int i; \ \ backwards = FALSE; \ if ((char *) dst < src) \ { \ if ((char *) (dst + 2 * (length - 1)) > src + length - 1) \ return -1; \ } \ else if ((char *) dst < src + length) \ backwards = TRUE; \ if (backwards) \ { \ for (i = 0, src_wk = src + length - 1, dst_wk = dst + 2 * length - 1; i < length; i++, src_wk--) \ { \ chr = *src_wk; \ *dst_wk-- = hextbl[chr % 16]; \ *dst_wk-- = hextbl[chr >> 4]; \ } \ } \ else \ { \ for (i = 0, src_wk = src, dst_wk = dst; i < length; i++, src_wk++) \ { \ chr = *src_wk; \ *dst_wk++ = hextbl[chr >> 4]; \ *dst_wk++ = hextbl[chr % 16]; \ } \ } \ dst[2 * length] = '\0'; \ return 2 * length * sizeof(type); \ } #ifdef UNICODE_SUPPORT static SQLLEN pg_bin2whex def_bin2hex(SQLWCHAR) #endif /* UNICODE_SUPPORT */ static SQLLEN pg_bin2hex def_bin2hex(char) SQLLEN pg_hex2bin(const char *src, char *dst, SQLLEN length) { UCHAR chr; const char *src_wk; char *dst_wk; SQLLEN i; int val; BOOL HByte = TRUE; for (i = 0, src_wk = src, dst_wk = dst; i < length; i++, src_wk++) { chr = *src_wk; if (!chr) break; if (chr >= 'a' && chr <= 'f') val = chr - 'a' + 10; else if (chr >= 'A' && chr <= 'F') val = chr - 'A' + 10; else val = chr - '0'; if (HByte) *dst_wk = (val << 4); else { *dst_wk += val; dst_wk++; } HByte = !HByte; } *dst_wk = '\0'; return length; } /*------- * 1. get oid (from 'value') * 2. open the large object * 3. read from the large object (handle multiple GetData) * 4. close when read less than requested? -OR- * lseek/read each time * handle case where application receives truncated and * decides not to continue reading. * * CURRENTLY, ONLY LONGVARBINARY is handled, since that is the only * data type currently mapped to a PG_TYPE_LO. But, if any other types * are desired to map to a large object (PG_TYPE_LO), then that would * need to be handled here. For example, LONGVARCHAR could possibly be * mapped to PG_TYPE_LO someday, instead of PG_TYPE_TEXT as it is now. *------- */ static int convert_lo(StatementClass *stmt, const void *value, SQLSMALLINT fCType, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue) { CSTR func = "convert_lo"; OID oid; int result; Int8 retval; Int8 left64 = -1; struct GetBlobDataClass *gdata_blob = NULL; ConnectionClass *conn = SC_get_conn(stmt); ConnInfo *ci = &(conn->connInfo); GetDataInfo *gdata_info = SC_get_GDTI(stmt); int factor; oid = ATOI32U(value); if (0 == oid) { if (pcbValue) *pcbValue = SQL_NULL_DATA; return COPY_OK; } switch (fCType) { case SQL_C_CHAR: factor = 2; break; case SQL_C_BINARY: factor = 1; break; default: SC_set_error(stmt, STMT_EXEC_ERROR, "Could not convert lo to the c-type", func); return COPY_GENERAL_ERROR; } /* If using SQLGetData, then current_col will be set */ if (stmt->current_col >= 0) { gdata_blob = &(gdata_info->gdata[stmt->current_col].blob); left64 = gdata_blob->data_left64; } /* * if this is the first call for this column, open the large object * for reading */ if (!gdata_blob || gdata_blob->data_left64 == -1) { /* begin transaction if needed */ if (!CC_is_in_trans(conn)) { if (!CC_begin(conn)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Could not begin (in-line) a transaction", func); return COPY_GENERAL_ERROR; } } stmt->lobj_fd = odbc_lo_open(conn, oid, INV_READ); if (stmt->lobj_fd < 0) { SC_set_error(stmt, STMT_EXEC_ERROR, "Couldnt open large object for reading.", func); return COPY_GENERAL_ERROR; } /* Get the size */ retval = odbc_lo_lseek64(conn, stmt->lobj_fd, 0L, SEEK_END); if (retval >= 0) { left64 = odbc_lo_tell64(conn, stmt->lobj_fd); if (gdata_blob) gdata_blob->data_left64 = left64; /* return to beginning */ odbc_lo_lseek64(conn, stmt->lobj_fd, 0L, SEEK_SET); } } else if (left64 == 0) return COPY_NO_DATA_FOUND; MYLOG(0, "lo data left = " FORMATI64 "\n", left64); if (stmt->lobj_fd < 0) { SC_set_error(stmt, STMT_EXEC_ERROR, "Large object FD undefined for multiple read.", func); return COPY_GENERAL_ERROR; } if (0 >= cbValueMax) retval = 0; else retval = (Int8) odbc_lo_read(conn, stmt->lobj_fd, (char *) rgbValue, (Int4) (factor > 1 ? (cbValueMax - 1) / factor : cbValueMax)); if (retval < 0) { odbc_lo_close(conn, stmt->lobj_fd); /* commit transaction if needed */ if (!ci->drivers.use_declarefetch && CC_does_autocommit(conn)) { if (!CC_commit(conn)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Could not commit (in-line) a transaction", func); return COPY_GENERAL_ERROR; } } stmt->lobj_fd = -1; SC_set_error(stmt, STMT_EXEC_ERROR, "Error reading from large object.", func); return COPY_GENERAL_ERROR; } if (factor > 1) pg_bin2hex((char *) rgbValue, (char *) rgbValue, retval); if (retval < left64) result = COPY_RESULT_TRUNCATED; else result = COPY_OK; if (pcbValue) { Int8 leftbytes = left64 * factor; *pcbValue = left64 < 0 ? SQL_NO_TOTAL : (leftbytes == (SQLLEN) leftbytes ? leftbytes : /* exceeds SQLLEN limit */ SQL_NO_TOTAL); } if (gdata_blob && gdata_blob->data_left64 > 0) gdata_blob->data_left64 -= retval; if (!gdata_blob || gdata_blob->data_left64 == 0) { odbc_lo_close(conn, stmt->lobj_fd); /* commit transaction if needed */ if (!ci->drivers.use_declarefetch && CC_does_autocommit(conn)) { if (!CC_commit(conn)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Could not commit (in-line) a transaction", func); return COPY_GENERAL_ERROR; } } stmt->lobj_fd = -1; /* prevent further reading */ } return result; } psqlodbc-REL-16_00_0005/convert.h000066400000000000000000000023411462406103600163270ustar00rootroot00000000000000/* File: convert.h * * Description: See "convert.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __CONVERT_H__ #define __CONVERT_H__ #include "psqlodbc.h" #ifdef __cplusplus extern "C" { #endif /* copy_and_convert results */ #define COPY_OK 0 #define COPY_UNSUPPORTED_TYPE 1 #define COPY_UNSUPPORTED_CONVERSION 2 #define COPY_RESULT_TRUNCATED 3 #define COPY_GENERAL_ERROR 4 #define COPY_NO_DATA_FOUND 5 #define COPY_INVALID_STRING_CONVERSION 6 int copy_and_convert_field_bindinfo(StatementClass *stmt, OID field_type, int atttypmod, void *value, int col); int copy_and_convert_field(StatementClass *stmt, OID field_type, int atttypmod, void *value, SQLSMALLINT fCType, int precision, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue, SQLLEN *pIndicator); int copy_statement_with_parameters(StatementClass *stmt, BOOL); SQLLEN pg_hex2bin(const char *in, char *out, SQLLEN len); size_t findTag(const char *str, int ccsc); BOOL build_libpq_bind_params(StatementClass *stmt, int *nParams, OID **paramTypes, char ***paramValues, int **paramLengths, int **paramFormats, int *resultFormat); #ifdef __cplusplus } #endif #endif psqlodbc-REL-16_00_0005/descriptor.c000066400000000000000000000457261462406103600170360ustar00rootroot00000000000000/*------- * Module: descriptor.c * * Description: This module contains functions related to creating * and manipulating a statement. * * Classes: DescriptorClass (Functions prefix: "DC_") * * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "environ.h" #include "connection.h" #include "descriptor.h" #include "statement.h" #include "qresult.h" #include "misc.h" #include #include #include #include "pgapifunc.h" void TI_Constructor(TABLE_INFO *self, const ConnectionClass *conn) { memset(self, 0, sizeof(TABLE_INFO)); TI_set_updatable(self); } void TI_Destructor(TABLE_INFO **ti, int count) { int i; MYLOG(DETAIL_LOG_LEVEL, "entering count=%d\n", count); if (ti) { for (i = 0; i < count; i++) { if (ti[i]) { TI_ClearObject(ti[i]); free(ti[i]); ti[i] = NULL; } } } } void TI_ClearObject(TABLE_INFO *ti) { if (ti) { COL_INFO *coli = ti->col_info; if (coli) { MYLOG(0, "!!!refcnt %p:%d -> %d\n", coli, coli->refcnt, coli->refcnt - 1); coli->refcnt--; if (coli->refcnt <= 1 && 0 == coli->acc_time) /* acc_time == 0 means the table is dropped */ free_col_info_contents(coli); /* Now coli object is unused, and may be reused later. */ if (coli->refcnt <= 0) { /* Last reference to coli object disappeared. Now destroying it. */ free(coli); ti->col_info = NULL; } } NULL_THE_NAME(ti->schema_name); NULL_THE_NAME(ti->table_name); NULL_THE_NAME(ti->table_alias); NULL_THE_NAME(ti->bestitem); NULL_THE_NAME(ti->bestqual); TI_Destroy_IH(ti); } } void FI_Constructor(FIELD_INFO *self, BOOL reuse) { MYLOG(DETAIL_LOG_LEVEL, "entering reuse=%d\n", reuse); if (reuse) FI_Destructor(&self, 1, FALSE); memset(self, 0, sizeof(FIELD_INFO)); self->nullable = TRUE; self->columnkey = -1; self->typmod = -1; } void FI_Destructor(FIELD_INFO **fi, int count, BOOL freeFI) { int i; MYLOG(DETAIL_LOG_LEVEL, "entering count=%d\n", count); if (fi) { for (i = 0; i < count; i++) { if (fi[i]) { NULL_THE_NAME(fi[i]->column_name); NULL_THE_NAME(fi[i]->column_alias); NULL_THE_NAME(fi[i]->schema_name); NULL_THE_NAME(fi[i]->before_dot); if (freeFI) { free(fi[i]); fi[i] = NULL; } } } if (freeFI) free(fi); } } static const pgNAME invNAME = {NULL}; #define INIT_IH 32 void TI_Create_IH(TABLE_INFO *ti) { int alloc = INIT_IH; InheritanceClass *ih; ih = (InheritanceClass *) malloc(sizeof(InheritanceClass) + (alloc - 1) * sizeof(ih->inf[0])); memset(ih, 0, sizeof(InheritanceClass)); ih->allocated = alloc; ti->ih = ih; } void TI_Destroy_IH(TABLE_INFO *ti) { InheritanceClass *ih; int i; if (NULL == (ih = ti->ih)) return; for (i = 0; i < ih->count; i++) { NULL_THE_NAME(ih->inf[i].fullTable); } free(ih); ti->ih = NULL; } const pgNAME TI_From_IH(TABLE_INFO *ti, OID tableoid) { InheritanceClass *ih; int i; if (NULL == (ih = ti->ih)) return invNAME; if (tableoid == ih->cur_tableoid) return ih->cur_fullTable; for (i = 0; i < ih->count; i++) { if (ih->inf[i].tableoid == tableoid) { ih->cur_tableoid = tableoid; ih->cur_fullTable = ih->inf[i].fullTable; return ih->cur_fullTable; } } return invNAME; } const pgNAME TI_Ins_IH(TABLE_INFO *ti, OID tableoid, const char *fullName) { InheritanceClass *ih; int count; if (NULL == (ih = ti->ih)) { TI_Create_IH(ti); if (ih = ti->ih, NULL == ih) return invNAME; } if ((count = ih->count) >= ih->allocated) { int alloc = ih->allocated * 2; InheritanceClass *nih; if (nih = (InheritanceClass *) realloc(ih, sizeof(InheritanceClass) + (alloc - 1) * sizeof(ih->inf[0])), NULL == nih) { TI_Destroy_IH(ti); return invNAME; } ti->ih = ih = nih; ih->allocated = alloc; } ih->inf[count].tableoid = tableoid; INIT_NAME(ih->inf[count].fullTable); STR_TO_NAME(ih->inf[count].fullTable, fullName); ih->cur_tableoid = tableoid; ih->cur_fullTable = ih->inf[count].fullTable; ih->count++; return ih->inf[count].fullTable; } void DC_Constructor(DescriptorClass *self, BOOL embedded, StatementClass *stmt) { memset(self, 0, sizeof(DescriptorClass)); self->deschd.embedded = embedded; } static void ARDFields_free(ARDFields * self) { MYLOG(DETAIL_LOG_LEVEL, "entering %p bookmark=%p\n", self, self->bookmark); if (self->bookmark) { free(self->bookmark); self->bookmark = NULL; } /* * the memory pointed to by the bindings is not deallocated by the * driver but by the application that uses that driver, so we don't * have to care */ ARD_unbind_cols(self, TRUE); } static void APDFields_free(APDFields * self) { if (self->bookmark) { free(self->bookmark); self->bookmark = NULL; } /* param bindings */ APD_free_params(self, STMT_FREE_PARAMS_ALL); } static void IRDFields_free(IRDFields * self) { /* Free the parsed field information */ if (self->fi) { FI_Destructor(self->fi, self->allocated, TRUE); self->fi = NULL; } self->allocated = 0; self->nfields = 0; } static void IPDFields_free(IPDFields * self) { /* param bindings */ IPD_free_params(self, STMT_FREE_PARAMS_ALL); } void DC_Destructor(DescriptorClass *self) { DescriptorHeader *deschd = &(self->deschd); if (deschd->__error_message) { free(deschd->__error_message); deschd->__error_message = NULL; } if (deschd->pgerror) { ER_Destructor(deschd->pgerror); deschd->pgerror = NULL; } if (deschd->type_defined) { switch (deschd->desc_type) { case SQL_ATTR_APP_ROW_DESC: ARDFields_free(&(self->ardf)); break; case SQL_ATTR_APP_PARAM_DESC: APDFields_free(&(self->apdf)); break; case SQL_ATTR_IMP_ROW_DESC: IRDFields_free(&(self->irdf)); break; case SQL_ATTR_IMP_PARAM_DESC: IPDFields_free(&(self->ipdf)); break; } } } void InitializeEmbeddedDescriptor(DescriptorClass *self, StatementClass *stmt, UInt4 desc_type) { DescriptorHeader *deschd = &(self->deschd); DC_Constructor(self, TRUE, stmt); DC_get_conn(self) = SC_get_conn(stmt); deschd->type_defined = TRUE; deschd->desc_type = desc_type; switch (desc_type) { case SQL_ATTR_APP_ROW_DESC: memset(&(self->ardf), 0, sizeof(ARDFields)); InitializeARDFields(&(self->ardf)); stmt->ard = self; break; case SQL_ATTR_APP_PARAM_DESC: memset(&(self->apdf), 0, sizeof(APDFields)); InitializeAPDFields(&(self->apdf)); stmt->apd = self; break; case SQL_ATTR_IMP_ROW_DESC: memset(&(self->irdf), 0, sizeof(IRDFields)); stmt->ird = self; stmt->ird->irdf.stmt = stmt; break; case SQL_ATTR_IMP_PARAM_DESC: memset(&(self->ipdf), 0, sizeof(IPDFields)); stmt->ipd = self; break; } } /* * ARDFields initialize */ void InitializeARDFields(ARDFields *opt) { memset(opt, 0, sizeof(ARDFields)); opt->size_of_rowset = 1; opt->bind_size = 0; /* default is to bind by column */ opt->size_of_rowset_odbc2 = 1; } /* * APDFields initialize */ void InitializeAPDFields(APDFields *opt) { memset(opt, 0, sizeof(APDFields)); opt->paramset_size = 1; opt->param_bind_type = 0; /* default is to bind by column */ opt->paramset_size_dummy = 1; /* dummy setting */ } BindInfoClass *ARD_AllocBookmark(ARDFields *ardopts) { if (!ardopts->bookmark) { ardopts->bookmark = (BindInfoClass *) malloc(sizeof(BindInfoClass)); memset(ardopts->bookmark, 0, sizeof(BindInfoClass)); } return ardopts->bookmark; } #define DESC_INCREMENT 10 char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc) { int i; int new_num_descs; DescriptorClass **descs; MYLOG(0, "entering self=%p, desc=%p\n", self, desc); for (i = 0; i < self->num_descs; i++) { if (!self->descs[i]) { DC_get_conn(desc) = self; self->descs[i] = desc; return TRUE; } } /* no more room -- allocate more memory */ new_num_descs = DESC_INCREMENT + self->num_descs; descs = (DescriptorClass **) realloc(self->descs, sizeof(DescriptorClass *) * new_num_descs); if (!descs) return FALSE; self->descs = descs; memset(&self->descs[self->num_descs], 0, sizeof(DescriptorClass *) * DESC_INCREMENT); DC_get_conn(desc) = self; self->descs[self->num_descs] = desc; self->num_descs = new_num_descs; return TRUE; } /* * This API allocates a Application descriptor. */ RETCODE SQL_API PGAPI_AllocDesc(HDBC ConnectionHandle, SQLHDESC *DescriptorHandle) { CSTR func = "PGAPI_AllocDesc"; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret = SQL_SUCCESS; DescriptorClass *desc; MYLOG(0, "entering...\n"); desc = (DescriptorClass *) malloc(sizeof(DescriptorClass)); if (desc) { memset(desc, 0, sizeof(DescriptorClass)); DC_get_conn(desc) = conn; if (CC_add_descriptor(conn, desc)) *DescriptorHandle = desc; else { free(desc); CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "Maximum number of descriptors exceeded", func); ret = SQL_ERROR; } } else { CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "No more memory ti allocate a further descriptor", func); ret = SQL_ERROR; } return ret; } RETCODE SQL_API PGAPI_FreeDesc(SQLHDESC DescriptorHandle) { DescriptorClass *desc = (DescriptorClass *) DescriptorHandle; RETCODE ret = SQL_SUCCESS; MYLOG(0, "entering...\n"); DC_Destructor(desc); if (!desc->deschd.embedded) { int i; ConnectionClass *conn = DC_get_conn(desc); for (i = 0; i < conn->num_descs; i++) { if (conn->descs[i] == desc) { conn->descs[i] = NULL; break; } } free(desc); } return ret; } static void BindInfoClass_copy(const BindInfoClass *src, BindInfoClass *target) { memcpy(target, src, sizeof(BindInfoClass)); } static void ARDFields_copy(const ARDFields *src, ARDFields *target) { memcpy(target, src, sizeof(ARDFields)); target->bookmark = NULL; if (src->bookmark) { BindInfoClass *bookmark = ARD_AllocBookmark(target); if (bookmark) BindInfoClass_copy(src->bookmark, bookmark); } if (src->allocated <= 0) { target->allocated = 0; target->bindings = NULL; } else { int i; target->bindings = malloc(target->allocated * sizeof(BindInfoClass)); if (!target->bindings) target->allocated = 0; for (i = 0; i < target->allocated; i++) BindInfoClass_copy(&src->bindings[i], &target->bindings[i]); } } static void ParameterInfoClass_copy(const ParameterInfoClass *src, ParameterInfoClass *target) { memcpy(target, src, sizeof(ParameterInfoClass)); } static void APDFields_copy(const APDFields *src, APDFields *target) { memcpy(target, src, sizeof(APDFields)); if (src->bookmark) { target->bookmark = malloc(sizeof(ParameterInfoClass)); if (target->bookmark) ParameterInfoClass_copy(src->bookmark, target->bookmark); } if (src->allocated <= 0) { target->allocated = 0; target->parameters = NULL; } else { int i; target->parameters = malloc(target->allocated * sizeof(ParameterInfoClass)); if (!target->parameters) target->allocated = 0; for (i = 0; i < target->allocated; i++) ParameterInfoClass_copy(&src->parameters[i], &target->parameters[i]); } } static void ParameterImplClass_copy(const ParameterImplClass *src, ParameterImplClass *target) { memcpy(target, src, sizeof(ParameterImplClass)); } static void IPDFields_copy(const IPDFields *src, IPDFields *target) { memcpy(target, src, sizeof(IPDFields)); if (src->allocated <= 0) { target->allocated = 0; target->parameters = NULL; } else { int i; target->parameters = (ParameterImplClass *) malloc(target->allocated * sizeof(ParameterImplClass)); if (!target->parameters) target->allocated = 0; for (i = 0; i < target->allocated; i++) ParameterImplClass_copy(&src->parameters[i], &target->parameters[i]); } } RETCODE SQL_API PGAPI_CopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle) { RETCODE ret = SQL_ERROR; DescriptorClass *src, *target; DescriptorHeader *srchd, *targethd; ARDFields *ard_src, *ard_tgt; APDFields *apd_src, *apd_tgt; IPDFields *ipd_src, *ipd_tgt; MYLOG(0, "entering...\n"); src = (DescriptorClass *) SourceDescHandle; target = (DescriptorClass *) TargetDescHandle; srchd = &(src->deschd); targethd = &(target->deschd); if (!srchd->type_defined) { MYLOG(0, "source type undefined\n"); DC_set_error(target, DESC_EXEC_ERROR, "source handle type undefined"); return ret; } if (targethd->type_defined) { MYLOG(DETAIL_LOG_LEVEL, "source type=%d -> target type=%d\n", srchd->desc_type, targethd->desc_type); if (SQL_ATTR_IMP_ROW_DESC == targethd->desc_type) { MYLOG(0, "can't modify IRD\n"); DC_set_error(target, DESC_EXEC_ERROR, "can't copy to IRD"); return ret; } else if (targethd->desc_type != srchd->desc_type) { if (targethd->embedded) { MYLOG(0, "src type != target type\n"); DC_set_error(target, DESC_EXEC_ERROR, "copying different type descriptor to embedded one"); return ret; } } DC_Destructor(target); } ret = SQL_SUCCESS; switch (srchd->desc_type) { case SQL_ATTR_APP_ROW_DESC: MYLOG(DETAIL_LOG_LEVEL, "src=%p target=%p type=%d", src, target, srchd->desc_type); if (!targethd->type_defined) { targethd->desc_type = srchd->desc_type; } ard_src = &(src->ardf); MYPRINTF(DETAIL_LOG_LEVEL, " rowset_size=" FORMAT_LEN " bind_size=" FORMAT_UINTEGER " ope_ptr=%p off_ptr=%p\n", ard_src->size_of_rowset, ard_src->bind_size, ard_src->row_operation_ptr, ard_src->row_offset_ptr); ard_tgt = &(target->ardf); MYPRINTF(DETAIL_LOG_LEVEL, " target=%p", ard_tgt); ARDFields_copy(ard_src, ard_tgt); MYPRINTF(DETAIL_LOG_LEVEL, " offset_ptr=%p\n", ard_tgt->row_offset_ptr); break; case SQL_ATTR_APP_PARAM_DESC: if (!targethd->type_defined) { targethd->desc_type = srchd->desc_type; } apd_src = &(src->apdf); apd_tgt = &(target->apdf); APDFields_copy(apd_src, apd_tgt); break; case SQL_ATTR_IMP_PARAM_DESC: if (!targethd->type_defined) { targethd->desc_type = srchd->desc_type; } ipd_src = &(src->ipdf); ipd_tgt = &(target->ipdf); IPDFields_copy(ipd_src, ipd_tgt); break; default: MYLOG(0, "invalid descriptor handle type=%d\n", srchd->desc_type); DC_set_error(target, DESC_EXEC_ERROR, "invalid descriptor type"); ret = SQL_ERROR; } if (SQL_SUCCESS == ret) targethd->type_defined = TRUE; return ret; } void DC_clear_error(DescriptorClass *self) { DescriptorHeader *deschd = &(self->deschd); if (deschd->__error_message) { free(deschd->__error_message); deschd->__error_message = NULL; } if (deschd->pgerror) { ER_Destructor(deschd->pgerror); deschd->pgerror = NULL; } deschd->__error_number = 0; deschd->error_row = 0; deschd->error_index = 0; } void DC_set_error(DescriptorClass *self, int errornumber, const char *errormsg) { DescriptorHeader *deschd = &(self->deschd); if (deschd->__error_message) free(deschd->__error_message); deschd->__error_number = errornumber; deschd->__error_message = errormsg ? strdup(errormsg) : NULL; } void DC_set_errormsg(DescriptorClass *self, const char *errormsg) { DescriptorHeader *deschd = &(self->deschd); if (deschd->__error_message) free(deschd->__error_message); deschd->__error_message = errormsg ? strdup(errormsg) : NULL; } const char *DC_get_errormsg(const DescriptorClass *desc) { return desc->deschd.__error_message; } int DC_get_errornumber(const DescriptorClass *desc) { return desc->deschd.__error_number; } /* Map sql commands to statement types */ static const struct { int number; const char ver3str[6]; const char ver2str[6]; } Descriptor_sqlstate[] = { { DESC_ERROR_IN_ROW, "01S01", "01S01" }, { DESC_OPTION_VALUE_CHANGED, "01S02", "01S02" }, { DESC_OK, "00000", "00000" }, /* OK */ { DESC_EXEC_ERROR, "HY000", "S1000" }, /* also a general error */ { DESC_STATUS_ERROR, "HY010", "S1010" }, { DESC_SEQUENCE_ERROR, "HY010", "S1010" }, /* Function sequence error */ { DESC_NO_MEMORY_ERROR, "HY001", "S1001" }, /* memory allocation failure */ { DESC_COLNUM_ERROR, "07009", "S1002" }, /* invalid column number */ { DESC_NO_STMTSTRING, "HY001", "S1001" }, /* having no stmtstring is also a malloc problem */ { DESC_ERROR_TAKEN_FROM_BACKEND, "HY000", "S1000" }, /* general error */ { DESC_INTERNAL_ERROR, "HY000", "S1000" }, /* general error */ { DESC_STILL_EXECUTING, "HY010", "S1010" }, { DESC_NOT_IMPLEMENTED_ERROR, "HYC00", "S1C00" }, /* == 'driver not * capable' */ { DESC_BAD_PARAMETER_NUMBER_ERROR, "07009", "S1093" }, { DESC_OPTION_OUT_OF_RANGE_ERROR, "HY092", "S1092" }, { DESC_INVALID_COLUMN_NUMBER_ERROR, "07009", "S1002" }, { DESC_RESTRICTED_DATA_TYPE_ERROR, "07006", "07006" }, { DESC_INVALID_CURSOR_STATE_ERROR, "07005", "24000" }, { DESC_CREATE_TABLE_ERROR, "42S01", "S0001" }, /* table already exists */ { DESC_NO_CURSOR_NAME, "S1015", "S1015" }, { DESC_INVALID_CURSOR_NAME, "34000", "34000" }, { DESC_INVALID_ARGUMENT_NO, "HY024", "S1009" }, /* invalid argument value */ { DESC_ROW_OUT_OF_RANGE, "HY107", "S1107" }, { DESC_OPERATION_CANCELLED, "HY008", "S1008" }, { DESC_INVALID_CURSOR_POSITION, "HY109", "S1109" }, { DESC_VALUE_OUT_OF_RANGE, "HY019", "22003" }, { DESC_OPERATION_INVALID, "HY011", "S1011" }, { DESC_PROGRAM_TYPE_OUT_OF_RANGE, "?????", "?????" }, { DESC_BAD_ERROR, "08S01", "08S01" }, /* communication link failure */ { DESC_INVALID_OPTION_IDENTIFIER, "HY092", "HY092" }, { DESC_RETURN_NULL_WITHOUT_INDICATOR, "22002", "22002" }, { DESC_INVALID_DESCRIPTOR_IDENTIFIER, "HY091", "HY091" }, { DESC_OPTION_NOT_FOR_THE_DRIVER, "HYC00", "HYC00" }, { DESC_FETCH_OUT_OF_RANGE, "HY106", "S1106" }, { DESC_COUNT_FIELD_INCORRECT, "07002", "07002" }, }; static PG_ErrorInfo *DC_create_errorinfo(const DescriptorClass *self) { const DescriptorHeader *deschd = &(self->deschd); PG_ErrorInfo *error; ConnectionClass *conn; EnvironmentClass *env; Int4 errornum; BOOL env_is_odbc3 = TRUE; if (deschd->pgerror) return deschd->pgerror; errornum = deschd->__error_number; error = ER_Constructor(errornum, deschd->__error_message); if (!error) return error; conn = DC_get_conn(self); if (conn && (env = (EnvironmentClass *) conn->henv)) env_is_odbc3 = EN_is_odbc3(env); errornum -= LOWEST_DESC_ERROR; if (errornum < 0 || errornum >= sizeof(Descriptor_sqlstate) / sizeof(Descriptor_sqlstate[0])) errornum = 1 - LOWEST_DESC_ERROR; STRCPY_FIXED(error->sqlstate, env_is_odbc3 ? Descriptor_sqlstate[errornum].ver3str : Descriptor_sqlstate[errornum].ver2str); return error; } void DC_log_error(const char *func, const char *desc, const DescriptorClass *self) { #define nullcheck(a) (a ? a : "(NULL)") if (self) { MYLOG(0, "DESCRIPTOR ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->deschd.__error_number, nullcheck(self->deschd.__error_message)); } } /* Returns the next SQL error information. */ RETCODE SQL_API PGAPI_DescError(SQLHDESC hdesc, SQLSMALLINT RecNumber, SQLCHAR * szSqlState, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT * pcbErrorMsg, UWORD flag) { /* CC: return an error of a hdesc */ DescriptorClass *desc = (DescriptorClass *) hdesc; DescriptorHeader *deschd = &(desc->deschd); MYLOG(0, "entering RecN=%hd\n", RecNumber); deschd->pgerror = DC_create_errorinfo(desc); return ER_ReturnError(deschd->pgerror, RecNumber, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg, flag); } psqlodbc-REL-16_00_0005/descriptor.h000066400000000000000000000162721462406103600170350ustar00rootroot00000000000000/* File: descriptor.h * * Description: This file contains defines and declarations that are related to * the entire driver. * * Comments: See "readme.txt" for copyright and license information. */ #ifndef __DESCRIPTOR_H__ #define __DESCRIPTOR_H__ #include "psqlodbc.h" typedef struct InheritanceClass { UInt4 allocated; UInt4 count; OID cur_tableoid; pgNAME cur_fullTable; struct { OID tableoid; pgNAME fullTable; } inf[1]; } InheritanceClass; enum { TI_UPDATABLE = 1L ,TI_HASOIDS_CHECKED = (1L << 1) ,TI_HASOIDS = (1L << 2) ,TI_COLATTRIBUTE = (1L << 3) ,TI_HASSUBCLASS = (1L << 4) }; typedef struct { OID table_oid; COL_INFO *col_info; /* cached SQLColumns info for this table */ pgNAME schema_name; pgNAME table_name; pgNAME table_alias; pgNAME bestitem; pgNAME bestqual; UInt4 flags; InheritanceClass *ih; } TABLE_INFO; #define TI_set_updatable(ti) (ti->flags |= TI_UPDATABLE) #define TI_is_updatable(ti) (0 != (ti->flags & TI_UPDATABLE)) #define TI_no_updatable(ti) (ti->flags &= (~TI_UPDATABLE)) #define TI_set_hasoids_checked(ti) (ti->flags |= TI_HASOIDS_CHECKED) #define TI_checked_hasoids(ti) (0 != (ti->flags & TI_HASOIDS)) #define TI_set_hasoids(ti) (ti->flags |= TI_HASOIDS) #define TI_has_oids(ti) (0 != (ti->flags & TI_HASOIDS)) #define TI_set_has_no_oids(ti) (ti->flags &= (~TI_HASOIDS)) #define TI_set_hassubclass(ti) (ti->flags |= TI_HASSUBCLASS) #define TI_has_subclass(ti) (0 != (ti->flags & TI_HASSUBCLASS)) #define TI_set_has_no_subclass(ti) (ti->flags &= (~TI_HASSUBCLASS)) void TI_Constructor(TABLE_INFO *, const ConnectionClass *); void TI_Destructor(TABLE_INFO **, int); void TI_ClearObject(TABLE_INFO *ti); void TI_Create_IH(TABLE_INFO *ti); void TI_Destroy_IH(TABLE_INFO *ti); const pgNAME TI_From_IH(TABLE_INFO *ti, OID tableoid); const pgNAME TI_Ins_IH(TABLE_INFO *ti, OID tableoid, const char *fullName); enum { FIELD_INITIALIZED = 0 ,FIELD_PARSING = 1L ,FIELD_TEMP_SET = (1L << 1) ,FIELD_COL_ATTRIBUTE = (1L << 2) ,FIELD_PARSED_OK = (1L << 3) ,FIELD_PARSED_INCOMPLETE = (1L << 4) }; typedef struct { char flag; char updatable; Int2 attnum; pgNAME schema_name; TABLE_INFO *ti; /* to resolve explicit table names */ pgNAME column_name; pgNAME column_alias; char nullable; char auto_increment; char func; char columnkey; int column_size; /* precision in 2.x */ int decimal_digits; /* scale in 2.x */ int display_size; SQLLEN length; OID columntype; OID basetype; /* may be the basetype when the column type is a domain */ int typmod; char expr; char quote; char dquote; char numeric; pgNAME before_dot; } FIELD_INFO; Int4 FI_precision(const FIELD_INFO *); Int4 FI_scale(const FIELD_INFO *); void FI_Constructor(FIELD_INFO *, BOOL reuse); void FI_Destructor(FIELD_INFO **, int, BOOL freeFI); #define FI_is_applicable(fi) (NULL != fi && (fi->flag & (FIELD_PARSED_OK | FIELD_COL_ATTRIBUTE)) != 0) #define FI_type(fi) (0 == (fi)->basetype ? (fi)->columntype : (fi)->basetype) typedef struct DescriptorHeader_ { ConnectionClass *conn_conn; char embedded; char type_defined; UInt4 desc_type; UInt4 error_row; /* 1-based row */ UInt4 error_index; /* 1-based index */ Int4 __error_number; char *__error_message; PG_ErrorInfo *pgerror; } DescriptorHeader; /* * ARD and APD are(must be) of the same format */ struct ARDFields_ { SQLLEN size_of_rowset; /* for ODBC3 fetch operation */ SQLUINTEGER bind_size; /* size of each structure if using * Row-wise Binding */ SQLUSMALLINT *row_operation_ptr; SQLULEN *row_offset_ptr; BindInfoClass *bookmark; BindInfoClass *bindings; SQLSMALLINT allocated; SQLLEN size_of_rowset_odbc2; /* for SQLExtendedFetch */ }; /* * APD must be of the same format as ARD */ struct APDFields_ { SQLLEN paramset_size; /* really an SQLINTEGER type */ SQLUINTEGER param_bind_type; /* size of each structure if using * Row-wise Parameter Binding */ SQLUSMALLINT *param_operation_ptr; SQLULEN *param_offset_ptr; ParameterInfoClass *bookmark; /* dummy item to fit APD to ARD */ ParameterInfoClass *parameters; SQLSMALLINT allocated; SQLLEN paramset_size_dummy; /* dummy item to fit APD to ARD */ }; struct IRDFields_ { StatementClass *stmt; SQLULEN *rowsFetched; SQLUSMALLINT *rowStatusArray; UInt4 nfields; SQLSMALLINT allocated; FIELD_INFO **fi; }; struct IPDFields_ { SQLULEN *param_processed_ptr; SQLUSMALLINT *param_status_ptr; SQLSMALLINT allocated; ParameterImplClass *parameters; }; /*** typedef struct { DescriptorHeader deschd; ARDFields ardopts; } ARDClass; typedef struct { DescriptorHeader deschd; APDFields apdopts; } APDClass; typedef struct { DescriptorHeader deschd; IRDFields irdopts; } IRDClass; typedef struct { DescriptorHeader deschd; IPDFields ipdopts; } IPDClass; ***/ typedef struct { DescriptorHeader deschd; union { ARDFields ardf; APDFields apdf; IRDFields irdf; IPDFields ipdf; }; } DescriptorClass; #define DC_get_conn(a) ((a)->deschd.conn_conn) #define DC_get_desc_type(a) ((a)->deschd.desc_type) #define DC_get_embedded(a) ((a)->deschd.embedded) void InitializeEmbeddedDescriptor(DescriptorClass *, StatementClass *stmt, UInt4 desc_type); void DC_Destructor(DescriptorClass *desc); void InitializeARDFields(ARDFields *self); void InitializeAPDFields(APDFields *self); /* void InitializeIRDFields(IRDFields *self); void InitializeIPDFiedls(IPDFields *self); */ BindInfoClass *ARD_AllocBookmark(ARDFields *self); void ARD_unbind_cols(ARDFields *self, BOOL freeall); void APD_free_params(APDFields *self, char option); void IPD_free_params(IPDFields *self, char option); BOOL getCOLIfromTI(const char *, ConnectionClass *, StatementClass *, const OID, TABLE_INFO **); RETCODE DC_set_stmt(DescriptorClass *desc, StatementClass *stmt); void DC_clear_error(DescriptorClass *desc); void DC_set_error(DescriptorClass *desc, int errornumber, const char * errormsg); void DC_set_errormsg(DescriptorClass *desc, const char * errormsg); PG_ErrorInfo *DC_get_error(DescriptorClass *self); int DC_get_errornumber(const DescriptorClass *self); const char *DC_get_errormsg(const DescriptorClass *self); void DC_log_error(const char *func, const char *desc, const DescriptorClass *self); /* Error numbers about descriptor handle */ enum { LOWEST_DESC_ERROR = -2 /* minus means warning/notice message */ ,DESC_ERROR_IN_ROW = -2 ,DESC_OPTION_VALUE_CHANGED = -1 ,DESC_OK = 0 ,DESC_EXEC_ERROR ,DESC_STATUS_ERROR ,DESC_SEQUENCE_ERROR ,DESC_NO_MEMORY_ERROR ,DESC_COLNUM_ERROR ,DESC_NO_STMTSTRING ,DESC_ERROR_TAKEN_FROM_BACKEND ,DESC_INTERNAL_ERROR ,DESC_STILL_EXECUTING ,DESC_NOT_IMPLEMENTED_ERROR ,DESC_BAD_PARAMETER_NUMBER_ERROR ,DESC_OPTION_OUT_OF_RANGE_ERROR ,DESC_INVALID_COLUMN_NUMBER_ERROR ,DESC_RESTRICTED_DATA_TYPE_ERROR ,DESC_INVALID_CURSOR_STATE_ERROR ,DESC_CREATE_TABLE_ERROR ,DESC_NO_CURSOR_NAME ,DESC_INVALID_CURSOR_NAME ,DESC_INVALID_ARGUMENT_NO ,DESC_ROW_OUT_OF_RANGE ,DESC_OPERATION_CANCELLED ,DESC_INVALID_CURSOR_POSITION ,DESC_VALUE_OUT_OF_RANGE ,DESC_OPERATION_INVALID ,DESC_PROGRAM_TYPE_OUT_OF_RANGE ,DESC_BAD_ERROR ,DESC_INVALID_OPTION_IDENTIFIER ,DESC_RETURN_NULL_WITHOUT_INDICATOR ,DESC_INVALID_DESCRIPTOR_IDENTIFIER ,DESC_OPTION_NOT_FOR_THE_DRIVER ,DESC_FETCH_OUT_OF_RANGE ,DESC_COUNT_FIELD_INCORRECT }; #endif /* __DESCRIPTOR_H__ */ psqlodbc-REL-16_00_0005/dlg_specific.c000066400000000000000000001571071462406103600172700ustar00rootroot00000000000000/*------- * Module: dlg_specific.c * * Description: This module contains any specific code for handling * dialog boxes such as driver/datasource options. Both the * ConfigDSN() and the SQLDriverConnect() functions use * functions in this module. If you were to add a new option * to any dialog box, you would most likely only have to change * things in here rather than in 2 separate places as before. * * Classes: none * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ /* Multibyte support Eiji Tokuya 2001-03-15 */ #include #include "dlg_specific.h" #include "misc.h" #include "pgapifunc.h" #define NULL_IF_NULL(a) ((a) ? ((const char *)(a)) : "(null)") CSTR ENTRY_TEST = " @@@ "; static void encode(const pgNAME, char *out, int outlen); static pgNAME decode(const char *in); static pgNAME decode_or_remove_braces(const char *in); #define OVR_EXTRA_BITS (BIT_FORCEABBREVCONNSTR | BIT_FAKE_MSS | BIT_BDE_ENVIRONMENT | BIT_CVT_NULL_DATE | BIT_ACCESSIBLE_ONLY | BIT_IGNORE_ROUND_TRIP_TIME | BIT_DISABLE_KEEPALIVE | BIT_DISABLE_CONVERT_FUNC) UInt4 getExtraOptions(const ConnInfo *ci) { UInt4 flag = ci->extra_opts & (~OVR_EXTRA_BITS); if (ci->force_abbrev_connstr > 0) flag |= BIT_FORCEABBREVCONNSTR; else if (ci->force_abbrev_connstr == 0) flag &= (~BIT_FORCEABBREVCONNSTR); if (ci->fake_mss > 0) flag |= BIT_FAKE_MSS; else if (ci->fake_mss == 0) flag &= (~BIT_FAKE_MSS); if (ci->bde_environment > 0) flag |= BIT_BDE_ENVIRONMENT; else if (ci->bde_environment == 0) flag &= (~BIT_BDE_ENVIRONMENT); if (ci->cvt_null_date_string > 0) flag |= BIT_CVT_NULL_DATE; else if (ci->cvt_null_date_string == 0) flag &= (~BIT_CVT_NULL_DATE); if (ci->accessible_only > 0) flag |= BIT_ACCESSIBLE_ONLY; else if (ci->accessible_only == 0) flag &= (~BIT_ACCESSIBLE_ONLY); if (ci->ignore_round_trip_time > 0) flag |= BIT_IGNORE_ROUND_TRIP_TIME; else if (ci->ignore_round_trip_time == 0) flag &= (~BIT_IGNORE_ROUND_TRIP_TIME); if (ci->disable_keepalive > 0) flag |= BIT_DISABLE_KEEPALIVE; else if (ci->disable_keepalive == 0) flag &= (~BIT_DISABLE_KEEPALIVE); if (ci->disable_convert_func > 0) flag |= BIT_DISABLE_CONVERT_FUNC; else if (ci->disable_convert_func == 0) flag &= (~BIT_DISABLE_CONVERT_FUNC); return flag; } CSTR hex_format = "%x%1s"; CSTR dec_format = "%u%1s"; CSTR octal_format = "%o%1s"; static UInt4 replaceExtraOptions(ConnInfo *ci, UInt4 flag, BOOL overwrite) { if (overwrite) ci->extra_opts = flag; else ci->extra_opts |= (flag & ~(OVR_EXTRA_BITS)); if (overwrite || ci->force_abbrev_connstr < 0) ci->force_abbrev_connstr = (0 != (flag & BIT_FORCEABBREVCONNSTR)); if (overwrite || ci->fake_mss < 0) ci->fake_mss = (0 != (flag & BIT_FAKE_MSS)); if (overwrite || ci->bde_environment < 0) ci->bde_environment = (0 != (flag & BIT_BDE_ENVIRONMENT)); if (overwrite || ci->cvt_null_date_string < 0) ci->cvt_null_date_string = (0 != (flag & BIT_CVT_NULL_DATE)); if (overwrite || ci->accessible_only < 0) ci->accessible_only = (0 != (flag & BIT_ACCESSIBLE_ONLY)); if (overwrite || ci->ignore_round_trip_time < 0) ci->ignore_round_trip_time = (0 != (flag & BIT_IGNORE_ROUND_TRIP_TIME)); if (overwrite || ci->disable_keepalive < 0) ci->disable_keepalive = (0 != (flag & BIT_DISABLE_KEEPALIVE)); if (overwrite || ci->disable_convert_func < 0) ci->disable_convert_func = (0 != (flag & BIT_DISABLE_CONVERT_FUNC)); return (ci->extra_opts = getExtraOptions(ci)); } BOOL setExtraOptions(ConnInfo *ci, const char *optstr, const char *format) { UInt4 flag = 0, cnt; char dummy[2]; if (!format) { if ('0' == *optstr) { switch (optstr[1]) { case '\0': format = dec_format; break; case 'x': case 'X': optstr += 2; format = hex_format; break; default: format = octal_format; break; } } else format = dec_format; } if (cnt = sscanf(optstr, format, &flag, dummy), cnt < 1) // format error return FALSE; else if (cnt > 1) // format error return FALSE; replaceExtraOptions(ci, flag, TRUE); return TRUE; } UInt4 add_removeExtraOptions(ConnInfo *ci, UInt4 aflag, UInt4 dflag) { ci->extra_opts |= aflag; ci->extra_opts &= (~dflag); if (0 != (aflag & BIT_FORCEABBREVCONNSTR)) ci->force_abbrev_connstr = TRUE; if (0 != (aflag & BIT_FAKE_MSS)) ci->fake_mss = TRUE; if (0 != (aflag & BIT_BDE_ENVIRONMENT)) ci->bde_environment = TRUE; if (0 != (aflag & BIT_CVT_NULL_DATE)) ci->cvt_null_date_string = TRUE; if (0 != (aflag & BIT_ACCESSIBLE_ONLY)) ci->accessible_only = TRUE; if (0 != (aflag & BIT_IGNORE_ROUND_TRIP_TIME)) ci->ignore_round_trip_time = TRUE; if (0 != (aflag & BIT_DISABLE_KEEPALIVE)) ci->disable_keepalive = TRUE; if (0 != (aflag & BIT_DISABLE_CONVERT_FUNC)) ci->disable_convert_func = TRUE; if (0 != (dflag & BIT_FORCEABBREVCONNSTR)) ci->force_abbrev_connstr = FALSE; if (0 != (dflag & BIT_FAKE_MSS)) ci->fake_mss =FALSE; if (0 != (dflag & BIT_CVT_NULL_DATE)) ci->cvt_null_date_string = FALSE; if (0 != (dflag & BIT_ACCESSIBLE_ONLY)) ci->accessible_only = FALSE; if (0 != (dflag & BIT_IGNORE_ROUND_TRIP_TIME)) ci->ignore_round_trip_time = FALSE; if (0 != (dflag & BIT_DISABLE_KEEPALIVE)) ci->disable_keepalive = FALSE; if (0 != (dflag & BIT_DISABLE_CONVERT_FUNC)) ci->disable_convert_func = FALSE; return (ci->extra_opts = getExtraOptions(ci)); } static const char * abbrev_sslmode(const char *sslmode, char *abbrevmode, size_t abbrevsize) { switch (sslmode[0]) { case SSLLBYTE_DISABLE: case SSLLBYTE_ALLOW: case SSLLBYTE_PREFER: case SSLLBYTE_REQUIRE: abbrevmode[0] = sslmode[0]; abbrevmode[1] = '\0'; break; case SSLLBYTE_VERIFY: abbrevmode[0] = sslmode[0]; abbrevmode[2] = '\0'; switch (sslmode[1]) { case 'f': case 'c': abbrevmode[1] = sslmode[1]; break; default: if (strnicmp(sslmode, "verify_", 7) == 0) abbrevmode[1] = sslmode[7]; else strncpy_null(abbrevmode, sslmode, abbrevsize); } break; } return abbrevmode; } static char * makeKeepaliveConnectString(char *target, int buflen, const ConnInfo *ci, BOOL abbrev) { char *buf = target; *buf = '\0'; if (ci->disable_keepalive) return target; if (ci->keepalive_idle >= 0) { if (abbrev) snprintf(buf, buflen, ABBR_KEEPALIVETIME "=%u;", ci->keepalive_idle); else snprintf(buf, buflen, INI_KEEPALIVETIME "=%u;", ci->keepalive_idle); } if (ci->keepalive_interval >= 0) { if (abbrev) snprintfcat(buf, buflen, ABBR_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval); else snprintfcat(buf, buflen, INI_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval); } return target; } #define OPENING_BRACKET '{' #define CLOSING_BRACKET '}' static const char * makeBracketConnectString(BOOL in_str, char **target, pgNAME item, const char *optname) { const char *istr, *iptr; char *buf, *optr; int len; if (!in_str) return NULL_STRING; istr = SAFE_NAME(item); for (iptr = istr, len = 0; *iptr; iptr++) { if (CLOSING_BRACKET == *iptr) len++; len++; } len += 30; if (buf = (char *) malloc(len), buf == NULL) return NULL_STRING; snprintf(buf, len, "%s=%c", optname, OPENING_BRACKET); optr = strchr(buf, '\0'); for (iptr = istr; *iptr; iptr++) { if (CLOSING_BRACKET == *iptr) *(optr++) = *iptr; *(optr++) = *iptr; } *(optr++) = CLOSING_BRACKET; *(optr++) = ';'; *optr = '\0'; *target = buf; return buf; } #ifdef _HANDLE_ENLIST_IN_DTC_ char * makeXaOptConnectString(char *target, int buflen, const ConnInfo *ci, BOOL abbrev) { char *buf = target; *buf = '\0'; if (ci->xa_opt < 0) return target; if (abbrev) { if (DEFAULT_XAOPT != ci->xa_opt) snprintf(buf, buflen, ABBR_XAOPT "=%u;", ci->xa_opt); } else snprintf(buf, buflen, INI_XAOPT "=%u;", ci->xa_opt); return target; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) { char got_dsn = (ci->dsn[0] != '\0'); char encoded_item[LARGE_REGISTRY_LEN]; char *connsetStr = NULL; char *pqoptStr = NULL; char keepaliveStr[64]; #ifdef _HANDLE_ENLIST_IN_DTC_ char xaOptStr[16]; #endif ssize_t hlen, nlen, olen; /*BOOL abbrev = (len <= 400);*/ BOOL abbrev = (len < 1024) || 0 < ci->force_abbrev_connstr; UInt4 flag; MYLOG(0, "%s row_versioning=%s\n", __FUNCTION__, ci->row_versioning); MYLOG(DETAIL_LOG_LEVEL, "force_abbrev=%d abbrev=%d\n", ci->force_abbrev_connstr, abbrev); encode(ci->password, encoded_item, sizeof(encoded_item)); /* fundamental info */ nlen = MAX_CONNECT_STRING; olen = snprintf(connect_string, nlen, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s", got_dsn ? "DSN" : "DRIVER", got_dsn ? ci->dsn : ci->drivername, ci->database, ci->server, ci->port, ci->username, encoded_item); if (olen < 0 || olen >= nlen) { connect_string[0] = '\0'; return; } /* extra info */ hlen = strlen(connect_string); nlen = MAX_CONNECT_STRING - hlen; MYLOG(DETAIL_LOG_LEVEL, "hlen=" FORMAT_SSIZE_T "\n", hlen); if (!abbrev) { char protocol_and[16]; if (ci->rollback_on_error >= 0) SPRINTF_FIXED(protocol_and, "7.4-%d", ci->rollback_on_error); else STRCPY_FIXED(protocol_and, "7.4"); olen = snprintf(&connect_string[hlen], nlen, ";" INI_SSLMODE "=%s;" INI_READONLY "=%s;" INI_PROTOCOL "=%s;" INI_FAKEOIDINDEX "=%s;" INI_SHOWOIDCOLUMN "=%s;" INI_ROWVERSIONING "=%s;" INI_SHOWSYSTEMTABLES "=%s;" "%s" /* INI_CONNSETTINGS */ INI_FETCH "=%d;" INI_UNKNOWNSIZES "=%d;" INI_MAXVARCHARSIZE "=%d;" INI_MAXLONGVARCHARSIZE "=%d;" INI_DEBUG "=%d;" INI_COMMLOG "=%d;" INI_USEDECLAREFETCH "=%d;" INI_TEXTASLONGVARCHAR "=%d;" INI_UNKNOWNSASLONGVARCHAR "=%d;" INI_BOOLSASCHAR "=%d;" INI_PARSE "=%d;" INI_EXTRASYSTABLEPREFIXES "=%s;" INI_LFCONVERSION "=%d;" INI_UPDATABLECURSORS "=%d;" INI_TRUEISMINUS1 "=%d;" INI_INT8AS "=%d;" INI_BYTEAASLONGVARBINARY "=%d;" INI_USESERVERSIDEPREPARE "=%d;" INI_LOWERCASEIDENTIFIER "=%d;" "%s" /* INI_PQOPT */ "%s" /* INIKEEPALIVE TIME/INTERVAL */ ABBR_NUMERIC_AS "=%d;" INI_OPTIONAL_ERRORS "=%d;" INI_FETCHREFCURSORS "=%d;" #ifdef _HANDLE_ENLIST_IN_DTC_ INI_XAOPT "=%d" /* XAOPT */ #endif /* _HANDLE_ENLIST_IN_DTC_ */ ,ci->sslmode ,ci->onlyread ,protocol_and ,ci->fake_oid_index ,ci->show_oid_column ,ci->row_versioning ,ci->show_system_tables ,makeBracketConnectString(ci->conn_settings_in_str, &connsetStr, ci->conn_settings, INI_CONNSETTINGS) ,ci->drivers.fetch_max ,ci->drivers.unknown_sizes ,ci->drivers.max_varchar_size ,ci->drivers.max_longvarchar_size ,ci->drivers.debug ,ci->drivers.commlog ,ci->drivers.use_declarefetch ,ci->drivers.text_as_longvarchar ,ci->drivers.unknowns_as_longvarchar ,ci->drivers.bools_as_char ,ci->drivers.parse ,ci->drivers.extra_systable_prefixes ,ci->lf_conversion ,ci->allow_keyset ,ci->true_is_minus1 ,ci->int8_as ,ci->bytea_as_longvarbinary ,ci->use_server_side_prepare ,ci->lower_case_identifier ,makeBracketConnectString(ci->pqopt_in_str, &pqoptStr, ci->pqopt, INI_PQOPT) ,makeKeepaliveConnectString(keepaliveStr, sizeof(keepaliveStr), ci, FALSE) ,ci->numeric_as ,ci->optional_errors ,ci->fetch_refcursors #ifdef _HANDLE_ENLIST_IN_DTC_ ,ci->xa_opt #endif /* _HANDLE_ENLIST_IN_DTC_ */ ); } /* Abbreviation is needed ? */ if (abbrev || olen >= nlen || olen < 0) { flag = 0; if (ci->allow_keyset) flag |= BIT_UPDATABLECURSORS; if (ci->lf_conversion) flag |= BIT_LFCONVERSION; if (ci->drivers.unique_index) flag |= BIT_UNIQUEINDEX; switch (ci->drivers.unknown_sizes) { case UNKNOWNS_AS_DONTKNOW: flag |= BIT_UNKNOWN_DONTKNOW; break; case UNKNOWNS_AS_MAX: flag |= BIT_UNKNOWN_ASMAX; break; } if (ci->drivers.commlog) flag |= BIT_COMMLOG; if (ci->drivers.debug) flag |= BIT_DEBUG; if (ci->drivers.parse) flag |= BIT_PARSE; if (ci->drivers.use_declarefetch) flag |= BIT_USEDECLAREFETCH; if (ci->onlyread[0] == '1') flag |= BIT_READONLY; if (ci->drivers.text_as_longvarchar) flag |= BIT_TEXTASLONGVARCHAR; if (ci->drivers.unknowns_as_longvarchar) flag |= BIT_UNKNOWNSASLONGVARCHAR; if (ci->drivers.bools_as_char) flag |= BIT_BOOLSASCHAR; if (ci->row_versioning[0] == '1') flag |= BIT_ROWVERSIONING; if (ci->show_system_tables[0] == '1') flag |= BIT_SHOWSYSTEMTABLES; if (ci->show_oid_column[0] == '1') flag |= BIT_SHOWOIDCOLUMN; if (ci->fake_oid_index[0] == '1') flag |= BIT_FAKEOIDINDEX; if (ci->true_is_minus1) flag |= BIT_TRUEISMINUS1; if (ci->bytea_as_longvarbinary) flag |= BIT_BYTEAASLONGVARBINARY; if (ci->use_server_side_prepare) flag |= BIT_USESERVERSIDEPREPARE; if (ci->lower_case_identifier) flag |= BIT_LOWERCASEIDENTIFIER; if (ci->optional_errors) flag |= BIT_OPTIONALERRORS; if (ci->fetch_refcursors) flag |= BIT_FETCHREFCURSORS; if (ci->sslmode[0]) { char abbrevmode[sizeof(ci->sslmode)]; (void) snprintf(&connect_string[hlen], nlen, ";" ABBR_SSLMODE "=%s", abbrev_sslmode(ci->sslmode, abbrevmode, sizeof(abbrevmode))); } hlen = strlen(connect_string); nlen = MAX_CONNECT_STRING - hlen; olen = snprintf(&connect_string[hlen], nlen, ";" "%s" /* ABBR_CONNSETTINGS */ ABBR_FETCH "=%d;" ABBR_MAXVARCHARSIZE "=%d;" ABBR_MAXLONGVARCHARSIZE "=%d;" INI_INT8AS "=%d;" ABBR_EXTRASYSTABLEPREFIXES "=%s;" "%s" /* ABBR_PQOPT */ "%s" /* ABBRKEEPALIVE TIME/INTERVAL */ ABBR_NUMERIC_AS "=%d;" #ifdef _HANDLE_ENLIST_IN_DTC_ "%s" #endif /* _HANDLE_ENLIST_IN_DTC_ */ INI_ABBREVIATE "=%02x%x", makeBracketConnectString(ci->conn_settings_in_str, &connsetStr, ci->conn_settings, ABBR_CONNSETTINGS), ci->drivers.fetch_max, ci->drivers.max_varchar_size, ci->drivers.max_longvarchar_size, ci->int8_as, ci->drivers.extra_systable_prefixes, makeBracketConnectString(ci->pqopt_in_str, &pqoptStr, ci->pqopt, ABBR_PQOPT), makeKeepaliveConnectString(keepaliveStr, sizeof(keepaliveStr), ci, TRUE), ci->numeric_as, #ifdef _HANDLE_ENLIST_IN_DTC_ makeXaOptConnectString(xaOptStr, sizeof(xaOptStr), ci, TRUE), #endif /* _HANDLE_ENLIST_IN_DTC_ */ EFFECTIVE_BIT_COUNT, flag); if (olen < nlen || ci->rollback_on_error >= 0) { hlen = strlen(connect_string); nlen = MAX_CONNECT_STRING - hlen; /* * The PROTOCOL setting must be placed after CX flag * so that this option can override the CX setting. */ if (ci->rollback_on_error >= 0) olen = snprintf(&connect_string[hlen], nlen, ";" ABBR_PROTOCOL "=7.4-%d", ci->rollback_on_error); else olen = snprintf(&connect_string[hlen], nlen, ";" ABBR_PROTOCOL "=7.4"); } } if (olen < nlen) { flag = getExtraOptions(ci); if (0 != flag) { hlen = strlen(connect_string); nlen = MAX_CONNECT_STRING - hlen; olen = snprintf(&connect_string[hlen], nlen, ";" INI_EXTRAOPTIONS "=%x;", flag); } } if (olen < 0 || olen >= nlen) /* failed */ connect_string[0] = '\0'; if (NULL != connsetStr) free(connsetStr); if (NULL != pqoptStr) free(pqoptStr); } static void unfoldCXAttribute(ConnInfo *ci, const char *value) { int count; UInt4 flag; if (strlen(value) < 2) { count = 3; sscanf(value, "%x", &flag); } else { char cnt[8]; memcpy(cnt, value, 2); cnt[2] = '\0'; sscanf(cnt, "%x", &count); sscanf(value + 2, "%x", &flag); } ci->allow_keyset = (char)((flag & BIT_UPDATABLECURSORS) != 0); ci->lf_conversion = (char)((flag & BIT_LFCONVERSION) != 0); if (count < 4) return; ci->drivers.unique_index = (char)((flag & BIT_UNIQUEINDEX) != 0); if ((flag & BIT_UNKNOWN_DONTKNOW) != 0) ci->drivers.unknown_sizes = UNKNOWNS_AS_DONTKNOW; else if ((flag & BIT_UNKNOWN_ASMAX) != 0) ci->drivers.unknown_sizes = UNKNOWNS_AS_MAX; else ci->drivers.unknown_sizes = UNKNOWNS_AS_LONGEST; ci->drivers.commlog = (char)((flag & BIT_COMMLOG) != 0); ci->drivers.debug = (char)((flag & BIT_DEBUG) != 0); ci->drivers.parse = (char)((flag & BIT_PARSE) != 0); ci->drivers.use_declarefetch = (char)((flag & BIT_USEDECLAREFETCH) != 0); ITOA_FIXED(ci->onlyread, (char)((flag & BIT_READONLY) != 0)); ci->drivers.text_as_longvarchar = (char)((flag & BIT_TEXTASLONGVARCHAR) !=0); ci->drivers.unknowns_as_longvarchar = (char)((flag & BIT_UNKNOWNSASLONGVARCHAR) !=0); ci->drivers.bools_as_char = (char)((flag & BIT_BOOLSASCHAR) != 0); ITOA_FIXED(ci->row_versioning, (char)((flag & BIT_ROWVERSIONING) != 0)); ITOA_FIXED(ci->show_system_tables, (char)((flag & BIT_SHOWSYSTEMTABLES) != 0)); ITOA_FIXED(ci->show_oid_column, (char)((flag & BIT_SHOWOIDCOLUMN) != 0)); ITOA_FIXED(ci->fake_oid_index, (char)((flag & BIT_FAKEOIDINDEX) != 0)); ci->true_is_minus1 = (char)((flag & BIT_TRUEISMINUS1) != 0); ci->bytea_as_longvarbinary = (char)((flag & BIT_BYTEAASLONGVARBINARY) != 0); ci->use_server_side_prepare = (char)((flag & BIT_USESERVERSIDEPREPARE) != 0); ci->lower_case_identifier = (char)((flag & BIT_LOWERCASEIDENTIFIER) != 0); ci->optional_errors = (char)((flag & BIT_OPTIONALERRORS) != 0); ci->fetch_refcursors = (char)((flag & BIT_FETCHREFCURSORS) != 0); } BOOL get_DSN_or_Driver(ConnInfo *ci, const char *attribute, const char *value) { BOOL found = TRUE; if (stricmp(attribute, "DSN") == 0) STRCPY_FIXED(ci->dsn, value); else if (stricmp(attribute, "driver") == 0) STRCPY_FIXED(ci->drivername, value); else found = FALSE; return found; } BOOL copyConnAttributes(ConnInfo *ci, const char *attribute, const char *value) { BOOL found = TRUE, printed = FALSE; if (stricmp(attribute, "DSN") == 0) STRCPY_FIXED(ci->dsn, value); else if (stricmp(attribute, "driver") == 0) STRCPY_FIXED(ci->drivername, value); else if (stricmp(attribute, INI_KDESC) == 0) STRCPY_FIXED(ci->desc, value); else if (stricmp(attribute, INI_DATABASE) == 0 || stricmp(attribute, ABBR_DATABASE) == 0) STRCPY_FIXED(ci->database, value); else if (stricmp(attribute, INI_SERVER) == 0 || stricmp(attribute, SPEC_SERVER) == 0) STRCPY_FIXED(ci->server, value); else if (stricmp(attribute, INI_USERNAME) == 0 || stricmp(attribute, INI_UID) == 0) STRCPY_FIXED(ci->username, value); else if (stricmp(attribute, INI_PASSWORD) == 0 || stricmp(attribute, "pwd") == 0) { NULL_THE_NAME(ci->password); ci->password = decode_or_remove_braces(value); #ifndef FORCE_PASSWORDE_DISPLAY MYLOG(0, "key='%s' value='xxxxxxxx'\n", attribute); printed = TRUE; #endif } else if (stricmp(attribute, INI_PORT) == 0) STRCPY_FIXED(ci->port, value); else if (stricmp(attribute, INI_READONLY) == 0 || stricmp(attribute, ABBR_READONLY) == 0) STRCPY_FIXED(ci->onlyread, value); else if (stricmp(attribute, INI_PROTOCOL) == 0 || stricmp(attribute, ABBR_PROTOCOL) == 0) { char *ptr; /* * The first part of the Protocol used to be "6.2", "6.3" or * "7.4" to denote which protocol version to use. Nowadays we * only support the 7.4 protocol, also known as the protocol * version 3. So just ignore the first part of the string, * parsing only the rollback_on_error value. */ ptr = strchr(value, '-'); if (ptr) { if ('-' != *value) { *ptr = '\0'; /* ignore first part */ } ci->rollback_on_error = atoi(ptr + 1); MYLOG(0, "key='%s' value='%s' rollback_on_error=%d\n", attribute, value, ci->rollback_on_error); printed = TRUE; } } else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0 || stricmp(attribute, ABBR_SHOWOIDCOLUMN) == 0) STRCPY_FIXED(ci->show_oid_column, value); else if (stricmp(attribute, INI_FAKEOIDINDEX) == 0 || stricmp(attribute, ABBR_FAKEOIDINDEX) == 0) STRCPY_FIXED(ci->fake_oid_index, value); else if (stricmp(attribute, INI_ROWVERSIONING) == 0 || stricmp(attribute, ABBR_ROWVERSIONING) == 0) STRCPY_FIXED(ci->row_versioning, value); else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0 || stricmp(attribute, ABBR_SHOWSYSTEMTABLES) == 0) STRCPY_FIXED(ci->show_system_tables, value); else if (stricmp(attribute, INI_CONNSETTINGS) == 0 || stricmp(attribute, ABBR_CONNSETTINGS) == 0) { /* We can use the conn_settings directly when they are enclosed with braces */ NULL_THE_NAME(ci->conn_settings); ci->conn_settings_in_str = TRUE; ci->conn_settings = decode_or_remove_braces(value); } else if (stricmp(attribute, INI_PQOPT) == 0 || stricmp(attribute, ABBR_PQOPT) == 0) { NULL_THE_NAME(ci->pqopt); ci->pqopt_in_str = TRUE; ci->pqopt = decode_or_remove_braces(value); } else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, ABBR_UPDATABLECURSORS) == 0) ci->allow_keyset = atoi(value); else if (stricmp(attribute, INI_LFCONVERSION) == 0 || stricmp(attribute, ABBR_LFCONVERSION) == 0) ci->lf_conversion = atoi(value); else if (stricmp(attribute, INI_TRUEISMINUS1) == 0 || stricmp(attribute, ABBR_TRUEISMINUS1) == 0) ci->true_is_minus1 = atoi(value); else if (stricmp(attribute, INI_INT8AS) == 0) ci->int8_as = atoi(value); else if (stricmp(attribute, INI_NUMERIC_AS) == 0 || stricmp(attribute, ABBR_NUMERIC_AS) == 0) ci->numeric_as = atoi(value); else if (stricmp(attribute, INI_BYTEAASLONGVARBINARY) == 0 || stricmp(attribute, ABBR_BYTEAASLONGVARBINARY) == 0) ci->bytea_as_longvarbinary = atoi(value); else if (stricmp(attribute, INI_USESERVERSIDEPREPARE) == 0 || stricmp(attribute, ABBR_USESERVERSIDEPREPARE) == 0) ci->use_server_side_prepare = atoi(value); else if (stricmp(attribute, INI_LOWERCASEIDENTIFIER) == 0 || stricmp(attribute, ABBR_LOWERCASEIDENTIFIER) == 0) ci->lower_case_identifier = atoi(value); else if (stricmp(attribute, INI_KEEPALIVETIME) == 0 || stricmp(attribute, ABBR_KEEPALIVETIME) == 0) 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_BATCHSIZE) == 0 || stricmp(attribute, ABBR_BATCHSIZE) == 0) ci->batch_size = atoi(value); else if (stricmp(attribute, INI_OPTIONAL_ERRORS) == 0 || stricmp(attribute, ABBR_OPTIONAL_ERRORS) == 0) ci->optional_errors = atoi(value); else if (stricmp(attribute, INI_IGNORETIMEOUT) == 0 || stricmp(attribute, ABBR_IGNORETIMEOUT) == 0) ci->ignore_timeout = atoi(value); else if (stricmp(attribute, INI_SSLMODE) == 0 || stricmp(attribute, ABBR_SSLMODE) == 0) { switch (value[0]) { case SSLLBYTE_ALLOW: STRCPY_FIXED(ci->sslmode, SSLMODE_ALLOW); break; case SSLLBYTE_PREFER: STRCPY_FIXED(ci->sslmode, SSLMODE_PREFER); break; case SSLLBYTE_REQUIRE: STRCPY_FIXED(ci->sslmode, SSLMODE_REQUIRE); break; case SSLLBYTE_VERIFY: switch (value[1]) { case 'f': STRCPY_FIXED(ci->sslmode, SSLMODE_VERIFY_FULL); break; case 'c': STRCPY_FIXED(ci->sslmode, SSLMODE_VERIFY_CA); break; default: STRCPY_FIXED(ci->sslmode, value); } break; case SSLLBYTE_DISABLE: default: STRCPY_FIXED(ci->sslmode, SSLMODE_DISABLE); break; } MYLOG(0, "key='%s' value='%s' set to '%s'\n", attribute, value, ci->sslmode); printed = TRUE; } else if (stricmp(attribute, INI_ABBREVIATE) == 0) unfoldCXAttribute(ci, value); #ifdef _HANDLE_ENLIST_IN_DTC_ else if (stricmp(attribute, INI_XAOPT) == 0) ci->xa_opt = atoi(value); #endif /* _HANDLE_ENLIST_IN_DTC_ */ else if (stricmp(attribute, INI_EXTRAOPTIONS) == 0) { UInt4 val1 = 0, val2 = 0; if ('+' == value[0]) { sscanf(value + 1, "%x-%x", &val1, &val2); add_removeExtraOptions(ci, val1, val2); } else if ('-' == value[0]) { sscanf(value + 1, "%x", &val2); add_removeExtraOptions(ci, 0, val2); } else { setExtraOptions(ci, value, hex_format); } MYLOG(0, "key='%s' value='%s'(force_abbrev=%d bde=%d cvt_null_date=%x)\n", attribute, value, ci->force_abbrev_connstr, ci->bde_environment, ci->cvt_null_date_string); printed = TRUE; } else if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, ABBR_FETCH) == 0) ci->drivers.fetch_max = atoi(value); else if (stricmp(attribute, INI_DEBUG) == 0 || stricmp(attribute, ABBR_DEBUG) == 0) ci->drivers.debug = atoi(value); else if (stricmp(attribute, INI_COMMLOG) == 0 || stricmp(attribute, ABBR_COMMLOG) == 0) ci->drivers.commlog = atoi(value); /* * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index = * atoi(value); */ else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, ABBR_UNKNOWNSIZES) == 0) ci->drivers.unknown_sizes = atoi(value); else if (stricmp(attribute, INI_LIE) == 0) ci->drivers.lie = atoi(value); else if (stricmp(attribute, INI_PARSE) == 0 || stricmp(attribute, ABBR_PARSE) == 0) ci->drivers.parse = atoi(value); else if (stricmp(attribute, INI_USEDECLAREFETCH) == 0 || stricmp(attribute, ABBR_USEDECLAREFETCH) == 0) ci->drivers.use_declarefetch = atoi(value); else if (stricmp(attribute, INI_MAXVARCHARSIZE) == 0 || stricmp(attribute, ABBR_MAXVARCHARSIZE) == 0) ci->drivers.max_varchar_size = atoi(value); else if (stricmp(attribute, INI_MAXLONGVARCHARSIZE) == 0 || stricmp(attribute, ABBR_MAXLONGVARCHARSIZE) == 0) ci->drivers.max_longvarchar_size = atoi(value); else if (stricmp(attribute, INI_TEXTASLONGVARCHAR) == 0 || stricmp(attribute, ABBR_TEXTASLONGVARCHAR) == 0) ci->drivers.text_as_longvarchar = atoi(value); else if (stricmp(attribute, INI_UNKNOWNSASLONGVARCHAR) == 0 || stricmp(attribute, ABBR_UNKNOWNSASLONGVARCHAR) == 0) ci->drivers.unknowns_as_longvarchar = atoi(value); else if (stricmp(attribute, INI_BOOLSASCHAR) == 0 || stricmp(attribute, ABBR_BOOLSASCHAR) == 0) ci->drivers.bools_as_char = atoi(value); else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, ABBR_EXTRASYSTABLEPREFIXES) == 0) STRCPY_FIXED(ci->drivers.extra_systable_prefixes, value); else if (stricmp(attribute, INI_FETCHREFCURSORS) == 0 || stricmp(attribute, ABBR_FETCHREFCURSORS) == 0) ci->fetch_refcursors = atoi(value); else found = FALSE; if (!printed) MYLOG(0, "key='%s' value='%s'%s\n", attribute, value, found ? NULL_STRING : " not found"); return found; } static void getCiDefaults(ConnInfo *ci) { MYLOG(0, "entering\n"); ci->drivers.debug = DEFAULT_DEBUG; ci->drivers.commlog = DEFAULT_COMMLOG; ITOA_FIXED(ci->onlyread, DEFAULT_READONLY); ITOA_FIXED(ci->fake_oid_index, DEFAULT_FAKEOIDINDEX); ITOA_FIXED(ci->show_oid_column, DEFAULT_SHOWOIDCOLUMN); ITOA_FIXED(ci->show_system_tables, DEFAULT_SHOWSYSTEMTABLES); ITOA_FIXED(ci->row_versioning, DEFAULT_ROWVERSIONING); ci->allow_keyset = DEFAULT_UPDATABLECURSORS; ci->lf_conversion = DEFAULT_LFCONVERSION; ci->true_is_minus1 = DEFAULT_TRUEISMINUS1; ci->int8_as = DEFAULT_INT8AS; ci->numeric_as = DEFAULT_NUMERIC_AS; ci->optional_errors = DEFAULT_OPTIONAL_ERRORS; ci->bytea_as_longvarbinary = DEFAULT_BYTEAASLONGVARBINARY; ci->use_server_side_prepare = DEFAULT_USESERVERSIDEPREPARE; ci->lower_case_identifier = DEFAULT_LOWERCASEIDENTIFIER; STRCPY_FIXED(ci->sslmode, DEFAULT_SSLMODE); ci->force_abbrev_connstr = 0; ci->fake_mss = 0; ci->bde_environment = 0; ci->cvt_null_date_string = 0; ci->accessible_only = 0; ci->ignore_round_trip_time = 0; ci->disable_keepalive = 0; { const char *p; ci->wcs_debug = 0; if (NULL != (p = getenv("PSQLODBC_WCS_DEBUG"))) if (strcmp(p, "1") == 0) ci->wcs_debug = 1; } ci->disable_convert_func = 0; ci->fetch_refcursors = DEFAULT_FETCHREFCURSORS; #ifdef _HANDLE_ENLIST_IN_DTC_ ci->xa_opt = DEFAULT_XAOPT; #endif /* _HANDLE_ENLIST_IN_DTC_ */ } int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen) { #ifdef WIN32 return SQLGetPrivateProfileString(ODBC_DATASOURCES, dsn, NULL_STRING, driver_name, namelen, ODBC_INI); #else /* WIN32 */ int cnt; cnt = SQLGetPrivateProfileString(dsn, "Driver", NULL_STRING, driver_name, namelen, ODBC_INI); if (!driver_name[0]) return cnt; if (strchr(driver_name, '/') || /* path to the driver */ strchr(driver_name, '.')) { driver_name[0] = '\0'; return 0; } return cnt; #endif /* WIN32 */ } static void Global_defset(GLOBAL_VALUES *comval) { comval->fetch_max = FETCH_MAX; comval->unique_index = DEFAULT_UNIQUEINDEX; comval->unknown_sizes = DEFAULT_UNKNOWNSIZES; comval->lie = DEFAULT_LIE; comval->parse = DEFAULT_PARSE; comval->use_declarefetch = DEFAULT_USEDECLAREFETCH; comval->max_varchar_size = MAX_VARCHAR_SIZE; comval->max_longvarchar_size = TEXT_FIELD_SIZE; comval->text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR; comval->unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR; comval->bools_as_char = DEFAULT_BOOLSASCHAR; STRCPY_FIXED(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES); STRCPY_FIXED(comval->protocol, DEFAULT_PROTOCOL); } static void get_Ci_Drivers(const char *section, const char *filename, GLOBAL_VALUES *comval); void getDriversDefaults(const char *drivername, GLOBAL_VALUES *comval) { MYLOG(0, "%p of the driver %s\n", comval, NULL_IF_NULL(drivername)); get_Ci_Drivers(drivername, ODBCINST_INI, comval); if (NULL != drivername) STR_TO_NAME(comval->drivername, drivername); } void getCiAllDefaults(ConnInfo *ci) { Global_defset(&(ci->drivers)); getCiDefaults(ci); } void getDSNinfo(ConnInfo *ci, const char *configDrvrname) { char *DSN = ci->dsn; char temp[LARGE_REGISTRY_LEN]; const char *drivername; /* * If a driver keyword was present, then dont use a DSN and return. * If DSN is null and no driver, then use the default datasource. */ MYLOG(0, "entering DSN=%s driver=%s&%s\n", DSN, ci->drivername, NULL_IF_NULL(configDrvrname)); getCiDefaults(ci); drivername = ci->drivername; if (DSN[0] == '\0') { if (drivername[0] == '\0') /* adding new DSN via configDSN */ { if (configDrvrname) drivername = configDrvrname; strncpy_null(DSN, INI_DSN, sizeof(ci->dsn)); } /* else dns-less connections */ } /* brute-force chop off trailing blanks... */ while (*(DSN + strlen(DSN) - 1) == ' ') *(DSN + strlen(DSN) - 1) = '\0'; if (!drivername[0] && DSN[0]) getDriverNameFromDSN(DSN, (char *) drivername, sizeof(ci->drivername)); MYLOG(0, "drivername=%s\n", drivername); if (!drivername[0]) drivername = INVALID_DRIVER; getDriversDefaults(drivername, &(ci->drivers)); if (DSN[0] == '\0') return; /* Proceed with getting info for the given DSN. */ SQLGetPrivateProfileString(DSN, INI_KDESC, NULL_STRING, ci->desc, sizeof(ci->desc), ODBC_INI); if (SQLGetPrivateProfileString(DSN, INI_SERVER, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->server, temp); if (SQLGetPrivateProfileString(DSN, INI_DATABASE, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->database, temp); if (SQLGetPrivateProfileString(DSN, INI_USERNAME, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->username, temp); if (SQLGetPrivateProfileString(DSN, INI_PASSWORD, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->password = decode(temp); if (SQLGetPrivateProfileString(DSN, INI_PORT, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->port, temp); /* It's appropriate to handle debug and commlog here */ if (SQLGetPrivateProfileString(DSN, INI_DEBUG, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->drivers.debug = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_COMMLOG, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->drivers.commlog = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_READONLY, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->onlyread, temp); if (SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->show_oid_column, temp); if (SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->fake_oid_index, temp); if (SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->row_versioning, temp); if (SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->show_system_tables, temp); SQLGetPrivateProfileString(DSN, INI_PROTOCOL, ENTRY_TEST, temp, sizeof(temp), ODBC_INI); if (strcmp(temp, ENTRY_TEST)) /* entry exists */ { char *ptr; if (ptr = strchr(temp, '-'), NULL != ptr) { *ptr = '\0'; ci->rollback_on_error = atoi(ptr + 1); MYLOG(0, "rollback_on_error=%d\n", ci->rollback_on_error); } } SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, ENTRY_TEST, temp, sizeof(temp), ODBC_INI); if (strcmp(temp, ENTRY_TEST)) /* entry exists */ { const UCHAR *ptr; BOOL percent_encoded = TRUE, pspace; int nspcnt; /* * percent-encoding was used before. * Note that there's no space in percent-encoding. */ for (ptr = (UCHAR *) temp, pspace = TRUE, nspcnt = 0; *ptr; ptr++) { if (isspace(*ptr)) pspace = TRUE; else { if (pspace) { if (nspcnt++ > 1) { percent_encoded = FALSE; break; } } pspace = FALSE; } } if (percent_encoded) ci->conn_settings = decode(temp); else STRX_TO_NAME(ci->conn_settings, temp); } SQLGetPrivateProfileString(DSN, INI_PQOPT, ENTRY_TEST, temp, sizeof(temp), ODBC_INI); if (strcmp(temp, ENTRY_TEST)) /* entry exists */ STRX_TO_NAME(ci->pqopt, temp); if (SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->translation_dll, temp); if (SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->translation_option, temp); if (SQLGetPrivateProfileString(DSN, INI_UPDATABLECURSORS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->allow_keyset = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_LFCONVERSION, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->lf_conversion = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_TRUEISMINUS1, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->true_is_minus1 = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_INT8AS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->int8_as = atoi(temp); if (SQLGetPrivateProfileString(DSN, ABBR_NUMERIC_AS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->numeric_as = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_OPTIONAL_ERRORS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->optional_errors = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_BYTEAASLONGVARBINARY, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->bytea_as_longvarbinary = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_USESERVERSIDEPREPARE, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->use_server_side_prepare = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_LOWERCASEIDENTIFIER, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->lower_case_identifier = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_KEEPALIVETIME, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) if (0 == (ci->keepalive_idle = atoi(temp))) ci->keepalive_idle = -1; if (SQLGetPrivateProfileString(DSN, INI_KEEPALIVEINTERVAL, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) if (0 == (ci->keepalive_interval = atoi(temp))) ci->keepalive_interval = -1; if (SQLGetPrivateProfileString(DSN, INI_BATCHSIZE, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) if (0 == (ci->batch_size = atoi(temp))) ci->batch_size = DEFAULT_BATCH_SIZE; if (SQLGetPrivateProfileString(DSN, INI_IGNORETIMEOUT, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->ignore_timeout = atoi(temp); if (SQLGetPrivateProfileString(DSN, INI_SSLMODE, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) STRCPY_FIXED(ci->sslmode, temp); if (SQLGetPrivateProfileString(DSN, INI_FETCHREFCURSORS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->fetch_refcursors = atoi(temp); #ifdef _HANDLE_ENLIST_IN_DTC_ if (SQLGetPrivateProfileString(DSN, INI_XAOPT, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) ci->xa_opt = atoi(temp); #endif /* _HANDLE_ENLIST_IN_DTC_ */ /* Force abbrev connstr or bde */ if (SQLGetPrivateProfileString(DSN, INI_EXTRAOPTIONS, NULL_STRING, temp, sizeof(temp), ODBC_INI) > 0) { UInt4 val = 0; sscanf(temp, "%x", &val); replaceExtraOptions(ci, val, TRUE); MYLOG(0, "force_abbrev=%d bde=%d cvt_null_date=%d\n", ci->force_abbrev_connstr, ci->bde_environment, ci->cvt_null_date_string); } /* Allow override of odbcinst.ini parameters here */ get_Ci_Drivers(DSN, ODBC_INI, &(ci->drivers)); STR_TO_NAME(ci->drivers.drivername, drivername); MYLOG(DETAIL_LOG_LEVEL, "DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n", DSN, ci->server, ci->port, ci->database, ci->username, NAME_IS_VALID(ci->password) ? "xxxxx" : ""); MYLOG(DETAIL_LOG_LEVEL, " onlyread='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n", ci->onlyread, ci->show_oid_column, ci->fake_oid_index, ci->show_system_tables); { #ifdef NOT_USED char *enc = (char *) check_client_encoding(ci->conn_settings); MYLOG(DETAIL_LOG_LEVEL, " conn_settings='%s', conn_encoding='%s'\n", ci->conn_settings, NULL != enc ? enc : "(null)"); if (NULL != enc) free(enc); #endif /* NOT_USED */ MYLOG(DETAIL_LOG_LEVEL, " translation_dll='%s',translation_option='%s'\n", ci->translation_dll, ci->translation_option); } } /* * This function writes any global parameters (that can be manipulated) * to the ODBCINST.INI portion of the registry */ int write_Ci_Drivers(const char *fileName, const char *sectionName, const GLOBAL_VALUES *comval) { char tmp[128]; int errc = 0; if (stricmp(ODBCINST_INI, fileName) == 0) { if (NULL == sectionName) sectionName = DBMS_NAME; } if (stricmp(ODBCINST_INI, fileName) == 0) return errc; ITOA_FIXED(tmp, comval->commlog); if (!SQLWritePrivateProfileString(sectionName, INI_COMMLOG, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->debug); if (!SQLWritePrivateProfileString(sectionName, INI_DEBUG, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->fetch_max); if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->unique_index); if (!SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->use_declarefetch); if (!SQLWritePrivateProfileString(sectionName, INI_USEDECLAREFETCH, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->unknown_sizes); if (!SQLWritePrivateProfileString(sectionName, INI_UNKNOWNSIZES, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->text_as_longvarchar); if (!SQLWritePrivateProfileString(sectionName, INI_TEXTASLONGVARCHAR, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->unknowns_as_longvarchar); if (!SQLWritePrivateProfileString(sectionName, INI_UNKNOWNSASLONGVARCHAR, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->bools_as_char); if (!SQLWritePrivateProfileString(sectionName, INI_BOOLSASCHAR, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->parse); if (!SQLWritePrivateProfileString(sectionName, INI_PARSE, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->max_varchar_size); if (!SQLWritePrivateProfileString(sectionName, INI_MAXVARCHARSIZE, tmp, fileName)) errc--; ITOA_FIXED(tmp, comval->max_longvarchar_size); if (!SQLWritePrivateProfileString(sectionName, INI_MAXLONGVARCHARSIZE, tmp, fileName)) errc--; if (!SQLWritePrivateProfileString(sectionName, INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName)) errc--; /* * Never update the conn_setting from this module * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS, * comval->conn_settings, fileName); */ return errc; } int writeDriversDefaults(const char *drivername, const GLOBAL_VALUES *comval) { return write_Ci_Drivers(ODBCINST_INI, drivername, comval); } /* This is for datasource based options only */ void writeDSNinfo(const ConnInfo *ci) { const char *DSN = ci->dsn; char encoded_item[MEDIUM_REGISTRY_LEN], temp[SMALL_REGISTRY_LEN]; SQLWritePrivateProfileString(DSN, INI_KDESC, ci->desc, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_DATABASE, ci->database, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SERVER, ci->server, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_PORT, ci->port, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_USERNAME, ci->username, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_UID, ci->username, ODBC_INI); encode(ci->password, encoded_item, sizeof(encoded_item)); SQLWritePrivateProfileString(DSN, INI_PASSWORD, encoded_item, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_READONLY, ci->onlyread, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SHOWOIDCOLUMN, ci->show_oid_column, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_FAKEOIDINDEX, ci->fake_oid_index, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_ROWVERSIONING, ci->row_versioning, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, ci->show_system_tables, ODBC_INI); if (ci->rollback_on_error >= 0) SPRINTF_FIXED(temp, "7.4-%d", ci->rollback_on_error); else STRCPY_FIXED(temp, NULL_STRING); SQLWritePrivateProfileString(DSN, INI_PROTOCOL, temp, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_CONNSETTINGS, SAFE_NAME(ci->conn_settings), ODBC_INI); SQLWritePrivateProfileString(DSN, INI_PQOPT, SAFE_NAME(ci->pqopt), ODBC_INI); ITOA_FIXED(temp, ci->allow_keyset); SQLWritePrivateProfileString(DSN, INI_UPDATABLECURSORS, temp, ODBC_INI); ITOA_FIXED(temp, ci->lf_conversion); SQLWritePrivateProfileString(DSN, INI_LFCONVERSION, temp, ODBC_INI); ITOA_FIXED(temp, ci->true_is_minus1); SQLWritePrivateProfileString(DSN, INI_TRUEISMINUS1, temp, ODBC_INI); ITOA_FIXED(temp, ci->int8_as); SQLWritePrivateProfileString(DSN, INI_INT8AS, temp, ODBC_INI); ITOA_FIXED(temp, ci->numeric_as); SQLWritePrivateProfileString(DSN, ABBR_NUMERIC_AS, temp, ODBC_INI); ITOA_FIXED(temp, ci->optional_errors); SQLWritePrivateProfileString(DSN, INI_OPTIONAL_ERRORS, temp, ODBC_INI); SPRINTF_FIXED(temp, "%x", getExtraOptions(ci)); SQLWritePrivateProfileString(DSN, INI_EXTRAOPTIONS, temp, ODBC_INI); ITOA_FIXED(temp, ci->bytea_as_longvarbinary); SQLWritePrivateProfileString(DSN, INI_BYTEAASLONGVARBINARY, temp, ODBC_INI); ITOA_FIXED(temp, ci->use_server_side_prepare); SQLWritePrivateProfileString(DSN, INI_USESERVERSIDEPREPARE, temp, ODBC_INI); ITOA_FIXED(temp, ci->lower_case_identifier); SQLWritePrivateProfileString(DSN, INI_LOWERCASEIDENTIFIER, temp, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SSLMODE, ci->sslmode, ODBC_INI); ITOA_FIXED(temp, ci->keepalive_idle); SQLWritePrivateProfileString(DSN, INI_KEEPALIVETIME, temp, ODBC_INI); ITOA_FIXED(temp, ci->keepalive_interval); SQLWritePrivateProfileString(DSN, INI_KEEPALIVEINTERVAL, temp, ODBC_INI); ITOA_FIXED(temp, ci->batch_size); SQLWritePrivateProfileString(DSN, INI_BATCHSIZE, temp, ODBC_INI); ITOA_FIXED(temp, ci->ignore_timeout); SQLWritePrivateProfileString(DSN, INI_IGNORETIMEOUT, temp, ODBC_INI); ITOA_FIXED(temp, ci->fetch_refcursors); SQLWritePrivateProfileString(DSN, INI_FETCHREFCURSORS, temp, ODBC_INI); #ifdef _HANDLE_ENLIST_IN_DTC_ ITOA_FIXED(temp, ci->xa_opt); SQLWritePrivateProfileString(DSN, INI_XAOPT, temp, ODBC_INI); #endif /* _HANDLE_ENLIST_IN_DTC_ */ } /* * This function reads the ODBCINST.INI portion of * the registry and gets any driver defaults. */ static void get_Ci_Drivers(const char *section, const char *filename, GLOBAL_VALUES *comval) { char temp[256]; BOOL inst_position = (stricmp(filename, ODBCINST_INI) == 0); if (0 != strcmp(ODBCINST_INI, filename)) MYLOG(0, "setting %s position of %s(%p)\n", filename, section, comval); /* * It's not appropriate to handle debug or commlog here. * Now they are handled in getDSNinfo(). */ if (inst_position) Global_defset(comval); if (NULL == section || strcmp(section, INVALID_DRIVER) == 0) return; /* * If inst_position of xxxxxx is present(usually not present), * it is the default of ci->drivers.xxxxxx . */ /* Fetch Count is stored in driver section */ if (SQLGetPrivateProfileString(section, INI_FETCH, NULL_STRING, temp, sizeof(temp), filename) > 0) { if (atoi(temp) > 0) comval->fetch_max = atoi(temp); } /* Recognize Unique Index is stored in the driver section only */ if (SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->unique_index = atoi(temp); /* Unknown Sizes is stored in the driver section only */ if (SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->unknown_sizes = atoi(temp); /* Lie about supported functions? */ if (SQLGetPrivateProfileString(section, INI_LIE, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->lie = atoi(temp); /* Parse statements */ if (SQLGetPrivateProfileString(section, INI_PARSE, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->parse = atoi(temp); /* UseDeclareFetch is stored in the driver section only */ if (SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->use_declarefetch = atoi(temp); /* Max Varchar Size */ if (SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->max_varchar_size = atoi(temp); /* Max TextField Size */ if (SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->max_longvarchar_size = atoi(temp); /* Text As LongVarchar */ if (SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->text_as_longvarchar = atoi(temp); /* Unknowns As LongVarchar */ if (SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->unknowns_as_longvarchar = atoi(temp); /* Bools As Char */ if (SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, NULL_STRING, temp, sizeof(temp), filename) > 0) comval->bools_as_char = atoi(temp); /* Extra Systable prefixes */ /* * Use ENTRY_TEST to distinguish between blank extra prefixes and no key * entry */ SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, ENTRY_TEST, temp, sizeof(temp), filename); if (strcmp(temp, ENTRY_TEST)) STRCPY_FIXED(comval->extra_systable_prefixes, temp); MYLOG(0, "comval=%p comval->extra_systable_prefixes = '%s'\n", comval, comval->extra_systable_prefixes); /* Dont allow override of an override! */ if (inst_position) { /* * Default state for future DSN's protocol attribute This isn't a * real driver option YET. This is more intended for * customization from the install. */ SQLGetPrivateProfileString(section, INI_PROTOCOL, ENTRY_TEST, temp, sizeof(temp), filename); if (strcmp(temp, ENTRY_TEST)) STRCPY_FIXED(comval->protocol, temp); } } static void encode(const pgNAME in, char *out, int outlen) { size_t i, ilen, o = 0; char inc, *ins; if (NAME_IS_NULL(in)) { out[0] = '\0'; return; } ins = GET_NAME(in); ilen = strlen(ins); for (i = 0; i < ilen && o < outlen - 1; i++) { inc = ins[i]; if (inc == '+') { if (o + 2 >= outlen) break; snprintf(&out[o], outlen - o, "%%2B"); o += 3; } else if (isspace((unsigned char) inc)) out[o++] = '+'; else if (!isalnum((unsigned char) inc)) { if (o + 2 >= outlen) break; snprintf(&out[o], outlen - o, "%%%02x", inc); o += 3; } else out[o++] = inc; } out[o++] = '\0'; } static unsigned int conv_from_hex(const char *s) { int i, y = 0, val; for (i = 1; i <= 2; i++) { if (s[i] >= 'a' && s[i] <= 'f') val = s[i] - 'a' + 10; else if (s[i] >= 'A' && s[i] <= 'F') val = s[i] - 'A' + 10; else val = s[i] - '0'; y += val << (4 * (2 - i)); } return y; } static pgNAME decode(const char *in) { size_t i, ilen = strlen(in), o = 0; char inc, *outs; pgNAME out; INIT_NAME(out); if (0 == ilen) { return out; } outs = (char *) malloc(ilen + 1); if (!outs) return out; for (i = 0; i < ilen; i++) { inc = in[i]; if (inc == '+') outs[o++] = ' '; else if (inc == '%') { snprintf(&outs[o], ilen + 1 - o, "%c", conv_from_hex(&in[i])); o++; i += 2; } else outs[o++] = inc; } outs[o++] = '\0'; STR_TO_NAME(out, outs); free(outs); return out; } /* * Remove braces if the input value is enclosed by braces({}). * Otherwise decode the input value. */ static pgNAME decode_or_remove_braces(const char *in) { if (OPENING_BRACKET == in[0]) { size_t inlen = strlen(in); if (CLOSING_BRACKET == in[inlen - 1]) /* enclosed with braces */ { int i; const char *istr, *eptr; char *ostr; pgNAME out; INIT_NAME(out); if (NULL == (ostr = (char *) malloc(inlen))) return out; eptr = in + inlen - 1; for (istr = in + 1, i = 0; *istr && istr < eptr; i++) { if (CLOSING_BRACKET == istr[0] && CLOSING_BRACKET == istr[1]) istr++; ostr[i] = *(istr++); } ostr[i] = '\0'; SET_NAME_DIRECTLY(out, ostr); return out; } } return decode(in); } /* * extract the specified attribute from the comment part. * attribute=[']value['] */ char *extract_extra_attribute_setting(const pgNAME setting, const char *attr) { const char *str = SAFE_NAME(setting); const char *cptr, *sptr = NULL; char *rptr; BOOL allowed_cmd = FALSE, in_quote = FALSE, in_comment = FALSE; int step = 0, step_last = 2; size_t len = 0, attrlen = strlen(attr); for (cptr = str; *cptr; cptr++) { if (in_quote) { if (LITERAL_QUOTE == *cptr) { if (step_last == step) { len = cptr - sptr; step = 0; } in_quote = FALSE; } continue; } else if (in_comment) { if ('*' == *cptr && '/' == cptr[1]) { if (step_last == step) { len = cptr - sptr; step = 0; } in_comment = FALSE; allowed_cmd = FALSE; cptr++; continue; } } else if ('/' == *cptr && '*' == cptr[1]) { in_comment = TRUE; allowed_cmd = TRUE; cptr++; continue; } else { if (LITERAL_QUOTE == *cptr) in_quote = TRUE; continue; } /* now in comment */ if (';' == *cptr || isspace((unsigned char) *cptr)) { if (step_last == step) len = cptr - sptr; allowed_cmd = TRUE; step = 0; continue; } if (!allowed_cmd) continue; switch (step) { case 0: if (0 != strnicmp(cptr, attr, attrlen)) { allowed_cmd = FALSE; continue; } if (cptr[attrlen] != '=') { allowed_cmd = FALSE; continue; } step++; cptr += attrlen; break; case 1: if (LITERAL_QUOTE == *cptr) { in_quote = TRUE; cptr++; sptr = cptr; } else sptr = cptr; step++; break; } } if (!sptr) return NULL; rptr = malloc(len + 1); if (!rptr) return NULL; memcpy(rptr, sptr, len); rptr[len] = '\0'; MYLOG(0, "extracted a %s '%s' from %s\n", attr, rptr, str); return rptr; } signed char ci_updatable_cursors_set(ConnInfo *ci) { ci->updatable_cursors = DISALLOW_UPDATABLE_CURSORS; if (ci->allow_keyset) { if (ci->drivers.lie || !ci->drivers.use_declarefetch) ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_KEYSET_DRIVEN_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS); else ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS); } return ci->updatable_cursors; } void CC_conninfo_release(ConnInfo *conninfo) { NULL_THE_NAME(conninfo->password); NULL_THE_NAME(conninfo->conn_settings); NULL_THE_NAME(conninfo->pqopt); finalize_globals(&conninfo->drivers); } void CC_conninfo_init(ConnInfo *conninfo, UInt4 option) { MYLOG(0, "entering opt=%d\n", option); if (0 != (CLEANUP_FOR_REUSE & option)) CC_conninfo_release(conninfo); memset(conninfo, 0, sizeof(ConnInfo)); conninfo->allow_keyset = -1; conninfo->lf_conversion = -1; conninfo->true_is_minus1 = -1; conninfo->int8_as = -101; conninfo->numeric_as = DEFAULT_NUMERIC_AS; conninfo->optional_errors = -1; conninfo->bytea_as_longvarbinary = -1; conninfo->use_server_side_prepare = -1; conninfo->lower_case_identifier = -1; conninfo->rollback_on_error = -1; conninfo->force_abbrev_connstr = -1; conninfo->bde_environment = -1; conninfo->fake_mss = -1; conninfo->cvt_null_date_string = -1; conninfo->accessible_only = -1; conninfo->ignore_round_trip_time = -1; conninfo->disable_keepalive = -1; conninfo->keepalive_idle = -1; conninfo->keepalive_interval = -1; conninfo->disable_convert_func = -1; conninfo->batch_size = DEFAULT_BATCH_SIZE; conninfo->ignore_timeout = DEFAULT_IGNORETIMEOUT; conninfo->wcs_debug = -1; conninfo->fetch_refcursors = -1; #ifdef _HANDLE_ENLIST_IN_DTC_ conninfo->xa_opt = -1; #endif /* _HANDLE_ENLIST_IN_DTC_ */ if (0 != (INIT_GLOBALS & option)) init_globals(&(conninfo->drivers)); } void init_globals(GLOBAL_VALUES *glbv) { memset(glbv, 0, sizeof(*glbv)); glbv->debug = -1; glbv->commlog = -1; } #define CORR_STRCPY(item) strncpy_null(to->item, from->item, sizeof(to->item)) #define CORR_VALCPY(item) (to->item = from->item) void copy_globals(GLOBAL_VALUES *to, const GLOBAL_VALUES *from) { memset(to, 0, sizeof(*to)); /*** memcpy(to, from, sizeof(GLOBAL_VALUES)); SET_NAME_DIRECTLY(to->drivername, NULL); ***/ NAME_TO_NAME(to->drivername, from->drivername); CORR_VALCPY(fetch_max); CORR_VALCPY(unknown_sizes); CORR_VALCPY(max_varchar_size); CORR_VALCPY(max_longvarchar_size); CORR_VALCPY(debug); CORR_VALCPY(commlog); CORR_VALCPY(unique_index); CORR_VALCPY(use_declarefetch); CORR_VALCPY(text_as_longvarchar); CORR_VALCPY(unknowns_as_longvarchar); CORR_VALCPY(bools_as_char); CORR_VALCPY(lie); CORR_VALCPY(parse); CORR_STRCPY(extra_systable_prefixes); CORR_STRCPY(protocol); MYLOG(0, "driver=%s\n", SAFE_NAME(to->drivername)); } void finalize_globals(GLOBAL_VALUES *glbv) { NULL_THE_NAME(glbv->drivername); } #undef CORR_STRCPY #undef CORR_VALCPY #define CORR_STRCPY(item) strncpy_null(ci->item, sci->item, sizeof(ci->item)) #define CORR_VALCPY(item) (ci->item = sci->item) void CC_copy_conninfo(ConnInfo *ci, const ConnInfo *sci) { memset(ci, 0,sizeof(ConnInfo)); CORR_STRCPY(dsn); CORR_STRCPY(desc); CORR_STRCPY(drivername); CORR_STRCPY(server); CORR_STRCPY(database); CORR_STRCPY(username); NAME_TO_NAME(ci->password, sci->password); CORR_STRCPY(port); CORR_STRCPY(sslmode); CORR_STRCPY(onlyread); CORR_STRCPY(fake_oid_index); CORR_STRCPY(show_oid_column); CORR_STRCPY(row_versioning); CORR_STRCPY(show_system_tables); CORR_STRCPY(translation_dll); CORR_STRCPY(translation_option); CORR_VALCPY(password_required); NAME_TO_NAME(ci->conn_settings, sci->conn_settings); CORR_VALCPY(allow_keyset); CORR_VALCPY(updatable_cursors); CORR_VALCPY(lf_conversion); CORR_VALCPY(true_is_minus1); CORR_VALCPY(int8_as); CORR_VALCPY(numeric_as); CORR_VALCPY(optional_errors); CORR_VALCPY(bytea_as_longvarbinary); CORR_VALCPY(use_server_side_prepare); CORR_VALCPY(lower_case_identifier); CORR_VALCPY(rollback_on_error); CORR_VALCPY(force_abbrev_connstr); CORR_VALCPY(bde_environment); CORR_VALCPY(fake_mss); CORR_VALCPY(cvt_null_date_string); CORR_VALCPY(accessible_only); CORR_VALCPY(ignore_round_trip_time); CORR_VALCPY(disable_keepalive); CORR_VALCPY(disable_convert_func); CORR_VALCPY(extra_opts); CORR_VALCPY(keepalive_idle); CORR_VALCPY(keepalive_interval); CORR_VALCPY(batch_size); CORR_VALCPY(ignore_timeout); CORR_VALCPY(fetch_refcursors); #ifdef _HANDLE_ENLIST_IN_DTC_ CORR_VALCPY(xa_opt); #endif copy_globals(&(ci->drivers), &(sci->drivers)); /* moved from driver's option */ } #undef CORR_STRCPY #undef CORR_VALCPY psqlodbc-REL-16_00_0005/dlg_specific.h000066400000000000000000000261161462406103600172700ustar00rootroot00000000000000/* File: dlg_specific.h * * Description: See "dlg_specific.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __DLG_SPECIFIC_H__ #define __DLG_SPECIFIC_H__ #include "psqlodbc.h" #ifdef WIN32 #include #include "resource.h" #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Unknown data type sizes */ #define UNKNOWNS_AS_MAX 0 #define UNKNOWNS_AS_DONTKNOW 1 #define UNKNOWNS_AS_LONGEST 2 /* ODBC initialization files */ #ifndef WIN32 #define ODBC_INI ".odbc.ini" #define ODBCINST_INI "odbcinst.ini" #else #define ODBC_INI "ODBC.INI" #define ODBCINST_INI "ODBCINST.INI" #endif #define ODBC_DATASOURCES "ODBC Data Sources" #define INVALID_DRIVER " @@driver not exist@@ " #ifdef UNICODE_SUPPORT #define INI_DSN "PostgreSQL35W" #else #define INI_DSN "PostgreSQL30" #endif /* UNICODE_SUPPORT */ #define INI_KDESC "Description" /* Data source * description */ #define INI_SERVER "Servername" /* Name of Server * running the Postgres * service */ #define SPEC_SERVER "server" #define INI_PORT "Port" /* Port on which the * Postmaster is listening */ #define INI_DATABASE "Database" /* Database Name */ #define ABBR_DATABASE "DX" /* Database Name */ #define INI_UID "UID" /* Default User Name */ #define INI_USERNAME "Username" /* Default User Name */ #define INI_PASSWORD "Password" /* Default Password */ #define INI_ABBREVIATE "CX" #define INI_DEBUG "Debug" /* Debug flag */ #define ABBR_DEBUG "B2" #define INI_FETCH "Fetch" /* Fetch Max Count */ #define ABBR_FETCH "A7" /* * "Socket", abbreviated as "A8" was used for socket buffer. Now that we do * everything through libpq, it's not used */ #define INI_READONLY "ReadOnly" /* Database is read only */ #define ABBR_READONLY "A0" #define INI_COMMLOG "CommLog" /* Communication to * backend logging */ #define ABBR_COMMLOG "B3" #define INI_PROTOCOL "Protocol" /* Controls rollback-on-error * behavior. Called "Protocol" * for historical reasons */ #define ABBR_PROTOCOL "A1" /* "Optimizer", abbreviated to B4 used to stand for "disable genetic query * optimizer". No longer supported, you can use generic ConnSettings instead. #define INI_OPTIMIZER "Optimizer" #define ABBR_OPTIMIZER "B4" */ /* "Ksqo", abbreviated to B5 was used with pre-7.1 server versions for * "keyset query optimization". No longer used. #define INI_KSQO "Ksqo" #define ABBR_KSQO "B5" */ #define INI_CONNSETTINGS "ConnSettings" /* Anything to send to * backend on successful * connection */ #define ABBR_CONNSETTINGS "A6" #define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique * indexes */ #define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown * result set sizes */ #define ABBR_UNKNOWNSIZES "A9" /* "CancelAsFreeStmt", abbreviated to "C1" was used with ODBC versions older * than 3.51. It was a hack that made SQLCancel to imply * SQLFreeStmt(SQL_CLOSE). It never had an effect in > 3.51 mode. #define INI_CANCELASFREESTMT "CancelAsFreeStmt" #define ABBR_CANCELASFREESTMT "C1" */ #define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch * cursors */ #define ABBR_USEDECLAREFETCH "B6" /* More ini stuff */ #define INI_TEXTASLONGVARCHAR "TextAsLongVarchar" #define ABBR_TEXTASLONGVARCHAR "B7" #define INI_UNKNOWNSASLONGVARCHAR "UnknownsAsLongVarchar" #define ABBR_UNKNOWNSASLONGVARCHAR "B8" #define INI_BOOLSASCHAR "BoolsAsChar" #define ABBR_BOOLSASCHAR "B9" #define INI_MAXVARCHARSIZE "MaxVarcharSize" #define ABBR_MAXVARCHARSIZE "B0" #define INI_MAXLONGVARCHARSIZE "MaxLongVarcharSize" #define ABBR_MAXLONGVARCHARSIZE "B1" #define INI_FAKEOIDINDEX "FakeOidIndex" #define ABBR_FAKEOIDINDEX "A2" #define INI_SHOWOIDCOLUMN "ShowOidColumn" #define ABBR_SHOWOIDCOLUMN "A3" #define INI_ROWVERSIONING "RowVersioning" #define ABBR_ROWVERSIONING "A4" #define INI_SHOWSYSTEMTABLES "ShowSystemTables" #define ABBR_SHOWSYSTEMTABLES "A5" #define INI_LIE "Lie" #define INI_PARSE "Parse" #define ABBR_PARSE "C0" #define INI_EXTRASYSTABLEPREFIXES "ExtraSysTablePrefixes" #define ABBR_EXTRASYSTABLEPREFIXES "C2" #define INI_TRANSLATIONNAME "TranslationName" #define INI_TRANSLATIONDLL "TranslationDLL" #define INI_TRANSLATIONOPTION "TranslationOption" /* * "DisallowPremature", abbreviated "C3", used to mean that we should not * execute a statement prematurely, before SQLExecute() when e.g. * SQLPrepare+SQLDescribeCol is called. We never do that anymore. * #define INI_DISALLOWPREMATURE "DisallowPremature" #define ABBR_DISALLOWPREMATURE "C3" */ #define INI_UPDATABLECURSORS "UpdatableCursors" #define ABBR_UPDATABLECURSORS "C4" #define INI_LFCONVERSION "LFConversion" #define ABBR_LFCONVERSION "C5" #define INI_TRUEISMINUS1 "TrueIsMinus1" #define ABBR_TRUEISMINUS1 "C6" #define INI_INT8AS "BI" #define INI_NUMERIC_AS "NumericAs" #define ABBR_NUMERIC_AS "D6" #define INI_BYTEAASLONGVARBINARY "ByteaAsLongVarBinary" #define ABBR_BYTEAASLONGVARBINARY "C7" #define INI_USESERVERSIDEPREPARE "UseServerSidePrepare" #define ABBR_USESERVERSIDEPREPARE "C8" #define INI_LOWERCASEIDENTIFIER "LowerCaseIdentifier" #define ABBR_LOWERCASEIDENTIFIER "C9" #define INI_SSLMODE "SSLmode" #define ABBR_SSLMODE "CA" #define INI_EXTRAOPTIONS "AB" #define INI_LOGDIR "Logdir" #define INI_KEEPALIVETIME "KeepaliveTime" #define ABBR_KEEPALIVETIME "D1" #define INI_KEEPALIVEINTERVAL "KeepaliveInterval" #define ABBR_KEEPALIVEINTERVAL "D2" #define INI_PQOPT "pqopt" #define ABBR_PQOPT "D5" #define INI_OPTIONAL_ERRORS "OptionalErrors" #define ABBR_OPTIONAL_ERRORS "D7" #define INI_BATCHSIZE "BatchSize" #define ABBR_BATCHSIZE "D8" #define INI_IGNORETIMEOUT "IgnoreTimeout" #define ABBR_IGNORETIMEOUT "D9" #define INI_DTCLOG "Dtclog" #define INI_FETCHREFCURSORS "FetchRefcursors" #define ABBR_FETCHREFCURSORS "DA" /* "PreferLibpq", abbreviated "D4", used to mean whether to prefer libpq. * libpq is now required #define INI_PREFERLIBPQ "PreferLibpq" #define ABBR_PREFERLIBPQ "D3" */ #define ABBR_XAOPT "D4" #define SSLMODE_DISABLE "disable" #define SSLMODE_ALLOW "allow" #define SSLMODE_PREFER "prefer" #define SSLMODE_REQUIRE "require" #define SSLMODE_VERIFY_CA "verify-ca" #define SSLMODE_VERIFY_FULL "verify-full" #define SSLLBYTE_DISABLE 'd' #define SSLLBYTE_ALLOW 'a' #define SSLLBYTE_PREFER 'p' #define SSLLBYTE_REQUIRE 'r' #define SSLLBYTE_VERIFY 'v' #ifdef _HANDLE_ENLIST_IN_DTC_ #define INI_XAOPT "XaOpt" #endif /* _HANDLE_ENLIST_IN_DTC_ */ /* Bit representation for abbreviated connection strings */ #define BIT_LFCONVERSION (1L) #define BIT_UPDATABLECURSORS (1L<<1) /* #define BIT_DISALLOWPREMATURE (1L<<2) */ #define BIT_UNIQUEINDEX (1L<<3) #define BIT_UNKNOWN_DONTKNOW (1L<<6) #define BIT_UNKNOWN_ASMAX (1L<<7) #define BIT_COMMLOG (1L<<10) #define BIT_DEBUG (1L<<11) #define BIT_PARSE (1L<<12) #define BIT_CANCELASFREESTMT (1L<<13) #define BIT_USEDECLAREFETCH (1L<<14) #define BIT_READONLY (1L<<15) #define BIT_TEXTASLONGVARCHAR (1L<<16) #define BIT_UNKNOWNSASLONGVARCHAR (1L<<17) #define BIT_BOOLSASCHAR (1L<<18) #define BIT_ROWVERSIONING (1L<<19) #define BIT_SHOWSYSTEMTABLES (1L<<20) #define BIT_SHOWOIDCOLUMN (1L<<21) #define BIT_FAKEOIDINDEX (1L<<22) #define BIT_TRUEISMINUS1 (1L<<23) #define BIT_BYTEAASLONGVARBINARY (1L<<24) #define BIT_USESERVERSIDEPREPARE (1L<<25) #define BIT_LOWERCASEIDENTIFIER (1L<<26) #define BIT_OPTIONALERRORS (1L<<27) #define BIT_FETCHREFCURSORS (1L<<28) #define EFFECTIVE_BIT_COUNT 28 /* Mask for extra options */ #define BIT_FORCEABBREVCONNSTR 1L #define BIT_FAKE_MSS (1L << 1) #define BIT_BDE_ENVIRONMENT (1L << 2) #define BIT_CVT_NULL_DATE (1L << 3) #define BIT_ACCESSIBLE_ONLY (1L << 4) #define BIT_IGNORE_ROUND_TRIP_TIME (1L << 5) #define BIT_DISABLE_KEEPALIVE (1L << 6) #define BIT_DISABLE_CONVERT_FUNC (1L << 7) /* Connection Defaults */ #define DEFAULT_READONLY 0 #define DEFAULT_PROTOCOL "7.4" /* the latest protocol is * the default */ #define DEFAULT_USEDECLAREFETCH 0 #define DEFAULT_TEXTASLONGVARCHAR 1 #define DEFAULT_UNKNOWNSASLONGVARCHAR 0 #define DEFAULT_BOOLSASCHAR 1 #define DEFAULT_UNIQUEINDEX 1 /* dont recognize */ #define DEFAULT_COMMLOG 0 /* dont log */ #define DEFAULT_DEBUG 0 #define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX #define DEFAULT_FAKEOIDINDEX 0 #define DEFAULT_SHOWOIDCOLUMN 0 #define DEFAULT_ROWVERSIONING 0 #define DEFAULT_SHOWSYSTEMTABLES 0 /* dont show system tables */ #define DEFAULT_LIE 0 #define DEFAULT_PARSE 0 #define DEFAULT_CANCELASFREESTMT 0 #define DEFAULT_EXTRASYSTABLEPREFIXES "" #define DEFAULT_TRUEISMINUS1 0 #define DEFAULT_UPDATABLECURSORS 1 #ifdef WIN32 #define DEFAULT_LFCONVERSION 1 #else #define DEFAULT_LFCONVERSION 0 #endif /* WIN32 */ #define DEFAULT_INT8AS 0 #define DEFAULT_BYTEAASLONGVARBINARY 1 #define DEFAULT_USESERVERSIDEPREPARE 1 #define DEFAULT_LOWERCASEIDENTIFIER 0 #define DEFAULT_SSLMODE SSLMODE_DISABLE #define DEFAULT_NUMERIC_AS (-101) #define DEFAULT_OPTIONAL_ERRORS 0 #define DEFAULT_BATCH_SIZE 100 #define DEFAULT_IGNORETIMEOUT 0 #define DEFAULT_FETCHREFCURSORS 0 #ifdef _HANDLE_ENLIST_IN_DTC_ #define DEFAULT_XAOPT 1 #endif /* _HANDLE_ENLIST_IN_DTC_ */ /* for CC_DSN_info */ #define CONN_DONT_OVERWRITE 0 #define CONN_OVERWRITE 1 /* prototypes */ #ifdef WIN32 void SetDlgStuff(HWND hdlg, const ConnInfo *ci); void GetDlgStuff(HWND hdlg, ConnInfo *ci); LRESULT CALLBACK driver_optionsProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK global_optionsProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ds_options1Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ds_options2Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ds_options3Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK manage_dsnProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); #endif /* WIN32 */ int write_Ci_Drivers(const char *fileName, const char *sectionName, const GLOBAL_VALUES *); int writeDriversDefaults(const char *drivername, const GLOBAL_VALUES *); void writeDSNinfo(const ConnInfo *ci); void getDriversDefaults(const char *drivername, GLOBAL_VALUES *); void getDSNinfo(ConnInfo *ci, const char *configDrvrname); void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD); BOOL get_DSN_or_Driver(ConnInfo *ci, const char *attribute, const char *value); BOOL copyConnAttributes(ConnInfo *ci, const char *attribute, const char *value); int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen); UInt4 getExtraOptions(const ConnInfo *); BOOL setExtraOptions(ConnInfo *, const char *str, const char *format); char *extract_extra_attribute_setting(const pgNAME setting, const char *attr); signed char ci_updatable_cursors_set(ConnInfo *ci); void getCiAllDefaults(ConnInfo *ci); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __DLG_SPECIFIC_H__ */ psqlodbc-REL-16_00_0005/dlg_wingui.c000066400000000000000000000727151462406103600170060ustar00rootroot00000000000000#ifdef WIN32 /*------- * Module: dlg_wingui.c * * Description: This module contains any specific code for handling * dialog boxes such as driver/datasource options. Both the * ConfigDSN() and the SQLDriverConnect() functions use * functions in this module. If you were to add a new option * to any dialog box, you would most likely only have to change * things in here rather than in 2 separate places as before. * * Classes: none * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ /* Multibyte support Eiji Tokuya 2001-03-15 */ #include "dlg_specific.h" #include "misc.h" // strncpy_null #include "win_setup.h" #include "loadlib.h" #include "pgapifunc.h" #ifdef _HANDLE_ENLIST_IN_DTC_ #include "xalibname.h" #include "connexp.h" #endif /* _HANDLE_ENLIST_IN_DTC_ */ extern HINSTANCE s_hModule; static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable); static int driver_options_update(HWND hdlg, ConnInfo *ci); static int ds_options_update(HWND hdlg, ConnInfo *ci); static int ds_options3Draw(HWND, const ConnInfo *); static int ds_options3_update(HWND hdlg, ConnInfo *ci); static struct { int ids; const char * const modestr; } modetab[] = { {IDS_SSLREQUEST_DISABLE, SSLMODE_DISABLE} , {IDS_SSLREQUEST_ALLOW, SSLMODE_ALLOW} , {IDS_SSLREQUEST_PREFER, SSLMODE_PREFER} , {IDS_SSLREQUEST_REQUIRE, SSLMODE_REQUIRE} , {IDS_SSLREQUEST_VERIFY_CA, SSLMODE_VERIFY_CA} , {IDS_SSLREQUEST_VERIFY_FULL, SSLMODE_VERIFY_FULL} }; static int dspcount_bylevel[] = {1, 4, 6}; void SetDlgStuff(HWND hdlg, const ConnInfo *ci) { char buff[MEDIUM_REGISTRY_LEN + 1]; int i, dsplevel, selidx, dspcount; /* * If driver attribute NOT present, then set the datasource name and * description */ SetDlgItemText(hdlg, IDC_DSNAME, ci->dsn); SetDlgItemText(hdlg, IDC_DESC, ci->desc); SetDlgItemText(hdlg, IDC_DATABASE, ci->database); SetDlgItemText(hdlg, IDC_SERVER, ci->server); SetDlgItemText(hdlg, IDC_USER, ci->username); SetDlgItemText(hdlg, IDC_PASSWORD, SAFE_NAME(ci->password)); SetDlgItemText(hdlg, IDC_PORT, ci->port); dsplevel = 0; /* * XXX: We used to hide or show this depending whether libpq was loaded, * but we depend on libpq directly nowadays, so it's always loaded. */ ShowWindow(GetDlgItem(hdlg, IDC_NOTICE_USER), SW_HIDE); dsplevel = 2; selidx = -1; for (i = 0; i < sizeof(modetab) / sizeof(modetab[0]); i++) { if (!stricmp(ci->sslmode, modetab[i].modestr)) { selidx = i; break; } } for (i = dsplevel; i < sizeof(dspcount_bylevel) / sizeof(int); i++) { if (selidx < dspcount_bylevel[i]) break; dsplevel++; } dspcount = dspcount_bylevel[dsplevel]; for (i = 0; i < dspcount; i++) { LoadString(GetWindowInstance(hdlg), modetab[i].ids, buff, MEDIUM_REGISTRY_LEN); SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff); } SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SETCURSEL, selidx, (WPARAM) 0); } void GetDlgStuff(HWND hdlg, ConnInfo *ci) { int sslposition; char medium_buf[MEDIUM_REGISTRY_LEN]; GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc)); GetDlgItemText(hdlg, IDC_DATABASE, ci->database, sizeof(ci->database)); GetDlgItemText(hdlg, IDC_SERVER, ci->server, sizeof(ci->server)); GetDlgItemText(hdlg, IDC_USER, ci->username, sizeof(ci->username)); GetDlgItemText(hdlg, IDC_PASSWORD, medium_buf, sizeof(medium_buf)); STR_TO_NAME(ci->password, medium_buf); GetDlgItemText(hdlg, IDC_PORT, ci->port, sizeof(ci->port)); sslposition = (int)(DWORD)SendMessage(GetDlgItem(hdlg, IDC_SSLMODE), CB_GETCURSEL, 0L, 0L); STRCPY_FIXED(ci->sslmode, modetab[sslposition].modestr); } static void getDriversDefaultsOfCi(const ConnInfo *ci, GLOBAL_VALUES *glbv) { const char *drivername = NULL; if (ci->drivername[0]) drivername = ci->drivername; else if (NAME_IS_VALID(ci->drivers.drivername)) drivername = SAFE_NAME(ci->drivers.drivername); if (drivername && drivername[0]) getDriversDefaults(drivername, glbv); else getDriversDefaults(INVALID_DRIVER, glbv); } static int driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable) { const GLOBAL_VALUES *comval = NULL; const char * drivername = NULL; GLOBAL_VALUES defval; MYLOG(0, "entering src=%d\n", src); init_globals(&defval); switch (src) { case 0: /* default */ getDriversDefaultsOfCi(ci, &defval); defval.debug = DEFAULT_DEBUG; defval.commlog = DEFAULT_COMMLOG; comval = &defval; break; case 1: /* dsn specific */ comval = &(ci->drivers); break; default: return 0; } ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL2), enable ? SW_SHOW : SW_HIDE); CheckDlgButton(hdlg, DRV_COMMLOG, comval->commlog > 0); SetDlgItemInt(hdlg, DS_COMMLOG, comval->commlog, FALSE); ShowWindow(GetDlgItem(hdlg, DS_COMMLOG), comval->commlog > 0 ? SW_SHOW : SW_HIDE); CheckDlgButton(hdlg, DRV_UNIQUEINDEX, comval->unique_index); /* EnableWindow(GetDlgItem(hdlg, DRV_UNIQUEINDEX), enable); */ EnableWindow(GetDlgItem(hdlg, DRV_READONLY), FALSE); CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, comval->use_declarefetch); /* Unknown Sizes clear */ CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 0); CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 0); CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 0); /* Unknown (Default) Data Type sizes */ switch (comval->unknown_sizes) { case UNKNOWNS_AS_DONTKNOW: CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1); break; case UNKNOWNS_AS_LONGEST: CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1); break; case UNKNOWNS_AS_MAX: default: CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1); break; } CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, comval->text_as_longvarchar); CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, comval->unknowns_as_longvarchar); CheckDlgButton(hdlg, DRV_BOOLS_CHAR, comval->bools_as_char); CheckDlgButton(hdlg, DRV_PARSE, comval->parse); CheckDlgButton(hdlg, DRV_DEBUG, comval->debug > 0); SetDlgItemInt(hdlg, DS_DEBUG, comval->debug, FALSE); ShowWindow(GetDlgItem(hdlg, DS_DEBUG), comval->debug > 0 ? SW_SHOW : SW_HIDE); SetDlgItemInt(hdlg, DRV_CACHE_SIZE, comval->fetch_max, FALSE); SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, comval->max_varchar_size, FALSE); SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, comval->max_longvarchar_size, TRUE); SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes); switch (src) { case 1: ShowWindow(GetDlgItem(hdlg, DS_BATCH_SIZE), SW_SHOW); ShowWindow(GetDlgItem(hdlg, DS_IGNORETIMEOUT), SW_SHOW); SetDlgItemInt(hdlg, DS_BATCH_SIZE, ci->batch_size, FALSE); CheckDlgButton(hdlg, DS_IGNORETIMEOUT, ci->ignore_timeout); break; default: ShowWindow(GetDlgItem(hdlg, DS_BATCH_SIZE), SW_HIDE); ShowWindow(GetDlgItem(hdlg, DS_IGNORETIMEOUT), SW_HIDE); break; } /* Driver Connection Settings */ EnableWindow(GetDlgItem(hdlg, DRV_CONNSETTINGS), FALSE); ShowWindow(GetDlgItem(hdlg, ID2NDPAGE), enable ? SW_HIDE : SW_SHOW); ShowWindow(GetDlgItem(hdlg, ID3RDPAGE), enable ? SW_HIDE : SW_SHOW); finalize_globals(&defval); return 0; } #define INIT_DISP_LOGVAL 2 static int driver_options_update(HWND hdlg, ConnInfo *ci) { GLOBAL_VALUES *comval; BOOL bTranslated; MYLOG(3, "entering\n"); comval = &(ci->drivers); (comval->commlog = GetDlgItemInt(hdlg, DS_COMMLOG, &bTranslated, FALSE)) || bTranslated || (comval->commlog = INIT_DISP_LOGVAL); comval->unique_index = IsDlgButtonChecked(hdlg, DRV_UNIQUEINDEX); comval->use_declarefetch = IsDlgButtonChecked(hdlg, DRV_USEDECLAREFETCH); /* Unknown (Default) Data Type sizes */ if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_MAX)) comval->unknown_sizes = UNKNOWNS_AS_MAX; else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_DONTKNOW)) comval->unknown_sizes = UNKNOWNS_AS_DONTKNOW; else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_LONGEST)) comval->unknown_sizes = UNKNOWNS_AS_LONGEST; else comval->unknown_sizes = UNKNOWNS_AS_MAX; comval->text_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_TEXT_LONGVARCHAR); comval->unknowns_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_UNKNOWNS_LONGVARCHAR); comval->bools_as_char = IsDlgButtonChecked(hdlg, DRV_BOOLS_CHAR); comval->parse = IsDlgButtonChecked(hdlg, DRV_PARSE); (comval->debug = GetDlgItemInt(hdlg, DS_DEBUG, &bTranslated, FALSE)) || bTranslated || (comval->debug = INIT_DISP_LOGVAL); comval->fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE); comval->max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE); comval->max_longvarchar_size = GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for * SQL_NO_TOTAL */ GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, sizeof(comval->extra_systable_prefixes)); ci->batch_size = GetDlgItemInt(hdlg, DS_BATCH_SIZE, NULL, FALSE); ci->ignore_timeout = IsDlgButtonChecked(hdlg, DS_IGNORETIMEOUT); /* fall through */ return 0; } #ifdef _HANDLE_ENLIST_IN_DTC_ static HMODULE DtcProc(const char *procname, FARPROC *proc) { HMODULE hmodule; *proc = NULL; if (hmodule = LoadLibraryEx(GetXaLibPath(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH), NULL != hmodule) { MYLOG(0, "GetProcAddress for %s\n", procname); *proc = GetProcAddress(hmodule, procname); } return hmodule; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ #include static const char *IsAnExistingDirectory(const char *path) { struct stat st; if (stat(path, &st) < 0) { CSTR errmsg_doesnt_exist = "doesn't exist"; return errmsg_doesnt_exist; } if ((st.st_mode & S_IFDIR) == 0) { CSTR errmsg_isnt_a_dir = "isn't a directory"; return errmsg_isnt_a_dir; } return NULL; } LRESULT CALLBACK global_optionsProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { #ifdef _HANDLE_ENLIST_IN_DTC_ HMODULE hmodule; FARPROC proc; #endif /* _HANDLE_ENLIST_IN_DTC_ */ ConnInfo *ci; char logdir[PATH_MAX]; const char *logmsg; GLOBAL_VALUES defval; // if (WM_INITDIALOG == wMsg || WM_COMMAND == wMsg) // MYLOG(0, "entering wMsg=%d\n", wMsg); init_globals(&defval); switch (wMsg) { case WM_INITDIALOG: SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for test etc */ ci = (ConnInfo *) lParam; getDriversDefaultsOfCi(ci, &defval); CheckDlgButton(hdlg, DRV_COMMLOG, getGlobalCommlog()); CheckDlgButton(hdlg, DRV_DEBUG, getGlobalDebug()); getLogDir(logdir, sizeof(logdir)); SetDlgItemText(hdlg, DS_LOGDIR, logdir); #ifdef _HANDLE_ENLIST_IN_DTC_ hmodule = DtcProc("GetMsdtclog", &proc); if (proc) { INT_PTR res = (*proc)(); CheckDlgButton(hdlg, DRV_DTCLOG, 0 != res); } else EnableWindow(GetDlgItem(hdlg, DRV_DTCLOG), FALSE); if (hmodule) FreeLibrary(hmodule); #else ShowWindow(GetDlgItem(hdlg, DRV_DTCLOG), SW_HIDE); #endif /* _HANDLE_ENLIST_IN_DTC_ */ break; case WM_COMMAND: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: getDriversDefaultsOfCi(ci, &defval); GetDlgItemText(hdlg, DS_LOGDIR, logdir, sizeof(logdir)); if (logdir[0] && (logmsg = IsAnExistingDirectory(logdir)) != NULL) { MessageBox(hdlg, "Folder for logging error", logmsg, MB_ICONEXCLAMATION | MB_OK); break; } setGlobalCommlog(IsDlgButtonChecked(hdlg, DRV_COMMLOG)); setGlobalDebug(IsDlgButtonChecked(hdlg, DRV_DEBUG)); writeGlobalLogs(); if (writeDriversDefaults(ci->drivername, &defval) < 0) MessageBox(hdlg, "Sorry, impossible to update the values\nWrite permission seems to be needed", "Update Error", MB_ICONEXCLAMATION | MB_OK); setLogDir(logdir[0] ? logdir : NULL); #ifdef _HANDLE_ENLIST_IN_DTC_ hmodule = DtcProc("SetMsdtclog", &proc); if (proc) (*proc)(IsDlgButtonChecked(hdlg, DRV_DTCLOG)); if (hmodule) FreeLibrary(hmodule); #endif /* _HANDLE_ENLIST_IN_DTC_ */ case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); return TRUE; } } finalize_globals(&defval); return FALSE; } static void CtrlCheckButton(HWND hdlg, int nIDcheck, int nIDint) { BOOL bTranslated; switch (Button_GetCheck(GetDlgItem(hdlg, nIDcheck))) { case BST_CHECKED: if (!GetDlgItemInt(hdlg, nIDint, &bTranslated, FALSE)) { ShowWindow(GetDlgItem(hdlg, nIDint), SW_SHOW); if (bTranslated) SetDlgItemInt(hdlg, nIDint, INIT_DISP_LOGVAL, FALSE); } break; case BST_UNCHECKED: if (GetDlgItemInt(hdlg, nIDint, &bTranslated, FALSE)) { ShowWindow(GetDlgItem(hdlg, nIDint), SW_HIDE); SetDlgItemInt(hdlg, nIDint, 0, FALSE); } break; } } LRESULT CALLBACK ds_options1Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { ConnInfo *ci; char strbuf[128]; // if (WM_INITDIALOG == wMsg || WM_COMMAND == wMsg) // MYLOG(0, "entering wMsg=%d in\n", wMsg); switch (wMsg) { case WM_INITDIALOG: SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK etc */ ci = (ConnInfo *) lParam; if (ci && ci->dsn && ci->dsn[0]) { DWORD cmd; char fbuf[64]; cmd = LoadString(s_hModule, IDS_ADVANCE_OPTION_DSN1, fbuf, sizeof(fbuf)); if (cmd <= 0) STRCPY_FIXED(fbuf, "Advanced Options (%s) 1/3"); SPRINTF_FIXED(strbuf, fbuf, ci->dsn); SetWindowText(hdlg, strbuf); } else { LoadString(s_hModule, IDS_ADVANCE_OPTION_CON1, strbuf, sizeof(strbuf)); SetWindowText(hdlg, strbuf); ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); } driver_optionsDraw(hdlg, ci, 1, FALSE); break; case WM_COMMAND: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: driver_options_update(hdlg, ci); case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); return TRUE; case IDAPPLY: driver_options_update(hdlg, ci); SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam); break; case IDDEFAULTS: driver_optionsDraw(hdlg, ci, 0, FALSE); break; case ID2NDPAGE: driver_options_update(hdlg, ci); EndDialog(hdlg, FALSE); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS), hdlg, ds_options2Proc, (LPARAM) ci); break; case ID3RDPAGE: driver_options_update(hdlg, ci); EndDialog(hdlg, FALSE); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS3), hdlg, ds_options3Proc, (LPARAM) ci); break; case DRV_COMMLOG: case DS_COMMLOG: CtrlCheckButton(hdlg, DRV_COMMLOG, DS_COMMLOG); break; case DRV_DEBUG: case DS_DEBUG: CtrlCheckButton(hdlg, DRV_DEBUG, DS_DEBUG); break; } } return FALSE; } static int ds_options_update(HWND hdlg, ConnInfo *ci) { char buf[128]; MYLOG(0, "entering got ci=%p\n", ci); /* ExtraOptions */ GetDlgItemText(hdlg, DS_EXTRA_OPTIONS, buf, sizeof(buf)); if (!setExtraOptions(ci, buf, NULL)) { MessageBox(hdlg, "ExtraOptions must be hex, decimal or octal", "Format error", MB_ICONEXCLAMATION | MB_OK); return 1; } /* Readonly */ ITOA_FIXED(ci->onlyread, IsDlgButtonChecked(hdlg, DS_READONLY)); /* Issue rollback command on error */ if (IsDlgButtonChecked(hdlg, DS_NO_ROLLBACK)) ci->rollback_on_error = 0; else if (IsDlgButtonChecked(hdlg, DS_TRANSACTION_ROLLBACK)) ci->rollback_on_error = 1; else if (IsDlgButtonChecked(hdlg, DS_STATEMENT_ROLLBACK)) ci->rollback_on_error = 2; else /* no button is checked */ ci->rollback_on_error = -1; /* Int8 As */ if (IsDlgButtonChecked(hdlg, DS_INT8_AS_DEFAULT)) ci->int8_as = 0; else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_BIGINT)) ci->int8_as = SQL_BIGINT; else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_NUMERIC)) ci->int8_as = SQL_NUMERIC; else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_DOUBLE)) ci->int8_as = SQL_DOUBLE; else if (IsDlgButtonChecked(hdlg, DS_INT8_AS_INT4)) ci->int8_as = SQL_INTEGER; else ci->int8_as = SQL_VARCHAR; /* Numeric without precision As */ if (IsDlgButtonChecked(hdlg, DS_NUMERIC_AS_NUMERIC)) ci->numeric_as = SQL_NUMERIC; else if (IsDlgButtonChecked(hdlg, DS_NUMERIC_AS_DOUBLE)) ci->numeric_as = SQL_DOUBLE; else if (IsDlgButtonChecked(hdlg, DS_NUMERIC_AS_VARCHAR)) ci->numeric_as = SQL_VARCHAR; else if (IsDlgButtonChecked(hdlg, DS_NUMERIC_AS_LONGVARCHAR)) ci->numeric_as = SQL_LONGVARCHAR; else ci->numeric_as = DEFAULT_NUMERIC_AS; ITOA_FIXED(ci->show_system_tables, IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES)); ITOA_FIXED(ci->row_versioning, IsDlgButtonChecked(hdlg, DS_ROWVERSIONING)); ci->lf_conversion = IsDlgButtonChecked(hdlg, DS_LFCONVERSION); ci->optional_errors = IsDlgButtonChecked(hdlg, DS_OPTIONALERRORS); ci->true_is_minus1 = IsDlgButtonChecked(hdlg, DS_TRUEISMINUS1); ci->allow_keyset = IsDlgButtonChecked(hdlg, DS_UPDATABLECURSORS); ci->use_server_side_prepare = IsDlgButtonChecked(hdlg, DS_SERVERSIDEPREPARE); ci->bytea_as_longvarbinary = IsDlgButtonChecked(hdlg, DS_BYTEAASLONGVARBINARY); ci->fetch_refcursors = IsDlgButtonChecked(hdlg, DS_FETCH_REFCURSORS); /*ci->lower_case_identifier = IsDlgButtonChecked(hdlg, DS_LOWERCASEIDENTIFIER);*/ /* OID Options */ ITOA_FIXED(ci->fake_oid_index, IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX)); ITOA_FIXED(ci->show_oid_column, IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN)); /* Datasource Connection Settings */ { char conn_settings[LARGE_REGISTRY_LEN]; GetDlgItemText(hdlg, DS_CONNSETTINGS, conn_settings, sizeof(conn_settings)); if ('\0' != conn_settings[0]) STR_TO_NAME(ci->conn_settings, conn_settings); } /* TCP KEEPALIVE */ ci->disable_keepalive = IsDlgButtonChecked(hdlg, DS_DISABLE_KEEPALIVE); ci->extra_opts = getExtraOptions(ci); if (ci->disable_keepalive) { ci->keepalive_idle = -1; ci->keepalive_interval = -1; } else { char temp[64]; int val; GetDlgItemText(hdlg, DS_KEEPALIVETIME, temp, sizeof(temp)); if (val = atoi(temp), 0 == val) val = -1; ci->keepalive_idle = val; GetDlgItemText(hdlg, DS_KEEPALIVEINTERVAL, temp, sizeof(temp)); if (val = atoi(temp), 0 == val) val = -1; ci->keepalive_interval = val; } return 0; } LRESULT CALLBACK ds_options2Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { ConnInfo *ci; char buf[128]; DWORD cmd; BOOL enable; // if (WM_INITDIALOG == wMsg || WM_COMMAND == wMsg) // MYLOG(0, "entering wMsg=%d in\n", wMsg); switch (wMsg) { case WM_INITDIALOG: ci = (ConnInfo *) lParam; SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK */ /* Change window caption */ if (ci && ci->dsn && ci->dsn[0]) { char fbuf[64]; cmd = LoadString(s_hModule, IDS_ADVANCE_OPTION_DSN2, fbuf, sizeof(fbuf)); if (cmd <= 0) STRCPY_FIXED(fbuf, "Advanced Options (%s) 2/3"); SPRINTF_FIXED(buf, fbuf, ci->dsn); SetWindowText(hdlg, buf); } else { LoadString(s_hModule, IDS_ADVANCE_OPTION_CON2, buf, sizeof(buf)); SetWindowText(hdlg, buf); ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); } /* Readonly */ CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread)); /* Protocol */ enable = (ci->sslmode[0] == SSLLBYTE_DISABLE || ci->username[0] == '\0'); /* How to issue Rollback */ switch (ci->rollback_on_error) { case 0: CheckDlgButton(hdlg, DS_NO_ROLLBACK, 1); break; case 1: CheckDlgButton(hdlg, DS_TRANSACTION_ROLLBACK, 1); break; case 2: CheckDlgButton(hdlg, DS_STATEMENT_ROLLBACK, 1); break; } /* Int8 As */ switch (ci->int8_as) { case SQL_BIGINT: CheckDlgButton(hdlg, DS_INT8_AS_BIGINT, 1); break; case SQL_NUMERIC: CheckDlgButton(hdlg, DS_INT8_AS_NUMERIC, 1); break; case SQL_VARCHAR: CheckDlgButton(hdlg, DS_INT8_AS_VARCHAR, 1); break; case SQL_DOUBLE: CheckDlgButton(hdlg, DS_INT8_AS_DOUBLE, 1); break; case SQL_INTEGER: CheckDlgButton(hdlg, DS_INT8_AS_INT4, 1); break; default: CheckDlgButton(hdlg, DS_INT8_AS_DEFAULT, 1); } /* Numeric As */ switch (ci->numeric_as) { case SQL_NUMERIC: CheckDlgButton(hdlg, DS_NUMERIC_AS_NUMERIC, 1); break; case SQL_VARCHAR: CheckDlgButton(hdlg, DS_NUMERIC_AS_VARCHAR, 1); break; case SQL_DOUBLE: CheckDlgButton(hdlg, DS_NUMERIC_AS_DOUBLE, 1); break; case SQL_LONGVARCHAR: CheckDlgButton(hdlg, DS_NUMERIC_AS_LONGVARCHAR, 1); break; default: CheckDlgButton(hdlg, DS_NUMERIC_AS_DEFAULT, 1); } SPRINTF_FIXED(buf, "0x%x", getExtraOptions(ci)); SetDlgItemText(hdlg, DS_EXTRA_OPTIONS, buf); CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column)); CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index)); CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning)); CheckDlgButton(hdlg, DS_SHOWSYSTEMTABLES, atoi(ci->show_system_tables)); CheckDlgButton(hdlg, DS_LFCONVERSION, ci->lf_conversion); CheckDlgButton(hdlg, DS_OPTIONALERRORS, ci->optional_errors); CheckDlgButton(hdlg, DS_TRUEISMINUS1, ci->true_is_minus1); CheckDlgButton(hdlg, DS_UPDATABLECURSORS, ci->allow_keyset); CheckDlgButton(hdlg, DS_SERVERSIDEPREPARE, ci->use_server_side_prepare); CheckDlgButton(hdlg, DS_BYTEAASLONGVARBINARY, ci->bytea_as_longvarbinary); CheckDlgButton(hdlg, DS_FETCH_REFCURSORS, ci->fetch_refcursors); /*CheckDlgButton(hdlg, DS_LOWERCASEIDENTIFIER, ci->lower_case_identifier);*/ EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column)); /* Datasource Connection Settings */ SetDlgItemText(hdlg, DS_CONNSETTINGS, SAFE_NAME(ci->conn_settings)); /* KEEPALIVE */ enable = (0 == (ci->extra_opts & BIT_DISABLE_KEEPALIVE)); CheckDlgButton(hdlg, DS_DISABLE_KEEPALIVE, !enable); if (enable) { if (ci->keepalive_idle > 0) { ITOA_FIXED(buf, ci->keepalive_idle); SetDlgItemText(hdlg, DS_KEEPALIVETIME, buf); } if (ci->keepalive_interval > 0) { ITOA_FIXED(buf, ci->keepalive_interval); SetDlgItemText(hdlg, DS_KEEPALIVEINTERVAL, buf); } } break; case WM_COMMAND: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); switch (cmd = GET_WM_COMMAND_ID(wParam, lParam)) { case DS_SHOWOIDCOLUMN: MYLOG(0, "WM_COMMAND: DS_SHOWOIDCOLUMN\n"); EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN)); return TRUE; case DS_DISABLE_KEEPALIVE: MYLOG(0, "WM_COMMAND: DS_SHOWOIDCOLUMN\n"); EnableWindow(GetDlgItem(hdlg, DS_KEEPALIVETIME), !IsDlgButtonChecked(hdlg, cmd)); EnableWindow(GetDlgItem(hdlg, DS_KEEPALIVEINTERVAL), !IsDlgButtonChecked(hdlg, cmd)); return TRUE; case IDOK: ds_options_update(hdlg, ci); case IDCANCEL: EndDialog(hdlg, IDOK == cmd); return TRUE; case IDAPPLY: ds_options_update(hdlg, ci); SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam); break; case ID1STPAGE: ds_options_update(hdlg, ci); EndDialog(hdlg, cmd == IDOK); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), hdlg, ds_options1Proc, (LPARAM) ci); break; case ID3RDPAGE: ds_options_update(hdlg, ci); EndDialog(hdlg, cmd == IDOK); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS3), hdlg, ds_options3Proc, (LPARAM) ci); break; } } return FALSE; } static int ds_options3Draw(HWND hdlg, const ConnInfo *ci) { BOOL enable = TRUE; static BOOL defset = FALSE; MYLOG(0, "entering\n"); #ifdef _HANDLE_ENLIST_IN_DTC_ switch (ci->xa_opt) { case 0: enable = FALSE; break; case DTC_CHECK_LINK_ONLY: CheckDlgButton(hdlg, DS_DTC_LINK_ONLY, 1); break; case DTC_CHECK_BEFORE_LINK: CheckDlgButton(hdlg, DS_DTC_SIMPLE_PRECHECK, 1); break; case DTC_CHECK_RM_CONNECTION: CheckDlgButton(hdlg, DS_DTC_CONFIRM_RM_CONNECTION, 1); break; } #else enable = FALSE; #endif /* _HANDLE_ENLIST_IN_DTC_ */ if (!enable) { EnableWindow(GetDlgItem(hdlg, DS_DTC_LINK_ONLY), enable); EnableWindow(GetDlgItem(hdlg, DS_DTC_SIMPLE_PRECHECK), enable); EnableWindow(GetDlgItem(hdlg, DS_DTC_CONFIRM_RM_CONNECTION), enable); } /* Datasource libpq parameters */ SetDlgItemText(hdlg, DS_LIBPQOPT, SAFE_NAME(ci->pqopt)); return 0; } void *PQconninfoParse(const char *, char **); void PQconninfoFree(void *); typedef void *(*PQCONNINFOPARSEPROC)(const char *, char **); typedef void (*PQCONNINFOFREEPROC)(void *); static int ds_options3_update(HWND hdlg, ConnInfo *ci) { void *connOpt = NULL; char *ermsg = NULL; char pqopt[LARGE_REGISTRY_LEN]; HMODULE hmodule; PQCONNINFOPARSEPROC pproc = NULL; PQCONNINFOFREEPROC fproc = NULL; MYLOG(0, "entering got ci=%p\n", ci); /* Datasource libpq parameters */ GetDlgItemText(hdlg, DS_LIBPQOPT, pqopt, sizeof(pqopt)); if (hmodule = LoadLibraryEx("libpq.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH), NULL != hmodule) { pproc = (PQCONNINFOPARSEPROC) GetProcAddress(hmodule, "PQconninfoParse"); if (NULL != pproc && NULL == (connOpt= (*pproc)(pqopt, &ermsg))) { const char *logmsg = "libpq parameter error"; MessageBox(hdlg, ermsg ? ermsg : "memory over?", logmsg, MB_ICONEXCLAMATION | MB_OK); if (NULL != ermsg) free(ermsg); FreeLibrary(hmodule); return 1; } fproc = (PQCONNINFOFREEPROC) GetProcAddress(hmodule, "PQconninfoFree"); if (fproc) (*fproc)(connOpt); FreeLibrary(hmodule); } STR_TO_NAME(ci->pqopt, pqopt); #ifdef _HANDLE_ENLIST_IN_DTC_ if (IsDlgButtonChecked(hdlg, DS_DTC_LINK_ONLY)) ci->xa_opt = DTC_CHECK_LINK_ONLY; else if (IsDlgButtonChecked(hdlg, DS_DTC_SIMPLE_PRECHECK)) ci->xa_opt = DTC_CHECK_BEFORE_LINK; else if (IsDlgButtonChecked(hdlg, DS_DTC_CONFIRM_RM_CONNECTION)) ci->xa_opt = DTC_CHECK_RM_CONNECTION; else ci->xa_opt = 0; #endif /* _HANDLE_ENLIST_IN_DTC_ */ return 0; } LRESULT CALLBACK ds_options3Proc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { ConnInfo *ci, tmpInfo; char buf[128]; DWORD cmd; if (WM_INITDIALOG == wMsg || WM_COMMAND == wMsg) MYLOG(0, "entering wMsg=%d\n", wMsg); switch (wMsg) { case WM_INITDIALOG: ci = (ConnInfo *) lParam; SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for OK */ /* Change window caption */ if (ci && ci->dsn && ci->dsn[0]) { char fbuf[64]; cmd = LoadString(s_hModule, IDS_ADVANCE_OPTION_DSN3, fbuf, sizeof(fbuf)); if (cmd <= 0) STRCPY_FIXED(fbuf, "Advanced Options (%s) 3/3"); SPRINTF_FIXED(buf, fbuf, ci->dsn); SetWindowText(hdlg, buf); } else { LoadString(s_hModule, IDS_ADVANCE_OPTION_CON3, buf, sizeof(buf)); SetWindowText(hdlg, buf); ShowWindow(GetDlgItem(hdlg, IDAPPLY), SW_HIDE); } ds_options3Draw(hdlg, ci); break; case WM_COMMAND: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); switch (cmd = GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: ds_options3_update(hdlg, ci); case IDCANCEL: EndDialog(hdlg, IDOK == cmd); return TRUE; case IDAPPLY: ds_options3_update(hdlg, ci); SendMessage(GetWindow(hdlg, GW_OWNER), WM_COMMAND, wParam, lParam); break; case IDC_TEST: CC_copy_conninfo(&tmpInfo, ci); ds_options3_update(hdlg, &tmpInfo); test_connection(hdlg, &tmpInfo, TRUE); CC_conninfo_release(&tmpInfo); break; case ID1STPAGE: ds_options3_update(hdlg, ci); EndDialog(hdlg, cmd == IDOK); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), hdlg, ds_options1Proc, (LPARAM) ci); break; case ID2NDPAGE: ds_options3_update(hdlg, ci); EndDialog(hdlg, cmd == IDOK); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS), hdlg, ds_options2Proc, (LPARAM) ci); break; } } return FALSE; } typedef SQLRETURN (SQL_API *SQLAPIPROC)(); static int makeDriversList(HWND lwnd, const ConnInfo *ci) { HMODULE hmodule; SQLHENV henv; int lcount = 0; LRESULT iidx; char drvname[64], drvatt[128]; SQLUSMALLINT direction = SQL_FETCH_FIRST; SQLSMALLINT drvncount, drvacount; SQLRETURN ret; SQLAPIPROC addr; hmodule = GetModuleHandle("ODBC32"); if (!hmodule) return lcount; addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLAllocEnv"); if (!addr) return lcount; ret = (*addr)(&henv); if (SQL_SUCCESS != ret) return lcount; do { ret = SQLDrivers(henv, direction, drvname, sizeof(drvname), &drvncount, drvatt, sizeof(drvatt), &drvacount); if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret) break; if (strnicmp(drvname, "postgresql", 10) == 0) { iidx = SendMessage(lwnd, LB_ADDSTRING, 0, (LPARAM) drvname); if (LB_ERR != iidx && stricmp(drvname, ci->drivername) == 0) { SendMessage(lwnd, LB_SETCURSEL, (WPARAM) iidx, (LPARAM) 0); } lcount++; } direction = SQL_FETCH_NEXT; } while (1); addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLFreeEnv"); if (addr) (*addr)(henv); return lcount; } LRESULT CALLBACK manage_dsnProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { LPSETUPDLG lpsetupdlg; ConnInfo *ci; HWND lwnd; LRESULT sidx; char drvname[64]; switch (wMsg) { case WM_INITDIALOG: SetWindowLongPtr(hdlg, DWLP_USER, lParam); lpsetupdlg = (LPSETUPDLG) lParam; ci = &lpsetupdlg->ci; lwnd = GetDlgItem(hdlg, IDC_DRIVER_LIST); makeDriversList(lwnd, ci); break; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER); lwnd = GetDlgItem(hdlg, IDC_DRIVER_LIST); sidx = SendMessage(lwnd, LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); if (LB_ERR == sidx) return FALSE; sidx = SendMessage(lwnd, LB_GETTEXT, (WPARAM) sidx, (LPARAM) drvname); if (LB_ERR == sidx) return FALSE; ChangeDriverName(hdlg, lpsetupdlg, drvname); case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); return TRUE; } } return FALSE; } #endif /* WIN32 */ psqlodbc-REL-16_00_0005/docs/000077500000000000000000000000001462406103600154265ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/docs/README.txt000066400000000000000000000003331462406103600171230ustar00rootroot00000000000000This directory contains documentation specific to this version. More general documentation about the psqlODBC project, and on how to use the driver is available at the psqlODBC website, at https://odbc.postgresql.org/. psqlodbc-REL-16_00_0005/docs/config-opt.html000066400000000000000000000161441462406103600203670ustar00rootroot00000000000000 How to specify as a connection option

How to specify as a connection option

Definition Keyword Abbreviation
Data source description Description Nothing
Name of Server Servername Nothing
Postmaster listening port Port Nothing
User Name Username Nothing
Password Password Nothing
Debug flag Debug B2
Fetch Max Count Fetch A7
Socket buffer size Socket A8
Database is read only ReadOnly A0
Communication to backend logging CommLog B3
PostgreSQL backend protocol Protocol A1
Connect Settings (commands sent to backend on connection) ConnSettings A6
Recognize unique indexes UniqueIndex Nothing
Unknown result set sizes UnknownSizes A9
Use Declare/Fetch cursors UseDeclareFetch B6
Text as LongVarchar TextAsLongVarchar B7
Unknowns as LongVarchar UnknownsAsLongVarchar B8
Bools as Char BoolsAsChar B9
Max Varchar size MaxVarcharSize B0
Max LongVarchar size MaxLongVarcharSize B1
Fakes a unique index on OID FakeOidIndex A2
Includes the OID in SQLColumns ShowOidColumn A3
Row Versioning RowVersioning A4
Show SystemTables ShowSystemTables A5
Parse Statements Parse C0
SysTable Prefixes ExtraSysTablePrefixes C2
Updateable Cursors UpdatableCursors C4
LF <-> CR/LF conversion LFConversion C5
True is -1 TrueIsMinus1 C6
Datatype to report int8 columns as BI Nothing
Bytea as LO (longVarBinary) ByteaAsLongVarBinary C7
Use serverside prepare UseServerSidePrepare C8
Lower case identifier LowerCaseIdentifier C9
SSL mode SSLmode CA
Extra options AB Nothing
Abbreviate(simple setup of a recommendation value) CX Nothing
TCP KEEPALIVE setting: idle time KeepaliveTime D1
TCP KEEPALIVE setting: interval KeepaliveInterval D2
Libpq parameters (a conninfo style string e.g. pqopt={sslcert=~/mycert sslkey=~/mykey} enclosed with braces in the case of connection strings) Pqopt D5
Numeric As: specify the map from numeric items without precision to SQL data types. 2(SQL_NUMERIC default), 8(SQL_DOUBLE), 12(SQL_VARCHAR) or -1(SQL_LONGVARCHAR) can be specified. NumericAS D6
Show optional error messages. OptionalErrors D7
Chunk size when executing batches for parameterized SQL statements with arrays of parameters. BatchSize D8
Ignore SQL_ATTR_QUERY_TIMEOUT set using SQLSetStmtAttr(). IgnoreTimeout D9



psqlodbc-REL-16_00_0005/docs/config.html000066400000000000000000000330771462406103600175730ustar00rootroot00000000000000 psqlODBC Configuration Options

psqlODBC Configuration Options

Advanced Options 1/3 Dialog Box

  • DEFAULTS: Press to this button restore the normal defaults for the settings described below.
     
  • Recognize Unique Indexes: Check this option.
     
  • Use Declare/Fetch: If true, the driver automatically uses declare cursor/fetch to handle SELECT statements and keeps 100 rows in a cache. This is mostly a great advantage, especially if you are only interested in reading and not updating. It results in the driver not sucking down lots of memory to buffer the entire result set. If set to false, cursors will not be used and the driver will retrieve the entire result set. For very large tables, this is very inefficient and may use up all the Windows memory/resources. However, it may handle updates better since the tables are not kept open, as they are when using cursors. This was the style of the old podbc32 driver. However, the behavior of the memory allocation is much improved so even when not using cursors, performance should at least be better than the old podbc32.
     
  • CommLog (C:\psqlodbc_xxxx.log): Log communications to/from the backend to that file. This is good for debugging problems.
     
  • Parse Statements: Tell the driver how to gather the information about result columns of queries, if the application requests that information before executing the query. See also ServerSide Prepare options.
    The driver checks this option first. If disabled then it checks the Server Side Prepare option.

    If this option is enabled, the driver will parse an SQL query statement to identify the columns and tables and gather statistics about them such as precision, nullability, aliases, etc. It then reports this information in SQLDescribeCol, SQLColAttributes, and SQLNumResultCols.

    When this option is disabled (the default), the query is sent to the server to be parsed and described. If the parser can not deal with a column (because it is a function or expression, etc.), it will fall back to describing the statement in the server. The parser is fairly sophisticated and can handle many things such as column and table aliases, quoted identifiers, literals, joins, cross-products, etc. It can correctly identify a function or expression column, regardless of the complexity, but it does not attempt to determine the data type or precision of these columns.
     
  • Ignore Timeout: Ignore SQL_ATTR_QUERY_TIMEOUT set using SQLSetStmtAttr(). Some tools issue SQLSetStmtAttr(.., SQL_ATTR_QUERY_TIMEOUT, ...) internally and sometimes it's difficult for users to change the value.
     
  • MyLog (C:\mylog_xxxx.log): Log debug messages to that file. This is good for debugging problems with the driver.
     
  • Unknown Sizes: This controls what SQLDescribeCol and SQLColAttributes will return as to precision for character data types (varchar, text, and unknown) in a result set when the precision is unknown. This was more of a workaround for pre-6.4 versions of PostgreSQL not being able to return the defined column width of the varchar data type.

    • Maximum: Always return the maximum precision of the data type.
    • Dont Know: Return "Don't Know" value and let application decide.
    • Longest: Return the longest string length of the column of any row. Beware of this setting when using cursors because the cache size may not be a good representation of the longest column in the cache.

    • MS Access: Seems to handle Maximum setting ok, as well as all the others.
      Borland: If sizes are large and lots of columns, Borland may crash badly (it doesn't seem to handle memory allocation well) if using Maximum size.

  • Data Type Options: affects how some data types are mapped:
     
    • Text as LongVarChar: PostgreSQL TEXT type is mapped to SQLLongVarchar, otherwise SQLVarchar.
    • Unknowns as LongVarChar: Unknown types (arrays, etc) are mapped to SQLLongVarChar, otherwise SQLVarchar
    • Bools as Char: Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.

  • Max Varchar The maximum precision of the Varchar and BPChar(char[x]) types. The default is 254 which actually means 255 because of the null terminator. Note, if you set this value higher than 254, Access will not let you index on varchar columns!
     
  • Cache Size:When using cursors, this is the row size of the tuple cache and the default is 100 rows. If not using cursors, this has no meaning.
     
  • Max LongVarChar: The maximum precision of the LongVarChar type. The default is 4094 which actually means 4095 with the null terminator. You can even specify (-4) for this size, which is the odbc SQL_NO_TOTAL value.
     
  • SysTable Prefixes: Additional prefixes of table names to regard as System Tables. Tables that begin with "pg_" are always treated as system tables, even without this option. Separate each prefix with a semicolon (;)
     
  • Batch Size:Chunk size when executing batches with arrays of parameters. Setting 1 to this option forces one by one execution (the behavior before).
     

Advanced Options 2/3 Dialog Box

  • ReadOnly: Whether the datasource will allow updates.
     
  • Show System Tables: The driver will treat system tables as regular tables in SQLTables. This is good for Access so you can see system tables.
     
  • LF <-> CR/LF conversion: Convert Unix style line endings to DOS style.
     
  • Updateable Cursors: Enable updateable cursor emulation in the driver.
     
  • Bytea as LO: Allow the use of bytea columns for Large Objects.
     
  • Row Versioning: Allows applications to detect whether data has been modified by other users while you are attempting to update a row. It also speeds the update process since every single column does not need to be specified in the where clause to update a row. The driver uses the "xmin" system field of PostgreSQL to allow for row versioning. Microsoft products seem to use this option well. See the faq for details on what you need to do to your database to allow for the row versioning feature to be used.
     
  • Display Optional Error Message: Display optional(detail, hint, statement position etc) error messages.
     
  • True is -1: Represent TRUE as -1 for compatibility with some applications.
     
  • Server side prepare:If set, the driver uses server-side prepared statements. See also Parse Statement option. Note that if a query needs to be described before execution, e.g. because the application calls SQLDescribeCol() or SQLNumResultCols() before SQLExecute(), the driver will send a Parse request to the server even if this option is disabled. In that case, the query that is sent to the server for parsing will have the parameter markers replaced with the actual parameter values, or NULL literals if the values are not known yet.
     
  • Int8 As: Define what datatype to report int8 columns as.
     
  • Numeric As: Specify the map from numeric items without precision to SQL data types. numeric(default), varchar, double or memo(SQL_LONGVARCHAR) can be specified.
     
  • Extra Opts: combination of the following bits.

      0x1: Force the output of short-length formatted connection string. Check this bit when you use MFC CDatabase class.
      0x2: Fake MS SQL Server so that MS Access recognizes PostgreSQL's serial type as AutoNumber type.
      0x4: Reply ANSI (not Unicode) char types for the inquiries from applications. Try to check this bit when your applications don't seem to be good at handling Unicode data.
     
  • Level of rollback on errors: Specifies what to rollback should an error occur.
     
    • Nop(0): Don't rollback anything and let the application handle the error.
       
    • Transaction(1): Rollback the entire transaction.
       
    • Statement(2): Rollback the statement.
       

    • Setup note: This specification is set up with the PROTOCOL option parameter.

      PROTOCOL=7.4-(0|1|2)
      default value is Statement (it is Transaction for servers before 8.0).

  • OID Options:
     
    • Show Column: Includes the OID in SQLColumns. This is good for using as a unique identifier to update records if no good key exists OR if the key has many parts, which blows up the backend.
       
    • Fake Index: This option fakes a unique index on OID. This is useful when there is not a real unique index on OID and for apps which can't ask what the unique identifier should be (i.e, Access 2.0).
       
  • Connect Settings: The driver sends these commands to the backend upon a successful connection.  It sends these settings AFTER it sends the driver "Connect Settings". Use a semi-colon (;) to separate commands. This can now handle any query, even if it returns results. The results will be thrown away however!
     
  • TCP KEEPALIVE setting(by sec): Specifies TCP keepalives setting.
     
    • disable: Check when client-side TCP keepalives are not used.
       
    • idle time: The number of seconds of inactivity after which TCP should send a keepalive message to the server.
       
    • interval: The number of seconds after which a TCP keepalive message that is not acknowledged by the server should be retransmitted.
       

Advanced Options 3/3 Dialog Box

  • Allow connections urecoverable by MSDTC?: How to test distributed transactions.
     
    • yes: MSDTC is needless unless applications crash. So don't check the connectivity from MSDTC.
       
    • rejects sslmode verify-[ca|full]: reject ssl connections with verify-ca or verify-full mode because in those cases msdtc could hardly establish the connection.
       
    • no: First confirm the connectivity from MSDTC.
       

  • Libpq parameters: Specify libpq connection parameters with conninfo style strings e.g. sslrootcert=c:\\myfolder\\myroot sslcert=C:\\myfolder\\mycert sslkey=C:\\myfolder\\mykey.
    Though host, port, dbname, user, password, sslmode, keepalives_idle or keepalive_interval parameters can be set using this(pqopt) option, the use is not recommended because they are ordinarily set by other options. When some settings for those parameters conflict with other ordinary options, connections are rejected.
     

Global settings Dialog Box

This dialog allows you to specify pre-connection/default logging options

  • CommLog (C:\psqlodbc_xxxx.log - Communications log): Log communications to/from the backend to that file. This is good for debugging problems.
     
  • MyLog (C:\mylog_xxxx.log - Detailed debug output): Log debug messages to that file. This is good for debugging problems with the driver.
     
  • MSDTCLog (C:\pgdtclog\mylog_xxxx.log - MSDTC debug output): Log debug messages to that file. This is good for debugging problems with the MSDTC.
     
  • Specification of the holder for log outputs: Adjustment of write permission.
     

Manage DSN Dialog Box

This dialog allows you to select which PostgreSQL ODBC driver to use for this connection. Note that this may not work with third party drivers.

How to specify as a connection option

There is a method of specifying a connection option in a keyword strings.

Example:VBA

  • myConn = "ODBC;DRIVER={PostgreSQL Unicode};" & serverConn & _
    "A0=0;A1=7.4;A2=0;A3=0;A4=0;A5=0;A6=;A7=100;A8=4096;A9=0;" & _
    "B0=254;B1=8190;B2=0;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;BI=-5;" & _
    "C0=0;C2=dd_;C4=1;C5=1;C6=1;C7=1;C8=1;C9=0;CA=verify-full;D1=30;D4=40;" & _
    "D5={sslrootcert=C:\\myfolder\\myroot sslcert=C:\\myfolder\\mycert sslkey=C:\\myfolder\\mykey}"

Please refer to a keyword list for details.

psqlodbc-REL-16_00_0005/docs/editConfiguration.jpg000077500000000000000000001773041462406103600216240ustar00rootroot00000000000000JFIF``C      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?6L 4}i2Q_*}QEQEQEQEQEQEQEQEQEQEQEp_G?$UTVMօ?iR4󽢿/?o'!𗦻ͱxHOY ]۾᳕5W#?~ h4ZUI{x^}$[iWIoi_>Eei>PAԊizߞsWo57 Bě%5-mNqBj>x?5oYқ cش&IIB0 ?k? +/ÚW{|G{%ߖv7˼ ~u_6ej&w$>֢>#ik|fkx(NsFך`F@*G2:̿j>sV1 b -s[$g^"/}.'< NTK\ۥ4WĿj9 _G$MO`[C<{KeM儉:[\|XoW ՖA1Ǧ_I<'l}/0ǜRw&Q^V{~Z9~Q~zy]c'T%mS^rsfH܁> h0|fH|~|AuOxRt&CPED`2K*O_!fe7ZK7jZKu;P`1N1__5fTu*1ݿ$/ɷgTWZ?_|h[_"O>4y7|q'|bF< 0kfiϪ)$Tɫ}QE# ( ( ( ( ( ( (h_WּV¶²FM M|6PW5d7>25ȍ^a6 /fϓMoct\[X(1_W4PxRHmN$ydi_iI0]8WZ:xh bY'2!e]@ mc:o WWKY Dy>hao:nB}*zD4{ɀ* _QUOmc:o QGM{faK7&ᰑpAE2SXck^zSXck^z-U?/=G6A7ǨSXck^z-U?/=G6A7ǨSXck^z-U?/=G6A7ǨSXck^z-U?/=G6A7ǨSXck^z-U?/=G6A7Ǩdx xz^Nx,ѴlP@` 5sXck^zp-Q9~i| o￱B>3Ogݻn3g9یqzouQ!xNՇemv0"uY̛[[ /=G6A7Ǫr{/E9 iznuֱw3)24{6]6_?go3MC'BVv3\Y_K+y[ P Jd^GM{?/=E7?[NY$w_~8/~>?Eߋ'Q:5Ɖk̿c)w$ʁT` q( /_g|b;Ѯ|S #EAUI#X&B?#twɾg_Q߭+/hy/Ÿ nKj!XS̟~ݘwU?~<$Zf1vŅ yAb|-Γ+  /ck^zmc:o P_֪_OKtg;|-{o/tm2-4"++Haa4=IGM{?/=BYyZ z7YȷET?#t tUOmc:o QGM{ET?#t tUOmc:o QGM{ET?#t tUOmc:o QGM{ET?#t tUOmc:o QGM{ET?#t tUOmc:o QGM{@ OByCr,x#__!oQmc:o QGM{ƦGR)4K ^tJ*Dx:_["u/?E{6A7Ǩ?#g7܎:ʿ2x:_["u/?E{6A7Ǩ?#Qϸ?֜*|#7xNC^]}k2"+4tgTtk./x$D(a7YگWDcX#Ư^ZNR{߫fw҈롮{ZDuQ@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@gO' 3Cz~'W;ZDu=o?:h((((((((((((((((((((((((((((((((L޷_Uo[x*gx< O(MG] QEQEQEQEW#+. 5MJONuЭ.D6wdO38* 5ݚ=' +={4,L>byGM@_Ou붌+?+ῃ%y^e{AM2'[属a"'Gį|)e<>/hZ^#8[Sܲș%G(q7տGLaQ/}jp&-kM}/V&o_M&t4WQ~Ң^K[%pVET$rO~ѺwZƷ6[x/4> 7D{q}{Fn&#I*(\Y5nQn\ExCJxHWQM[3SҦ#Cc$WWV I!Tybm(7&?OjX}Q}NKR{b"yy8!Y.\)r1TM./5ԛ7^A>ht/@GImt_oXd;ya7?i.fzkoj{|u/F浳|aasq=`ޙ,f+yd[U2Io)}rd-{O=z<$nj)8..k{ Bcs$O4JҠ8,3ڟᏂt+g7MI;9uH#f걳013~4Iչ | < wKş𬴋o:~m> pwf1TMk~ ]xViWz4L1A2rў!"R/EoF]zh;y^|'{Sÿn*V|Gg{cElG#"4JN29W>x~:`k9ujsR`vP2sU_xth@[Ym<;]jյ/qssq* H؀ $ 5fDb~SP Ï)l|8–W@ Ï)l|8–W@ Ï)l|8–W@ Ï)l|8–W@ Ï)lvޕwȽKyF"VSR;W__|Y(7EES_r"@?~ط,t|8–Q Ï)ly|8–Q Ï)ly|8–Q Ï)lx/Z/Xo.4Is+$ fU-޺@r( cTq-OR(|/ß5 k'!sEy JXx؀YN30=nW88GM& ( ( (04 O_gO'w҈롮{ZDuEPEPEPEPݟ AGju xsΖy1[%Q1'׆h_ mAFv SwDǧG#\R`_y[U)՝m6kյk{|EF0J1-uT%>ɾ[io/7>K֧mLڷu _ijztZ[eIE)X 9O?` hFˍ#ZiGgX]]̳C&3հk *4JY]4+I%{w]mwEVkvJڶ+$Os a;zl^֗?!A?xQ}BCoy&$8L,Ltp*z>3j5Ծ|mNN.}B;-9g[3@ ҖFB-M4mnVV&qRJK+5۽߁fi u? [i:nZi%k˸P]ujd6,l#&(Gß g[/xZfZjVWЉ 2r)Js~]?[JSS}?#_⧈>-؟׍~ÍKC=ChJ XXfs@DB|o::֥fU֍ cė%Ծ""[K{ecYf|LvQMi5>_y}?/)}]o>>3O=B%>e5t @[ mˀ gğ_$cn?TדAӵ6-J{KXCZ-ئxZ9YsWBi E|DO|{ri#KHUeYV)8Wp 3ɥ K7.I.o;/i~ƑxB:O-.A5u-;O\A2ݽ!ӥC;BD`ex:xG-O+Tow^5us'Rlm62Ə9M #FڋŦe:̌.淴x&m!PYFBgTU]*jZ&VjWN (y&S[HH's[U7YA,~tiU0b$PYXOCOCj1~h[ׄ!'?jQ: jZoOn2N2M;(\dѬx'cŒx'c¡9sy5]|ַ++y_>o¿[jZ/<%kO jpuoiCaƍqkؗW.Yc/ǏZxA5Moz_>DYk_N<3-ckD)(D2?~ǿI׽Dr U6y_Gj߳tsSv55 C=cVfbm@1| ,I9Mx'cŒx'cªr擗qB ݏo)gRY\. '})gRY\. '})gR/-G$zgA/2GXxB]d2E`u4QE ( ( ( ( ( (04 O_gO'w҈롮{ZDuEPEPw]xAT=?G-/R0EB*K޲|u _-χSGN~ڞJda)9?>i_~kmբOL1S$3FѸ 9kcYX}ddI.UH@{ y6|<߶|fgXu!u֚x&5_mЗftr#](Bo,(|WTڴ6"< .t;P;YO]ڱRDBZ;Ro[4WijXSvߍ޶dus~-@>,cif=;Z |GOԴ#n!JN# NM})~v c[ߊ:xC%RZXkikM99B]]~+|1y_ -x_AdP7>#+kgVonԷ,7fq,tN̶ǥ|'ѾG>x7:ē$Q]91p h7`lQN38wK;-W2ݪ骰sOnjd?>O۪𯆾-_Ѵ^&i>2%nH"C<| P'~Zn𮕥Kճ6-77iwu#ZZ <kO#/ I?ˏA: xNMJ1H_1&h@xaU9o^^Twv̔yo^\vd: վ(=3_[}6D,_%!$1"HW~07ý~6^ATd iv#]8Lj`XG;-~G A 6k! M ςcЬ`fX,o'e5432P/"/KxufT }%9mauIE'¨on]=o |wܑT^ۖWsYE+o/߳umoR}*A{넷_&1U dןx;ggI޵l>h4&[E#cȥ&[l䔴F>.OO7LZԡ-D ndH !.FH? &x!{@mu%hO-])=q־Kdz]_:Ь|_#Hx4Fb?~ d"/_d(,+B|VM;.u]oVWQFmgk-[i"/>Gtӑ#I^^~Z)'ydޛ+kiiļn/i^6kO >ӵ/_Cbω,_q 40acUwk͠j_ k\˦kְk-̍H,1<" 1O/xWFJT爴Kykn7He Yw2nq?k L]O{ipl)!> rgۍko ~~0i:y,~*&}g[[]g#ÒXqam8ET6KhvGSG77Y (lك^ g_j7/{iI:ۛOTe˭? ?hn-|ofYE-nA p;dʷ?)㊗9_m?n<`]xM-t 7;Ñ=E+-nV8H@>#g7ljUS^m̼$~_Sɷ[.(PQEW-k4WS\%?~MG gG Yxr"iW͔wWmIa2qFc+g<](Xχ>'<0j!|GguiZϹC[Q{ k{?ǿi_)kv4fkh"HI'kiX]|̻X $x|UKxa4<.c&hSoMEftMYmumlm_ʵ~Wq6l贾s l x>_xV K kPXbyX|Ĕh\99]O_t_ xMepDJH~ʓ&]?tΖ߳wzsmSV ^ifK9Kq;˜ib HM>6x+ǃ|9|??*^vt4``34[pW[gvW{vZSi)9Yty][W꛷?ਟC%K|B%4ZxN}9iyn<-"IcRN^kkon`՚{{$E= tQ3!ev.Gj\ڿKY7F[_^i/s*FQE|`NzG[v?mMnSER((((((L޷_Uo[x*gx< O(MG] QEQEQEQEQ\gO=֩ izgY$J.$|q..oUgHR_-]N7gQ V?]Oڗ?~)›RЍ.X)7?ߊԿOBI~ͪV3qF̈́U$F5oSo% V?]u4P- V?]5oSo%SEr5oSo% V?]u4P- V?]5oSo%SEr5oSo%կZ-φoNɼmpo.DUA 8)QEQEQEW c}C(e𾳪[ꚌwvلdvАD'Nk9oX)7Ѝ.)տFOiG, [oFu@, [oFuR>!Z[i6ܶRݻ!@'R;uPER([]ۼ3}c]j:\[YC)Jn `j#x4KB7#Mh- V?]5oSo%SEr5oSo%Wmkv6V1C_rXyQG 39;.YmRIwQp (Q@Q@Q@Q@Q@Q@gO' 3Cz~'W;ZDu=o?:h(('?i%ZW[χ;]fY%e.9\4FHc_'ik|5\{?NSl/{F^Q,u*R'os?"{3Oړ"K7!k?񮹧}mif9aۏ&!ΗH{!Y/Kou Nz_<yoR.C%%#b鰪'tEhῌ_%iZ/#SzMKigrז}Ε"EK1i\[힑ixፅ ^mlxEԗdRQq&&R^~kOz Z+9'iOܽrv fZ{6pY]n pY:S}lx?Zo<%Z5Z~Eackܶ$ kʪV>%~ZT~.eO{MEW-E; ro)oWӕu4QEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQE`i? T4 O_ DŽiC\҈론(( 4OxBC%|Q?McjP:Dܧ-Y$K%BWa  ޯ=M?7_U_@Pjo,?  ޯ=}E|  ޯ=`~ oui~w[yWk߼l>6 ^))//k)M7dǟwezv:8ouK(`-}u5>YWhJ!x9F:Ȉ\j-[~lgwOI{Z Qx/A[7| /=S͖Iy%U7@&#íS K?YϤiΛwK!2!cz/sx >8=ľּ ?rbm Q-b¹|7OG+ڛ'3z4>*ǫMGO:_jۍ62Oby?(ߊvAi¹yqg46| #3\ŲGdlN*WfW+[ME_z |~ϥ4;[7T4[ $Iy}o,rjfR ,_D:ό K-EO5d2EWWhVRyvSĶ |W/7J ;`w8YQs'Q oC_ƿ/[ пo('*o ;Icsw i-S%!;keܬ ҿ??'|-I!qF_mOxsEЮ/'Zݤ+m>QdrJK 5joecϟ۳;1As!K(?F\N=MT{7_5POUw쥪U>ցxF}ǚƪZi9eHh}K?Fzq,Ŋ3{rьc ‚B_ƿ/[ )r5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POTk A?!WSEr5POUx_2ZuMWYWO_\IDNdk Cx ;LWWׇڀ;lG',jnCW~|Gi/.4gKm]@‚p>~ ط,((( 3Cz~'Wꆙ!oIo?:k7xA_֟Qt4QEQEOMU~#oOMU~#oQEQEoJo%^<ӿ+l0h-g ὓw5[ǥSH~R;9uā&ևc/ZW$'h_|a*o:}3w:TP!< vmF,U!d/T3/a ;  T$8tiq\W[~Rub|7tOYi.ϊw~ŧY"XݥhQ䲈yWo?i &,Z~hRkxV즸d;IUT _ZF憏liohk:q4w\y9G]T$W2sKomm -3_4-3MxWzދ%NV-o'mzjuٮb[[\ Xb DWg%N,u;G,u;K^nz2>&=|_Cn-ZPZy_eK9" 4C.wK}fOI'W]xU]-Z7G[sKF Jt $ݵ +_cg +_cg(Z'`e{m~MGb?P:V^*I|K׷b)d-U/Pc€=jVA_:VA_:gk*+eks?eksVTW+Y+YXRVA_:VA_:z 9 9Ԩ-W1γhW1γhEyo,u;G,u;E*+eks?eks,Q^[ +_cg +_cg`=JYZ?vYZ?vTW+Y+YXRVA_:VA_:z 9 9Ԩ-W1γhW1γhEyo,u;G,u;E*+eks?eks,WׇڽKVA_:|k|W`?=]%-|Kᫍ6;igI|v +0pKoZc8{V1lwLwcd]'?I~y`~qv|g5 nG)㑠xZƃyL|[w1"G,m'W 6 51U2W Q@Q@Q@gO' 3Cz~'W;ZDu=o?:h((&G]b7DIȵog:RK.˨+yLjM?7_UV?ࣟnWUUAsTڔW'yYyvM7!ӵWV:EdiF}:XὍI!TGG`1lu> >"6z>>(y6H$f:t(!-usJ֟RiU߀>_xo_4!4H +#kcf%62J! ~_SxKxJ_ '-ŕLJ#{{cyiZ}EI!(_Zw344 |L!xMӬ|$tVO}z׳=p€I 34bBs=xKZ_džcV ["ƴg_lQ.Aj"w( #('VQMt}m׶浛N2#+{t;_uoz^2zs<}^:cDWx&-Vi.D i~qYۿ5ra>8'?3f<;ݝ9ٟ$D#]giּ=m Pj"ZL:)"o]w_5?h(#A[I5٦JISt`",JNUavm9y'8][k~;Z VėjfǪK K osDL- R Z]K%&֏rM]nQEIQEQEQEQEQEQEQEQEQEQEQEQEQEQEWׇھh???Ӎ4q%7G# ?s O,o;vO߈_m?SNj~j>l9>^T}x/n_=_}EPEPEP!oICL޷_U7xA_֟Qt5x< O((( &?*7k &?*7k +x&׸as8`wo#wcqk2U{|Om|_L8$Ӿ?|wumךNs024l+ + YZE HԀ1RQNO/?|5I> |qh |uaMfJO:²BAab?"߃JyW=YH?_8zG$WP/g[=#(~?r?_@Q@?ؿe9opH!AO|Q{<7|${} {NԠ}gēAp8CݸBFzF-W+}_N;h xZU&Xk#`@8$gt`}! V?]5oSo%~ M' x{ԴkSԵO׺n<+ [ F+;|M0V?hoৃfx> Q uN/;Y,⸽Y$ d>5^D5.Ux]-5, [oFtտFOi_=?h~>!~OH5| GX$|io/xPԬEIAog:F<2G U.f-?I^ kg)]I}, [oFtտFOiG(ПoQ 7_'[0(?`j#x4KB7#M?F+ "Q ?)@X)7Ѝ.Q ?)oO `(B7#M?`j#x4KoO `(-?4Ѝ.X)7-??F+ "?`j#x4KB7#M?F+ "Q ?)@X)7Ѝ.Q ?)oO `(B7#M?`j#x4KoO `(-?4Ѝ.X)7-??F+ "?`j#x4KB7#M?F+ "Q ?)@X)7Ѝ.Q ?)oO `(B7#M?`j#x4KoO `(-?4Ѝ.X)7-??F+ "?`j#x4KB7#M?F+ "Q ?)@X)7Ѝ.Q ?)oO `(B7#M🍾ψiƚoÿ_v%;).gel=M!ӽ{(ПoWi:7uO ^ .-<=sqQ}HIdvqo=Iow>"74?/[. y-FK ƥ$.Xgv5 #w]r|#/ xWӼSPKY9_ʖ8ѶS=EHkEQEQEo[x*P?7<~3MG] s&?J# ( (>iɺʯMiɺʯM ( (>)M7dǟweykw Gq+KԒ: i\xŖ(Pbu:EaȖwQ[ź)qgR *eoqmgM% N2j.WZ 7릳=#A<F^j7mG1 B,f*'ǿ!e[YV>"RcBs%~QV)Uuo]wdJh;. wVѣ /6'u]cE&5QчQ-Ygw|n y_c|Um_?kw|[$zs4k^$> \de 1#gh_aW^ ]"yHg$G8TQxO`J+Yi xZŦ~`Ҷ%ϛCa\ YFRwtUOio࿊>'ΡE._Nhwem52e}> (ܫ#$d_>"WP)&Os?z<^,"=6%՛I$+BGhn5I8=d[euz%e-Siyo"iQcG5mN~t 5K|>ilcg6c̩3ht흤WrzW")U\1$7[IGǝ>rm&d`[یwe.G>!~:~'xK ϋ?j-]Iw6yc;FuhռS=žÛ+gRϢ^mT._[iΓx&>M?(Z7!Q PoBd:GqO C ڮ|Oai,?c_w>`_04SeT g|I_/xNŷih`>hik(YU#ҟ=X_kW]5RmBK9'6 =ݾ?o5;XME+C4{̍":2*pAO OW0jji2wS,G$nw(I&kh/do|kegZ-zPOjw6٤p6xĐ cLɯ~.jIh+|=vg;),u{q@iIwj\Lz|D1W+δ rn7jZ~΅Jc^٥7@hYog^ԴMsOo(jpzc{z˸ Ex?ſVg6{ [sť\½Q!?'$)`c?lÿjԶV~"=g-sʥ㏗#8GGo ?u$A_B5s!K 6U 7Oy_[&ڕ(ڧKݒ׭¯{/|qS қZ~ƺާddmGXͅȮv)MᏉ4d5=( O[GjŲBKm_u7=\]PH[tm+ R_]`n?A៉ 4?ږa/XASG5`$Dv1'8xĪcZwi%o% r]kmLg;7mb)M[W7@hG2n?Bѿ Jfhyo2n?Bѿ d~?zs0<7@hG2n?Bѿ J9[ PoB7@h^E-M?(Z7!Q PoBRf&-M?(Z7!WQG3tT&-Ԩɺ F*?tUTQd~?ɺ F**(`yo2n?Bѿ d~?zs0<7@hG2n?Bѿ J9[ PoB-J]j,,cYVm*.@ȭx{]'ğu 7w }2"ֆ[@30v%b_z?*_[◉<,gk/y 휏mx&(.0FD`qiݥoV~#^I%I$W?=L|r}"coep?i] q ߃?WV~#|Et*D8%Y[[+y.mm{g ͋ m <~?RO}Bmu{m>/M]޵ ?>wM+-X&IF"Fea5|E=S"aG'ğF>ږwece=AvCK;1dcqCI=2qjQvhѼ}X^Ya)yE,Q[x^G~¹oSO mK IM}߫I_K&Zmo:+?ߊԿOڗAMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠMŸ?Sj_~SO mKѠM|AxmO?)/?\ߋ?d/x_u+KZ[WUavWhʱBʧi8(~fbϊNJc?nv?GI'A|c Vyy_g\*o $?5} Q/?.a_Z֛qgyoKܑMH$x ҏO%s`(((L޷_Uo[x*gx< O(MG] QEQExGx:>xio\ Fg0)]9ZAyo35oGΟ43ןA.p+HCv4#4≹%_TRo-?>qxf_ kURg$M,壕ic eYa'خ:<_gq>T6>lqw-Fvĥ ٿo|I/x<;Qn*KHZKkIb}=xnqnnk?E ~QCO_1cL|CzYC15#BHZZɴi?얝o~f,ziuoG̕vN=~"}_K_ >/"ѧ|? &?*7k #/w#?>"ѧ|?(>"ѧ|?[McG~5ho澩>6Կ?tz7?cߊUag ,f_0j~ZP]ʆ zm_e-k)M7dǟwe{t>0n|[qGikv_ir i^Df;7xUr0' :\wo.<Z 57M}{y"[k (g - 9z>S&*4~mVQ~ݟ}ۻw99}TVM7{Z^liohhF憾?|GѼUhV~i Tu+MF88/Vh7kv]«F_X[ fhO+.oړ g9~~ ğzxUЭl"՛\ionU[U\Gs_//ǂmb4m uŃMٍ!Oy*_xI<#ɼGceӨi׷1[@-ͳims rpx3g|/o5-f _KԮ/.ac,:Ũ2+Bd2dQ*JVWկR_ ˙Ob$N?L_b\Ox KWO }sm?Je|X]STOBo%#+F{( 3#._,ɲ6_;i^2B>)KhtkW}/[Go$, 'C6wѫ^뺲nCQ%(4 IO3?pi?&u/1^S(ׂ%4K1zI[ؿPW{8c]R$لe9s{i;fxCV y-P ,÷h 0 si~kkZs+Pqמܶ{[ޏ4O:>)gRoKs 'n'ͶM,ք_[Ũ\)*6K? =|9vi 5O o#VV}/Q/,"37$/wN[[{{Zs+s_N6w. '}KO. '}!_\wI3_񧊼 Z ][ͨ[>{}K W0cB?:O;YoO&#7QSP|觅]AoD y[#ff?Qk-;?2xI:ZIIs 6T$y.XE'~CY'''E+54pkSdݷ=>)gR?L_bkR xR"S%xR[K+{ڊ:]^O5 1 w2C bVB ? {PKDpv`|-d_eP%(Ikz^LyeoVJ-&ߍ(sF. '})gR'aJ>W|9f{+B.šg+ ݇$eϥ||'X|,FjOjz4[b@ {FWә\F!s&QsvIeewifKm-mjz. '} |qh |uaMfJO:²BAab?" )M]&٧oƐ,diF_g'vo]vGߴ٠|_k~AxF%vn,|9cq_Gw 4V-Oq m"Rј՗q4.s7=ʥ7K6'"?K E*]w=YH?h+7.׼?czgO 跷״J K|I01]ۀt$ajrr[moWTӆNmK\<7+/Z炋XɪΈDd)q7;M~<~/G!xP^u;/Vn3q}юs m$mǖ ǠտFOiG, [oFu®M;u|WW})Ӓ4kjm4V{_'ܿ|=oJ.hD ĶZCɁp夁4[baB+/|($>}ů3xxmg9uYS3Lʹ&B7#M?`j#x4KJַFq|[]ovWy:Y/jKK]υ ~ iտu{zRx$/-h2q"Lv'cGAgPO_;/5ek8|a5FT.^ U;Z -nЍ.X)7髫[[?ʵz+-E$w.w<3wb_4m3]ǣ|C>6YtV[[Y-rYm*7`h xNju:,6 RZ|0f6ͣؿ`j#x4KB7#M井(tVmSyԤ5Uk9I}rVƿMOo>|Hx,,w&sG%ɨ"[HdFS%_*|Ax_s&w }?Gn4龜5=IћrCW5oSo% V?][nO̟(Ek%oK->nW>W />V[Mw\/o_ ]Cog%QIM*R!Hh^13ºwg'+[}ށ,K{+=B4QbHw`j#x4KB7#M些m/~+gV}~OujXk߲OĿ>0WCu>@д V}Wך޳ YZM䱍c?'{jҼwiIW7uPM%M"Ig42o5oSo% V?]\s[[W*EM;;iu|yx_ƃvP5mF/ _P[c|FyPFj_yԲKԤ$ c;DUQտFOiG, [oFun.=+/&'|.~$ş :}է|tܢ5=Оo)6mlA~"QoxDM+ OxZO,Gn,h[ kQmp+4dJ*O)5oSo% V?]o+RiZ=_=Vki?U}OxG_Wí.I|UhwZp xb<|t@__Gĝ|Kχ 4;kK;mTI.JMYv5_5oSo% V?]SnoMwbz[^m|cg|8O۩9sxg୶k?mwtxK %Yṁ$$Ǯ1^o?(]4gŞQFҬƽvY`cf=_TտFOi^99xMwK.:$G%Lp̭U)d6r:w薽Ւ{U|^}7G# ?s O,o;vO߈_m?SNj~j>l9>^}=Iow>"74?/[. y-FK ƥ$.Xgv4GEikG}EPEPEP!oICL޷_U7xA_֟Qt5x< O((( &?*7k &?*7jsMJJp\ӄ?Q_KQ\ǼQ_/co?-g▗(-zٯYYBPC5T-ۥi^|yu_x=xO[Ҵ B[5Rmn5+ jI;kx]m{FdyY]9ͥRo(7L.ן/V[VW|\3x(OEqźm[o4VHn셴(c3HH`r׺m̀Į@ ӧ(]Kttf[r\G|FU;2#S~ *^UPxY~̈gZD' 3>6ȒF*p`b RoQE9| uvይ2Mzofzb.#ͱtq3} ڈ{ԣUln1/M)*Ηm)F|^eQ@E֑-/H ;P{Kl5p@ ϡ5|+|VHԾn䌐\ 3T髻;/2ݑǂ~.Iß5Oi>(/ĺKvgn>20cnDDZ>Eӵq kz ljWºY6i/[phlpT~ɞ2M/Z6v񭟈4kKX!{0CX?ekQ[~x7@[j:q/2˺CM+&Y&uDVFE*Iʕv9$ӣi-~XI2zwI.Rik4oCoJm>F*%jRV"RO"WP3K aLeekKO~n;s[iQ}0q#߳evkþ~?c[Pm{6w&]i2IjP8'cF7_Xg d$0|Ə+;_exWRuoMX>5 [IS\+8HBKoG _ OӼ1?6h/Gq.O<:Wg~<#/.]ͭm"Ka:݈WQ3+pb~8v7ONӵKˏUZhLZ<`X:Q!f q~M~$?|/ĭoW5ηZzZh^]Jk(.(,DJHl>4>sUR~'f&NҎu?N@bs&QSiFTaME]י]/z7ڰ>Xɭ\U)-zYv#_=wnPqr`6H'oGЬ #p^:7PN%ηŻIyxK$SEYZ(ܷғp涻O^z=zmYH i[)agi^+[fLIs_?A 뺗K/px[^,V/EIzͤLmų," q%ֳ{ڽγet5;itUڒǣ~d3brK}9yIYV*km/X;[?ſ>1_|OĴ[_ xH֣Eh+˅>['o[/? |dӾj7,>  \ϧEDC2+F"g\E!ʡk?O|P ?:^]iV$/P}IF6F$+~#tv?xJdWQOM:C-RN/n, pBfh)H:/~Vm=ihU(uyV~^>S>k [{_ΟwˮAovSh+xDy]ӿioSPo|ߊnϫmvK.NhыycGO Y渺m6gYiPW-JeQ}M%kRHSa騿R+SzUku|KY Zj>ׂFNf3e1lϘ"}q>"ΟWgz_>&:mw_3qLv| ~b-Z]>>)|##xl.Ƥ*,o=.2P7<.~Ҟ*w$i>K䅮4ytĶiE=PEY&F݊qh'^ϽU>ɇiS/NMS_v(/)-.f#;:-y/~/oi&8/<5j泵m1v{LO?%?Zn/GKj[_W] .o>Xkr5g0ltmSB][pz;?s>Т(((L޷_Uo[x*gx< O(MG] QEQE|u__h9/ > BUH"sgu崙FSOOm`T|w &?*7k 6i{lx? |{m$>,[Tu9[w~L7p4yԛ+E[ώrv>)M7dǟwez'?f_|H]hl%ђo\G "MGOQ&W7X~?I> ,--$ߋ5_ ]]S\i)}7(a _8x[tW]s5h>OX V aȅ%te;C#m"% QCN=NW^h4ӟP6KEY›KAmۧkt)>[9u{~O}P<-X??yx+ .k;z~')}7)h0<-X??yx+ .W>)}7+EƍUex"C@]Zij=̖Ҳ`PlT R2fT׷IW _8x[tW]qo}+Q񕷇4ZRTZh[ܺƞv;!9hIT4N|Ti@7?B|~ak>,WR%+C2ʐJ_F_ k]CkG//o'{o>Oo:ƿnn5 Mou=[o|So"UYn$p `<-X??_<DS> x^Ο`if(d{2lSqP@!h s<-X??yx+ .W>)}7(^^ 5p `. )}7)h _8x[uCÿ>x>[]'^>m=Ci}kIk%mkWcn9kJdf*Wl5zo//o _8x[uv:l&5^+ ?C;͋FNEy{ragmsi>)kj7i'AH @ J6oK'<-X??yx+ .7Q__)?/XN,Mz֏0!vJw`+c/~3ix'fգC$v/oe;ĭ")`]AW 6z?yx+ .^^ 5^Ц񏇬u}'6zwvwK2(dmHee "|%~+׃>5Y,[ )&UiԢ CEzmw.oRN*Kg//owOׇYUt{Ay& ۙlVwnsq_O¿տyO^3kVZ]徣u.CDžH|K@ A%}d(ρuYFWz~pp5»b~Iw۝3ԭ/v7z( ( (04 O_gO'w҈롮{ZDuEPEPM?7_U_@WM?7_U_@PEPEP)xN wOG: Z7Ogx_Owj;%Zڪ$>b)oJo%^<ӿ*ǯ/O;xxV> |&} v2͔Peƣ {k 7!9o^k[u9%ݼyӣc 'jW[xZE>]SOm{G"8ٓ(*WGY֮!xgXBִwJ#di=ŻhdVgRH`<ŸN/6zaZKiۙ\[Ἱ;|{Կs{」%[Ӻ)|74{x^~$PМ=+[򛏈C-TTtM}BnSoCF_<-XxZ|6l$2]G#J{RdeO,N|kOz'_ wssS,5}CZ{).4U...-fmߢ͈ݥ$vtV0Tcū'K率?>?g_d[w=+&n5rL/rQnm cuq*]1mqrogLO;Iмe=ZUAsY&ϸ`HfG޴TU%W=cӪeUUZYZk{-Ww}YcW><5xᧁ4/ è[5|?> o&+#v)\_Anv4Ia{\_iaj-_j:ekG7z䎚i%;KI,1GEkyTߧ/n1;$}]{h~mjO#VâhvD-Z[ ǕF40Bk{CSRkMnc%ߊ$KojPAsu{rm⽏+ 0' +$wd}߼ߔ{u9I饹v^Jkf~NWŤ|>xMٶaVu^KYkVrެmos{tEfvjm..%?]N}^EuWV 6K)"7$ݾg+-t[UNteE[kM[cbgɥAPWD-Oķ6;F;[6{tdM IW<Iо$k]$[W _m.zLq+&H`V$(fJRokZpʗ(sT kjZ~<|!xNwG66߂HhbsJ2O9_Hj)YUM4kY9;+ ˞M.Kt?1lXoz/zցsaSxRct|KyNO2o>>ئNKGm? ?~ꚏiZ8!.dZzh^n*Y}xxoz+YMsiI}9U.PJׯ£{5n* }GG~_ ~&\յ j)NH" G(fn?ko_nǂ42-*@uFmtn.f2<}χ+M6.n VA5koIB^-}Rd'Ϳ]~WƟ~2x|_e׃|;g CL𶣮&5q^êCcNE$7ضȕ"~ u赟$ֿikWnt%ȓ{ 8'&%bh+;?'Y*&q;}[$?)b]skr77S/yJYig.M4jy[>];/~c o |!Լ9#[[@(md j>9d4g?|S\WY|.J_,>&W'>x< k/=i2]@ @@|tK6*Cywيm/0*ͣxJ'M[{ շqq[I,p_Q)N:UK5UFW~*Y+*ӵ>o{M\•8OW_Ȝ{]o 4K? z/gFT!c\z4.|2\bnb6-`wZ߁/~-N2o{Ex?2`ABN~|2>w:oeykGI.۩nd˳y}]P",}8kVVKtYm1o m+Tc?j>[ mGO&xdu d" AV_@b|Y:{]{iJ4{HrVyV?iF,$o6z^էw4Ѵ}  hڌ3<{mHtId1ZӘf3#-o+Wyn¾6oMwB1Ml20[myh\o)?w{Y^MM?du}d_|$KK/h>м?io^^PX:Zv ?&3p|e?P:m9O:^-k uCp[:/ R& 0;uSQT]=NkO|+|Mw∯;?xJC>4/y^N\\׷HIE`~Wׇڔn{djuSvo[_}ZoEm?i7-?K%TouC>+*5b@ٹ 6$n s:$Z~yZ"a}p<'?<GUyiG|О}EPEPEP!oICL޷_U7xA_֟Qt5x< O((( &?*7k &?*7k (e)W9zjma R;ZoMi${kKb61G4\I2ySe{ _[jsJ:!.^Y;yeK?iplNJpo?*0/ޏW~ZWψk};E𮭤i:Ji:ujsiI..2JR7lBJ|F{M7KW{M7EM΋%ޏyޘ"m'm*@MCޓ+-byi(}%dοZ)|5Y+[v#R.'ys"n*ĩ^¼it'źzV֣lЬ k(&S2  8xI="}oLj ٷBeE y$7% Uu^b֏ۨg"EM E~%c+6_ͯ*+n~*<ηtk[O%wo!tyr V&y1c o~ |3ޝ:XeO.& azѤmq2y+3j%Sqkii^+_Nג\]_ͯ*(W_?kʊO;T@SK/uog]լ.gn|>Ӡ΍Bybjo}♼9n}m~NiߘlΧۤo9.&cc'>h%յNmye.vn>mOAE~%c+6?3z'wY> Kxt#GagL$PQu cxsھ G°oGJoZm}{eӡԖV̳[ydtQSym뢕^)U7OqRm|%yĿ f+/YEy'c;^+OxDg%(AW2)6"%|Dy_֗wϰ\|6}Go:_~&;[3I(bh]e䢛oM7"(γ*m.]5c_E~%c+6_ͯ*+o]>,>Ү_o=E!u8ncO41Ƚ~3jٖde2H;mG4 `̃"--o{]ߙmZ|ਯɿ Ŀ f+/YE|~;/ :n[h^?U!{e|gIlEK$C4R2"FB_/7('YæZxPԣ5[$i6{}>h89+f< U?t!/ǚ-/tg)ZN+u/r_n=_ͯ*(W_?kʊ#O?o6ˏzʄ/JPn5LCYfee9hm}/E~%c+6_ͯ*+~>|`j ;z6YïZ_#R:d7En]:kUny|-~[oxC:6kVГ0ji{Z%0U<2Xm~(:6ִ f7 v#S 0ᮗk& 6E5}o{ǒwVe9^_/+|_'o^W_?kʊ?A7|Pnj_<x[?Fu&//Yln$H3W |;|ߍ ѯm:;]oHԙc-iq\^ZMm0d^QrM|.;?əs1I5W^"1_TQĿ f1sR~>?>|/--Oso|缹ŭٕ>o7 v1tZY_]~6Z>ϙvq^R}k`+/YEKVmQ^aB~ |1ց;XOuoM犬5EqH-neZ q2!g# w⿈1mvZDq"${MV]^-{+E~%c+6_ͯ*+_SK.>{._oλsSt.[{k'ڮhGn-m/(&~[ika{mpNJc֯hbVtfx|ƣn}#o{Gvח{koAE~%c+6ůi;j muͥŢ| R27@&S%|%_6|dux.#Ү< =GurQ!*Cu˛ I6*I{ϛʦ~GTY=qZzs+_ͯ*+~1Ţx|{ˠ5Ɲqfm,郙Z##nӟ6gσ'׈>^ŗ)K]i:&9Z´S7_,si̾.KI'UەgZnpB-a{DKf2q}ZI-|u.7 Wexb^Sݴ;kVoћe;`lG5~n??[J`}EPEPEP!oICL޷_U7xA_֟Qt5x< O((( &?*7k ?ூi/ٯD'/x>:>_ <;6a<׷v c2 I6ӾSWbX7y5f*jB3[9?%svߑ%6 VB#|ZZjjp/cg-L">yTo2Fa}ů?>Gï [^kAӞ[nP*(ܜcF?MDoM_әtnY$\J+Kͽ[g}!I!| _?7k$ooak07cA1xᇂ.5h Mji*Yj\K$za # R#8Kf8MJQ'gO+O}H_Kî_haek, vNGșG;FWg·g;_{^_^jq^C{s{,ss* DQ-v>5Oɴd ??&թ59T)sכȚSQEU~|>A ?4w:<An+ L ghm3BrYv`5i UKJ;' kw{Dr3F'ƿ0x[ 6o'ڛ+(_k^ls_ c_G ˡ\7K {44I3"÷oZ>5Oɴd ??&ZIIno+ZuYvD\]t꛿{uc$~m ShIeo/$>#hf ßg YiuII+}D_0>Xvc ` ]O`m>5Oɴ--nսMyRMK[tӿɵs5OɴY%eOMK ^W?_cDOkg5OɴӺI?%O*{߅]ՙ?h?z'4;sqWM1u@6 77/'?l~6xǞ0u[^]Q%6Fq'ٕ: _<-GO`m*kJq&|éYlt\~7u9~? %xsǚ^^ecqwf-Es2KnCG@^4]_[O6Ě5{"ivHUHI'ƿ0x[ 6o',k|kzY%S{ m[G4 iM,i,ֽ]ۙX/nnn-j-nxc4'}+<7.k62}[P5Oɴ_%$|5'6ɭZx_ZΡkqŽķsu#G%C@Ht}n>yw8>5Oɴd ??&([[_i_v%mZuYvFÿGh->xr 3N^_orU,I8[5d ??&_<-U&ܤؒIY|iF>&g9=h|7adq7#\=Wq6 [TX;˥e r %Ğ'ƿ0x[ 6o'ژEG}zkvCz?O~/}7C<*⭳Z9Ɲ,GO񬼔3JY[#|:tMNPӢG:xqgXm̖zma>Z?|kCh ~M(V]mO-og[} ٗ-?BeێM{~ЈTWu渖Y[s!7O_X]+"lKtz Θ.T,_zf,6}'ƿ0x[ 6o'$&o OVݥ͍Ck7oRK۹|ҒB_k~^v„ 7#c?<7?/ڼ<7ϗl潗?uJq+Xo>"xB;Mnk \9chة:g}Gpz]]袊((?7<~i? @&?J#DŽiC@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@gO' 3Cz~'W;ZDu=o?:h((((((((((((((((((((((((((((((((L޷_Uo[x*gx< O(((((((((((((((((((((((((((((((((( 3Cz~'W袀?psqlodbc-REL-16_00_0005/docs/frame_adjust.js000066400000000000000000000010451462406103600204300ustar00rootroot00000000000000 psqlodbc-REL-16_00_0005/docs/msdtc_pgxalib_tracing_README.txt000066400000000000000000000023031462406103600235310ustar00rootroot00000000000000The files: msdtc_pgxalib_tracing_enable.reg msdtc_pgxalib_tracing_disable.reg are Windows Registry Editor files that can be opened to add registry entries that turn psqlODBC's tracing for the Microsoft Distributed Transaction Co-Ordinator (MSDTC) on and off. You must also create C:\pgdtclog and ensure NETWORKSERVICE has write permissions. (It will by default on most Windows installs). At time of writing the trace path is hard coded to this location. This tracing is separate to regular ODBC API tracing and to psqlODBC's "mylog" tracing. It only traces access to the XA transaction manager used by MSDTC when doing XA transaction co-ordination. You probably only need this if you're debugging issues with "In doubt" or "only failed to notify" transactions in MSDTC. If you're tracing XA transactions in MSDTC you probably also want to trace MSDTC its self. For that, see: http://msdn.microsoft.com/en-us/library/ms684379(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/ms678917(v=vs.85).aspx Tests suggest that only some SDKs' versions of the tracefmt.exe tool required will work - I found that Windows SDK 7.1's worked, but Visual Studio Express for Desktop 2012's didn't. Your results may vary. psqlodbc-REL-16_00_0005/docs/msdtc_pgxalib_tracing_disable.reg000066400000000000000000000003561462406103600241430ustar00rootroot00000000000000Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL] "MsdtcLog"="0" psqlodbc-REL-16_00_0005/docs/msdtc_pgxalib_tracing_enable.reg000066400000000000000000000003561462406103600237660ustar00rootroot00000000000000Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL] "MsdtcLog"="1" psqlodbc-REL-16_00_0005/docs/release-7.3.html000066400000000000000000000711051462406103600202450ustar00rootroot00000000000000 psqlODBC release notes - 7.3 and below

psqlODBC release notes - 7.3 and below

Note

Releases from this point onwards are based on the REL-07_03_ENHANCED code branch of psqlODBC - please see http://archives.postgresql.org/pgsql-odbc/2006-02/msg00131.php for further details.

The following changes are based on the 07.03 codebase

[7.3.0261]

1.Handle the conversion from text-like field to SQL_C_BINARY more properly.
2.Make buffer extension in SQLPutData more effective.
3.Reply SQL_CONVERT_xxxx correctly for SQLGetInfo request.
4.Reply DBMS_NAME, DBMS_VERSION correctly for SQLGetInfo request.
5.Not call show max_identifier_length in PG 7.4.
6.Change adjustLikePattern() to take literal quote(') into account.
7.Fix a bug in memory debug routine.
8.Change the multibyte encoding list to match that of the current
  official driver.
9.Change SC_clear_error() to call CC_clear_error() also.
10.Change the length values returned when they are unknown for
   SQLDescribeCol or SQLColAttribute requests.

[7.3.0261]

1.Fix the handling of *too small buffer* in the Unicode version.
2.Fix the behavior of DiscardStatementSvp which resets the status too early.
3.Fix the bug in PGAPI_ParamData which fails to count the number
  of parameters.
4.Allow blanks in password.
5.Add an option to force abbreviation of connection string.
6.Fix the handling of "PROTOCOL=x.x-x" in the connection string.
7.Fix the loadlib module of *nix.

[7.3.0260]

1. Change delay load import library mechanism(libpq,openssl)
2. Compile Optimization correspondence.
3. SQLForeignKeys ResultSet accuracy correspondence.

[7.3.0258]

1. bug fix: SQLBulkOperations rollback option.
   There was a case where a rollback was not published in SQLBulkOperations
   as option specification at the time of error generating.

[7.3.0257]

1. Fault correction of the division SQLGetData to SQL_C_WCHAR.

[7.3.0256]

1. SQLSetPos does not position to current-row to renewal of unblock cursor.
   (Data is unacquirable by SQLGetData etc.)

[7.3.0255]

1. bug fix: leak of a return value clearance
2. Correspondence Windows English Dialog.
3. Changes into the libpq link method.

[7.3.0254]

1. Setting menu of SSLMODE is added.
2. Correspondence to domain type lo (an approvement is still required).
3. bug fix: LIBPQ version cancellation request transmitting correspondence.
4. Correction of the exclusive control between threads of SQLCancel

[7.3.0253]

1. Compilation of escape usage.
   (preliminaries corresponding to a literal-escape abolition schedule)
2. Correspondence of libpq and openssl.
3. SQLProcedureColumns()RESULT_COLS row is outputted.
4. bug fix: server-side prepare the number check of parameters.
5. bug fix: parameter bind without a parameter marker is disregarded.
6. bug fix: Retrying without carrying out a select operation to EWOULDBLOCK of socket/SSL-read.
7. Abolition of abolition in manual_result mode, TupleList, and TupleNode employment

[7.3.0252]

1. Bug fix: Multi-byte employment by a table name etc.
2. The text (varchar/char) type key assignation was enabled by MS-Access.

[7.3.0251]

1. Suppression of SQLColumnPrivilege support
   It rejects using information_schema.column_privileges.
2. Binary mode is used for a bytea type parameter value setup.
   (Performs by the sequence of SQLPrepare->SQLExecute by server_side_prepare employment)
3. Coexistence of LO type and bytea type.
   When the parameter of LongVarBinary exists not by SQLPrepare->SQLExecute but by
   SQLExecDirect at the time of direct dispatching, the Parse/Describe function of
   a protocol 3 is used, the model in saver of LongVarBinary is acquired beforehand,
   and a bytea type and LO type are recognized.

[Feature of Driver7.3.025x]

1. Correspondence protocol 3
   Options, such as client encoding, are set up by the start-up packet.
   This makes the most of the mechanism of Parse/Bind/Execute.
   .The outfit of SQLDescribeParam
   .PREPARE/EXECUTE is changed from the command base to the protocol base.
   .FETCH command is changed to an Execute request as it has come out.
   .Moreover, bytea and lo type coexistence is possible.
   .Others...

2. Enhancement in declare/fetch mode (7.4 or later)
   Even if a certain renewal occurs on the way by holdable cursor exploitation,
   a commitment is possible in comfort.
   Moreover, the static update cursor was supported.
   (Only for SQLSetPos correspondence, SQLBulkOperation are un-supporting)
   Bug fix of the cursor which can be updated.

3. Rollback support of a syntactical unit at the time of an error.(8.0 or later)
   Can choose from three Transaction module,Statement module,Nothing.
   These can be specified by data source setup.

4. Output parameter support (8.1 or later)
   Corresponded to the output parameter of the function introduced by 8.1.
   (Only the return value of a function was supported before.)

psqlODBC 08.01.0200 Release

psqlODBC 08.01.0200 contains only documentation changes over the 08.01.0108 development build.


  • Notes: psqlODBC 08.01.0108

  • 1) fix most warnings during build in x86_64 environment
    2) fixed point of failure on x86_64 boxes
    3) fixed autocommit = off behaviour with starting transactions when needed
    4) quick hack againist access violation with Disallow premature - this rarely used feature is still broken, but should no longer crash
    5) report correct SQLSTATE in SQLGetDiagField and SQLGetDiagRec

  • Notes: psqlODBC 08.01.0107

  • 1) fix next problem with calling implicit rollback in bad time
    2) detecting transaction commands into if branch which mean backend successfully done the command. add support for "start transaction"
    3) fix bug when mylog output can't be created
    4) fix problem with SQLSetPos
    5) fix problem with column length in CC_mapping
    6) fix - typelen could be less then zero not only -1

  • Notes: psqlODBC 08.01.0106

  • 1) fix problem with getting long text in unicode driver
    2) fix sqlstate in case of error in statement
    3) doesn't call rollback in autocommit off or in manual transaction
    4) remove obsolete parameter protocol

  • Notes: psqlODBC 08.01.0105

  • Changes:
    1) fix problem with rollback aborted queries
    2) SQLColumns or SQLColAttribute may return bad answer when Show system tables is turned off
    3) adds support for ; delimited options in ConfigDSN
    4) fixes problem with binding parameters and SQLCancel without SQLFreeStmt

  • Notes: psqlODBC 08.01.0104

  • Changes:
    1) add commit after set basic options in SQLDriverConnect when autocommit is turned off
    2) driver doesn't fail when there isn't bind enough parameters
    3) collattributes doesn't work since switch to libpq.
    There is still problem with select '' as xx from table
    4) SQLTables after SQLExecDirect has problem with GetData for all rows
    5) grow MAXKEYLEN for SQLConfigDataSource
    6) repair behaviour of more queries in one statement

  • Notes: psqlODBC 08.01.0103

  • Changes:
    1) RowCount problem in SELECT
    2) Server side prepare - but only first run in allocated statement
    (http://pgfoundry.org/tracker/index.php?func=detail&aid=1000460&group_id=1000125&atid=538)
    3) Table names repeated in BDE with usedeclarefetch=1
    4) Binding parameters are now freed in SQLCancel
    5) Skip fetching data for commands

  • Notes: psqlODBC 08.01.0102

  • Changes:
    1) Server side prepare now works correctly.
    2) A bug in SQLTables that shows up in Borland SQL Explorer in
    3) Declare/Fetch mode has been fixed.
    4) A number of inconsistent internal APIs have been cleaned up. These
    issues only showed up on some OS's.
    5) Correct value returned by SQLGetInfo for
    SQL_CATALOG_LOCATION/SQL_QUALIFIER_LOCATION. This prevented use of the
    driver in Visual Studio 2005.

    The last four numbers will represent the build. If the last 2 digits are
    both zero, a stable version is indicated. If the last two digits are
    non-zero, it is a development snapshot.
    So, starting with the next stable release, we will have:
    08.01.0200 - Stable
    08.01.0201 - Development
    ...
    ...
    08.01.0299 - Development
    08.01.0300 - Stable
    Of course, we won't necessarily have 99 snaphosts between stable releases!

  • Notes: psqlODBC 08.01.0101

  • Changes:
    This release fixes a serious problem in non-declare/fetch mode where
    recordsets over the configured declare/fetch cache size were returned
    incorrectly. It is advised that all users of v08.01.0100 upgrade as soon
    as possible.

    psqlODBC 08.01.0100 Release

    This release represents a major change to the driver over previous versions;
    in particular, the network code has been replaced with the PostgreSQL libpq
    library. This allows us to more easily take advantage of updates and new
    features that might be introduced to the PostgreSQL wire protocol, and also
    allowed us to upgrade straight away to the version 3 protocol which was
    previously unsupported. We were also able to add SSL support, as well as
    Kerberos authentication support.

    >From this release, two versions of the driver are provided for Windows,
    'PostgreSQL ANSI' which supports single and multibyte applications through
    the ANSI ODBC API, and 'PostgreSQL Unicode' which provides Unicode support
    through the Unicode ODBC API. On Unix systems, the driver type may be
    selected via a configure option.

    psqlODBC may be downloaded from http://www.postgresql.org/ftp/odbc/versions/
    in source, Windows Installer, merge module, and basic zip file formats.

    Please post any bug reports to the pgsql-odbc@postgresql.org mailing list.

    I'd like to take this opportunity to thank all those involved with the
    development, testing and bug fixing of the updated driver.
    PostgreSQL Core Team

  • Notes: psqlODBC 08.00.0102

  • This is a bug fix release
    of the pre-libpq version of the driver, specifically to fix a bug
    affecting Unix users
    (http://gborg.postgresql.org/project/psqlodbc/bugs/bugupdate.php?1176)

    psqlODBC 08.00.0100 Release

    The driver is available in source form, as well as a dll, merge module
    and msi installer for Windows.

    Regards, Dave.

  • Notes: psqlODBC 08.00.0005

  • This version
    contains a some recent fixes, and is packaged in a new installer built
    entirely using open source tools (specifically, the Wix toolkit).

  • Notes: psqlODBC 08.00.0002

  • This version of the driver is a minor update
    with a fix to the string sizing code in SQLGetInfo, and removal of the
    need for tables to be in the search path or public schema for them to be
    returned by SQLTables.

  • Notes: psqlODBC 08.00.0001

  • The purpose of this version is to try to get something stable, with
    proper schema/without OID support ready for the 8.0 release
    (particularly the win32 release). To that end, this release is mainly a
    quick cleanup of the following:

    - GUI cleanup. Dialogues should behave better now and not have unlabeled
    buttons or move around the screen in strange ways.

    - Updateable Cursor support. This is largely experimental and is (I
    believe) the cause of a least a couple of stability issues in the recent
    snapshots. In this release it is marked 'experimental' on the setup
    dialogue (only in English, if anyone can do the Japanese version, please
    send a patch) and turned off by default.

    I'd appreciate it if ppl could test it a little with Updateable Cursors
    *turned off* and report any bugs.

    psqlODBC 07.05.0001

    This is version 07.05.0001. For those that don't know or don't recall
    how the versioning works, the major and minor number track the latest
    release of PostgreSQL that the driver is expected to work with. The
    revision number is a bit more complex. The first two digits are the
    version number, where even numbers are development versions, and odd are
    release. The last two digits are the build number.

    In other words, this driver is build 01 of development version 00, and
    is expected to work with PostgreSQL 7.5dev. :-) The leading zeros are an
    ODBC thing...

    psqlODBC 07.03.0100 Release

    I'm pleased to announce the long awaited new version of psqlODBC. This
    release represents a major change in the packaging and distribution of
    psqlODBC. In particular the following points should be noted:

    1) The build number will now be used to indicate both the release number
    (first 2 digits), and snapshot build number (last 2 digits). this
    release is 0100, or release 1, snapshot 0. The first development
    snapshot will become 0101, the second 0102 and so on. The next official
    release should be 07.03.0200.

    2) With this release, the ODBC 3 driver is now the default. The
    filenames, driver names and their capabilities are as follows:

    psqlodbc.dll PostgreSQL ODBC3.0 Level
    driver
    psqlodbc25.dll PostgreSQL Legacy ODBC2.5 Level
    driver
    psqlodbc30w.dll PostgreSQL Unicode (Beta) Beta quality ODBC3.0
    level driver with Unicode support

    3) The 3 drivers are no longer self contained. psqlodbc.dll is used as
    the setup dll for all three drivers, hence no matter how you
    redistribute or install the drivers, you should always include this
    file.

    In addition, this driver fixes an annoying problem with recent builds of
    PostgreSQL on Redhat systems that have a particularly long compiler
    version string that caused a buffer overflow resulting in a GPF on
    Windows upon connection to the database.
    The driver is released under the LGPL, and can be downloaded from the
    Downloads page on the website at
    http://gborg.postgresql.org/project/psqlodbc/projdisplay.php

    === gborg.postgresql.org(This is the past history.) ===

    1.33 by hinoue Annotate
    Thu Feb 5 09:11:44 2004 (2 weeks, 3 days ago)
    Changed since 1.32: +3 -3 [Select for Diff]
    Diffs to version 1.32 (long / unified)
    Diffs ignoring whitespace to version 1.32 (long / unified)
    [7.3.0208]
    1) Change catalog functions to search 'public' schema if a user
    tries to search the user named schema and finds no record to
    return.
    2) Set the statement status to STMT_FINISHED(not STMT_PREPARED)
    if the pre execution causes an error.
    3) Adjust null terminator for SQL_C_WCHAR type.
    4) Change getCharColumnSize to return max size when the
    statement has no result.
    5) Cache the number of parameters for statements.

    1.32 by hinoue Annotate
    Tue Jan 6 09:58:22 2004 (46 hours, 12 minutes ago)
    Changed since 1.31: +3 -3 [Select for Diff]
    Diffs to version 1.31 (long / unified)
    Diffs ignoring whitespace to version 1.31 (long / unified)
    1) Correct the handling of SQL_C_ULONG (for *nix).
    2) Prevent plan deallocation errors when the transaction
    is in abort status.
    3) Avoid a connection failure when notice message arrives.
    4) Improve the handling of mutex(critical section).
    5) Correct the cursor open check.
    6) Change the Unicode driver to set the NULL terminator
    of SQL_C_WCHAR type data properly.
    7) Add some m(re)alloc error check.
    8) Add proper cleanup steps for some functions.
    9) Return proper min & max scale for timestamp data type.
    10) Return proper scale for timestamp data fields.
    11) Fix the bug that .009 numeric generates .9 output. (George A.J)

    1.31 by hinoue Annotate
    Tue Dec 9 05:01:38 2003 (44 hours, 22 minutes ago)
    Changed since 1.30: +3 -3 [Select for Diff]
    Diffs to version 1.30 (long / unified)
    Diffs ignoring whitespace to version 1.30 (long / unified)
    [7.3.0205]
    (for *nix)
    1. Detect -lsocket for some platforms.
    2. Handle unix domain sockets.
    3. EINTR safety for send/recv.
    4. Set TCP_NDEALY option for inet connections.
    <1-4: thanks to Hartmut Raschick>
    5. Use recursive mutex if possible.
    6. Add descriptor.c to Makefile.
    (for Windows)
    7. Automatic setting of client encoding for latin1(9).
    (common)
    8. Avoid those notorious core dumps when logging on hitting
    "null" data...
    <8: thanls to Hartmut Raschick>
    9. Removed a static variable for thread-safety.
    10. Improve the performance of keyset-driven fetch operation.
    11. Map (var)char type to SQL type more properly.
    12. Change create_params for NUMERIC type to (precision, scale).
    13. Add type cast to remove some compiler warnings.

    1.30 by hinoue
    Wed Nov 12 05:15:21 2003 (8 days, 1 hour ago)
    Changed since 1.29: +3 -3 [Select for Diff]
    Diffs to version 1.29 (long / unified)
    Diffs ignoring whitespace to version 1.29 (long / unified)
    [7.03.0204]
    1) Clear statements' cursors on commit/rollback.
    2) Change SQLColumns, SQLTablePrivileges to take show_system_tables
    option into account.
    3) When an ODBC 2.x application working with an ODBC 3.x driver
    1.calls SQLExecDirect, SQLExecute, or SQLParamData, and a searched
    2.update or delete statement was executed but did not affect any
    3.rows at the data source, the ODBC 3.x driver should return
    4.SQL_SUCCESS. When an ODBC 3.x application working with an ODBC
    5.3.x driver calls SQLExecDirect, SQLExecute, or SQLParamData
    6.with the same result, the ODBC 3.x driver should return SQL_NO_DATA.

    1.29 by hinoue
    Mon Nov 10 02:10:07 2003 (10 hours, 1 minute ago)
    Changed since 1.28: +3 -3 [Select for Diff]
    Diffs to version 1.28 (long / unified)
    Diffs ignoring whitespace to version 1.28 (long / unified)
    [7.03.0203]
    1) Add conversion from text to SQL_C_BINARY(bug report from Brad Wilson).
    2) Change SQLColumns, SQLTables etc to initialize the statement handle
    properly(bug report from Yutaka Tanida).
    3) Improve the handling of mutex under *nix(bug report from Steve Wampler).

    1.28 by hinoue
    Wed Nov 5 20:35:02 2003 (4 days, 15 hours ago)
    Changed since 1.27: +3 -3 [Select for Diff]
    Diffs to version 1.27 (long / unified)
    Diffs ignoring whitespace to version 1.27 (long / unified)
    [7.03.0202]
    1) Improve SQLColAttributes(SQL_COLUMN_DISPLAY_SIZE) (bug report from Benjamin Riefenstahl).
    2) Correct EN_set_odbc3 macro (bug report from tomas@nocrew.org(Tomas Skäre)).

    1.27 by hinoue
    Sat Oct 25 00:19:23 2003 (2 weeks, 2 days ago)
    Changed since 1.26: +3 -3 [Select for Diff]
    Diffs to version 1.26 (long / unified)
    Diffs ignoring whitespace to version 1.26 (long / unified)
    [7.03.0201]
    1) Revise the handling of descriptors and implement SQLCopyDesc.
    2) Handle data_at_execution columns for SQLSetPos or SQLBulkOperations.

    1.26 by dpage
    Wed Oct 22 09:07:25 2003 (2 weeks, 5 days ago)
    CVS Tags: REL-07_03_0200
    Changed since 1.25: +3 -3 [Select for Diff]
    Diffs to version 1.25 (long / unified)
    Diffs ignoring whitespace to version 1.25 (long / unified)
    Version number bump.

    1.25 by hinoue
    Sun Oct 19 22:37:42 2003 (3 weeks ago)
    Changed since 1.24: +3 -3 [Select for Diff]
    Diffs to version 1.24 (long / unified)
    Diffs ignoring whitespace to version 1.24 (long / unified)
    [7.03.0116]
    1. Fix a memory leak in case of updatable KEYSET_DRIVEN cursors.
    2. Change SQLMoreResults to initialize the cursor position.
    3. Hopefully, SQLDescribeCol() returns a more appropriate
    error code(SQLSTATE).

    1.24 by hinoue
    Fri Sep 19 05:25:17 2003 (7 weeks, 3 days ago)
    Changed since 1.23: +3 -3 [Select for Diff]
    Diffs to version 1.23 (long / unified)
    Diffs ignoring whitespace to version 1.23 (long / unified)
    1) Correct the return info for SQLGetInfo(.., SQL_CURSOR_COMMIT
    (ROLLBACK)_BEHAVIOR) call.
    2) Explicitly reject the SQLBrowseConnect call.

    1.23 by hinoue
    Mon Sep 15 04:25:03 2003 (8 weeks ago)
    Changed since 1.22: +3 -3 [Select for Diff]
    Diffs to version 1.22 (long / unified)
    Diffs ignoring whitespace to version 1.22 (long / unified)
    1. Serialize the connection use for communication(multi-thread).
    2. Let escape strings case-insensitive.

    1.22 by hinoue
    Tue Sep 2 07:25:53 2003 (2 months, 1 week ago)
    Changed since 1.21: +1 -1 [Select for Diff]
    Diffs to version 1.21 (long / unified)
    Diffs ignoring whitespace to version 1.21 (long / unified)
    Fix a bug when handling data_at_execution parameter array
    reported by Jol Valentine .

    1.21 by hinoue
    Wed Aug 27 06:17:53 2003 (2 months, 2 weeks ago)
    Changed since 1.20: +3 -3 [Select for Diff]
    Diffs to version 1.20 (long / unified)
    Diffs ignoring whitespace to version 1.20 (long / unified)
    1) Fix a bug on SQLSetStmtAttr(.., SQL_CONCURRENCY) reported by Shachar Shemesh.
    2) Apply a patch to changes the storage type of the debug "func" variables
    to be stored in the constant area of the program(Shachar Shemesh).
    3) Correct the column size in case of bytea as LO.

    1.20 by hinoue
    Wed Jul 30 21:57:50 2003 (3 months, 1 week ago)
    Changed since 1.19: +3 -3 [Select for Diff]
    Diffs to version 1.19 (long / unified)
    Diffs ignoring whitespace to version 1.19 (long / unified)
    1) Distinguish the rowset size for SQLFetch(Scroll) from that for
    SQLExtendedFetch.
    2) Implement SQLGetDiagFieldW() for the Unicode driver.

    1.19 by hinoue
    Fri Jul 11 06:47:17 2003 (4 months ago)
    Changed since 1.18: +3 -3 [Select for Diff]
    Diffs to version 1.18 (long / unified)
    Diffs ignoring whitespace to version 1.18 (long / unified)
    Improve SQLGetDiagField so that an MFC application reports
    error messages properly(bug report from Silvio Scarpati).

    1.18 by hinoue
    Wed Jul 9 04:09:11 2003 (4 months ago)
    Changed since 1.17: +3 -3 [Select for Diff]
    Diffs to version 1.17 (long / unified)
    Diffs ignoring whitespace to version 1.17 (long / unified)
    Add quotes around table names to use ::regclass in parse.c .

    1.17 by hinoue
    Sun Jun 29 23:51:24 2003 (4 months, 1 week ago)
    Changed since 1.16: +3 -3 [Select for Diff]
    Diffs to version 1.16 (long / unified)
    Diffs ignoring whitespace to version 1.16 (long / unified)
    Change SQLGetFunctions to contain ODBC3 APIs.

    1.16 by hinoue
    Thu May 29 22:30:33 2003 (5 months, 1 week ago)
    Changed since 1.15: +3 -3 [Select for Diff]
    Diffs to version 1.15 (long / unified)
    Diffs ignoring whitespace to version 1.15 (long / unified)
    1) Improve the SQL_C_VARBOOKMARK type handling.
    2) Cleanup copy_and_convert_field() a little.
    3) Set an error number and an error message for SQLAllocHandle(
    SQL_HANDLE_DESC).

    1.15 by hinoue
    Tue May 27 22:26:37 2003 (5 months, 2 weeks ago)
    Changed since 1.14: +3 -3 [Select for Diff]
    Diffs to version 1.14 (long / unified)
    Diffs ignoring whitespace to version 1.14 (long / unified)
    Fix a bug about a bookmark handling in SQLBulkOperaitons(SQL_ADD,..)

    1.14 by hinoue
    Tue May 27 19:23:41 2003 (5 months, 2 weeks ago)
    Changed since 1.13: +3 -3 [Select for Diff]
    Diffs to version 1.13 (long / unified)
    Diffs ignoring whitespace to version 1.13 (long / unified)
    Remove date cast(::date) from the conversion of {d escape before
    7.3 servers. 7.2 servers are poor in implicit cast from date ->
    timestamp without time zone.

    1.13 by hinoue
    Tue May 27 01:20:09 2003 (5 months, 2 weeks ago)
    Changed since 1.12: +3 -3 [Select for Diff]
    Diffs to version 1.12 (long / unified)
    Diffs ignoring whitespace to version 1.12 (long / unified)
    1) Correct the handling of bookmark in SQLBulkOperations.
    2) Correct the calculation of a global index in SC_pos_add.
    3) Cleanup global/rowset/resultset index handling a little.

    1.12 by hinoue
    Sun May 25 20:47:50 2003 (5 months, 2 weeks ago)
    Changed since 1.11: +3 -3 [Select for Diff]
    Diffs to version 1.11 (long / unified)
    Diffs ignoring whitespace to version 1.11 (long / unified)
    Correct a handling of offset in SQLBulkOperations.

    1.11 by hinoue
    Tue May 20 10:11:22 2003 (5 months, 3 weeks ago)
    Changed since 1.10: +4 -4 [Select for Diff]
    Diffs to version 1.10 (long / unified)
    Diffs ignoring whitespace to version 1.10 (long / unified)
    Fix a crash bug in SQLDriverConnect().

    1.10 by hinoue
    Tue May 20 06:39:28 2003 (5 months, 3 weeks ago)
    Changed since 1.9: +3 -3 [Select for Diff]
    Diffs to version 1.9 (long / unified)
    Diffs ignoring whitespace to version 1.9 (long / unified)
    The previous change wasn't in time of 7.3.0100.
    It belongs to 7.03.0101.

    1.9 by hinoue
    Mon May 19 06:12:09 2003 (5 months, 3 weeks ago)
    Changed since 1.8: +1 -1 [Select for Diff]
    Diffs to version 1.8 (long / unified)
    Diffs ignoring whitespace to version 1.8 (long / unified)
    1) Revert a *int8 as* DSN option to *numeric* for MS Jet.
    2) Add a SQL_CA2_SENSITIVITY_ADDTIONS mask to the reply for
    SQLGetInfo(.., SQL_ATTR_KEYSET_DRIVEN_CURSOR_ATTRIBUTES2)
    which would make a little OpenOffice happy.
    3) Fix a bug in SQLGetInfo(.., SQL_ATTR_ROW_NUMBER) for keyset_driven
    cursors.

    1.8 by dpage
    Thu May 15 04:24:40 2003 (5 months, 3 weeks ago)
    CVS Tags: REL-07_03_0100
    Changed since 1.7: +3 -3 [Select for Diff]
    Diffs to version 1.7 (long / unified)
    Diffs ignoring whitespace to version 1.7 (long / unified)
    Updates for 07.03.0100

    1.7 by dpage
    Thu May 15 03:38:16 2003 (5 months, 3 weeks ago)
    Changed since 1.6: +3 -3 [Select for Diff]
    Diffs to version 1.6 (long / unified)
    Diffs ignoring whitespace to version 1.6 (long / unified)
    Updates for 07.03.0001

    1.6 by hinoue
    Mon May 12 11:44:08 2003 (5 months, 4 weeks ago)
    Changed since 1.5: +3 -3 [Select for Diff]
    Diffs to version 1.5 (long / unified)
    Diffs ignoring whitespace to version 1.5 (long / unified)
    1) Add a *bytea as LO* DSN option button.
    2) Add japanese resources to psqlodbc.rc.
    3) Add a dialog for the driver change.

    1.5 by hinoue
    Wed Apr 23 05:49:47 2003 (6 months, 2 weeks ago)
    Changed since 1.4: +3 -3 [Select for Diff]
    Diffs to version 1.4 (long / unified)
    Diffs ignoring whitespace to version 1.4 (long / unified)
    1) Avoid password leak in the log.
    2) Reduce time() calls for the performance.
    3) Improve the handling of per Driver resource.
    4) #define HAVE_STRTOLL
    etc.

    1.4 by hinoue
    Wed Nov 27 04:30:53 2002 (11 months, 1 week ago)
    CVS Tags: REL-07_02_0005
    Changed since 1.3: +3 -3 [Select for Diff]
    Diffs to version 1.3 (long / unified)
    Diffs ignoring whitespace to version 1.3 (long / unified)
    Upgrade to 7.2.0005.

    1.3 by hinoue
    Thu Oct 10 02:37:54 2002 (13 months ago)
    CVS Tags: REL-07_02_0004
    Changed since 1.2: +3 -3 [Select for Diff]
    Diffs to version 1.2 (long / unified)
    Diffs ignoring whitespace to version 1.2 (long / unified)
    1) Change SQLDescribeCol or SQLColAttribute to return right ResultNumCols for
    keyset/static cursors.
    2) Change PG_TYPE_TEXT -> PG_TYPE_VARCHAR for character columns of the
    result of catalog functions (bug report from Mike Mascari).

    1.2 by hinoue
    Mon Sep 23 04:08:22 2002 (13 months, 2 weeks ago)
    CVS Tags: REL-07_02_0003
    Changed since 1.1: +3 -3 [Select for Diff]
    Diffs to version 1.1 (long / unified)
    Diffs ignoring whitespace to version 1.1 (long / unified)
    1) Removed most static variables for thread safety.
    2) Trial implementation of the thread safe driver under
    Windows.
    3) Fix a bug about DSN options setting.
    4) Fix a bug about Driver options setting.
    5) Implement SQLProcedureColumns().
    6) Changed default numeric precision/scale.
    7) Fix some memory leaks in Unicode driver.
    8) datetime -> timestamp with time zone since 7.0.
    9) Change manually started(using begin) transactions never
    be implicitly committed.

    1.1 by inoue
    Thu May 9 00:10:22 2002 (18 months ago)
    [Select for Diff]
    Add a file for version control.

    psqlodbc-REL-16_00_0005/docs/release.html000066400000000000000000003070211462406103600177370ustar00rootroot00000000000000 psqlODBC release notes

    psqlODBC release notes


    psqlODBC 16.00.0000 Release

    Changes:
    1. Use autoconf to check for stdbool.h.
    2. Make it possible to use standard bool on Windows.

    psqlODBC 15.00.0000 Release

    Changes:
    1. Fix a bug that SQLGetDiagField(SQL_DIAG_NUMBER) with SQL_HANDLE_DBC returns SQL_NO_DATA even if an error record exists.
    2. Fix a typo "RECISION" which should be "PRECISION".
    3. Enable SQLColumnPrivileges functionality.
    4. Currently SQLColumnPrivileges() call fails. Fix a typo which is the cause.
    5. Fix a bug that SQLColAttribute returns wrong column name.

    psqlODBC 13.02.0000 Release

    Changes:
    1. Fix a bug of CC_send_query_append() when the ignore_roundtrip_time flag is onRemove a mylog() call which is a dupilicate of the preceding MYLOG() macro call.
    2. Also direct use of mylog() should be avoided because mylog() uses lots of CPU.
    3. Noticed that the password field on the PostgreSQL Connection
    4. dialog is always focused when empty, even when other fields that appear earlier on the dialog (and in the tab order) are empty. This is only a minor annoyance, but it does seem like it would be contrary to the expectation of most users. I would propose separating the conditional to inform the user that the password is required, but still focus the first empty field.
    5. Remove REFCUR_SUPPORT, add FetchRefcursors setting
    6. Support fetching results from multiple refcursors
    7. Multiple result sets are returned if multiple refcursors are found Works with both ODBC CALL and PostgreSQL CALL syntaxes Query must be executed in a transaction to avoid cursors being closed Now works when output parameters are present.
    8. Named parameter binding support
    9. Use ODBC 3 column names for the result set of catalog functions.

    psqlODBC 13.01.0000 Release

    Changes:
    1. Fix a bug of CC_send_query_append() when the ignore_roundtrip_time flag is on.
    2. Add a call for SQLDescribeCol() before SQLExecute() to prepare-test.
    3. The diff of the result was reported by Mangold Fabian and will be fixed in the later commit.
    4. Add a *update returning* test case to insertreturning regression test.
    5. The diff of the result was reported by Patrick Cheung and will be fixed in the later commit.
    6. Let SQLDescribeCol() use parsed result when the current executed result is NULL.
    7. This change fixes the diff of prepare-test regression test reported by Mangold Fabian.
    8. Let SQLExecute() destroy the old result first.
    9. This change fixes the diff of insertreturning-test regression test reported by Patrick Cheung.
    10. Forget to apply disable_convert_func flag to VARCHAR and LONGVARCHAR.
    11. Prioritize DISABLE_KEEPALIVE checkbox over the disable_keepalive bit of ExtraOptions.
    12. Format check for ExtraOptions of setup dialog.

    psqlODBC 13.00.0000 Release

    Changes:
    1. Add support for CONVERT scalar function.
    2. Cope with the case that openssl libraries link msvc runtimes other than libraries which psqlodbc or libpq links.
    3. Call AC_CHECK_SIZEOF() or AC_CHECK_TYPES() macros at earlier stage where LIBS variable isn't set yet.
    4. These macros compile and run some programs. On some platforms(with some linker options like --no-as-needed in Lnux Gnu linker) the programs try to link libraries specified by LIBS variable at run time. There are some cases that the programs fail due to missing library which is actually not needed and AC_CHECK_SIZEOF() returns 0.
    5. Fix a compilation error with GCC 10 due to conflicting variable names.
    6. Patch by Paul Wise.
    7. Remove curr_param_result property of StatementClass and separate parsed result from the exec result.
    8. Add support for development with VC16(Visual Studio 2019).
    9. MSToolsVersion parameter of BuildAll.ps1 and of regress.ps1 are deprecated.
    10. Hold the first and last result for parametrized SQL statements with array of parameters.
    11. This would improve the performance of bulk inserts/updates etc.
    12. Revise the handling of QResultClass list.
    13. Introduce macros QR_concat(), QR_detach() and QR_next().
    14. Correct the handling of SQL_ROW_ERROR and SQL_ROW_SUCCESS_WITH_INFO.
    15. Remove the single table restriction in SC_set_SS_columnkey.
    16. Improve error reporting about SC_pos_reload_needed().

    psqlODBC 12.02.0000 Release

    Changes:
    1. Add a new *Display Optional Error Message* option.
    2. This option allows to display error messages other than primary one. Also add documentaition about the option and *Numeric as* option.
    3. Handle notice messages in libpq_bind_and_exec().
    4. Sets and resets a notify receiver around PQexecParams() or PQexecPrepared().
    5. Ignore PQtransactionStatus PQTRANS_ACTIVE in LIBPQ_update_transaction_status(). PQTRANS_ACTIVE isn't a transaction status.
    6. Improve execution of parameterized SQL statements with arrays of parameters by sending chunks of SQL statements.
    7. If SQL_ATTR_CURSOR_TYPE of an statement is SQL_CURSOR_FORWARD_ONLY, SQL_ATTR_CONCURRENCY is SQL_CONCUR_READ_ONLY and extended protocol isn't used, the batch execution of the statement is possible. A new option Batch Size was introduced for such cases.
      Batch Size: Split an array (of parameters) into chunks of Batch Size to execute statements. The last chunk may contain less than Batch Size elements. Setting 1 to this option forces the current one by one execution.
      Also turn off use_server_side_prepare option temporarily when batch execution is possible.
    8. Change SC_execute() so that it returns a return code which is not affetced by the preceding results. It's necessary for batch execution with arrays of parameters.
    9. Add a new option IgnoreTimeout.
    10. Some tools issue issue SQLSetStmtAttr(.., SQL_ATTR_QUERY_TIMEOUT,,) internally and sometimes it's difficult for users to change the timeout value. You can disable the timeout by turning on this option.
    11. An improvement for psqlodbc developers.
    12. Make it possible to call some shell scripts from other directories.

    psqlODBC 12.01.0000 Release

    Changes:
    1. Fix result-conversions regression test.
      1. Remove tests for abstime type because the type was removed in PG12.
      2. Update results for PG12's new floating point output format.
    2. Fix the bug that causes Error : A parameter cannot be found that matches parameter name�ene'.
      1. Check BuildResult(the result of drivers build) before building installers.
      2. Enclose the command part * Find_VSDir $vc_ver * with parentheses so that the subsequent * -ne "" * isn't considered to be a parameter.
    3. Cope with the removal of pg_class.relhasoids in PG12 correctly when retrieving updatable cursors.

    psqlODBC 12.00.0000 Release

    Changes:
    1. Fix the bug that SQLGetDescField() for Field SQL_DESC_COUNT returns SQLINTEGER value which should be of type SQLSMALLINT.
    2. SQLGetTypeInfo() filters SQL_TYPE_DATE, SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP for ODBC 2.x applications.
    3. Added support for scalar functions TIMESTAMPADD(), TIMESTAMPDIFF() and EXTRACT() functions.
    4. The macro IS_NOT_SPACE() is used for not pointers but integers.
    5. Fix a crash bug when SQLProcedureColumns() handles satisfies_hash_partition().
    6. The proargmodes column of satisfies_hash_partition()'s pg_proc entry is not null but the proallargtypes column is null.
      Per report from James.wang.

    psqlODBC 11.01.0000 Release

    Changes:
    1. Correct the rgbInfoValue returned by SQLGetInfo(SQL_TIMEDATE_FUNCTIONS, ..).
    2. Pointed out by Song X. Gao.
    3. Because the field 'relhasoids' was dropped in PG12, psqlodbc drivers would have some troubles with PG12 servers.
    4. Report and patch by Vladimir Kokovic.
    5. Register drivers {PostgreSQL ANSI} and {PostgreSQL Unicode} during installation on 64bit Windows so that users could use the same connection strings in both x86 and x64 environments.
    6. Per report from Grant Shirreffs.
    7. Correct the rgbInfoValue returned by SQLGetInfo(SQL_LIKE_ESCAPE_CLAUSE, ..).
    8. Pointed out by Grant Shirreffs.
    9. Fix a typo in SQLForeignKeys-ResultSet-Column. 'deferrablity' should be 'DEFERRABILITY'.
    10. Report from Alexander Roskamp.
    11. Correct the rgbInfoValue returned by SQLGetInfo(.., SQL_NUMERIC_FUNCTIONS(SQL_SYSTEM_FUNCTIONS or SQL_STRING_FUNCTIONS, ..).
    12. Pointed out by Grant Shirreffs.
    13. Bug fix: don't forget to set parameter numbers while handling escaped ODBC functions.
    14. Report and patch by Grant Shirreiffs.
    15. ix test_connection() in setup.c so that settings of conn_settings and pqopt option are reflected properly.

    psqlODBC 11.00.0000 Release

    Changes:
    1. Remove obsolete maps pointed out.
    2. POWER -> pow, CONCAT -> textcat, LEFT -> ltrunc, RIGHT -> rtrunc
      Patch by Daniel Cory.
    3. Remove connSettings option and/or pqopt option from the OutConnectionString parameter of SQLDriverConnect() when each option doesn't exist in InConnectionString parameter.
    4. The parameters should be cast because parameters of concat() function are variadic "any".
    5. Unbuffered-IO in Windows is incredibly slow. Instead call fflush() after fprintf().
    6. Add an alias DX of *Database* keyword for connection strings to avoid the use of "database" keyword which has a special meaning in some apps or middlewares.
    7. numeric items without precision are unlimited and there's no natural map between SQL Data types.
    8. Add an option *Numeric(without precision) as*.
    9. Fix a bug that SQLSpecialColumns() returns oid/xmin incorrectly when a table does not exist.
    10. Patch by Quan Zongliang.

    psqlODBC 10.03.0000 Release

    Changes:
    1. Put back the handling of lock_CC_for_rb variable. The variable lock_CC_for_rb should be held per connection.
    2. Per report from Ayman Samamry.
    3. Fix SQLGetTypeInfo() so that it filters SQL_TYPE_DATE, SQL_TYPE_TIME or SQL_TYPE_TIMESTAMP for ODBC 2.x applications.
    4. Per report from Oleg Tonkikh.
    5. Revise ConfigDSN() so that it handles the 4th parameter(lpszAttributes) correctly.
    6. Per report from Haribabu Kommi.
    7. Fix a crash bug when handling error messages. Also modified some error messages.
    8. Let SQLTables() or SQLTablePrivileges() show partition tables.
    9. Fix build on Solaris defined(__SUNPRO_C) using Solaris Studio
    10. Reduce DB access to pg_class or pg_index by caching relhasoids, relhassubclass etc. It would improve the performance of SQLSetPos() or SQLBulkOperations() very much in some cases.
    11. Per report from Takayuki Tsunakawa.

    psqlODBC 10.02.0000 Release

    Changes:
    1. It's safer to call setlocale(LC_CTYPE, "") than calling setlocale(LC_ALL, "").
    2. Report and patch by Mario De Frutos.
    3. Avoid replacing effective notice messages.
    4. Report from Wolfgang Apolinarski.
      Patch by Clemens Ladisch.
    5. Handle MALLOC/REALLOC errors while fetching tuples more effectively.
    6. Per report from Haruka Takatsuka.
    7. Make SQLSetPos(SQL_DELETE/SQL_REFRESH) more effective. Because queries calling currtid(2) like
      select .. from .. where ctid=currtid2(.., ..)
      cause Seq Scan, their execution may be very slow.
      It is better to execute queries using subqueries like
      select .. from .. where ctid=(select currtid2(.., ..))
      because they cause Tid Scan.
      Report and changes by Tsunakawa Takayuki.
    8. Fix a crash bug in AddDeleted().
    9. Report and patch by Takayuki Tsunakawa.

    psqlODBC 10.01.0000 Release

    Changes:
    1. Call Get-VSSetupInstance to detect Visual Studio installations whose version >= 15 when VSSetup module is available.
    2. Review the handling of @@IDENTITY when a column's default is nextval(a_sequence) but the column isn't a serial. Unfortunately the function pg_get_serial_sequence() doesn't work for sequences which aren't serial type.
    3. Add add an option -NoPDB to buildInstallers.ps1.
    4. The switch option can be specified so as to exclude PDB files from the installers.
    5. Fix a bug in pgdebug_realloc().
    6. Free any data at exec params before the statement is executed again or the next set of parameters is processed. If not, then there will be a memory leak when the next SQLParamData/SQLPutData is called.
    7. Per report from Mihai Giurgeanu
    8. Review the level of MYLOG, QLOG.
    9. Divide *level 1(detail)* log into *level 1(tuple level)* log and *level 2(detail)* log.

    psqlODBC 10.00.0000 Release

    Changes:
    1. Fix multibyte handling of ansi driver.
    2. Handle PG 10 identity columns.
    3. For PG10 servers, we will never see "unknown" output columns.
    4. Improve @@identity handling.
    5. Use multibyte-aware eatTableIdentifiers() instead of next_name_token().
      Use identifierEscape() to escape single quotes or double quotes.
    6. PG_PRINTF_ATTRIBUTE instead of printf in __attribute__((format(printf, .., ..))) function attribute.
    7. Review the use of encoded_nextchar().
    8. Remove variables which work in conjunction with encstr(encoded_str) so as to avoid misleadingness.
    9. Use pg_get_serial_sequence() to get serial sequence of identity columns or serial columns.
    10. pg_get_serial_sequence() for identity columns became available in PG 10.
    11. Preparation for development with VC15(VS 2017).
    12. Fix the bug that 'create table T_$001 (\81c)' fails when useServerSidePrepare is turned on.
    13. Per report from Gregory Pruss.

    psqlODBC 09.06.0500 Release

    Changes:
    1. Fix a segfault on ResolveOneParam() function while executing a query after calling SQLSetStmtAttr(.., SQL_ATTR_APP_PARAM_DESC, an_ARD_for_another_statement, ..).
    2. Fix a linkage error when doing installcheck for test/win.mak.
    3. Report and patch by Kazuki Uehara.
    4. Fix a bug when fetching bytea field to SQL_C_BINALY data. It's bad to double count of bytes.
    5. Handle '$'s in identifiers correctly. Also take multibyte characters into account in identifiers.
    6. Reduce the use of snprintfcat(or SPRINTFCAT_FIXED macro) as much as possible. Instead use PQExpBuffer library without having to worry about buffer length.
    7. Use macro MYLOG instead of function mylog in preparation for later changes and unify mylog() and inolog() using level parameter. Enable the compiler to check the format string against the parameter of mylog() by adding __attribute__((format(printf,.,.))) to the declaration of mylog(GCC only). Using this mechanism, check and fix many discordances of parameters.
    8. Implement myprintf() which prints logs according to printf format and make logs a little easier to read using the macro MYPRINTF() which calls myprintf().
    9. Introduce token control while parsing. Detect *select .. into* or *select ... for update* and suppress *declare .. cursor for* clause in declare/fetch mode using the mechanism.
    10. Add __FILE__, __FUNCTION__, __LINE__ to MYLOG.
    11. Fix an parameter unmatch error which would cause a crash.
    12. Removed some qlogs, changed some qlogs to MYLOG and added some qlogs.
    13. Move the implementation of GetExeName() from psqlodbc.c(psqlsetup.c) to mylog.c.
    14. Remove the GssAuthUseGssapi option completely.
    15. Fix bug that calls strdup() for NULL pointers.
    16. Per report from Ding, Haiqiang.
    17. Detect fast shutdown while connecting.
    18. Put back the behavior when conversion errors from the current locale to SQLWCHAR occur. Simply returns zero length string instead of erroring out.
    19. Per report from Andrus.
    20. Add level parameter to Commlog/Mylog option of setup program.
    21. Add __attribute__((format(printf,3,4))) to the declaration of snprintfcat().
    22. Allow PROCCALL in ReadOnly mode.
    23. Per report from Matej Mihelic.

    psqlODBC 09.06.0410 Release

    Changes:
    1. Fix buffer truncations. The truncations occurred when concatenating 'RELEASE xxxx...;' and 'SAVEPOINT xxxx....'.
    2. Per reported by Pavel Raiskup.
    3. Correct the behavior of snprintfcat() on Windows using posix_vsnprintf() instead of _vsnprintf().
    4. Handle StrLen_or_IndPtr argument of SQLBindParameter() properly when StrLen_or_IndPtr doesn't point to SQL_NTS and conversions between SQLWCHAR and SQLCHAR occur.
    5. This change fixes MSACCESS errors reported by Christian Ullrich and Robert Ball.
    6. Make quote_table() and ti_quote() thread safe.This change fixes "relation does not exist".
    7. Per report and patch by Scott Beil.

    psqlODBC 09.06.0400 Release

    Changes:
    1. Reorganize the language conversion between the current locale and unicode.
    2. Make a function setup_getdataclass() separating from long confusing if-block in convert_text_field_to_sql_c() and clarify the parameters.
    3. Implement SC_get_localtime() and reduce time()/localtime() calls.
    4. Visual C++ 14 provides snprintf().
    5. Fix a crash bug in SQLBulkOperations() under use_declare/fetch off mode.
    6. Clean up the use of 'internal' member of StatementClass.
    7. Fix an infinite loop of CC_on_commit. The loop occurs when checking whether cursors are alive using 'MOVE 0' in CC_clear_cursors().
    8. Fix the bug, skip malloc(0) in build_libpq_bind_params(). malloc(0) seems to return NULL on AIX, whereas it returns non-NULL on Windows or linux.
    9. Per reported by Keith Handlon.
    10. Add support for foreign tables and matviews in SQLTables.
    11. Documentation fix for the 'PROTOCOL=' option. It's out of sync with the current driver behavior (since 09.05.0100).
    12. Patch by Jan Wieck.
    13. Fix more bugs with returning NULL for malloc(0).
    14. Patch by TAKATSUKA Haruka.

    psqlODBC 09.06.0310 Release

    Changes:
    1. Fix a crash bug when connecting from MSACCESS(Microsoft Jet)
    2. Per reported by Robert Ball.
      This occurs when MSACCESS(Jet) calls SQLConnectAttr(.., 30002, ..) => ucs2_to_utf8() and about to call mylog() with a NULL dereferenced pointer parameter.

    psqlODBC 09.06.0300 Release

    Changes:
    1. Implement SQLSet/GetConnectAttr() for some driver specific options.
    2. Modify the code about UNKNOWNS_AS_LONGEST of the Unknown Sizes option so that it works properly.
    3. Revise the handling of show oid column and row versioning option.
    4. Revise the use of pgtype_xxxx() in catalog functions.
    5. Replace pgtype_xxxx() whose 1st parameter is StatementClass with pgtype_attr_xxxx().
    6. Also use macros for pgtype_xxxx() calls which have PG_ATP_UNSET, PG_ADT_UNSET or PG_UNKNOWNS_UNSET parameters.
    7. Remove the use of PG_STATIC and UNKNOWNS_AS_DEFAULT.
    8. Remove UNKNOWNS_AS_CATALOG of Unknown Sizes option.
    9. Use symbols defined in catfunc.h instead of literal column numbers in SQLGetTypeInfo(), SQLSpecialColumns() and SQLTablePrivileges().
    10. Fixes about SQLDescribeCol() or SQLColAttribute().
      1. Report the size of constant strings using Unknown Sizes as Longest.
      2. Correct the inconsistency between the sqltype of PG_TYPE_TEXT or PG_TYPE_UNKNOWN and the size in case of Unknown Sizes as Longeset.
    11. Fix a bug about Unicode driver for ansi apps.
    12. Fix a dangling reference in CC_lookup_characterset() introduced.
    13. Simple implementation of get_environment_setting() on non-Windows platforms. If the codeset part of the current locale is UTF8, set the client_encoding to 'UTF8'. Take * set client_coding='...' * into account in check_client_coding().
    14. Revise the handling of client encoding so as not to forget the update of related items(ccsc or mb_maxbyte_per_char).
    15. Change the max byte per char of UTF8 from 6 to 4.
    16. For Unicode drivers, when SQLConnect() or SQLDriverConnect() instead of SQLConnectW or SQLDriverConnectW is called, use the same client encoding as ANSI version of drivers use.Stop using percent-encoding to store the conn_settings option in odbc.ini.
    17. Stop using percent-encoding to store the conn_settings option in odbc.ini.
    18. Add #ifdef UNICODE_SUPPORT where there should be.
    19. Introduce locale_encoding which corresponds to the locale. For non-Windows platforms determine the locale encodings from the current locale.
    20. Make a function convert_text_field_to_sql_c() simply extracting from long confusing code and clarify the parameters for subsequent modifications.
    21. Handle locales in non-Windows platforms and overhaule the language system.
    22. convert bad to use lf_conv here.
    23. Add __STDC_ISO_10646__ check to confirm that wchar_t means unicode.
    24. Error out when SQLSetPos() skips updates.
    25. Don't reset the status of Keyset in case of updates.
    26. This fixes the bug about repeated updates using SQLSetPos().
    27. Correct the inappropriate use of set_nullfield_int2().
    28. Review the handling of OUTPUT parameters in SQLProcedureColumns().
      1. If there are OUT, INOUT or TABLE arguments, ignore RETURN values.
      2. OUT parameters of functions with returning SETOF should be treated as SQL_RESULT_COL rather than SQL_PARAM_OUTPUT.
      3. Also treat table output arguments as SQL_RESULT_COL because functions returning table are equivalent to using one or more OUT parameters plus marking the function as returning SETOF record (or SETOF a single output parameter's type).
    29. Use the same CPPFLAGS as well as CFLAGS/LDFLAGS to build regression tests as used to build driver.Also uchar.h header checking for later use.
    30. Fix a crash bug when the locale isn't set connection.

    psqlODBC 09.06.0200 Release

    Changes:
    1. Start transactons first before calling SQLEndTran().
    2. The failure of libpq_bind_exec() which returns NULL doesn't mean a FATAL error. Also make a check for disconnected connections.
    3. Handle output parameters properly in build_libpq_bind_params.Also handle return values properly.
    4. Make check of connection lost.
    5. Revise recent lost connection check.
    6. Check the lost connection
      1. at the beginning of ODBC APIs.
      2. at the beginning of FE-BE communications using extended protocol.
    7. Stop specifying parameter datatype oids in parse message. Unfortunately it is inflexible and rather harmful. Though I don't know if it has much meaning, use cast instead just in order to keep regression test results. It's not necessary to cast any more the 2nd parameter of {call a_b_c_d_e(?, ?, ?, ?, ?)} in odbc-escapes-test.

    psqlODBC 09.06.0100 Release

    Changes:
    1. Optimization of a build system.
    2. some adjustment and support Visual Studio 2015 for Windows.
    3. Use SIZEOF_LONG_INT to check whether SQLROWSETSIZE exists.
    4. SIZEOF_LONG_INT is defined in UnixODBC headers, while SIZEOF_LONG is defined by psqlodbc's ./configure. In odbcapi.c, we use it to determine what format modifier, %ld or %lld, to use for pointers. (Why don't we use %p?). We should rely on our autoconf check for that. In odbcapi.c, however, the check should match that in the ODBC headers, to determine whether SQLROWSIZE exists, so we should use SIZEOF_LONG_INT.
    5. Fix the bug messages handle.
    6. handle_error_message() and handle_notice_message() were unified into handle_pgres_error() in the wrong way. Unfortunately handle_error_message() never handled notice messages and set positive errornumbers which mean error_not_a_notice in psqlodbc. I renamed the constant CONNECTION_SERVER_REPORTED_ERROR to CONNECTION_SERVER_REPORTED_SEVERITY_FATAL and the constant CONNECTION_SERVER_REPORTED_WARNING to CONNECTION_SERVER_REPORTED_SEVERITY_ERROR so as to avoid confusion.
      Reported by Shinji Mecha.
    7. Allow setting isolation level before the establishment of connection.
    8. Fixed return proper sqlstate error 08S01 in case of communication link failures.
    9. Patch by Tsunakawa,Takayuki.
    10. Check the existence of directory for logging.
    11. Handle PG_DIAG_SEVERITY_NONLOCALIZED for servers whose version >= 9.6 so as to detect FATAL message properly.
    12. Now default isolation level is server's default instead of fixed SQL_TXN_READ_COMMITTED.
    13. Patch by Tsunakawa,Takayuki.
    14. Make sure the isolation level is SQLUINTEGER and add the declaration of CC_get_isolation().
    15. Change the default for ExtraSysTablePrefixes to an empty string.
    16. Use lo_lseek64(lo_tell64) instead of lo_lseek(lo_tell) if the server's version >= 9.3. We are now able to handle > 2GB BLOBs.
    17. Implement SQL_FECTH_BY_BOOKMARK operation of SQLBulkOperations properly.
    18. Enable SQLBulkOperations in declare/fetch mode using long (>=12bytes) bookmarks.
    19. Formerly the driver offered very simple bookmark support -- it is just the current row number. Now the driver offers more verbose bookmarks which contain KeySet information (CTID (+ OID)). Though they consume 12bytes (row number + CTID) or 16bytes (row number + CTID + OID), they are useful in declare/fetch mode.
    20. a hack to handle boolean items in VBA with MS Access.
    21. VBA seems to transform the where condition a_boolean_item=True into ("a_boolean_item" = 1) which causes an ERROR:Operator does not exist boolean = integer . Here transforms it into ("a_boolean_item"='1') which seems safe in anyway.
    22. Add a new option 'pqopt' which specifies libpq connection parameters as a conninfo style string.
    23. The string must be enclosed with braces {} e.g. pqopt={sslcert=... sslkey=... sslrootcert=...} in the case of connection strings. Though host, port, dbname, user, password, sslmode, keepalives_idle or keepalive_interval parameters can be set using this option, they are ordinarily set by other options. When some settings for those parameters conflict with other ordinary options, connections are rejected.
    24. Fix a corner case when parsing connection strings enclosed with braces.
    25. As tuple_updated item in AddUpdated(), the parameter should be used. Deriving from other items caused bad results.
    26. Change the default of ByteaAsLongVarBinary from 0 to 1.

    psqlODBC 09.05.0400 Release

    Changes:
    1. Enable COMMLOG and MYLOG button.
    2. Default of *level of rollback on errors* is default(statement) not transaction.
    3. Fix the bug SQLGetDescFieldW or SQLColAttributeW mistakenly returns SQL_ERROR.
    4. Move src/*.exe to exe/*.exe on Windows.
    5. Also use fc command instead of diff command on Windows. Fix a compilation error in large-object-data-at-exec-test.c regarding a type declaration in the middle of a code block.
      Patch by Michael Paquier.
    6. Ignore the difference between CR LF, LF and CR line break when comparing expected and result output.
    7. Prior to Visual Studio 2015 Update 3, the hook functions of type PfnDliHook __pfnDliNotifyHook2 and __pfnDliFailureHook2 were non-const.
    8. They were made const to improve security (global, writable function pointers are bad). If for backwards compatibility you require the hooks to be writable, define the macro DELAYIMP_INSECURE_WRITABLE_HOOKS prior to including this header and provide your own non-const definition of the hooks.
      The following information is from Dave Cramer(davecramer@gmail.com).
    9. Fix a regression test some failures.

    psqlODBC 09.05.0300 Release

    Changes:
    1. Largely reduce overhead of localtime() in SQLFetch
    2. localtime() is a very costly system call causing serious grief on performance of the driver for OLTP-type applications using a lot SQLFetch and this one is being called for all data types when performing an in-line conversion, while it is being used only in the case where some of the date and/or timestamp fields are not initialized. While testing performance of an internal application, this patch has proved to improve the overall performance of an application by 20%.
    3. Fix the use and the implementation of getNthValid().
    4. Fix the handling of boundary_should_be_adjusted case when a rowset is cut in the middle of cached rows. Also fix the row info of SQL_ADDed tuples.
    5. Estimate the rowsetSize including deleted tuples correctly so that rowset can be effectively handled.
    6. Set once_reached_eof status when useDeclareFetch=0 so that QR_num_total_read() macro works well.
    7. Don't forget to call CC_on_abort_partial() when rollback back to a savepoint. Now the driver passes cursor-block-delete test.
    8. Refine SQLFetchScroll() for the orientations other than SQL_FETCH_NEXT/PRIOR.
    9. Discard move_from_the_last stuff and call move_cursor_to_last() instead.
    10. Refine cursors with KEYSET using oid or oid alternative as far as possible.
    11. Preparation for handling inheritance.
    12. Convert tableoid to relation name in case of inheritance.
    13. fix buffer overrun in logging, and code cleanup.
    14. Patch by Tsunakawa, Takayuki.
    15. Implement SQL_QUERY_TIMEOUT.
    16. Patch by Tsunakawa, Takayuki.
    17. 'for' loop initial declarations are only allowed in C99 mode.

    psqlODBC 09.05.0210 Release

    Changes:
    1. Makefile.am in order to add new test case and expected output to distribution.
    2. Use LoadLibraryEx for gxalib.dll load search path.

    psqlODBC 09.05.0200 Release

    Changes:
    1. Clear the parsed result before executing simple query so that SQLRowCount() returns.
    2. This fix the bug reported by Walter Willmertinger.
    3. Fix NULL dereferences which causes application crash.
    4. Patch by Tsunakawa, Takayuki.
    5. Don't initialize next_in_cache or rowstart_in_cache info when scrolling (block) cursors in declare/fetch mode.
    6. This fixes the bug reported by John Kew.
    7. Correct the detection of eof in useDeclare/fetch mode.
    8. This change fixes the bug about fetching prior after scrolling next until eof reported by BenS.
    9. Fix the bug about MONEY type.
    10. Consider decimal_digits of SQL_TIME (and time field of PostgreSQL).
    11. Don't forget to update num_total_read field of QResultClass record in case 'fetch 0 rows' after 'move'.
    12. This fixes the bug 'When fetching a row "behind" the rowset by "fetch absolute" only the first ones of the result set can be fetched.' reported by Bernhard Goebel.
    13. Make sure that EOF occurs when 'fetched < fetch requested'.
    14. Correctly handle SQLGetData() when the target type is SQL_C_WCHAR and the buffer is small to get the whole data for some data types such as bool, date, time ... etc.
    15. Refine SQLGetData().
      1. Unify midtemp and moneytemp.
      2. Variable wconverted is no longer needed.
      3. Pre_convert for PG_TYPE_BOOL is not needed.
      4. It's better to take the same road even in case of pre_convert.
    16. Fixed possible once to build test suite in a different place other than the source code is, it's not now.
    17. CHAR causes a compilation error in some environment. Use char instead of CHAR.
    18. Correctly judge the SQLSTATE 01S06(Attempt to fetch before the result set returned the first rowset) for SQL_FETCH_PRIOR operations of SQFetchScroll.
    19. Checking a flag bit mistakenly resets other flag bits.
    20. Patch by Tsunakawa, Takayuki.
    21. setup.c:test_connection() calls EN_Constructor() twice, leaking small memory.
    22. Patch by tsunakawa, Takayuki.
    23. The existing memory is not freed upon realloc() failure.
    24. PGAPI_BindCol() doesn't check the failure of extend_getdata_info().
      Patch by Tsunakawa, Takayuki.
    25. The statement linked list is not properly chained, which throws away some statements.
    26. Patch by Tsunakawa, Takayuki.
    27. LINKMT is not used in the build process.
    28. ADDL_INC should be ADD_INC. Just a typo. The CLEAN target doesn't delete .pdb files.
      Patch by Tsunakawa, Takayuki.
    29. Fix a parameter unmatch of snprintf.
    30. In Windows the use of external variables timezone, tzname and daylight are deprecated. Use _timezone, _tzname and _daylight instead.
    31. SQLS(G)etDescRecW instead of SQLS(G)etDescRec for Unicode driver.
    32. The third stricmp() in writeDriverCommoninfo() is useless, because the second one causes the function to return.
      1. SC_get_errormsg() definition is repeated twice in succession.
      2. In info.c:SQLGetInfo(), "len = 0" is unnecessary because len is assigned at the end of the function.
      3. In execute.c:PGAPI_ExecDirect(), flag doesn't need to be set as its value doesn't change.
      4. PODBC_PER_STATEMENT_ROLLBACK is not used.
      Patch by Tsunakawa, Takayuki.

    psqlODBC 09.05.0100 Release

    Changes:
    1. Use libpq for all communication with the server
    2. Previously, libpq was only used for authentication. Using it for all communication lets us remove a lot of duplicated code. libpq is now required for building or using libpq.
    3. Remove support for protocol versions older than 3.
    4. Protocol version 3 was introduced in PostgreSQL 7.4, so this means that we no longer support server versions 7.3 or older. This simplified the code, making maintenance easier.
    5. Remove support for ODBC versions older than 3.51.
    6. The official binaries have been compiled in 3.51 mode for a very long time, so this has no effect on the official binaries.
    7. Avoid one round-trip to the server when establishing connection.
    8. When connecting to a server, the driver used to issue a query to determine the client_encoding setting being used, but that was unnecessary because all supported server versions send that information as part of the connection handshake when a connection is established. Remove the extra query, which should make connecting over a high-latency link faster.
    9. Report max length of 'name' fields correctly.
    10. PostgreSQL columns of type 'name', used e.g. in catalog tables to hold names of relations and other objects, were reported as having type VARCHAR(64). However, the real max length of a name field is only 63 bytes.
    11. Remove 'Optimizer' configuration option
    12. You can use the generic ConnSettings option with value "set geqo=off", to disable GEQO.
    13. Fix title in 32-bit Unicode drivers setup dialog
    14. The title on the 32-bit Unicode drivers's setup dialog on Windows incorrectly said "ANSI".
    15. Don't export private symbols that are not part of the ODBC interface
    16. This was causing problems when the driver was loaded together with another dynamically loaded library with a function of the same name. This was reported to happen when loading the odbc_fdw foreign data wrapper into a PostgreSQL server, because both the PostgreSQL server and the ODBC driver contain a function called check_client_encoding().
    17. Report a sensible SQL_DESC_OCTET_LENGTH value for result set columns of type 'unknown'
    18. If a query returns a column of type 'unknown', as happens e.g. in a query like "select 'foobar' from table" where the datatype of the constant 'foobar' is not specified, the SQL_DESC_OCTET_LENGTH property of the column was returned as invalid. Report it the same as 'varchar' field with no explicit length, instead.
    19. Fix quoting bugs in sending integer query parameters to server
    20. The drivers used to assume that if a parameter's SQL type is SQL_INTEGER or SQL_SMALLINT, the value does not require quoting when its send to the server. For example, "SELECT ?", with parameter 123 was translated to "SELECT 123", when UseServerSidePrepare was not enabled. However, there was no check that the query parameter in fact contained a valid integer, when replacing the parameter markers with their values. Also, in a query like "SELECT 0-?", a negative value needs to have parens around it, as in "SELECT 0-(-123)".
    21. Don't reset autocommit when a connection is established
    22. If autocommit is disabled on a connection, by calling SQLSetConnectAttr(SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0), before connecting with SQLDriverConnect(), autocommit was incorrectly reset back to on when the connection was established.
    23. Send datatype information for query parameters, when known
    24. If a query parameter is bound with a specific SQL type, pass on that information to the server. This makes the behaviour of queries like "SELECT '555' > ?" more sensible, where the result depends on whether the query parameter is interpreted as an integer or a string.
    25. Use libpq defaults for Server, Username and Database settings
    26. Server, Username and Database settings can now be left empty, in which case the corresponding libpq defaults will be used. The libpq default is to connect to a local server over Unix domain sockets (on Unix systems) or to localhost over TCP/IP (on Windows), if Server is left empty. The default username is the current operating system user, and the database to connect to is a database with the same name as the user. These built-in defaults can be changed by environment variables, however. This is particularly useful for connecting to a local installation via Unix domain sockets, as that is the default when Server is left empty, and was difficult to configure otherwise.
    27. Fix bug in parsing E'' literals
    28. The driver needs to parse a query string to determine whether a '?' character is a parameter marker, or if it's inside a quoted string or a SQL comment. This parsing did not correctly handle E''-style strings.
    29. Remove 256 byte limit on the length of NOTICE messages
    30. There was a built-in limit of 256 bytes on the length of NOTICE messages received from the server. Strings larger than 256 bytes were not returned to the application. That limit has been removed.
    31. Fix parsing of strings containing escaped quotes with Parse=1
    32. This fixes issues in extracting metadata like result set column names, with the Parse=1 option.
    33. Fix connecting with a user or database name that contains spaces or quotes
    34. User and database names were not quoted correctly when building a connection string. A different method is now used for sending those parameters, which doesn't require quoting and escaping.
    35. Remove support for so-called "premature execution"
    36. Premature execution was a method for getting information about a result set of a query, before SQLExecute() was called. That was always dangerous, as any side-effects of the query would happen, even if the application did not call SQLExecute() after all. With protocol version 3, there is a safer way to do this. This also removes the DisallowPremature configuration option, as the driver never does premature execution anymore.
    37. Fix buffer overrun when the server reports an error message longer than 4096 bytes
    38. If the server returned an error longer than 4096 bytes, we would overrun the buffer by two bytes. If you're unlucky, that could lead to a crash. That consistently happened on Windows.
    39. Improve parsing of INSERT INTO statements, for @@identity support
    40. The code that parses INSERT INTO statements, to extract the name of the target table, got confused by values containing dots, and other things. Improve the parsing support to handle a wider range of INSERT statements.
    41. Fix crash in SQLTables() function, if search_path was set to a non-existent schema
    42. The server-side current_schema() function returns a NULL if search_path is set to a non-existent schema, and the driver code was not prepared for a NULL result.
    43. Fix buffer overrun when connecting, and KeepaliveTime and KeepaliveInterval were both set
    44. If the server returned an error longer than 4096 bytes, we would overrun the buffer by two bytes. If you're unlucky, that could lead to a crash, and it consistently did on Windows. Per report from Andrus Moor.
    45. Set an error message when password is required to connect.
    46. In previous versions, if a connection fails because the server requires a password and no password was supplied. Per report from "PSequel Support".
    47. Improve parsing of INSERT INTO statements to support @@identity
    48. Patch by Christian Ullrich.
    49. Fix SQL_DATA_AT_EXEC processing for large objects.
    50. Reported by Vadym Krevs.
    51. The server decide if SQL_LONGVARBINARY means a bytea or large object.
    52. This reverts the behaviour of SQL_LONGVARBINARY parameters.
    53. Fix handling of return value in {? = CALL ... } syntax.
    54. When sending the query to the server, need to use the number of parameters calculated by build_libpq_bind_params(), which excludes the OUT parameter, rather than the original number of parameters. Reported by Haribabu Kommi.

    psqlODBC 09.03.0400 Release

    Changes:
    1. Rip out broken retry/timeout logic in SOCK_wait_for_ready.
    2. At a quick glance, the logic looked like retry with progressive timeout, but it was horribly broken. First of all, the timeout was only used if retry_count was passed as 0. And in that case, the timeout was 0. So retry_count == 0 actually meant "check if data can be read/written without blocking", while retry_count > 0 meant "sleep until data is available". There was also some code to handle retry_count < 0, but that was dead code because none of the callers passed a negative value. The hardcoded max. retry count of 30 retries was quite bogus too. Filling the output buffer more 30 times is not necessary an error, and it's not clear that the ssl library could not return SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE more than 30 times. Unlikely, yes, but possible. So, just rip out the retry_count and progressive timeout logic. Replace the retry_count argument with a simple "should block?" argument. I didn't dare to remove the condition that we always wait if SSL is enabled, although I don't understand that at all. But perhaps there's some well-hidden reason for that. Per report from Prakash Itnal, although this just removes the broken code, and won't enable the kind of a timeout that he wanted.
    3. Clean up Windows makefiles.
    4. Get rid of the CPU and CPUTYPE variables in win64.mak. Instead, assume that the TARGET_CPU variable has been set correctly in the environment. TARGET_CPU is set by "setenv" script that comes with the Microsoft Visual Studio C compiler package. It never worked to pass a "CPU=x86" and using a x64 compiler, for example, so seems better to determine the correct target from the environment, than fail with a cryptic error message if the CPU argument and the environment don't match. To build 32-bit binaries with win64.mak, simply do "setenv /x86" before running "nmake -f win64.mak". Similarly, to build 64-bit binaries, use "setenv /x64". It should now be possible to build both 32-bit and 64-bit binaries with win64.mak. Ideally, we could now remove win32.mak altogether, but there are small differences between win64.mak and win32.mak in the build options that they use. I don't understand the differences enough to dare to remove win32.mak yet. The CPU=AMD64 alias for x64 is no longer supported (as the whole parameter is now gone). Also do whitespace & other cosmetic fixes to win32.mak and win64, to make them more similar. This helps when comparing the two with "diff". Remove remains of the long-gone "MULTIBYTE" setting (it was misspelled in win64.mak, anyway)
    5. Fix crash if connection is closed while sending a query to the server.
    6. Some functions reset conn->sock to NULL on a socket error, so we must not keep a copy of it in a local variable. Also, SOCK_get_id should check for NULL argument like all the rest of the SOCK_get/put_* functions.
    7. Rewrite the conversion functions between strings and SQL_NUMERIC_STRUCT.
    8. Aside from making the functions more readable and faster, this fixes a number of bugs:
      1. When converting a large number from decimal to binary, the least significant byte might be wrong.
        reported by Walter Couto.
      2. In binary->decimal conversion, a number with small precision but large scale caused a "Floating point exception".
      3. In binary->decimal conversion, building the final string was wrong, picking up "digits" from outside the reserved stack space, if scale was larger than 40
      4. The param_string buffer allocated for the result of binary->decimal conversion was too small.
      Also add a test cases for all of these bugs.
    9. Fix ODBC function escape for SPACE function.
    10. Make sure that the psqlodbc ANSI driver is ODBC3.5.
    11. Register 64bit XA DLL on installation
    12. Changes by a patch from Craig Ringer
    13. Fix potentially uninitialized local pointer access which causes.
    14. fatal compilation errors on vs2012/2013 reported by Craig Ringer.
    15. Fixed ctype_length() is missing the length for SQL_C_BIGINT and SQL_C_NUMERIC.
    16. patch by John Smith.
    17. Fix access to unallocated memory in IAsyncPG.
    18. IAsyncPG was deleting its self, then returning an instance variable by value. This is probably going to be safe pretty much all the time, but it's still a memory error, and DrMemory (a Windows valgrind-alike)
    19. SQL_NUMERIC_STRUCT was not available until ODBC 3.0.
    20. Also add a prototype for ResolveNumericParam for readability.
    21. Increase digits used to convert from REAL/DOUBLEs to strings so that the reverse conversions can recover original values.
    22. Patch originally by John Smith.
    23. Clear errors for prepared statement for subsequent executions.
    24. Fix the problems using SQLFetch on prepared INSERT with RETURNING clause.
    25. reported by John Smith.
    26. Fix use of server-queried version before connection.
    27. psqlODBC attempted to use the version that's queried from the server before it was obtained from the server during the connection setup. Because the server version is initialized to 0.0, tests for "server version >= 7.4" or "server version >= 6.4" using the PG_VERSION_LT macro were always returning false. Instead, use PROTOCOL_64 and PROTOCOL_74 tests against conninfo. These don't offer any "greater than" form, so just test both. There's little point adding anything prettier when it can all be removed when v1/v2 protocol support is removed soon anyway. The main symptom of this issue was that psqlODBC was sending an invalid protocol message for the v3 protocol, "Q \0", causing the server to wait for the second half of the length word forever. At connection close, the server would emit:
        unexpected EOF within message length word
      This issue was observed while tracking down problems with XA transactions in MSDTC failing to commit after a successful prepare because an isolated tx created via getLockedXAConn() got stuck here, but is not confined to that problem.
    28. Don't use PG_VERSION_xx() macros in original_CC_connect().
    29. it's not obtained from the server yet. This may fix another cause of the problem Craig Ringer reported.
    30. Fix bug in SQLCancel().
    31. If one thread was busy executing a savepoint statement, while another thread calls SQLCancel() on the statement, SQLCancel() would try to release the locks held by the other thread. That's extremely racy; if the other thread tries to increment/decrement the lock_CC_for_rb counter at the same time, we could end up releasing the lock to many times or too few times. Also, releasing a pthread mutex from a different thread than the one who acquired it is undefined behavior. AFAICS the DiscardStatementSvp() call in SQLCancel() can be safely removed. It's outright wrong and dangerous if the statement is busy executing in a different thread, and the other codepaths in PGAPI_Cancel() already call DiscardStatementSvp(). Bug report by Jade Koskela.
    32. Fixes a NULL pointer dereference occurring when connecting.
    33. using SSPI authentication (without kerberos, a local Windows user trying to connect to postgres instance on same host). Patch originally by Nikhil R Deshpande.
    34. Fix bug with UseDeclareFetch=1 when a transaction is committed before fetch.
    35. If a server cursor is closed before the application has fetched any rows from the result set, the "base" of the result set's cached rowset was off-by-one. Also add a regression test for the same. This fixes the bug reported by Jan-Peter Seifert.
    36. Fix driver name mismatch between 32-bit ODBC app and 64-bit MSDTC host.
    37. If the 32-bit driver runs on a 64-bit host within a 32-bit app running under SysWow64 then XA transactions will fail to recover. That's because recovery is done by pgxalib.dll which runs with in MSDTC.exe - a 64-bit application. It connects to a DSN supplied by psqlODBC in EnlistInDtc_1pipe during DTC enlistment by the XA resource manager. This DSN uses the driver name of the client's ODBC driver - which is fine so long as the client and MSDTC architectures match. If they don't then MSDTC will fail to connect to Pg, so it'll never resolve transactions. Traces of MSDTC will show RM_COMMIT_DELIVERY_FAILED_DUE_TO_CONNECTION_DOWN events. Traces of pgxalib.dll will show xa_recover(..) being entered, followed by "SQLDriverConnect return=-1".
    38. Remove PgDtc_set_property(.., prepareRequestded, 0) which causes a crash in case PREPARE TRANSACTION error.
    39. The property prepareRequested isn't set anywhere.
    40. Add KeepaliveTime and KeepaliveInterval options to specify time or interval for keepalive.
    41. Fix a memory leak check qresult.
    42. Per report by Pluto Cobain.
    43. Get rid of copy and paste code in installer/ and unify them.
    44. The powershell scripts had lots of duplication. Make the unified code instead. Original patch was provided by Craig Ringer.
    45. Clear unused stuff from PgDtc_isolate() function.
    46. Also add CC_initialize_pg_version() call after CC_copy_conninfo() so as to avoid the trouble caused by early PG_VERSION_xx() calls.
    47. Fix race condition in getting the current decimal separator.
    48. The code to get the current decimal separator was not thread-safe. If two threads concurrently saw that the locale had changed, they might both try to free() the same string. This isn't a perfect fix, there's still a race condition if a thread changes the locale while another thread is running the psqlodbc code. But at least this eliminates the race condition when the locale was changed earlier, not concurrently, and even if it is changed concurrently, this is less likely to crash, depending on the way localeconv() is implemented in libc.
    49. Fix bug in building an abbreviated connection string.
    50. Introduced by the keepalive-patch, which accidentally removed a line from sprintf format string. Caught by a compiler warning.
    51. Fix buffer overflow in SQLGetData.
    52. If a PostgreSQL timestamp column is fetched using SQLGetData, into a SQL_C_CHAR output variable, with size of 20-22 bytes, the driver might overrun the buffer by a few bytes with unusual timestamp values, with year < 0 or > 10000. While at it, fix the truncation behavior for date/time/timestamp values so that if the output buffer is too small, we still write what fits and truncate, instead of writing nothing. This is something that one might do on purpose, e.g. if you only want to fetch the year part of a date, you might call SQLGetData() on a date column, with only 4 bytes long output buffer. (although we haven't heard any complaints from the field). Also, if the output buffer is of type SQL_C_WCHAR, but the buffer length is odd, and we have to truncate, we didn't NULL-terminate the string. Using an odd-sized buffer with SQL_C_WCHAR is a pretty unlikely thing to do, but nevertheless I think this is more correct behavior.
    53. The function SC_setInsertedTable() prepares an info for subsequent 'select @@IDENTITY' command.
    54. Take table name like catalog.schema.table into account in the function. Fix the bug reported by Phillippe Champignon.
    55. Improve pgxalib.dll(MSDTC support).
      1. Add an option which lets xa_open() try to connect to the database immediately. This would cause an error at enlistment in dtc when the authentication method depends not only on the db user but also on the OS user, which means the automatic transaction recovery is unavailable.
      2. Log the error message in case of SQLDriverConnect() error.
      3. Improve the logging.
    56. Fix the regkey search bug when XARMcreate() causes an error at enlistmentvin DTC.
    57. Additional improvement on MSDTC enlistment.
    58. Unfortunately the current pgxalib.dll can't recover transactions which use sslmode verify-[ca|full] or whose authentication is SSPI, certificate or ident. When MSDTC.exe tries to connect to PostgreSQL it does so under Windows user NETWORKSERVICE, which won't match the username the original user connected to PostgreSQL as. So PostgreSQL will reject the connection.
    59. Fix SQLTables column names to be ODBC version 3 compliant.
    60. In ODBC3, TABLE_QUALIFIER was renamed to TABLE_CAT, and TABLE_OWNER to TABLE_SCHEM. Per report David Hedberg.
    61. Add a new dialog page to the setup program and allow the setting of PREFERLIBPQ and XAOPT option.
    62. Add a powershell script buildBootStrapper.ps1 which builds bootStrapper program with some optional parameters.
    63. Quote the version number of bootstrapper from the configuration xml file unless specified. Also change the name of 32bit MSI in the bootstrapper according to changes of 32bit installer build system. Change buildInstallers.ps1 build the bootstrapper together. Change ALLUSERS from "2" to "1" of the 64bit installer.

    psqlODBC 09.03.0300 Release

    Changes:
    1. Fix implicit casts between SQLCHAR and char. Don't rely on -Wno-pointer-sign.
    2. Pass the argument to isalpha/isspace etc. routines as unsigned char.
    3. Per the C standard, the routine should be passed an int, with a value that's representable as an unsigned char or EOF. Passing a signed char is wrong, because a negative value is not representable as an unsigned char. Unfortunately no compiler warns about that.
    4. Use "function(void)" instead of "function()" to declare 0-arg functions.
    5. "function(void)" is the correct syntax in a function declaration, although in practice compilers accept the latter too. It's OK in a function definition, but change those too for consistency. This fixed by Michael Paquier.
    6. Add missing function declarations.
    7. These are not actually used outside of pgtypes.c, but let's be consistent and declare them in pgtypes.h This fixed by Michael Paquier.
    8. Use the PG_CONFIG setting from ./configure cmd line in regression tests.
    9. If compiling without libpq (configure --without-libpq), then you still need to have pg_config in path to build the regression tests, or specify PG_CONFIG at the make command line.
    10. Add more test cases.
    11. Add a new test case to test ODBC functions deprecated in ODBC 3.0, ODBC catalog functions, SQLGetConnectOption and Avoid deprecated SQLAllocStmt/SQLFreeStmt in regression tests. and more. Per Michael Paquier
    12. Don't clear error number when SQLGetDiagRec is called.
    13. Calls to SQLGetDiagRec are supposed to be nondestructive, per ODBC spec. Also add a test case for that.
    14. Fix two UseDeclareFetch bugs.
      1. NOTICE messages were not delivered to the application, if they arrived as response to the DECLARE CURSOR statement.
      2. Array-bound parameters on SELECT-queries caused a "cursor already open" error.
      These bugs were found by running the regression suite with UseDeclareFetch=1. It's now clean.
    15. Fix crash if connection is closed during CC_send_query_append function.
    16. This fixed Malcolm MacLeod

    psqlODBC 09.03.0210 Release

    Changes:
    1. SSL verify[-(ca|full)] is available since 8.4.
    2. There seems no need to check it. Also there's no need to call lt_dlopen currently.
    3. Update EXTRA_DIST in Makefile.am
    4. Files for the new lfconversion test case were missing.
    5. Fix locking in SC_set_prepared
    6. added ENTER/LEAVE_CRIT_CS calls in SC_set_prepared.
    7. Add test case for CTE queries (WITH ...)
    8. None of the existing test cases covered that. This test case gives a different e rror message than the original one, but it's the same underlying issue.
    9. Silence compiler warning.
    10. SQLGUID format and conn_settings cannot be NULL.
      This fixed by Michael Paquier.
    11. Fixed POSTGRES_RESOURCE_VERSION variable.
    12. Pass the content of POSTGRES_RESOURCE_VERSION variable to the resource compiler correctly so that FileVersion and ProductVersion are properly set.
    13. Change regression test positioned-update
    14. Use "exit(1);" instead of "return;" to exit from main().
      This fixed by Michael Paquier, at least some compiler on OS X didn't like it.

    psqlODBC 09.03.0200

    Changes:
    1. Set TCP keepalive by default.
    2. Fix cursors test case on big-endian systems.
    3. The SQL_CURSOR_COMMIT_BEHAVIOR property is a SQLUSMALLINT, not SQLUINTEGER. On a little-endian system, you wouldn't notice, provided that the target variable was initialized to 0 before the SQLGetInfo call.
      Per report from Christoph Berg that the cursors test was failing on mipsel and other big-endian architectures.

    4. Add regression test for SQLBindCol.
    5. We were already doing SQLBindCol as part of the positioned-update test, but seems good to have one explicitly for it.
    6. The driver takes SQL_C_LONG to mean SQLINTEGER rather than "long".
    7. The regression test was failing on the s390x architecture because of that.
      It's big-endian, with sizeof(long) == 8.
    8. Revert "When LF->CR+LF conversion causes an buffer truncation, suppress the conversion (in case of unicode)."
    9. Refactor utf8_to_ucs_lf.
    10. A macro is difficult to debug, so turn it into a regular function.
      Also, add a new test case for LF->CR+LF conversion, to test the bug that Nils Go"sche reported (which was already fixed).
    11. Add locking to SQLFreeStmt and SQLFreeHandle.
    12. This fixes a race condition, where SQLFreeStmt is called while the connection is busy executing another statement.
      SC_set_prepared would see that the connection is busy (CONN_EXECUTING), and not issue a DEALLOCATE statement to free the prepared statement in the backend, leaking it.
    13. The 2dn argument of SC_set_prepared() is int(enum) not BOOL.
    14. Change to supply non-NULL parameters for SC_set_error().

    psqlODBC 09.03.0100

    Changes:
    1. Fix uninitialized use of 'allocbuf' variable, in case of out-of-memory.
    2. Compiler warned about this. If ENLARGE_NEWSTATEMENT macro ran out of memory, it would jump to cleanup routine.
      The cleanup would check if allocbuf isNULL, and try to free() it if not.
      allocbuf needs to be initialized to NULL before the first ENLARGE_NEWSTATEMENT macro invocation.
    3. SQL_C_SLONG stands for SQLINTEGER not long.
    4. Change SQL_ATTR_PARAMS_PROCESSED_PTR attribute which is set by SQLSetStmtAttr() from (SQLUINTEGER *) to (SQLULEN *).
    5. This fixes the bug reported by Christopf Berg.
      Also verify similar attributes which were changed from SQL(U)INTEGER (*) to SQL(U)LEN (*) when 64bit ODBC was introduced.
    6. Reduce the memory usage of ConnectionClass objects by changing their large fixed length text fields to variable ones.
    7. Because changes are applied to percent-encoded fields this time, password field is also a target of this.
    8. Revise MSDTC support.
    9. Remove pointlessly complicated AsyncThreads stuff. Instead use _beginthread() to clean up threads.
      Make pgenlist.dll from the structure change of ConnectionClass.
      The driver dlls exports the functions described in connexp.h which are used by pgenlist.dll.
      Isolate the current communication path if necessary.
      While an IAsyncPG object is alive, a ConnectionClass object (hereinafter referred to as conn-obj) is assigned to it.
      The assignment has to be changed in the following cases.
      1. SQLDisconnect() is called for the current connection handle which is assigned to an IAsyncPG object.
      2. Allocate another conn-obj and move the current communication path (*sock* member of the current conn-obj) to the new conn-obj. The communicaation path is lost from the current conn-obj and the new conn-obj is assigned to the IAsyncPG object.
      3. Another (global) transaction is about to begin but the current global transaction is not PREPARED yet.
      4. Same as case a) but will open a new communication path for the current conn-obj for the subsequent ODBC API calls.
      5. Another (global) transaction is about to begin and the current global transaction is already PREPARED.
      6. Allocate another conn-obj and open a new communication path for the conn-obj. The new conn-obj is assigned to the IAsyncPG object only to issue COMMIT/ROLLBACK PREPARED command. communication pass (*sock* member of the current ConnectionClass object) to the new object and change the state of the current object NOT CONNECTED. The IAsyncPG object uses new object instead of the current object. In case b) the current object will open a new communication path.
    10. Ignore automatically-generated files in source code with .gitignore.
    11. This is useful to prevent accidental commit of files that are not wanted in the remote repository.
      The original patch was provided by MichaelPaquier. I also added files genearated by VC build tools or WIX tools to .gitignore.
    12. The first cut of psqlodbc setup project. It builds a setup program which can't be done by a single MSI.
    13. It would install VC++ redistributable, 32 bit psqlodbc driver and 64 bit psqlodbc driver (on 64 bit windows).
    14. Change the configure.ac
      1. Change checking SIZEOF_LONG not SIZEOF_LONG_INT.
      2. with_xxxxx (xxxxx is the package name) variables directly instead of the withval variable.
      3. Improve the help message of configure script.
      4. Stop linking lib(i)odbc library because the library is unnecessary and rather harmful.
      5. Per report from Pavel Raiskup(postgresql.org/message-id/1769926.65KUyECjFr@nb.usersys.redhat.com).
      6. Move -Wall -Wno-pointer-sign CFLAGS option specified in Makefile.am to configure.ac.
      7. ODBC_CONFIG is set when neither unixODBC nor iODBC is explicitly specified.
    15. Silence misc compiler warnings. Also a few comment typo and whitespace fixes.
    16. CC_Copy is needed if _HANDLE_ENLIST_IN_DTC_ is used, regardless of CLEANUP_CONN_BEFORE_ISOLATION.
    17. That caused compilation on Windows to fail.
    18. Remove some dead code.(SOCK_clear_error, SOCK_skip_n_bytes)
    19. Handle turning standard_conforming_strings to off in mid-session.
    20. We already watched for a ParameterStatus response indicating that standard_conforming_strings was turned on, and acted accordingly, but if it was turned off, we did nothing.
    21. Remove common.o on "make clean"
    22. Change the default for UseServerSidePrepare to 1.
    23. The docs have recommended UseServerSidePrepare=1 for server versions 7.4 onwards, so it seems prudent to change the default so that people don't needto remember to specify it manually.
      With UseServerSidePrepare=1, the "insertreturning" regression test case behaves better, ie.
      SQLNumResultCols() correctly returns the number of columns for an INSERT RETURNING statement, even when called before SQLExecute().
    24. Remove useless 'sync' parameter from prepareParameters() function. It was always passed as TRUE.
    25. Don't issue a BEGIN when running VACUUM in auto-commit mode.
    26. Normally in auto-commit mode the driver begins a new transaction implicitly at the first statement, by sending a BEGIN statement. However, some commands, like VACUUM, cannot be run in a transaction block, and you will get an error like "VACUUM cannot run inside a transaction block" from the server. In UseServerSidePrepare=0 mode, the code looks at the first word of the query to determine if the statement is one of the special ones, and if so, didn't begin a new transaction even when auto-commit mode is disabled. However, in UseServerSidePrepare=1 mode, when using SQLPrepare/ SQLExecute to run the VACUUM, that check was not made. Fix that. There was one more related inconsistency between UseServerSidePrepare modes. Without server-side-prepares, if you issued an explicit BEGIN in auto-commit mode, the implicit BEGIN was ont sent. But without server-side prepares, it was. It seems best to send the implicit BEGIN in both cases, because then you get a warning from the backend about the second BEGIN. That's a good thing, because a sane ODBC application should be using the ODBC function SQLEndTran() for transaction control, not explicit BEGIN/COMMIT.
    27. When LF->CR+LF conversion causes an buffer truncation, suppress the conversion (in case of unicode).
    28. Handle SSL client certificate authentication in Windows Schannel security support provider.
    29. You have to place the certificate file postgresql.pfx (PFX or PKCS12 format) in %APPDATA%\postgresql folder instead of postgresql.crt and postgresql.key (I wasn't able to find the way to handle PEM format using Cryptography API unfortunately).
      You can create the file using the following command.
      openssl pkcs12 -export -in postgresql.crt -inkey postgresql.key -out postgresql.pfx (with empty password).
    30. Change Windows installer build system for the next release.
    31. Change to specify ProductCode for each version so as not to forget to change ProductCode in case of major version up. Remove VC runtime merge modules from the installer(runtime dlls will be installed via psqlodbc setup program).
      [64bit version only] Use libpq by default Remove GSSAPI support by default
    32. Concentrate the settings of Windows build system to an xml file and build binaries or installers with reference to it.
    33. (configuration.xml) xml file to specify the setting of the build environment. It is automatically generated in winbuild folder as a copy of winbuild/configuration_template.xml when you invoke editConfiguration script firstly.
      .winbuild/configuration.ps1 modules to handle the configuration file
      .winbuild/editConfiguration.ps1 edit configuration file (GUI)
      .winbuild/editConfiguration.bat same as above with a minimized console window
      .buildx86.ps1 build 32bit binary
      .buildx64.ps1 build 64bit binary
      .installer/buildx86-installer.ps1 build 32bit installer
      .installer/buildx64-installer.ps1 build 64bit installer
    34. handle private keys of PEM form using CryptoAPI.
    35. Certificates of PFX form are no longer needed for SSL client certificate authntication.
    36. Fix a bug in CC_copy_conninfo() that free()s password item of input source unexpectedly.
    37. Change CC_copy_conninfo() and copy_globals() so that they copy each item one by one.
    38. Fix the newly-introduced CORR_STRCPY and CORR_VALCPY macros.
    39. They were broken, did not compile. This fixed by Michael Paquier.
    40. Add support for verify-ca/full sslmode using Windows Schannel Security Service Provider.
    41. Root CAs must be installed into Windows Root certificate store beforehand.
    42. VOID is not defined on all systems. Use void instead.
    43. This fixed by Christoph Berg.
    44. winres.h instead of afxres.h.
    45. There are some cases (VS 2012 express etc) when afxres.h doesn't exist.
    46. Avoid double-free() bug.
    47. Spotted by Fortify static analysis tool.
    48. Escape double-quotes in table name correctly.
    49. When constructing the select/update/delete for current row in a rowset, and the schema or table name contained double-quotes, they were not correctly escaped in the constructed SQL statement. That lead to errors when doing positioned updates. Also, use snprintf and snprintf_add instead of sprintf and strcat in more places. Makes these things look less like buffer overflows to static analysis tools, and make for more readable code anyway.
    50. Construct ctid string correctly for block no > 2^31.
    51. Block number is unsigned. Other places where we construct ctid strings we got this right, but not this one. I'm not sure how to trigger this codepath, but I'm sure something funny would happen if you tried to use these functions on large enough tables (> 16 TB).
    52. Fix buffer overflow in interval parsing.
    53. Flagged by Fortify static analysis tool.
    54. Check return value of stdup() for out-of-memory.
    55. There are a lot of little bugs like this throughout the code, but it's start...
    56. Replace calls to my_strcat and my_strcat with snprintf_add.
    57. my_strcat didn't check for buffer overflow, which Fortify static analysis tool flagged as an issue.
    58. Fix buffer overflow in handling of SQLTables params.
    59. Use snprintf() instead of sprintf() for safety.
    60. I believe these instances were in fact safe, because a cursor name has a maximum length.
    61. bufferoverflowu.lib seems no longer needed in recent versions of VC environment.
    62. removed it from win64.mak. Speocify CUSTOMLINKLIBS=bufferoverflowu.lib from the command line when it is necessary in old VC environment.
    63. Fix memset() call, meant to clear the whole struct.
    64. Per compiler warning.(psqlodbc.c)
    65. socket: speedup also ipv6 connection
    66. Call getaddrinfo() with AI_NUMERICHOST if it is ipv4/ipv6 address. For that reason the inet_pton() is better than inet_addr().
      This fixed by Pavel Raiskup
    67. Call getaddrinfo() with AI_NUMERICSERV because the service is a port number.
    68. Fixed lost mylog.h in Makefile.am.
    69. This fixed by Pavel Raiskup

    psqlODBC 09.02.0100

    Changes:
    1.) Protect shared connection list when making cleanup tasks in EN_Destructor using the patch provided by Michael Kocherov.
    2.) Fix a lot of compiler warnings. Most of them were harmless, but some pointed to real, but rare, bugs.
    3.) Check SIZEOF_LONG_INT, rather than SIZEOF_VOID_P, when deciding whether SQLROWSETSIZE exists. That's consistent with unixodbc's sqltypes.h.
    4.) Check BUILD_LEGACY_64_BIT_MODE instead of BUILD_REAL_64_BIT_MODE. This makes us choose correctly whether we're building a 32-bit or 64-bit version, when building with unixODBC version 2.2.13 or higher.
    5.) Fix handling of some out-of-memory situations.
    6.) Eliminate recursion when freeing result sets of queries with array-bound parameters. This avoids running out of stack space on SQLFreeHandle, and speeds it up considerably.
    7.) Fix memory leak, e.g when SQLNumResultCols is called on a non-SELECT query. This was caused by unintentional multiple evaluation of macro arguments.
    8.) Move psqlodbc website's main page, FAQ, and howto pages to a separate git repository. They are no longer included in psqldbc release tarballs.
    9.) Fix bug with binding a 5-bytes long string as VARCHAR parameter, with UseServerSidePrepare=0 and BoolsAsChar=1. That combination produced an extra empty result set on execution.
    10.) Make the MSI build process of 32bit drivers available in 64bit.
    11.) Fix bug with DeUseDeclareFetch=1 and UseServerSidePrepare=1, issue COMMIT commands properly in case of AUTOCOMMIT on mode. per reported by Jack Wilson(ljwilson@digitalav.com).
    12.) Don't #include errno.h on Windows. VC10 or later intentionally changed the values of error numbers like EINTR, EWOULDBLOCK.
    13.) Allow special characters in the password value of a connection string by enclosing the value by braces({}).
    14.) Fixed conflict between winsock2.h and winsock.h in socket.c.
    15.)Apply blank date <-> null conversion functionality to timestamp type as well.
    16.) Fix the *cursor XXXXXXXX already exists* error when handling *with cte* statements reported by Joe Conway.
    17.) Fixed the problem *Segmentation Fault in Postgres server when using psqlODBC* reported by Joshua Berry.
    18.) Fixed the problem *UseDeclareFetch=1, Fetch=100, UseServerSidePrepare=1 causes Windows client to intermittently hang* reported by Jack Wilson.

    psqlODBC 09.01.0200

    Changes:
    1.) Use int instead of size_t when condition >=0 is used.
    2.) Add a necessary break in a switch statement etc.
    3.) Fix missing constant(SQL_ATTR_PGOPT_FETCH).
    4.) Fix a bug about reference count handling for columns info (Bug report by B.Goebel).
    5.) Improve the handling of ARRAY type.
    6.) Fix a compilation error etc when MULTITHREAD support is disabled.
    7.) Don't discard the result of unnamed statements for later SQLDescribeCol or SQLColAttribute calls.(Bug report by Alexandre).
    8.) Set rowstart_in_cache properly when closing eof cursors.(Bug report by Alexandre).
    9.) Remove columns info of dropped tables ASAP.
    10.) Fix the bug which causes a segfault in SQLSpecialColumns when table name is null string (bug report by Terrence Enger).
    11.) Fix the bug that when the show OID column option is enabled, SQLColumns() returns "oid" column info even when the column name parameter which is different from "oid" is specified (bug report from Seifert, Jan-Peter).
    12.) Take care of an environment variable PGKRBSRVNAME.

    psqlODBC 09.01.0100

    Changes:
    1.) SQLStatistics() sets 'D' for the collation column when an reverse index is used.
    2.) Fix the bug that PostgreSQL's function calls in queries cause a crash on SQL Server linked servers.
    3.) Fix the bug that the first fetch operation doesn't work properly when the operation is SQL_FETCH_ABSOLUTE or SQL_FETCH_LAST.
    4.) Revise the handling of decimal point.
    5.) Adjust the operations after closing eof-detected cursors.
    6.) Before dropping the statement, sync and discard the response from the server for the pending extended query.
    7.) Clear col_info(columns info) cache when DROP/ALTER TABLE is called so that later SQLDescribeCol() etc work properly.
    8.) Improve the handling of BYTEA type.
    9.) Don't clear the columns cache info when they are referenced.
    10.) Correct the column size of interval types.

    psqlODBC 09.00.0310

    Changes:
    1.) Let SC_forget_unnamed() clear the result in case the statement is not executed yet. It would fix the bug reported by Silvio Brandani.
    2.) Fix the bug that strings are copied to a null pointer.
    3.) Don't clear the parsed plan in SC_recycle_statement().
    4.) Now SQLDescribeCol() can detect the changes of column type or size.
    5.) Handle *with or without oids* correctly.
    6.) Take the environment variable into account.
    7.) Use SOCK_get_next_n_bytes() instead of SOCK_get_next_byte().
    8.) Add some driver specific options for SQLSetConnectAttr().
    9.) Fix compilation errors in case ODBC 2.5.
    10.) Fix compilation error on different ODBCVER.
    11.) Correct the behavior of SQLSetConnectAttr() for the driver specific options.

    psqlODBC 09.00.0300

    Changes:
    1.) Don't propgate the connection level statement options to the internal statements. This fixes an infinite loop reported by Nelson Andre.
    2.) Improved a mylog output.
    3.) Fix the bug introduced by the previous change reprted by Adrien de Croy.
    4.) Divide SC_returns_rows() macro into several categories and make SQLResultNumCols(), SQLDescribeCol() or SQLColAttribute() available
    for insert/update/delete .. returning statements.
    5.) Initialize flags member in QResultClass before calling QR_set_rowstart_in_cache() per report from Arno Moore.
    6.) Applied a patch by Taizo Ito and correct the length of BIT type in Postgres.
    7.) Change to read and skip the rest of result data when out of memory occurs while reading tuples so that we can continue to use the connection.
    8.) Fix the bug that Access autonumber fields are not detected in 9.0.0200 reported by Arnaud Lesauvage.
    9.) Convert large integer strings properly.
    10.) Fix the trouble introduced by the change *Return 0 for the column size when the size of numeric items are unknown* per report from Marco Gaiarin.
    11.) Remove a meaningless if clause. This had a problem with ltdl function.

    psqlODBC 09.00.0200

    Changes:
    1.) Fix a bug about sizeof() at idx_fake_oid of info.
    2.) Return 0 for the column size when the size of numeric items are unknown.
    Also improve the calculation of scale of numeric items when it is not explicitly specified.
    3.) Change to use 'if' instead of an inappropriate 'else if' at cursor of convert.
    4.) Remember to set permanent flag to holdable cursors on commit with no precedent rollback (to savepoint) operations.
    This fixes a crash bug in case of cursor operations across transaction.
    5.) Fix a bug about the handling of the SQL_RETRIEVE_DATA option.
    Per report by Andreas.
    6.) Fix cursor bug introduced by the previous change.
    Per report by Andreas.
    7.) Move the setting of folder name of libpq or gssapi related dlls from .wxs file to .bat file.
    8.) Fix a bug which returns incorrect values for SQL_DATETIME_SUB.

    psqlODBC 09.00.0101

    Changes:
    1.) Fix build source of Windows 64bit environment.

    psqlODBC 09.00.0100

    Changes:
    1.) Allow password which contains special characters like {,},=,;.
    2.) Add a new data source option which makes it possible to use Kerberos for Windows library to reply to GSSAPI authentication request.
    3.) Native support for SSPI Kerberos or Negaotiate service. It may be useful for the 64-bit drivers.
    4.) Fix an oversight of Memory overflow handling.
    5.) Removed "#define SQL_WCHART_CONVERT" which causes a trouble on some platforms.
    6.) Removed the use of misused strcat_s together with snprintf_s (bug report from Jap-Peter Seifert) and use strlcat instead of strncat.
    7.) Fix a bug about pre-execute behavior in case of protocol v2 or earlier.
    8.) Use poll() instead of select() when it's available.
    9.) Take comments or line comments in a query into account.
    10.) Fix a crash bug on authentication failures.
    11.) Take --without-iodbc(unixODBC) configure option into account.
    12.) Apply the patch by Peter Crabtree which fixes a crash bug.
    13.) Improve the handling of bools_as_char case.
    14.) Fix a bug when creating a connection string.
    15.) Use pg_get_expr(adbin, ..) instead of unreliable adsrc in pg_attrdef so as to know the sequence name associated with serial items.
    16.) Added 64-bit version of installer files.
    17.) Introduce pgtype_attr_xxxx functions which take a typmod parameter as well as a type oid parameter as an extension of pgtype_xxxx functions so that SQLColumns and SQLDescribeCol(SQLColAttrinute) could use common functions.
    18.) Call PQconnectdbParams instead of PQconnectdb when it's available.
    19.) Make cursor open check at transaction end a little more effective.
    20.) Added code for SQL_INTERVAL support and refcursor support though they are disabled.
    21.) Correct the handling of dynamic cursors so that they are substituted by keyset-driven ones.
    22.) Remove a compilation error and some compiler warnings under unixdODBC 2.3 environment.
    23.) Make sure the support of the backward-compatibility version of getaddrinfo() family even when _WIN32_WINNT is supplied.
    24.) Update win64.mak so that gssapi support is available without libpq.

    psqlODBC 08.04.0200

    Changes:
    1.) Fix a column uodatability problem reported by Tom Goodman.
    2.) Display SSL mode list properly on setup dialog.
    3.) Don't truncate the result of msgtowstr()/wstrtomsg().
    4.) Implement ConfigDriver() function.
    5.) check of the SQLLEN definition by the unixODBC version by SQLColAttribute.
    6.) Take WITH cte staments into account.
    7.) Fix a bug about UTF8 handling.
    8.) Wait a ReadyForQuery Message after errors correctly.
    9.) Fix a problem with {call procedure reported by Wolfgang Pasche.
    10.) Cleanups about the handing of unnamed parsed statements and the handling of ODBC escape { .
    11.)Link ws2_32.lib in case the compilation environment #defines _WIN32_WINNT and the value >= 0x0501.
    12) Added --with(out)-libpq[=DIR} option to configure.
    13) Revise autoconf/automake so that libpq/ssl header/libs are resolved at configure phase.
    14) Use md5.c directly instead of win_md5.c.
    15) Suppress some compiler warnings.
    16) Fix memory leaks on connection failure (Shouji morimoto).
    17) Suppress some compilation errors and warnings.
    18) Fix SSL connection timeout.

    psqlODBC 08.04.0100

    Changes:
    1.) Avoid a crash on exit when using SSL connections by resetting CRTPTO_xx_callbacks before unloding libpq.
    2.) Correct the function name DiscardRollbackState pointed out by Zoltan Boszormenyi.
    3.) Correct the value of INDEX_QUALIFIER column which returned by SLQSTATISTICS();
    4.) Take domain types into account in SQLColumns() (Thanks to Luiz K. Matsumura).
    5.) Take RESTRICT actions into account in SQLForeignKeys() (report from Farid Zidan).
    6.) Fix a bug that small negative decimal values are mistaken for non-negative (bug report from Dominic Smith).
    7.) Use MSG_NOSIGNAL/MSG_NOSIGPIPE option on send()/recv() to avoid crash on SIGPIPE (bug report from Brian Feldman).
    8.) Remove a spurious "." with no trailing digits in timestamp representation (bug report from Brian Feldman).
    9.) Rename trim() function in order to avoid conflict of function name(report from Dominic Smith).
    10.) Put back the change to add *read only* clause for read only cursors.
    11.) Improve pgtype_transfer_octet_length().
    12.) Fix a bug reported by Milen Manev that SQLExec *select for a table* -> SQLDescribeCol() -> add a column to the table -> SQLExec *select for the table* -> SQLDescribeCol() for the added column causes a bad result.
    13.) Use strncpy_null() instead of strncpy().
    14.) Close (holdable) cursors on commit if possible.
    15.) Recycle columns cache info if the size becomes pretty large.
    16.) Add a 'verify-ca' and 'verify-full' to the sslmode option via libpq of version 8.4.
    17.) Add a functionality to change the directory for logging.
    18.) Correct the error code for communication errors.
    19.) Correct the conversion between UTF-16 and UTF-8 for non UCS2 characters.
    20.) Try to convert (especially connection error) messages using local conversions when they are not valid unicode characters.
    21.) Add a textbox to setup dialog to change the directory for logging.
    22.) Allow multiple Connsettings statements in connection string by enclosing them by braces({}).
    23.) Improve the transactional control under useDeclareFetch mode.
    24.) Take the platforms where char is unsigned into account per report from Alex Goncharov.
    25.) Improve the handling of UUID type especially to support IMPORT or LINK in MS Access.

    psqlODBC 08.03.0400

    Changes:
    1.) GUID forgot to set the value to the buffer.
    2.) -Wall was taken as gcc limitation.

    psqlODBC 08.03.0300

    Changes:
    1.) SQLGUID type support thanks to Jan-Willem Goossens.
    2.) Fix a bug about silently adding a *for read only* clause.
    3.) Fix a 64bit mode bug about handling of arrays of parameters.
    4.) Change the implemetatin of SQLForeignKeys() for 8.3+ servers.
    5.) Not commit the transaction too early in useDeclareFetch mode.
    6.) Add a cursor open check for SQLPrepare().
    7.) Reset the column binding information after SQLMoreResults().
    8.) Save the rowset size properly for the FETCH_NEXT operation in case of >= 3.0 drivers.
    9.) Support FE/BE communications on Big Endian platform.
    10.) Check strerror_r function's return type.
    11.) Suppress some compiler warnings.

    psqlODBC 08.03.0200

    Changes:
    1.) Fix a bug in socket which uses a socket variable.
    2.) Support column alias without "as" so that links from the SQLServer work.
    3.) Take ';' into account when the driver adds "for read only" clause.
    4.) Use the E'.. ' notation not only in '=' expressions but also in LIKE expressions.
    5.) Change to return milliseconds parts for timestamp fields.
    6.) Change to return a specific sqlstate in case of multiple parameters.
    7.) Fix bug of the selection not using SSL.

    psqlODBC 08.03.0100

    Changes:
    1.) Correct the flow of trial of multi protocols and fix related bugs about handling of connection errors.
    2.) Use SSPI service for SSL support when libpq is unavailable.
    3.) Fix a bug in copy_and_convert_field() when fetching bookmark columns. This bug could occur in case no suitable? lo type is found.
    4.) Improve the parse statement operation so that it detect srf in (from clause).
    5.) Correct the COLUMN_LENGTH return value of SQLColumns() for varchar/bpchar type columns (Unicode driver).
    6.) Change to not return database name if case of MS Query.
    7.) The first cut to use Windows SSPI. The trial to use Schannel service for SSL support.
    8.) Be more careful about in UseDeclareFetch mode. "for read only" clause for read only queries for 8.3 or later servers for safety.

    psqlODBC 08.02.0500

    Changes:
    1.) Correct the format of Bind message under 64bit environment.
    2.) Fixed build of without OpenSSL.

    psqlODBC 08.02.0403

    Changes:
    1.) Support SQLColAttribute for MS specific SQL_CA_SS_COLUMN_KEY. Some MS applications use this.
    2.) Improve the check of updatability of queries by checking if they have multiple tables.
    3.) Reduce the round trip overhead in FE/BE communications(especially in useDeclareFetch mode).
    4.) Fix a bug in ResolveOneParam() pointed out by Rainer Bauer.
    5.) Add a flag which lets SQLTables() show only accessible tables.
    6.) The unicode driver now can handle utf-16 surrogate pairs.

    psqlODBC 08.02.0402

    Changes:
    1.) Fix some bugs in case without MSDTC support.
    2.) Refine the realloc handling.
    3.) Put back the @@IDENTITY implementation so as not to use lastval().
    4.) Change SQLColumns() to return correct column length in the Unicode driver.
    5.) Remove the connection count limitation.
    6.) Fix Protocol=7.4--1 notation (should be Protocol=7.4).
    7.) Fix a typo in socket.c (bug report from Rainer bauer).
    8.) Add CC_set_autocommit to psqlodbc(a).def files.
    9.) Handle Standard_conforming_strings.
    10.) Handle standard_conforming_strings also in case via libpq.
    11.) Fix a bug which doesn't free connection list properly.
    12.) Fix DelayLoadDLL was made explicit of psqlodbc.proj file.

    psqlODBC 08.02.0401

    Changes:
    1.) Fix a bug which checking join is confused by CR+LF.
    2.) Handle AUTOCOMMIT mode more carefully in a distributed transaction so as not to issue COMMIT unexpectedly.
    3.) Allow the UNIX domain configuration (the same as libpq).
    4.) Fixed the automake/autoconf scripts.(by Peter Eisentraut)

    psqlODBC 08.02.0400

    Changes:
    1.) Fixed control binding of SetField problem.
    2.) Fixed pgenlist.h losts to the release package.

    psqlODBC 08.02.0300

    Changes:
    1.) Allow non-admin or Vista users to create log files in the home directory.
    2.) Fix an index over bug which causes a crash or an unexpected result.

    psqlODBC 08.02.0205

    Changes:
    1.) Append DETAIL messages to GetDiag...() messages.
    2.) Use SQL_SUCCEEDED macros so as to simplify the code.
    3.) Use lastval() function to replace IDENTITY on 8.1 or later servers.
    4.) Remove WSAStartup() and WSACleanup() from DllMain.
    5.) Load libpq from the driver's folder.
    6.) Use QR_get_value_backend_int/_text() funcs instead of QR_get_value_backend_row().
    7.) Improve the implementation of SQLSetPos(.., SQL_ADD/SQL_UPDATE) using the 8.2 new feature INSERT/UPDATE .. returning.
    8.) Seaparate DTC code as a Delayload DLL.

    psqlODBC 08.02.0204

    Changes:
    1.) Configure the combination of time.h and sys/time.h.
    2.) Treat the tables in information_schema as system tables.
    3.) Correct the precision of SQL_NUMERIC_STRUCT.
    4.) Change the default max varchar size from 254 to 255.
    5.) Reset the fields information properly in case of SQLMoreResults.
    6.) Implement SQLDescribeParam() also in case of multi-command queries.
    7.) Handle dollar-quotes more properly.
    8.) Provide a make option to link dynamic multithread library.
    9.) Set the default nullablity to TRUE.
    10.) Parse command delimiters(;) more correctly.
    11.) Use QR_get_value_backend_text() or QR_get_value_backend_int()
    12.) instead of QR_get_value_backend_row().
    13.) Apply Parse statement or disallow premature properly.
    14.) Reset current_schema cache in case 'set search_path ..' command is issued.

    psqlODBC 08.02.0203

    Changes:
    1) Fix a bug which forgets unnamed plans too early especially when handling large objects.
    2) Don't treat characters whose value >= 128 as alphanumeric in case of conversion of binary data to bytea.
    3) Change ConfigDSN() so that it takes the options in Setup Dialog page 1 into account.
    4) Simplify the memory management of statements'columns info so as to prevent memory leaks or a crash in parse_statement etc.
    5) SQLTables("", SQL_ALL_SCHEMAS. "", ..) now returns a list of valid schemas.
    6) SQLTables("", "", "", SQL_ALL_TABLE_TYPES) now returns a list of valid table types.
    7) SQLGetInfo SQL_DATABASE_NAME now returns the database name.
    8) Improve the automatic setting mechanism of the client_encoding for Windows code page 125x (ANSI drivers only).

    psqlODBC 08.02.0202

    Changes:
    1) Change to use NULL indicator instead of the length buffer in SQLFetch.
    2) Fix long -> serial conversion error in MS Access.

    psqlODBC 08.02.0201

    Changes:
    1) Ditinguish the indicaitor and the octet_length field of APD clcearly.
    2) Handle @@IDENTITY more generally.
    3) Take outer join into account so as to evaluate nullability.
    4) Fix a bug about Keyset-driven cursors.

    psqlODBC 08.02.0200

    Changes:
    1) Fix some bugs or warnings on 64 bit OS.
    2) Avoid backend crash caused by Execute Requests for committed holdable cursors.

    psqlODBC 08.02.0105

    Changes:
    1) SQLStatistics now returns indices based on expression also.
    2) Add a TEST button on the setup dialog.

    psqlODBC 08.02.0104

    Changes:
    1) Take 64bit mode into account for the format parameter of (s(n))printf, sscanf etc.
    2) getpid() instead of _getpid()
    3) SQLGetInfo(SQL_NULL_COLLATION) now returns SQL_NC_HIGH instead of SQL_NC_END
    4) Remove the function SQLParamOptions from ODBC3.0.

    psqlODBC 08.02.0103

    Changes:
    1) Improve the handling of connection error messages.
    2) Add an option to convert empty strings to NULL.
    3) Handle domain type as the basetype.
    4) Fake MSS in case of not only SQLExecute but also SQLParamData.
    5) Prevent SQLColumns from displaying system columns.
    6) Unload delayLoaded libraries on dll detach (not on disconnect time).
    7) Fix a SQLGetDiagField crash bug.
    8) Fix a insertion count bug.
    9) Take win98 cases into account a little.

    psqlODBC 08.02.0102

    Changes:
    1) Compensate a loss of report of being Jet when using MS Access.
    2) Add NULL <-> "" date conversion function for FOXPRO and
    revise parse/describe/execute mechanism.
    3) Miscellaneous type changes for 64 bit drivers.

    psqlODBC 08.02.0101

    Changes:
    1) Delayload import XOLEHLP.dll so that the driver can be loaded
    without the existence of the dll.
    2) Fix a simple password authentication bug.
    3) Fix a buffer overrun bug which prevented the connection phase
    from retrying another version appropriately.
    4) Handle multi-addresses of a specified host properly.
    5) Refine the socket handling(connect, recv, send).
    6) Display more appropriate error messages in the connection phase.

    psqlODBC 08.02.0100

    Changes:
    1) Return to Unicode/ANSI driver distribution as some users still find one works better than the other for them.
    2) Improve connection error message in case of invalid protocol characters.
    3) Initial value has set MSDTC=no of VC6 (Support of MSDTC is only VC7 and VC8)
    4) Addition which is a driver name in a resource (Unicode or ANSI)

    psqlODBC 08.02.0007

    Changes:
    1) Fix some SQLPrimaryKey, SQLForeignKey bugs.
    Fill PK_NAME or FK_NAME columns.
    Return right update_rule values.
    Remove duplicates.
    2) Handle SQL_ALL_SCHEMAS parameter in SQLTables.
    3) Handle unaligned indicator/length buffers more properly.
    4) Fix a bug in ProcedureColumns in case of set returning functions.
    5) Fix a buffer overrun in handle_notice_message (Bart Samuel)
    6) Fix a output parameters problem (Bart Samuel)
    7) Hold the connection lock while a rollbackable statement running.
    8) Add Extra Opts option to the DSN option setupdialog.

    psqlODBC 08.02.0006

    Changes:
    1) Add an option to fake Microsoft SQL Server which would improve SERIAL type handling.
    2) Add support for LOGIN_TIMEOUT.
    3) Improve Statement error handling about the reference of Connection error.
    4) Improve the handling BIGINT type in the OSs without having strtoll().
    5) Support ODBC CONVERT scalar functions in some cases.
    6) Close qlog, mylog files on detach dll.
    7) Improve communication performance in case of the driver's original socket.
    8) Fix send a close
    9) Support of IPV6.

    8.2.0003-8.2.0005 was skipped by the situation.

    psqlODBC 08.02.0002

    Changes:
    1) SQL injections via ODBC catalog function calls.
    2) Fix SQLNumParams problem related to literal or dollar quote.
    3) Call libpq in case of Kerberos authentication.
    4) Add E' before literal for after 8.1 severs.
    5) Return the correct error message in case of no password.
    6) Take E'...' literal expression into account.
    7) Fix an SQL_C_WCHAR -> numeric type conversion problem.
    8) Refine the handling of io or output parameters.
    9) Refine the dollar quote handling.
    10) Fix the client_encoding mismatch problem.
    11) Fix for SQLStatistics returns UNKNOWN instead of real column names.

    psqlODBC 08.02.0001

    Changes:
    1) updated CVS tip to the REL-07_03_ENHANCED branch
    2) updated the installer for the single driver distribution
    3) standardised various filenames that were previously based on build types
    4) standardised the build on ODBC version 3.51

    Release notes for older versions are here psqlodbc-REL-16_00_0005/docs/unix-compilation.html000066400000000000000000000043071462406103600216170ustar00rootroot00000000000000 Compiling psqlODBC on Unix

    Compiling psqlODBC on Unix

    Following psqlODBC's move away from the main PostgreSQL source tree, Peter Eisentraut was kind enough provide a build environment for us which is now included in psqlODBC tarballs.

    Installation

    To install, just try something like:

    % tar -zxvf psqlodbc-xx.xx.xxxx.tar.gz
    % cd psqlodbc-xx.xx.xxxx
    % ./configure
    % make
    % make install
    

    The configure script will accept the following useful options:

    • --with-libpq=DIR postgresql path (mandatory)
    • --with-unixodbc=DIR path or direct odbc_config file (default:yes)
    • --with-iodbc=DIR path or direct iodbc-config file
    • --with-odbcver=VERSION change default ODBC version number [0x0351]
    • --enable-pthreads (thread-safe driver on some platforms)
    • --disable-unicode (build non-Unicode driver)
    • --help

    Building a distribution

    Prerequisites

    • Autoconf 2.59 or higher
    • Automake 1.9.2 (Lower versions are rejected, version 1.7 untested.)
    • Libtool 1.5.10 or higher
    • PostgreSQL source tree (9.0 branch)

    Bootstrapping

    autoreconf -i
    

    You can run 'make maintainer-clean' to remove all the files this generates.

    Building

    ./configure
    make
    make install
    

    configure has the same options that the PostgreSQL configure used to have for ODBC, namely --with-iodbc or --with-unixodbc

    Making a Source Distribution

    'make dist' makes a file psqlodbc-xx.xx.xxxx.tar.gz. It's even better to use 'make distcheck', which runs a number of tests to see if the distribution is internally consistent.

    The distribution does not contain any Windows-specific files (*.def, maybe others). If it is desired to include them, edit Makefile.am.

    psqlodbc-REL-16_00_0005/docs/win32-compilation.html000066400000000000000000000227141462406103600216000ustar00rootroot00000000000000 Compiling psqlODBC on Windows

    Compiling psqlODBC on Windows

    This page describes how to build the PostgreSQL ODBC Driver on Windows. There are three methods to build: from command line using nmake makefiles, from Powershell using MSBuild files, and from Visual Studio IDE.

    The following 3rd party software are required for the build:

    • Microsoft Windows SDK 7.0 (or later), or Microsoft Visual Studio C++ 2005 Edition (or later). Other compilers may work but have not been tested. Download the latest version from Microsoft's download page
    • PostgreSQL Client library (libpq.dll) and headers. Download the latest version from the PostgreSQL Binaries Download page.
    • WiX Toolset. Required for building the installer. Download the latest version from the WiX Toolset website

    Building with Powershell and MSBuild

      Using Powershell and MSBuild is recommended. 
      In fact the binaries of official release are built using this mothod.
    
      Currently 4 Windows Powershell scripts are provided for developers.
    
      winbuild/BuildAll.ps1          - build all dlls for psqlodbc drivers using
    				   MSBuild.
      winbuild/editConfiguration.ps1 - a GUI tool to set Build environment
      winbuild/regress.ps1           - build regression test programs and run
      installer/buildInstallers.ps1  - build installers(.msi and setup.exe)
    
      Use Powershell console or Command Prompt to invoke scripts:
    
      For example, to build the driver:
    
      C:\psqlodbc\winbuild\> (Powershell) ./BuildAll.ps1 <options>
     
        or you can use the same functionality from Command Prompt using Windows
        helper batch at the parent folder (..\). See ..\readme_winbuild.txt.
     
      C:\psqlodbc\> (Command Prompt) .\BuildAll.bat <options>
    
      1. Please start a powershell console and set the ExecutionPolicy of
         Powershell to RemoteSigned or Unrestricted.
    
         You can get the ExecutionPolicy by typing
    
    	Get-ExecutionPolicy
    
         When the ExecutionPolicy is "Restricted" or "AllSigned" then type e.g.
    
    	Set-ExecutionPolicy RemoteSigned
    
         To see details about ExecutionPolicy, type
    
    	Get-Help about_Execution_Policies
    
      2. You have to install one of the following.
    
       . Visual Studio 2015 non-Express edtion or Express 2015 for Windows
    	Desktop
       . Visual Studio 2013 non-Express edtion or Express 2013 for Windows
    	Desktop
       . Visual Studio 2012 non-Express edtion or Express 2012 for Windows
    	Desktop
       . Full Microsoft Visual C++ 2010
       . Windows SDK 7.1
    
         You have to include x64 development tools (bin, lib, include) as
         well as x86 ones for the installation.
    
         You can install multiple versions of VC++ and use them.
         You can easily switch by specifying VCVersion parameter.
    
      3. Setup Build environment
    
         Please type
    
    	.\editConfiguration(.ps1)
    
         and edit the setting of your environment especially the folders
         you placed libpq related include/lib/bin files.
    
    		
    
      4. Build
    
         Please type
    
    	.\BuildAll(.ps1)
    
         to invoke build operations.
    
         If you installed both VC10 and VC12 and you'd like to compile
         under VC10 environment, type
    
            .\BuildAll(.ps1) -V(CVersion) 10.0
    
         or set the value 10.0 to vcversion using ./editConfiguration.
    
         To see details about the use of BuildAll, type
    
    	Get-Help .\BuildAll(.ps1) [-Detailed | -Examples | -Full]
    
      5. Outputs of Build
    
         The build can produce output in up to four directories for each of
         the debug and release configurations:
    
         - x64_Unicode_Release     the Unicode driver, 64-bit
         - x86_ANSI_Release        the ANSI driver, 64-bit
         - x86_Unicode_Release     the ANSI driver, 32-bit
         - x86_ANSI_Release        the Unicode driver, 32-bit
    
         For debug builds (-Configuration Debug) the directories are named with
         Debug instead of Release but otherwise the same.
    
         pgxalib.dll is only built for the multibyte/unicode version, as it is
         the same for both unicode and ansi drivers.
      
      6. How to use drivers.
    
         You can't use psqlodbc drivers at once you build the drivers.
         Usually you have to install drivers using installers made by
         installer/buildInstallers.ps1. buildInstallers.ps1 bundles
         libpq and related libraries like ssleay32, libeay32 from the
         PostgreSQL bin directory and MSVC runtime libraries compiled with.
    
         However, it is painful for developers to build binaries, build
         installers and install each time the source files are changed. 
         It is recommended to use a special installation-less driver
         (postgres_devw) registered by regress.ps1
    
      7. Regression test in place
    
         After BuildAll(.ps1), please type
    
    	.\regress(.ps1)
    
         You have to neither install nor copy binaries.
         By default, build 32-bit binaries from test sources and run the tests.
         If you'd like to test 64-bit version, please type
    
    	.\regress(.ps1) -p(latform) x64
    
         Please note the outputs(obj, exe etc) generated by build operations and
         results of tests are placed in the directory winbuild/test_x86(test_x64
         in case of 64-bit).
    
      8. Installer
         
         To build the .msi installer file:
    
         C:\psqlodbc\installer\> (Powershell) ./buildInstallers.ps1 <options>
            or
         C:\psqlodbc\> (Command Prompt) .\buildInstallers.bat <options>
    
         By default, buildInstallers.ps1 builds bootstrapper program
         psqlodbc-setup.exe together.
    
         See ../installer/readme.txt in the source directory for details.
    
    Troubleshooting:
    
         Some documentation on dealing with Windows SDK installation issues
         can be found on the related pg_build_win page:
         https://github.com/2ndQuadrant/pg_build_win#troubleshooting
    
    

    Building with nmake.exe

    Use NMAKE.exe to build the driver for the currently active target:

    C:\psqlodbc\> nmake /f win64.mak <options>

    Despite the name, win64.mak is used to build both 32-bit and 64-bit binaries. With the Microsoft Windows SDK Command Prompt, you can switch between 32-bit and 64-bit target architectures with setenv /x86 and setenv /x64 commands. If using a Visual Studio Command Prompt you can start the x86 or x64 versions from the Start menu, or run vcvarsall.bat with appropriate options to switch architectures.

    To build the .msi installer file:

    C:\psqlodbc\> nmake /f win64.mak installer

    The resulting installer file goes to installer/x64 or installer/x86 directory.

    To build both 32-bit and 64-bit versions in one command:

    C:\psqlodbc\> nmake /f win64.mak world

    The following build options may be used, either on the command line, or by creating a file called "windows-local.mak".

    Variable Values
    CFG Release(default), or Debug
    PG_INC $(PROGRAMFILES)\PostgreSQL\9.3\include
    PG_LIB $(PROGRAMFILES)\PostgreSQL\9.3\lib
    SSL_INC C:\OpenSSL-Win32\include
    SSL_LIB C:\OpenSSL-Win32\lib
    ANSI_VERSION no (If set to "yes", output dll name to psqlodbc30a.dll)
    MSDTC yes

    1. UNICODE is the default (psqlodbc35w.dll), unless ANSI_VERSION is selected (psqlodbc30a.dll)
    2. libpq.dll is mandatory.
    3. If MSDTC == Yes, "pgxalib.dll" is created.
    4. If MSDTC is enabled, ANSI_VERSION also creates "pgenlista.dll", or UNICODE creates "pgenlist.dll".

    IDE Method

    A Microsoft Visual Studio project file (and workspace) is included in the source tree.

    psqlodbc.dsp can be used with Microsoft Visual C++ 6.0.

    psqlodbc.proj and psqlodbc.sln can be used with Microsoft Visual C++ 2005 Edition (including the Express edition which can be downloaded free of charge from http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx)

    Preparation before the build:

    1. The Windows distribution of PostgreSQL will install the required headers and libraries into C:\Program Files\PostgreSQL\9.2
    2. OpenSSL should be installed into C:\OpenSSL (OpenSSL binaries can be downloaded from http://www.slproweb.com/products/Win32OpenSSL.html)

    If you want to change the installation arrangement, it is necessary to edit the project settings.

    Note:

    The default build settings will create the following driver:

    1. UNICODE support.
    2. libpq is mandatory.
    3. The driver filename is "psqlodbc35w.dll".
    psqlodbc-REL-16_00_0005/drvconn.c000066400000000000000000000343011462406103600163140ustar00rootroot00000000000000/*------- Module: drvconn.c * * Description: This module contains only routines related to * implementing SQLDriverConnect. * * Classes: n/a * * API functions: SQLDriverConnect * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "psqlodbc.h" #include #include #include "connection.h" #include "misc.h" #ifndef WIN32 #include #include #else #include #endif #include #ifdef WIN32 #include #include "resource.h" #endif #include "pgapifunc.h" #include "dlg_specific.h" #define FORCE_PASSWORD_DISPLAY #define NULL_IF_NULL(a) (a ? a : "(NULL)") #ifndef FORCE_PASSWORD_DISPLAY static char * hide_password(const char *str) { char *outstr, *pwdp; if (!str) return NULL; outstr = strdup(str); if (!outstr) return NULL; if (pwdp = strstr(outstr, "PWD="), !pwdp) pwdp = strstr(outstr, "pwd="); if (pwdp) { char *p; for (p=pwdp + 4; *p && *p != ';'; p++) *p = 'x'; } return outstr; } #endif /* prototypes */ static BOOL dconn_get_DSN_or_Driver(const char *connect_string, ConnInfo *ci); static BOOL dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci); #ifdef WIN32 LRESULT CALLBACK dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci); extern HINSTANCE s_hModule; /* Saved module handle. */ #endif #define PASSWORD_IS_REQUIRED 1 static int paramRequired(const ConnInfo *ci, int reqs) { int required = 0; const char *pw = SAFE_NAME(ci->password); /* Password is not necessarily a required parameter. */ if ((reqs & PASSWORD_IS_REQUIRED) != 0) if ('\0' == pw[0]) required |= PASSWORD_IS_REQUIRED; return required; } RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, const SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT * pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { CSTR func = "PGAPI_DriverConnect"; ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci; #ifdef WIN32 RETCODE dialog_result; BOOL didUI = FALSE; #endif const char *lackMessage = NULL; RETCODE result; char *connStrIn = NULL; char connStrOut[MAX_CONNECT_STRING]; int retval; char salt[5]; ssize_t len = 0; SQLSMALLINT lenStrout; int reqs = 0; MYLOG(0, "entering...\n"); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } connStrIn = make_string(szConnStrIn, cbConnStrIn, NULL, 0); #ifdef FORCE_PASSWORD_DISPLAY MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn); #else if (get_mylog()) { char *hide_str = hide_password(connStrIn); MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, NULL_IF_NULL(hide_str)); if (hide_str) free(hide_str); } #endif /* FORCE_PASSWORD_DISPLAY */ ci = &(conn->connInfo); /* First parse the connect string and get the name of DSN or Driver */ if (!dconn_get_DSN_or_Driver(connStrIn, ci)) { CC_set_error(conn, CONN_OPENDB_ERROR, "Connection string parse error", func); return SQL_ERROR; } /* * If the ConnInfo in the hdbc is missing anything, this function will * fill them in from the registry (assuming of course there is a DSN * given -- if not, it does nothing!) */ getDSNinfo(ci, NULL); /* Parse the connect string and fill in conninfo for this hdbc. */ if (!dconn_get_connect_attributes(connStrIn, ci)) { CC_set_error(conn, CONN_OPENDB_ERROR, "Connection string parse error", func); return SQL_ERROR; } logs_on_off(1, ci->drivers.debug, ci->drivers.commlog); if (connStrIn) { free(connStrIn); connStrIn = NULL; } /* initialize pg_version */ CC_initialize_pg_version(conn); memset(salt, 0, sizeof(salt)); #ifdef WIN32 dialog: #endif MYLOG(DETAIL_LOG_LEVEL, "DriverCompletion=%d\n", fDriverCompletion); switch (fDriverCompletion) { #ifdef WIN32 case SQL_DRIVER_PROMPT: if (NULL == hwnd) break; dialog_result = dconn_DoDialog(hwnd, ci); didUI = TRUE; if (dialog_result != SQL_SUCCESS) return dialog_result; break; case SQL_DRIVER_COMPLETE_REQUIRED: /* Fall through */ case SQL_DRIVER_COMPLETE: if (NULL == hwnd) break; if (paramRequired(ci, reqs)) { dialog_result = dconn_DoDialog(hwnd, ci); didUI = TRUE; if (dialog_result != SQL_SUCCESS) return dialog_result; } break; #else case SQL_DRIVER_PROMPT: case SQL_DRIVER_COMPLETE: case SQL_DRIVER_COMPLETE_REQUIRED: #endif case SQL_DRIVER_NOPROMPT: break; } /* * Password is not a required parameter unless authentication asks for * it. For now, I think it's better to just let the application ask * over and over until a password is entered (the user can always hit * Cancel to get out) */ if (paramRequired(ci, reqs)) { /* if (didUI) return SQL_NO_DATA_FOUND; */ if (!lackMessage) lackMessage = "Please supply password"; CC_set_error(conn, CONN_OPENDB_ERROR, lackMessage, func); return SQL_ERROR; } reqs = 0; MYLOG(DETAIL_LOG_LEVEL, "before CC_connect\n"); /* do the actual connect */ retval = CC_connect(conn, salt); if (retval < 0) { /* need a password */ if (fDriverCompletion == SQL_DRIVER_NOPROMPT) { CC_log_error(func, "Need password but Driver_NoPrompt", conn); return SQL_ERROR; /* need a password but not allowed to * prompt so error */ } else { #ifdef WIN32 if (ci->password_required) reqs |= PASSWORD_IS_REQUIRED; if (hwnd && paramRequired(ci, reqs)) goto dialog; #endif /* WIN32 */ /* Prompting for missing options is only supported on Windows. */ return SQL_ERROR; } } else if (retval == 0) { /* error msg filled in above */ CC_log_error(func, "Error from CC_Connect", conn); return SQL_ERROR; } /* * Create the Output Connection String */ result = (1 == retval ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); lenStrout = cbConnStrOutMax; if (conn->ms_jet && lenStrout > 255) lenStrout = 255; makeConnectString(connStrOut, ci, lenStrout); len = strlen(connStrOut); if (szConnStrOut) { /* * Return the completed string to the caller. The correct method * is to only construct the connect string if a dialog was put up, * otherwise, it should just copy the connection input string to * the output. However, it seems ok to just always construct an * output string. There are possible bad side effects on working * applications (Access) by implementing the correct behavior, * anyway. */ /*strncpy_null(szConnStrOut, connStrOut, cbConnStrOutMax);*/ strncpy((char *) szConnStrOut, connStrOut, cbConnStrOutMax); if (len >= cbConnStrOutMax) { int clen; for (clen = cbConnStrOutMax - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--) szConnStrOut[clen] = '\0'; result = SQL_SUCCESS_WITH_INFO; CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the ConnStrOut.", func); } } if (pcbConnStrOut) *pcbConnStrOut = (SQLSMALLINT) len; #ifdef FORCE_PASSWORD_DISPLAY if (cbConnStrOutMax > 0) { MYLOG(0, "szConnStrOut = '%s' len=" FORMAT_SSIZE_T ",%d\n", NULL_IF_NULL((char *) szConnStrOut), len, cbConnStrOutMax); } #else if (get_mylog()) { char *hide_str = NULL; if (cbConnStrOutMax > 0) hide_str = hide_password(szConnStrOut); MYLOG(0, "szConnStrOut = '%s' len=%d,%d\n", NULL_IF_NULL(hide_str), len, cbConnStrOutMax); if (hide_str) free(hide_str); } #endif /* FORCE_PASSWORD_DISPLAY */ MYLOG(0, "leaving %d\n", result); return result; } #ifdef WIN32 RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci) { LRESULT dialog_result; MYLOG(0, "entering ci = %p\n", ci); if (hwnd) { dialog_result = DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_CONFIG), hwnd, dconn_FDriverConnectProc, (LPARAM) ci); if (-1 == dialog_result) { int errc = GetLastError(); MYLOG(0, " LastError=%d\n", errc); } if (!dialog_result || (dialog_result == -1)) return SQL_NO_DATA_FOUND; else return SQL_SUCCESS; } MYLOG(0, " No window specified\n"); return SQL_ERROR; } LRESULT CALLBACK dconn_FDriverConnectProc( HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { ConnInfo *ci; char strbuf[64]; switch (wMsg) { case WM_INITDIALOG: ci = (ConnInfo *) lParam; /* Change the caption for the setup dialog */ SetWindowText(hdlg, "PostgreSQL Connection"); LoadString(s_hModule, IDS_ADVANCE_CONNECTION, strbuf, sizeof(strbuf)); SetWindowText(GetDlgItem(hdlg, IDC_DATASOURCE), strbuf); /* Hide the DSN and description fields */ ShowWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_DSNAME), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_DESC), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_DRIVER), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_TEST), SW_HIDE); ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE); // ShowWindow(GetDlgItem(hdlg, IDC_DATASOURCE), SW_HIDE); if ('\0' != ci->server[0]) EnableWindow(GetDlgItem(hdlg, IDC_SERVER), FALSE); if ('\0' != ci->port[0]) EnableWindow(GetDlgItem(hdlg, IDC_PORT), FALSE); SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* Save the ConnInfo for the "OK" */ SetDlgStuff(hdlg, ci); if (ci->password_required) { HWND notu = GetDlgItem(hdlg, IDC_NOTICE_USER); SetWindowText(notu, " Supply password "); ShowWindow(notu, SW_SHOW); SendMessage(notu, WM_CTLCOLOR, 0, 0); } if (ci->database[0] == '\0') SetFocus(GetDlgItem(hdlg, IDC_DATABASE)); else if (ci->server[0] == '\0') SetFocus(GetDlgItem(hdlg, IDC_SERVER)); else if (ci->port[0] == '\0') SetFocus(GetDlgItem(hdlg, IDC_PORT)); else if (ci->username[0] == '\0') SetFocus(GetDlgItem(hdlg, IDC_USER)); else if (SAFE_NAME(ci->password)[0] == '\0' && ci->password_required) SetFocus(GetDlgItem(hdlg, IDC_PASSWORD)); break; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); GetDlgStuff(hdlg, ci); case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); return TRUE; case IDC_DATASOURCE: ci = (ConnInfo *) GetWindowLongPtr(hdlg, DWLP_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), hdlg, ds_options1Proc, (LPARAM) ci); break; } break; case WM_CTLCOLORSTATIC: if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER)) { HBRUSH hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH); SetTextColor((HDC)wParam, RGB(255, 0, 0)); return (LRESULT)hBrush; } break; } return FALSE; } #endif /* WIN32 */ #define ATTRIBUTE_DELIMITER ';' #define OPENING_BRACKET '{' #define CLOSING_BRACKET '}' typedef BOOL (*copyfunc)(ConnInfo *, const char *attribute, const char *value); static BOOL dconn_get_attributes(copyfunc func, const char *connect_string, ConnInfo *ci) { BOOL ret = TRUE; char *our_connect_string; const char *pair, *attribute, *value, *termp; BOOL eoftok; char *equals, *delp; char *strtok_arg; #ifdef HAVE_STRTOK_R char *last = NULL; #endif /* HAVE_STRTOK_R */ if (our_connect_string = strdup(connect_string), NULL == our_connect_string) return FALSE; strtok_arg = our_connect_string; #ifdef FORCE_PASSWORD_DISPLAY MYLOG(0, "our_connect_string = '%s'\n", our_connect_string); #else if (get_mylog()) { char *hide_str = hide_password(our_connect_string); MYLOG(0, "our_connect_string = '%s'\n", hide_str); free(hide_str); } #endif /* FORCE_PASSWORD_DISPLAY */ termp = strchr(our_connect_string, '\0'); eoftok = FALSE; while (!eoftok) { if (strtok_arg != NULL && strtok_arg >= termp) /* for safety */ break; #ifdef HAVE_STRTOK_R pair = strtok_r(strtok_arg, ";", &last); #else pair = strtok(strtok_arg, ";"); #endif /* HAVE_STRTOK_R */ if (strtok_arg) strtok_arg = NULL; if (!pair) break; equals = strchr(pair, '='); if (!equals) continue; *equals = '\0'; attribute = pair; /* ex. DSN */ value = equals + 1; /* ex. 'CEO co1' */ /* * Values enclosed with braces({}) can contain ; etc * We don't remove the braces here because * decode_or_remove_braces() in dlg_specific.c * would remove them later. * Just correct the misdetected delimiter(;). */ switch (*value) { const char *valuen, *closep; case OPENING_BRACKET: delp = strchr(value, '\0'); if (delp >= termp) { eoftok = TRUE; break; } /* Where's a corresponding closing bracket? */ closep = strchr(value, CLOSING_BRACKET); if (NULL != closep && closep[1] == '\0') break; for (valuen = value; valuen < termp; closep = strchr(valuen, CLOSING_BRACKET)) { if (NULL == closep) { if (!delp) /* error */ { MYLOG(0, "closing bracket doesn't exist 1\n"); ret = FALSE; goto cleanup; } closep = strchr(delp + 1, CLOSING_BRACKET); if (!closep) /* error */ { MYLOG(0, "closing bracket doesn't exist 2\n"); ret = FALSE; goto cleanup; } *delp = ATTRIBUTE_DELIMITER; /* restore delimiter */ delp = NULL; } if (CLOSING_BRACKET == closep[1]) { valuen = closep + 2; if (valuen >= termp) break; else if (valuen == delp) { *delp = ATTRIBUTE_DELIMITER; delp = NULL; } continue; } else if (ATTRIBUTE_DELIMITER == closep[1] || '\0' == closep[1] || delp == closep + 1) { delp = (char *) (closep + 1); *delp = '\0'; strtok_arg = delp + 1; if (strtok_arg + 1 >= termp) eoftok = TRUE; break; } MYLOG(0, "subsequent char to the closing bracket is %c value=%s\n", closep[1], value); ret = FALSE; goto cleanup; } } /* Copy the appropriate value to the conninfo */ (*func)(ci, attribute, value); } cleanup: free(our_connect_string); return ret; } static BOOL dconn_get_DSN_or_Driver(const char *connect_string, ConnInfo *ci) { CC_conninfo_init(ci, INIT_GLOBALS); return dconn_get_attributes(get_DSN_or_Driver, connect_string, ci); } static BOOL dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci) { return dconn_get_attributes(copyConnAttributes, connect_string, ci); } psqlodbc-REL-16_00_0005/editConfiguration.bat000077500000000000000000000002261462406103600206460ustar00rootroot00000000000000:: :: Start editConfiguration with a mimimized console window :: powershell -Sta -WindowStyle Minimized "& '%~dp0\winbuild\editConfiguration.ps1' %*" psqlodbc-REL-16_00_0005/environ.c000066400000000000000000000351741462406103600163340ustar00rootroot00000000000000/*------- * Module: environ.c * * Description: This module contains routines related to * the environment, such as storing connection handles, * and returning errors. * * Classes: EnvironmentClass (Functions prefix: "EN_") * * API functions: SQLAllocEnv, SQLFreeEnv, SQLError * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "environ.h" #include "misc.h" #include "connection.h" #include "dlg_specific.h" #include "statement.h" #include #include #include "pgapifunc.h" #ifdef WIN32 #include #endif /* WIN32 */ #include "loadlib.h" /* The one instance of the handles */ static int conns_count = 0; static ConnectionClass **conns = NULL; #if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION conns_cs; CRITICAL_SECTION common_cs; /* commonly used for short term blocking */ CRITICAL_SECTION common_lcs; /* commonly used for not necessarily short term blocking */ #elif defined(POSIX_MULTITHREAD_SUPPORT) pthread_mutex_t conns_cs; pthread_mutex_t common_cs; pthread_mutex_t common_lcs; #endif /* WIN_MULTITHREAD_SUPPORT */ void shortterm_common_lock(void) { ENTER_COMMON_CS; } void shortterm_common_unlock(void) { LEAVE_COMMON_CS; } int getConnCount(void) { return conns_count; } ConnectionClass * const *getConnList(void) { return conns; } RETCODE SQL_API PGAPI_AllocEnv(HENV * phenv) { CSTR func = "PGAPI_AllocEnv"; SQLRETURN ret = SQL_SUCCESS; MYLOG(0, "entering\n"); /* * For systems on which none of the constructor-making * techniques in psqlodbc.c work: * It's ok to call initialize_global_cs() twice. */ { initialize_global_cs(); } *phenv = (HENV) EN_Constructor(); if (!*phenv) { *phenv = SQL_NULL_HENV; EN_log_error(func, "Error allocating environment", NULL); ret = SQL_ERROR; } MYLOG(0, "leaving phenv=%p\n", *phenv); return ret; } RETCODE SQL_API PGAPI_FreeEnv(HENV henv) { CSTR func = "PGAPI_FreeEnv"; SQLRETURN ret = SQL_SUCCESS; EnvironmentClass *env = (EnvironmentClass *) henv; MYLOG(0, "entering env=%p\n", env); if (env && EN_Destructor(env)) { MYLOG(0, " ok\n"); goto cleanup; } ret = SQL_ERROR; EN_log_error(func, "Error freeing environment", NULL); cleanup: return ret; } #define SIZEOF_SQLSTATE 6 static void pg_sqlstate_set(const EnvironmentClass *env, UCHAR *szSqlState, const char *ver3str, const char *ver2str) { strncpy_null((char *) szSqlState, EN_is_odbc3(env) ? ver3str : ver2str, SIZEOF_SQLSTATE); } PG_ErrorInfo * ER_Constructor(SDWORD errnumber, const char *msg) { PG_ErrorInfo *error; ssize_t aladd, errsize; if (DESC_OK == errnumber) return NULL; if (msg) { errsize = strlen(msg); aladd = errsize - sizeof(error->__error_message) + 1; if (aladd < 0) aladd = 0; } else { errsize = -1; aladd = 0; } error = (PG_ErrorInfo *) malloc(sizeof(PG_ErrorInfo) + aladd); if (error) { memset(error, 0, sizeof(PG_ErrorInfo)); error->status = errnumber; error->errorsize = (Int2) errsize; if (errsize > 0) memcpy(error->__error_message, msg, errsize); error->__error_message[errsize] = '\0'; error->recsize = -1; } return error; } void ER_Destructor(PG_ErrorInfo *self) { free(self); } PG_ErrorInfo * ER_Dup(const PG_ErrorInfo *self) { PG_ErrorInfo *new; Int4 alsize; if (!self) return NULL; alsize = sizeof(PG_ErrorInfo); if (self->errorsize > 0) alsize += self->errorsize; new = (PG_ErrorInfo *) malloc(alsize); if (new) memcpy(new, self, alsize); return new; } #define DRVMNGRDIV 511 /* Returns the next SQL error information. */ RETCODE SQL_API ER_ReturnError(PG_ErrorInfo *pgerror, SQLSMALLINT RecNumber, SQLCHAR * szSqlState, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT * pcbErrorMsg, UWORD flag) { /* CC: return an error of a hstmt */ PG_ErrorInfo *error; BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0); const char *msg; UWORD msglen, wrtlen, pcblen; UInt4 stapos; if (!pgerror) return SQL_NO_DATA_FOUND; error = pgerror; msg = error->__error_message; MYLOG(0, "entering status = %d, msg = #%s#\n", error->status, msg); msglen = (SQLSMALLINT) strlen(msg); /* * Even though an application specifies a larger error message * buffer, the driver manager changes it silently. * Therefore we divide the error message into ... */ if (error->recsize < 0) { if (cbErrorMsgMax > 0) error->recsize = cbErrorMsgMax - 1; /* apply the first request */ else error->recsize = DRVMNGRDIV; } else if (1 == RecNumber && cbErrorMsgMax > 0) error->recsize = cbErrorMsgMax - 1; if (RecNumber < 0) { if (0 == error->errorpos) RecNumber = 1; else RecNumber = 2 + (error->errorpos - 1) / error->recsize; } stapos = (RecNumber - 1) * error->recsize; if (stapos > msglen) return SQL_NO_DATA_FOUND; pcblen = wrtlen = msglen - stapos; if (pcblen > error->recsize) pcblen = error->recsize; if (0 == cbErrorMsgMax) wrtlen = 0; else if (wrtlen >= cbErrorMsgMax) { if (partial_ok) wrtlen = cbErrorMsgMax - 1; else if (cbErrorMsgMax <= error->recsize) wrtlen = cbErrorMsgMax - 1; else wrtlen = error->recsize; } if (wrtlen > pcblen) wrtlen = pcblen; if (NULL != pcbErrorMsg) *pcbErrorMsg = pcblen; if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) { memcpy(szErrorMsg, msg + stapos, wrtlen); szErrorMsg[wrtlen] = '\0'; } if (NULL != pfNativeError) *pfNativeError = error->status; if (NULL != szSqlState) strncpy_null((char *) szSqlState, error->sqlstate, 6); MYLOG(0, " szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, pcblen, szErrorMsg); if (wrtlen < pcblen) return SQL_SUCCESS_WITH_INFO; else return SQL_SUCCESS; } RETCODE SQL_API PGAPI_ConnectError(HDBC hdbc, SQLSMALLINT RecNumber, SQLCHAR * szSqlState, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT * pcbErrorMsg, UWORD flag) { ConnectionClass *conn = (ConnectionClass *) hdbc; EnvironmentClass *env = (EnvironmentClass *) conn->henv; char *msg; int status; BOOL once_again = FALSE; ssize_t msglen; MYLOG(0, "entering hdbc=%p <%d>\n", hdbc, cbErrorMsgMax); if (RecNumber != 1 && RecNumber != -1) return SQL_NO_DATA_FOUND; if (cbErrorMsgMax < 0) return SQL_ERROR; if (CONN_EXECUTING == conn->status || !CC_get_error(conn, &status, &msg) || NULL == msg) { MYLOG(0, "CC_Get_error returned nothing.\n"); if (NULL != szSqlState) strncpy_null((char *) szSqlState, "00000", SIZEOF_SQLSTATE); if (NULL != pcbErrorMsg) *pcbErrorMsg = 0; if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) szErrorMsg[0] = '\0'; return SQL_NO_DATA_FOUND; } MYLOG(0, "CC_get_error: status = %d, msg = #%s#\n", status, msg); msglen = strlen(msg); if (NULL != pcbErrorMsg) { *pcbErrorMsg = (SQLSMALLINT) msglen; if (cbErrorMsgMax == 0) once_again = TRUE; else if (msglen >= cbErrorMsgMax) *pcbErrorMsg = cbErrorMsgMax - 1; } if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) strncpy_null((char *) szErrorMsg, msg, cbErrorMsgMax); if (NULL != pfNativeError) *pfNativeError = status; if (NULL != szSqlState) { if (conn->sqlstate[0]) strncpy_null((char *) szSqlState, conn->sqlstate, SIZEOF_SQLSTATE); else switch (status) { case CONN_OPTION_VALUE_CHANGED: pg_sqlstate_set(env, szSqlState, "01S02", "01S02"); break; case CONN_TRUNCATED: pg_sqlstate_set(env, szSqlState, "01004", "01004"); /* data truncated */ break; case CONN_INIREAD_ERROR: pg_sqlstate_set(env, szSqlState, "IM002", "IM002"); /* data source not found */ break; case CONNECTION_SERVER_NOT_REACHED: case CONN_OPENDB_ERROR: pg_sqlstate_set(env, szSqlState, "08001", "08001"); /* unable to connect to data source */ break; case CONN_INVALID_AUTHENTICATION: case CONN_AUTH_TYPE_UNSUPPORTED: pg_sqlstate_set(env, szSqlState, "28000", "28000"); break; case CONN_STMT_ALLOC_ERROR: pg_sqlstate_set(env, szSqlState, "HY001", "S1001"); /* memory allocation failure */ break; case CONN_IN_USE: pg_sqlstate_set(env, szSqlState, "HY000", "S1000"); /* general error */ break; case CONN_UNSUPPORTED_OPTION: pg_sqlstate_set(env, szSqlState, "HYC00", "IM001"); /* driver does not support this function */ break; case CONN_INVALID_ARGUMENT_NO: pg_sqlstate_set(env, szSqlState, "HY009", "S1009"); /* invalid argument value */ break; case CONN_TRANSACT_IN_PROGRES: pg_sqlstate_set(env, szSqlState, "HY011", "S1011"); break; case CONN_NO_MEMORY_ERROR: pg_sqlstate_set(env, szSqlState, "HY001", "S1001"); break; case CONN_NOT_IMPLEMENTED_ERROR: pg_sqlstate_set(env, szSqlState, "HYC00", "S1C00"); break; case CONN_ILLEGAL_TRANSACT_STATE: pg_sqlstate_set(env, szSqlState, "25000", "S1010"); break; case CONN_VALUE_OUT_OF_RANGE: pg_sqlstate_set(env, szSqlState, "HY019", "22003"); break; case CONNECTION_COULD_NOT_SEND: case CONNECTION_COULD_NOT_RECEIVE: case CONNECTION_COMMUNICATION_ERROR: case CONNECTION_NO_RESPONSE: pg_sqlstate_set(env, szSqlState, "08S01", "08S01"); break; default: pg_sqlstate_set(env, szSqlState, "HY000", "S1000"); /* general error */ break; } } MYLOG(0, " szSqlState = '%s',len=" FORMAT_SSIZE_T ", szError='%s'\n", szSqlState ? (char *) szSqlState : PRINT_NULL, msglen, szErrorMsg ? (char *) szErrorMsg : PRINT_NULL); if (once_again) { CC_set_errornumber(conn, status); return SQL_SUCCESS_WITH_INFO; } else return SQL_SUCCESS; } RETCODE SQL_API PGAPI_EnvError(HENV henv, SQLSMALLINT RecNumber, SQLCHAR * szSqlState, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT * pcbErrorMsg, UWORD flag) { EnvironmentClass *env = (EnvironmentClass *) henv; char *msg = NULL; int status; MYLOG(0, "entering henv=%p <%d>\n", henv, cbErrorMsgMax); if (RecNumber != 1 && RecNumber != -1) return SQL_NO_DATA_FOUND; if (cbErrorMsgMax < 0) return SQL_ERROR; if (!EN_get_error(env, &status, &msg) || NULL == msg) { MYLOG(0, "EN_get_error: msg = #%s#\n", msg); if (NULL != szSqlState) pg_sqlstate_set(env, szSqlState, "00000", "00000"); if (NULL != pcbErrorMsg) *pcbErrorMsg = 0; if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) szErrorMsg[0] = '\0'; return SQL_NO_DATA_FOUND; } MYLOG(0, "EN_get_error: status = %d, msg = #%s#\n", status, msg); if (NULL != pcbErrorMsg) *pcbErrorMsg = (SQLSMALLINT) strlen(msg); if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) strncpy_null((char *) szErrorMsg, msg, cbErrorMsgMax); if (NULL != pfNativeError) *pfNativeError = status; if (szSqlState) { switch (status) { case ENV_ALLOC_ERROR: /* memory allocation failure */ pg_sqlstate_set(env, szSqlState, "HY001", "S1001"); break; default: pg_sqlstate_set(env, szSqlState, "HY000", "S1000"); /* general error */ break; } } return SQL_SUCCESS; } /* * EnvironmentClass implementation */ EnvironmentClass * EN_Constructor(void) { EnvironmentClass *rv = NULL; #ifdef WIN32 WORD wVersionRequested; WSADATA wsaData; const int major = 2, minor = 2; /* Load the WinSock Library */ wVersionRequested = MAKEWORD(major, minor); if (WSAStartup(wVersionRequested, &wsaData)) { MYLOG(0, " WSAStartup error\n"); return rv; } /* Verify that this is the minimum version of WinSock */ if (LOBYTE(wsaData.wVersion) >= 1 && (LOBYTE(wsaData.wVersion) >= 2 || HIBYTE(wsaData.wVersion) >= 1)) ; else { MYLOG(0, " WSAStartup version=(%d,%d)\n", LOBYTE(wsaData.wVersion), HIBYTE(wsaData.wVersion)); goto cleanup; } #endif /* WIN32 */ rv = (EnvironmentClass *) malloc(sizeof(EnvironmentClass)); if (NULL == rv) { MYLOG(0, " malloc error\n"); goto cleanup; } rv->errormsg = 0; rv->errornumber = 0; rv->flag = 0; INIT_ENV_CS(rv); cleanup: #ifdef WIN32 if (NULL == rv) { WSACleanup(); } #endif /* WIN32 */ return rv; } char EN_Destructor(EnvironmentClass *self) { int lf, nullcnt; char rv = 1; MYLOG(0, "entering self=%p\n", self); if (!self) return 0; /* * the error messages are static strings distributed throughout the * source--they should not be freed */ /* Free any connections belonging to this environment */ ENTER_CONNS_CS; for (lf = 0, nullcnt = 0; lf < conns_count; lf++) { if (NULL == conns[lf]) nullcnt++; else if (conns[lf]->henv == self) { if (CC_Destructor(conns[lf])) conns[lf] = NULL; else rv = 0; nullcnt++; } } if (conns && nullcnt >= conns_count) { MYLOG(0, "clearing conns count=%d\n", conns_count); free(conns); conns = NULL; conns_count = 0; } LEAVE_CONNS_CS; DELETE_ENV_CS(self); free(self); #ifdef WIN32 WSACleanup(); #endif MYLOG(0, "leaving rv=%d\n", rv); #ifdef _MEMORY_DEBUG_ debug_memory_check(); #endif /* _MEMORY_DEBUG_ */ return rv; } char EN_get_error(EnvironmentClass *self, int *number, char **message) { if (self && self->errormsg && self->errornumber) { *message = self->errormsg; *number = self->errornumber; self->errormsg = 0; self->errornumber = 0; return 1; } else return 0; } #define INIT_CONN_COUNT 128 char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) { int i, alloc; ConnectionClass **newa; char ret = FALSE; MYLOG(0, "entering self = %p, conn = %p\n", self, conn); ENTER_CONNS_CS; for (i = 0; i < conns_count; i++) { if (!conns[i]) { conn->henv = self; conns[i] = conn; ret = TRUE; MYLOG(0, " added at i=%d, conn->henv = %p, conns[i]->henv = %p\n", i, conn->henv, conns[i]->henv); goto cleanup; } } if (conns_count > 0) alloc = 2 * conns_count; else alloc = INIT_CONN_COUNT; if (newa = (ConnectionClass **) realloc(conns, alloc * sizeof(ConnectionClass *)), NULL == newa) goto cleanup; conn->henv = self; newa[conns_count] = conn; conns = newa; ret = TRUE; MYLOG(0, " added at %d, conn->henv = %p, conns[%d]->henv = %p\n", conns_count, conn->henv, conns_count, conns[conns_count]->henv); for (i = conns_count + 1; i < alloc; i++) conns[i] = NULL; conns_count = alloc; cleanup: LEAVE_CONNS_CS; return ret; } char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) { int i; for (i = 0; i < conns_count; i++) if (conns[i] == conn && conns[i]->status != CONN_EXECUTING) { ENTER_CONNS_CS; conns[i] = NULL; LEAVE_CONNS_CS; return TRUE; } return FALSE; } void EN_log_error(const char *func, char *desc, EnvironmentClass *self) { if (self) MYLOG(0, "ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg); else MYLOG(0, "INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", func, desc); } psqlodbc-REL-16_00_0005/environ.h000066400000000000000000000066751462406103600163450ustar00rootroot00000000000000/* * * Description: See "environ.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __ENVIRON_H__ #define __ENVIRON_H__ #ifdef __cplusplus extern "C" { #endif #include "psqlodbc.h" #if defined (POSIX_MULTITHREAD_SUPPORT) #include #endif #define ENV_ALLOC_ERROR 1 /********** Environment Handle *************/ struct EnvironmentClass_ { char *errormsg; int errornumber; Int4 flag; #if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) pthread_mutex_t cs; #endif /* WIN_MULTITHREAD_SUPPORT */ }; /* Environment prototypes */ EnvironmentClass *EN_Constructor(void); char EN_Destructor(EnvironmentClass *self); char EN_get_error(EnvironmentClass *self, int *number, char **message); char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn); char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn); void EN_log_error(const char *func, char *desc, EnvironmentClass *self); int getConnCount(void); ConnectionClass * const *getConnList(void); #define EN_OV_ODBC2 1L #define EN_CONN_POOLING (1L<<1) #define EN_is_odbc2(env) (((env)->flag & EN_OV_ODBC2) != 0) #define EN_is_odbc3(env) ((env) && ((env)->flag & EN_OV_ODBC2) == 0) #define EN_set_odbc2(env) ((env)->flag |= EN_OV_ODBC2) #define EN_set_odbc3(env) ((env)->flag &= ~EN_OV_ODBC2) #define EN_is_pooling(env) ((env) && ((env)->flag & EN_CONN_POOLING) != 0) #define EN_set_pooling(env) ((env)->flag |= EN_CONN_POOLING) #define EN_unset_pooling(env) ((env)->flag &= ~EN_CONN_POOLING) /* For Multi-thread */ #if defined( WIN_MULTITHREAD_SUPPORT) #define INIT_CONNS_CS InitializeCriticalSection(&conns_cs) #define ENTER_CONNS_CS EnterCriticalSection(&conns_cs) #define LEAVE_CONNS_CS LeaveCriticalSection(&conns_cs) #define DELETE_CONNS_CS DeleteCriticalSection(&conns_cs) #define INIT_ENV_CS(x) InitializeCriticalSection(&((x)->cs)) #define ENTER_ENV_CS(x) EnterCriticalSection(&((x)->cs)) #define LEAVE_ENV_CS(x) LeaveCriticalSection(&((x)->cs)) #define DELETE_ENV_CS(x) DeleteCriticalSection(&((x)->cs)) #define INIT_COMMON_CS InitializeCriticalSection(&common_cs) #define ENTER_COMMON_CS EnterCriticalSection(&common_cs) #define LEAVE_COMMON_CS LeaveCriticalSection(&common_cs) #define DELETE_COMMON_CS DeleteCriticalSection(&common_cs) #elif defined(POSIX_MULTITHREAD_SUPPORT) #define INIT_CONNS_CS pthread_mutex_init(&conns_cs,0) #define ENTER_CONNS_CS pthread_mutex_lock(&conns_cs) #define LEAVE_CONNS_CS pthread_mutex_unlock(&conns_cs) #define DELETE_CONNS_CS pthread_mutex_destroy(&conns_cs) #define INIT_ENV_CS(x) pthread_mutex_init(&((x)->cs),0) #define ENTER_ENV_CS(x) pthread_mutex_lock(&((x)->cs)) #define LEAVE_ENV_CS(x) pthread_mutex_unlock(&((x)->cs)) #define DELETE_ENV_CS(x) pthread_mutex_destroy(&((x)->cs)) #define INIT_COMMON_CS pthread_mutex_init(&common_cs,0) #define ENTER_COMMON_CS pthread_mutex_lock(&common_cs) #define LEAVE_COMMON_CS pthread_mutex_unlock(&common_cs) #define DELETE_COMMON_CS pthread_mutex_destroy(&common_cs) #else #define INIT_CONNS_CS #define ENTER_CONNS_CS #define LEAVE_CONNS_CS #define DELETE_CONNS_CS #define INIT_ENV_CS(x) #define ENTER_ENV_CS(x) #define LEAVE_ENV_CS(x) #define DELETE_ENV_CS(x) #define INIT_COMMON_CS #define ENTER_COMMON_CS #define LEAVE_COMMON_CS #define DELETE_COMMON_CS #endif /* WIN_MULTITHREAD_SUPPORT */ void shortterm_common_lock(void); void shortterm_common_unlock(void); #ifdef __cplusplus } #endif #endif /* __ENVIRON_H_ */ psqlodbc-REL-16_00_0005/execute.c000066400000000000000000001310771462406103600163150ustar00rootroot00000000000000/*------- * Module: execute.c * * Description: This module contains routines related to * preparing and executing an SQL statement. * * Classes: n/a * * API functions: SQLPrepare, SQLExecute, SQLExecDirect, SQLTransact, * SQLCancel, SQLNativeSql, SQLParamData, SQLPutData * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "psqlodbc.h" #include "misc.h" #include #include #ifndef WIN32 #include #endif /* WIN32 */ #include "environ.h" #include "connection.h" #include "statement.h" #include "qresult.h" #include "convert.h" #include "bind.h" #include "pgtypes.h" #include "lobj.h" #include "pgapifunc.h" /* Perform a Prepare on the SQL statement */ RETCODE SQL_API PGAPI_Prepare(HSTMT hstmt, const SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr) { CSTR func = "PGAPI_Prepare"; StatementClass *self = (StatementClass *) hstmt; RETCODE retval = SQL_SUCCESS; BOOL prepared; MYLOG(0, "entering...\n"); #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(self); */ /* * According to the ODBC specs it is valid to call SQLPrepare multiple * times. In that case, the bound SQL statement is replaced by the new * one */ prepared = self->prepared; SC_set_prepared(self, NOT_YET_PREPARED); switch (self->status) { case STMT_DESCRIBED: MYLOG(0, "**** STMT_DESCRIBED, recycle\n"); SC_recycle_statement(self); /* recycle the statement, but do * not remove parameter bindings */ break; case STMT_FINISHED: MYLOG(0, "**** STMT_FINISHED, recycle\n"); SC_recycle_statement(self); /* recycle the statement, but do * not remove parameter bindings */ break; case STMT_ALLOCATED: MYLOG(0, "**** STMT_ALLOCATED, copy\n"); self->status = STMT_READY; break; case STMT_READY: MYLOG(0, "**** STMT_READY, change SQL\n"); if (NOT_YET_PREPARED != prepared) SC_recycle_statement(self); /* recycle the statement */ break; case STMT_EXECUTING: MYLOG(0, "**** STMT_EXECUTING, error!\n"); SC_set_error(self, STMT_SEQUENCE_ERROR, "PGAPI_Prepare(): The handle does not point to a statement that is ready to be executed", func); retval = SQL_ERROR; goto cleanup; default: SC_set_error(self, STMT_INTERNAL_ERROR, "An Internal Error has occurred -- Unknown statement status.", func); retval = SQL_ERROR; goto cleanup; } SC_initialize_stmts(self, TRUE); if (!szSqlStr) { SC_set_error(self, STMT_NO_MEMORY_ERROR, "the query is NULL", func); retval = SQL_ERROR; goto cleanup; } if (!szSqlStr[0]) self->statement = strdup(""); else self->statement = make_string(szSqlStr, cbSqlStr, NULL, 0); if (!self->statement) { SC_set_error(self, STMT_NO_MEMORY_ERROR, "No memory available to store statement", func); retval = SQL_ERROR; goto cleanup; } self->prepare = PREPARE_STATEMENT; self->statement_type = statement_type(self->statement); /* Check if connection is onlyread (only selects are allowed) */ if (CC_is_onlyread(SC_get_conn(self)) && STMT_UPDATE(self)) { SC_set_error(self, STMT_EXEC_ERROR, "Connection is readonly, only select statements are allowed.", func); retval = SQL_ERROR; goto cleanup; } cleanup: #undef return MYLOG(DETAIL_LOG_LEVEL, "leaving %d\n", retval); return retval; } /* Performs the equivalent of SQLPrepare, followed by SQLExecute. */ RETCODE SQL_API PGAPI_ExecDirect(HSTMT hstmt, const SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr, UWORD flag) { StatementClass *stmt = (StatementClass *) hstmt; RETCODE result; CSTR func = "PGAPI_ExecDirect"; const ConnectionClass *conn = SC_get_conn(stmt); MYLOG(0, "entering...%x\n", flag); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; /* * keep a copy of the un-parametrized statement, in case they try to * execute this statement again */ stmt->statement = make_string(szSqlStr, cbSqlStr, NULL, 0); MYLOG(DETAIL_LOG_LEVEL, "a2\n"); if (!stmt->statement) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "No memory available to store statement", func); return SQL_ERROR; } MYLOG(0, "**** hstmt=%p, statement='%s'\n", hstmt, stmt->statement); if (0 != (flag & PODBC_WITH_HOLD)) SC_set_with_hold(stmt); if (0 != (flag & PODBC_RDONLY)) SC_set_readonly(stmt); /* * If an SQLPrepare was performed prior to this, but was left in the * described state because an error occurred prior to SQLExecute then * set the statement to finished so it can be recycled. */ if (stmt->status == STMT_DESCRIBED) stmt->status = STMT_FINISHED; stmt->statement_type = statement_type(stmt->statement); /* Check if connection is onlyread (only selects are allowed) */ if (CC_is_onlyread(conn) && STMT_UPDATE(stmt)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Connection is readonly, only select statements are allowed.", func); return SQL_ERROR; } MYLOG(0, "calling PGAPI_Execute...\n"); result = PGAPI_Execute(hstmt, flag); MYLOG(0, "leaving %hd\n", result); return result; } static int inquireHowToPrepare(const StatementClass *stmt) { ConnectionClass *conn; ConnInfo *ci; int ret = 0; conn = SC_get_conn(stmt); ci = &(conn->connInfo); if (!stmt->use_server_side_prepare) { /* Do prepare operations by the driver itself */ return PREPARE_BY_THE_DRIVER; } if (NOT_YET_PREPARED == stmt->prepared) { SQLSMALLINT num_params; if (STMT_TYPE_DECLARE == stmt->statement_type && PG_VERSION_LT(conn, 8.0)) { return PREPARE_BY_THE_DRIVER; } if (stmt->multi_statement < 0) PGAPI_NumParams((StatementClass *) stmt, &num_params); if (stmt->multi_statement > 0) { /* * divide the query into multiple commands and apply V3 parse * requests for each of them */ ret = PARSE_REQ_FOR_INFO; } else { if (SC_may_use_cursor(stmt)) { if (ci->drivers.use_declarefetch) return PARSE_REQ_FOR_INFO; else if (SQL_CURSOR_FORWARD_ONLY != stmt->options.cursor_type) ret = PARSE_REQ_FOR_INFO; else ret = PARSE_TO_EXEC_ONCE; } else ret = PARSE_TO_EXEC_ONCE; } } if (SC_is_prepare_statement(stmt) && (PARSE_TO_EXEC_ONCE == ret)) ret = NAMED_PARSE_REQUEST; return ret; } int decideHowToPrepare(StatementClass *stmt, BOOL force) { int method = SC_get_prepare_method(stmt); if (0 != method) /* a method was already determined */ return method; switch (stmt->prepare) { case NON_PREPARE_STATEMENT: /* not a prepare statement */ if (!force) return method; break; } method = inquireHowToPrepare(stmt); stmt->prepare |= method; if (PREPARE_BY_THE_DRIVER == method) stmt->discard_output_params = 1; return method; } /* dont/should/can send Parse request ? */ enum { doNothing = 0 ,allowParse ,preferParse ,shouldParse ,usingCommand }; #define ONESHOT_CALL_PARSE allowParse #define NOPARAM_ONESHOT_CALL_PARSE doNothing static int HowToPrepareBeforeExec(StatementClass *stmt, BOOL checkOnly) { SQLSMALLINT num_params = stmt->num_params; ConnectionClass *conn = SC_get_conn(stmt); ConnInfo *ci = &(conn->connInfo); int nCallParse = doNothing, how_to_prepare = 0; BOOL bNeedsTrans = FALSE; if (num_params < 0) PGAPI_NumParams(stmt, &num_params); how_to_prepare = decideHowToPrepare(stmt, checkOnly); if (checkOnly) { if (num_params <= 0) return doNothing; } else { switch (how_to_prepare) { case NAMED_PARSE_REQUEST: return shouldParse; case PARSE_TO_EXEC_ONCE: switch (stmt->prepared) { case PREPARED_TEMPORARILY: nCallParse = preferParse; break; default: if (num_params <= 0) nCallParse = NOPARAM_ONESHOT_CALL_PARSE; else nCallParse = ONESHOT_CALL_PARSE; } break; default: return doNothing; } } if (num_params > 0) { int param_number = -1; ParameterInfoClass *apara; ParameterImplClass *ipara; OID pgtype; while (TRUE) { SC_param_next(stmt, ¶m_number, &apara, &ipara); if (!ipara || !apara) break; pgtype = PIC_get_pgtype(*ipara); if (checkOnly) { switch (ipara->SQLType) { case SQL_LONGVARBINARY: if (0 == pgtype) { if (ci->bytea_as_longvarbinary && 0 != conn->lobj_type) nCallParse = shouldParse; } break; case SQL_CHAR: if (ci->cvt_null_date_string) nCallParse = shouldParse; break; case SQL_VARCHAR: if (ci->drivers.bools_as_char && PG_WIDTH_OF_BOOLS_AS_CHAR == ipara->column_size) nCallParse = shouldParse; break; } } else { BOOL bBytea = FALSE; switch (ipara->SQLType) { case SQL_LONGVARBINARY: if (conn->lobj_type == pgtype || PG_TYPE_OID == pgtype) bNeedsTrans = TRUE; else if (PG_TYPE_BYTEA == pgtype) bBytea = TRUE; else if (0 == pgtype) { if (ci->bytea_as_longvarbinary) bBytea = TRUE; else bNeedsTrans = TRUE; } if (bBytea) if (nCallParse < preferParse) nCallParse = preferParse; break; } } } } if (bNeedsTrans && PARSE_TO_EXEC_ONCE == how_to_prepare) { if (!CC_is_in_trans(conn) && CC_does_autocommit(conn)) nCallParse = doNothing; } return nCallParse; } static const char *GetSvpName(const ConnectionClass *conn, char *wrk, int wrksize) { snprintf(wrk, wrksize, "_EXEC_SVP_%p", conn); return wrk; } /* * The execution after all parameters were resolved. */ #define INVALID_EXPBUFFER PQExpBufferDataBroken(stmt->stmt_deffered) #define VALID_EXPBUFFER (!PQExpBufferDataBroken(stmt->stmt_deffered)) static void param_status_batch_update(IPDFields *ipdopts, RETCODE retval, SQLLEN target_row, int count_of_deffered) { int i, j; if (NULL != ipdopts->param_status_ptr) { for (i = target_row, j = 0; i >= 0 && j <= count_of_deffered; i--) { if (SQL_PARAM_UNUSED != ipdopts->param_status_ptr[i]) { ipdopts->param_status_ptr[i] = retval; j++; } } } } static RETCODE Exec_with_parameters_resolved(StatementClass *stmt, EXEC_TYPE exec_type, BOOL *exec_end) { CSTR func = "Exec_with_parameters_resolved"; RETCODE retval; SQLLEN start_row, end_row; SQLINTEGER cursor_type, scroll_concurrency; ConnectionClass *conn; QResultClass *res; APDFields *apdopts; IPDFields *ipdopts; BOOL prepare_before_exec = FALSE; char *stmt_with_params; SQLLEN status_row = stmt->exec_current_row; int count_of_deffered; *exec_end = FALSE; conn = SC_get_conn(stmt); MYLOG(0, "copying statement params: trans_status=%d, len=" FORMAT_SIZE_T ", stmt='%s'\n", conn->transact_status, strlen(stmt->statement), stmt->statement); #define return DONT_CALL_RETURN_FROM_HERE??? #define RETURN(code) { retval = code; goto cleanup; } ENTER_CONN_CS(conn); /* save the cursor's info before the execution */ cursor_type = stmt->options.cursor_type; scroll_concurrency = stmt->options.scroll_concurrency; /* Prepare the statement if possible at backend side */ if (HowToPrepareBeforeExec(stmt, FALSE) >= allowParse) prepare_before_exec = TRUE; MYLOG(DETAIL_LOG_LEVEL, "prepare_before_exec=%d srv=%d\n", prepare_before_exec, stmt->use_server_side_prepare); /* Create the statement with parameters substituted. */ stmt_with_params = stmt->stmt_with_params; if (LAST_EXEC == exec_type) { if (NULL != stmt_with_params) { free(stmt_with_params); stmt_with_params = stmt->stmt_with_params = NULL; } if (INVALID_EXPBUFFER || !stmt->stmt_deffered.data[0]) RETURN(SQL_SUCCESS); } else { retval = copy_statement_with_parameters(stmt, prepare_before_exec); stmt->current_exec_param = -1; if (retval != SQL_SUCCESS) { stmt->exec_current_row = -1; *exec_end = TRUE; RETURN(retval) /* error msg is passed from the above */ } stmt_with_params = stmt->stmt_with_params; if (!stmt_with_params) // Extended Protocol exec_type = DIRECT_EXEC; } MYLOG(0, " stmt_with_params = '%s'\n", stmt->stmt_with_params); /* * The real execution. */ MYLOG(0, "about to begin SC_execute exec_type=%d\n", exec_type); ipdopts = SC_get_IPDF(stmt); apdopts = SC_get_APDF(stmt); if (start_row = stmt->exec_start_row, start_row < 0) start_row = 0; if (end_row = stmt->exec_end_row, end_row < 0) { end_row = (SQLINTEGER) apdopts->paramset_size - 1; if (end_row < 0) end_row = 0; } if (LAST_EXEC == exec_type && NULL != ipdopts->param_status_ptr) { int i; for (i = end_row; i >= start_row; i--) { if (SQL_PARAM_UNUSED != ipdopts->param_status_ptr[i]) { status_row = i; break; } } } count_of_deffered = stmt->count_of_deffered; if (DIRECT_EXEC == exec_type) { retval = SC_execute(stmt); stmt->count_of_deffered = 0; } else if (DEFFERED_EXEC == exec_type && stmt->exec_current_row < end_row && stmt->count_of_deffered + 1 < stmt->batch_size) { if (INVALID_EXPBUFFER) initPQExpBuffer(&stmt->stmt_deffered); if (INVALID_EXPBUFFER) { retval = SQL_ERROR; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory", __FUNCTION__); } else { if (NULL != stmt_with_params) { if (stmt->stmt_deffered.data[0]) appendPQExpBuffer(&stmt->stmt_deffered, ";%s", stmt_with_params); else printfPQExpBuffer(&stmt->stmt_deffered, "%s", stmt_with_params); } if (NULL != ipdopts->param_status_ptr) ipdopts->param_status_ptr[stmt->exec_current_row] = SQL_PARAM_SUCCESS; // set without exec stmt->count_of_deffered++; stmt->exec_current_row++; RETURN(SQL_SUCCESS); } } else { if (VALID_EXPBUFFER) { if (NULL != stmt_with_params) appendPQExpBuffer(&stmt->stmt_deffered, ";%s", stmt_with_params); stmt->stmt_with_params = stmt->stmt_deffered.data; } retval = SC_execute(stmt); stmt->stmt_with_params = stmt_with_params; stmt->count_of_deffered = 0; if (VALID_EXPBUFFER) resetPQExpBuffer(&stmt->stmt_deffered); } if (retval == SQL_ERROR) { MYLOG(0, "count_of_deffered=%d\n", count_of_deffered); param_status_batch_update(ipdopts, SQL_PARAM_ERROR, stmt->exec_current_row, count_of_deffered); stmt->exec_current_row = -1; *exec_end = TRUE; RETURN(retval) } res = SC_get_Result(stmt); /* special handling of result for keyset driven cursors */ if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type && SQL_CONCUR_READ_ONLY != stmt->options.scroll_concurrency) { QResultClass *kres; if (kres = QR_nextr(res), kres) { QR_set_fields(kres, QR_get_fields(res)); QR_set_fields(res, NULL); kres->num_fields = res->num_fields; QR_detach(res); SC_set_Result(stmt, kres); res = kres; } } ipdopts = SC_get_IPDF(stmt); if (ipdopts->param_status_ptr) { switch (retval) { case SQL_SUCCESS: ipdopts->param_status_ptr[status_row] = SQL_PARAM_SUCCESS; break; case SQL_SUCCESS_WITH_INFO: MYLOG(0, "count_of_deffered=%d has_notice=%d\n", count_of_deffered, stmt->has_notice); param_status_batch_update(ipdopts, (count_of_deffered > 0 && !stmt->has_notice) ? SQL_PARAM_SUCCESS : SQL_PARAM_SUCCESS_WITH_INFO, status_row, count_of_deffered); break; default: param_status_batch_update(ipdopts, SQL_PARAM_ERROR, status_row, count_of_deffered); break; } } stmt->has_notice = 0; if (stmt->exec_current_row >= end_row) { *exec_end = TRUE; stmt->exec_current_row = -1; } else stmt->exec_current_row++; if (res) { EnvironmentClass *env = (EnvironmentClass *) CC_get_env(conn); const char *cmd = QR_get_command(res); if (retval == SQL_SUCCESS && NULL != cmd && start_row >= end_row && NULL != env && EN_is_odbc3(env)) { int count; if (sscanf(cmd , "UPDATE %d", &count) == 1) ; else if (sscanf(cmd , "DELETE %d", &count) == 1) ; else count = -1; if (0 == count) retval = SQL_NO_DATA; } stmt->diag_row_count = res->recent_processed_row_count; } /* * The cursor's info was changed ? */ if (retval == SQL_SUCCESS && (stmt->options.cursor_type != cursor_type || stmt->options.scroll_concurrency != scroll_concurrency)) { SC_set_error(stmt, STMT_OPTION_VALUE_CHANGED, "cursor updatability changed", func); retval = SQL_SUCCESS_WITH_INFO; } cleanup: #undef RETURN #undef return LEAVE_CONN_CS(conn); return retval; } int StartRollbackState(StatementClass *stmt) { int ret; ConnectionClass *conn; ConnInfo *ci = NULL; MYLOG(DETAIL_LOG_LEVEL, "entering %p->external=%d\n", stmt, stmt->external); conn = SC_get_conn(stmt); if (conn) ci = &conn->connInfo; if (!ci || ci->rollback_on_error < 0) /* default */ { if (conn && PG_VERSION_GE(conn, 8.0)) ret = 2; /* statement rollback */ else ret = 1; /* transaction rollback */ } else { ret = ci->rollback_on_error; if (2 == ret && PG_VERSION_LT(conn, 8.0)) ret = 1; } switch (ret) { case 1: SC_start_tc_stmt(stmt); break; case 2: SC_start_rb_stmt(stmt); break; } return ret; } int GenerateSvpCommand(ConnectionClass *conn, int type, char *cmd, int buflen) { char esavepoint[50]; int rtn = -1; cmd[0] = '\0'; switch (type) { case INTERNAL_SAVEPOINT_OPERATION: /* savepoint */ #ifdef _RELEASE_INTERNAL_SAVEPOINT if (conn->internal_svp) rtn = snprintf(cmd, buflen, "RELEASE %s;", GetSvpName(conn, esavepoint, sizeof(esavepoint))); #endif /* _RELEASE_INTERNAL_SAVEPOINT */ rtn = snprintfcat(cmd, buflen, "SAVEPOINT %s", GetSvpName(conn, esavepoint, sizeof(esavepoint))); break; case INTERNAL_ROLLBACK_OPERATION: /* rollback */ if (conn->internal_svp) rtn = snprintf(cmd, buflen, "ROLLBACK TO %s", GetSvpName(conn, esavepoint, sizeof(esavepoint))); else rtn = snprintf(cmd, buflen, "ROLLBACK"); break; } return rtn; } /* * Must be in a transaction or the subsequent execution * invokes a transaction. */ RETCODE SetStatementSvp(StatementClass *stmt, unsigned int option) { CSTR func = "SetStatementSvp"; char cmd[128]; ConnectionClass *conn = SC_get_conn(stmt); QResultClass *res; RETCODE ret = SQL_SUCCESS_WITH_INFO; if (NULL == conn->pqconn) { SC_set_error(stmt, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__); return SQL_ERROR; } if (CC_is_in_error_trans(conn)) return ret; if (!stmt->lock_CC_for_rb) { ENTER_CONN_CS(conn); stmt->lock_CC_for_rb = TRUE; } MYLOG(DETAIL_LOG_LEVEL, " %p->accessed=%d opt=%u in_progress=%u prev=%u\n", conn, CC_accessed_db(conn), option, conn->opt_in_progress, conn->opt_previous); conn->opt_in_progress &= option; switch (stmt->statement_type) { case STMT_TYPE_SPECIAL: case STMT_TYPE_TRANSACTION: return ret; } /* If rbpoint is not yet started and the previous statement was not read-only */ if (!CC_started_rbpoint(conn) && 0 == (conn->opt_previous & SVPOPT_RDONLY)) { BOOL need_savep = FALSE; if (SC_is_rb_stmt(stmt)) { if (CC_is_in_trans(conn)) /* needless to issue SAVEPOINT before the 1st command */ { need_savep = TRUE; } } if (need_savep) { if (0 != (option & SVPOPT_REDUCE_ROUNDTRIP)) { conn->internal_op = PREPEND_IN_PROGRESS; CC_set_accessed_db(conn); return ret; } GenerateSvpCommand(conn, INTERNAL_SAVEPOINT_OPERATION, cmd, sizeof(cmd)); conn->internal_op = SAVEPOINT_IN_PROGRESS; res = CC_send_query(conn, cmd, NULL, 0, NULL); conn->internal_op = 0; if (QR_command_maybe_successful(res)) ret = SQL_SUCCESS; else { SC_set_error(stmt, STMT_INTERNAL_ERROR, "internal SAVEPOINT failed", func); ret = SQL_ERROR; } QR_Destructor(res); } } CC_set_accessed_db(conn); MYLOG(DETAIL_LOG_LEVEL, "leaving %p->accessed=%d\n", conn, CC_accessed_db(conn)); return ret; } RETCODE DiscardStatementSvp(StatementClass *stmt, RETCODE ret, BOOL errorOnly) { CSTR func = "DiscardStatementSvp"; ConnectionClass *conn = SC_get_conn(stmt); BOOL start_stmt = FALSE; MYLOG(DETAIL_LOG_LEVEL, "entering %p->accessed=%d is_in=%d is_rb=%d is_tc=%d\n", conn, CC_accessed_db(conn), CC_is_in_trans(conn), SC_is_rb_stmt(stmt), SC_is_tc_stmt(stmt)); if (stmt->lock_CC_for_rb) MYLOG(0, "in_progress=%u previous=%d\n", conn->opt_in_progress, conn->opt_previous); switch (ret) { case SQL_NEED_DATA: break; case SQL_ERROR: start_stmt = TRUE; break; default: if (!errorOnly) start_stmt = TRUE; break; } if (!CC_accessed_db(conn) || !CC_is_in_trans(conn)) goto cleanup; if (!SC_is_rb_stmt(stmt) && !SC_is_tc_stmt(stmt)) goto cleanup; if (SQL_ERROR == ret) { if (CC_started_rbpoint(conn) && conn->internal_svp) { int cmd_success = CC_internal_rollback(conn, PER_STATEMENT_ROLLBACK, FALSE); if (!cmd_success) { SC_set_error(stmt, STMT_INTERNAL_ERROR, "internal ROLLBACK failed", func); goto cleanup; } } else { CC_abort(conn); goto cleanup; } } else if (errorOnly) return ret; MYLOG(DETAIL_LOG_LEVEL, "\tret=%d\n", ret); cleanup: #ifdef NOT_USED if (!SC_is_prepare_statement(stmt) && ONCE_DESCRIBED == stmt->prepared) SC_set_prepared(stmt, NOT_YET_PREPARED); #endif if (start_stmt || SQL_ERROR == ret) { stmt->execinfo = 0; if (SQL_ERROR != ret && CC_accessed_db(conn)) { conn->opt_previous = conn->opt_in_progress; CC_init_opt_in_progress(conn); } if (stmt->lock_CC_for_rb) { stmt->lock_CC_for_rb = FALSE; LEAVE_CONN_CS(conn); MYLOG(DETAIL_LOG_LEVEL, " release conn_lock\n"); } CC_start_stmt(conn); } MYLOG(DETAIL_LOG_LEVEL, "leaving %d\n", ret); return ret; } /* * Given a SQL statement, see if it is an INSERT INTO statement and extract * the name of the table (with schema) of the table that was inserted to. * (It is needed to resolve any @@identity references in the future.) */ void SC_setInsertedTable(StatementClass *stmt, RETCODE retval) { const char *cmd = stmt->statement; ConnectionClass *conn; size_t len; if (STMT_TYPE_INSERT != stmt->statement_type) return; if (!SQL_SUCCEEDED(retval)) return; conn = SC_get_conn(stmt); #ifdef NOT_USED /* give up the use of lastval() */ if (PG_VERSION_GE(conn, 8.1)) /* lastval() is available */ return; #endif /* NOT_USED */ /*if (!CC_fake_mss(conn)) return;*/ /* * Parse a statement that was just executed. If it looks like an INSERT INTO * statement, try to extract the table name (and schema) of the table that * we inserted into. * * This is by no means fool-proof, we don't implement the whole backend * lexer and grammar here, but should handle most simple INSERT statements. */ while (isspace((UCHAR) *cmd)) cmd++; if (!*cmd) return; len = 6; if (strnicmp(cmd, "insert", len)) return; cmd += len; while (isspace((UCHAR) *(++cmd))); if (!*cmd) return; len = 4; if (strnicmp(cmd, "into", len)) return; cmd += len; while (isspace((UCHAR) *cmd)) cmd++; if (!*cmd) return; NULL_THE_NAME(conn->schemaIns); NULL_THE_NAME(conn->tableIns); eatTableIdentifiers((const UCHAR *) cmd, conn->ccsc, &conn->tableIns, &conn->schemaIns); if (!NAME_IS_VALID(conn->tableIns)) NULL_THE_NAME(conn->schemaIns); } /* Execute a prepared SQL statement */ RETCODE SQL_API PGAPI_Execute(HSTMT hstmt, UWORD flag) { CSTR func = "PGAPI_Execute"; StatementClass *stmt = (StatementClass *) hstmt; RETCODE retval = SQL_SUCCESS; ConnectionClass *conn; APDFields *apdopts; IPDFields *ipdopts; SQLLEN i, start_row, end_row; BOOL exec_end = FALSE, recycled = FALSE, recycle = TRUE; SQLSMALLINT num_params; MYLOG(0, "entering...%x %p status=%d\n", flag, stmt, stmt->status); stmt->has_notice = 0; conn = SC_get_conn(stmt); apdopts = SC_get_APDF(stmt); /* * If the statement was previously described, just recycle the old result * set that contained just the column information. */ if ((stmt->prepare && stmt->status == STMT_DESCRIBED) || (stmt->status == STMT_FINISHED && 0 != (flag & PODBC_RECYCLE_STATEMENT))) { stmt->exec_current_row = -1; SC_recycle_statement(stmt); } MYLOG(0, "clear errors...\n"); SC_clear_error(stmt); if (!stmt->statement) { SC_set_error(stmt, STMT_NO_STMTSTRING, "This handle does not have a SQL statement stored in it", func); MYLOG(0, "problem with handle\n"); return SQL_ERROR; } #define return DONT_CALL_RETURN_FROM_HERE??? if (stmt->exec_current_row > 0) { /* * executing an array of parameters. * Don't recycle the statement. */ recycle = FALSE; } else if (PREPARED_PERMANENTLY == stmt->prepared || PREPARED_TEMPORARILY == stmt->prepared) { /* * re-executing an prepared statement. * Don't recycle the statement but * discard the old result. */ recycle = FALSE; SC_reset_result_for_rerun(stmt); } /* * If SQLExecute is being called again, recycle the statement. Note * this should have been done by the application in a call to * SQLFreeStmt(SQL_CLOSE) or SQLCancel. */ else if (stmt->status == STMT_FINISHED) { MYLOG(0, "recycling statement (should have been done by app)...\n"); /******** Is this really NEEDED ? ******/ SC_recycle_statement(stmt); recycled = TRUE; } /* Check if the statement is in the correct state */ else if ((stmt->prepare && stmt->status != STMT_READY) || (stmt->status != STMT_ALLOCATED && stmt->status != STMT_READY)) { SC_set_error(stmt, STMT_STATUS_ERROR, "The handle does not point to a statement that is ready to be executed", func); MYLOG(0, "problem with statement\n"); retval = SQL_ERROR; goto cleanup; } if (start_row = stmt->exec_start_row, start_row < 0) start_row = 0; if (end_row = stmt->exec_end_row, end_row < 0) { end_row = (SQLINTEGER) apdopts->paramset_size - 1; if (end_row < 0) end_row = 0; } if (stmt->exec_current_row < 0) stmt->exec_current_row = start_row; ipdopts = SC_get_IPDF(stmt); num_params = stmt->num_params; if (num_params < 0) PGAPI_NumParams(stmt, &num_params); if (stmt->exec_current_row == start_row) { /* We sometimes need to know about the PG type of binding parameters even in case of non-prepared statements. */ int nCallParse = doNothing; BOOL maybeBatch = FALSE; if (end_row > start_row && SQL_CURSOR_FORWARD_ONLY == stmt->options.cursor_type && SQL_CONCUR_READ_ONLY == stmt->options.scroll_concurrency && stmt->batch_size > 1) maybeBatch = TRUE; MYLOG(0, "prepare=%d prepared=%d batch_size=%d start_row=" FORMAT_LEN "end_row=" FORMAT_LEN " => maybeBatch=%d\n", stmt->prepare, stmt->prepared, stmt->batch_size, start_row, end_row, maybeBatch); if (NOT_YET_PREPARED == stmt->prepared) { if (maybeBatch) stmt->use_server_side_prepare = 0; switch (nCallParse = HowToPrepareBeforeExec(stmt, TRUE)) { case shouldParse: if (retval = prepareParameters(stmt, FALSE), SQL_ERROR == retval) goto cleanup; break; } } MYLOG(0, "prepareParameters was %s called, prepare state:%d\n", shouldParse == nCallParse ? "" : "not", stmt->prepare); if (shouldParse == nCallParse && PREPARE_BY_THE_DRIVER == stmt->prepare) { SC_set_Result(stmt, NULL); } if (0 != (PREPARE_BY_THE_DRIVER & stmt->prepare) && maybeBatch) stmt->exec_type = DEFFERED_EXEC; else stmt->exec_type = DIRECT_EXEC; MYLOG(0, "prepare=%d maybeBatch=%d exec_type=%d\n", stmt->prepare, maybeBatch, stmt->exec_type); if (ipdopts->param_processed_ptr) *ipdopts->param_processed_ptr = 0; /* * Initialize param_status_ptr */ if (ipdopts->param_status_ptr) { for (i = 0; i <= end_row; i++) ipdopts->param_status_ptr[i] = SQL_PARAM_UNUSED; } if (recycle && !recycled) SC_recycle_statement(stmt); if (isSqlServr() && stmt->external && 0 != stmt->prepare && PG_VERSION_LT(conn, 8.4) && SC_can_parse_statement(stmt)) parse_sqlsvr(stmt); } next_param_row: if (stmt->exec_current_row > end_row) exec_end = TRUE; else if (apdopts->param_operation_ptr) { while (apdopts->param_operation_ptr[stmt->exec_current_row] == SQL_PARAM_IGNORE) { if (stmt->exec_current_row >= end_row) { exec_end = TRUE; break; } ++stmt->exec_current_row; } } if (exec_end) { if (DEFFERED_EXEC == stmt->exec_type ) retval = Exec_with_parameters_resolved(stmt, LAST_EXEC, &exec_end); stmt->exec_current_row = -1; goto cleanup; } /* * Initialize the current row status */ if (ipdopts->param_status_ptr) ipdopts->param_status_ptr[stmt->exec_current_row] = SQL_PARAM_ERROR; /* * Free any data at exec params before the statement is * executed again or the next set of parameters is processed. * If not, then there will be a memory leak when the next * SQLParamData/SQLPutData is called. */ SC_free_params(stmt, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY); /* * Check if statement has any data-at-execute parameters when it is * not in SC_pre_execute. */ { /* * The bound parameters could have possibly changed since the last * execute of this statement? Therefore check for params and * re-copy. */ SQLULEN offset = apdopts->param_offset_ptr ? *apdopts->param_offset_ptr : 0; SQLINTEGER bind_size = apdopts->param_bind_type; SQLLEN current_row = stmt->exec_current_row < 0 ? 0 : stmt->exec_current_row; Int4 num_p = num_params < apdopts->allocated ? num_params : apdopts->allocated; /* * Increment the number of currently processed rows */ if (ipdopts->param_processed_ptr) (*ipdopts->param_processed_ptr)++; stmt->data_at_exec = -1; for (i = 0; i < num_p; i++) { SQLLEN *pcVal = apdopts->parameters[i].used; apdopts->parameters[i].data_at_exec = FALSE; if (pcVal) { if (bind_size > 0) pcVal = LENADDR_SHIFT(pcVal, offset + bind_size * current_row); else pcVal = LENADDR_SHIFT(pcVal, offset) + current_row; if (*pcVal == SQL_DATA_AT_EXEC || *pcVal <= SQL_LEN_DATA_AT_EXEC_OFFSET) apdopts->parameters[i].data_at_exec = TRUE; } /* Check for data at execution parameters */ if (apdopts->parameters[i].data_at_exec) { MYLOG(0, "The " FORMAT_LEN "th parameter of " FORMAT_LEN "-row is data at exec(" FORMAT_LEN ")\n", i, current_row, pcVal ? (*pcVal) : -1); if (stmt->data_at_exec < 0) stmt->data_at_exec = 1; else stmt->data_at_exec++; } } /* * If there are some data at execution parameters, return need * data */ /* * SQLParamData and SQLPutData will be used to send params and * execute the statement. */ if (stmt->data_at_exec > 0) { retval = SQL_NEED_DATA; goto cleanup; } } if (0 != (flag & PODBC_WITH_HOLD)) SC_set_with_hold(stmt); retval = Exec_with_parameters_resolved(stmt, stmt->exec_type, &exec_end); if (!exec_end) { goto next_param_row; } cleanup: MYLOG(0, "leaving %p retval=%d status=%d\n", stmt, retval, stmt->status); SC_setInsertedTable(stmt, retval); #undef return if (SQL_SUCCESS == retval && STMT_OK > SC_get_errornumber(stmt)) retval = SQL_SUCCESS_WITH_INFO; return retval; } RETCODE SQL_API PGAPI_Transact(HENV henv, HDBC hdbc, SQLUSMALLINT fType) { CSTR func = "PGAPI_Transact"; ConnectionClass *conn; char ok; int lf; MYLOG(0, "entering hdbc=%p, henv=%p\n", hdbc, henv); if (hdbc == SQL_NULL_HDBC && henv == SQL_NULL_HENV) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } /* * If hdbc is null and henv is valid, it means transact all * connections on that henv. */ if (hdbc == SQL_NULL_HDBC && henv != SQL_NULL_HENV) { ConnectionClass * const *conns = getConnList(); const int conn_count = getConnCount(); for (lf = 0; lf < conn_count; lf++) { conn = conns[lf]; if (conn && CC_get_env(conn) == henv) if (PGAPI_Transact(henv, (HDBC) conn, fType) != SQL_SUCCESS) return SQL_ERROR; } return SQL_SUCCESS; } conn = (ConnectionClass *) hdbc; if (fType != SQL_COMMIT && fType != SQL_ROLLBACK) { CC_set_error(conn, CONN_INVALID_ARGUMENT_NO, "PGAPI_Transact can only be called with SQL_COMMIT or SQL_ROLLBACK as parameter", func); return SQL_ERROR; } /* If manual commit and in transaction, then proceed. */ if (CC_loves_visible_trans(conn) && CC_is_in_trans(conn)) { MYLOG(0, "sending on conn %p '%d'\n", conn, fType); ok = (SQL_COMMIT == fType) ? CC_commit(conn) : CC_abort(conn); if (!ok) { /* error msg will be in the connection */ CC_on_abort(conn, NO_TRANS); CC_log_error(func, "", conn); return SQL_ERROR; } } return SQL_SUCCESS; } RETCODE SQL_API PGAPI_Cancel(HSTMT hstmt) /* Statement to cancel. */ { CSTR func = "PGAPI_Cancel"; StatementClass *stmt = (StatementClass *) hstmt, *estmt; ConnectionClass *conn; RETCODE ret = SQL_SUCCESS; MYLOG(0, "entering...\n"); /* Check if this can handle canceling in the middle of a SQLPutData? */ if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } conn = SC_get_conn(stmt); if (stmt->execute_delegate) estmt = stmt->execute_delegate; else estmt = stmt; /* * SQLCancel works differently depending on what the statement is * currently doing: * * 1. In the middle of SQLParamData / SQLPutData * -> cancel the statement * * 2. Running a query asynchronously. (asynchronous mode is not supported * by psqlODBC) * * 3. Busy running a function in another thread. * -> Send a query cancel request to the server * * 4. Not doing anything. * -> in ODBC version 2.0, same as SQLFreeStmt(SQL_CLOSE). In version * 3.5, it has no effect. * * XXX: Checking for these conditions is racy. For example, we might * see that the statement is waiting for SQLParamdata/SQLPutData, but * before we acquire the lock on the statement, another thread has * supplied the data and started executing. In that case, we'll block * on the lock until the execution finishes. */ if (estmt->data_at_exec >= 0) { /* Waiting for more data from SQLParamData/SQLPutData. Cancel that. */ /* * Note, any previous data-at-exec buffers will be freed * if they call SQLExecDirect or SQLExecute again. */ ENTER_STMT_CS(stmt); SC_clear_error(stmt); estmt->data_at_exec = -1; estmt->current_exec_param = -1; estmt->put_data = FALSE; cancelNeedDataState(estmt); LEAVE_STMT_CS(stmt); return ret; } else if (estmt->status == STMT_EXECUTING) { /* * Busy executing in a different thread. Send a cancel request to * the server. */ if (!CC_send_cancel_request(conn)) return SQL_ERROR; else return SQL_SUCCESS; } else { /* * The statement is not executing, and it's not waiting for params * either. Looks like it's not doing anything. */ return SQL_SUCCESS; } } /* * Returns the SQL string as modified by the driver. * Currently, just copy the input string without modification * observing buffer limits and truncation. */ RETCODE SQL_API PGAPI_NativeSql(HDBC hdbc, const SQLCHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLCHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER * pcbSqlStr) { CSTR func = "PGAPI_NativeSql"; size_t len = 0; char *ptr; ConnectionClass *conn = (ConnectionClass *) hdbc; RETCODE result; MYLOG(0, "entering...cbSqlStrIn=" FORMAT_INTEGER "\n", cbSqlStrIn); ptr = (cbSqlStrIn == 0) ? "" : make_string(szSqlStrIn, cbSqlStrIn, NULL, 0); if (!ptr) { CC_set_error(conn, CONN_NO_MEMORY_ERROR, "No memory available to store native sql string", func); return SQL_ERROR; } result = SQL_SUCCESS; len = strlen(ptr); if (szSqlStr) { strncpy_null((char *) szSqlStr, ptr, cbSqlStrMax); if (len >= cbSqlStrMax) { result = SQL_SUCCESS_WITH_INFO; CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the NativeSQL.", func); } } if (pcbSqlStr) *pcbSqlStr = (SQLINTEGER) len; if (cbSqlStrIn) free(ptr); return result; } /* * Supplies parameter data at execution time. * Used in conjunction with SQLPutData. */ RETCODE SQL_API PGAPI_ParamData(HSTMT hstmt, PTR * prgbValue) { CSTR func = "PGAPI_ParamData"; StatementClass *stmt = (StatementClass *) hstmt, *estmt; APDFields *apdopts; IPDFields *ipdopts; RETCODE retval; int i; Int2 num_p; ConnectionClass *conn = NULL; MYLOG(0, "entering...\n"); conn = SC_get_conn(stmt); estmt = stmt->execute_delegate ? stmt->execute_delegate : stmt; apdopts = SC_get_APDF(estmt); MYLOG(0, "\tdata_at_exec=%d, params_alloc=%d\n", estmt->data_at_exec, apdopts->allocated); #define return DONT_CALL_RETURN_FROM_HERE??? if (SC_AcceptedCancelRequest(stmt)) { SC_set_error(stmt, STMT_OPERATION_CANCELLED, "Cancel the statement, sorry", func); retval = SQL_ERROR; goto cleanup; } if (estmt->data_at_exec < 0) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "No execution-time parameters for this statement", func); retval = SQL_ERROR; goto cleanup; } if (estmt->data_at_exec > apdopts->allocated) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Too many execution-time parameters were present", func); retval = SQL_ERROR; goto cleanup; } /* close the large object */ if (estmt->lobj_fd >= 0) { odbc_lo_close(conn, estmt->lobj_fd); /* commit transaction if needed */ if (!CC_cursor_count(conn) && CC_does_autocommit(conn)) { if (!CC_commit(conn)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Could not commit (in-line) a transaction", func); retval = SQL_ERROR; goto cleanup; } } estmt->lobj_fd = -1; } /* Done, now copy the params and then execute the statement */ ipdopts = SC_get_IPDF(estmt); MYLOG(DETAIL_LOG_LEVEL, "ipdopts=%p\n", ipdopts); if (estmt->data_at_exec == 0) { BOOL exec_end; UWORD flag = SC_is_with_hold(stmt) ? PODBC_WITH_HOLD : 0; retval = Exec_with_parameters_resolved(estmt, stmt->exec_type, &exec_end); if (exec_end) { /**SC_reset_delegate(retval, stmt);**/ retval = dequeueNeedDataCallback(retval, stmt); goto cleanup; } if (retval = PGAPI_Execute(estmt, flag), SQL_NEED_DATA != retval) { goto cleanup; } } /* * Set beginning param; if first time SQLParamData is called , start * at 0. Otherwise, start at the last parameter + 1. */ i = estmt->current_exec_param >= 0 ? estmt->current_exec_param + 1 : 0; num_p = estmt->num_params; if (num_p < 0) PGAPI_NumParams(estmt, &num_p); MYLOG(DETAIL_LOG_LEVEL, "i=%d allocated=%d num_p=%d\n", i, apdopts->allocated, num_p); if (num_p > apdopts->allocated) num_p = apdopts->allocated; /* At least 1 data at execution parameter, so Fill in the token value */ for (; i < num_p; i++) { MYLOG(DETAIL_LOG_LEVEL, "i=%d", i); if (apdopts->parameters[i].data_at_exec) { MYPRINTF(DETAIL_LOG_LEVEL, " at exec buffer=%p", apdopts->parameters[i].buffer); estmt->data_at_exec--; estmt->current_exec_param = i; estmt->put_data = FALSE; if (prgbValue) { /* returns token here */ if (stmt->execute_delegate) { SQLULEN offset = apdopts->param_offset_ptr ? *apdopts->param_offset_ptr : 0; SQLLEN perrow = apdopts->param_bind_type > 0 ? apdopts->param_bind_type : apdopts->parameters[i].buflen; MYPRINTF(DETAIL_LOG_LEVEL, " offset=" FORMAT_LEN " perrow=" FORMAT_LEN, offset, perrow); *prgbValue = apdopts->parameters[i].buffer + offset + estmt->exec_current_row * perrow; } else *prgbValue = apdopts->parameters[i].buffer; } break; } MYPRINTF(DETAIL_LOG_LEVEL, "\n"); } retval = SQL_NEED_DATA; MYLOG(DETAIL_LOG_LEVEL, "return SQL_NEED_DATA\n"); cleanup: #undef return SC_setInsertedTable(stmt, retval); MYLOG(0, "leaving %d\n", retval); return retval; } /* * Supplies parameter data at execution time. * Used in conjunction with SQLParamData. */ RETCODE SQL_API PGAPI_PutData(HSTMT hstmt, PTR rgbValue, SQLLEN cbValue) { CSTR func = "PGAPI_PutData"; StatementClass *stmt = (StatementClass *) hstmt, *estmt; ConnectionClass *conn; RETCODE retval = SQL_SUCCESS; APDFields *apdopts; IPDFields *ipdopts; PutDataInfo *pdata; SQLLEN old_pos; ParameterInfoClass *current_param; ParameterImplClass *current_iparam; PutDataClass *current_pdata; char *putbuf, *allocbuf = NULL; Int2 ctype; SQLLEN putlen; BOOL lenset = FALSE, handling_lo = FALSE; MYLOG(0, "entering...\n"); #define return DONT_CALL_RETURN_FROM_HERE??? if (SC_AcceptedCancelRequest(stmt)) { SC_set_error(stmt, STMT_OPERATION_CANCELLED, "Cancel the statement, sorry.", func); retval = SQL_ERROR; goto cleanup; } estmt = stmt->execute_delegate ? stmt->execute_delegate : stmt; apdopts = SC_get_APDF(estmt); if (estmt->current_exec_param < 0) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Previous call was not SQLPutData or SQLParamData", func); retval = SQL_ERROR; goto cleanup; } current_param = &(apdopts->parameters[estmt->current_exec_param]); ipdopts = SC_get_IPDF(estmt); current_iparam = &(ipdopts->parameters[estmt->current_exec_param]); pdata = SC_get_PDTI(estmt); current_pdata = &(pdata->pdata[estmt->current_exec_param]); ctype = current_param->CType; conn = SC_get_conn(estmt); if (ctype == SQL_C_DEFAULT) { ctype = sqltype_to_default_ctype(conn, current_iparam->SQLType); #ifdef UNICODE_SUPPORT if (SQL_C_WCHAR == ctype && CC_default_is_c(conn)) ctype = SQL_C_CHAR; #endif } if (SQL_NTS == cbValue) { #ifdef UNICODE_SUPPORT if (SQL_C_WCHAR == ctype) { putlen = WCLEN * ucs2strlen((SQLWCHAR *) rgbValue); lenset = TRUE; } else #endif /* UNICODE_SUPPORT */ if (SQL_C_CHAR == ctype) { putlen = strlen(rgbValue); lenset = TRUE; } } if (!lenset) { if (cbValue < 0) putlen = cbValue; else #ifdef UNICODE_SUPPORT if (ctype == SQL_C_CHAR || ctype == SQL_C_BINARY || ctype == SQL_C_WCHAR) #else if (ctype == SQL_C_CHAR || ctype == SQL_C_BINARY) #endif /* UNICODE_SUPPORT */ putlen = cbValue; else putlen = ctype_length(ctype); } putbuf = rgbValue; handling_lo = (PIC_dsp_pgtype(conn, *current_iparam) == conn->lobj_type); if (handling_lo && SQL_C_CHAR == ctype) { allocbuf = malloc(putlen / 2 + 1); if (allocbuf) { pg_hex2bin(rgbValue, allocbuf, putlen); putbuf = allocbuf; putlen /= 2; } } if (!estmt->put_data) { /* first call */ MYLOG(0, "(1) cbValue = " FORMAT_LEN "\n", cbValue); estmt->put_data = TRUE; current_pdata->EXEC_used = (SQLLEN *) malloc(sizeof(SQLLEN)); if (!current_pdata->EXEC_used) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_PutData (1)", func); retval = SQL_ERROR; goto cleanup; } *current_pdata->EXEC_used = putlen; if (cbValue == SQL_NULL_DATA) { retval = SQL_SUCCESS; goto cleanup; } /* Handle Long Var Binary with Large Objects */ /* if (current_iparam->SQLType == SQL_LONGVARBINARY) */ if (handling_lo) { /* begin transaction if needed */ if (!CC_is_in_trans(conn)) { if (!CC_begin(conn)) { SC_set_error(stmt, STMT_EXEC_ERROR, "Could not begin (in-line) a transaction", func); retval = SQL_ERROR; goto cleanup; } } /* store the oid */ current_pdata->lobj_oid = odbc_lo_creat(conn, INV_READ | INV_WRITE); if (current_pdata->lobj_oid == 0) { SC_set_error(stmt, STMT_EXEC_ERROR, "Couldnt create large object.", func); retval = SQL_ERROR; goto cleanup; } /* * major hack -- to allow convert to see somethings there have * to modify convert to handle this better */ /***current_param->EXEC_buffer = (char *) ¤t_param->lobj_oid;***/ /* store the fd */ estmt->lobj_fd = odbc_lo_open(conn, current_pdata->lobj_oid, INV_WRITE); if (estmt->lobj_fd < 0) { SC_set_error(stmt, STMT_EXEC_ERROR, "Couldnt open large object for writing.", func); retval = SQL_ERROR; goto cleanup; } retval = odbc_lo_write(conn, estmt->lobj_fd, putbuf, (Int4) putlen); MYLOG(0, "lo_write: cbValue=" FORMAT_LEN ", wrote %d bytes\n", putlen, retval); } else { current_pdata->EXEC_buffer = malloc(putlen + 1); if (!current_pdata->EXEC_buffer) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_PutData (2)", func); retval = SQL_ERROR; goto cleanup; } memcpy(current_pdata->EXEC_buffer, putbuf, putlen); current_pdata->EXEC_buffer[putlen] = '\0'; } } else { /* calling SQLPutData more than once */ MYLOG(0, "(>1) cbValue = " FORMAT_LEN "\n", cbValue); /* if (current_iparam->SQLType == SQL_LONGVARBINARY) */ if (handling_lo) { /* the large object fd is in EXEC_buffer */ retval = odbc_lo_write(conn, estmt->lobj_fd, putbuf, (Int4) putlen); MYLOG(0, "lo_write(2): cbValue = " FORMAT_LEN ", wrote %d bytes\n", putlen, retval); *current_pdata->EXEC_used += putlen; } else { old_pos = *current_pdata->EXEC_used; if (putlen > 0) { SQLLEN used = *current_pdata->EXEC_used + putlen; SQLLEN allocsize; char *buffer; for (allocsize = (1 << 4); allocsize <= used; allocsize <<= 1) ; MYLOG(0, " cbValue = " FORMAT_LEN ", old_pos = " FORMAT_LEN ", *used = " FORMAT_LEN "\n", putlen, old_pos, used); /* dont lose the old pointer in case out of memory */ buffer = realloc(current_pdata->EXEC_buffer, allocsize); if (!buffer) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR,"Out of memory in PGAPI_PutData (3)", func); retval = SQL_ERROR; goto cleanup; } memcpy(&buffer[old_pos], putbuf, putlen); buffer[used] = '\0'; /* reassign buffer incase realloc moved it */ *current_pdata->EXEC_used = used; current_pdata->EXEC_buffer = buffer; } else { SC_set_error(stmt, STMT_INTERNAL_ERROR, "bad cbValue", func); retval = SQL_ERROR; goto cleanup; } } } retval = SQL_SUCCESS; cleanup: #undef return if (allocbuf) free(allocbuf); return retval; } psqlodbc-REL-16_00_0005/info.c000066400000000000000000005536331462406103600156140ustar00rootroot00000000000000/*-------- * Module: info.c * * Description: This module contains routines related to * ODBC informational functions. * * Classes: n/a * * API functions: SQLGetInfo, SQLGetTypeInfo, SQLGetFunctions, * SQLTables, SQLColumns, SQLStatistics, SQLSpecialColumns, * SQLPrimaryKeys, SQLForeignKeys, * SQLProcedureColumns, SQLProcedures, * SQLTablePrivileges, SQLColumnPrivileges(NI) * * Comments: See "readme.txt" for copyright and license information. *-------- */ #include "psqlodbc.h" #include "unicode_support.h" #include #include #ifndef WIN32 #include #endif #include "tuple.h" #include "pgtypes.h" #include "dlg_specific.h" #include "environ.h" #include "connection.h" #include "statement.h" #include "qresult.h" #include "bind.h" #include "misc.h" #include "pgtypes.h" #include "pgapifunc.h" #include "multibyte.h" #include "catfunc.h" /* Trigger related stuff for SQLForeign Keys */ #define TRIGGER_SHIFT 3 #define TRIGGER_MASK 0x03 #define TRIGGER_DELETE 0x01 #define TRIGGER_UPDATE 0x02 static const SQLCHAR *pubstr = (SQLCHAR *) "public"; static const char *likeop = "like"; static const char *eqop = "="; /* group of SQL_CVT_(chars) */ #define PG_CONVERT_CH SQL_CVT_CHAR | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR /* group of SQL_CVT_(numbers) */ #define PG_CONVERT_NUM SQL_CVT_SMALLINT | SQL_CVT_INTEGER | SQL_CVT_BIGINT | SQL_CVT_REAL | SQL_CVT_FLOAT | SQL_CVT_DOUBLE | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL /* group of SQL_CVT_(date time) */ #define PG_CONVERT_DT SQL_CVT_DATE | SQL_CVT_TIME | SQL_CVT_TIMESTAMP /* group of SQL_CVT_(wchars) */ #ifdef UNICODE_SUPPORT #define PG_CONVERT_WCH SQL_CVT_WCHAR | SQL_CVT_WVARCHAR | SQL_CVT_WLONGVARCHAR #else #define PG_CONVERT_WCH 0 #endif /* UNICODE_SUPPORT */ #define QR_set_field_info_EN(self, field_num, adtid, adtsize) (CI_set_field_info(self->fields, field_num, catcn[field_num][is_ODBC2], adtid, adtsize, -1, 0, 0)) const SQLLEN mask_longvarbinary = SQL_CVT_LONGVARBINARY; RETCODE SQL_API PGAPI_GetInfo(HDBC hdbc, SQLUSMALLINT fInfoType, PTR rgbInfoValue, SQLSMALLINT cbInfoValueMax, SQLSMALLINT * pcbInfoValue) { CSTR func = "PGAPI_GetInfo"; ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci; const char *p = NULL; char tmp[MAX_INFO_STRING]; SQLULEN len = 0, value = 0; RETCODE ret = SQL_ERROR; char odbcver[16]; MYLOG(0, "entering...fInfoType=%d\n", fInfoType); if (!conn) { CC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } ci = &(conn->connInfo); switch (fInfoType) { case SQL_ACCESSIBLE_PROCEDURES: /* ODBC 1.0 */ p = "N"; break; case SQL_ACCESSIBLE_TABLES: /* ODBC 1.0 */ p = CC_accessible_only(conn) ? "Y" : "N"; break; case SQL_ACTIVE_CONNECTIONS: /* ODBC 1.0 */ len = 2; value = 0; break; case SQL_ACTIVE_STATEMENTS: /* ODBC 1.0 */ len = 2; value = 0; break; case SQL_ALTER_TABLE: /* ODBC 2.0 */ len = 4; value = SQL_AT_ADD_COLUMN | SQL_AT_DROP_COLUMN | SQL_AT_ADD_COLUMN_SINGLE | SQL_AT_ADD_CONSTRAINT | SQL_AT_ADD_TABLE_CONSTRAINT | SQL_AT_CONSTRAINT_INITIALLY_DEFERRED | SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE | SQL_AT_CONSTRAINT_DEFERRABLE | SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT | SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE | SQL_AT_DROP_COLUMN_RESTRICT | SQL_AT_DROP_COLUMN_CASCADE; break; case SQL_BOOKMARK_PERSISTENCE: /* ODBC 2.0 */ /* very simple bookmark support */ len = 4; value = SQL_BP_SCROLL | SQL_BP_DELETE | SQL_BP_UPDATE | SQL_BP_TRANSACTION; break; case SQL_COLUMN_ALIAS: /* ODBC 2.0 */ p = "Y"; break; case SQL_CONCAT_NULL_BEHAVIOR: /* ODBC 1.0 */ len = 2; value = SQL_CB_NON_NULL; break; case SQL_CONVERT_BIT: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : SQL_CVT_BIT | SQL_CVT_INTEGER | PG_CONVERT_CH | PG_CONVERT_WCH; MYLOG(0, "SQL_CONVERT_ mask=" FORMAT_ULEN "\n", value); break; case SQL_CONVERT_INTEGER: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : SQL_CVT_BIT | PG_CONVERT_NUM | PG_CONVERT_CH | PG_CONVERT_WCH; break; case SQL_CONVERT_SMALLINT: case SQL_CONVERT_BIGINT: case SQL_CONVERT_DECIMAL: case SQL_CONVERT_DOUBLE: case SQL_CONVERT_FLOAT: case SQL_CONVERT_NUMERIC: case SQL_CONVERT_REAL: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : PG_CONVERT_NUM | PG_CONVERT_CH | PG_CONVERT_WCH; break; case SQL_CONVERT_CHAR: case SQL_CONVERT_VARCHAR: /* ODBC 1.0 */ case SQL_CONVERT_LONGVARCHAR: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : SQL_CVT_BIT | PG_CONVERT_NUM | PG_CONVERT_CH | PG_CONVERT_WCH; break; case SQL_CONVERT_DATE: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : PG_CONVERT_CH | SQL_CVT_DATE | SQL_CVT_TIMESTAMP | PG_CONVERT_WCH; break; case SQL_CONVERT_TIME: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : PG_CONVERT_CH | SQL_CVT_TIME | PG_CONVERT_WCH; break; case SQL_CONVERT_TIMESTAMP: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : PG_CONVERT_CH | PG_CONVERT_DT | PG_CONVERT_WCH; break; case SQL_CONVERT_LONGVARBINARY: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : SQL_CVT_LONGVARBINARY; break; #ifdef UNICODE_SUPPORT case SQL_CONVERT_WCHAR: case SQL_CONVERT_WLONGVARCHAR: case SQL_CONVERT_WVARCHAR: len = sizeof(SQLUINTEGER); value = ci->disable_convert_func ? 0 : SQL_CVT_BIT | PG_CONVERT_NUM | PG_CONVERT_DT | PG_CONVERT_WCH; break; #endif /* UNICODE_SUPPORT */ case SQL_CONVERT_TINYINT: case SQL_CONVERT_BINARY: case SQL_CONVERT_VARBINARY: /* ODBC 1.0 */ len = sizeof(SQLUINTEGER); value = 0; /* CONVERT is unavailable */ break; case SQL_CONVERT_FUNCTIONS: /* ODBC 1.0 */ len = sizeof(SQLUINTEGER); value = SQL_FN_CVT_CONVERT; MYLOG(0, "CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value); break; case SQL_CORRELATION_NAME: /* ODBC 1.0 */ /* * Saying no correlation name makes Query not work right. * value = SQL_CN_NONE; */ len = 2; value = SQL_CN_ANY; break; case SQL_CURSOR_COMMIT_BEHAVIOR: /* ODBC 1.0 */ len = 2; value = SQL_CB_PRESERVE; break; case SQL_CURSOR_ROLLBACK_BEHAVIOR: /* ODBC 1.0 */ len = 2; if (!ci->drivers.use_declarefetch) value = SQL_CB_PRESERVE; else value = SQL_CB_CLOSE; break; case SQL_DATA_SOURCE_NAME: /* ODBC 1.0 */ p = CC_get_DSN(conn); break; case SQL_DATA_SOURCE_READ_ONLY: /* ODBC 1.0 */ p = CC_is_onlyread(conn) ? "Y" : "N"; break; case SQL_DATABASE_NAME: /* Support for old ODBC 1.0 Apps */ /* * Returning the database name causes problems in MS Query. It * generates query like: "SELECT DISTINCT a FROM byronnbad3 * bad3" * * p = CC_get_database(conn); */ p = CurrCatString(conn); break; case SQL_DBMS_NAME: /* ODBC 1.0 */ if (CC_fake_mss(conn)) p = "Microsoft SQL Server"; else p = "PostgreSQL"; break; case SQL_DBMS_VER: /* ODBC 1.0 */ /* * The ODBC spec wants ##.##.#### ...whatever... so prepend * the driver */ /* version number to the dbms version string */ /* SPRINTF_FIXED(tmp, "%s %s", POSTGRESDRIVERVERSION, conn->pg_version); tmp[sizeof(tmp) - 1] = '\0'; */ if (CC_fake_mss(conn)) p = "09.00.1399"; else { STRCPY_FIXED(tmp, conn->pg_version); p = tmp; } break; case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */ len = 4; if (0 == conn->default_isolation) conn->isolation = CC_get_isolation(conn); value = conn->default_isolation; break; case SQL_DRIVER_NAME: /* ODBC 1.0 */ p = DRIVER_FILE_NAME; break; case SQL_DRIVER_ODBC_VER: SPRINTF_FIXED(odbcver, "%02x.%02x", ODBCVER / 256, ODBCVER % 256); /* p = DRIVER_ODBC_VER; */ p = odbcver; break; case SQL_DRIVER_VER: /* ODBC 1.0 */ p = POSTGRESDRIVERVERSION; break; case SQL_EXPRESSIONS_IN_ORDERBY: /* ODBC 1.0 */ p = "Y"; break; case SQL_FETCH_DIRECTION: /* ODBC 1.0 */ len = 4; value = (SQL_FD_FETCH_NEXT | SQL_FD_FETCH_FIRST | SQL_FD_FETCH_LAST | SQL_FD_FETCH_PRIOR | SQL_FD_FETCH_ABSOLUTE | SQL_FD_FETCH_RELATIVE | SQL_FD_FETCH_BOOKMARK); break; case SQL_FILE_USAGE: /* ODBC 2.0 */ len = 2; value = SQL_FILE_NOT_SUPPORTED; break; case SQL_GETDATA_EXTENSIONS: /* ODBC 2.0 */ len = 4; value = (SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER | SQL_GD_BOUND | SQL_GD_BLOCK); break; case SQL_GROUP_BY: /* ODBC 2.0 */ len = 2; value = SQL_GB_GROUP_BY_EQUALS_SELECT; break; case SQL_IDENTIFIER_CASE: /* ODBC 1.0 */ /* * are identifiers case-sensitive (yes, but only when quoted. * If not quoted, they default to lowercase) */ len = 2; value = SQL_IC_LOWER; break; case SQL_IDENTIFIER_QUOTE_CHAR: /* ODBC 1.0 */ /* the character used to quote "identifiers" */ p = "\""; break; case SQL_KEYWORDS: /* ODBC 2.0 */ p = NULL_STRING; break; case SQL_LIKE_ESCAPE_CLAUSE: /* ODBC 2.0 */ p = "Y"; break; case SQL_LOCK_TYPES: /* ODBC 2.0 */ len = 4; value = ci->drivers.lie ? (SQL_LCK_NO_CHANGE | SQL_LCK_EXCLUSIVE | SQL_LCK_UNLOCK) : SQL_LCK_NO_CHANGE; break; case SQL_MAX_BINARY_LITERAL_LEN: /* ODBC 2.0 */ len = 4; value = 0; break; case SQL_MAX_CHAR_LITERAL_LEN: /* ODBC 2.0 */ len = 4; value = 0; break; case SQL_MAX_COLUMN_NAME_LEN: /* ODBC 1.0 */ len = 2; value = CC_get_max_idlen(conn); if (0 == value) value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_COLUMNS_IN_GROUP_BY: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_COLUMNS_IN_INDEX: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_COLUMNS_IN_ORDER_BY: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_COLUMNS_IN_SELECT: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_COLUMNS_IN_TABLE: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_CURSOR_NAME_LEN: /* ODBC 1.0 */ len = 2; value = MAX_CURSOR_LEN; break; case SQL_MAX_INDEX_SIZE: /* ODBC 2.0 */ len = 4; value = 0; break; case SQL_MAX_OWNER_NAME_LEN: /* ODBC 1.0 */ len = 2; value = 0; if (PG_VERSION_GT(conn, 7.4)) value = CC_get_max_idlen(conn); #ifdef MAX_SCHEMA_LEN else value = MAX_SCHEMA_LEN; #endif /* MAX_SCHEMA_LEN */ if (0 == value) value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_PROCEDURE_NAME_LEN: /* ODBC 1.0 */ len = 2; value = 0; break; case SQL_MAX_QUALIFIER_NAME_LEN: /* ODBC 1.0 */ len = 2; value = 0; break; case SQL_MAX_ROW_SIZE: /* ODBC 2.0 */ len = 4; /* No limit with tuptoaster in 7.1+ */ value = 0; break; case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */ len = 4; value = 0; break; case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */ len = 2; if (PG_VERSION_GT(conn, 7.4)) value = CC_get_max_idlen(conn); #ifdef MAX_TABLE_LEN else value = MAX_TABLE_LEN; #endif /* MAX_TABLE_LEN */ if (0 == value) value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_TABLES_IN_SELECT: /* ODBC 2.0 */ len = 2; value = 0; break; case SQL_MAX_USER_NAME_LEN: len = 2; value = 0; break; case SQL_MULT_RESULT_SETS: /* ODBC 1.0 */ /* Don't support multiple result sets but say yes anyway? */ p = "Y"; break; case SQL_MULTIPLE_ACTIVE_TXN: /* ODBC 1.0 */ p = "Y"; break; case SQL_NEED_LONG_DATA_LEN: /* ODBC 2.0 */ /* * Don't need the length, SQLPutData can handle any size and * multiple calls */ p = "N"; break; case SQL_NON_NULLABLE_COLUMNS: /* ODBC 1.0 */ len = 2; value = SQL_NNC_NON_NULL; break; case SQL_NULL_COLLATION: /* ODBC 2.0 */ /* where are nulls sorted? */ len = 2; value = SQL_NC_HIGH; break; case SQL_NUMERIC_FUNCTIONS: /* ODBC 1.0 */ len = 4; value = SQL_FN_NUM_ABS | SQL_FN_NUM_ACOS | SQL_FN_NUM_ASIN | SQL_FN_NUM_ATAN | SQL_FN_NUM_ATAN2 | SQL_FN_NUM_CEILING | SQL_FN_NUM_COS | SQL_FN_NUM_COT | SQL_FN_NUM_DEGREES | SQL_FN_NUM_EXP | SQL_FN_NUM_FLOOR | SQL_FN_NUM_LOG | SQL_FN_NUM_LOG10 | SQL_FN_NUM_MOD | SQL_FN_NUM_PI | SQL_FN_NUM_POWER | SQL_FN_NUM_RADIANS | SQL_FN_NUM_RAND | SQL_FN_NUM_ROUND | SQL_FN_NUM_SIGN | SQL_FN_NUM_SIN | SQL_FN_NUM_SQRT | SQL_FN_NUM_TAN | SQL_FN_NUM_TRUNCATE; break; case SQL_ODBC_API_CONFORMANCE: /* ODBC 1.0 */ len = 2; value = SQL_OAC_LEVEL1; break; case SQL_ODBC_SAG_CLI_CONFORMANCE: /* ODBC 1.0 */ len = 2; value = SQL_OSCC_NOT_COMPLIANT; break; case SQL_ODBC_SQL_CONFORMANCE: /* ODBC 1.0 */ len = 2; value = SQL_OSC_CORE; break; case SQL_ODBC_SQL_OPT_IEF: /* ODBC 1.0 */ p = "N"; break; case SQL_OJ_CAPABILITIES: /* ODBC 2.01 */ len = 4; value = (SQL_OJ_LEFT | SQL_OJ_RIGHT | SQL_OJ_FULL | SQL_OJ_NESTED | SQL_OJ_NOT_ORDERED | SQL_OJ_INNER | SQL_OJ_ALL_COMPARISON_OPS); break; case SQL_ORDER_BY_COLUMNS_IN_SELECT: /* ODBC 2.0 */ p = "Y"; break; case SQL_OUTER_JOINS: /* ODBC 1.0 */ p = "Y"; break; case SQL_OWNER_TERM: /* ODBC 1.0 */ p = "schema"; break; case SQL_OWNER_USAGE: /* ODBC 2.0 */ len = 4; value = SQL_OU_DML_STATEMENTS | SQL_OU_TABLE_DEFINITION | SQL_OU_INDEX_DEFINITION | SQL_OU_PRIVILEGE_DEFINITION; break; case SQL_POS_OPERATIONS: /* ODBC 2.0 */ len = 4; value = (SQL_POS_POSITION | SQL_POS_REFRESH); if (0 != ci->updatable_cursors) value |= (SQL_POS_UPDATE | SQL_POS_DELETE | SQL_POS_ADD); break; case SQL_POSITIONED_STATEMENTS: /* ODBC 2.0 */ len = 4; value = ci->drivers.lie ? (SQL_PS_POSITIONED_DELETE | SQL_PS_POSITIONED_UPDATE | SQL_PS_SELECT_FOR_UPDATE) : 0; break; case SQL_PROCEDURE_TERM: /* ODBC 1.0 */ p = "procedure"; break; case SQL_PROCEDURES: /* ODBC 1.0 */ p = "Y"; break; case SQL_QUALIFIER_LOCATION: /* ODBC 2.0 */ len = 2; if (CurrCat(conn)) value = SQL_QL_START; else value = 0; break; case SQL_QUALIFIER_NAME_SEPARATOR: /* ODBC 1.0 */ if (CurrCat(conn)) p = "."; else p = NULL_STRING; break; case SQL_QUALIFIER_TERM: /* ODBC 1.0 */ if (CurrCat(conn)) p = "catalog"; else p = NULL_STRING; break; case SQL_QUALIFIER_USAGE: /* ODBC 2.0 */ len = 4; if (CurrCat(conn)) value = SQL_CU_DML_STATEMENTS; else value = 0; break; case SQL_QUOTED_IDENTIFIER_CASE: /* ODBC 2.0 */ /* are "quoted" identifiers case-sensitive? YES! */ len = 2; value = SQL_IC_SENSITIVE; break; case SQL_ROW_UPDATES: /* ODBC 1.0 */ /* * Driver doesn't support keyset-driven or mixed cursors, so * not much point in saying row updates are supported */ p = (0 != ci->updatable_cursors) ? "Y" : "N"; break; case SQL_SCROLL_CONCURRENCY: /* ODBC 1.0 */ len = 4; value = SQL_SCCO_READ_ONLY; if (0 != ci->updatable_cursors) value |= SQL_SCCO_OPT_ROWVER; if (ci->drivers.lie) value |= (SQL_SCCO_LOCK | SQL_SCCO_OPT_VALUES); break; case SQL_SCROLL_OPTIONS: /* ODBC 1.0 */ len = 4; value = SQL_SO_FORWARD_ONLY | SQL_SO_STATIC; if (0 != (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) value |= SQL_SO_KEYSET_DRIVEN; if (ci->drivers.lie) value |= (SQL_SO_DYNAMIC | SQL_SO_MIXED); break; case SQL_SEARCH_PATTERN_ESCAPE: /* ODBC 1.0 */ p = "\\"; break; case SQL_SERVER_NAME: /* ODBC 1.0 */ p = CC_get_server(conn); break; case SQL_SPECIAL_CHARACTERS: /* ODBC 2.0 */ p = "_"; break; case SQL_STATIC_SENSITIVITY: /* ODBC 2.0 */ len = 4; value = 0; if (0 != ci->updatable_cursors) value |= (SQL_SS_ADDITIONS | SQL_SS_DELETIONS | SQL_SS_UPDATES); break; case SQL_STRING_FUNCTIONS: /* ODBC 1.0 */ len = 4; value = SQL_FN_STR_ASCII | SQL_FN_STR_CHAR | SQL_FN_STR_CONCAT | SQL_FN_STR_INSERT | SQL_FN_STR_LCASE | SQL_FN_STR_LEFT | SQL_FN_STR_LENGTH | SQL_FN_STR_LOCATE | SQL_FN_STR_LOCATE_2 | SQL_FN_STR_LTRIM | SQL_FN_STR_REPEAT | SQL_FN_STR_RIGHT | SQL_FN_STR_RTRIM | SQL_FN_STR_SPACE | SQL_FN_STR_SUBSTRING | SQL_FN_STR_UCASE; break; case SQL_SUBQUERIES: /* ODBC 2.0 */ /* postgres 6.3 supports subqueries */ len = 4; value = (SQL_SQ_QUANTIFIED | SQL_SQ_IN | SQL_SQ_EXISTS | SQL_SQ_COMPARISON); break; case SQL_SYSTEM_FUNCTIONS: /* ODBC 1.0 */ len = 4; value = SQL_FN_SYS_IFNULL | SQL_FN_SYS_USERNAME; break; case SQL_TABLE_TERM: /* ODBC 1.0 */ p = "table"; break; case SQL_TIMEDATE_ADD_INTERVALS: /* ODBC 2.0 */ len = 4; value = SQL_FN_TSI_DAY | SQL_FN_TSI_HOUR | SQL_FN_TSI_MINUTE | SQL_FN_TSI_SECOND | SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_YEAR | SQL_FN_TSI_MONTH | SQL_FN_TSI_WEEK; break; case SQL_TIMEDATE_DIFF_INTERVALS: /* ODBC 2.0 */ len = 4; value = SQL_FN_TSI_DAY | SQL_FN_TSI_HOUR | SQL_FN_TSI_MINUTE | SQL_FN_TSI_SECOND | SQL_FN_TSI_SECOND; break; case SQL_TIMEDATE_FUNCTIONS: /* ODBC 1.0 */ len = 4; value = SQL_FN_TD_NOW | SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME | SQL_FN_TD_CURRENT_TIMESTAMP | SQL_FN_TD_CURDATE | SQL_FN_TD_CURTIME | SQL_FN_TD_DAYNAME | SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | SQL_FN_TD_MONTH | SQL_FN_TD_MONTHNAME | SQL_FN_TD_NOW | SQL_FN_TD_QUARTER | SQL_FN_TD_SECOND | SQL_FN_TD_WEEK | SQL_FN_TD_YEAR | SQL_FN_TD_TIMESTAMPADD | SQL_FN_TD_TIMESTAMPDIFF | SQL_FN_TD_EXTRACT; break; case SQL_TXN_CAPABLE: /* ODBC 1.0 */ /* * Postgres can deal with create or drop table statements in a * transaction */ len = 2; value = SQL_TC_ALL; break; case SQL_TXN_ISOLATION_OPTION: /* ODBC 1.0 */ len = 4; value = SQL_TXN_READ_UNCOMMITTED | SQL_TXN_READ_COMMITTED | SQL_TXN_REPEATABLE_READ | SQL_TXN_SERIALIZABLE; break; case SQL_UNION: /* ODBC 2.0 */ /* unions with all supported in postgres 6.3 */ len = 4; value = (SQL_U_UNION | SQL_U_UNION_ALL); break; case SQL_USER_NAME: /* ODBC 1.0 */ p = CC_get_username(conn); break; /* Keys for ODBC 3.0 */ case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: len = 4; value = 0; break; case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: len = 4; value = 0; break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: len = 4; value = SQL_CA1_NEXT; /* others aren't allowed in ODBC spec */ break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: len = 4; value = SQL_CA2_READ_ONLY_CONCURRENCY; if (!ci->drivers.use_declarefetch || ci->drivers.lie) value |= SQL_CA2_CRC_EXACT; break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: len = 4; value = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE | SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK | SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_POS_POSITION | SQL_CA1_POS_REFRESH; if (0 != (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) value |= (SQL_CA1_POS_UPDATE | SQL_CA1_POS_DELETE | SQL_CA1_BULK_ADD | SQL_CA1_BULK_UPDATE_BY_BOOKMARK | SQL_CA1_BULK_DELETE_BY_BOOKMARK | SQL_CA1_BULK_FETCH_BY_BOOKMARK ); if (ci->drivers.lie) value |= (SQL_CA1_LOCK_EXCLUSIVE | SQL_CA1_LOCK_UNLOCK | SQL_CA1_POSITIONED_UPDATE | SQL_CA1_POSITIONED_DELETE | SQL_CA1_SELECT_FOR_UPDATE ); break; case SQL_KEYSET_CURSOR_ATTRIBUTES2: len = 4; value = SQL_CA2_READ_ONLY_CONCURRENCY; if (0 != (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) value |= (SQL_CA2_OPT_ROWVER_CONCURRENCY /*| SQL_CA2_CRC_APPROXIMATE*/ ); if (0 != (ci->updatable_cursors & SENSE_SELF_OPERATIONS)) value |= (SQL_CA2_SENSITIVITY_DELETIONS | SQL_CA2_SENSITIVITY_UPDATES | SQL_CA2_SENSITIVITY_ADDITIONS ); if (!ci->drivers.use_declarefetch || ci->drivers.lie) value |= SQL_CA2_CRC_EXACT; if (ci->drivers.lie) value |= (SQL_CA2_LOCK_CONCURRENCY | SQL_CA2_OPT_VALUES_CONCURRENCY | SQL_CA2_MAX_ROWS_SELECT | SQL_CA2_MAX_ROWS_INSERT | SQL_CA2_MAX_ROWS_DELETE | SQL_CA2_MAX_ROWS_UPDATE | SQL_CA2_MAX_ROWS_CATALOG | SQL_CA2_MAX_ROWS_AFFECTS_ALL | SQL_CA2_SIMULATE_NON_UNIQUE | SQL_CA2_SIMULATE_TRY_UNIQUE | SQL_CA2_SIMULATE_UNIQUE ); break; case SQL_STATIC_CURSOR_ATTRIBUTES1: len = 4; value = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE | SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK | SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_POS_POSITION | SQL_CA1_POS_REFRESH; if (0 != (ci->updatable_cursors & ALLOW_STATIC_CURSORS)) value |= (SQL_CA1_POS_UPDATE | SQL_CA1_POS_DELETE ); if (0 != (ci->updatable_cursors & ALLOW_BULK_OPERATIONS)) value |= (SQL_CA1_BULK_ADD | SQL_CA1_BULK_UPDATE_BY_BOOKMARK | SQL_CA1_BULK_DELETE_BY_BOOKMARK | SQL_CA1_BULK_FETCH_BY_BOOKMARK ); break; case SQL_STATIC_CURSOR_ATTRIBUTES2: len = 4; value = SQL_CA2_READ_ONLY_CONCURRENCY; if (0 != (ci->updatable_cursors & ALLOW_STATIC_CURSORS)) value |= (SQL_CA2_OPT_ROWVER_CONCURRENCY ); if (0 != (ci->updatable_cursors & SENSE_SELF_OPERATIONS)) value |= (SQL_CA2_SENSITIVITY_DELETIONS | SQL_CA2_SENSITIVITY_UPDATES | SQL_CA2_SENSITIVITY_ADDITIONS ); if (!ci->drivers.use_declarefetch || ci->drivers.lie) value |= (SQL_CA2_CRC_EXACT ); break; case SQL_ODBC_INTERFACE_CONFORMANCE: len = 4; value = SQL_OIC_CORE; if (ci->drivers.lie) value = SQL_OIC_LEVEL2; break; case SQL_ACTIVE_ENVIRONMENTS: len = 2; value = 0; break; case SQL_AGGREGATE_FUNCTIONS: len = 4; value = SQL_AF_ALL; break; case SQL_ALTER_DOMAIN: len = 4; value = 0; break; case SQL_ASYNC_MODE: len = 4; value = SQL_AM_NONE; break; case SQL_BATCH_ROW_COUNT: len = 4; value = SQL_BRC_EXPLICIT; break; case SQL_BATCH_SUPPORT: len = 4; value = SQL_BS_SELECT_EXPLICIT | SQL_BS_ROW_COUNT_EXPLICIT; break; case SQL_CATALOG_NAME: if (CurrCat(conn)) p = "Y"; else p = "N"; break; case SQL_COLLATION_SEQ: p = ""; break; case SQL_CREATE_ASSERTION: len = 4; value = 0; break; case SQL_CREATE_CHARACTER_SET: len = 4; value = 0; break; case SQL_CREATE_COLLATION: len = 4; value = 0; break; case SQL_CREATE_DOMAIN: len = 4; value = 0; break; case SQL_CREATE_SCHEMA: len = 4; value = SQL_CS_CREATE_SCHEMA | SQL_CS_AUTHORIZATION; break; case SQL_CREATE_TABLE: len = 4; value = SQL_CT_CREATE_TABLE | SQL_CT_COLUMN_CONSTRAINT | SQL_CT_COLUMN_DEFAULT | SQL_CT_GLOBAL_TEMPORARY | SQL_CT_TABLE_CONSTRAINT | SQL_CT_CONSTRAINT_NAME_DEFINITION | SQL_CT_CONSTRAINT_INITIALLY_DEFERRED | SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE | SQL_CT_CONSTRAINT_DEFERRABLE; break; case SQL_CREATE_TRANSLATION: len = 4; value = 0; break; case SQL_CREATE_VIEW: len = 4; value = SQL_CV_CREATE_VIEW; break; case SQL_DDL_INDEX: len = 4; value = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; break; case SQL_DESCRIBE_PARAMETER: p = "N"; break; case SQL_DROP_ASSERTION: len = 4; value = 0; break; case SQL_DROP_CHARACTER_SET: len = 4; value = 0; break; case SQL_DROP_COLLATION: len = 4; value = 0; break; case SQL_DROP_DOMAIN: len = 4; value = 0; break; case SQL_DROP_SCHEMA: len = 4; value = SQL_DS_DROP_SCHEMA | SQL_DS_RESTRICT | SQL_DS_CASCADE; break; case SQL_DROP_TABLE: len = 4; value = SQL_DT_DROP_TABLE; value |= (SQL_DT_RESTRICT | SQL_DT_CASCADE); break; case SQL_DROP_TRANSLATION: len = 4; value = 0; break; case SQL_DROP_VIEW: len = 4; value = SQL_DV_DROP_VIEW; value |= (SQL_DV_RESTRICT | SQL_DV_CASCADE); break; case SQL_INDEX_KEYWORDS: len = 4; value = SQL_IK_NONE; break; case SQL_INFO_SCHEMA_VIEWS: len = 4; value = 0; break; case SQL_INSERT_STATEMENT: len = 4; value = SQL_IS_INSERT_LITERALS | SQL_IS_INSERT_SEARCHED | SQL_IS_SELECT_INTO; break; case SQL_MAX_IDENTIFIER_LEN: len = 2; value = CC_get_max_idlen(conn); if (0 == value) value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_ROW_SIZE_INCLUDES_LONG: p = "Y"; break; case SQL_PARAM_ARRAY_ROW_COUNTS: len = 4; value = SQL_PARC_BATCH; break; case SQL_PARAM_ARRAY_SELECTS: len = 4; value = SQL_PAS_BATCH; break; case SQL_SQL_CONFORMANCE: len = 4; value = SQL_SC_SQL92_ENTRY; break; case SQL_SQL92_DATETIME_FUNCTIONS: len = 4; value = SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIME | SQL_SDF_CURRENT_TIMESTAMP; break; case SQL_SQL92_FOREIGN_KEY_DELETE_RULE: len = 4; value = SQL_SFKD_CASCADE | SQL_SFKD_NO_ACTION | SQL_SFKD_SET_DEFAULT | SQL_SFKD_SET_NULL; break; case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE: len = 4; value = SQL_SFKU_CASCADE | SQL_SFKU_NO_ACTION | SQL_SFKU_SET_DEFAULT | SQL_SFKU_SET_NULL; break; case SQL_SQL92_GRANT: len = 4; value = SQL_SG_DELETE_TABLE | SQL_SG_INSERT_TABLE | SQL_SG_REFERENCES_TABLE | SQL_SG_SELECT_TABLE | SQL_SG_UPDATE_TABLE; break; case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS: len = 4; value = SQL_SNVF_BIT_LENGTH | SQL_SNVF_CHAR_LENGTH | SQL_SNVF_CHARACTER_LENGTH | SQL_SNVF_EXTRACT | SQL_SNVF_OCTET_LENGTH | SQL_SNVF_POSITION; break; case SQL_SQL92_PREDICATES: len = 4; value = SQL_SP_BETWEEN | SQL_SP_COMPARISON | SQL_SP_EXISTS | SQL_SP_IN | SQL_SP_ISNOTNULL | SQL_SP_ISNULL | SQL_SP_LIKE | SQL_SP_OVERLAPS | SQL_SP_QUANTIFIED_COMPARISON; break; case SQL_SQL92_RELATIONAL_JOIN_OPERATORS: len = 4; value = SQL_SRJO_CROSS_JOIN | SQL_SRJO_EXCEPT_JOIN | SQL_SRJO_FULL_OUTER_JOIN | SQL_SRJO_INNER_JOIN | SQL_SRJO_INTERSECT_JOIN | SQL_SRJO_LEFT_OUTER_JOIN | SQL_SRJO_NATURAL_JOIN | SQL_SRJO_RIGHT_OUTER_JOIN | SQL_SRJO_UNION_JOIN; break; case SQL_SQL92_REVOKE: len = 4; value = SQL_SR_DELETE_TABLE | SQL_SR_INSERT_TABLE | SQL_SR_REFERENCES_TABLE | SQL_SR_SELECT_TABLE | SQL_SR_UPDATE_TABLE; break; case SQL_SQL92_ROW_VALUE_CONSTRUCTOR: len = 4; value = SQL_SRVC_VALUE_EXPRESSION | SQL_SRVC_NULL; break; case SQL_SQL92_STRING_FUNCTIONS: len = 4; value = SQL_SSF_CONVERT | SQL_SSF_LOWER | SQL_SSF_UPPER | SQL_SSF_SUBSTRING | SQL_SSF_TRANSLATE | SQL_SSF_TRIM_BOTH | SQL_SSF_TRIM_LEADING | SQL_SSF_TRIM_TRAILING; break; case SQL_SQL92_VALUE_EXPRESSIONS: len = 4; value = SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF; break; #ifdef SQL_DTC_TRANSACTION_COST case SQL_DTC_TRANSACTION_COST: #else case 1750: #endif len = 4; break; /* The followings aren't implemented yet */ case SQL_DATETIME_LITERALS: len = 4; case SQL_DM_VER: len = 0; case SQL_DRIVER_HDESC: len = 4; case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS: len = 4; case SQL_STANDARD_CLI_CONFORMANCE: len = 4; case SQL_XOPEN_CLI_YEAR: len = 0; default: /* unrecognized key */ CC_set_error(conn, CONN_NOT_IMPLEMENTED_ERROR, "Unrecognized key passed to PGAPI_GetInfo.", NULL); goto cleanup; } ret = SQL_SUCCESS; MYLOG(0, "p='%s', len=" FORMAT_ULEN ", value=" FORMAT_ULEN ", cbMax=%d\n", p ? p : "", len, value, cbInfoValueMax); /* * NOTE, that if rgbInfoValue is NULL, then no warnings or errors * should result and just pcbInfoValue is returned, which indicates * what length would be required if a real buffer had been passed in. */ if (p) { /* char/binary data */ len = strlen(p); if (rgbInfoValue) { #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) { len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / WCLEN); len *= WCLEN; } else #endif /* UNICODE_SUPPORT */ strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax); if (len >= cbInfoValueMax) { ret = SQL_SUCCESS_WITH_INFO; CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the InfoValue.", func); } } #ifdef UNICODE_SUPPORT else if (CC_is_in_unicode_driver(conn)) len *= WCLEN; #endif /* UNICODE_SUPPORT */ } else { /* numeric data */ if (rgbInfoValue) { if (len == sizeof(SQLSMALLINT)) *((SQLUSMALLINT *) rgbInfoValue) = (SQLUSMALLINT) value; else if (len == sizeof(SQLINTEGER)) *((SQLUINTEGER *) rgbInfoValue) = (SQLUINTEGER) value; } } if (pcbInfoValue) *pcbInfoValue = (SQLSMALLINT) len; cleanup: return ret; } /* * macros for pgtype_xxxx() calls which have PG_ATP_UNSET parameters */ #define PGTYPE_COLUMN_SIZE(conn, pgType) pgtype_attr_column_size(conn, pgType, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_TO_CONCISE_TYPE(conn, pgType) pgtype_attr_to_concise_type(conn, pgType, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_TO_SQLDESCTYPE(conn, pgType) pgtype_attr_to_sqldesctype(conn, pgType, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_BUFFER_LENGTH(conn, pgType) pgtype_attr_buffer_length(conn, pgType, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_DECIMAL_DIGITS(conn, pgType) pgtype_attr_decimal_digits(conn, pgType, PG_ATP_UNSET, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_TRANSFER_OCTET_LENGTH(conn, pgType) pgtype_attr_transfer_octet_length(conn, pgType, PG_ATP_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_TO_NAME(conn, pgType, auto_increment) pgtype_attr_to_name(conn, pgType, PG_ATP_UNSET, auto_increment) #define PGTYPE_TO_DATETIME_SUB(conn, pgtype) pgtype_attr_to_datetime_sub(conn, pgtype, PG_ATP_UNSET) RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT hstmt, SQLSMALLINT fSqlType) { CSTR func = "PGAPI_GetTypeInfo"; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; QResultClass *res = NULL; TupleField *tuple; int i, result_cols; /* Int4 type; */ Int4 pgType; Int2 sqlType; RETCODE ret = SQL_ERROR, result; static const char *catcn[][2] = { {"TYPE_NAME", "TYPE_NAME"}, {"DATA_TYPE", "DATA_TYPE"}, {"COLUMN_SIZE", "PRECISION"}, {"LITERAL_PREFIX", "LITERAL_PREFIX"}, {"LITERAL_SUFFIX", "LITERAL_SUFFIX"}, {"CREATE_PARAMS", "CREATE_PARAMS"}, {"NULLABLE", "NULLABLE"}, {"CASE_SENSITIVE", "CASE_SENSITIVE"}, {"SEARCHABLE", "SEARCHABLE"}, {"UNSIGNED_ATTRIBUTE", "UNSIGNED_ATTRIBUTE"}, {"FIXED_PREC_SCALE", "MONEY"}, {"AUTO_UNIQUE_VALUE", "AUTO_INCREMENT"}, {"LOCAL_TYPE_NAME", "LOCAL_TYPE_NAME"}, {"MINIMUM_SCALE", "MINIMUM_SCALE"}, {"MAXIMUM_SCALE", "MAXIMUM_SCALE"}, {"SQL_DATA_TYPE", "SQL_DATA_TYPE"}, {"SQL_DATETIME_SUB", "SQL_DATETIME_SUB"}, {"NUM_PREC_RADIX", "NUM_PREC_RADIX"}, {"INTERVAL_PRECISION", "INTERVAL_PRECISION"} }; EnvironmentClass *env; BOOL is_ODBC2; MYLOG(0, "entering...fSqlType=%d\n", fSqlType); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; conn = SC_get_conn(stmt); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_INTERNAL_ERROR, "Error creating result.", func); return SQL_ERROR; } SC_set_Result(stmt, res); #define return DONT_CALL_RETURN_FROM_HERE??? result_cols = NUM_OF_GETTYPE_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; QR_set_num_fields(res, result_cols); QR_set_field_info_EN(res, 0, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 1, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 2, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, 3, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 4, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 5, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 6, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 7, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 8, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 9, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 10, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 11, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 12, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 13, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 14, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 15, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 16, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 17, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, 18, PG_TYPE_INT2, 2); for (i = 0, sqlType = sqlTypes[0]; sqlType; sqlType = sqlTypes[++i]) { /* Filter unsupported data types when fSqlType = SQL_ALL_TYPES */ if (SQL_ALL_TYPES == fSqlType && EN_is_odbc2(env)) { switch (sqlType) { case SQL_TYPE_DATE: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: continue; } } pgType = sqltype_to_pgtype(conn, sqlType); if (sqlType == SQL_LONGVARBINARY) { ConnInfo *ci = &(conn->connInfo); MYLOG(DETAIL_LOG_LEVEL, "%d sqltype=%d -> pgtype=%d\n", ci->bytea_as_longvarbinary, sqlType, pgType); } if (fSqlType == SQL_ALL_TYPES || fSqlType == sqlType) { int pgtcount = 1, aunq_match = -1, cnt; /*if (SQL_INTEGER == sqlType || SQL_TINYINT == sqlType)*/ if (SQL_INTEGER == sqlType) { MYLOG(0, "sqlType=%d ms_jet=%d\n", sqlType, conn->ms_jet); if (conn->ms_jet) { aunq_match = 1; pgtcount = 2; } MYLOG(0, "aunq_match=%d pgtcount=%d\n", aunq_match, pgtcount); } for (cnt = 0; cnt < pgtcount; cnt ++) { if (tuple = QR_AddNew(res), NULL == tuple) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't QR_AddNew.", func); goto cleanup; } /* These values can't be NULL */ if (aunq_match == cnt) { set_tuplefield_string(&tuple[GETTYPE_TYPE_NAME], PGTYPE_TO_NAME(conn, pgType, TRUE)); set_tuplefield_int2(&tuple[GETTYPE_NULLABLE], SQL_NO_NULLS); MYLOG(DETAIL_LOG_LEVEL, "serial in\n"); } else { set_tuplefield_string(&tuple[GETTYPE_TYPE_NAME], PGTYPE_TO_NAME(conn, pgType, FALSE)); set_tuplefield_int2(&tuple[GETTYPE_NULLABLE], pgtype_nullable(conn, pgType)); } set_tuplefield_int2(&tuple[GETTYPE_DATA_TYPE], (Int2) sqlType); set_tuplefield_int2(&tuple[GETTYPE_CASE_SENSITIVE], pgtype_case_sensitive(conn, pgType)); set_tuplefield_int2(&tuple[GETTYPE_SEARCHABLE], pgtype_searchable(conn, pgType)); set_tuplefield_int2(&tuple[GETTYPE_FIXED_PREC_SCALE], pgtype_money(conn, pgType)); /* * Localized data-source dependent data type name (always * NULL) */ set_tuplefield_null(&tuple[GETTYPE_LOCAL_TYPE_NAME]); /* These values can be NULL */ set_nullfield_int4(&tuple[GETTYPE_COLUMN_SIZE], PGTYPE_COLUMN_SIZE(conn, pgType)); set_nullfield_string(&tuple[GETTYPE_LITERAL_PREFIX], pgtype_literal_prefix(conn, pgType)); set_nullfield_string(&tuple[GETTYPE_LITERAL_SUFFIX], pgtype_literal_suffix(conn, pgType)); set_nullfield_string(&tuple[GETTYPE_CREATE_PARAMS], pgtype_create_params(conn, pgType)); if (1 < pgtcount) set_tuplefield_int2(&tuple[GETTYPE_UNSIGNED_ATTRIBUTE], SQL_TRUE); else set_nullfield_int2(&tuple[GETTYPE_UNSIGNED_ATTRIBUTE], pgtype_unsigned(conn, pgType)); if (aunq_match == cnt) set_tuplefield_int2(&tuple[GETTYPE_AUTO_UNIQUE_VALUE], SQL_TRUE); else set_nullfield_int2(&tuple[GETTYPE_AUTO_UNIQUE_VALUE], pgtype_auto_increment(conn, pgType)); set_nullfield_int2(&tuple[GETTYPE_MINIMUM_SCALE], pgtype_min_decimal_digits(conn, pgType)); set_nullfield_int2(&tuple[GETTYPE_MAXIMUM_SCALE], pgtype_max_decimal_digits(conn, pgType)); set_tuplefield_int2(&tuple[GETTYPE_SQL_DATA_TYPE], PGTYPE_TO_SQLDESCTYPE(conn, pgType)); set_nullfield_int2(&tuple[GETTYPE_SQL_DATETIME_SUB], PGTYPE_TO_DATETIME_SUB(conn, pgType)); set_nullfield_int4(&tuple[GETTYPE_NUM_PREC_RADIX], pgtype_radix(conn, pgType)); set_nullfield_int4(&tuple[GETTYPE_INTERVAL_PRECISION], 0); } } } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; stmt->currTuple = -1; if (SQL_SUCCEEDED(ret)) SC_set_rowset_start(stmt, -1, FALSE); else SC_set_Result(stmt, NULL); SC_set_current_col(stmt, -1); return ret; } RETCODE SQL_API PGAPI_GetFunctions(HDBC hdbc, SQLUSMALLINT fFunction, SQLUSMALLINT * pfExists) { ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci = &(conn->connInfo); MYLOG(0, "entering...%u\n", fFunction); if (fFunction == SQL_API_ALL_FUNCTIONS) { memset(pfExists, 0, sizeof(pfExists[0]) * 100); /* ODBC core functions */ pfExists[SQL_API_SQLALLOCCONNECT] = TRUE; pfExists[SQL_API_SQLALLOCENV] = TRUE; pfExists[SQL_API_SQLALLOCSTMT] = TRUE; pfExists[SQL_API_SQLBINDCOL] = TRUE; pfExists[SQL_API_SQLCANCEL] = TRUE; pfExists[SQL_API_SQLCOLATTRIBUTES] = TRUE; pfExists[SQL_API_SQLCONNECT] = TRUE; pfExists[SQL_API_SQLDESCRIBECOL] = TRUE; /* partial */ pfExists[SQL_API_SQLDISCONNECT] = TRUE; pfExists[SQL_API_SQLERROR] = TRUE; pfExists[SQL_API_SQLEXECDIRECT] = TRUE; pfExists[SQL_API_SQLEXECUTE] = TRUE; pfExists[SQL_API_SQLFETCH] = TRUE; pfExists[SQL_API_SQLFREECONNECT] = TRUE; pfExists[SQL_API_SQLFREEENV] = TRUE; pfExists[SQL_API_SQLFREESTMT] = TRUE; pfExists[SQL_API_SQLGETCURSORNAME] = TRUE; pfExists[SQL_API_SQLNUMRESULTCOLS] = TRUE; pfExists[SQL_API_SQLPREPARE] = TRUE; /* complete? */ pfExists[SQL_API_SQLROWCOUNT] = TRUE; pfExists[SQL_API_SQLSETCURSORNAME] = TRUE; pfExists[SQL_API_SQLSETPARAM] = FALSE; /* odbc 1.0 */ pfExists[SQL_API_SQLTRANSACT] = TRUE; /* ODBC level 1 functions */ pfExists[SQL_API_SQLBINDPARAMETER] = TRUE; pfExists[SQL_API_SQLCOLUMNS] = TRUE; pfExists[SQL_API_SQLDRIVERCONNECT] = TRUE; pfExists[SQL_API_SQLGETCONNECTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLGETDATA] = TRUE; pfExists[SQL_API_SQLGETFUNCTIONS] = TRUE; pfExists[SQL_API_SQLGETINFO] = TRUE; pfExists[SQL_API_SQLGETSTMTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLGETTYPEINFO] = TRUE; pfExists[SQL_API_SQLPARAMDATA] = TRUE; pfExists[SQL_API_SQLPUTDATA] = TRUE; pfExists[SQL_API_SQLSETCONNECTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLSETSTMTOPTION] = TRUE; pfExists[SQL_API_SQLSPECIALCOLUMNS] = TRUE; pfExists[SQL_API_SQLSTATISTICS] = TRUE; pfExists[SQL_API_SQLTABLES] = TRUE; /* ODBC level 2 functions */ pfExists[SQL_API_SQLBROWSECONNECT] = FALSE; pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = TRUE; pfExists[SQL_API_SQLDATASOURCES] = FALSE; /* only implemented by * DM */ if (SUPPORT_DESCRIBE_PARAM(ci)) pfExists[SQL_API_SQLDESCRIBEPARAM] = TRUE; else pfExists[SQL_API_SQLDESCRIBEPARAM] = FALSE; /* not properly * implemented */ pfExists[SQL_API_SQLDRIVERS] = FALSE; /* only implemented by * DM */ pfExists[SQL_API_SQLEXTENDEDFETCH] = TRUE; pfExists[SQL_API_SQLFOREIGNKEYS] = TRUE; pfExists[SQL_API_SQLMORERESULTS] = TRUE; pfExists[SQL_API_SQLNATIVESQL] = TRUE; pfExists[SQL_API_SQLNUMPARAMS] = TRUE; pfExists[SQL_API_SQLPARAMOPTIONS] = TRUE; pfExists[SQL_API_SQLPRIMARYKEYS] = TRUE; pfExists[SQL_API_SQLPROCEDURECOLUMNS] = TRUE; pfExists[SQL_API_SQLPROCEDURES] = TRUE; pfExists[SQL_API_SQLSETPOS] = TRUE; pfExists[SQL_API_SQLSETSCROLLOPTIONS] = TRUE; /* odbc 1.0 */ pfExists[SQL_API_SQLTABLEPRIVILEGES] = TRUE; if (0 == ci->updatable_cursors) pfExists[SQL_API_SQLBULKOPERATIONS] = FALSE; else pfExists[SQL_API_SQLBULKOPERATIONS] = TRUE; } else { if (ci->drivers.lie) *pfExists = TRUE; else { switch (fFunction) { case SQL_API_SQLBINDCOL: *pfExists = TRUE; break; case SQL_API_SQLCANCEL: *pfExists = TRUE; break; case SQL_API_SQLCOLATTRIBUTE: *pfExists = TRUE; break; case SQL_API_SQLCONNECT: *pfExists = TRUE; break; case SQL_API_SQLDESCRIBECOL: *pfExists = TRUE; break; /* partial */ case SQL_API_SQLDISCONNECT: *pfExists = TRUE; break; case SQL_API_SQLEXECDIRECT: *pfExists = TRUE; break; case SQL_API_SQLEXECUTE: *pfExists = TRUE; break; case SQL_API_SQLFETCH: *pfExists = TRUE; break; case SQL_API_SQLFREESTMT: *pfExists = TRUE; break; case SQL_API_SQLGETCURSORNAME: *pfExists = TRUE; break; case SQL_API_SQLNUMRESULTCOLS: *pfExists = TRUE; break; case SQL_API_SQLPREPARE: *pfExists = TRUE; break; case SQL_API_SQLROWCOUNT: *pfExists = TRUE; break; case SQL_API_SQLSETCURSORNAME: *pfExists = TRUE; break; /* ODBC level 1 functions */ case SQL_API_SQLBINDPARAMETER: *pfExists = TRUE; break; case SQL_API_SQLCOLUMNS: *pfExists = TRUE; break; case SQL_API_SQLDRIVERCONNECT: *pfExists = TRUE; break; case SQL_API_SQLGETDATA: *pfExists = TRUE; break; case SQL_API_SQLGETFUNCTIONS: *pfExists = TRUE; break; case SQL_API_SQLGETINFO: *pfExists = TRUE; break; case SQL_API_SQLGETTYPEINFO: *pfExists = TRUE; break; case SQL_API_SQLPARAMDATA: *pfExists = TRUE; break; case SQL_API_SQLPUTDATA: *pfExists = TRUE; break; case SQL_API_SQLSPECIALCOLUMNS: *pfExists = TRUE; break; case SQL_API_SQLSTATISTICS: *pfExists = TRUE; break; case SQL_API_SQLTABLES: *pfExists = TRUE; break; /* ODBC level 2 functions */ case SQL_API_SQLBROWSECONNECT: *pfExists = FALSE; break; case SQL_API_SQLCOLUMNPRIVILEGES: *pfExists = TRUE; break; case SQL_API_SQLDATASOURCES: *pfExists = FALSE; break; /* only implemented by DM */ case SQL_API_SQLDESCRIBEPARAM: if (SUPPORT_DESCRIBE_PARAM(ci)) *pfExists = TRUE; else *pfExists = FALSE; break; /* not properly implemented */ case SQL_API_SQLDRIVERS: *pfExists = FALSE; break; /* only implemented by DM */ case SQL_API_SQLEXTENDEDFETCH: *pfExists = TRUE; break; case SQL_API_SQLFOREIGNKEYS: *pfExists = TRUE; break; case SQL_API_SQLMORERESULTS: *pfExists = TRUE; break; case SQL_API_SQLNATIVESQL: *pfExists = TRUE; break; case SQL_API_SQLNUMPARAMS: *pfExists = TRUE; break; case SQL_API_SQLPRIMARYKEYS: *pfExists = TRUE; break; case SQL_API_SQLPROCEDURECOLUMNS: *pfExists = TRUE; break; case SQL_API_SQLPROCEDURES: *pfExists = TRUE; break; case SQL_API_SQLSETPOS: *pfExists = TRUE; break; case SQL_API_SQLTABLEPRIVILEGES: *pfExists = TRUE; break; case SQL_API_SQLBULKOPERATIONS: /* 24 */ case SQL_API_SQLALLOCHANDLE: /* 1001 */ case SQL_API_SQLBINDPARAM: /* 1002 */ case SQL_API_SQLCLOSECURSOR: /* 1003 */ case SQL_API_SQLENDTRAN: /* 1005 */ case SQL_API_SQLFETCHSCROLL: /* 1021 */ case SQL_API_SQLFREEHANDLE: /* 1006 */ case SQL_API_SQLGETCONNECTATTR: /* 1007 */ case SQL_API_SQLGETDESCFIELD: /* 1008 */ case SQL_API_SQLGETDIAGFIELD: /* 1010 */ case SQL_API_SQLGETDIAGREC: /* 1011 */ case SQL_API_SQLGETENVATTR: /* 1012 */ case SQL_API_SQLGETSTMTATTR: /* 1014 */ case SQL_API_SQLSETCONNECTATTR: /* 1016 */ case SQL_API_SQLSETDESCFIELD: /* 1017 */ case SQL_API_SQLSETENVATTR: /* 1019 */ case SQL_API_SQLSETSTMTATTR: /* 1020 */ *pfExists = TRUE; break; case SQL_API_SQLGETDESCREC: /* 1009 */ case SQL_API_SQLSETDESCREC: /* 1018 */ case SQL_API_SQLCOPYDESC: /* 1004 */ *pfExists = FALSE; break; default: *pfExists = FALSE; break; } } } return SQL_SUCCESS; } char * identifierEscape(const SQLCHAR *src, SQLLEN srclen, const ConnectionClass *conn, char *buf, size_t bufsize, BOOL double_quote) { int i, outlen; UCHAR tchar; char *dest = NULL, escape_ch = CC_get_escape(conn); encoded_str encstr; if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) srclen = (SQLLEN) strlen((char *) src); if (srclen <= 0) return dest; MYLOG(0, "entering in=%s(" FORMAT_LEN ")\n", src, srclen); if (NULL != buf && bufsize > 0) dest = buf; else { bufsize = 2 * srclen + 1; dest = malloc(bufsize); } if (!dest) return NULL; encoded_str_constr(&encstr, conn->ccsc, (char *) src); outlen = 0; if (double_quote) dest[outlen++] = IDENTIFIER_QUOTE; for (i = 0, tchar = encoded_nextchar(&encstr); i < srclen && outlen < bufsize - 1; i++, tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) { dest[outlen++] = tchar; continue; } if (LITERAL_QUOTE == tchar || escape_ch == tchar) dest[outlen++] = tchar; else if (double_quote && IDENTIFIER_QUOTE == tchar) dest[outlen++] = tchar; dest[outlen++] = tchar; } if (double_quote) dest[outlen++] = IDENTIFIER_QUOTE; dest[outlen] = '\0'; MYLOG(0, "leaving output=%s(%d)\n", dest, outlen); return dest; } static char * simpleCatalogEscape(const SQLCHAR *src, SQLLEN srclen, const ConnectionClass *conn) { return identifierEscape(src, srclen, conn, NULL, -1, FALSE); } /* * PostgreSQL needs 2 '\\' to escape '_' and '%'. */ static char * adjustLikePattern(const SQLCHAR *src, int srclen, const ConnectionClass *conn) { int i, outlen; UCHAR tchar; char *dest = NULL, escape_in_literal = CC_get_escape(conn); BOOL escape_in = FALSE; encoded_str encstr; if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) srclen = (int) strlen((char *) src); /* if (srclen <= 0) */ if (srclen < 0) return dest; MYLOG(0, "entering in=%.*s(%d)\n", srclen, src, srclen); encoded_str_constr(&encstr, conn->ccsc, (char *) src); dest = malloc(4 * srclen + 1); if (!dest) return NULL; for (i = 0, outlen = 0; i < srclen; i++) { tchar = encoded_nextchar(&encstr); if (MBCS_NON_ASCII(encstr)) { dest[outlen++] = tchar; continue; } if (escape_in) { switch (tchar) { case '%': case '_': break; default: if (SEARCH_PATTERN_ESCAPE == escape_in_literal) dest[outlen++] = escape_in_literal; dest[outlen++] = SEARCH_PATTERN_ESCAPE; break; } } if (tchar == SEARCH_PATTERN_ESCAPE) { escape_in = TRUE; if (SEARCH_PATTERN_ESCAPE == escape_in_literal) dest[outlen++] = escape_in_literal; /* insert 1 more LEXER escape */ } else { escape_in = FALSE; if (LITERAL_QUOTE == tchar) dest[outlen++] = tchar; } dest[outlen++] = tchar; } if (escape_in) { if (SEARCH_PATTERN_ESCAPE == escape_in_literal) dest[outlen++] = escape_in_literal; dest[outlen++] = SEARCH_PATTERN_ESCAPE; } dest[outlen] = '\0'; MYLOG(0, "leaving output=%s(%d)\n", dest, outlen); return dest; } #define CSTR_SYS_TABLE "SYSTEM TABLE" #define CSTR_TABLE "TABLE" #define CSTR_VIEW "VIEW" #define CSTR_FOREIGN_TABLE "FOREIGN TABLE" #define CSTR_MATVIEW "MATVIEW" CSTR like_op_sp = "like "; CSTR like_op_ext = "like E"; CSTR eq_op_sp = "= "; CSTR eq_op_ext = "= E"; #define IS_VALID_NAME(str) ((str) && (str)[0]) static const char *gen_opestr(const char *orig_opestr, const ConnectionClass * conn) { BOOL addE = (0 != CC_get_escape(conn) && PG_VERSION_GE(conn, 8.1)); if (0 == strcmp(orig_opestr, eqop)) return (addE ? eq_op_ext : eq_op_sp); return (addE ? like_op_ext : like_op_sp); } /* * If specified schema name == user_name and the current schema is * 'public', allowed to use the 'public' schema. */ static BOOL allow_public_schema(ConnectionClass *conn, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName) { const char *user = CC_get_username(conn); const char *curschema; size_t userlen = strlen(user); size_t schemalen; if (NULL == szSchemaName) return FALSE; if (SQL_NTS == cbSchemaName) schemalen = strlen((char *) szSchemaName); else schemalen = cbSchemaName; if (schemalen != userlen) return FALSE; if (strnicmp((char *) szSchemaName, user, userlen) != 0) return FALSE; curschema = CC_get_current_schema(conn); if (curschema == NULL) return FALSE; return stricmp(curschema, (const char *) pubstr) == 0; } #define TABLE_IN_RELKIND "('r', 'v', 'm', 'f', 'p')" RETCODE SQL_API PGAPI_Tables(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* PV X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* PV E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* PV E*/ SQLSMALLINT cbTableName, const SQLCHAR * szTableType, SQLSMALLINT cbTableType, UWORD flag) { CSTR func = "PGAPI_Tables"; StatementClass *stmt = (StatementClass *) hstmt; StatementClass *tbl_stmt = NULL; QResultClass *res; TupleField *tuple; RETCODE ret = SQL_ERROR, result; int result_cols; char *tableType = NULL; PQExpBufferData tables_query = {0}; char table_name[MAX_INFO_STRING], table_owner[MAX_INFO_STRING], relkind_or_hasrules[MAX_INFO_STRING]; #ifdef HAVE_STRTOK_R char *last; #endif /* HAVE_STRTOK_R */ ConnectionClass *conn; ConnInfo *ci; char *escCatName = NULL, *escSchemaName = NULL, *escTableName = NULL; /* Support up to 32 system table prefixes. Should be more than enough. */ #define MAX_PREFIXES 32 char *prefix[MAX_PREFIXES], prefixes[MEDIUM_REGISTRY_LEN]; int nprefixes; char show_system_tables, show_regular_tables, show_views, show_matviews, show_foreign_tables; char regular_table, view, matview, foreign_table, systable; int i; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const char *like_or_eq, *op_string; const SQLCHAR *szSchemaName; BOOL search_pattern; BOOL list_cat = FALSE, list_schemas = FALSE, list_table_types = FALSE, list_some = FALSE; SQLLEN cbRelname, cbRelkind, cbSchName; EnvironmentClass *env; BOOL is_ODBC2; static const char *catcn[][2] = { {"TABLE_CAT", "TABLE_QUALIFIER"}, {"TABLE_SCHEM", "TABLE_OWNER"}, {"TABLE_NAME", "TABLE_NAME"}, {"TABLE_TYPE", "TABLE_TYPE"}, {"REMARKS", "REMARKS"}}; MYLOG(0, "entering...stmt=%p scnm=%p len=%d\n", stmt, szTableOwner, cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; conn = SC_get_conn(stmt); ci = &(conn->connInfo); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); result = PGAPI_AllocStmt(conn, (HSTMT *) &tbl_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_Tables result.", func); return SQL_ERROR; } szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; #define return DONT_CALL_RETURN_FROM_HERE??? search_pattern = (0 == (flag & PODBC_NOT_SEARCH_PATTERN)); if (search_pattern) { like_or_eq = likeop; escCatName = adjustLikePattern(szTableQualifier, cbTableQualifier, conn); escTableName = adjustLikePattern(szTableName, cbTableName, conn); } else { like_or_eq = eqop; escCatName = simpleCatalogEscape(szTableQualifier, cbTableQualifier, conn); escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); } retry_public_schema: if (escSchemaName) free(escSchemaName); if (search_pattern) escSchemaName = adjustLikePattern(szSchemaName, cbSchemaName, conn); else escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, conn); /* * Create the query to find out the tables */ /* make_string mallocs memory */ tableType = make_string(szTableType, cbTableType, NULL, 0); if (search_pattern && escTableName && '\0' == escTableName[0] && escCatName && escSchemaName) { if ('\0' == escSchemaName[0]) { if (stricmp(escCatName, SQL_ALL_CATALOGS) == 0) list_cat = TRUE; else if ('\0' == escCatName[0] && stricmp(tableType, SQL_ALL_TABLE_TYPES) == 0) list_table_types = TRUE; } else if ('\0' == escCatName[0] && stricmp(escSchemaName, SQL_ALL_SCHEMAS) == 0) list_schemas = TRUE; } list_some = (list_cat || list_schemas || list_table_types); initPQExpBuffer(&tables_query); #define return DONT_CALL_RETURN_FROM_HERE??? if (list_cat) appendPQExpBufferStr(&tables_query, "select NULL, NULL, NULL"); else if (list_table_types) { /* * Query relations depending on what is available: * - 10 and newer versions have partition tables * - 9.3 and newer versions have materialized views * - 9.1 and newer versions have foreign tables */ appendPQExpBufferStr(&tables_query, "select NULL, NULL, relkind from (select 'r' as relkind " "union select 'v' " "union select 'm' " "union select 'f' " "union select 'p') as a"); } else if (list_schemas) { appendPQExpBufferStr(&tables_query, "select NULL, nspname, NULL" " from pg_catalog.pg_namespace n where true"); } else { /* * View is represented by its relkind since 7.1, * Materialized views are added in 9.3, and foreign * tables in 9.1. */ appendPQExpBufferStr(&tables_query, "select relname, nspname, relkind " "from pg_catalog.pg_class c, pg_catalog.pg_namespace n " "where relkind in " TABLE_IN_RELKIND); } op_string = gen_opestr(like_or_eq, conn); if (!list_some) { schema_appendPQExpBuffer1(&tables_query, " and nspname %s'%.*s'", op_string, escSchemaName, TABLE_IS_VALID(szTableName, cbTableName), conn); if (IS_VALID_NAME(escTableName)) appendPQExpBuffer(&tables_query, " and relname %s'%s'", op_string, escTableName); } /* * Parse the extra systable prefix configuration variable into an array * of prefixes. */ STRCPY_FIXED(prefixes, ci->drivers.extra_systable_prefixes); for (i = 0; i < MAX_PREFIXES; i++) { char *str = (i == 0) ? prefixes : NULL; #ifdef HAVE_STRTOK_R prefix[i] = strtok_r(str, ";", &last); #else prefix[i] = strtok(str, ";"); #endif /* HAVE_STRTOK_R */ if (prefix[i] == NULL) break; } nprefixes = i; /* Parse the desired table types to return */ show_system_tables = FALSE; show_regular_tables = FALSE; show_views = FALSE; show_foreign_tables = FALSE; show_matviews = FALSE; /* TABLE_TYPE */ if (!tableType) { show_regular_tables = TRUE; show_views = TRUE; show_foreign_tables = TRUE; show_matviews = TRUE; } else if (list_some || stricmp(tableType, SQL_ALL_TABLE_TYPES) == 0) { show_regular_tables = TRUE; show_views = TRUE; show_foreign_tables = TRUE; show_matviews = TRUE; } else { /* Check for desired table types to return */ char *srcstr; for (srcstr = tableType;; srcstr = NULL) { char *typestr; #ifdef HAVE_STRTOK_R typestr = strtok_r(srcstr, ",", &last); #else typestr = strtok(srcstr, ","); #endif /* HAVE_STRTOK_R */ if (typestr == NULL) break; while (isspace((unsigned char) *typestr)) typestr++; if (*typestr == '\'') typestr++; if (strnicmp(typestr, CSTR_SYS_TABLE, strlen(CSTR_SYS_TABLE)) == 0) show_system_tables = TRUE; else if (strnicmp(typestr, CSTR_TABLE, strlen(CSTR_TABLE)) == 0) show_regular_tables = TRUE; else if (strnicmp(typestr, CSTR_VIEW, strlen(CSTR_VIEW)) == 0) show_views = TRUE; else if (strnicmp(typestr, CSTR_FOREIGN_TABLE, strlen(CSTR_FOREIGN_TABLE)) == 0) show_foreign_tables = TRUE; else if (strnicmp(typestr, CSTR_MATVIEW, strlen(CSTR_MATVIEW)) == 0) show_matviews = TRUE; } } /* * If not interested in SYSTEM TABLES then filter them out to save * some time on the query. If treating system tables as regular * tables, then dont filter either. */ if ((list_schemas || !list_some) && !atoi(ci->show_system_tables) && !show_system_tables) appendPQExpBufferStr(&tables_query, " and nspname not in ('pg_catalog', 'information_schema', 'pg_toast', 'pg_temp_1')"); if (!list_some) { if (CC_accessible_only(conn)) appendPQExpBufferStr(&tables_query, " and has_table_privilege(c.oid, 'select')"); } if (list_schemas) appendPQExpBufferStr(&tables_query, " order by nspname"); else if (list_some) ; else appendPQExpBufferStr(&tables_query, " and n.oid = relnamespace order by nspname, relname"); if (PQExpBufferDataBroken(tables_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_Tables()", func); goto cleanup; } result = PGAPI_ExecDirect(tbl_stmt, (SQLCHAR *) tables_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } /* If not found */ if ((res = SC_get_Result(tbl_stmt)) && 0 == QR_get_num_total_tuples(res)) { if (allow_public_schema(conn, szSchemaName, cbSchemaName)) { szSchemaName = pubstr; cbSchemaName = SQL_NTS; goto retry_public_schema; } } #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ result = PGAPI_BindCol(tbl_stmt, 1, internal_asis_type, table_name, MAX_INFO_STRING, &cbRelname); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 2, internal_asis_type, table_owner, MAX_INFO_STRING, &cbSchName); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 3, internal_asis_type, relkind_or_hasrules, MAX_INFO_STRING, &cbRelkind); if (!SQL_SUCCEEDED(result)) { goto cleanup; } if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_Tables result.", func); goto cleanup; } SC_set_Result(stmt, res); /* the binding structure for a statement is not set up until */ /* * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_TABLES_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; /* set the field names */ QR_set_num_fields(res, result_cols); QR_set_field_info_EN(res, TABLES_CATALOG_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, TABLES_SCHEMA_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, TABLES_TABLE_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, TABLES_TABLE_TYPE, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, TABLES_REMARKS, PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE); /* add the tuples */ table_name[0] = '\0'; table_owner[0] = '\0'; result = PGAPI_Fetch(tbl_stmt); while (SQL_SUCCEEDED(result)) { /* * Determine if this table name is a system table. If treating * system tables as regular tables, then no need to do this test. */ systable = FALSE; if (!atoi(ci->show_system_tables)) { if (stricmp(table_owner, "pg_catalog") == 0 || stricmp(table_owner, "pg_toast") == 0 || strnicmp(table_owner, "pg_temp_", 8) == 0 || stricmp(table_owner, "information_schema") == 0) systable = TRUE; else { /* Check extra system table prefixes */ for (i = 0; i < nprefixes; i++) { MYLOG(0, "table_name='%s', prefix[%d]='%s'\n", table_name, i, prefix[i]); if (strncmp(table_name, prefix[i], strlen(prefix[i])) == 0) { systable = TRUE; break; } } } } /* Determine if the table name is a view */ view = (relkind_or_hasrules[0] == 'v'); /* Check for foreign tables and materialized views ... */ foreign_table = (relkind_or_hasrules[0] == 'f'); matview = (relkind_or_hasrules[0] == 'm'); /* It must be a regular table */ regular_table = (!systable && !view); /* Include the row in the result set if meets all criteria */ /* * NOTE: Unsupported table types (i.e., LOCAL TEMPORARY, ALIAS, * etc) will return nothing */ if ((systable && show_system_tables) || (view && show_views) || (foreign_table && show_foreign_tables) || (matview && show_matviews) || (regular_table && show_regular_tables)) { tuple = QR_AddNew(res); if (list_cat || !list_some) set_tuplefield_string(&tuple[TABLES_CATALOG_NAME], CurrCat(conn)); else set_tuplefield_null(&tuple[TABLES_CATALOG_NAME]); /* * I have to hide the table owner from Access, otherwise it * insists on referring to the table as 'owner.table'. (this * is valid according to the ODBC SQL grammar, but Postgres * won't support it.) * * set_tuplefield_string(&tuple[TABLES_SCHEMA_NAME], table_owner); */ MYLOG(0, "table_name = '%s'\n", table_name); if (list_schemas || !list_some) set_tuplefield_string(&tuple[TABLES_SCHEMA_NAME], GET_SCHEMA_NAME(table_owner)); else set_tuplefield_null(&tuple[TABLES_SCHEMA_NAME]); if (list_some) set_tuplefield_null(&tuple[TABLES_TABLE_NAME]); else set_tuplefield_string(&tuple[TABLES_TABLE_NAME], table_name); if (list_table_types || !list_some) { if (systable) set_tuplefield_string(&tuple[TABLES_TABLE_TYPE], CSTR_SYS_TABLE); else if (view) set_tuplefield_string(&tuple[TABLES_TABLE_TYPE], CSTR_VIEW); else if (matview) set_tuplefield_string(&tuple[TABLES_TABLE_TYPE], CSTR_MATVIEW); else if (foreign_table) set_tuplefield_string(&tuple[TABLES_TABLE_TYPE], CSTR_FOREIGN_TABLE); else set_tuplefield_string(&tuple[TABLES_TABLE_TYPE], CSTR_TABLE); } else set_tuplefield_null(&tuple[TABLES_TABLE_TYPE]); set_tuplefield_string(&tuple[TABLES_REMARKS], NULL_STRING); /*** set_tuplefield_string(&tuple[TABLES_REMARKS], "TABLE"); ***/ } result = PGAPI_Fetch(tbl_stmt); } if (result != SQL_NO_DATA_FOUND) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, tbl_stmt, TRUE); if (!PQExpBufferDataBroken(tables_query)) termPQExpBuffer(&tables_query); if (escCatName) free(escCatName); if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); if (tableType) free(tableType); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); if (tbl_stmt) PGAPI_FreeStmt(tbl_stmt, SQL_DROP); MYLOG(0, "leaving stmt=%p, ret=%d\n", stmt, ret); return ret; } /* * macros for pgtype_attr_xxxx() calls which have * PG_ADT_UNSET or PG_UNKNOWNS_UNSET parameters */ #define PGTYPE_ATTR_COLUMN_SIZE(conn, pgType, atttypmod) pgtype_attr_column_size(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_TO_CONCISE_TYPE(conn, pgType, atttypmod) pgtype_attr_to_concise_type(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_TO_SQLDESCTYPE(conn, pgType, atttypmod) pgtype_attr_to_sqldesctype(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_DISPLAY_SIZE(conn, pgType, atttypmod) pgtype_attr_display_size(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_BUFFER_LENGTH(conn, pgType, atttypmod) pgtype_attr_buffer_length(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_DECIMAL_DIGITS(conn, pgType, atttypmod) pgtype_attr_decimal_digits(conn, pgType, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET) #define PGTYPE_ATTR_TRANSFER_OCTET_LENGTH(conn, pgType, atttypmod) pgtype_attr_transfer_octet_length(conn, pgType, atttypmod, PG_UNKNOWNS_UNSET) /* * for oid or xmin */ static void add_tuple_for_oid_or_xmin(TupleField *tuple, int ordinal, const char *colname, OID the_type, const char *typname, const ConnectionClass *conn, const char *table_owner, const char *table_name, OID greloid, int attnum, BOOL auto_increment, int table_info) { int sqltype; const int atttypmod = -1; set_tuplefield_string(&tuple[COLUMNS_CATALOG_NAME], CurrCat(conn)); /* see note in SQLTables() */ set_tuplefield_string(&tuple[COLUMNS_SCHEMA_NAME], GET_SCHEMA_NAME(table_owner)); set_tuplefield_string(&tuple[COLUMNS_TABLE_NAME], table_name); set_tuplefield_string(&tuple[COLUMNS_COLUMN_NAME], colname); sqltype = PGTYPE_ATTR_TO_CONCISE_TYPE(conn, the_type, atttypmod); set_tuplefield_int2(&tuple[COLUMNS_DATA_TYPE], sqltype); set_tuplefield_string(&tuple[COLUMNS_TYPE_NAME], typname); set_tuplefield_int4(&tuple[COLUMNS_PRECISION], PGTYPE_ATTR_COLUMN_SIZE(conn, the_type, atttypmod)); set_tuplefield_int4(&tuple[COLUMNS_LENGTH], PGTYPE_ATTR_BUFFER_LENGTH(conn, the_type, atttypmod)); set_nullfield_int2(&tuple[COLUMNS_SCALE], PGTYPE_ATTR_DECIMAL_DIGITS(conn, the_type, atttypmod)); set_nullfield_int2(&tuple[COLUMNS_RADIX], pgtype_radix(conn, the_type)); set_tuplefield_int2(&tuple[COLUMNS_NULLABLE], SQL_NO_NULLS); set_tuplefield_string(&tuple[COLUMNS_REMARKS], NULL_STRING); set_tuplefield_null(&tuple[COLUMNS_COLUMN_DEF]); set_tuplefield_int2(&tuple[COLUMNS_SQL_DATA_TYPE], sqltype); set_tuplefield_null(&tuple[COLUMNS_SQL_DATETIME_SUB]); set_tuplefield_null(&tuple[COLUMNS_CHAR_OCTET_LENGTH]); set_tuplefield_int4(&tuple[COLUMNS_ORDINAL_POSITION], ordinal); set_tuplefield_string(&tuple[COLUMNS_IS_NULLABLE], "No"); set_tuplefield_int4(&tuple[COLUMNS_DISPLAY_SIZE], PGTYPE_ATTR_DISPLAY_SIZE(conn, the_type, atttypmod)); set_tuplefield_int4(&tuple[COLUMNS_FIELD_TYPE], the_type); set_tuplefield_int4(&tuple[COLUMNS_AUTO_INCREMENT], auto_increment); set_tuplefield_int2(&tuple[COLUMNS_PHYSICAL_NUMBER], attnum); set_tuplefield_int4(&tuple[COLUMNS_TABLE_OID], greloid); set_tuplefield_int4(&tuple[COLUMNS_BASE_TYPEID], 0); set_tuplefield_int4(&tuple[COLUMNS_ATTTYPMOD], -1); set_tuplefield_int4(&tuple[COLUMNS_TABLE_INFO], table_info); } RETCODE SQL_API PGAPI_Columns(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* OA X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* PV E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* PV E*/ SQLSMALLINT cbTableName, const SQLCHAR * szColumnName, /* PV E*/ SQLSMALLINT cbColumnName, UWORD flag, OID reloid, Int2 attnum) { CSTR func = "PGAPI_Columns"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; TupleField *tuple; StatementClass *col_stmt = NULL; PQExpBufferData columns_query = {0}; RETCODE ret = SQL_ERROR, result; char table_owner[MAX_INFO_STRING], table_name[MAX_INFO_STRING], field_name[MAX_INFO_STRING], field_type_name[MAX_INFO_STRING]; Int2 field_number, sqltype, concise_type, result_cols; Int4 mod_length, ordinal, typmod, relhasoids, relhassubclass; OID field_type, greloid, basetype; char not_null[MAX_INFO_STRING], relhasrules[MAX_INFO_STRING], relkind[8], attidentity[2]; char *escSchemaName = NULL, *escTableName = NULL, *escColumnName = NULL; BOOL search_pattern = TRUE, search_by_ids, relisaview, show_oid_column, row_versioning; ConnInfo *ci; ConnectionClass *conn; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const char *like_or_eq = likeop, *op_string; const SQLCHAR *szSchemaName; BOOL setIdentity = FALSE; int table_info = 0; static const char *catcn[][2] = { {"TABLE_CAT", "TABLE_QUALIFIER"}, {"TABLE_SCHEM", "TABLE_OWNER"}, {"TABLE_NAME", "TABLE_NAME"}, {"COLUMN_NAME", "COLUMN_NAME"}, {"DATA_TYPE", "DATA_TYPE"}, {"TYPE_NAME", "TYPE_NAME"}, {"COLUMN_SIZE", "PRECISION"}, {"BUFFER_LENGTH", "LENGTH"}, {"DECIMAL_DIGITS", "SCALE"}, {"NUM_PREC_RADIX", "RADIX"}, {"NULLABLE", "NULLABLE"}, {"REMARKS", "REMARKS"}, {"COLUMN_DEF", "COLUMN_DEF"}, {"SQL_DATA_TYPE", "SQL_DATA_TYPE"}, {"SQL_DATETIME_SUB", "SQL_DATETIME_SUB"}, {"CHAR_OCTET_LENGTH", "CHAR_OCTET_LENGTH"}, {"ORDINAL_POSITION", "ORDINAL_POSITION"}, {"IS_NULLABLE", "IS_NULLABLE"}, /* User defined fields */ {"DISPLAY_SIZE", "DISPLAY_SIZE"}, {"FIELD_TYPE", "FIELD_TYPE"}, {"AUTO_INCREMENT", "AUTO_INCREMENT"}, {"PHYSICAL NUMBER", "PHYSICAL NUMBER"}, {"TABLE OID", "TABLE OID"}, {"BASE TYPEID", "BASE TYPEID"}, {"TYPMOD", "TYPMOD"}, {"TABLE INFO", "TABLE INFO"} }; EnvironmentClass *env; BOOL is_ODBC2; MYLOG(0, "entering...stmt=%p scnm=%p len=%d columnOpt=%x\n", stmt, szTableOwner, cbTableOwner, flag); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; conn = SC_get_conn(stmt); ci = &(conn->connInfo); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ #define return DONT_CALL_RETURN_FROM_HERE??? show_oid_column = ((flag & PODBC_SHOW_OID_COLUMN) != 0); row_versioning = ((flag & PODBC_ROW_VERSIONING) != 0); search_by_ids = ((flag & PODBC_SEARCH_BY_IDS) != 0); if (search_by_ids) { szSchemaName = NULL; cbSchemaName = SQL_NULL_DATA; } else { szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; reloid = 0; attnum = 0; /* * TableName or ColumnName is ordinarily an pattern value, */ search_pattern = ((flag & PODBC_NOT_SEARCH_PATTERN) == 0); if (search_pattern) { like_or_eq = likeop; escTableName = adjustLikePattern(szTableName, cbTableName, conn); escColumnName = adjustLikePattern(szColumnName, cbColumnName, conn); } else { like_or_eq = eqop; escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); escColumnName = simpleCatalogEscape(szColumnName, cbColumnName, conn); } } retry_public_schema: if (!search_by_ids) { if (escSchemaName) free(escSchemaName); if (search_pattern) escSchemaName = adjustLikePattern(szSchemaName, cbSchemaName, conn); else escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, conn); } initPQExpBuffer(&columns_query); #define return DONT_CALL_RETURN_FROM_HERE??? /* * Create the query to find out the columns (Note: pre 6.3 did not * have the atttypmod field) */ op_string = gen_opestr(like_or_eq, conn); printfPQExpBuffer(&columns_query, "select n.nspname, c.relname, a.attname, a.atttypid, " "t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, " "c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), " "case t.typtype when 'd' then t.typbasetype else 0 end, t.typtypmod, " "%s, %s, c.relhassubclass " "from (((pg_catalog.pg_class c " "inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace", PG_VERSION_GE(conn, 12.0) ? "0" : "c.relhasoids", PG_VERSION_GE(conn, 10.0) ? "attidentity" : "''"); if (search_by_ids) appendPQExpBuffer(&columns_query, " and c.oid = %u", reloid); else { if (escTableName) appendPQExpBuffer(&columns_query, " and c.relname %s'%s'", op_string, escTableName); schema_appendPQExpBuffer1(&columns_query, " and n.nspname %s'%.*s'", op_string, escSchemaName, TABLE_IS_VALID(szTableName, cbTableName), conn); } appendPQExpBufferStr(&columns_query, ") inner join pg_catalog.pg_attribute a" " on (not a.attisdropped)"); if (0 == attnum && (NULL == escColumnName || like_or_eq != eqop)) appendPQExpBufferStr(&columns_query, " and a.attnum > 0"); if (search_by_ids) { if (attnum != 0) appendPQExpBuffer(&columns_query, " and a.attnum = %d", attnum); } else if (escColumnName) appendPQExpBuffer(&columns_query, " and a.attname %s'%s'", op_string, escColumnName); appendPQExpBufferStr(&columns_query, " and a.attrelid = c.oid) inner join pg_catalog.pg_type t" " on t.oid = a.atttypid) left outer join pg_attrdef d" " on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum"); appendPQExpBufferStr(&columns_query, " order by n.nspname, c.relname, attnum"); if (PQExpBufferDataBroken(columns_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_Columns()", func); goto cleanup; } result = PGAPI_AllocStmt(conn, (HSTMT *) &col_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_Columns result.", func); goto cleanup; } MYLOG(0, "col_stmt = %p\n", col_stmt); result = PGAPI_ExecDirect(col_stmt, (SQLCHAR *) columns_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, col_stmt, FALSE); goto cleanup; } /* If not found */ if ((flag & PODBC_SEARCH_PUBLIC_SCHEMA) != 0 && (res = SC_get_Result(col_stmt)) && 0 == QR_get_num_total_tuples(res)) { if (!search_by_ids && allow_public_schema(conn, szSchemaName, cbSchemaName)) { PGAPI_FreeStmt(col_stmt, SQL_DROP); col_stmt = NULL; szSchemaName = pubstr; cbSchemaName = SQL_NTS; goto retry_public_schema; } } result = PGAPI_BindCol(col_stmt, 1, internal_asis_type, table_owner, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 2, internal_asis_type, table_name, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 3, internal_asis_type, field_name, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 4, SQL_C_ULONG, &field_type, 4, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 5, internal_asis_type, field_type_name, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 6, SQL_C_SHORT, &field_number, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } #ifdef NOT_USED result = PGAPI_BindCol(col_stmt, 7, SQL_C_LONG, &field_length, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } #endif /* NOT_USED */ result = PGAPI_BindCol(col_stmt, 8, SQL_C_LONG, &mod_length, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 9, internal_asis_type, not_null, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 10, internal_asis_type, relhasrules, MAX_INFO_STRING, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 11, internal_asis_type, relkind, sizeof(relkind), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 12, SQL_C_LONG, &greloid, sizeof(greloid), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 14, SQL_C_ULONG, &basetype, sizeof(basetype), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 15, SQL_C_LONG, &typmod, sizeof(typmod), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 16, SQL_C_LONG, &relhasoids, sizeof(relhasoids), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 17, SQL_C_CHAR, attidentity, sizeof(attidentity), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 18, SQL_C_LONG, &relhassubclass, sizeof(relhassubclass), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_Columns result.", func); goto cleanup; } SC_set_Result(stmt, res); /* the binding structure for a statement is not set up until */ /* * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_COLUMNS_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); /* * Setting catalog_result here affects the behavior of * pgtype_xxx() functions. So set it later. * stmt->catalog_result = TRUE; */ /* set the field names */ QR_set_num_fields(res, result_cols); QR_set_field_info_EN(res, COLUMNS_CATALOG_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, COLUMNS_SCHEMA_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, COLUMNS_TABLE_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, COLUMNS_COLUMN_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, COLUMNS_DATA_TYPE, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_TYPE_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, COLUMNS_PRECISION, PG_TYPE_INT4, 4); /* COLUMN_SIZE */ QR_set_field_info_EN(res, COLUMNS_LENGTH, PG_TYPE_INT4, 4); /* BUFFER_LENGTH */ QR_set_field_info_EN(res, COLUMNS_SCALE, PG_TYPE_INT2, 2); /* DECIMAL_DIGITS ***/ QR_set_field_info_EN(res, COLUMNS_RADIX, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_NULLABLE, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_REMARKS, PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE); QR_set_field_info_EN(res, COLUMNS_COLUMN_DEF, PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE); QR_set_field_info_EN(res, COLUMNS_SQL_DATA_TYPE, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_SQL_DATETIME_SUB, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_CHAR_OCTET_LENGTH, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_ORDINAL_POSITION, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_IS_NULLABLE, PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE); /* User defined fields */ QR_set_field_info_EN(res, COLUMNS_DISPLAY_SIZE, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_FIELD_TYPE, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_AUTO_INCREMENT, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_PHYSICAL_NUMBER, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, COLUMNS_TABLE_OID, PG_TYPE_OID, 4); QR_set_field_info_EN(res, COLUMNS_BASE_TYPEID, PG_TYPE_OID, 4); QR_set_field_info_EN(res, COLUMNS_ATTTYPMOD, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, COLUMNS_TABLE_INFO, PG_TYPE_INT4, 4); ordinal = 1; result = PGAPI_Fetch(col_stmt); /* * Only show oid if option AND there are other columns AND it's not * being called by SQLStatistics . Always show OID if it's a system * table */ relisaview = (relkind[0] == 'v'); if (SQL_SUCCEEDED(result)) { if (relhasoids) table_info |= TBINFO_HASOIDS; if (relhassubclass) table_info |= TBINFO_HASSUBCLASS; if (!relisaview && relhasoids && (show_oid_column || strncmp(table_name, POSTGRES_SYS_PREFIX, strlen(POSTGRES_SYS_PREFIX)) == 0) && (NULL == escColumnName || 0 == strcmp(escColumnName, OID_NAME))) { const char *typname; /* For OID fields */ tuple = QR_AddNew(res); if (CC_fake_mss(conn)) { typname = "OID identity"; setIdentity = TRUE; } else typname = OID_NAME; add_tuple_for_oid_or_xmin(tuple, ordinal, OID_NAME, PG_TYPE_OID, typname, conn, table_owner, table_name, greloid, OID_ATTNUM, TRUE, table_info); ordinal++; } } while (SQL_SUCCEEDED(result)) { int auto_unique; SQLLEN len_needed; char *attdef; attdef = NULL; PGAPI_SetPos(col_stmt, 1, SQL_POSITION, 0); PGAPI_GetData(col_stmt, 13, internal_asis_type, NULL, 0, &len_needed); if (len_needed > 0) { MYLOG(0, "len_needed=" FORMAT_LEN "\n", len_needed); attdef = malloc(len_needed + 1); if (!attdef) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for attdef.", func); goto cleanup; } PGAPI_GetData(col_stmt, 13, internal_asis_type, attdef, len_needed + 1, &len_needed); MYLOG(0, " and the data=%s\n", attdef); } tuple = QR_AddNew(res); sqltype = SQL_TYPE_NULL; /* unspecified */ set_tuplefield_string(&tuple[COLUMNS_CATALOG_NAME], CurrCat(conn)); /* see note in SQLTables() */ set_tuplefield_string(&tuple[COLUMNS_SCHEMA_NAME], GET_SCHEMA_NAME(table_owner)); set_tuplefield_string(&tuple[COLUMNS_TABLE_NAME], table_name); set_tuplefield_string(&tuple[COLUMNS_COLUMN_NAME], field_name); auto_unique = SQL_FALSE; if (field_type = pg_true_type(conn, field_type, basetype), field_type == basetype) mod_length = typmod; switch (field_type) { case PG_TYPE_OID: if (0 != atoi(ci->fake_oid_index)) { auto_unique = SQL_TRUE; set_tuplefield_string(&tuple[COLUMNS_TYPE_NAME], "identity"); break; } case PG_TYPE_INT4: case PG_TYPE_INT8: if (attidentity[0] != 0 || (attdef && strnicmp(attdef, "nextval(", 8) == 0 && not_null[0] != '0')) { auto_unique = SQL_TRUE; if (!setIdentity && CC_fake_mss(conn)) { char tmp[256]; SPRINTF_FIXED(tmp, "%s identity", field_type_name); set_tuplefield_string(&tuple[COLUMNS_TYPE_NAME], tmp); break; } } default: set_tuplefield_string(&tuple[COLUMNS_TYPE_NAME], field_type_name); break; } /*---------- * Some Notes about Postgres Data Types: * * VARCHAR - the length is stored in the pg_attribute.atttypmod field * BPCHAR - the length is also stored as varchar is * * NUMERIC - the decimal_digits is stored in atttypmod as follows: * * column_size =((atttypmod - VARHDRSZ) >> 16) & 0xffff * decimal_digits = (atttypmod - VARHDRSZ) & 0xffff * *---------- */ MYLOG(0, "table='%s',field_name='%s',type=%d,name='%s'\n", table_name, field_name, field_type, field_type_name); /* Subtract the header length */ switch (field_type) { case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIME: case PG_TYPE_TIME_WITH_TMZONE: case PG_TYPE_BIT: break; default: if (mod_length >= 4) mod_length -= 4; } set_tuplefield_int4(&tuple[COLUMNS_PRECISION], PGTYPE_ATTR_COLUMN_SIZE(conn, field_type, mod_length)); set_tuplefield_int4(&tuple[COLUMNS_LENGTH], PGTYPE_ATTR_BUFFER_LENGTH(conn, field_type, mod_length)); set_tuplefield_int4(&tuple[COLUMNS_DISPLAY_SIZE], PGTYPE_ATTR_DISPLAY_SIZE(conn, field_type, mod_length)); set_nullfield_int2(&tuple[COLUMNS_SCALE], PGTYPE_ATTR_DECIMAL_DIGITS(conn, field_type, mod_length)); sqltype = PGTYPE_ATTR_TO_CONCISE_TYPE(conn, field_type, mod_length); concise_type = PGTYPE_ATTR_TO_SQLDESCTYPE(conn, field_type, mod_length); set_tuplefield_int2(&tuple[COLUMNS_DATA_TYPE], sqltype); set_nullfield_int2(&tuple[COLUMNS_RADIX], pgtype_radix(conn, field_type)); set_tuplefield_int2(&tuple[COLUMNS_NULLABLE], (Int2) (not_null[0] != '0' ? SQL_NO_NULLS : pgtype_nullable(conn, field_type))); set_tuplefield_string(&tuple[COLUMNS_REMARKS], NULL_STRING); if (attdef && strlen(attdef) > INFO_VARCHAR_SIZE) set_tuplefield_string(&tuple[COLUMNS_COLUMN_DEF], "TRUNCATE"); else set_tuplefield_string(&tuple[COLUMNS_COLUMN_DEF], attdef); set_tuplefield_int2(&tuple[COLUMNS_SQL_DATA_TYPE], concise_type); set_nullfield_int2(&tuple[COLUMNS_SQL_DATETIME_SUB], pgtype_attr_to_datetime_sub(conn, field_type, mod_length)); set_tuplefield_int4(&tuple[COLUMNS_CHAR_OCTET_LENGTH], PGTYPE_ATTR_TRANSFER_OCTET_LENGTH(conn, field_type, mod_length)); set_tuplefield_int4(&tuple[COLUMNS_ORDINAL_POSITION], ordinal); set_tuplefield_null(&tuple[COLUMNS_IS_NULLABLE]); set_tuplefield_int4(&tuple[COLUMNS_FIELD_TYPE], field_type); set_tuplefield_int4(&tuple[COLUMNS_AUTO_INCREMENT], auto_unique); set_tuplefield_int2(&tuple[COLUMNS_PHYSICAL_NUMBER], field_number); set_tuplefield_int4(&tuple[COLUMNS_TABLE_OID], greloid); set_tuplefield_int4(&tuple[COLUMNS_BASE_TYPEID], basetype); set_tuplefield_int4(&tuple[COLUMNS_ATTTYPMOD], mod_length); set_tuplefield_int4(&tuple[COLUMNS_TABLE_INFO], table_info); ordinal++; result = PGAPI_Fetch(col_stmt); if (attdef) free(attdef); } if (result != SQL_NO_DATA_FOUND) { SC_full_error_copy(stmt, col_stmt, FALSE); goto cleanup; } /* * Put the row version column at the end so it might not be mistaken * for a key field. */ if (!relisaview && row_versioning && (NULL == escColumnName || 0 == strcmp(escColumnName, XMIN_NAME))) { /* For Row Versioning fields */ tuple = QR_AddNew(res); add_tuple_for_oid_or_xmin(tuple, ordinal, XMIN_NAME, PG_TYPE_XID, "xid", conn, table_owner, table_name, greloid, XMIN_ATTNUM, FALSE, table_info); ordinal++; } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; stmt->catalog_result = TRUE; if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, col_stmt, TRUE); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); if (!PQExpBufferDataBroken(columns_query)) termPQExpBuffer(&columns_query); if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); if (escColumnName) free(escColumnName); if (col_stmt) PGAPI_FreeStmt(col_stmt, SQL_DROP); MYLOG(0, "leaving stmt=%p\n", stmt); return ret; } RETCODE SQL_API PGAPI_SpecialColumns(HSTMT hstmt, SQLUSMALLINT fColType, const SQLCHAR * szTableQualifier, SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* OA E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* OA(R) E*/ SQLSMALLINT cbTableName, SQLUSMALLINT fScope, SQLUSMALLINT fNullable) { CSTR func = "PGAPI_SpecialColumns"; TupleField *tuple; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; QResultClass *res; StatementClass *col_stmt = NULL; PQExpBufferData columns_query = {0}; char *escSchemaName = NULL, *escTableName = NULL; RETCODE ret = SQL_ERROR, result; char relhasrules[MAX_INFO_STRING], relkind[8], relhasoids[8]; BOOL relisaview; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const SQLCHAR *szSchemaName; const char *eq_string; int result_cols; static const char *catcn[][2] = { {"SCOPE", "SCOPE"}, {"COLUMN_NAME", "COLUMN_NAME"}, {"DATA_TYPE", "DATA_TYPE"}, {"TYPE_NAME", "TYPE_NAME"}, {"COLUMN_SIZE", "PRECISION"}, {"BUFFER_LENGTH", "LENGTH"}, {"DECIMAL_DIGITS", "SCALE"}, {"PSEUDO_COLUMN", "PSEUDO_COLUMN"}}; EnvironmentClass *env; BOOL is_ODBC2; MYLOG(0, "entering...stmt=%p scnm=%p len=%d colType=%d scope=%d\n", stmt, szTableOwner, cbTableOwner, fColType, fScope); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; conn = SC_get_conn(stmt); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); if (!escTableName) { SC_set_error(stmt, STMT_INVALID_NULL_ARG, "The table name is required", func); return SQL_ERROR; } #define return DONT_CALL_RETURN_FROM_HERE??? retry_public_schema: if (escSchemaName) free(escSchemaName); escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, conn); eq_string = gen_opestr(eqop, conn); initPQExpBuffer(&columns_query); #define return DONT_CALL_RETURN_FROM_HERE??? /* * Create the query to find out if this is a view or not... */ appendPQExpBufferStr(&columns_query, "select c.relhasrules, c.relkind"); if (PG_VERSION_LT(conn, 12.0)) appendPQExpBufferStr(&columns_query, ", c.relhasoids"); else appendPQExpBufferStr(&columns_query, ", 0 as relhasoids"); appendPQExpBufferStr(&columns_query, " from pg_catalog.pg_namespace u," " pg_catalog.pg_class c where " "u.oid = c.relnamespace"); /* TableName cannot contain a string search pattern */ if (escTableName) appendPQExpBuffer(&columns_query, " and c.relname %s'%s'", eq_string, escTableName); /* SchemaName cannot contain a string search pattern */ schema_appendPQExpBuffer1(&columns_query, " and u.nspname %s'%.*s'", eq_string, escSchemaName, TABLE_IS_VALID(szTableName, cbTableName), conn); result = PGAPI_AllocStmt(conn, (HSTMT *) &col_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for SQLSpecialColumns result.", func); goto cleanup; } MYLOG(0, "col_stmt = %p\n", col_stmt); if (PQExpBufferDataBroken(columns_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_SpecialColumns()", func); goto cleanup; } result = PGAPI_ExecDirect(col_stmt, (SQLCHAR *) columns_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, col_stmt, FALSE); goto cleanup; } /* If not found */ if ((res = SC_get_Result(col_stmt)) && 0 == QR_get_num_total_tuples(res)) { if (allow_public_schema(conn, szSchemaName, cbSchemaName)) { PGAPI_FreeStmt(col_stmt, SQL_DROP); col_stmt = NULL; szSchemaName = pubstr; cbSchemaName = SQL_NTS; goto retry_public_schema; } SC_set_error(stmt, DESC_BAD_PARAMETER_NUMBER_ERROR, "The specified table does not exist", func); goto cleanup; } result = PGAPI_BindCol(col_stmt, 1, internal_asis_type, relhasrules, sizeof(relhasrules), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, 2, internal_asis_type, relkind, sizeof(relkind), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } relhasoids[0] = '1'; result = PGAPI_BindCol(col_stmt, 3, internal_asis_type, relhasoids, sizeof(relhasoids), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_Fetch(col_stmt); relisaview = (relkind[0] == 'v'); PGAPI_FreeStmt(col_stmt, SQL_DROP); col_stmt = NULL; res = QR_Constructor(); if (!res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for query.", func); goto cleanup; } SC_set_Result(stmt, res); extend_column_bindings(SC_get_ARDF(stmt), 8); stmt->catalog_result = TRUE; result_cols = NUM_OF_SPECOLS_FIELDS; QR_set_num_fields(res, result_cols); QR_set_field_info_EN(res, 0, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 1, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 2, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 3, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, 4, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, 5, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, 6, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, 7, PG_TYPE_INT2, 2); if (relisaview) { /* there's no oid for views */ if (fColType == SQL_BEST_ROWID) { ret = SQL_SUCCESS; goto cleanup; } else if (fColType == SQL_ROWVER) { Int2 the_type = PG_TYPE_TID; int atttypmod = -1; tuple = QR_AddNew(res); set_tuplefield_null(&tuple[SPECOLS_SCOPE]); set_tuplefield_string(&tuple[SPECOLS_COLUMN_NAME], "ctid"); set_tuplefield_int2(&tuple[SPECOLS_DATA_TYPE], PGTYPE_ATTR_TO_CONCISE_TYPE(conn, the_type, atttypmod)); set_tuplefield_string(&tuple[SPECOLS_TYPE_NAME], pgtype_attr_to_name(conn, the_type, atttypmod, FALSE)); set_tuplefield_int4(&tuple[SPECOLS_COLUMN_SIZE], PGTYPE_ATTR_COLUMN_SIZE(conn, the_type, atttypmod)); set_tuplefield_int4(&tuple[SPECOLS_BUFFER_LENGTH], PGTYPE_ATTR_BUFFER_LENGTH(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_DECIMAL_DIGITS], PGTYPE_ATTR_DECIMAL_DIGITS(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_PSEUDO_COLUMN], SQL_PC_NOT_PSEUDO); MYLOG(DETAIL_LOG_LEVEL, "Add ctid\n"); } } else { /* use the oid value for the rowid */ if (fColType == SQL_BEST_ROWID) { Int2 the_type = PG_TYPE_OID; int atttypmod = -1; if (relhasoids[0] != '1') { ret = SQL_SUCCESS; goto cleanup; } tuple = QR_AddNew(res); set_tuplefield_int2(&tuple[SPECOLS_SCOPE], SQL_SCOPE_SESSION); set_tuplefield_string(&tuple[SPECOLS_COLUMN_NAME], OID_NAME); set_tuplefield_int2(&tuple[SPECOLS_DATA_TYPE], PGTYPE_ATTR_TO_CONCISE_TYPE(conn, the_type, atttypmod)); set_tuplefield_string(&tuple[SPECOLS_TYPE_NAME], pgtype_attr_to_name(conn, the_type, atttypmod, TRUE)); set_tuplefield_int4(&tuple[SPECOLS_COLUMN_SIZE], PGTYPE_ATTR_COLUMN_SIZE(conn, the_type, atttypmod)); set_tuplefield_int4(&tuple[SPECOLS_BUFFER_LENGTH], PGTYPE_ATTR_BUFFER_LENGTH(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_DECIMAL_DIGITS], PGTYPE_ATTR_DECIMAL_DIGITS(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_PSEUDO_COLUMN], SQL_PC_PSEUDO); } else if (fColType == SQL_ROWVER) { Int2 the_type = PG_TYPE_XID; int atttypmod = -1; tuple = QR_AddNew(res); set_tuplefield_null(&tuple[SPECOLS_SCOPE]); set_tuplefield_string(&tuple[SPECOLS_COLUMN_NAME], XMIN_NAME); set_tuplefield_int2(&tuple[SPECOLS_DATA_TYPE], PGTYPE_ATTR_TO_CONCISE_TYPE(conn, the_type, atttypmod)); set_tuplefield_string(&tuple[SPECOLS_TYPE_NAME], pgtype_attr_to_name(conn, the_type, atttypmod, FALSE)); set_tuplefield_int4(&tuple[SPECOLS_COLUMN_SIZE], PGTYPE_ATTR_COLUMN_SIZE(conn, the_type, atttypmod)); set_tuplefield_int4(&tuple[SPECOLS_BUFFER_LENGTH], PGTYPE_ATTR_BUFFER_LENGTH(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_DECIMAL_DIGITS], PGTYPE_ATTR_DECIMAL_DIGITS(conn, the_type, atttypmod)); set_tuplefield_int2(&tuple[SPECOLS_PSEUDO_COLUMN], SQL_PC_PSEUDO); } } ret = SQL_SUCCESS; cleanup: #undef return if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, col_stmt, TRUE); if (!PQExpBufferDataBroken(columns_query)) termPQExpBuffer(&columns_query); if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); stmt->status = STMT_FINISHED; stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); if (col_stmt) PGAPI_FreeStmt(col_stmt, SQL_DROP); MYLOG(0, "leaving stmt=%p\n", stmt); return ret; } #define INDOPTION_DESC 0x0001 /* values are in reverse order */ RETCODE SQL_API PGAPI_Statistics(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* OA X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* OA E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* OA(R) E*/ SQLSMALLINT cbTableName, SQLUSMALLINT fUnique, SQLUSMALLINT fAccuracy) { CSTR func = "PGAPI_Statistics"; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; QResultClass *res; PQExpBufferData index_query = {0}; RETCODE ret = SQL_ERROR, result; char *escSchemaName = NULL, *table_name = NULL, *escTableName = NULL; char index_name[MAX_INFO_STRING]; short fields_vector[INDEX_KEYS_STORAGE_COUNT + 1]; short indopt_vector[INDEX_KEYS_STORAGE_COUNT + 1]; char isunique[10], isclustered[10], ishash[MAX_INFO_STRING]; SQLLEN index_name_len, fields_vector_len; TupleField *tuple; int i; StatementClass *col_stmt = NULL, *indx_stmt = NULL; char column_name[MAX_INFO_STRING], table_schemaname[MAX_INFO_STRING], relhasrules[10]; struct columns_idx { int pnum; char *col_name; } *column_names = NULL; /* char **column_names = NULL; */ SQLLEN column_name_len; int total_columns = 0, alcount; ConnInfo *ci; char buf[256]; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName, field_number; const SQLCHAR *szSchemaName; const char *eq_string; OID ioid; Int4 relhasoids; static const char *catcn[][2] = { {"TABLE_CAT", "TABLE_QUALIFIER"}, {"TABLE_SCHEM", "TABLE_OWNER"}, {"TABLE_NAME", "TABLE_NAME"}, {"NON_UNIQUE" , "NON_UNIQUE"}, {"INDEX_QUALIFIER", "INDEX_QUALIFIER"}, {"INDEX_NAME", "INDEX_NAME"}, {"TYPE", "TYPE"}, {"ORDINAL_POSITION", "SEQ_IN_INDEX"}, {"COLUMN_NAME", "COLUMN_NAME"}, {"ASC_OR_DESC", "COLLATION"}, {"CARDINALITY", "CARDINALITY"}, {"PAGES", "PAGES"}, {"FILTER_CONDITION", "FILTER_CONDITION"}}; EnvironmentClass *env; BOOL is_ODBC2; MYLOG(0, "entering...stmt=%p scnm=%p len=%d\n", stmt, szTableOwner, cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; table_name = make_string(szTableName, cbTableName, NULL, 0); if (!table_name) { SC_set_error(stmt, STMT_INVALID_NULL_ARG, "The table name is required", func); return result; } conn = SC_get_conn(stmt); ci = &(conn->connInfo); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_Statistics result.", func); free(table_name); return SQL_ERROR; } SC_set_Result(stmt, res); /* the binding structure for a statement is not set up until */ /* * a statement is actually executed, so we'll have to do this * ourselves. */ extend_column_bindings(SC_get_ARDF(stmt), 13); stmt->catalog_result = TRUE; /* set the field names */ QR_set_num_fields(res, NUM_OF_STATS_FIELDS); QR_set_field_info_EN(res, STATS_CATALOG_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_SCHEMA_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_TABLE_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_NON_UNIQUE, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, STATS_INDEX_QUALIFIER, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_INDEX_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_TYPE, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, STATS_SEQ_IN_INDEX, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, STATS_COLUMN_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, STATS_COLLATION, PG_TYPE_CHAR, 1); QR_set_field_info_EN(res, STATS_CARDINALITY, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, STATS_PAGES, PG_TYPE_INT4, 4); QR_set_field_info_EN(res, STATS_FILTER_CONDITION, PG_TYPE_VARCHAR, MAX_INFO_STRING); #define return DONT_CALL_RETURN_FROM_HERE??? szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; table_schemaname[0] = '\0'; schema_str(table_schemaname, sizeof(table_schemaname), szSchemaName, cbSchemaName, TABLE_IS_VALID(szTableName, cbTableName), conn); /* * we need to get a list of the field names first, so we can return * them later. */ result = PGAPI_AllocStmt(conn, (HSTMT *) &col_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in PGAPI_Statistics for columns.", func); goto cleanup; } /* * table_name parameter cannot contain a string search pattern. */ result = PGAPI_Columns(col_stmt, NULL, 0, (SQLCHAR *) table_schemaname, SQL_NTS, (SQLCHAR *) table_name, SQL_NTS, NULL, 0, PODBC_NOT_SEARCH_PATTERN | PODBC_SEARCH_PUBLIC_SCHEMA, 0, 0); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, COLUMNS_COLUMN_NAME + 1, internal_asis_type, column_name, sizeof(column_name), &column_name_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(col_stmt, COLUMNS_PHYSICAL_NUMBER + 1, SQL_C_SHORT, &field_number, sizeof(field_number), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } alcount = 0; result = PGAPI_Fetch(col_stmt); while (SQL_SUCCEEDED(result)) { if (0 == total_columns) PGAPI_GetData(col_stmt, 2, internal_asis_type, table_schemaname, sizeof(table_schemaname), NULL); if (total_columns >= alcount) { if (0 == alcount) alcount = 4; else alcount *= 2; SC_REALLOC_gexit_with_error(column_names, struct columns_idx, alcount * sizeof(struct columns_idx), stmt, "Couldn't allocate memory for column names.", (result = SQL_ERROR)); } column_names[total_columns].col_name = strdup(column_name); if (!column_names[total_columns].col_name) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for column name.", func); goto cleanup; } column_names[total_columns].pnum = field_number; total_columns++; MYLOG(0, "column_name = '%s'\n", column_name); result = PGAPI_Fetch(col_stmt); } if (result != SQL_NO_DATA_FOUND) { SC_full_error_copy(stmt, col_stmt, FALSE); goto cleanup; } PGAPI_FreeStmt(col_stmt, SQL_DROP); col_stmt = NULL; if (total_columns == 0) { /* Couldn't get column names in SQLStatistics.; */ ret = SQL_SUCCESS; goto cleanup; } /* get a list of indexes on this table */ result = PGAPI_AllocStmt(conn, (HSTMT *) &indx_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in SQLStatistics for indices.", func); goto cleanup; } /* TableName cannot contain a string search pattern */ escTableName = simpleCatalogEscape((SQLCHAR *) table_name, SQL_NTS, conn); eq_string = gen_opestr(eqop, conn); escSchemaName = simpleCatalogEscape((SQLCHAR *) table_schemaname, SQL_NTS, conn); initPQExpBuffer(&index_query); printfPQExpBuffer(&index_query, "select c.relname, i.indkey, i.indisunique" ", i.indisclustered, a.amname, c.relhasrules, n.nspname" ", c.oid, %s, %s" " from pg_catalog.pg_index i, pg_catalog.pg_class c," " pg_catalog.pg_class d, pg_catalog.pg_am a," " pg_catalog.pg_namespace n" " where d.relname %s'%s'" " and n.nspname %s'%s'" " and n.oid = d.relnamespace" " and d.oid = i.indrelid" " and i.indexrelid = c.oid" " and c.relam = a.oid order by" , PG_VERSION_LT(conn, 12.0) ? "d.relhasoids" : "0" , PG_VERSION_GE(conn, 8.3) ? "i.indoption" : "0" , eq_string, escTableName, eq_string, escSchemaName); appendPQExpBufferStr(&index_query, " i.indisprimary desc,"); appendPQExpBufferStr(&index_query, " i.indisunique, n.nspname, c.relname"); if (PQExpBufferDataBroken(index_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_Columns()", func); goto cleanup; } result = PGAPI_ExecDirect(indx_stmt, (SQLCHAR *) index_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { /* * "Couldn't execute index query (w/SQLExecDirect) in * SQLStatistics."; */ SC_full_error_copy(stmt, indx_stmt, FALSE); goto cleanup; } /* bind the index name column */ result = PGAPI_BindCol(indx_stmt, 1, internal_asis_type, index_name, MAX_INFO_STRING, &index_name_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } /* bind the vector column */ result = PGAPI_BindCol(indx_stmt, 2, SQL_C_DEFAULT, fields_vector, sizeof(fields_vector), &fields_vector_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } /* bind the "is unique" column */ result = PGAPI_BindCol(indx_stmt, 3, internal_asis_type, isunique, sizeof(isunique), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } /* bind the "is clustered" column */ result = PGAPI_BindCol(indx_stmt, 4, internal_asis_type, isclustered, sizeof(isclustered), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } /* bind the "is hash" column */ result = PGAPI_BindCol(indx_stmt, 5, internal_asis_type, ishash, sizeof(ishash), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(indx_stmt, 6, internal_asis_type, relhasrules, sizeof(relhasrules), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(indx_stmt, 8, SQL_C_ULONG, &ioid, sizeof(ioid), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(indx_stmt, 9, SQL_C_ULONG, &relhasoids, sizeof(relhasoids), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } /* bind the vector column */ result = PGAPI_BindCol(indx_stmt, 10, SQL_C_DEFAULT, indopt_vector, sizeof(fields_vector), &fields_vector_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } relhasrules[0] = '0'; result = PGAPI_Fetch(indx_stmt); /* fake index of OID */ if (relhasoids && relhasrules[0] != '1' && atoi(ci->show_oid_column) && atoi(ci->fake_oid_index)) { tuple = QR_AddNew(res); /* no table qualifier */ set_tuplefield_string(&tuple[STATS_CATALOG_NAME], CurrCat(conn)); /* don't set the table owner, else Access tries to use it */ set_tuplefield_string(&tuple[STATS_SCHEMA_NAME], GET_SCHEMA_NAME(table_schemaname)); set_tuplefield_string(&tuple[STATS_TABLE_NAME], table_name); /* non-unique index? */ set_tuplefield_int2(&tuple[STATS_NON_UNIQUE], (Int2) (ci->drivers.unique_index ? FALSE : TRUE)); /* no index qualifier */ set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], GET_SCHEMA_NAME(table_schemaname)); SPRINTF_FIXED(buf, "%s_idx_fake_oid", table_name); set_tuplefield_string(&tuple[STATS_INDEX_NAME], buf); /* * Clustered/HASH index? */ set_tuplefield_int2(&tuple[STATS_TYPE], (Int2) SQL_INDEX_OTHER); set_tuplefield_int2(&tuple[STATS_SEQ_IN_INDEX], (Int2) 1); set_tuplefield_string(&tuple[STATS_COLUMN_NAME], OID_NAME); set_tuplefield_string(&tuple[STATS_COLLATION], "A"); set_tuplefield_null(&tuple[STATS_CARDINALITY]); set_tuplefield_null(&tuple[STATS_PAGES]); set_tuplefield_null(&tuple[STATS_FILTER_CONDITION]); } while (SQL_SUCCEEDED(result)) { /* If only requesting unique indexes, then just return those. */ if (fUnique == SQL_INDEX_ALL || (fUnique == SQL_INDEX_UNIQUE && atoi(isunique))) { int colcnt, attnum; /* add a row in this table for each field in the index */ colcnt = fields_vector[0]; for (i = 1; i <= colcnt; i++) { tuple = QR_AddNew(res); /* no table qualifier */ set_tuplefield_string(&tuple[STATS_CATALOG_NAME], CurrCat(conn)); /* don't set the table owner, else Access tries to use it */ set_tuplefield_string(&tuple[STATS_SCHEMA_NAME], GET_SCHEMA_NAME(table_schemaname)); set_tuplefield_string(&tuple[STATS_TABLE_NAME], table_name); /* non-unique index? */ if (ci->drivers.unique_index) set_tuplefield_int2(&tuple[STATS_NON_UNIQUE], (Int2) (atoi(isunique) ? FALSE : TRUE)); else set_tuplefield_int2(&tuple[STATS_NON_UNIQUE], TRUE); /* no index qualifier */ set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], GET_SCHEMA_NAME(table_schemaname)); set_tuplefield_string(&tuple[STATS_INDEX_NAME], index_name); /* * Clustered/HASH index? */ set_tuplefield_int2(&tuple[STATS_TYPE], (Int2) (atoi(isclustered) ? SQL_INDEX_CLUSTERED : (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); set_tuplefield_int2(&tuple[STATS_SEQ_IN_INDEX], (Int2) i); attnum = fields_vector[i]; if (OID_ATTNUM == attnum) { set_tuplefield_string(&tuple[STATS_COLUMN_NAME], OID_NAME); MYLOG(0, "column name = oid\n"); } else if (0 == attnum) { char cmd[64]; QResultClass *res; SPRINTF_FIXED(cmd, "select pg_get_indexdef(%u, %d, true)", ioid, i); res = CC_send_query(conn, cmd, NULL, READ_ONLY_QUERY, stmt); if (QR_command_maybe_successful(res)) set_tuplefield_string(&tuple[STATS_COLUMN_NAME], QR_get_value_backend_text(res, 0, 0)); QR_Destructor(res); } else { int j, matchidx; BOOL unknownf = TRUE; if (attnum > 0) { for (j = 0; j < total_columns; j++) { if (attnum == column_names[j].pnum) { matchidx = j; unknownf = FALSE; break; } } } if (unknownf) { set_tuplefield_string(&tuple[STATS_COLUMN_NAME], "UNKNOWN"); MYLOG(0, "column name = UNKNOWN\n"); } else { set_tuplefield_string(&tuple[STATS_COLUMN_NAME], column_names[matchidx].col_name); MYLOG(0, "column name = '%s'\n", column_names[matchidx].col_name); } } if (i <= indopt_vector[0] && (indopt_vector[i] & INDOPTION_DESC) != 0) set_tuplefield_string(&tuple[STATS_COLLATION], "D"); else set_tuplefield_string(&tuple[STATS_COLLATION], "A"); set_tuplefield_null(&tuple[STATS_CARDINALITY]); set_tuplefield_null(&tuple[STATS_PAGES]); set_tuplefield_null(&tuple[STATS_FILTER_CONDITION]); } } result = PGAPI_Fetch(indx_stmt); } if (result != SQL_NO_DATA_FOUND) { /* "SQLFetch failed in SQLStatistics."; */ SC_full_error_copy(stmt, indx_stmt, FALSE); goto cleanup; } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) { SC_error_copy(stmt, col_stmt, TRUE); if (0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, indx_stmt, TRUE); } if (col_stmt) PGAPI_FreeStmt(col_stmt, SQL_DROP); if (indx_stmt) PGAPI_FreeStmt(indx_stmt, SQL_DROP); /* These things should be freed on any error ALSO! */ if (!PQExpBufferDataBroken(index_query)) termPQExpBuffer(&index_query); if (table_name) free(table_name); if (escTableName) free(escTableName); if (escSchemaName) free(escSchemaName); if (column_names) { for (i = 0; i < total_columns; i++) free(column_names[i].col_name); free(column_names); } /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); MYLOG(0, "leaving stmt=%p, ret=%d\n", stmt, ret); return ret; } RETCODE SQL_API PGAPI_ColumnPrivileges(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* OA X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* OA E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* OA(R) E*/ SQLSMALLINT cbTableName, const SQLCHAR * szColumnName, /* PV E*/ SQLSMALLINT cbColumnName, UWORD flag) { CSTR func = "PGAPI_ColumnPrivileges"; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn = SC_get_conn(stmt); RETCODE ret = SQL_ERROR; char *escSchemaName = NULL, *escTableName = NULL, *escColumnName = NULL; const char *like_or_eq, *op_string, *eq_string; PQExpBufferData column_query = {0}; BOOL search_pattern; QResultClass *res = NULL; MYLOG(0, "entering...\n"); /* Neither Access or Borland care about this. */ if (SC_initialize_and_recycle(stmt) != SQL_SUCCESS) return SQL_ERROR; escSchemaName = simpleCatalogEscape(szTableOwner, cbTableOwner, conn); escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); search_pattern = (0 == (flag & PODBC_NOT_SEARCH_PATTERN)); if (search_pattern) { like_or_eq = likeop; escColumnName = adjustLikePattern(szColumnName, cbColumnName, conn); } else { like_or_eq = eqop; escColumnName = simpleCatalogEscape(szColumnName, cbColumnName, conn); } initPQExpBuffer(&column_query); #define return DONT_CALL_RETURN_FROM_HERE??? appendPQExpBufferStr(&column_query, "select table_catalog as TABLE_CAT, table_schema as TABLE_SCHEM," " table_name, column_name, grantor, grantee," " privilege_type as PRIVILEGE, is_grantable from" " information_schema.column_privileges where true"); /* cq_len = strlen(column_query); cq_size = sizeof(column_query); col_query = column_query; */ op_string = gen_opestr(like_or_eq, conn); eq_string = gen_opestr(eqop, conn); if (escSchemaName) appendPQExpBuffer(&column_query, " and table_schema %s'%s'", eq_string, escSchemaName); if (escTableName) appendPQExpBuffer(&column_query, " and table_name %s'%s'", eq_string, escTableName); if (escColumnName) appendPQExpBuffer(&column_query, " and column_name %s'%s'", op_string, escColumnName); if (PQExpBufferDataBroken(column_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_ColumnPriviles()", func); goto cleanup; } if (res = CC_send_query(conn, column_query.data, NULL, READ_ONLY_QUERY, stmt), !QR_command_maybe_successful(res)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_ColumnPrivileges query error", func); goto cleanup; } SC_set_Result(stmt, res); /* * also, things need to think that this statement is finished so the * results can be retrieved. */ extend_column_bindings(SC_get_ARDF(stmt), 8); /* set up the current tuple pointer for SQLFetch */ ret = SQL_SUCCESS; cleanup: #undef return if (!SQL_SUCCEEDED(ret)) QR_Destructor(res); /* set up the current tuple pointer for SQLFetch */ stmt->status = STMT_FINISHED; stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); if (!PQExpBufferDataBroken(column_query)) termPQExpBuffer(&column_query); if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); if (escColumnName) free(escColumnName); return ret; } /* * SQLPrimaryKeys() * * Retrieve the primary key columns for the specified table. */ RETCODE SQL_API PGAPI_PrimaryKeys(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* OA X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* OA E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* OA(R) E*/ SQLSMALLINT cbTableName, OID reloid) { CSTR func = "PGAPI_PrimaryKeys"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; ConnectionClass *conn; TupleField *tuple; RETCODE ret = SQL_ERROR, result; int seq = 0; StatementClass *tbl_stmt = NULL; PQExpBufferData tables_query = {0}; char attname[MAX_INFO_STRING]; SQLLEN attname_len; char *pktab = NULL, *pktbname; char pkscm[SCHEMA_NAME_STORAGE_LEN + 1]; SQLLEN pkscm_len; char tabname[TABLE_NAME_STORAGE_LEN + 1]; SQLLEN tabname_len; char pkname[TABLE_NAME_STORAGE_LEN + 1]; Int2 result_cols; int qno, qstart, qend; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const SQLCHAR *szSchemaName; const char *eq_string; char *escSchemaName = NULL, *escTableName = NULL; static const char *catcn[][2] = { {"TABLE_CAT", "TABLE_QUALIFIER"}, {"TABLE_SCHEM", "TABLE_OWNER"}, {"TABLE_NAME", "TABLE_NAME"}, {"COLUMN_NAME", "COLUMN_NAME"}, {"KEY_SEQ", "KEY_SEQ"}, {"PK_NAME", "PK_NAME"}}; EnvironmentClass *env; BOOL is_ODBC2; MYLOG(0, "entering...stmt=%p scnm=%p len=%d\n", stmt, szTableOwner, cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_PrimaryKeys result.", func); return SQL_ERROR; } SC_set_Result(stmt, res); /* the binding structure for a statement is not set up until * * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_PKS_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; conn = SC_get_conn(stmt); env = CC_get_env(conn); is_ODBC2 = EN_is_odbc2(env); /* set the field names */ QR_set_num_fields(res, result_cols); QR_set_field_info_EN(res, PKS_TABLE_CAT, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, PKS_TABLE_SCHEM, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, PKS_TABLE_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, PKS_COLUMN_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_EN(res, PKS_KEY_SQ, PG_TYPE_INT2, 2); QR_set_field_info_EN(res, PKS_PK_NAME, PG_TYPE_VARCHAR, MAX_INFO_STRING); result = PGAPI_AllocStmt(conn, (HSTMT *) &tbl_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for Primary Key result.", func); goto cleanup; } #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ #define return DONT_CALL_RETURN_FROM_HERE??? if (0 != reloid) { szSchemaName = NULL; cbSchemaName = SQL_NULL_DATA; } else { pktab = make_string(szTableName, cbTableName, NULL, 0); if (!pktab || pktab[0] == '\0') { SC_set_error(stmt, STMT_INTERNAL_ERROR, "No Table specified to PGAPI_PrimaryKeys.", func); goto cleanup; } szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); } eq_string = gen_opestr(eqop, conn); retry_public_schema: pkscm[0] = '\0'; if (0 == reloid) { if (escSchemaName) free(escSchemaName); escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, conn); schema_str(pkscm, sizeof(pkscm), (SQLCHAR *) escSchemaName, SQL_NTS, TABLE_IS_VALID(szTableName, cbTableName), conn); } result = PGAPI_BindCol(tbl_stmt, 1, internal_asis_type, attname, MAX_INFO_STRING, &attname_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 3, internal_asis_type, pkname, TABLE_NAME_STORAGE_LEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 4, internal_asis_type, pkscm, SCHEMA_NAME_STORAGE_LEN, &pkscm_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 5, internal_asis_type, tabname, TABLE_NAME_STORAGE_LEN, &tabname_len); if (!SQL_SUCCEEDED(result)) { goto cleanup; } initPQExpBuffer(&tables_query); qstart = 1; if (0 == reloid) qend = 2; else qend = 1; for (qno = qstart; qno <= qend; qno++) { resetPQExpBuffer(&tables_query); switch (qno) { case 1: /* * Simplified query to remove assumptions about number of * possible index columns. Courtesy of Tom Lane - thomas * 2000-03-21 */ appendPQExpBufferStr(&tables_query, "select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname" " from pg_catalog.pg_attribute ta," " pg_catalog.pg_attribute ia, pg_catalog.pg_class tc," " pg_catalog.pg_index i, pg_catalog.pg_namespace n" ", pg_catalog.pg_class ic"); if (0 == reloid) appendPQExpBuffer(&tables_query, " where tc.relname %s'%s'" " AND n.nspname %s'%s'" , eq_string, escTableName, eq_string, pkscm); else appendPQExpBuffer(&tables_query, " where tc.oid = %u", reloid); appendPQExpBufferStr(&tables_query, " AND tc.oid = i.indrelid" " AND n.oid = tc.relnamespace" " AND i.indisprimary = 't'" " AND ia.attrelid = i.indexrelid" " AND ta.attrelid = i.indrelid" " AND ta.attnum = i.indkey[ia.attnum-1]" " AND (NOT ta.attisdropped)" " AND (NOT ia.attisdropped)" " AND ic.oid = i.indexrelid" " order by ia.attnum"); break; case 2: /* * Simplified query to search old fashioned primary key */ appendPQExpBuffer(&tables_query, "select ta.attname, ia.attnum, ic.relname, n.nspname, NULL" " from pg_catalog.pg_attribute ta," " pg_catalog.pg_attribute ia, pg_catalog.pg_class ic," " pg_catalog.pg_index i, pg_catalog.pg_namespace n" " where ic.relname %s'%s_pkey'" " AND n.nspname %s'%s'" " AND ic.oid = i.indexrelid" " AND n.oid = ic.relnamespace" " AND ia.attrelid = i.indexrelid" " AND ta.attrelid = i.indrelid" " AND ta.attnum = i.indkey[ia.attnum-1]" " AND (NOT ta.attisdropped)" " AND (NOT ia.attisdropped)" " order by ia.attnum", eq_string, escTableName, eq_string, pkscm); break; } if (PQExpBufferDataBroken(tables_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_PrimaryKeys()", func); goto cleanup; } MYLOG(0, "tables_query='%s'\n", tables_query.data); result = PGAPI_ExecDirect(tbl_stmt, (SQLCHAR *) tables_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } result = PGAPI_Fetch(tbl_stmt); if (result != SQL_NO_DATA_FOUND) break; } /* If not found */ if (SQL_NO_DATA_FOUND == result) { if (0 == reloid && allow_public_schema(conn, szSchemaName, cbSchemaName)) { szSchemaName = pubstr; cbSchemaName = SQL_NTS; goto retry_public_schema; } } while (SQL_SUCCEEDED(result)) { tuple = QR_AddNew(res); set_tuplefield_string(&tuple[PKS_TABLE_CAT], CurrCat(conn)); /* * I have to hide the table owner from Access, otherwise it * insists on referring to the table as 'owner.table'. (this is * valid according to the ODBC SQL grammar, but Postgres won't * support it.) */ if (SQL_NULL_DATA == pkscm_len) pkscm[0] = '\0'; set_tuplefield_string(&tuple[PKS_TABLE_SCHEM], GET_SCHEMA_NAME(pkscm)); if (SQL_NULL_DATA == tabname_len) tabname[0] = '\0'; pktbname = pktab ? pktab : tabname; set_tuplefield_string(&tuple[PKS_TABLE_NAME], pktbname); set_tuplefield_string(&tuple[PKS_COLUMN_NAME], attname); set_tuplefield_int2(&tuple[PKS_KEY_SQ], (Int2) (++seq)); set_tuplefield_string(&tuple[PKS_PK_NAME], pkname); MYLOG(0, ">> primaryKeys: schema ='%s', pktab = '%s', attname = '%s', seq = %d\n", pkscm, pktbname, attname, seq); result = PGAPI_Fetch(tbl_stmt); } if (result != SQL_NO_DATA_FOUND) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, tbl_stmt, TRUE); if (tbl_stmt) PGAPI_FreeStmt(tbl_stmt, SQL_DROP); if (!PQExpBufferDataBroken(tables_query)) termPQExpBuffer(&tables_query); if (pktab) free(pktab); if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); MYLOG(0, "leaving stmt=%p, ret=%d\n", stmt, ret); return ret; } /* * Multibyte support stuff for SQLForeignKeys(). * There may be much more effective way in the * future version. The way is very forcible currently. */ static BOOL isMultibyte(const char *str) { for (; *str; str++) { if ((unsigned char) *str >= 0x80) return TRUE; } return FALSE; } static char * getClientColumnName(ConnectionClass *conn, UInt4 relid, char *serverColumnName, BOOL *nameAlloced) { char query[1024], saveattnum[16], *ret = serverColumnName; const char *eq_string; BOOL continueExec = TRUE, bError = FALSE; QResultClass *res = NULL; UWORD flag = READ_ONLY_QUERY; *nameAlloced = FALSE; if (!conn->original_client_encoding || !isMultibyte(serverColumnName)) return ret; if (!conn->server_encoding) { if (res = CC_send_query(conn, "select getdatabaseencoding()", NULL, flag, NULL), QR_command_maybe_successful(res)) { if (QR_get_num_cached_tuples(res) > 0) conn->server_encoding = strdup(QR_get_value_backend_text(res, 0, 0)); } QR_Destructor(res); res = NULL; } if (!conn->server_encoding) return ret; SPRINTF_FIXED(query, "SET CLIENT_ENCODING TO '%s'", conn->server_encoding); bError = (!QR_command_maybe_successful((res = CC_send_query(conn, query, NULL, flag, NULL)))); QR_Destructor(res); eq_string = gen_opestr(eqop, conn); if (!bError && continueExec) { SPRINTF_FIXED(query, "select attnum from pg_attribute " "where attrelid = %u and attname %s'%s'", relid, eq_string, serverColumnName); if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res)) { if (QR_get_num_cached_tuples(res) > 0) { STRCPY_FIXED(saveattnum, QR_get_value_backend_text(res, 0, 0)); } else continueExec = FALSE; } else bError = TRUE; QR_Destructor(res); } continueExec = (continueExec && !bError); /* restore the client encoding */ SPRINTF_FIXED(query, "SET CLIENT_ENCODING TO '%s'", conn->original_client_encoding); bError = (!QR_command_maybe_successful((res = CC_send_query(conn, query, NULL, flag, NULL)))); QR_Destructor(res); if (bError || !continueExec) return ret; SPRINTF_FIXED(query, "select attname from pg_attribute where attrelid = %u and attnum = %s", relid, saveattnum); if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res)) { if (QR_get_num_cached_tuples(res) > 0) { char *tmp; tmp = strdup(QR_get_value_backend_text(res, 0, 0)); if (tmp) { ret = tmp; *nameAlloced = TRUE; } } } QR_Destructor(res); return ret; } static RETCODE SQL_API PGAPI_ForeignKeys_new(HSTMT hstmt, const SQLCHAR * szPkTableQualifier, /* OA X*/ SQLSMALLINT cbPkTableQualifier, const SQLCHAR * szPkTableOwner, /* OA E*/ SQLSMALLINT cbPkTableOwner, const SQLCHAR * szPkTableName, /* OA(R) E*/ SQLSMALLINT cbPkTableName, const SQLCHAR * szFkTableQualifier, /* OA X*/ SQLSMALLINT cbFkTableQualifier, const SQLCHAR * szFkTableOwner, /* OA E*/ SQLSMALLINT cbFkTableOwner, const SQLCHAR * szFkTableName, /* OA(R) E*/ SQLSMALLINT cbFkTableName); static RETCODE SQL_API PGAPI_ForeignKeys_old(HSTMT hstmt, const SQLCHAR * szPkTableQualifier, /* OA X*/ SQLSMALLINT cbPkTableQualifier, const SQLCHAR * szPkTableOwner, /* OA E*/ SQLSMALLINT cbPkTableOwner, const SQLCHAR * szPkTableName, /* OA(R) E*/ SQLSMALLINT cbPkTableName, const SQLCHAR * szFkTableQualifier, /* OA X*/ SQLSMALLINT cbFkTableQualifier, const SQLCHAR * szFkTableOwner, /* OA E*/ SQLSMALLINT cbFkTableOwner, const SQLCHAR * szFkTableName, /* OA(R) E*/ SQLSMALLINT cbFkTableName) { CSTR func = "PGAPI_ForeignKeys"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; TupleField *tuple; HSTMT hpkey_stmt = NULL; StatementClass *tbl_stmt = NULL; RETCODE ret = SQL_ERROR, result, keyresult; PQExpBufferData tables_query = {0}; char trig_deferrable[2]; char trig_initdeferred[2]; char trig_args[1024]; char upd_rule[TABLE_NAME_STORAGE_LEN], del_rule[TABLE_NAME_STORAGE_LEN]; char *pk_table_needed = NULL, *escPkTableName = NULL; char fk_table_fetched[TABLE_NAME_STORAGE_LEN + 1]; char *fk_table_needed = NULL, *escFkTableName = NULL; char pk_table_fetched[TABLE_NAME_STORAGE_LEN + 1]; char schema_needed[SCHEMA_NAME_STORAGE_LEN + 1]; char schema_fetched[SCHEMA_NAME_STORAGE_LEN + 1]; char constrname[NAMESTORAGELEN + 1], pkname[TABLE_NAME_STORAGE_LEN + 1]; char *pkey_ptr, *pkey_text = NULL, *fkey_ptr, *fkey_text = NULL; ConnectionClass *conn; BOOL pkey_alloced, fkey_alloced, got_pkname; int i, j, k, num_keys; SQLSMALLINT trig_nargs, upd_rule_type = 0, del_rule_type = 0; SQLSMALLINT internal_asis_type = SQL_C_CHAR; SQLSMALLINT defer_type; char pkey[MAX_INFO_STRING]; Int2 result_cols; UInt4 relid1, relid2; const char *eq_string; MYLOG(0, "entering...stmt=%p\n", stmt); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_ForeignKeys result.", func); return SQL_ERROR; } SC_set_Result(stmt, res); /* the binding structure for a statement is not set up until */ /* * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_FKS_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; /* set the field names */ QR_set_num_fields(res, result_cols); QR_set_field_info_v(res, FKS_PKTABLE_CAT, "PKTABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_PKTABLE_SCHEM, "PKTABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_PKTABLE_NAME, "PKTABLE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_PKCOLUMN_NAME, "PKCOLUMN_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_FKTABLE_CAT, "FKTABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_FKTABLE_SCHEM, "FKTABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_FKTABLE_NAME, "FKTABLE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_FKCOLUMN_NAME, "FKCOLUMN_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_KEY_SEQ, "KEY_SEQ", PG_TYPE_INT2, 2); QR_set_field_info_v(res, FKS_UPDATE_RULE, "UPDATE_RULE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, FKS_DELETE_RULE, "DELETE_RULE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, FKS_FK_NAME, "FK_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_PK_NAME, "PK_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, FKS_DEFERRABILITY, "DEFERRABILITY", PG_TYPE_INT2, 2); QR_set_field_info_v(res, FKS_TRIGGER_NAME, "TRIGGER_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); conn = SC_get_conn(stmt); result = PGAPI_AllocStmt(conn, (HSTMT *) &tbl_stmt, 0); if (!SQL_SUCCEEDED(result)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys result.", func); return SQL_ERROR; } #define return DONT_CALL_RETURN_FROM_HERE??? schema_needed[0] = '\0'; schema_fetched[0] = '\0'; pk_table_needed = make_string(szPkTableName, cbPkTableName, NULL, 0); fk_table_needed = make_string(szFkTableName, cbFkTableName, NULL, 0); #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ pkey_alloced = fkey_alloced = FALSE; eq_string = gen_opestr(eqop, conn); initPQExpBuffer(&tables_query); /* * Case #2 -- Get the foreign keys in the specified table (fktab) that * refer to the primary keys of other table(s). */ if (fk_table_needed && fk_table_needed[0] != '\0') { char *escSchemaName; MYLOG(0, " Foreign Key Case #2\n"); escFkTableName = simpleCatalogEscape((SQLCHAR *) fk_table_needed, SQL_NTS, conn); schema_str(schema_needed, sizeof(schema_needed), szFkTableOwner, cbFkTableOwner, TABLE_IS_VALID(szFkTableName, cbFkTableName), conn); escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn); printfPQExpBuffer(&tables_query, "SELECT pt.tgargs, " " pt.tgnargs, " " pt.tgdeferrable, " " pt.tginitdeferred, " " pp1.proname, " " pp2.proname, " " pc.oid, " " pc1.oid, " " pc1.relname, " " pt.tgconstrname, pn.nspname " "FROM pg_catalog.pg_class pc, " " pg_catalog.pg_proc pp1, " " pg_catalog.pg_proc pp2, " " pg_catalog.pg_trigger pt1, " " pg_catalog.pg_trigger pt2, " " pg_catalog.pg_proc pp, " " pg_catalog.pg_trigger pt, " " pg_catalog.pg_class pc1, " " pg_catalog.pg_namespace pn, " " pg_catalog.pg_namespace pn1 " "WHERE pt.tgrelid = pc.oid " "AND pp.oid = pt.tgfoid " "AND pt1.tgconstrrelid = pc.oid " "AND pp1.oid = pt1.tgfoid " "AND pt2.tgfoid = pp2.oid " "AND pt2.tgconstrrelid = pc.oid " "AND ((pc.relname %s'%s') " "AND (pn1.oid = pc.relnamespace) " "AND (pn1.nspname %s'%s') " "AND (pp.proname LIKE '%%ins') " "AND (pp1.proname LIKE '%%upd') " "AND (pp1.proname not LIKE '%%check%%') " "AND (pp2.proname LIKE '%%del') " "AND (pt1.tgrelid=pt.tgconstrrelid) " "AND (pt1.tgconstrname=pt.tgconstrname) " "AND (pt2.tgrelid=pt.tgconstrrelid) " "AND (pt2.tgconstrname=pt.tgconstrname) " "AND (pt.tgconstrrelid=pc1.oid) " "AND (pc1.relnamespace=pn.oid))" " order by pt.tgconstrname", eq_string, escFkTableName, eq_string, escSchemaName); free(escSchemaName); if (PQExpBufferDataBroken(tables_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_ForeignKeys()", func); goto cleanup; } result = PGAPI_ExecDirect(tbl_stmt, (SQLCHAR *) tables_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 1, SQL_C_BINARY, trig_args, sizeof(trig_args), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 2, SQL_C_SHORT, &trig_nargs, 0, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 3, internal_asis_type, trig_deferrable, sizeof(trig_deferrable), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 4, internal_asis_type, trig_initdeferred, sizeof(trig_initdeferred), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 5, internal_asis_type, upd_rule, sizeof(upd_rule), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 6, internal_asis_type, del_rule, sizeof(del_rule), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 7, SQL_C_ULONG, &relid1, sizeof(relid1), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 8, SQL_C_ULONG, &relid2, sizeof(relid2), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 9, internal_asis_type, pk_table_fetched, TABLE_NAME_STORAGE_LEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 10, internal_asis_type, constrname, NAMESTORAGELEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 11, internal_asis_type, schema_fetched, SCHEMA_NAME_STORAGE_LEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_Fetch(tbl_stmt); if (result == SQL_NO_DATA_FOUND) { ret = SQL_SUCCESS; goto cleanup; } if (result != SQL_SUCCESS) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt, 0); if (!SQL_SUCCEEDED(keyresult)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys (pkeys) result.", func); goto cleanup; } keyresult = PGAPI_BindCol(hpkey_stmt, 4, internal_asis_type, pkey, sizeof(pkey), NULL); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't bindcol for primary keys for PGAPI_ForeignKeys result.", func); goto cleanup; } while (result == SQL_SUCCESS) { /* Compute the number of keyparts. */ num_keys = (trig_nargs - 4) / 2; MYLOG(0, "Foreign Key Case#2: trig_nargs = %d, num_keys = %d\n", trig_nargs, num_keys); /* If there is a pk table specified, then check it. */ if (pk_table_needed && pk_table_needed[0] != '\0') { /* If it doesn't match, then continue */ if (strcmp(pk_table_fetched, pk_table_needed)) { result = PGAPI_Fetch(tbl_stmt); continue; } } got_pkname = FALSE; keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, (SQLCHAR *) schema_fetched, SQL_NTS, (SQLCHAR *) pk_table_fetched, SQL_NTS, 0); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't get primary keys for PGAPI_ForeignKeys result.", func); goto cleanup; } /* Get to first primary key */ pkey_ptr = trig_args; for (i = 0; i < 5; i++) pkey_ptr += strlen(pkey_ptr) + 1; for (k = 0; k < num_keys; k++) { /* Check that the key listed is the primary key */ keyresult = PGAPI_Fetch(hpkey_stmt); if (keyresult != SQL_SUCCESS) { num_keys = 0; break; } if (!got_pkname) { PGAPI_GetData(hpkey_stmt, 6, internal_asis_type, pkname, sizeof(pkname), NULL); got_pkname = TRUE; } pkey_text = getClientColumnName(conn, relid2, pkey_ptr, &pkey_alloced); MYLOG(0, "pkey_ptr='%s', pkey='%s'\n", pkey_text, pkey); if (strcmp(pkey_text, pkey)) { num_keys = 0; break; } if (pkey_alloced) free(pkey_text); pkey_alloced = FALSE; /* Get to next primary key */ for (k = 0; k < 2; k++) pkey_ptr += strlen(pkey_ptr) + 1; } PGAPI_FreeStmt(hpkey_stmt, SQL_CLOSE); /* Set to first fk column */ fkey_ptr = trig_args; for (k = 0; k < 4; k++) fkey_ptr += strlen(fkey_ptr) + 1; /* Set update and delete actions for foreign keys */ if (!strcmp(upd_rule, "RI_FKey_cascade_upd")) upd_rule_type = SQL_CASCADE; else if (!strcmp(upd_rule, "RI_FKey_noaction_upd")) upd_rule_type = SQL_NO_ACTION; else if (!strcmp(upd_rule, "RI_FKey_restrict_upd")) upd_rule_type = SQL_NO_ACTION; else if (!strcmp(upd_rule, "RI_FKey_setdefault_upd")) upd_rule_type = SQL_SET_DEFAULT; else if (!strcmp(upd_rule, "RI_FKey_setnull_upd")) upd_rule_type = SQL_SET_NULL; if (!strcmp(del_rule, "RI_FKey_cascade_del")) del_rule_type = SQL_CASCADE; else if (!strcmp(del_rule, "RI_FKey_noaction_del")) del_rule_type = SQL_NO_ACTION; else if (!strcmp(del_rule, "RI_FKey_restrict_del")) del_rule_type = SQL_NO_ACTION; else if (!strcmp(del_rule, "RI_FKey_setdefault_del")) del_rule_type = SQL_SET_DEFAULT; else if (!strcmp(del_rule, "RI_FKey_setnull_del")) del_rule_type = SQL_SET_NULL; /* Set deferrability type */ if (!strcmp(trig_initdeferred, "y")) defer_type = SQL_INITIALLY_DEFERRED; else if (!strcmp(trig_deferrable, "y")) defer_type = SQL_INITIALLY_IMMEDIATE; else defer_type = SQL_NOT_DEFERRABLE; /* Get to first primary key */ pkey_ptr = trig_args; for (i = 0; i < 5; i++) pkey_ptr += strlen(pkey_ptr) + 1; for (k = 0; k < num_keys; k++) { tuple = QR_AddNew(res); pkey_text = getClientColumnName(conn, relid2, pkey_ptr, &pkey_alloced); fkey_text = getClientColumnName(conn, relid1, fkey_ptr, &fkey_alloced); MYLOG(0, "pk_table = '%s', pkey_ptr = '%s'\n", pk_table_fetched, pkey_text); set_tuplefield_string(&tuple[FKS_PKTABLE_CAT], CurrCat(conn)); set_tuplefield_string(&tuple[FKS_PKTABLE_SCHEM], GET_SCHEMA_NAME(schema_fetched)); set_tuplefield_string(&tuple[FKS_PKTABLE_NAME], pk_table_fetched); set_tuplefield_string(&tuple[FKS_PKCOLUMN_NAME], pkey_text); MYLOG(0, "fk_table_needed = '%s', fkey_ptr = '%s'\n", fk_table_needed, fkey_text); set_tuplefield_string(&tuple[FKS_FKTABLE_CAT], CurrCat(conn)); set_tuplefield_string(&tuple[FKS_FKTABLE_SCHEM], GET_SCHEMA_NAME(schema_needed)); set_tuplefield_string(&tuple[FKS_FKTABLE_NAME], fk_table_needed); set_tuplefield_string(&tuple[FKS_FKCOLUMN_NAME], fkey_text); MYLOG(0, "upd_rule_type = '%i', del_rule_type = '%i'\n, trig_name = '%s'", upd_rule_type, del_rule_type, trig_args); set_tuplefield_int2(&tuple[FKS_KEY_SEQ], (Int2) (k + 1)); set_tuplefield_int2(&tuple[FKS_UPDATE_RULE], upd_rule_type); set_tuplefield_int2(&tuple[FKS_DELETE_RULE], del_rule_type); set_tuplefield_string(&tuple[FKS_FK_NAME], constrname); set_tuplefield_string(&tuple[FKS_PK_NAME], pkname); set_tuplefield_int2(&tuple[FKS_DEFERRABILITY], defer_type); set_tuplefield_string(&tuple[FKS_TRIGGER_NAME], trig_args); if (fkey_alloced) free(fkey_text); fkey_alloced = FALSE; if (pkey_alloced) free(pkey_text); pkey_alloced = FALSE; /* next primary/foreign key */ for (i = 0; i < 2; i++) { fkey_ptr += strlen(fkey_ptr) + 1; pkey_ptr += strlen(pkey_ptr) + 1; } } result = PGAPI_Fetch(tbl_stmt); } } /* * Case #1 -- Get the foreign keys in other tables that refer to the * primary key in the specified table (pktab). i.e., Who points to * me? */ else if (pk_table_needed[0] != '\0') { char *escSchemaName; escPkTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, conn); schema_str(schema_needed, sizeof(schema_needed), szPkTableOwner, cbPkTableOwner, TABLE_IS_VALID(szPkTableName, cbPkTableName), conn); escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn); printfPQExpBuffer(&tables_query, "SELECT pt.tgargs, " " pt.tgnargs, " " pt.tgdeferrable, " " pt.tginitdeferred, " " pp1.proname, " " pp2.proname, " " pc.oid, " " pc1.oid, " " pc1.relname, " " pt.tgconstrname, pn1.nspname " "FROM pg_catalog.pg_class pc, " " pg_catalog.pg_class pc1, " " pg_catalog.pg_proc pp, " " pg_catalog.pg_proc pp1, " " pg_catalog.pg_proc pp2, " " pg_catalog.pg_trigger pt, " " pg_catalog.pg_trigger pt1, " " pg_catalog.pg_trigger pt2, " " pg_catalog.pg_namespace pn, " " pg_catalog.pg_namespace pn1 " "WHERE pc.relname %s'%s' " " AND pn.nspname %s'%s' " " AND pc.relnamespace = pn.oid " " AND pt.tgconstrrelid = pc.oid " " AND pp.oid = pt.tgfoid " " AND pp.proname Like '%%ins' " " AND pt1.tgconstrname = pt.tgconstrname " " AND pt1.tgconstrrelid = pt.tgrelid " " AND pt1.tgrelid = pc.oid " " AND pc1.oid = pt.tgrelid " " AND pp1.oid = pt1.tgfoid " " AND pp1.proname like '%%upd' " " AND (pp1.proname not like '%%check%%') " " AND pt2.tgconstrname = pt.tgconstrname " " AND pt2.tgconstrrelid = pt.tgrelid " " AND pt2.tgrelid = pc.oid " " AND pp2.oid = pt2.tgfoid " " AND pp2.proname Like '%%del' " " AND pn1.oid = pc1.relnamespace " " order by pt.tgconstrname", eq_string, escPkTableName, eq_string, escSchemaName); free(escSchemaName); if (PQExpBufferDataBroken(tables_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_ForeignKeys()", func); goto cleanup; } result = PGAPI_ExecDirect(tbl_stmt, (SQLCHAR *) tables_query.data, SQL_NTS, PODBC_RDONLY); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 1, SQL_C_BINARY, trig_args, sizeof(trig_args), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 2, SQL_C_SHORT, &trig_nargs, 0, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 3, internal_asis_type, trig_deferrable, sizeof(trig_deferrable), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 4, internal_asis_type, trig_initdeferred, sizeof(trig_initdeferred), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 5, internal_asis_type, upd_rule, sizeof(upd_rule), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 6, internal_asis_type, del_rule, sizeof(del_rule), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 7, SQL_C_ULONG, &relid1, sizeof(relid1), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 8, SQL_C_ULONG, &relid2, sizeof(relid2), NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 9, internal_asis_type, fk_table_fetched, TABLE_NAME_STORAGE_LEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 10, internal_asis_type, constrname, NAMESTORAGELEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_BindCol(tbl_stmt, 11, internal_asis_type, schema_fetched, SCHEMA_NAME_STORAGE_LEN, NULL); if (!SQL_SUCCEEDED(result)) { goto cleanup; } result = PGAPI_Fetch(tbl_stmt); if (result == SQL_NO_DATA_FOUND) { ret = SQL_SUCCESS; goto cleanup; } if (result != SQL_SUCCESS) { SC_full_error_copy(stmt, tbl_stmt, FALSE); goto cleanup; } /* * get pk_name here */ keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt, 0); if (!SQL_SUCCEEDED(keyresult)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys (pkeys) result.", func); goto cleanup; } keyresult = PGAPI_BindCol(hpkey_stmt, 6, internal_asis_type, pkname, sizeof(pkname), NULL); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't bindcol for primary keys for PGAPI_ForeignKeys result.", func); goto cleanup; } keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, (SQLCHAR *) schema_needed, SQL_NTS, (SQLCHAR *) pk_table_needed, SQL_NTS, 0); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't get primary keys for PGAPI_ForeignKeys result.", func); goto cleanup; } pkname[0] = '\0'; keyresult = PGAPI_Fetch(hpkey_stmt); PGAPI_FreeStmt(hpkey_stmt, SQL_CLOSE); while (result == SQL_SUCCESS) { /* Calculate the number of key parts */ num_keys = (trig_nargs - 4) / 2;; /* Handle action (i.e., 'cascade', 'restrict', 'setnull') */ if (!strcmp(upd_rule, "RI_FKey_cascade_upd")) upd_rule_type = SQL_CASCADE; else if (!strcmp(upd_rule, "RI_FKey_noaction_upd")) upd_rule_type = SQL_NO_ACTION; else if (!strcmp(upd_rule, "RI_FKey_restrict_upd")) upd_rule_type = SQL_NO_ACTION; else if (!strcmp(upd_rule, "RI_FKey_setdefault_upd")) upd_rule_type = SQL_SET_DEFAULT; else if (!strcmp(upd_rule, "RI_FKey_setnull_upd")) upd_rule_type = SQL_SET_NULL; if (!strcmp(del_rule, "RI_FKey_cascade_del")) del_rule_type = SQL_CASCADE; else if (!strcmp(del_rule, "RI_FKey_noaction_del")) del_rule_type = SQL_NO_ACTION; else if (!strcmp(del_rule, "RI_FKey_restrict_del")) del_rule_type = SQL_NO_ACTION; else if (!strcmp(del_rule, "RI_FKey_setdefault_del")) del_rule_type = SQL_SET_DEFAULT; else if (!strcmp(del_rule, "RI_FKey_setnull_del")) del_rule_type = SQL_SET_NULL; /* Set deferrability type */ if (!strcmp(trig_initdeferred, "y")) defer_type = SQL_INITIALLY_DEFERRED; else if (!strcmp(trig_deferrable, "y")) defer_type = SQL_INITIALLY_IMMEDIATE; else defer_type = SQL_NOT_DEFERRABLE; MYLOG(0, "Foreign Key Case#1: trig_nargs = %d, num_keys = %d\n", trig_nargs, num_keys); /* Get to first primary key */ pkey_ptr = trig_args; for (i = 0; i < 5; i++) pkey_ptr += strlen(pkey_ptr) + 1; /* Get to first foreign key */ fkey_ptr = trig_args; for (k = 0; k < 4; k++) fkey_ptr += strlen(fkey_ptr) + 1; for (k = 0; k < num_keys; k++) { pkey_text = getClientColumnName(conn, relid1, pkey_ptr, &pkey_alloced); fkey_text = getClientColumnName(conn, relid2, fkey_ptr, &fkey_alloced); MYLOG(0, "pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'\n", pkey_text, fk_table_fetched, fkey_text); tuple = QR_AddNew(res); MYLOG(0, "pk_table_needed = '%s', pkey_ptr = '%s'\n", pk_table_needed, pkey_text); set_tuplefield_string(&tuple[FKS_PKTABLE_CAT], CurrCat(conn)); set_tuplefield_string(&tuple[FKS_PKTABLE_SCHEM], GET_SCHEMA_NAME(schema_needed)); set_tuplefield_string(&tuple[FKS_PKTABLE_NAME], pk_table_needed); set_tuplefield_string(&tuple[FKS_PKCOLUMN_NAME], pkey_text); MYLOG(0, "fk_table = '%s', fkey_ptr = '%s'\n", fk_table_fetched, fkey_text); set_tuplefield_string(&tuple[FKS_FKTABLE_CAT], CurrCat(conn)); set_tuplefield_string(&tuple[FKS_FKTABLE_SCHEM], GET_SCHEMA_NAME(schema_fetched)); set_tuplefield_string(&tuple[FKS_FKTABLE_NAME], fk_table_fetched); set_tuplefield_string(&tuple[FKS_FKCOLUMN_NAME], fkey_text); set_tuplefield_int2(&tuple[FKS_KEY_SEQ], (Int2) (k + 1)); MYLOG(0, "upd_rule = %d, del_rule= %d", upd_rule_type, del_rule_type); set_nullfield_int2(&tuple[FKS_UPDATE_RULE], upd_rule_type); set_nullfield_int2(&tuple[FKS_DELETE_RULE], del_rule_type); set_tuplefield_string(&tuple[FKS_FK_NAME], constrname); set_tuplefield_string(&tuple[FKS_PK_NAME], pkname); set_tuplefield_string(&tuple[FKS_TRIGGER_NAME], trig_args); MYPRINTF(0, " defer_type = %d\n", defer_type); set_tuplefield_int2(&tuple[FKS_DEFERRABILITY], defer_type); if (pkey_alloced) free(pkey_text); pkey_alloced = FALSE; if (fkey_alloced) free(fkey_text); fkey_alloced = FALSE; /* next primary/foreign key */ for (j = 0; j < 2; j++) { pkey_ptr += strlen(pkey_ptr) + 1; fkey_ptr += strlen(fkey_ptr) + 1; } } result = PGAPI_Fetch(tbl_stmt); } } else { SC_set_error(stmt, STMT_INTERNAL_ERROR, "No tables specified to PGAPI_ForeignKeys.", func); goto cleanup; } ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; if (!SQL_SUCCEEDED(ret) && 0 >= SC_get_errornumber(stmt)) SC_error_copy(stmt, tbl_stmt, TRUE); if (!PQExpBufferDataBroken(tables_query)) termPQExpBuffer(&tables_query); if (pkey_alloced) free(pkey_text); if (fkey_alloced) free(fkey_text); if (pk_table_needed) free(pk_table_needed); if (escPkTableName) free(escPkTableName); if (fk_table_needed) free(fk_table_needed); if (escFkTableName) free(escFkTableName); if (tbl_stmt) PGAPI_FreeStmt(tbl_stmt, SQL_DROP); if (hpkey_stmt) PGAPI_FreeStmt(hpkey_stmt, SQL_DROP); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); MYLOG(0, "leaving stmt=%p, ret=%d\n", stmt, ret); return ret; } RETCODE SQL_API PGAPI_ForeignKeys(HSTMT hstmt, const SQLCHAR * szPkTableQualifier, /* OA X*/ SQLSMALLINT cbPkTableQualifier, const SQLCHAR * szPkTableOwner, /* OA E*/ SQLSMALLINT cbPkTableOwner, const SQLCHAR * szPkTableName, /* OA(R) E*/ SQLSMALLINT cbPkTableName, const SQLCHAR * szFkTableQualifier, /* OA X*/ SQLSMALLINT cbFkTableQualifier, const SQLCHAR * szFkTableOwner, /* OA E*/ SQLSMALLINT cbFkTableOwner, const SQLCHAR * szFkTableName, /* OA(R) E*/ SQLSMALLINT cbFkTableName) { ConnectionClass *conn = SC_get_conn(((StatementClass *) hstmt)); if (PG_VERSION_GE(conn, 8.1)) return PGAPI_ForeignKeys_new(hstmt, szPkTableQualifier, cbPkTableQualifier, szPkTableOwner, cbPkTableOwner, szPkTableName, cbPkTableName, szFkTableQualifier, cbFkTableQualifier, szFkTableOwner, cbFkTableOwner, szFkTableName, cbFkTableName); else return PGAPI_ForeignKeys_old(hstmt, szPkTableQualifier, cbPkTableQualifier, szPkTableOwner, cbPkTableOwner, szPkTableName, cbPkTableName, szFkTableQualifier, cbFkTableQualifier, szFkTableOwner, cbFkTableOwner, szFkTableName, cbFkTableName); } #define PRORET_COUNT #define DISPLAY_ARGNAME static BOOL has_outparam(const char *proargmodes) { const char *ptr; if (!proargmodes) return FALSE; for (ptr = proargmodes; *ptr; ptr++) { switch (*ptr) { case 'o': case 'b': case 't': return TRUE; } } return FALSE; } RETCODE SQL_API PGAPI_ProcedureColumns(HSTMT hstmt, const SQLCHAR * szProcQualifier, /* OA X*/ SQLSMALLINT cbProcQualifier, const SQLCHAR * szProcOwner, /* PV E*/ SQLSMALLINT cbProcOwner, const SQLCHAR * szProcName, /* PV E*/ SQLSMALLINT cbProcName, const SQLCHAR * szColumnName, /* PV X*/ SQLSMALLINT cbColumnName, UWORD flag) { CSTR func = "PGAPI_ProcedureColumns"; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn = SC_get_conn(stmt); PQExpBufferData proc_query = {0}; Int2 result_cols; TupleField *tuple; char *schema_name, *procname; char *escSchemaName = NULL, *escProcName = NULL; char *params, *proargnames; char *proargmodes; char *delim = NULL; char *atttypid, *attname, *column_name; QResultClass *res, *tres = NULL; SQLLEN tcount; OID pgtype; Int4 paramcount, column_size, i, j; RETCODE ret = SQL_ERROR, result; BOOL search_pattern, bRetset, outpara_exist; const char *like_or_eq, *op_string, *retset; int ret_col = -1, ext_pos = -1, poid_pos = -1, attid_pos = -1, attname_pos = -1; UInt4 poid = 0, newpoid; MYLOG(0, "entering...\n"); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; search_pattern = (0 == (flag & PODBC_NOT_SEARCH_PATTERN)); if (search_pattern) { like_or_eq = likeop; escSchemaName = adjustLikePattern(szProcOwner, cbProcOwner, conn); escProcName = adjustLikePattern(szProcName, cbProcName, conn); } else { like_or_eq = eqop; escSchemaName = simpleCatalogEscape(szProcOwner, cbProcOwner, conn); escProcName = simpleCatalogEscape(szProcName, cbProcName, conn); } op_string = gen_opestr(like_or_eq, conn); initPQExpBuffer(&proc_query); #define return DONT_CALL_RETURN_FROM_HERE??? appendPQExpBufferStr(&proc_query, "select proname, proretset, prorettype, " "pronargs, proargtypes, nspname, p.oid"); ret_col = ext_pos = 7; poid_pos = 6; #ifdef PRORET_COUNT appendPQExpBufferStr(&proc_query, ", atttypid, attname"); attid_pos = ext_pos; attname_pos = ext_pos + 1; ret_col += 2; ext_pos = ret_col; #endif /* PRORET_COUNT */ if (PG_VERSION_GE(conn, 8.0)) { appendPQExpBufferStr(&proc_query, ", proargnames"); ret_col++; } if (PG_VERSION_GE(conn, 8.1)) { appendPQExpBufferStr(&proc_query, ", proargmodes, proallargtypes"); ret_col += 2; } #ifdef PRORET_COUNT appendPQExpBufferStr(&proc_query, " from ((pg_catalog.pg_namespace n inner join" " pg_catalog.pg_proc p on p.pronamespace = n.oid)" " inner join pg_type t on t.oid = p.prorettype)" " left outer join pg_attribute a on a.attrelid = t.typrelid " " and attnum > 0 and not attisdropped where"); #else appendPQExpBufferStr(&proc_query, " from pg_catalog.pg_namespace n," " pg_catalog.pg_proc p where"); " p.pronamespace = n.oid and" " (not proretset) and"); #endif /* PRORET_COUNT */ appendPQExpBuffer(&proc_query, " has_function_privilege(p.oid, 'EXECUTE')"); if (IS_VALID_NAME(escSchemaName)) appendPQExpBuffer(&proc_query, " and nspname %s'%s'", op_string, escSchemaName); if (escProcName) appendPQExpBuffer(&proc_query, " and proname %s'%s'", op_string, escProcName); appendPQExpBuffer(&proc_query, " order by nspname, proname, p.oid, attnum"); if (escSchemaName) free(escSchemaName); if (escProcName) free(escProcName); if (PQExpBufferDataBroken(proc_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_ProcedureColumns()", func); goto cleanup; } tres = CC_send_query(conn, proc_query.data, NULL, READ_ONLY_QUERY, stmt); if (!QR_command_maybe_successful(tres)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_ProcedureColumns query error", func); QR_Destructor(tres); goto cleanup; } if (res = QR_Constructor(), !res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for PGAPI_ProcedureColumns result.", func); goto cleanup; } SC_set_Result(stmt, res); /* * the binding structure for a statement is not set up until * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_PROCOLS_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; /* set the field names */ QR_set_num_fields(res, result_cols); QR_set_field_info_v(res, PROCOLS_PROCEDURE_CAT, "PROCEDURE_CAT", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_PROCEDURE_SCHEM, "PROCEDUR_SCHEM", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_PROCEDURE_NAME, "PROCEDURE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_COLUMN_NAME, "COLUMN_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_COLUMN_TYPE, "COLUMN_TYPE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_DATA_TYPE, "DATA_TYPE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_TYPE_NAME, "TYPE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_COLUMN_SIZE, "COLUMN_SIZE", PG_TYPE_INT4, 4); QR_set_field_info_v(res, PROCOLS_BUFFER_LENGTH, "BUFFER_LENGTH", PG_TYPE_INT4, 4); QR_set_field_info_v(res, PROCOLS_DECIMAL_DIGITS, "DECIMAL_DIGITS", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_NUM_PREC_RADIX, "NUM_PREC_RADIX", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_NULLABLE, "NULLABLE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_REMARKS, "REMARKS", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_COLUMN_DEF, "COLUMN_DEF", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, PROCOLS_SQL_DATA_TYPE, "SQL_DATA_TYPE", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_SQL_DATETIME_SUB, "SQL_DATETIME_SUB", PG_TYPE_INT2, 2); QR_set_field_info_v(res, PROCOLS_CHAR_OCTET_LENGTH, "CHAR_OCTET_LENGTH", PG_TYPE_INT4, 4); QR_set_field_info_v(res, PROCOLS_ORDINAL_POSITION, "ORDINAL_POSITION", PG_TYPE_INT4, 4); QR_set_field_info_v(res, PROCOLS_IS_NULLABLE, "IS_NULLABLE", PG_TYPE_VARCHAR, MAX_INFO_STRING); column_name = make_string(szColumnName, cbColumnName, NULL, 0); if (column_name) /* column_name is unavailable now */ { tcount = 0; free(column_name); } else tcount = QR_get_num_total_tuples(tres); for (i = 0, poid = 0; i < tcount; i++) { schema_name = GET_SCHEMA_NAME(QR_get_value_backend_text(tres, i, 5)); procname = QR_get_value_backend_text(tres, i, 0); retset = QR_get_value_backend_text(tres, i, 1); pgtype = QR_get_value_backend_int(tres, i, 2, NULL); bRetset = retset && (retset[0] == 't' || retset[0] == 'y'); outpara_exist = FALSE; newpoid = 0; if (poid_pos >= 0) newpoid = QR_get_value_backend_int(tres, i, poid_pos, NULL); MYLOG(0, "newpoid=%d\n", newpoid); atttypid = NULL; if (attid_pos >= 0) { atttypid = QR_get_value_backend_text(tres, i, attid_pos); MYLOG(0, "atttypid=%s\n", atttypid ? atttypid : "(null)"); } if (poid == 0 || newpoid != poid) { poid = newpoid; proargmodes = NULL; proargnames = NULL; if (ext_pos >=0) { #ifdef DISPLAY_ARGNAME /* !! named parameter is unavailable !! */ if (PG_VERSION_GE(conn, 8.0)) proargnames = QR_get_value_backend_text(tres, i, ext_pos); #endif /* DISPLAY_ARGNAME */ if (PG_VERSION_GE(conn, 8.1)) proargmodes = QR_get_value_backend_text(tres, i, ext_pos + 1); } outpara_exist = has_outparam(proargmodes); /* RETURN_VALUE info */ if (0 != pgtype && PG_TYPE_VOID != pgtype && !bRetset && !atttypid && !outpara_exist) { tuple = QR_AddNew(res); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_CAT], CurrCat(conn)); set_nullfield_string(&tuple[PROCOLS_PROCEDURE_SCHEM], schema_name); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_NAME], procname); set_tuplefield_string(&tuple[PROCOLS_COLUMN_NAME], NULL_STRING); set_tuplefield_int2(&tuple[PROCOLS_COLUMN_TYPE], SQL_RETURN_VALUE); set_tuplefield_int2(&tuple[PROCOLS_DATA_TYPE], PGTYPE_TO_CONCISE_TYPE(conn, pgtype)); set_tuplefield_string(&tuple[PROCOLS_TYPE_NAME], PGTYPE_TO_NAME(conn, pgtype, FALSE)); column_size = PGTYPE_COLUMN_SIZE(conn, pgtype); set_nullfield_int4(&tuple[PROCOLS_COLUMN_SIZE], column_size); set_tuplefield_int4(&tuple[PROCOLS_BUFFER_LENGTH], PGTYPE_BUFFER_LENGTH(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_DECIMAL_DIGITS], PGTYPE_DECIMAL_DIGITS(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_NUM_PREC_RADIX], pgtype_radix(conn, pgtype)); set_tuplefield_int2(&tuple[PROCOLS_NULLABLE], SQL_NULLABLE_UNKNOWN); set_tuplefield_null(&tuple[PROCOLS_REMARKS]); set_tuplefield_null(&tuple[PROCOLS_COLUMN_DEF]); set_tuplefield_int2(&tuple[PROCOLS_SQL_DATA_TYPE], PGTYPE_TO_SQLDESCTYPE(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_SQL_DATETIME_SUB], PGTYPE_TO_DATETIME_SUB(conn, pgtype)); set_nullfield_int4(&tuple[PROCOLS_CHAR_OCTET_LENGTH], PGTYPE_TRANSFER_OCTET_LENGTH(conn, pgtype)); set_tuplefield_int4(&tuple[PROCOLS_ORDINAL_POSITION], 0); set_tuplefield_string(&tuple[PROCOLS_IS_NULLABLE], NULL_STRING); } paramcount = 0; params = NULL; if (proargmodes) { const char *p; for (p = proargmodes; *p; p++) { if (',' == (*p)) paramcount++; } paramcount++; params = QR_get_value_backend_text(tres, i, ext_pos + 2); // proallargtypes - oidarray if ('{' == *proargmodes) proargmodes++; } if (0 == paramcount) paramcount = QR_get_value_backend_int(tres, i, 3, NULL); if (0 < paramcount && NULL == params) params = QR_get_value_backend_text(tres, i, 4); // proargtypes - oidvector if (proargnames) { if ('{' == *proargnames) proargnames++; } if (params && '{' == *params) params++; /* PARAMETERS info */ for (j = 0; j < paramcount; j++) { /* PG type of parameters */ pgtype = 0; if (params) { while (isspace((unsigned char) *params) || ',' == *params) params++; if ('\0' == *params || '}' == *params) params = NULL; else { sscanf(params, "%u", &pgtype); while (isdigit((unsigned char) *params)) params++; } } /* input/output type of parameters */ if (proargmodes) { while (isspace((unsigned char) *proargmodes) || ',' == *proargmodes) proargmodes++; if ('\0' == *proargmodes || '}' == *proargmodes) proargmodes = NULL; } /* name of parameters */ if (proargnames) { while (isspace((unsigned char) *proargnames) || ',' == *proargnames) proargnames++; if ('\0' == *proargnames || '}' == *proargnames) proargnames = NULL; else if ('"' == *proargnames) { proargnames++; for (delim = proargnames; *delim && *delim != '"'; delim++) ; } else { for (delim = proargnames; IS_NOT_SPACE(*delim) && ',' != *delim && '}' != *delim; delim++) ; } if (proargnames && '\0' == *delim) /* discard the incomplete name */ proargnames = NULL; } tuple = QR_AddNew(res); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_CAT], CurrCat(conn)); set_nullfield_string(&tuple[PROCOLS_PROCEDURE_SCHEM], schema_name); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_NAME], procname); if (proargnames) { *delim = '\0'; set_tuplefield_string(&tuple[PROCOLS_COLUMN_NAME], proargnames); proargnames = delim + 1; } else set_tuplefield_string(&tuple[PROCOLS_COLUMN_NAME], NULL_STRING); if (proargmodes) { int ptype; switch (*proargmodes) { case 'o': case 't': ptype = bRetset ? SQL_RESULT_COL : SQL_PARAM_OUTPUT; break; case 'b': ptype = SQL_PARAM_INPUT_OUTPUT; break; default: ptype = SQL_PARAM_INPUT; break; } set_tuplefield_int2(&tuple[PROCOLS_COLUMN_TYPE], ptype); proargmodes++; } else set_tuplefield_int2(&tuple[PROCOLS_COLUMN_TYPE], SQL_PARAM_INPUT); set_tuplefield_int2(&tuple[PROCOLS_DATA_TYPE], PGTYPE_TO_CONCISE_TYPE(conn, pgtype)); set_tuplefield_string(&tuple[PROCOLS_TYPE_NAME], PGTYPE_TO_NAME(conn, pgtype, FALSE)); column_size = PGTYPE_COLUMN_SIZE(conn, pgtype); set_nullfield_int4(&tuple[PROCOLS_COLUMN_SIZE], column_size); set_tuplefield_int4(&tuple[PROCOLS_BUFFER_LENGTH], PGTYPE_BUFFER_LENGTH(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_DECIMAL_DIGITS], PGTYPE_DECIMAL_DIGITS(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_NUM_PREC_RADIX], pgtype_radix(conn, pgtype)); set_tuplefield_int2(&tuple[PROCOLS_NULLABLE], SQL_NULLABLE_UNKNOWN); set_tuplefield_null(&tuple[PROCOLS_REMARKS]); set_tuplefield_null(&tuple[PROCOLS_COLUMN_DEF]); set_tuplefield_int2(&tuple[PROCOLS_SQL_DATA_TYPE], PGTYPE_TO_SQLDESCTYPE(conn, pgtype)); set_nullfield_int2(&tuple[PROCOLS_SQL_DATETIME_SUB], PGTYPE_TO_DATETIME_SUB(conn, pgtype)); set_nullfield_int4(&tuple[PROCOLS_CHAR_OCTET_LENGTH], PGTYPE_TRANSFER_OCTET_LENGTH(conn, pgtype)); set_tuplefield_int4(&tuple[PROCOLS_ORDINAL_POSITION], j + 1); set_tuplefield_string(&tuple[PROCOLS_IS_NULLABLE], NULL_STRING); } } /* RESULT Columns info */ if (!outpara_exist && (NULL != atttypid || bRetset)) { int typid; if (!atttypid) { typid = pgtype; attname = NULL; } else { typid = atoi(atttypid); attname = QR_get_value_backend_text(tres, i, attname_pos); } tuple = QR_AddNew(res); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_CAT], CurrCat(conn)); set_nullfield_string(&tuple[PROCOLS_PROCEDURE_SCHEM], schema_name); set_tuplefield_string(&tuple[PROCOLS_PROCEDURE_NAME], procname); set_tuplefield_string(&tuple[PROCOLS_COLUMN_NAME], attname); set_tuplefield_int2(&tuple[PROCOLS_COLUMN_TYPE], bRetset ? SQL_RESULT_COL : SQL_PARAM_OUTPUT); set_tuplefield_int2(&tuple[PROCOLS_DATA_TYPE], PGTYPE_TO_CONCISE_TYPE(conn, typid)); set_tuplefield_string(&tuple[PROCOLS_TYPE_NAME], PGTYPE_TO_NAME(conn, typid, FALSE)); column_size = PGTYPE_COLUMN_SIZE(conn, typid); set_nullfield_int4(&tuple[PROCOLS_COLUMN_SIZE], column_size); set_tuplefield_int4(&tuple[PROCOLS_BUFFER_LENGTH], PGTYPE_BUFFER_LENGTH(conn, typid)); set_nullfield_int2(&tuple[PROCOLS_DECIMAL_DIGITS], PGTYPE_DECIMAL_DIGITS(conn, typid)); set_nullfield_int2(&tuple[PROCOLS_NUM_PREC_RADIX], pgtype_radix(conn, typid)); set_tuplefield_int2(&tuple[PROCOLS_NULLABLE], SQL_NULLABLE_UNKNOWN); set_tuplefield_null(&tuple[PROCOLS_REMARKS]); set_tuplefield_null(&tuple[PROCOLS_COLUMN_DEF]); set_tuplefield_int2(&tuple[PROCOLS_SQL_DATA_TYPE], PGTYPE_TO_SQLDESCTYPE(conn, typid)); set_nullfield_int2(&tuple[PROCOLS_SQL_DATETIME_SUB], PGTYPE_TO_DATETIME_SUB(conn, typid)); set_nullfield_int4(&tuple[PROCOLS_CHAR_OCTET_LENGTH], PGTYPE_TRANSFER_OCTET_LENGTH(conn, typid)); set_tuplefield_int4(&tuple[PROCOLS_ORDINAL_POSITION], 0); set_tuplefield_string(&tuple[PROCOLS_IS_NULLABLE], NULL_STRING); } } ret = SQL_SUCCESS; cleanup: #undef return if (tres) QR_Destructor(tres); if (!PQExpBufferDataBroken(proc_query)) termPQExpBuffer(&proc_query); /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); return ret; } RETCODE SQL_API PGAPI_Procedures(HSTMT hstmt, const SQLCHAR * szProcQualifier, /* OA X*/ SQLSMALLINT cbProcQualifier, const SQLCHAR * szProcOwner, /* PV E*/ SQLSMALLINT cbProcOwner, const SQLCHAR * szProcName, /* PV E*/ SQLSMALLINT cbProcName, UWORD flag) { CSTR func = "PGAPI_Procedures"; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn = SC_get_conn(stmt); PQExpBufferData proc_query = {0}; char *escSchemaName = NULL, *escProcName = NULL; QResultClass *res; RETCODE ret = SQL_ERROR, result; const char *like_or_eq, *op_string; BOOL search_pattern; MYLOG(0, "entering... scnm=%p len=%d\n", szProcOwner, cbProcOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; search_pattern = (0 == (flag & PODBC_NOT_SEARCH_PATTERN)); if (search_pattern) { like_or_eq = likeop; escSchemaName = adjustLikePattern(szProcOwner, cbProcOwner, conn); escProcName = adjustLikePattern(szProcName, cbProcName, conn); } else { like_or_eq = eqop; escSchemaName = simpleCatalogEscape(szProcOwner, cbProcOwner, conn); escProcName = simpleCatalogEscape(szProcName, cbProcName, conn); } /* * The following seems the simplest implementation */ op_string = gen_opestr(like_or_eq, conn); initPQExpBuffer(&proc_query); #define return DONT_CALL_RETURN_FROM_HERE??? appendPQExpBufferStr(&proc_query, "select ''::varchar as " "PROCEDURE_CAT" ", nspname as " "PROCEDURE_SCHEM" "," " proname as " "PROCEDURE_NAME" ", ''::varchar as " "NUM_INPUT_PARAMS" "," " ''::varchar as " "NUM_OUTPUT_PARAMS" ", ''::varchar as " "NUM_RESULT_SETS" "," " ''::varchar as " "REMARKS" "," " case when prorettype = 0 then 1::int2 else 2::int2 end" " as " "PROCEDURE_TYPE" " from pg_catalog.pg_namespace," " pg_catalog.pg_proc" " where pg_proc.pronamespace = pg_namespace.oid"); schema_appendPQExpBuffer1(&proc_query, " and nspname %s'%.*s'", op_string, escSchemaName, TABLE_IS_VALID(szProcName, cbProcName), conn); if (IS_VALID_NAME(escProcName)) appendPQExpBuffer(&proc_query, " and proname %s'%s'", op_string, escProcName); if (PQExpBufferDataBroken(proc_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_Procedures()", func); goto cleanup; } res = CC_send_query(conn, proc_query.data, NULL, READ_ONLY_QUERY, stmt); if (!QR_command_maybe_successful(res)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_Procedures query error", func); QR_Destructor(res); goto cleanup; } SC_set_Result(stmt, res); ret = SQL_SUCCESS; /* * also, things need to think that this statement is finished so the * results can be retrieved. */ cleanup: #undef return stmt->status = STMT_FINISHED; extend_column_bindings(SC_get_ARDF(stmt), 8); if (escSchemaName) free(escSchemaName); if (escProcName) free(escProcName); if (!PQExpBufferDataBroken(proc_query)) termPQExpBuffer(&proc_query); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); return ret; } #define ACLMAX 8 #define ALL_PRIVILEGES "arwdRxt" static int usracl_auth(char *usracl, const char *auth) { int i, j, addcnt = 0; for (i = 0; auth[i]; i++) { for (j = 0; j < ACLMAX; j++) { if (usracl[j] == auth[i]) break; else if (!usracl[j]) { usracl[j]= auth[i]; addcnt++; break; } } } return addcnt; } static void useracl_upd(char (*useracl)[ACLMAX], QResultClass *allures, const char *user, const char *auth) { int usercount = (int) QR_get_num_cached_tuples(allures), i, addcnt = 0; MYLOG(0, "user=%s auth=%s\n", user, auth); if (user[0]) for (i = 0; i < usercount; i++) { if (strcmp(QR_get_value_backend_text(allures, i, 0), user) == 0) { addcnt += usracl_auth(useracl[i], auth); break; } } else for (i = 0; i < usercount; i++) { addcnt += usracl_auth(useracl[i], auth); } MYLOG(0, "addcnt=%d\n", addcnt); } RETCODE SQL_API PGAPI_TablePrivileges(HSTMT hstmt, const SQLCHAR * szTableQualifier, /* OA X*/ SQLSMALLINT cbTableQualifier, const SQLCHAR * szTableOwner, /* PV E*/ SQLSMALLINT cbTableOwner, const SQLCHAR * szTableName, /* PV E*/ SQLSMALLINT cbTableName, UWORD flag) { StatementClass *stmt = (StatementClass *) hstmt; CSTR func = "PGAPI_TablePrivileges"; ConnectionClass *conn = SC_get_conn(stmt); Int2 result_cols; PQExpBufferData proc_query = {0}; QResultClass *res, *wres = NULL, *allures = NULL; TupleField *tuple; Int4 tablecount, usercount, i, j, k; BOOL grpauth, sys, su; char (*useracl)[ACLMAX] = NULL, *acl, *user, *delim, *auth; const char *reln, *owner, *priv, *schnm = NULL; RETCODE result, ret = SQL_ERROR; const char *like_or_eq, *op_string; const SQLCHAR *szSchemaName; SQLSMALLINT cbSchemaName; char *escSchemaName = NULL, *escTableName = NULL; BOOL search_pattern; MYLOG(0, "entering... scnm=%p len-%d\n", szTableOwner, cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; /* * a statement is actually executed, so we'll have to do this * ourselves. */ result_cols = NUM_OF_TABPRIV_FIELDS; extend_column_bindings(SC_get_ARDF(stmt), result_cols); stmt->catalog_result = TRUE; /* set the field names */ res = QR_Constructor(); if (!res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for query.", func); return SQL_ERROR; } SC_set_Result(stmt, res); QR_set_num_fields(res, result_cols); QR_set_field_info_v(res, 0, "TABLE_CAT", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 1, "TABLE_SCHEM", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 2, "TABLE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 3, "GRANTOR", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 4, "GRANTEE", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 5, "PRIVILEGE", PG_TYPE_VARCHAR, MAX_INFO_STRING); QR_set_field_info_v(res, 6, "IS_GRANTABLE", PG_TYPE_VARCHAR, MAX_INFO_STRING); /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); szSchemaName = szTableOwner; cbSchemaName = cbTableOwner; #define return DONT_CALL_RETURN_FROM_HERE??? search_pattern = (0 == (flag & PODBC_NOT_SEARCH_PATTERN)); if (search_pattern) { like_or_eq = likeop; escTableName = adjustLikePattern(szTableName, cbTableName, conn); } else { like_or_eq = eqop; escTableName = simpleCatalogEscape(szTableName, cbTableName, conn); } retry_public_schema: if (escSchemaName) free(escSchemaName); if (search_pattern) escSchemaName = adjustLikePattern(szSchemaName, cbSchemaName, conn); else escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, conn); op_string = gen_opestr(like_or_eq, conn); initPQExpBuffer(&proc_query); appendPQExpBufferStr(&proc_query, "select relname, usename, relacl, nspname" " from pg_catalog.pg_namespace, pg_catalog.pg_class ," " pg_catalog.pg_user where"); if (escSchemaName) schema_appendPQExpBuffer1(&proc_query, " nspname %s'%.*s' and", op_string, escSchemaName, TABLE_IS_VALID(szTableName, cbTableName), conn); if (escTableName) appendPQExpBuffer(&proc_query, " relname %s'%s' and", op_string, escTableName); appendPQExpBufferStr(&proc_query, " pg_namespace.oid = relnamespace and relkind in " TABLE_IN_RELKIND " and"); if ((!escTableName) && (!escSchemaName)) appendPQExpBufferStr(&proc_query, " nspname not in ('pg_catalog', 'information_schema') and"); appendPQExpBufferStr(&proc_query, " pg_user.usesysid = relowner"); if (PQExpBufferDataBroken(proc_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_TablePrivileges()", func); goto cleanup; } if (wres = CC_send_query(conn, proc_query.data, NULL, READ_ONLY_QUERY, stmt), !QR_command_maybe_successful(wres)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_TablePrivileges query error", func); goto cleanup; } tablecount = (Int4) QR_get_num_cached_tuples(wres); /* If not found */ if ((flag & PODBC_SEARCH_PUBLIC_SCHEMA) != 0 && 0 == tablecount) { if (allow_public_schema(conn, szSchemaName, cbSchemaName)) { QR_Destructor(wres); wres = NULL; szSchemaName = pubstr; cbSchemaName = SQL_NTS; goto retry_public_schema; } } resetPQExpBuffer(&proc_query); appendPQExpBufferStr(&proc_query, "select usename, usesysid, usesuper from pg_user"); if (PQExpBufferDataBroken(proc_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_TablePrivileges()", func); goto cleanup; } if (allures = CC_send_query(conn, proc_query.data, NULL, READ_ONLY_QUERY, stmt), !QR_command_maybe_successful(allures)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_TablePrivileges query error", func); goto cleanup; } usercount = (Int4) QR_get_num_cached_tuples(allures); useracl = (char (*)[ACLMAX]) malloc(usercount * sizeof(char [ACLMAX])); if (!useracl) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for user acl.", func); goto cleanup; } for (i = 0; i < tablecount; i++) { memset(useracl, 0, usercount * sizeof(char[ACLMAX])); acl = (char *) QR_get_value_backend_text(wres, i, 2); if (acl && acl[0] == '{') user = acl + 1; else user = NULL; for (; user && *user;) { grpauth = FALSE; if (user[0] == '"' && strncmp(user + 1, "group ", 6) == 0) { user += 7; grpauth = TRUE; } if (delim = strchr(user, '='), !delim) break; *delim = '\0'; auth = delim + 1; if (grpauth) { if (delim = strchr(auth, '"'), delim) { *delim = '\0'; delim++; } } else if (delim = strchr(auth, ','), delim) *delim = '\0'; else if (delim = strchr(auth, '}'), delim) *delim = '\0'; if (grpauth) /* handle group privilege */ { QResultClass *gres; int i; char *grolist, *uid, *delm; resetPQExpBuffer(&proc_query); appendPQExpBuffer(&proc_query, "select grolist from pg_group where groname = '%s'", user); if (PQExpBufferDataBroken(proc_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_TablePrivileges()", func); goto cleanup; } if (gres = CC_send_query(conn, proc_query.data, NULL, READ_ONLY_QUERY, stmt), !QR_command_maybe_successful(gres)) { grolist = QR_get_value_backend_text(gres, 0, 0); if (grolist && grolist[0] == '{') { for (uid = grolist + 1; *uid;) { if (delm = strchr(uid, ','), delm) *delm = '\0'; else if (delm = strchr(uid, '}'), delm) *delm = '\0'; MYLOG(0, "guid=%s\n", uid); for (i = 0; i < usercount; i++) { if (strcmp(QR_get_value_backend_text(allures, i, 1), uid) == 0) useracl_upd(useracl, allures, QR_get_value_backend_text(allures, i, 0), auth); } uid = delm + 1; } } } QR_Destructor(gres); } else useracl_upd(useracl, allures, user, auth); if (!delim) break; user = delim + 1; } reln = QR_get_value_backend_text(wres, i, 0); owner = QR_get_value_backend_text(wres, i, 1); schnm = QR_get_value_backend_text(wres, i, 3); /* The owner has all privileges */ useracl_upd(useracl, allures, owner, ALL_PRIVILEGES); for (j = 0; j < usercount; j++) { user = QR_get_value_backend_text(allures, j, 0); su = (strcmp(QR_get_value_backend_text(allures, j, 2), "t") == 0); sys = (strcmp(user, owner) == 0); /* Super user has all privileges */ if (su) useracl_upd(useracl, allures, user, ALL_PRIVILEGES); for (k = 0; k < ACLMAX; k++) { if (!useracl[j][k]) break; switch (useracl[j][k]) { case 'R': /* rule */ case 't': /* trigger */ continue; } tuple = QR_AddNew(res); set_tuplefield_string(&tuple[TABPRIV_TABLE_CAT], CurrCat(conn)); set_tuplefield_string(&tuple[TABPRIV_TABLE_SCHEM], GET_SCHEMA_NAME(schnm)); set_tuplefield_string(&tuple[TABPRIV_TABLE_NAME], reln); if (su || sys) set_tuplefield_string(&tuple[TABPRIV_GRANTOR], "_SYSTEM"); else set_tuplefield_string(&tuple[TABPRIV_GRANTOR], owner); MYLOG(0, "user=%s\n", user); set_tuplefield_string(&tuple[TABPRIV_GRANTEE], user); switch (useracl[j][k]) { case 'a': priv = "INSERT"; break; case 'r': priv = "SELECT"; break; case 'w': priv = "UPDATE"; break; case 'd': priv = "DELETE"; break; case 'x': priv = "REFERENCES"; break; default: priv = NULL_STRING; } set_tuplefield_string(&tuple[TABPRIV_PRIVILEGE], priv); /* The owner and the super user are grantable */ if (sys || su) set_tuplefield_string(&tuple[TABPRIV_IS_GRANTABLE], "YES"); else set_tuplefield_string(&tuple[TABPRIV_IS_GRANTABLE], "NO"); } } } ret = SQL_SUCCESS; cleanup: #undef return if (escSchemaName) free(escSchemaName); if (escTableName) free(escTableName); if (useracl) free(useracl); if (!PQExpBufferDataBroken(proc_query)) termPQExpBuffer(&proc_query); if (wres) QR_Destructor(wres); if (allures) QR_Destructor(allures); return ret; } static RETCODE SQL_API PGAPI_ForeignKeys_new(HSTMT hstmt, const SQLCHAR * szPkTableQualifier, /* OA X*/ SQLSMALLINT cbPkTableQualifier, const SQLCHAR * szPkTableOwner, /* OA E*/ SQLSMALLINT cbPkTableOwner, const SQLCHAR * szPkTableName, /* OA(R) E*/ SQLSMALLINT cbPkTableName, const SQLCHAR * szFkTableQualifier, /* OA X*/ SQLSMALLINT cbFkTableQualifier, const SQLCHAR * szFkTableOwner, /* OA E*/ SQLSMALLINT cbFkTableOwner, const SQLCHAR * szFkTableName, /* OA(R) E*/ SQLSMALLINT cbFkTableName) { CSTR func = "PGAPI_ForeignKeys"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res = NULL; RETCODE ret = SQL_ERROR, result; PQExpBufferData tables_query = {0}; char *pk_table_needed = NULL, *escTableName = NULL; char *fk_table_needed = NULL; char schema_needed[SCHEMA_NAME_STORAGE_LEN + 1]; char *escSchemaName; char catName[SCHEMA_NAME_STORAGE_LEN], scmName1[SCHEMA_NAME_STORAGE_LEN], scmName2[SCHEMA_NAME_STORAGE_LEN]; const char *relqual; ConnectionClass *conn = SC_get_conn(stmt); const char *eq_string; MYLOG(0, "entering...stmt=%p\n", stmt); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; schema_needed[0] = '\0'; #define return DONT_CALL_RETURN_FROM_HERE??? pk_table_needed = make_string(szPkTableName, cbPkTableName, NULL, 0); fk_table_needed = make_string(szFkTableName, cbFkTableName, NULL, 0); eq_string = gen_opestr(eqop, conn); /* * Case #2 -- Get the foreign keys in the specified table (fktab) that * refer to the primary keys of other table(s). */ if (NULL != fk_table_needed) { MYLOG(0, " Foreign Key Case #2\n"); escTableName = simpleCatalogEscape((SQLCHAR *) fk_table_needed, SQL_NTS, conn); schema_str(schema_needed, sizeof(schema_needed), szFkTableOwner, cbFkTableOwner, TABLE_IS_VALID(szFkTableName, cbFkTableName), conn); relqual = "\n and conrelid = c.oid"; } /* * Case #1 -- Get the foreign keys in other tables that refer to the * primary key in the specified table (pktab). i.e., Who points to * me? */ else if (NULL != pk_table_needed) { escTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, conn); schema_str(schema_needed, sizeof(schema_needed), szPkTableOwner, cbPkTableOwner, TABLE_IS_VALID(szPkTableName, cbPkTableName), conn); relqual = "\n and confrelid = c.oid"; } else { SC_set_error(stmt, STMT_INTERNAL_ERROR, "No tables specified to PGAPI_ForeignKeys.", func); goto cleanup; } if (NULL != CurrCat(conn)) SPRINTF_FIXED(catName, "'%s'::name", CurrCat(conn)); else STRCPY_FIXED(catName, "NULL::name"); STRCPY_FIXED(scmName1, "n2.nspname"); STRCPY_FIXED(scmName2, "n1.nspname"); escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn); initPQExpBuffer(&tables_query); #define return DONT_CALL_RETURN_FROM_HERE??? printfPQExpBuffer(&tables_query, "select" " %s as \"PKTABLE_CAT\"" ",\n %s as \"PKTABLE_SCHEM\"" ",\n c2.relname as \"PKTABLE_NAME\"" ",\n a2.attname as \"PKCOLUMN_NAME\"" ",\n %s as \"FKTABLE_CAT\"" ",\n %s as \"FKTABLE_SCHEM\"" ",\n c1.relname as \"FKTABLE_NAME\"" ",\n a1.attname as \"FKCOLUMN_NAME\"" ",\n i::int2 as \"KEY_SEQ\"" ",\n case ref.confupdtype" "\n when 'c' then %d::int2" "\n when 'n' then %d::int2" "\n when 'd' then %d::int2" "\n when 'r' then %d::int2" "\n else %d::int2" "\n end as \"UPDATE_RULE\"" ",\n case ref.confdeltype" "\n when 'c' then %d::int2" "\n when 'n' then %d::int2" "\n when 'd' then %d::int2" "\n when 'r' then %d::int2" "\n else %d::int2" "\n end as \"DELETE_RULE\"" ",\n ref.conname as \"FK_NAME\"" ",\n cn.conname as \"PK_NAME\"" ",\n case" "\n when ref.condeferrable then" "\n case" "\n when ref.condeferred then %d::int2" "\n else %d::int2" "\n end" "\n else %d::int2" "\n end as \"DEFERRABILITY\"" "\n from" "\n (((((((" " (select cn.oid, conrelid, conkey, confrelid, confkey" ",\n generate_series(array_lower(conkey, 1), array_upper(conkey, 1)) as i" ",\n confupdtype, confdeltype, conname" ",\n condeferrable, condeferred" "\n from pg_catalog.pg_constraint cn" ",\n pg_catalog.pg_class c" ",\n pg_catalog.pg_namespace n" "\n where contype = 'f' %s" "\n and relname %s'%s'" "\n and n.oid = c.relnamespace" "\n and n.nspname %s'%s'" "\n ) ref" "\n inner join pg_catalog.pg_class c1" "\n on c1.oid = ref.conrelid)" "\n inner join pg_catalog.pg_namespace n1" "\n on n1.oid = c1.relnamespace)" "\n inner join pg_catalog.pg_attribute a1" "\n on a1.attrelid = c1.oid" "\n and a1.attnum = conkey[i])" "\n inner join pg_catalog.pg_class c2" "\n on c2.oid = ref.confrelid)" "\n inner join pg_catalog.pg_namespace n2" "\n on n2.oid = c2.relnamespace)" "\n inner join pg_catalog.pg_attribute a2" "\n on a2.attrelid = c2.oid" "\n and a2.attnum = confkey[i])" "\n left outer join pg_catalog.pg_constraint cn" "\n on cn.conrelid = ref.confrelid" "\n and cn.contype = 'p')" , catName , scmName1 , catName , scmName2 , SQL_CASCADE , SQL_SET_NULL , SQL_SET_DEFAULT , SQL_RESTRICT , SQL_NO_ACTION , SQL_CASCADE , SQL_SET_NULL , SQL_SET_DEFAULT , SQL_RESTRICT , SQL_NO_ACTION , SQL_INITIALLY_DEFERRED , SQL_INITIALLY_IMMEDIATE , SQL_NOT_DEFERRABLE , relqual , eq_string, escTableName , eq_string, escSchemaName); free(escSchemaName); if (NULL != pk_table_needed && NULL != fk_table_needed) { free(escTableName); escTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, conn); appendPQExpBuffer(&tables_query, "\n where c2.relname %s'%s'", eq_string, escTableName); } appendPQExpBufferStr(&tables_query, "\n order by ref.oid, ref.i"); if (PQExpBufferDataBroken(tables_query)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in PGAPI_SpecialColumns()", func); goto cleanup; } if (res = CC_send_query(conn, tables_query.data, NULL, READ_ONLY_QUERY, stmt), !QR_command_maybe_successful(res)) { SC_set_error(stmt, STMT_EXEC_ERROR, "PGAPI_ForeignKeys query error", func); QR_Destructor(res); goto cleanup; } SC_set_Result(stmt, res); ret = SQL_SUCCESS; cleanup: #undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ if (SQL_SUCCEEDED(ret)) { stmt->status = STMT_FINISHED; extend_column_bindings(SC_get_ARDF(stmt), QR_NumResultCols(res)); } if (pk_table_needed) free(pk_table_needed); if (escTableName) free(escTableName); if (fk_table_needed) free(fk_table_needed); if (!PQExpBufferDataBroken(tables_query)) termPQExpBuffer(&tables_query); /* set up the current tuple pointer for SQLFetch */ stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); MYLOG(0, "leaving stmt=%p, ret=%d\n", stmt, ret); return ret; } psqlodbc-REL-16_00_0005/inouealc.c000066400000000000000000000122171462406103600164440ustar00rootroot00000000000000#undef _MEMORY_DEBUG_ #include "psqlodbc.h" #ifndef _MIMALLOC_ #ifdef WIN32 #ifdef _DEBUG /* #include */ #define _CRTDBG_MAP_ALLOC #include #else #include #endif /* _DEBUG */ #endif /* WIN32 */ #endif /* _MIMALLOC_ */ #include #include "misc.h" typedef struct { size_t len; void *aladr; } ALADR; static int alsize = 0; static int tbsize = 0; static ALADR *altbl = NULL; CSTR ALCERR = "alcerr"; void * pgdebug_alloc(size_t size) { void * alloced; alloced = pg_malloc(size); MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size); if (alloced) { if (!alsize) { alsize = 100; altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR)); } else if (tbsize >= alsize) { ALADR *al; alsize *= 2; if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al) return alloced; altbl = al; } altbl[tbsize].aladr = alloced; altbl[tbsize].len = size; tbsize++; } else MYLOG(0, "%s:alloc " FORMAT_SIZE_T "byte\n", ALCERR, size); return alloced; } void * pgdebug_calloc(size_t n, size_t size) { void * alloced = pg_calloc(n, size); if (alloced) { if (!alsize) { alsize = 100; altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR)); } else if (tbsize >= alsize) { ALADR *al; alsize *= 2; if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al) return alloced; altbl = al; } altbl[tbsize].aladr = alloced; altbl[tbsize].len = n * size; tbsize++; } else MYLOG(0, "%s:calloc " FORMAT_SIZE_T "byte\n", ALCERR, size); MYLOG(2, "calloced = %p\n", alloced); return alloced; } void * pgdebug_realloc(void * ptr, size_t size) { void * alloced; if (!ptr) return pgdebug_alloc(size); alloced = pg_realloc(ptr, size); if (!alloced) { MYLOG(0, "%s %p error\n", ALCERR, ptr); } else /* if (alloced != ptr) */ { int i; for (i = 0; i < tbsize; i++) { if (altbl[i].aladr == ptr) { altbl[i].aladr = alloced; altbl[i].len = size; break; } } } MYLOG(2, "%p->%p\n", ptr, alloced); return alloced; } char * pgdebug_strdup(const char * ptr) { char * alloced = pg_strdup(ptr); if (!alloced) { MYLOG(0, "%s %p error\n", ALCERR, ptr); } else { if (!alsize) { alsize = 100; altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR)); } else if (tbsize >= alsize) { ALADR *al; alsize *= 2; if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al) return alloced; altbl = al; } altbl[tbsize].aladr = alloced; altbl[tbsize].len = strlen(ptr) + 1; tbsize++; } MYLOG(2, "%p->%p(%s)\n", ptr, alloced, alloced); return alloced; } void pgdebug_free(void * ptr) { int i, j; int freed = 0; if (!ptr) { MYLOG(0, "%s null ptr\n", ALCERR); return; } for (i = 0; i < tbsize; i++) { if (altbl[i].aladr == ptr) { for (j = i; j < tbsize - 1; j++) { altbl[j].aladr = altbl[j + 1].aladr; altbl[j].len = altbl[j + 1].len; } tbsize--; freed = 1; break; } } if (! freed) { MYLOG(0, "%s not found ptr %p\n", ALCERR, ptr); return; } else MYLOG(2, "ptr=%p\n", ptr); pg_free(ptr); } static BOOL out_check(void *out, size_t len, const char *name) { BOOL ret = TRUE; int i; for (i = 0; i < tbsize; i++) { if ((ULONG_PTR)out < (ULONG_PTR)(altbl[i].aladr)) continue; if ((ULONG_PTR)out < (ULONG_PTR)(altbl[i].aladr) + altbl[i].len) { if ((ULONG_PTR)out + len > (ULONG_PTR)(altbl[i].aladr) + altbl[i].len) { ret = FALSE; MYLOG(0, "%s:%s:out_check found memory buffer overrun %p(" FORMAT_SIZE_T ")>=%p(" FORMAT_SIZE_T ")\n", ALCERR, name, out, len, altbl[i].aladr, altbl[i].len); } break; } } return ret; } char *pgdebug_strcpy(char *out, const char *in) { if (!out || !in) { MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, strlen(in) + 1, __FUNCTION__); return strcpy(out, in); } char *pgdebug_strncpy(char *out, const char *in, size_t len) { if (!out || !in) { MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, len, __FUNCTION__); return strncpy(out, in, len); } char *pgdebug_strncpy_null(char *out, const char *in, size_t len) { if (!out || !in) { MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, len, __FUNCTION__); strncpy_null(out, in, len); return out; } void *pgdebug_memcpy(void *out, const void *in, size_t len) { if (!out || !in) { MYLOG(0, "%s null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, len, __FUNCTION__); return memcpy(out, in, len); } void *pgdebug_memset(void *out, int c, size_t len) { if (!out) { MYLOG(0, "%s null pointer out=%p\n", ALCERR, out); return NULL; } out_check(out, len, __FUNCTION__); return memset(out, c, len); } void debug_memory_check(void) { int i; if (0 == tbsize) { MYLOG(0, "no memry leak found and max count allocated so far is %d\n", alsize); pg_free(altbl); alsize = 0; } else { MYLOG(0, "%s:memory leak found check count=%d alloc=%d\n", ALCERR, tbsize, alsize); for (i = 0; i < tbsize; i++) { MYLOG(0, "%s:leak = %p(" FORMAT_SIZE_T ")\n", ALCERR, altbl[i].aladr, altbl[i].len); } } } psqlodbc-REL-16_00_0005/installer/000077500000000000000000000000001462406103600164735ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/installer/README.txt000066400000000000000000000020231462406103600201660ustar00rootroot00000000000000This directory contains the psqlODBC installer for Windows. To build the installer, you will need a copy of WiX installed somewhere in your system path. The installer has been tested with WiX version 3.0.2420 and WiX 3.8 at the time writing. WiX may be downloaded from: http://wix.codeplex.com/ Two parallel systems to build the installers are currently provided: POWERSHELL BASED ---------- Ensure that suitable binaries are in the parent directory Release build outputs (see ..\winbuild for that). .\buildInstallers.ps1 For help: Get-Help .\buildInstallers.ps1 If you get execution policy errors: Set-ExecutionPolicy RemoteSigned and try again. Note that these installer generators use the configuration file prepared by the PowerShell scripts in ..\winbuild, defaulting to ..\winbuild\configuration.xml, so you can't just mix them with SDK- or NMake based compilation. NMAKE BASED ----------- Use the top-level file (win64.mak), per the documentation in docs/win32-compilation.html, to build installers using NMake. psqlodbc-REL-16_00_0005/installer/background.bmp000066400000000000000000004602661462406103600213300ustar00rootroot00000000000000BM`6(8\      "" !%"$%"%%$$(%'*(**(*-*,,*-.,-1//202538766976:88:99<:;?<=>==@>AA??B@@BAADBDDCBFDDFDDHEGJHILJMPNQQNNQPPRQQURRVTUVUUXVXXWVYXYZYZ\Z\\[Z^\]^]`_^]a^aa__a`aa`adacgdeeddhefjhjljmpnppnnqppsrrurtvuuxvwyxxzyz|z|}{{~}|~}~~Ñɖ˘̘   "# *',(.+0-6296=9A=A>C@ECIEMJRNUR 55VTYV\Yb_dajgjhnkqntryw}zkk~~________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[__________________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[_______________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\]_ͬ_]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[____________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\_Ӳ_\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[______________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[___________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[_____________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\Ӳ____]\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[__________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\]_\\\\\\\\\]__\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[___________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\_\\\\\\\\\\\\\\]__\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\__\\\\\\\\\\\\\\\\\\_]\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[__________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\_\\\\\\\\\\\\\\\\\\\\]\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[_______________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[_________________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\]\\\\\\\\\\\\\\\\\\\\\\\]\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[______________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\]\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_______________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\_]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[______________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[___________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[___________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[______________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]_[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Z_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_][[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[\_[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[_[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[_[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\______\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[_[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]_ִ_]\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[_][[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZ____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]___]]]]]]]]]]]]]]]\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[]][[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZ_____________]]]]]]]]]]]]]]]]]]]]]]]]]]]]_]]]]]]]]]_]\__\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[\_[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZ__________]]]]]]]]]]]]]]]]]]]]]]]]]]__]]]]]]____\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZ___________]]]]]]]]]]]]]]]]]]]]]]]]]_]]]]]__]\\\\___\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZ________]]]]]]]]]]]]]]]]]]]]]]]]]]]__\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZ__________]]]]]]]]]]]]]]]]]]]]]]]_]]__]]_]\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[۶Ӳ_[[[[ZZZZZZZZZZZZZ________]]]]]]]]]]]]]]]]]]]]]]_]]]]]]_]_Ӳ_]\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[_\ZZZZZZZZZZZZZ__________]]]]]]]]]]]]]]]]]]]]]__]]]]]]]]_]_]\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[_]ZZZZZZZZZZZ________]]]]]]]]]]]]]]]]]]]]]_]]]]]]]]]]_\__\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[_]ZZZZZZZZZ__________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\_\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[\___[[[____ZZZZZZZZ________]]]]]]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]\\\\]_\\\\\\\\__\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[\_[[[[[[[[[[[[[___ZZZZZZ__________]]]]]]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]\\\\\\\\\_\\\\\\\__\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[\_[[[[[[[[[[[[[[[Z\_ZZZZZ________]]]]]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]]_\\\\\\\\\\_\\\\\\_]\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[\_[[[[[[[[[[[[[[ZZZZ\_ZZZZ__________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]__\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZ__ZZZ________]]]]]]]]]]]]]]]]]__]]]]]]]]]]]]]]]]]\\__\\\\\\\\\\__\\\_\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[][[[[[[_Ͷ_\[ZZZ__________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\__\\\\\\\\\\__]\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[__[[[ZZ________]]]]]]]]]]]]]]]]__]]]]]]]]]]]]]]]]]\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[ZZ__________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\_\\\_\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[\ZZ________]]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]]]\\\\\\\]__\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[_ʶ__ZZZ__________]]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]]\\\\\\\\\]_\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[_[ZZZZZZZZZZ\__ͬZZZZ________]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]]]\\\\\\\\\\]]_\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[][ZZZZZZZZZZZZZZZZZZZZZZ__________]]]]]]]]]]]]]]_]]]]]]]]]]]]]]]]\\\\\\\\\\\\___]_]\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZ________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[__ZZZZZZZZZZZZZZZZZZZZZZ__________]]]]]]]]]]]]]__]]]]]]]]]]]]]]]]\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[\[YYYYYYYYYYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\]_\\\\\\\\\__\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_YYYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[]YYYYYYYYYYYYYYYYYYYY________]]]]]]]]]]]]__]]]]]]]]]]]]]]]\\\\\\\\\\\_]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[]__YYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\_\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[Y_YYYYYYYYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[\]\YYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]__]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[]Y__YYYYYYYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\__\\\\\\\\\\\\\\\\]\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[][YY\YYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_[_[Y_YYYYYYYYYYYYYYYYY________]]]]]]]]]]__]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_[[[_YY[YYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[][[YYY_YYYYYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\__\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_[[YYYYY[YYYYYYYYYYYYYYY__________]]]]]]]]]__]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[YYYYYY_YYYYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[_[[YYYYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_]\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[YYYYYYYY__YYYYYYYYYYYYYY________]]]]]]]]__]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[__[[YYYYYYYYYYYYYYYYYYYYYYY__________]]]]]]]]__]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[YYYYYYYYYY__YYYYYYYYYYYYY________]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[__[YYYYYYYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[YYYYYYYYYYYY__YYYYYYYYYYYY________]]]]]]]__]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[__[ZYYYYYYYYYYYYYYYYYYYYYYYYY__________]]]]]]]_]]]]]]]]]]\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\_\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZYYYYYY_YYYYYYY]YYYYYYYYYYY________]]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[[[[_[ZZYYYYYY_YYYYYYY\YYYYYYYYYYY__________]]]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[[[[\ZZZYYYYY[\YYYYYYYYYYYYYYYYYYY________]]]]]]__]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\]\[[[[[[[[[[[[[[[[[[[[[[[[[[[]ZZZZYYYYY_YYYYYYYYY]_YYYYYYYYYY__________]]]]]]_]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[\ZZZZYYYYY_YYYYYYYYYYYYYYYYYYYY________]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZYYYYY_YYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[__ZZZZZYYYYYYYYYYYYYYY\YYYYYYYYY________]]]]]__]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY__________]]]]]_]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZYYYYYYYYYYYYYYYY_]YYYYYYYY________]]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[\_ZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________]]]]]_]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZYYYYYYYYYYYYYYYYY_]YYYYYYY__________]]]]__]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________]]]]_]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\[_[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZZZZZYYYYY_YYYYYYYYYYYYYYYYYYYY__________]]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\[_\[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZZZZZYYYYY_YYYYYYYYYYYYY_\YYYYYY________]]]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\_]\\[_[[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZZZZZYYYYYY]YYYYYYYYYYYYY_YYYYYY__________]]]]_]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\__[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZZZZZYYYYYY_YYYYYYYYYYYYYYYYYYY________]]]]_]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\]][[[[[[[[[[[[[[[[[[[[[[[[[[[[_ZZZ[_YYYYYYYYYYYYYYYYYYYYYYYY__________]]]_]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\_]_[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZ\YYYYYYYYYYYYYYYYY\_YYYYY________]]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\[\[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZ_YYYYYYYYYYYYYYYYYYYYYY__________]]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\__[[][[[[[[[[[[[[[[[[[[[[[[[[[[ZZ__Z__YYYYYYYYYYYYYYYYYYYYYY________]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\[[__[[[[[[[[[[[[[[[[[[[[[[[[[ZZZ\_ZZ__YYYY_YYYYYYYYYYYYYY_YYYYY__________]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\\]_[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZ\ZZZYYYYYY_YYYYYYYYYYYYYY\\YYYY________]]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZ۶____YYYYYYYYYYYYYYY_YYYY__________]]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZ\YYYYYYYYYYYYYYYYYYY________]]_]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZYYYYYYYYYYYYYYYYYYY__________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_Ӭ][[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZ]YYYYYYYYYYYYYYY_YYYY________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]__[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZ_YYYYYYYYYYYYYYY_YYYY__________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZYYYYY\_YYYYYYYYYYYYYYYY_YYY________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZYYYYY[YYYYYYYYYYYYYYYY_YYY__________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZYYYY__YYYYYYYYYYYYYYYYYYYY__________]]]]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________]]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZYYY__YYYYYYYYYYYYYYYYYYYYY__________]\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZYY__YYYYYYYYYYYYYYYYYYY_YYY__________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZY\YYYYYYYYYYYYYYYYYYYY_YYY________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZY_YYYYYYYYYYYYYYYYYYYY_YYY__________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZ_YYYYYYYYYYYYYYYYYYYYYYYY________\\\_]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZ\\YYYYYYYYYYYYYYYYYYYYYYYY__________\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYY________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYYYYYYX__________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZ_[YYYYYYYYYYYYYYYYYYYYYYYYYX________\\\\__\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZ__YYYYYYYYYYYYYYYYYYYYYYY\_YXX__________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZ\YYYYYYYYYYYYYYYYYYYYYYYYYXXX________\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZ\YYYYYYYYYYYYYYYYYYYYYYYY\YXXX__________\\\\\]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[_[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZ\YYYYYYYYYYYYYYYYYYYYYYYYY\XXXX________\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[_[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZ_[YYYYYYYYYYYYYYYYYYYYYYYYYXXXX__________\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[_][[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZ[ZYYYYYYYYYYYYYYYYYYYYYYYYXXXXX________\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[][[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZ[ZZYYYYYYYYYYYYYYYYYYYYYY_XXXXXX__________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[\][[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZ_\ZZZYYYYYYYYYYYYYYYYYYYYY_YXXXXXX________\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[]][[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYY\YXXXXXXX__________\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[_][[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZ__ZZZZZZYYYYYYYYYYYYYYYYYY__YXXXXXXXX___]____\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[]_[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZ__ZZZZZZZYYYYYYYYYYYYYYYYY_YYXXXXXXXX___]]]_____\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[__[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZ_[ZZZZZZZZYYYYYYYYYYYYYYY_\YYXXXXXXXXX_]]]\]____\\\\\\\\\\\\__\\\\\\\\\\\\\\\\\\[[[[[[[__[[[[[[[[[[ZZZZZZZZZZZZZZ_]ZZZZZZZZZZYYYYYYYYYYYYY_YYYYXXXXXXXXX_]]]\]]]_____\\\\\\\\\\\\\___\\\\\\\\\\\\\\[]_۬_[[[[[[ZZZZZZZZZZZ__ZZZZZZZZZZZZYYYYYYYYYY[YYYYXXXXXXXXXX_]\]]]]\____\\\\\\\\\\\\\\\Ь__ͬ___________ZZZZZZZZZZZZZZYYYYYYY\[YYYYXXXXXXXXXXX_\]]]\]]_____\\\\\\\\\\\\\\\\]۲_[[[[\_\ZZZZZZZZZZZZZYYY\__YYYYYXXXXXXXXXXXX_]]]\]]]____\\\\\\\\\\\\\\\\\\]_][[[[[[[[[\ʴ______YYYYYYYXXXXXXXXXXXX_]\]]]]\]____\\\\\\\\\\\\\\\\\\\\\_ֶ_\[[[[[[[[[[[[[[[[__YYYYYYYYXXXXXXXXXXXXX_]]\]]\]]\]]_\\\\\\\\\\\\\\\\\\\\\\\\\__Ӷ__[[[[[[[[[[[[[[[[[[[[[[[[[_۶_]ZZ]ӨYYYYYYYYYYYXXXXXXXXXXXXX_]\]]\]]]]\]]\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Z[[[[[[[[ZZZZZZZZZZZZ__Ӳ_[YYYYYYYYYYYYXXXXXXXXXXXXXX_\]]\]]\]\]\]\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZZZ\__Ͳ__\YYYYYYYYYYYYYYYYXXXXXXXXXXXXXXX_]]\]]\]]\]]\]]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYYXXXXXXXXXXXXXXX_\]\]\]\]\]\]\]_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZYYYYYYYYYYYYYYYYYYYXXXXXXXXXXXXXXXX_]\]\]\]]\]\]\]\]\]\]\]\]\]\]]\]\]\]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]________________________________________]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\________________________________________]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]_______________________________________]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]____________________________________]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]__________________________________]]\]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]]\]\]\]\]\\]\\\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]________________________________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\_____________________________\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\___________________________\]\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\\\\\]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_________________________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]\\]\\\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]________________________\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\\\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\______________________\\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\____________________]\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__________________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\________________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\______________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\____________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\___________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_________\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_______\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_____\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\___\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\\\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[_\\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[___\\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[____\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\_____\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\_____\\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\\[\_______\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[\[[_______[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[__________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[__________[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[_________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z[Z_________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[_________________________________________________________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[___________________________________________________________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[_________________________________________________________[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[Y[__________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY___________________________________________________YYYY[YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY___________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY________________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY___________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY__________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY____________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY______________________________________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_____________________________YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY_______________________________________________________YXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYX_______________________________YXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXY_________________________________________________________YXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYX________________________________YXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYY__________________________________________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX__________________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX____________________________________________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX___________________________ʗ_________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX___________________________________ʗ________________XXXXXXXXXXXXXXXXXXXXXXXXXXX_____________________________ʗ_________XXXXXXXXXXXXXXXXXXXXXXXX____________________________________ʗ_______________________XXXXXXXXXXXXXXXXXXXXX_________________________________________XXXXXXXXXXXXXXXXXX_____________________________________________________________XXXXXXXXXXXXXX____________________________________________XXXXXXXX___________________________________________________________________XX_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ʗ_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________ʗ_____________________________________________________________________________________________________________________ʗ______________________________________________________ʗ____________________________________________________________________ʗ_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ʗ____________________________________________________________ʗʗ__________________________________________________________ʗ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________psqlodbc-REL-16_00_0005/installer/banner.bmp000066400000000000000000002476061462406103600204570ustar00rootroot00000000000000BMO6(:POB B ʖʖɖɖɖɖɖɖɖɖɖȕȕȕȕȕȕȕȕǕǕǕǕǕǔǔǔǔƔƔƔƔƔƔƔ͡jעʃӯBĔēĒĒqqÒÒÒÒÒÒÑё‘‘‘‘‘‘‘ʡ(ʖʖɖɖɖɖɖɖɖɖȖȕȕȕȕȕȕȕȕǕǕ΢ ݿfʀlҩ3ǔƔƔƔƔƔƔӬ:ܿgŕĒqqÒÒÒÒÒÑё‘‘‘‘‘‘‘‘ƙʖɖɖɖɖɖɖɖɖɖȕȕȕȕȕȕȕȕǕ˞՚ϥ*ƔƔƔƔoϧ2qqÒÒÒÒÒÑё‘‘‘‘‘‘‘ɖɖɖɖɖɖɖɖɖȕȕȕȕȕȕȕȕǕϣ#״LƔƔ͢!̇Ӯ@˟œœœǗ Υ,ܿiqÒÒÒÒÑё‘‘‘‘‘‘‘‘ÖɖɖɖɖɖɖɖɖȖȕȕȕȕȕȕȕȕӫ7ύܼaʁѨ1Ɣܾeڻ`ɜœœœœœēēēēҭ>qÒÒÒÒё‘‘‘‘‘‘‘‘ټfyԝԝԝԝԝˉټgΪ=•ɖɖɖɖɖɖɖɖȕȕȕȕȕȕȕȕ̝ϣ%ǔǔǔʛЦ-͢"ҕֳMɛœēēēĒĒǘ٧qÒÒÒÑё‘‘‘‘‘‘‘ї{Ƞ'ɖɖɖɖɖɖɖȖȕȕȕȕȕȕȕȕ߲ə ǔǔǔƔƔʛ˝ձFܬϨ1ēĒĒĒĒēکqÒÒÑё‘‘‘‘‘‘‘‘ʅۯˤ3ɖɖɖɖɖɖȖȕȕȕȕȕȕȕȕڸU΢ ǔǔǔƔƔƔƔʛǖƕִNБqĒĒĒĒĒǘqÒÒё‘‘‘‘‘‘‘‘ָ\tЭD̤1ĘřЭDӲOzڬ̍•ɖɖɖɖɖɖȕȕȕȕȕȕȕȕ˛ڹWǔǔǔǔƔƔƔƔƔΤ'ݮœœœœ˞ں]՜ۼdĒĒĒÒÒyqÒÑё‘‘‘‘‘‘‘ָ\ʆƝ Ȅɢ.ɖɖɖɖɖȖȕȕȕȕȕȕȕȕΉǕǔǔǔƔƔƔƔƔƔƔҬ9΍œœœœœēț֟Ҭ?ĒĒÒÒʃ۾gÑё‘‘‘‘‘‘‘‘ԳRΏ ~ѰNɖɖɖɖɖȕȕȕȕȕȕȕȕΡЦ*ǔǔǔǔƔƔƔƔƔƔƔƓضRܿhœœœœēēēؤ̠"ÒÒĔͥ,Ñё‘‘‘‘‘‘‘ǝ ×ƜҰLҰMȟ'ś ɢ.Ǡ(ɖɖɖɖȕȕȕȕȕȕȕȕǕЎђǔǔǔǔƔƔƔƔƔƔƔƔœœk׵PœœēēēĒŔЩ6̣)ݱÒё‘‘‘‘‘‘‘‘ҙ•ƛДګΑݳɖɖɖȖȕȕȕȕȕȕȕȕʛ̟ǔǔǔƔƔƔƔƔƔƔƔƓœœœҕӭ?ēēēēϧ0ִQuϨ4ё‘‘‘‘‘‘‘‘ԳR潎ɖɖɖȕȕȕȕȕȕȕȕǕʀ۩ǔǔǔǔƔƔƔƔƔƔƔƔœœœœœҭ>Φ-єղLÑё‘‘‘‘‘‘‘ǁЕϔȃɖɖȖȕȕȕȕȕȕȕȕȗЦ*ǔǔǔƔƔƔƔƔƔƔƔœœœœœœǗ ɁɝÑё‘‘‘‘‘‘‘‘̦5بǞ#–˦6ָ`|̌ҳTɖȖȕȕȕȕȕȕȕȕǕںYǔǔǔƔƔƔƔƔƔƔƔƓœœœœœœœǖ єܿjțÒÒÒÑё‘‘‘‘‘‘‘ұNͧ8ɖȕȕȕȕȕȕȕȕǕǕضQǔǔǔƔƔƔƔƔƔƔƔœœœœœœœœֳK{țĒĒĒ̉vÒÒÑё‘‘‘‘‘‘‘‘ƜʾȖȕȕȕȕȕȕȕȕǕ͡ȗǔǔƔƔƔƔƔƔƔƔƓœœœœœœœձI̡$ĒĒĒĒÒϨ5ÒÒё‘‘‘‘‘‘‘‘rȕȕȕȕȕȕȕȕǕǕqώǔǔƔƔƔƔƔƔƔƔƓœœœœœœœ˞ܭŔĒĒĒĒÒÒÓʟ Ñё‘‘‘‘‘‘‘tӜΪ>ĘȕȕȕȕȕȕȕǕǕǕХ)ǔǔƔƔƔƔƔƔƔƔœœœœœœœœŔĒĒĒĒĒÒÒÒ͋ʅё‘‘‘‘‘‘‘‘ƛǞ#֣ҚȕȕȕȕȕȕȕǕǕЧ,ǔǔƔƔƔƔƔƔƔƔƓœœœœœœœӭ?țĒĒĒĒĒÒÒÒỌ̀(ŕ ‘‘‘‘‘‘‘‘ДЕƜ ɢ/ȕȕȕȕȕȕǕǕǕ˃ǔǔƔƔƔƔƔƔƔƔœœœœœœœœܿhĒĒĒĒĒÒÒÒÒÒÒع^‘‘‘‘‘‘‘Śͨ:޾wỾȕȕȕȕȕǕǕǕǕЦ+ǔƔƔƔƔƔƔƔƔœœœœœœœœ̡!ŖĒĒĒĒĒÒÒÒÒÒÒԱH‘‘‘‘‘‘‘ϒӛɢ. ѰNȕȕȕȕȕǕǕǕϥ&ǔƔƔƔƔƔƔƔƔƓœœœœœœœœ۽d΍ĒĒĒĒĒÒÒÒÒÒÒÒēͦ0‘‘‘‘‘ɡ*ƛ|ػfػgϽȕȕȕȕǕǕǕǕr}ǔƔƔƔƔƔƔƔƔœœœœœœœœœ֟ղKĒĒĒĒĒÒÒÒÒÒÒÑÑpѕ‘‘‘‘٩ДѰMΒҲQȕȕȕȕǕǕǕǕӫ9ƔƔƔƔƔƔƔƔƓœœœœœœœœēǙĒĒĒĒÒÒÒÒÒÒÑёƙ’‘‘‘˥2ÖǞ%ڬԴW̽ȕȕȕǕǕǕǕ˞ǔƔƔƔƔƔƔƔƔœœœœœœœœœēēĒĒĒÒÒÒÒÒÒÒÑё‘Χ4‘‘}Ɯ¾̨<ȕȕǕǕǕǕǕٷT՛ƔƔƔƔƔƔƔƔœœœœœœœœœēŖĒĒĒĒÒÒÒÒÒÒÑё‘‘{v‘‘ϫA” Ɯ¾շ^๽ȕȕǕǕǕǕǔ՛ں[ƔƔƔƔƔƔƔƓœœœœœœœœēēĔœĒĒÒÒÒÒÒÒÒё‘‘‘Ѭ@ئ‘ָ]Ɯ߶˦9ȕǕǕǕǕǔǔ˝ƔƔƔƔƔƔƔœœœœœœœœœēēēƖ ĒÒÒÒÒÒÒÒÑё‘‘‘ǚϬCΪ@ϔvԟȕǕǕǕǕǔ˝ƔƔƔƔƔƔƔƓœœœœœœœœēēēĒ˟ĒÒÒÒÒÒÒÑё‘‘‘‘’ڭغcҲR×ǕǕǕǕǔǔٸVΌƔƔƔƔƔƔƓœœœœœœœœēēēēĒڪѪ8ÒÒÒÒÒÒÒё‘‘‘‘‘‘ʣ/{ػfϕ{ǕǕǕǔǔǔҕ״MƔƔƔƔƔƔœœœœœœœœœēēēĒĒєֳNÒÒÒÒÒÒÑё‘‘‘‘‘‘צ{ʉϮHƞ&轎ǕǕǕǔǔǔʛƔƔƔƔƔƓœœœœœœœœēēēĒĒĒ|۽fÒÒÒÒÒÑё‘‘‘‘‘‘‘ǛĘ•٪˧8ϮJǕǕǔǔǔΡ ƔƔƔƔƔƓœœœœœœœœœēēēĒĒĒ۽e۽fÒÒÒÒÒÑё‘‘‘‘‘‘‘“ڿmӚ߸ո`קǕǔǔǔǔۻ]ЏƔƔƔƔƔœœœœœœœœœēēēĒĒĒĒֳMВÒÒÒÒÑё‘‘‘‘‘‘‘‘Ϊ= Ǖǔǔǔǔأ״MƔƔƔƔƓœœœœœœœœēēēēĒĒĒĒֳMєÒÒÒÒё‘‘‘‘‘‘‘‘’ę侏 Ӟոaǔǔǔǔǔ˞ƔƔƔƔœœœœœœœœœēēēĒĒĒĒĒֳMєÒÒÒÑё‘‘‘‘‘‘‘ŘԴTј뾐˦9޶ǔǔǔǔɘ ƔƔƔƔƓœœœœœœœœēēēĒĒĒĒĒĒճMєÒÒÑё‘‘‘‘‘‘‘‘ˢ)͏ӳS ǔǔǔƔѩ3ݮƔƔƔƓœœœœœœœœēēēēĒĒĒĒĒÒظYɀÒÒÑё‘‘‘‘‘‘‘յSΎƜ! ԟֹdǔǔǔƔܾf|ƔƔƔœœœœœœœœœēēēĒĒĒĒĒĒÒ|۽fÒÑё‘‘‘‘‘‘‘‘}ٻd٪ʤ3ϮJ۰ǔǔƔƔӘֲIƔƔƓœœœœœœœœēēēĒĒĒĒĒĒÒÒ|۽fÒё‘‘‘‘‘ĕ ׸Zpȝܰϩ:ȄӳUǔƔƔƔ˝ƔƓœœœœœœœœēēēēĒĒĒĒĒÒÒÒ|۽fÑё‘‘‘‘ɟ ͦ1Ř ɢ/ ֹbw޶ͫEǔƔƔǕƔƔœœœœœœœœœēēēĒĒĒĒĒĒÒÒÒ|עƗ ‘‘‘‘‘‘ګˇˣ-ΫBѰMϮHϔֺfDŽƔƔƔϥ)ޱƔƓœœœœœœœœēēēĒĒĒĒĒĒÒÒÒÒ|ֵS‘‘‘‘‘xȀŗϑبշ\٩˜ś⿼Ɵ*ȻƔƔƔӬ:ӗƔœœœœœœœœœēēēĒĒĒĒĒÒÒÒÒÒ|ع]Ǜ‘‘‘ֶXɟ"ѯKɢ-ٽjצݳ׻f м ƔƔƔܽc}œœœœœœœœœēēēĒĒĒĒĒĒÒÒÒÒÒ|ȁԳOΨ7Ψ7ۿlɃxƝ"רʦ:ƔƔƔ͊ضQœœœœœœœœēēēēĒĒĒĒĒÒÒÒÒÒÒع\ֵTإĘګګutƔƔƔԙѪ5œœœœœœœœēēēĒĒĒĒĒÒÒÒÒÒÒÒճMє‘’ҮEә۾l–צ̪CӟƔƔƔڨ͢#œœœœœœœēēēĒĒĒĒĒĒÒÒÒÒÒÒÑˡ%‘‘‘‘‘Ψ6غ`}٧ԝ{Ь@ĕ ʣ1̍ѼѺƔƔƔ͡#œœœœœœœēēēĒĒĒĒĒÒÒÒÒÒÒÒÑǘ‘‘‘‘‘ƞ%˥6×ǃǂpsqlodbc-REL-16_00_0005/installer/buildInstallers.ps1000066400000000000000000000261571462406103600222730ustar00rootroot00000000000000<# .SYNOPSIS Build all installers of psqlodbc project. .DESCRIPTION Build psqlodbc_x86.msi(msm), psqlodbc_x64.msi(msm). .PARAMETER cpu Specify build cpu type, "both"(default), "x86" or "x64" is available. .PARAMETER AlongWithDrivers Specify when you'd like to build drivers before building installers. .PARAMETER ExcludeRuntime Specify when you'd like to exclude a msvc runtime dll from the installer. .PARAMETER RedistUCRT Specify when you'd like to redistribute Visual C++ 2015(or later) Redistributable. .PARAMETER NoPDB Specify when you'd rather not include PDB files. .PARAMETER BuildConfigPath Specify the configuration xml file name if you want to use the configuration file other than standard one. The relative path is relative to the current directory. .EXAMPLE > .\buildInstallers Build 32bit and 64bit installers. .EXAMPLE > .\buildInstallers x86 Build 32bit installers. .NOTES Author: Hiroshi Inoue Date: July 4, 2014 #> # build 32bit and/or 64bit installers # Param( [ValidateSet("x86", "x64", "both")] [string]$cpu="both", [switch]$AlongWithDrivers, [switch]$ExcludeRuntime, [switch]$RedistUCRT, [switch]$NoPDB, [string]$BuildConfigPath ) [int]$ucrt_version=14 [String]$str_msvcr="msvcr" [String]$str_vcrun="vcruntime" [String]$str_msvcp="msvcp" [String]$msrun_ptn="msvcr|vcruntime" function msvcrun([int]$runtime_version) { [String]$str = if ($runtime_version -lt $ucrt_version) {$str_msvcr} else {$str_vcrun} return $str } function env_vcversion_no() { $viver = $env:VisualStudioVersion if ("$viver" -ne "") { if ("$viver" -match "(\d+)\.0") { return [int]$matches[1] } } return 0 } function toolset_no_to_runtimeversion([int]$toolset_no) { return [int] ($toolset_no / 10) } function runtimeversion_to_toolset_no([int]$runtime_version) { [int]$toolset_no = $runtime_version * 10 if ($runtime_version -eq 14) { # possibly be v141 [int]$vc_ver = 15 if ((env_vcversion_no) -eq $vc_ver) { # v141 $toolseto++ } elseif ((Find-VSDir $vc_ver) -ne "") { # v141 $toolset_no++ } } return $toolset_no } function toolset_no_to_vcversion([int]$toolset_no) { return [int] ($toolset_no / 10 + $toolset_no % 10) } function findRuntime([int]$toolset_no, [String]$pgmvc) { $runtime_version = toolset_no_to_runtimeversion($toolset_no) $vcversion_no = toolset_no_to_vcversion($toolset_no) # where's the dll? [String]$rt_dllname = (msvcrun $runtime_version) + "${runtime_version}0.dll" if ("$pgmvc" -ne "") { $dllspecified = "${pgmvc}\${rt_dllname}" if (Test-Path -Path $dllspecified) { return $dllspecified, "" } } $dllinredist = "${LIBPQBINDIR}\${rt_dllname}" if (Test-Path -Path $dllinredist) { return $dllinredist, "" } if ($env:PROCESSOR_ARCHITECTURE -eq "x86") { $pgmvc = "$env:ProgramFiles" } else { $pgmvc = "${env:ProgramFiles(x86)}" } $dllinredist = "" $vsdir = Find-VSDir $vcversion_no if ("$vsdir" -ne "") { if ($vcversion_no -gt 14) { # VC15 ~ VC?? $lslist = @(Get-ChildItem "${vsdir}VC\Redist\MSVC\*\${CPUTYPE}\Microsoft.VC${toolset_no}.CRT\${rt_dllname}" -ErrorAction SilentlyContinue) if ($lslist.Count -gt 0) { $dllinredist = $lslist[0].FullName } } else { # VC10 ~ VC14 $dllinredist = "${vsdir}VC\redist\${CPUTYPE}\Microsoft.VC${toolset_no}.CRT\${rt_dllname}" } } if (("$dllinredist" -ne "") -and (Test-Path -Path $dllinredist)) { return $dllinredist, "" } else { $messageSpec = "Please specify Configuration.$CPUTYPE.runtime_folder element of the configuration file where msvc runtime dll $rt_dllname can be found" if ($CPUTYPE -eq "x86") { if ($env:PROCESSOR_ARCHITECTURE -eq "x86") { $pgmvc = "${env:SystemRoot}\system32" } else { $pgmvc = "${env:SystemRoot}\syswow64" } } else { if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { $pgmvc = "${env:SystemRoot}\system32" } elseif ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") { $pgmvc = "${env:SystemRoot}\sysnative" } else { throw "${messageSpec}`n$dllinredist doesn't exist unfortunately" } } $dllinsystem = "${pgmvc}\${rt_dllname}" if (-not(Test-Path -Path $dllinsystem)) { throw "${messageSpec}`nneither $dllinredist nor $dllinsystem exists unfortunately" } } return "", $rt_dllname } function buildInstaller([string]$CPUTYPE) { $LIBPQBINDIR=getPGDir $configInfo $CPUTYPE "bin" # msvc runtime psqlodbc links $PODBCMSVCDLL = "" $PODBCMSVPDLL = "" $PODBCMSVCSYS = "" $PODBCMSVPSYS = "" # msvc runtime libpq links $LIBPQMSVCDLL = "" $LIBPQMSVCSYS = "" $pgmvc = $configInfo.Configuration.$CPUTYPE.runtime_folder $runtime_list = @() if (-not $ExcludeRuntime) { $toolset = $configInfo.Configuration.BuildResult.PlatformToolset if ($toolset -match "^v(\d+)") { $toolset_no0 = [int]$matches[1] } else { $toolset_no0 = 100 } $runtime_version0 = toolset_no_to_runtimeversion($toolset_no0) # where's the msvc runtime dll psqlodbc links? if ($runtime_version0 -ge $ucrt_version -and $RedistUCRT) { $script:wRedist=$true } else { $dlls=findRuntime $toolset_no0 $pgmvc $PODBCMSVCDLL=$dlls[0] if ("$PODBCMSVCDLL" -ne "") { Write-Host "psqlodbc picks $PODBCMSVCDLL" $runtime_list += $PODBCMSVCDLL } $PODBCMSVCSYS=$dlls[1] if ("$PODBCMSVCSYS" -ne "") { Write-Host "psqlodbc picks system $PODBCMSVCSYS" $runtime_list += $PODBCMSVCSYS } $PODBCMSVPDLL=$PODBCMSVCDLL.Replace((msvcrun $runtime_version0), $str_msvcp) if ("$PODBCMSVPDLL" -ne "") { $runtime_list += $PODBCMSVPDLL } $PODBCMSVPSYS=$PODBCMSVCSYS.Replace((msvcrun $runtime_version0), $str_msvcp) if ("$PODBCMSVPSYS" -ne "") { $runtime_list += $PODBCMSVPSYS } } # where's the runtime dll libpq links? $msvclist=& ${dumpbinexe} /imports $LIBPQBINDIR\libpq.dll | select-string -pattern "^\s*($msrun_ptn)(\d+)0\.dll" | % {$_.Matches.Groups[2].Value} if ($msvclist -ne $Null -and $msvclist.length -gt 0) { if ($msvclist.GetType().Name -eq "String") { $runtime_version1=[int]$msvclist } else { $runtime_version1=[int]$msvclist[0] } if ($runtime_version1 -eq $runtime_version0) { $toolset_no1 = $toolset_no0 } else { $toolset_no1 = runtimeversion_to_toolset_no($runtime_version1) } if ($runtime_version1 -ge $ucrt_version -and $RedistUCRT) { $script:wRedist=$true } elseif ($runtime_version1 -ne $runtime_version0) { $dlls=findRuntime $toolset_no1 $pgmvc $LIBPQMSVCDLL=$dlls[0] if ("$LIBPQMSVCDLL" -ne "") { Write-Host "LIBPQ picks $LIBPQMSVCDLL" $runtime_list += $LIBPQMSVCDLL } $LIBPQMSVCSYS=$dlls[1] if ("$LIBPQMSVCSYS" -ne "") { Write-Host "LIBPQ picks system $LIBPQMSVCSYS" $runtime_list += $LIBPQMSVCSYS } } } else { $script:wRedist=$true } } Write-Host "CPUTYPE : $CPUTYPE" Write-Host "VERSION : $VERSION" Write-Host "LIBPQBINDIR: $LIBPQBINDIR" if ($env:WIX -ne "") { $wix = "$env:WIX" $env:Path += ";$WIX/bin" } # The subdirectory to install into $SUBLOC=$VERSION.substring(0, 2) + $VERSION.substring(3, 2) # $maxmem=10 $libpqmem=Get-RelatedDlls "libpq.dll" $LIBPQBINDIR for ($i=0; $i -lt $libpqmem.length; ) { if ($runtime_list -contains $libpqmem[$i]) { $libpqmem[$i]=$Null } else { $i++ } } if ($libpqmem.length -gt $maxmem) { throw("number of libpq related dlls exceeds $maxmem") } for ($i=$libpqmem.length; $i -lt $maxmem; $i++) { $libpqmem += "" } [string []]$libpqRelArgs=@() for ($i=0; $i -lt $maxmem; $i++) { $libpqRelArgs += ("-dLIBPQMEM$i=" + $libpqmem[$i]) } if (-not(Test-Path -Path $CPUTYPE)) { New-Item -ItemType directory -Path $CPUTYPE | Out-Null } $PRODUCTCODE = [GUID]::NewGuid() Write-Host "PRODUCTCODE: $PRODUCTCODE" try { pushd "$scriptPath" Write-Host ".`nBuilding psqlODBC/$SUBLOC merge module..." $BINBASE = GetObjbase ".." $INSTBASE = GetObjbase ".\$CPUTYPE" "installer\$CPUTYPE" candle -nologo $libpqRelArgs "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dLIBPQBINDIR=$LIBPQBINDIR" "-dLIBPQMSVCDLL=$LIBPQMSVCDLL" "-dLIBPQMSVCSYS=$LIBPQMSVCSYS" "-dPODBCMSVCDLL=$PODBCMSVCDLL" "-dPODBCMSVPDLL=$PODBCMSVPDLL" "-dPODBCMSVCSYS=$PODBCMSVCSYS" "-dPODBCMSVPSYS=$PODBCMSVPSYS" "-dNoPDB=$NoPDB" "-dBINBASE=$BINBASE" -o $INSTBASE\psqlodbcm.wixobj psqlodbcm_cpu.wxs if ($LASTEXITCODE -ne 0) { throw "Failed to build merge module" } Write-Host ".`nLinking psqlODBC merge module..." light -sval -nologo -o $INSTBASE\psqlodbc_$CPUTYPE.msm $INSTBASE\psqlodbcm.wixobj if ($LASTEXITCODE -ne 0) { throw "Failed to link merge module" } Write-Host ".`nBuilding psqlODBC installer database..." candle -nologo "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dPRODUCTCODE=$PRODUCTCODE" "-dINSTBASE=$INSTBASE" -o $INSTBASE\psqlodbc.wixobj psqlodbc_cpu.wxs if ($LASTEXITCODE -ne 0) { throw "Failed to build installer database" } Write-Host ".`nLinking psqlODBC installer database..." 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" } Write-Host ".`nModifying psqlODBC installer database..." cscript modify_msi.vbs $INSTBASE\psqlodbc_$CPUTYPE.msi if ($LASTEXITCODE -ne 0) { throw "Failed to modify installer database" } Write-Host ".`nDone!`n" } catch [Exception] { Write-Host ".`Aborting build!" throw $error[0] } finally { popd } } $scriptPath = (Split-Path $MyInvocation.MyCommand.Path) $modulePath="${scriptPath}\..\winbuild" Import-Module ${modulePath}\Psqlodbc-config.psm1 $defaultConfigDir=$modulePath $configInfo = LoadConfiguration $BuildConfigPath $defaultConfigDir if ($AlongWithDrivers) { try { pushd "$scriptpath" $platform = $cpu if ($cpu -eq "x86") { $platform = "win32" } ..\winbuild\BuildAll.ps1 -Platform $platform -BuildConfigPath "$BuildConfigPath" if ($LASTEXITCODE -ne 0) { throw "Failed to build binaries" } } catch [Exception] { if ("$_.Exception.Message" -ne "") { Write-Host ("Error: " + $_.Exception.Message) -ForegroundColor Red } else { echo $_.Exception | Format-List -Force } Remove-Module Psqlodbc-config return } finally { popd } } Import-Module ${scriptPath}\..\winbuild\MSProgram-Get.psm1 try { if ($configInfo.Configuration.BuildResult.Date -eq "") { Write-Host "!! Driver dlls haven't been built yet !!" Write-Host "!! Please build driver dlls first !!" return } $dumpbinexe = Find-Dumpbin $wRedist=$false $VERSION = GetPackageVersion $configInfo "$scriptPath/.." if ($cpu -eq "both") { buildInstaller "x86" buildInstaller "x64" Write-Host "wRedist=$wRedist" Remove-Module Psqlodbc-config try { pushd "$scriptPath" psqlodbc-setup\buildBootstrapper.ps1 -version $VERSION -withRedist:$wRedist if ($LASTEXITCODE -ne 0) { throw "Failed to build bootstrapper" } } catch [Exception] { throw $error[0] } finally { popd } } else { buildInstaller $cpu Remove-Module Psqlodbc-config } } catch [Exception] { if ("$_.Exception.Message" -ne "") { Write-Host ("Error: " + $_.Exception.Message) -ForegroundColor Red } else { echo $_.Exception | Format-List -Force } return } finally { Remove-Module MSProgram-Get if (Get-Module Psqlodbc-config) { Remove-Module Psqlodbc-config } } psqlodbc-REL-16_00_0005/installer/installer.mak000066400000000000000000000031471462406103600211670ustar00rootroot00000000000000 # All the driver files that will be included in the installer DRIVER_FILES = ../$(TARGET_CPU)_Unicode_$(CFG)/psqlodbc35w.dll \ ../$(TARGET_CPU)_Unicode_$(CFG)/pgxalib.dll \ ../$(TARGET_CPU)_Unicode_$(CFG)/pgenlist.dll \ ../$(TARGET_CPU)_ANSI_$(CFG)/psqlodbc30a.dll \ ../$(TARGET_CPU)_ANSI_$(CFG)/pgxalib.dll \ ../$(TARGET_CPU)_ANSI_$(CFG)/pgenlista.dll ALL: $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi CANDLE="$(WIX)bin\candle.exe" LIGHT="$(WIX)bin\light" !INCLUDE ..\windows-defaults.mak !IF EXISTS(..\windows-local.mak) !INCLUDE ..\windows-local.mak !ENDIF !MESSAGE determining product code !INCLUDE productcodes.mak !MESSAGE Got product code $(PRODUCTCODE) MSM_OPTS = -dLIBPQBINDIR="$(LIBPQ_BIN)" # Merge module $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm: psqlodbcm_cpu.wxs $(DRIVER_FILES) echo Building Installer Merge Module $(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) $(MSM_OPTS) -o $(TARGET_CPU)\psqlodbcm.wixobj psqlodbcm_cpu.wxs $(LIGHT) -nologo -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbcm.wixobj $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi: psqlodbc_cpu.wxs $(DRIVER_FILES) echo Building Installer $(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) -dPRODUCTCODE=$(PRODUCTCODE) -o $(TARGET_CPU)\psqlodbc.wixobj psqlodbc_cpu.wxs $(LIGHT) -nologo -ext WixUIExtension -cultures:en-us -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi $(TARGET_CPU)\psqlodbc.wixobj cscript modify_msi.vbs $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi clean: -rd /Q /S x64 x86 psqlodbc-REL-16_00_0005/installer/lgpl.rtf000066400000000000000000001351041462406103600201520ustar00rootroot00000000000000{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;} {\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f23\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}MS Mincho{\*\falt MS ??};}{\f28\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}@MS Mincho;} {\f35\froman\fcharset238\fprq2 Times New Roman CE;}{\f36\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f38\froman\fcharset161\fprq2 Times New Roman Greek;}{\f39\froman\fcharset162\fprq2 Times New Roman Tur;} {\f40\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f41\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f42\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f43\fswiss\fcharset238\fprq2 Arial CE;}{\f44\fswiss\fcharset204\fprq2 Arial Cyr;} {\f46\fswiss\fcharset161\fprq2 Arial Greek;}{\f47\fswiss\fcharset162\fprq2 Arial Tur;}{\f48\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f49\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f50\fswiss\fcharset186\fprq2 Arial Baltic;} {\f51\fmodern\fcharset238\fprq1 Courier New CE;}{\f52\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f54\fmodern\fcharset161\fprq1 Courier New Greek;}{\f55\fmodern\fcharset162\fprq1 Courier New Tur;}{\f56\fmodern\fcharset177\fprq1 Courier New (Hebrew);} {\f57\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f58\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f221\fmodern\fcharset0\fprq1 MS Mincho Western{\*\falt MS ??};}{\f219\fmodern\fcharset238\fprq1 MS Mincho CE{\*\falt MS ??};} {\f220\fmodern\fcharset204\fprq1 MS Mincho Cyr{\*\falt MS ??};}{\f222\fmodern\fcharset161\fprq1 MS Mincho Greek{\*\falt MS ??};}{\f223\fmodern\fcharset162\fprq1 MS Mincho Tur{\*\falt MS ??};} {\f226\fmodern\fcharset186\fprq1 MS Mincho Baltic{\*\falt MS ??};}{\f261\fmodern\fcharset0\fprq1 @MS Mincho Western;}{\f259\fmodern\fcharset238\fprq1 @MS Mincho CE;}{\f260\fmodern\fcharset204\fprq1 @MS Mincho Cyr;} {\f262\fmodern\fcharset161\fprq1 @MS Mincho Greek;}{\f263\fmodern\fcharset162\fprq1 @MS Mincho Tur;}{\f266\fmodern\fcharset186\fprq1 @MS Mincho Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0; \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128; \red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}{ \s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \f2\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \sbasedon0 \snext15 Plain Text;}}{\info{\author Administrator}{\operator Administrator} {\creatim\yr2001\mo4\dy3\hr19\min37}{\revtim\yr2001\mo4\dy3\hr19\min44}{\version5}{\edmins1}{\nofpages10}{\nofwords3823}{\nofchars21794}{\*\company The Vale Housing Association}{\nofcharsws0}{\vern8269}}\paperw11906\paperh16838\margl1152\margr1152 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow1\dgvshow1 \jexpand\viewkind4\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd \linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5 \pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \f2\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 { \fs16\loch\af1\hich\af1\dbch\af23 \tab \tab \hich\af1\dbch\af23\loch\f1 GNU LESSER GENERAL PUBLIC LICENSE \par \tab \tab \hich\af1\dbch\af23\loch\f1 Version 2.1, February 1999 \par \par \hich\af1\dbch\af23\loch\f1 Copyright (C) 1991, 1999 Free Software Foundation, Inc. \par \hich\af1\dbch\af23\loch\f1 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \par \hich\af1\dbch\af23\loch\f1 Everyone is permitted to copy and distribute verbatim copies \par \hich\af1\dbch\af23\loch\f1 of this license document, but changing it is not allowed. \par \par \hich\af1\dbch\af23\loch\f1 [This is the first released version of the Lesser GPL. It also counts \par \hich\af1\dbch\af23\loch\f1 a\hich\af1\dbch\af23\loch\f1 s the successor of the GNU Library Public License, version 2, hence \par \hich\af1\dbch\af23\loch\f1 the version number 2.1.] \par \par \tab \tab \tab \hich\af1\dbch\af23\loch\f1 Preamble \par \par \hich\af1\dbch\af23\loch\f1 The licenses for most software are designed to take away your \par \hich\af1\dbch\af23\loch\f1 freedom to share and change it. By contrast, the GNU General Public \par \hich\af1\dbch\af23\loch\f1 Licenses ar\hich\af1\dbch\af23\loch\f1 e intended to guarantee your freedom to share and change \par \hich\af1\dbch\af23\loch\f1 free software--to make sure the software is free for all its users. \par \par \hich\af1\dbch\af23\loch\f1 This license, the Lesser General Public License, applies to some \par \hich\af1\dbch\af23\loch\f1 specially designated software packages--typically libraries--of\hich\af1\dbch\af23\loch\f1 the \par \hich\af1\dbch\af23\loch\f1 Free Software Foundation and other authors who decide to use it. You \par \hich\af1\dbch\af23\loch\f1 can use it too, but we suggest you first think carefully about whether \par \hich\af1\dbch\af23\loch\f1 this license or the ordinary General Public License is the better \par \hich\af1\dbch\af23\loch\f1 strategy to use in any particular case, base\hich\af1\dbch\af23\loch\f1 d on the explanations below. \par \par \hich\af1\dbch\af23\loch\f1 When we speak of free software, we are referring to freedom of use, \par \hich\af1\dbch\af23\loch\f1 not price. Our General Public Licenses are designed to make sure that \par \hich\af1\dbch\af23\loch\f1 you have the freedom to distribute copies of free software (and charge \par \hich\af1\dbch\af23\loch\f1 for this servi\hich\af1\dbch\af23\loch\f1 ce if you wish); that you receive source code or can get \par \hich\af1\dbch\af23\loch\f1 it if you want it; that you can change the software and use pieces of \par \hich\af1\dbch\af23\loch\f1 it in new free programs; and that you are informed that you can do \par \hich\af1\dbch\af23\loch\f1 these things. \par \par \hich\af1\dbch\af23\loch\f1 To protect your rights, we need to make restrictions that forbid \par \hich\af1\dbch\af23\loch\f1 distributors to deny you these rights or to ask you to surrender these \par \hich\af1\dbch\af23\loch\f1 rights. These restrictions translate to certain responsibilities for \par \hich\af1\dbch\af23\loch\f1 you if you distribute copies of the library or i\hich\af1\dbch\af23\loch\f1 f you modify it. \par \par \hich\af1\dbch\af23\loch\f1 For example, if you distribute copies of the library, whether gratis \par \hich\af1\dbch\af23\loch\f1 or for a fee, you must give the recipients all the rights that we gave \par \hich\af1\dbch\af23\loch\f1 you. You must make sure that they, too, receive or can get the source \par \hich\af1\dbch\af23\loch\f1 code. If you link other \hich\af1\dbch\af23\loch\f1 code with the library, you must provide \par \hich\af1\dbch\af23\loch\f1 complete object files to the recipients, so that they can relink them \par \hich\af1\dbch\af23\loch\f1 with the library after making changes to the library and recompiling \par \hich\af1\dbch\af23\loch\f1 it. And you must show them these terms so they know their rights. \par \par \hich\af1\dbch\af23\loch\f1 We prot\hich\af1\dbch\af23\loch\f1 ect your rights with a two-step method: (1) we copyright the \par \hich\af1\dbch\af23\loch\f1 library, and (2) we offer you this license, which gives you legal \par \hich\af1\dbch\af23\loch\f1 permission to copy, distribute and/or modify the library. \par \par \hich\af1\dbch\af23\loch\f1 To protect each distributor, we want to make it very clear that \par \hich\af1\dbch\af23\loch\f1 ther\hich\af1\dbch\af23\loch\f1 e is no warranty for the free library. Also, if the library is \par \hich\af1\dbch\af23\loch\f1 modified by someone else and passed on, the recipients should know \par \hich\af1\dbch\af23\loch\f1 that what they have is not the original version, so that the original \par \hich\af1\dbch\af23\loch\f1 author's reputation will not be affected by problems th\hich\af1\dbch\af23\loch\f1 at might be \par \hich\af1\dbch\af23\loch\f1 introduced by others. \par \page \par \hich\af1\dbch\af23\loch\f1 Finally, software patents pose a constant threat to the existence of \par \hich\af1\dbch\af23\loch\f1 any free program. We wish to make sure that a company cannot \par \hich\af1\dbch\af23\loch\f1 effectively restrict the users of a free program by obtaining a \par \hich\af1\dbch\af23\loch\f1 restrictive licens\hich\af1\dbch\af23\loch\f1 e from a patent holder. Therefore, we insist that \par \hich\af1\dbch\af23\loch\f1 any patent license obtained for a version of the library must be \par \hich\af1\dbch\af23\loch\f1 consistent with the full freedom of use specified in this license. \par \par \hich\af1\dbch\af23\loch\f1 Most GNU software, including some libraries, is covered by the \par \hich\af1\dbch\af23\loch\f1 ordinar\hich\af1\dbch\af23\loch\f1 y GNU General Public License. This license, the GNU Lesser \par \hich\af1\dbch\af23\loch\f1 General Public License, applies to certain designated libraries, and \par \hich\af1\dbch\af23\loch\f1 is quite different from the ordinary General Public License. We use \par \hich\af1\dbch\af23\loch\f1 this license for certain libraries in order to permit link\hich\af1\dbch\af23\loch\f1 ing those \par \hich\af1\dbch\af23\loch\f1 libraries into non-free programs. \par \par \hich\af1\dbch\af23\loch\f1 When a program is linked with a library, whether statically or using \par \hich\af1\dbch\af23\loch\f1 a shared library, the combination of the two is legally speaking a \par \hich\af1\dbch\af23\loch\f1 combined work, a derivative of the original library. The ordinary \par \hich\af1\dbch\af23\loch\f1 Genera\hich\af1\dbch\af23\loch\f1 l Public License therefore permits such linking only if the \par \hich\af1\dbch\af23\loch\f1 entire combination fits its criteria of freedom. The Lesser General \par \hich\af1\dbch\af23\loch\f1 Public License permits more lax criteria for linking other code with \par \hich\af1\dbch\af23\loch\f1 the library. \par \par \hich\af1\dbch\af23\loch\f1 We call this license the "Lesser" General \hich\af1\dbch\af23\loch\f1 Public License because it \par \hich\af1\dbch\af23\loch\f1 does Less to protect the user's freedom than the ordinary General \par \hich\af1\dbch\af23\loch\f1 Public License. It also provides other free software developers Less \par \hich\af1\dbch\af23\loch\f1 of an advantage over competing non-free programs. These disadvantages \par \hich\af1\dbch\af23\loch\f1 are the reason we use t\hich\af1\dbch\af23\loch\f1 he ordinary General Public License for many \par \hich\af1\dbch\af23\loch\f1 libraries. However, the Lesser license provides advantages in certain \par \hich\af1\dbch\af23\loch\f1 special circumstances. \par \par \hich\af1\dbch\af23\loch\f1 For example, on rare occasions, there may be a special need to \par \hich\af1\dbch\af23\loch\f1 encourage the widest possible use o\hich\af1\dbch\af23\loch\f1 f a certain library, so that it becomes \par \hich\af1\dbch\af23\loch\f1 a de-facto standard. To achieve this, non-free programs must be \par \hich\af1\dbch\af23\loch\f1 allowed to use the library. A more frequent case is that a free \par \hich\af1\dbch\af23\loch\f1 library does the same job as widely used non-free libraries. In this \par \hich\af1\dbch\af23\loch\f1 case, there is l\hich\af1\dbch\af23\loch\f1 ittle to gain by limiting the free library to free \par \hich\af1\dbch\af23\loch\f1 software only, so we use the Lesser General Public License. \par \par \hich\af1\dbch\af23\loch\f1 In other cases, permission to use a particular library in non-free \par \hich\af1\dbch\af23\loch\f1 programs enables a greater number of people to use a large body of \par \hich\af1\dbch\af23\loch\f1 free sof\hich\af1\dbch\af23\loch\f1 tware. For example, permission to use the GNU C Library in \par \hich\af1\dbch\af23\loch\f1 non-free programs enables many more people to use the whole GNU \par \hich\af1\dbch\af23\loch\f1 operating system, as well as its variant, the GNU/Linux operating \par \hich\af1\dbch\af23\loch\f1 system. \par \par \hich\af1\dbch\af23\loch\f1 Although the Lesser General Public License is Less prot\hich\af1\dbch\af23\loch\f1 ective of the \par \hich\af1\dbch\af23\loch\f1 users' freedom, it does ensure that the user of a program that is \par \hich\af1\dbch\af23\loch\f1 linked with the Library has the freedom and the wherewithal to run \par \hich\af1\dbch\af23\loch\f1 that program using a modified version of the Library. \par \par \hich\af1\dbch\af23\loch\f1 The precise terms and conditions for copying, distri\hich\af1\dbch\af23\loch\f1 bution and \par \hich\af1\dbch\af23\loch\f1 modification follow. Pay close attention to the difference between a \par \hich\af1\dbch\af23\loch\f1 "work based on the library" and a "work that uses the library". The \par \hich\af1\dbch\af23\loch\f1 former contains code derived from the library, whereas the latter must \par \hich\af1\dbch\af23\loch\f1 be combined with the library in ord\hich\af1\dbch\af23\loch\f1 er to run. \par \page \par \tab \tab \hich\af1\dbch\af23\loch\f1 GNU LESSER GENERAL PUBLIC LICENSE \par \hich\af1\dbch\af23\loch\f1 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION \par \par \hich\af1\dbch\af23\loch\f1 0. This License Agreement applies to any software library or other \par \hich\af1\dbch\af23\loch\f1 program which contains a notice placed by the copyright holder or \par \hich\af1\dbch\af23\loch\f1 other authorized party saying it may be distributed under the terms of \par \hich\af1\dbch\af23\loch\f1 this Lesser General Public License (also called "this License"). \par \hich\af1\dbch\af23\loch\f1 Each licensee is addressed as "you". \par \par \hich\af1\dbch\af23\loch\f1 A "library" means a collection of software functions and/or data \par \hich\af1\dbch\af23\loch\f1 prepared so as \hich\af1\dbch\af23\loch\f1 to be conveniently linked with application programs \par \hich\af1\dbch\af23\loch\f1 (which use some of those functions and data) to form executables. \par \par \hich\af1\dbch\af23\loch\f1 The "Library", below, refers to any such software library or work \par \hich\af1\dbch\af23\loch\f1 which has been distributed under these terms. A "work based on the \par \hich\af1\dbch\af23\loch\f1 L\hich\af1\dbch\af23\loch\f1 ibrary" means either the Library or any derivative work under \par \hich\af1\dbch\af23\loch\f1 copyright law: that is to say, a work containing the Library or a \par \hich\af1\dbch\af23\loch\f1 portion of it, either verbatim or with modifications and/or translated \par \hich\af1\dbch\af23\loch\f1 straightforwardly into another language. (Hereinafter, t\hich\af1\dbch\af23\loch\f1 ranslation is \par \hich\af1\dbch\af23\loch\f1 included without limitation in the term "modification".) \par \par \hich\af1\dbch\af23\loch\f1 "Source code" for a work means the preferred form of the work for \par \hich\af1\dbch\af23\loch\f1 making modifications to it. For a library, complete source code means \par \hich\af1\dbch\af23\loch\f1 all the source code for all modules it contai\hich\af1\dbch\af23\loch\f1 ns, plus any associated \par \hich\af1\dbch\af23\loch\f1 interface definition files, plus the scripts used to control compilation \par \hich\af1\dbch\af23\loch\f1 and installation of the library. \par \par \hich\af1\dbch\af23\loch\f1 Activities other than copying, distribution and modification are not \par \hich\af1\dbch\af23\loch\f1 covered by this License; they are outside its scope. \hich\af1\dbch\af23\loch\f1 The act of \par \hich\af1\dbch\af23\loch\f1 running a program using the Library is not restricted, and output from \par \hich\af1\dbch\af23\loch\f1 such a program is covered only if its contents constitute a work based \par \hich\af1\dbch\af23\loch\f1 on the Library (independent of the use of the Library in a tool for \par \hich\af1\dbch\af23\loch\f1 writing it). Whether that is true depends on what the Library does \par \hich\af1\dbch\af23\loch\f1 and what the program that uses the Library does. \par \hich\af1\dbch\af23\loch\f1 \par \hich\af1\dbch\af23\loch\f1 1. You may copy and distribute verbatim copies of the Library's \par \hich\af1\dbch\af23\loch\f1 complete source code as you receive it, in any medium, provided that \par \hich\af1\dbch\af23\loch\f1 y\hich\af1\dbch\af23\loch\f1 ou conspicuously and appropriately publish on each copy an \par \hich\af1\dbch\af23\loch\f1 appropriate copyright notice and disclaimer of warranty; keep intact \par \hich\af1\dbch\af23\loch\f1 all the notices that refer to this License and to the absence of any \par \hich\af1\dbch\af23\loch\f1 warranty; and distribute a copy of this License along with \hich\af1\dbch\af23\loch\f1 the \par \hich\af1\dbch\af23\loch\f1 Library. \par \par \hich\af1\dbch\af23\loch\f1 You may charge a fee for the physical act of transferring a copy, \par \hich\af1\dbch\af23\loch\f1 and you may at your option offer warranty protection in exchange for a \par \hich\af1\dbch\af23\loch\f1 fee. \par \page \par \hich\af1\dbch\af23\loch\f1 2. You may modify your copy or copies of the Library or any portion \par \hich\af1\dbch\af23\loch\f1 of it, thus forming a work\hich\af1\dbch\af23\loch\f1 based on the Library, and copy and \par \hich\af1\dbch\af23\loch\f1 distribute such modifications or work under the terms of Section 1 \par \hich\af1\dbch\af23\loch\f1 above, provided that you also meet all of these conditions: \par \par \hich\af1\dbch\af23\loch\f1 a) The modified work must itself be a software library. \par \par \hich\af1\dbch\af23\loch\f1 b) You must cause the files\hich\af1\dbch\af23\loch\f1 modified to carry prominent notices \par \hich\af1\dbch\af23\loch\f1 stating that you changed the files and the date of any change. \par \par \hich\af1\dbch\af23\loch\f1 c) You must cause the whole of the work to be licensed at no \par \hich\af1\dbch\af23\loch\f1 charge to all third parties under the terms of this License. \par \par \hich\af1\dbch\af23\loch\f1 d) If a facility\hich\af1\dbch\af23\loch\f1 in the modified Library refers to a function or a \par \hich\af1\dbch\af23\loch\f1 table of data to be supplied by an application program that uses \par \hich\af1\dbch\af23\loch\f1 the facility, other than as an argument passed when the facility \par \hich\af1\dbch\af23\loch\f1 is invoked, then you must make a good faith effort to ensure that, \par \hich\af1\dbch\af23\loch\f1 in the event an application does not supply such function or \par \hich\af1\dbch\af23\loch\f1 table, the facility still operates, and performs whatever part of \par \hich\af1\dbch\af23\loch\f1 its purpose remains meaningful. \par \par \hich\af1\dbch\af23\loch\f1 (For exam\hich\af1\dbch\af23\loch\f1 ple, a function in a library to compute square roots has \par \hich\af1\dbch\af23\loch\f1 a purpose that is entirely well-defined independent of the \par \hich\af1\dbch\af23\loch\f1 application. Therefore, Subsection 2d requires that any \par \hich\af1\dbch\af23\loch\f1 application-supplied function or table used by this function must \par \hich\af1\dbch\af23\loch\f1 b\hich\af1\dbch\af23\loch\f1 e optional: if the application does not supply it, the square \par \hich\af1\dbch\af23\loch\f1 root function must still compute square roots.) \par \par \hich\af1\dbch\af23\loch\f1 These requirements apply to the modified work as a whole. If \par \hich\af1\dbch\af23\loch\f1 identifiable sections of that work are not derived from the Library, \par \hich\af1\dbch\af23\loch\f1 and can be\hich\af1\dbch\af23\loch\f1 reasonably considered independent and separate works in \par \hich\af1\dbch\af23\loch\f1 themselves, then this License, and its terms, do not apply to those \par \hich\af1\dbch\af23\loch\f1 sections when you distribute them as separate works. But when you \par \hich\af1\dbch\af23\loch\f1 distribute the same sections as part of a whole which is a work \hich\af1\dbch\af23\loch\f1 based \par \hich\af1\dbch\af23\loch\f1 on the Library, the distribution of the whole must be on the terms of \par \hich\af1\dbch\af23\loch\f1 this License, whose permissions for other licensees extend to the \par \hich\af1\dbch\af23\loch\f1 entire whole, and thus to each and every part regardless of who wrote \par \hich\af1\dbch\af23\loch\f1 it. \par \par \hich\af1\dbch\af23\loch\f1 Thus, it is not the intent of this sect\hich\af1\dbch\af23\loch\f1 ion to claim rights or contest \par \hich\af1\dbch\af23\loch\f1 your rights to work written entirely by you; rather, the intent is to \par \hich\af1\dbch\af23\loch\f1 exercise the right to control the distribution of derivative or \par \hich\af1\dbch\af23\loch\f1 collective works based on the Library. \par \par \hich\af1\dbch\af23\loch\f1 In addition, mere aggregation of another work not based on the Library \par \hich\af1\dbch\af23\loch\f1 with the Library (or with a work based on the Library) on a volume of \par \hich\af1\dbch\af23\loch\f1 a storage or distribution medium does not bring the other work under \par \hich\af1\dbch\af23\loch\f1 the scope of this License. \par \par \hich\af1\dbch\af23\loch\f1 3. You may opt t\hich\af1\dbch\af23\loch\f1 o apply the terms of the ordinary GNU General Public \par \hich\af1\dbch\af23\loch\f1 License instead of this License to a given copy of the Library. To do \par \hich\af1\dbch\af23\loch\f1 this, you must alter all the notices that refer to this License, so \par \hich\af1\dbch\af23\loch\f1 that they refer to the ordinary GNU General Public License, vers\hich\af1\dbch\af23\loch\f1 ion 2, \par \hich\af1\dbch\af23\loch\f1 instead of to this License. (If a newer version than version 2 of the \par \hich\af1\dbch\af23\loch\f1 ordinary GNU General Public License has appeared, then you can specify \par \hich\af1\dbch\af23\loch\f1 that version instead if you wish.) Do not make any other change in \par \hich\af1\dbch\af23\loch\f1 these notices. \par \page \par \hich\af1\dbch\af23\loch\f1 Once this change is \hich\af1\dbch\af23\loch\f1 made in a given copy, it is irreversible for \par \hich\af1\dbch\af23\loch\f1 that copy, so the ordinary GNU General Public License applies to all \par \hich\af1\dbch\af23\loch\f1 subsequent copies and derivative works made from that copy. \par \par \hich\af1\dbch\af23\loch\f1 This option is useful when you wish to copy part of the code of \par \hich\af1\dbch\af23\loch\f1 the Library int\hich\af1\dbch\af23\loch\f1 o a program that is not a library. \par \par \hich\af1\dbch\af23\loch\f1 4. You may copy and distribute the Library (or a portion or \par \hich\af1\dbch\af23\loch\f1 derivative of it, under Section 2) in object code or executable form \par \hich\af1\dbch\af23\loch\f1 under the terms of Sections 1 and 2 above provided that you accompany \par \hich\af1\dbch\af23\loch\f1 it with the complet\hich\af1\dbch\af23\loch\f1 e corresponding machine-readable source code, which \par \hich\af1\dbch\af23\loch\f1 must be distributed under the terms of Sections 1 and 2 above on a \par \hich\af1\dbch\af23\loch\f1 medium customarily used for software interchange. \par \par \hich\af1\dbch\af23\loch\f1 If distribution of object code is made by offering access to copy \par \hich\af1\dbch\af23\loch\f1 from a designated place, then offering equivalent access to copy the \par \hich\af1\dbch\af23\loch\f1 source code from the same place satisfies the requirement to \par \hich\af1\dbch\af23\loch\f1 distribute the source code, even though third parties are not \par \hich\af1\dbch\af23\loch\f1 compelled to copy the source along with the object code. \par \par \hich\af1\dbch\af23\loch\f1 5. A\hich\af1\dbch\af23\loch\f1 program that contains no derivative of any portion of the \par \hich\af1\dbch\af23\loch\f1 Library, but is designed to work with the Library by being compiled or \par \hich\af1\dbch\af23\loch\f1 linked with it, is called a "work that uses the Library". Such a \par \hich\af1\dbch\af23\loch\f1 work, in isolation, is not a derivative work of the Library,\hich\af1\dbch\af23\loch\f1 and \par \hich\af1\dbch\af23\loch\f1 therefore falls outside the scope of this License. \par \par \hich\af1\dbch\af23\loch\f1 However, linking a "work that uses the Library" with the Library \par \hich\af1\dbch\af23\loch\f1 creates an executable that is a derivative of the Library (because it \par \hich\af1\dbch\af23\loch\f1 contains portions of the Library), rather than a "work that us\hich\af1\dbch\af23\loch\f1 es the \par \hich\af1\dbch\af23\loch\f1 library". The executable is therefore covered by this License. \par \hich\af1\dbch\af23\loch\f1 Section 6 states terms for distribution of such executables. \par \par \hich\af1\dbch\af23\loch\f1 When a "work that uses the Library" uses material from a header file \par \hich\af1\dbch\af23\loch\f1 that is part of the Library, the object code for the\hich\af1\dbch\af23\loch\f1 work may be a \par \hich\af1\dbch\af23\loch\f1 derivative work of the Library even though the source code is not. \par \hich\af1\dbch\af23\loch\f1 Whether this is true is especially significant if the work can be \par \hich\af1\dbch\af23\loch\f1 linked without the Library, or if the work is itself a library. The \par \hich\af1\dbch\af23\loch\f1 threshold for this to be true is not pr\hich\af1\dbch\af23\loch\f1 ecisely defined by law. \par \par \hich\af1\dbch\af23\loch\f1 If such an object file uses only numerical parameters, data \par \hich\af1\dbch\af23\loch\f1 structure layouts and accessors, and small macros and small inline \par \hich\af1\dbch\af23\loch\f1 functions (ten lines or less in length), then the use of the object \par \hich\af1\dbch\af23\loch\f1 file is unrestricted, regardless o\hich\af1\dbch\af23\loch\f1 f whether it is legally a derivative \par \hich\af1\dbch\af23\loch\f1 work. (Executables containing this object code plus portions of the \par \hich\af1\dbch\af23\loch\f1 Library will still fall under Section 6.) \par \par \hich\af1\dbch\af23\loch\f1 Otherwise, if the work is a derivative of the Library, you may \par \hich\af1\dbch\af23\loch\f1 distribute \hich\af1\dbch\af23\loch\f1 the object code for the work under the terms of Section 6. \par \hich\af1\dbch\af23\loch\f1 Any executables containing that work also fall under Section 6, \par \hich\af1\dbch\af23\loch\f1 whether or not they are linked directly with the Library itself. \par \page \par \hich\af1\dbch\af23\loch\f1 6. As an exception to the Sections above, you may also combine o\hich\af1\dbch\af23\loch\f1 r \par \hich\af1\dbch\af23\loch\f1 link a "work that uses the Library" with the Library to produce a \par \hich\af1\dbch\af23\loch\f1 work containing portions of the Library, and distribute that work \par \hich\af1\dbch\af23\loch\f1 under terms of your choice, provided that the terms permit \par \hich\af1\dbch\af23\loch\f1 modification of the work for the customer's own use and reverse \par \hich\af1\dbch\af23\loch\f1 engineering for debugging such modifications. \par \par \hich\af1\dbch\af23\loch\f1 You must give prominent notice with each copy of the work that the \par \hich\af1\dbch\af23\loch\f1 Library is used in it and that the Library and its use are covered by \par \hich\af1\dbch\af23\loch\f1 this License. You must supply a copy of this License. If the work \par \hich\af1\dbch\af23\loch\f1 d\hich\af1\dbch\af23\loch\f1 uring execution displays copyright notices, you must include the \par \hich\af1\dbch\af23\loch\f1 copyright notice for the Library among them, as well as a reference \par \hich\af1\dbch\af23\loch\f1 directing the user to the copy of this License. Also, you must do one \par \hich\af1\dbch\af23\loch\f1 of these things: \par \par \hich\af1\dbch\af23\loch\f1 a) Accompany the work with the\hich\af1\dbch\af23\loch\f1 complete corresponding \par \hich\af1\dbch\af23\loch\f1 machine-readable source code for the Library including whatever \par \hich\af1\dbch\af23\loch\f1 changes were used in the work (which must be distributed under \par \hich\af1\dbch\af23\loch\f1 Sections 1 and 2 above); and, if the work is an executable linked \par \hich\af1\dbch\af23\loch\f1 with the Library, with \hich\af1\dbch\af23\loch\f1 the complete machine-readable "work that \par \hich\af1\dbch\af23\loch\f1 uses the Library", as object code and/or source code, so that the \par \hich\af1\dbch\af23\loch\f1 user can modify the Library and then relink to produce a modified \par \hich\af1\dbch\af23\loch\f1 executable containing the modified Library. (It is understood \par \hich\af1\dbch\af23\loch\f1 that the user who changes the contents of definitions files in the \par \hich\af1\dbch\af23\loch\f1 Library will not necessarily be able to recompile the application \par \hich\af1\dbch\af23\loch\f1 to use the modified definitions.) \par \par \hich\af1\dbch\af23\loch\f1 b) Use a suitable shared library mechanism for linking with the \par \hich\af1\dbch\af23\loch\f1 Libr\hich\af1\dbch\af23\loch\f1 ary. A suitable mechanism is one that (1) uses at run time a \par \hich\af1\dbch\af23\loch\f1 copy of the library already present on the user's computer system, \par \hich\af1\dbch\af23\loch\f1 rather than copying library functions into the executable, and (2) \par \hich\af1\dbch\af23\loch\f1 will operate properly with a modified version of\hich\af1\dbch\af23\loch\f1 the library, if \par \hich\af1\dbch\af23\loch\f1 the user installs one, as long as the modified version is \par \hich\af1\dbch\af23\loch\f1 interface-compatible with the version that the work was made with. \par \par \hich\af1\dbch\af23\loch\f1 c) Accompany the work with a written offer, valid for at \par \hich\af1\dbch\af23\loch\f1 least three years, to give the same user\hich\af1\dbch\af23\loch\f1 the materials \par \hich\af1\dbch\af23\loch\f1 specified in Subsection 6a, above, for a charge no more \par \hich\af1\dbch\af23\loch\f1 than the cost of performing this distribution. \par \par \hich\af1\dbch\af23\loch\f1 d) If distribution of the work is made by offering access to copy \par \hich\af1\dbch\af23\loch\f1 from a designated place, offer equivalent access to cop\hich\af1\dbch\af23\loch\f1 y the above \par \hich\af1\dbch\af23\loch\f1 specified materials from the same place. \par \par \hich\af1\dbch\af23\loch\f1 e) Verify that the user has already received a copy of these \par \hich\af1\dbch\af23\loch\f1 materials or that you have already sent this user a copy. \par \par \hich\af1\dbch\af23\loch\f1 For an executable, the required form of the "work that uses the \par \hich\af1\dbch\af23\loch\f1 Libr\hich\af1\dbch\af23\loch\f1 ary" must include any data and utility programs needed for \par \hich\af1\dbch\af23\loch\f1 reproducing the executable from it. However, as a special exception, \par \hich\af1\dbch\af23\loch\f1 the materials to be distributed need not include anything that is \par \hich\af1\dbch\af23\loch\f1 normally distributed (in either source or binary form) with the major \par \hich\af1\dbch\af23\loch\f1 components (compiler, kernel, and so on) of the operating system on \par \hich\af1\dbch\af23\loch\f1 which the executable runs, unless that component itself accompanies \par \hich\af1\dbch\af23\loch\f1 the executable. \par \par \hich\af1\dbch\af23\loch\f1 It may happen that this require\hich\af1\dbch\af23\loch\f1 ment contradicts the license \par \hich\af1\dbch\af23\loch\f1 restrictions of other proprietary libraries that do not normally \par \hich\af1\dbch\af23\loch\f1 accompany the operating system. Such a contradiction means you cannot \par \hich\af1\dbch\af23\loch\f1 use both them and the Library together in an executable that you \par \hich\af1\dbch\af23\loch\f1 distribute. \par \page \par \hich\af1\dbch\af23\loch\f1 7. You may\hich\af1\dbch\af23\loch\f1 place library facilities that are a work based on the \par \hich\af1\dbch\af23\loch\f1 Library side-by-side in a single library together with other library \par \hich\af1\dbch\af23\loch\f1 facilities not covered by this License, and distribute such a combined \par \hich\af1\dbch\af23\loch\f1 library, provided that the separate distribution of the work \hich\af1\dbch\af23\loch\f1 based on \par \hich\af1\dbch\af23\loch\f1 the Library and of the other library facilities is otherwise \par \hich\af1\dbch\af23\loch\f1 permitted, and provided that you do these two things: \par \par \hich\af1\dbch\af23\loch\f1 a) Accompany the combined library with a copy of the same work \par \hich\af1\dbch\af23\loch\f1 based on the Library, uncombined with any other library \par \hich\af1\dbch\af23\loch\f1 \hich\af1\dbch\af23\loch\f1 facilities. This must be distributed under the terms of the \par \hich\af1\dbch\af23\loch\f1 Sections above. \par \par \hich\af1\dbch\af23\loch\f1 b) Give prominent notice with the combined library of the fact \par \hich\af1\dbch\af23\loch\f1 that part of it is a work based on the Library, and explaining \par \hich\af1\dbch\af23\loch\f1 where to find the accompanying uncom\hich\af1\dbch\af23\loch\f1 bined form of the same work. \par \par \hich\af1\dbch\af23\loch\f1 8. You may not copy, modify, sublicense, link with, or distribute \par \hich\af1\dbch\af23\loch\f1 the Library except as expressly provided under this License. Any \par \hich\af1\dbch\af23\loch\f1 attempt otherwise to copy, modify, sublicense, link with, or \par \hich\af1\dbch\af23\loch\f1 distribute the Library is void, and will automatically terminate your \par \hich\af1\dbch\af23\loch\f1 rights under this License. However, parties who have received copies, \par \hich\af1\dbch\af23\loch\f1 or rights, from you under this License will not have their licenses \par \hich\af1\dbch\af23\loch\f1 terminated so long as such parties remain in fu\hich\af1\dbch\af23\loch\f1 ll compliance. \par \par \hich\af1\dbch\af23\loch\f1 9. You are not required to accept this License, since you have not \par \hich\af1\dbch\af23\loch\f1 signed it. However, nothing else grants you permission to modify or \par \hich\af1\dbch\af23\loch\f1 distribute the Library or its derivative works. These actions are \par \hich\af1\dbch\af23\loch\f1 prohibited by law if you do not acc\hich\af1\dbch\af23\loch\f1 ept this License. Therefore, by \par \hich\af1\dbch\af23\loch\f1 modifying or distributing the Library (or any work based on the \par \hich\af1\dbch\af23\loch\f1 Library), you indicate your acceptance of this License to do so, and \par \hich\af1\dbch\af23\loch\f1 all its terms and conditions for copying, distributing or modifying \par \hich\af1\dbch\af23\loch\f1 the Library or works b\hich\af1\dbch\af23\loch\f1 ased on it. \par \par \hich\af1\dbch\af23\loch\f1 10. Each time you redistribute the Library (or any work based on the \par \hich\af1\dbch\af23\loch\f1 Library), the recipient automatically receives a license from the \par \hich\af1\dbch\af23\loch\f1 original licensor to copy, distribute, link with or modify the Library \par \hich\af1\dbch\af23\loch\f1 subject to these terms and conditio\hich\af1\dbch\af23\loch\f1 ns. You may not impose any further \par \hich\af1\dbch\af23\loch\f1 restrictions on the recipients' exercise of the rights granted herein. \par \hich\af1\dbch\af23\loch\f1 You are not responsible for enforcing compliance by third parties with \par \hich\af1\dbch\af23\loch\f1 this License. \par \page \par \hich\af1\dbch\af23\loch\f1 11. If, as a consequence of a court judgment or allegation o\hich\af1\dbch\af23\loch\f1 f patent \par \hich\af1\dbch\af23\loch\f1 infringement or for any other reason (not limited to patent issues), \par \hich\af1\dbch\af23\loch\f1 conditions are imposed on you (whether by court order, agreement or \par \hich\af1\dbch\af23\loch\f1 otherwise) that contradict the conditions of this License, they do not \par \hich\af1\dbch\af23\loch\f1 excuse you from the conditions of this \hich\af1\dbch\af23\loch\f1 License. If you cannot \par \hich\af1\dbch\af23\loch\f1 distribute so as to satisfy simultaneously your obligations under this \par \hich\af1\dbch\af23\loch\f1 License and any other pertinent obligations, then as a consequence you \par \hich\af1\dbch\af23\loch\f1 may not distribute the Library at all. For example, if a patent \par \hich\af1\dbch\af23\loch\f1 license would not permit royalty-free redistribution of the Library by \par \hich\af1\dbch\af23\loch\f1 all those who receive copies directly or indirectly through you, then \par \hich\af1\dbch\af23\loch\f1 the only way you could satisfy both it and this License would be to \par \hich\af1\dbch\af23\loch\f1 refrain entirely from distribution of the Libra\hich\af1\dbch\af23\loch\f1 ry. \par \par \hich\af1\dbch\af23\loch\f1 If any portion of this section is held invalid or unenforceable under any \par \hich\af1\dbch\af23\loch\f1 particular circumstance, the balance of the section is intended to apply, \par \hich\af1\dbch\af23\loch\f1 and the section as a whole is intended to apply in other circumstances. \par \par \hich\af1\dbch\af23\loch\f1 It is not the purpose of this \hich\af1\dbch\af23\loch\f1 section to induce you to infringe any \par \hich\af1\dbch\af23\loch\f1 patents or other property right claims or to contest validity of any \par \hich\af1\dbch\af23\loch\f1 such claims; this section has the sole purpose of protecting the \par \hich\af1\dbch\af23\loch\f1 integrity of the free software distribution system which is \par \hich\af1\dbch\af23\loch\f1 implemented by public li\hich\af1\dbch\af23\loch\f1 cense practices. Many people have made \par \hich\af1\dbch\af23\loch\f1 generous contributions to the wide range of software distributed \par \hich\af1\dbch\af23\loch\f1 through that system in reliance on consistent application of that \par \hich\af1\dbch\af23\loch\f1 system; it is up to the author/donor to decide if he or she is willing \par \hich\af1\dbch\af23\loch\f1 to distribute \hich\af1\dbch\af23\loch\f1 software through any other system and a licensee cannot \par \hich\af1\dbch\af23\loch\f1 impose that choice. \par \par \hich\af1\dbch\af23\loch\f1 This section is intended to make thoroughly clear what is believed to \par \hich\af1\dbch\af23\loch\f1 be a consequence of the rest of this License. \par \par \hich\af1\dbch\af23\loch\f1 12. If the distribution and/or use of the Library is restric\hich\af1\dbch\af23\loch\f1 ted in \par \hich\af1\dbch\af23\loch\f1 certain countries either by patents or by copyrighted interfaces, the \par \hich\af1\dbch\af23\loch\f1 original copyright holder who places the Library under this License may add \par \hich\af1\dbch\af23\loch\f1 an explicit geographical distribution limitation excluding those countries, \par \hich\af1\dbch\af23\loch\f1 so that distribution is permitted only in or among countries not thus \par \hich\af1\dbch\af23\loch\f1 excluded. In such case, this License incorporates the limitation as if \par \hich\af1\dbch\af23\loch\f1 written in the body of this License. \par \par \hich\af1\dbch\af23\loch\f1 13. The Free Software Foundation may publish revised and/or new \par \hich\af1\dbch\af23\loch\f1 versions o\hich\af1\dbch\af23\loch\f1 f the Lesser General Public License from time to time. \par \hich\af1\dbch\af23\loch\f1 Such new versions will be similar in spirit to the present version, \par \hich\af1\dbch\af23\loch\f1 but may differ in detail to address new problems or concerns. \par \par \hich\af1\dbch\af23\loch\f1 Each version is given a distinguishing version number. If the Library \par \hich\af1\dbch\af23\loch\f1 specifies a version number of this License which applies to it and \par \hich\af1\dbch\af23\loch\f1 "any later version", you have the option of following the terms and \par \hich\af1\dbch\af23\loch\f1 conditions either of that version or of any later version published by \par \hich\af1\dbch\af23\loch\f1 the Free Software Foundation. If the Library doe\hich\af1\dbch\af23\loch\f1 s not specify a \par \hich\af1\dbch\af23\loch\f1 license version number, you may choose any version ever published by \par \hich\af1\dbch\af23\loch\f1 the Free Software Foundation. \par \page \par \hich\af1\dbch\af23\loch\f1 14. If you wish to incorporate parts of the Library into other free \par \hich\af1\dbch\af23\loch\f1 programs whose distribution conditions are incompatible with these, \par \hich\af1\dbch\af23\loch\f1 w\hich\af1\dbch\af23\loch\f1 rite to the author to ask for permission. For software which is \par \hich\af1\dbch\af23\loch\f1 copyrighted by the Free Software Foundation, write to the Free \par \hich\af1\dbch\af23\loch\f1 Software Foundation; we sometimes make exceptions for this. Our \par \hich\af1\dbch\af23\loch\f1 decision will be guided by the two goals of preserving the free\hich\af1\dbch\af23\loch\f1 status \par \hich\af1\dbch\af23\loch\f1 of all derivatives of our free software and of promoting the sharing \par \hich\af1\dbch\af23\loch\f1 and reuse of software generally. \par \par \tab \tab \tab \hich\af1\dbch\af23\loch\f1 NO WARRANTY \par \par \hich\af1\dbch\af23\loch\f1 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO \par \hich\af1\dbch\af23\loch\f1 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. \par \hich\af1\dbch\af23\loch\f1 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR \par \hich\af1\dbch\af23\loch\f1 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY \par \hich\af1\dbch\af23\loch\f1 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NO\hich\af1\dbch\af23\loch\f1 T LIMITED TO, THE \par \hich\af1\dbch\af23\loch\f1 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR \par \hich\af1\dbch\af23\loch\f1 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE \par \hich\af1\dbch\af23\loch\f1 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME \par \hich\af1\dbch\af23\loch\f1 THE COST OF ALL NECESSARY SERVICING\hich\af1\dbch\af23\loch\f1 , REPAIR OR CORRECTION. \par \par \hich\af1\dbch\af23\loch\f1 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN \par \hich\af1\dbch\af23\loch\f1 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY \par \hich\af1\dbch\af23\loch\f1 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU \par \hich\af1\dbch\af23\loch\f1 FOR DAMAGES, INCLUDING AN\hich\af1\dbch\af23\loch\f1 Y GENERAL, SPECIAL, INCIDENTAL OR \par \hich\af1\dbch\af23\loch\f1 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE \par \hich\af1\dbch\af23\loch\f1 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING \par \hich\af1\dbch\af23\loch\f1 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A \par \hich\af1\dbch\af23\loch\f1 FAILURE OF THE LIBR\hich\af1\dbch\af23\loch\f1 ARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF \par \hich\af1\dbch\af23\loch\f1 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH \par \hich\af1\dbch\af23\loch\f1 DAMAGES. \par \par \tab \tab \hich\af1\dbch\af23\loch\f1 END OF TERMS AND CONDITIONS \par \page \par \hich\af1\dbch\af23\loch\f1 How to Apply These Terms to Your New Libraries \par \par \hich\af1\dbch\af23\loch\f1 If you develop a new library\hich\af1\dbch\af23\loch\f1 , and you want it to be of the greatest \par \hich\af1\dbch\af23\loch\f1 possible use to the public, we recommend making it free software that \par \hich\af1\dbch\af23\loch\f1 everyone can redistribute and change. You can do so by permitting \par \hich\af1\dbch\af23\loch\f1 redistribution under these terms (or, alternatively, under the terms of the \par \hich\af1\dbch\af23\loch\f1 ordinary General Public License). \par \par \hich\af1\dbch\af23\loch\f1 To apply these terms, attach the following notices to the library. It is \par \hich\af1\dbch\af23\loch\f1 safest to attach them to the start of each source file to most effectively \par \hich\af1\dbch\af23\loch\f1 convey the exclusion of warranty; and each file should have at least t\hich\af1\dbch\af23\loch\f1 he \par \hich\af1\dbch\af23\loch\f1 "copyright" line and a pointer to where the full notice is found. \par \par \hich\af1\dbch\af23\loch\f1 \par \hich\af1\dbch\af23\loch\f1 Copyright (C) \par \par \hich\af1\dbch\af23\loch\f1 This library is free software; you can redistribute it and/or \par \hich\af1\dbch\af23\loch\f1 modify it under the terms of the GNU Lesser General Public \par \hich\af1\dbch\af23\loch\f1 License as published by the Free Software Foundation; either \par \hich\af1\dbch\af23\loch\f1 version 2.1 of the License, or (at your option) any later version. \par \par \hich\af1\dbch\af23\loch\f1 This library is distributed in the hope that it will\hich\af1\dbch\af23\loch\f1 be useful, \par \hich\af1\dbch\af23\loch\f1 but WITHOUT ANY WARRANTY; without even the implied warranty of \par \hich\af1\dbch\af23\loch\f1 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \par \hich\af1\dbch\af23\loch\f1 Lesser General Public License for more details. \par \par \hich\af1\dbch\af23\loch\f1 You should have received a copy of the GNU Lesser \hich\af1\dbch\af23\loch\f1 General Public \par \hich\af1\dbch\af23\loch\f1 License along with this library; if not, write to the Free Software \par \hich\af1\dbch\af23\loch\f1 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \par \par \hich\af1\dbch\af23\loch\f1 Also add information on how to contact you by electronic and paper mail. \par \par \hich\af1\dbch\af23\loch\f1 You should also \hich\af1\dbch\af23\loch\f1 get your employer (if you work as a programmer) or your \par \hich\af1\dbch\af23\loch\f1 school, if any, to sign a "copyright disclaimer" for the library, if \par \hich\af1\dbch\af23\loch\f1 necessary. Here is a sample; alter the names: \par \par \hich\af1\dbch\af23\loch\f1 Yoyodyne, Inc., hereby disclaims all copyright interest in the \par \hich\af1\dbch\af23\loch\f1 library `Frob' (a library for tweaking knobs) written by James Random Hacker. \par \par \hich\af1\dbch\af23\loch\f1 , 1 April 1990 \par \hich\af1\dbch\af23\loch\f1 Ty Coon, President of Vice \par \par \hich\af1\dbch\af23\loch\f1 That's all there is to it! \par \par \par \par \par }}psqlodbc-REL-16_00_0005/installer/modify_msi.vbs000077500000000000000000000027371462406103600213620ustar00rootroot00000000000000' ' When the dll name of the driver is not of 8.3-format ' the modification of the FileName is needed ' ' This is to work-around a bug in the WiX Toolset, see ' http://wixtoolset.org/issues/1422/ ' ' We remove the short name from the filename field in the File-table ' of the two DLLs that need to be registered as ODBC drivers. Strictly ' speaking, that makes the contents of the table invalid, because a short ' name is mandatory, but Windows Installer seems nevertheless install it ' just fine. ' option Explicit Const msiOpenDatabaseModeTransact = 1 Const msiViewModifyInsert = 1 Const msiViewModifyUpdate = 2 Dim msiPath : msiPath = Wscript.Arguments(0) Dim installer Set installer = Wscript.CreateObject("WindowsInstaller.Installer") Dim database Set database = installer.OpenDatabase(msiPath, msiOpenDatabaseModeTransact) Dim query query = "Select * FROM File" Dim view Set view = database.OpenView(query) view.Execute Dim record Set record = view.Fetch Dim gFile, pos Do While not record Is Nothing gFile = record.StringData(1) If Left(gFile, 8) = "psqlodbc" Then gFile = record.StringData(3) ' Check if the FileName field is ShortName|LongName pos = InStr(record.StringData(3), "|") If pos > 0 Then ' Omit the ShortName part gFile = Mid(record.StringData(3), pos + 1) WScript.echo record.StringData(3) & " -> " & gFile ' And update the field record.StringData(3) = gFile view.Modify msiViewModifyUpdate, record End If End If Set record = view.Fetch Loop database.Commit psqlodbc-REL-16_00_0005/installer/productcodes.mak000066400000000000000000000023361462406103600216670ustar00rootroot00000000000000!IF "$(POSTGRESDRIVERVERSION)" == "09.02.0100" PRODUCTCODE="3E42F836-9204-4c42-B3C3-8680A0434875" SUBLOC=0902 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0100" PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485" SUBLOC=0903 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0200" PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485" SUBLOC=0903 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0210" PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485" SUBLOC=0903 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0300" PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485" SUBLOC=0903 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.05.0100" PRODUCTCODE="4C4C4544-004D-5210-8035-B4C04F4B5731" SUBLOC=0905 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.05.0200" PRODUCTCODE="E40653B0-7482-45F6-9BBB-BBB4414E282C" SUBLOC=0905 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.05.0300" PRODUCTCODE="6621B0BF-1017-4b6d-AB9A-C1F9CFF092C8" SUBLOC=0905 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.05.0400" PRODUCTCODE="B047E4C0-B2C9-44DE-B125-6A4DEEFD26CD" SUBLOC=0905 !ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.06.0100" PRODUCTCODE="FBA4F687-2F8E-4E5F-BB7B-60F606E6F1C3" SUBLOC=0906 !ELSE !MESSAGE Driver version $(POSTGRESDRIVERVERSION) is not listed in productcodes.mak EXIT !ENDIF psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/000077500000000000000000000000001462406103600214405ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/Bundle.wxs000077500000000000000000000021731462406103600234220ustar00rootroot00000000000000 psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/Make.bat000077500000000000000000000004611462406103600230110ustar00rootroot00000000000000:: :: Build bootstrapper program of psqlodbc project :: @echo off if "%1" == "/?" ( powershell Get-Help '%~dp0\buildBootstrapper.ps1' -detailed ) else if "%1" == "-?" ( powershell Get-Help '%~dp0\buildBootstrapper.ps1' %2 %3 %4 %5 %6 %7 %8 %9 ) else ( powershell "& '%~dp0\buildBootstrapper.ps1' %*" ) psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/buildBootstrapper.ps1000066400000000000000000000104661462406103600256000ustar00rootroot00000000000000<# .SYNOPSIS Build a bootstrapper application of psqlodbc drivers. .DESCRIPTION Build psqlodbc-setup.exe .PARAMETER version Specify when you'd like to specify the version explicitly. .PARAMETER UI Specify when you'd like to show UIs of each MSIs. .PARAMETER withRedist Specify when you have to include vcredist. .PARAMETER BuildConfigPath Specify the configuration xml file name if you want to use the configuration file other than standard one. The relative path is relative to the current directory. .EXAMPLE > .\buildBootstrapper Build the bootstrapper. .EXAMPLE > .\buildBootstrapper -w(ithRedist) Build the bootstrapper with vcredist. .NOTES Author: Hiroshi Inoue Date: October 8, 2014 #> # build bootstrapper of psqlodbc drivers # Param( [string]$version, [switch]$UI, [switch]$withRedist, [string]$BuildConfigPath ) write-host "Building bootstrapper program`n" $scriptPath = (Split-Path $MyInvocation.MyCommand.Path) $modulePath="${scriptPath}\..\..\winbuild" Import-Module ${modulePath}\Psqlodbc-config.psm1 if ("$version" -eq "") { # $configInfo = & "$scriptPath\..\..\winbuild\configuration.ps1" "$BuildConfigPath" $defaultConfigDir=$modulePath $configInfo = LoadConfiguration $BuildConfigPath $defaultConfigDir $version = GetPackageVersion $configInfo "$scriptPath/../.." } $STUPBASE = GetObjbase "." "installer\psqlodbc-setup" $INSTBASE = GetObjbase ".." "installer" write-host INSTBASE=$INSTBASE Remove-Module Psqlodbc-config if ("$env:WIX" -eq "") { throw "Please install WIX" } $wix_dir="${env:WIX}bin" $pgmname="psqlodbc-setup" $build_config="Release" $objdir="$STUPBASE\obj\${build_config}" $bindir="$STUPBASE\bin\${build_config}" $modules=@("Bundle.wxs") $wRedist="no" $objs=@("${objdir}\Bundle.wixobj") if ($withRedist) { $modules += "vcredist.wxs" $objs += "${objdir}\vcredist.wixobj" $wRedist = "yes" write-host "with Redistributable" } $wUI = "no" if ($UI) { $wUI = "yes" } try { pushd "$scriptPath" & ${wix_dir}\candle.exe -v "-dVERSION=$version" "-dwithRedist=$wRedist" "-dINSTBASE=$INSTBASE" "-dwithUI=$wUI" "-dConfiguration=${build_config}" "-dOutDir=${bindir}\" -dPlatform=x86 "-dProjectDir=.\" "-dProjectExt=.wixproj" "-dProjectFileName=${pgmname}.wixproj" "-dProjectName=${pgmname}" "-dProjectPath=${pgmname}.wixproj" "-dTargetDir=${bindir}\" "-dTargetExt=.exe" "-dTargetFileName=${pgmname}.exe" "-dTargetName=${pgmname}" "-dTargetPath=${bindir}\${pgmname}.exe" -out "${objdir}\" -arch x86 -ext ${wix_dir}\WixUtilExtension.dll -ext ${wix_dir}\WixBalExtension.dll $modules # $candle_cmd = "& `"${wix_dir}\candle.exe`" -v `"-dVERSION=$version`" -dwithRedist=$wRedist -dwithUI=$wUI -dConfiguration=${build_config} `"-dOutDir=${bindir}\`" -dPlatform=x86 `"-dProjectDir=.\`" `"-dProjectExt=.wixproj`" `"-dProjectFileName=${pgmname}.wixproj`" -dProjectName=${pgmname} `"-dProjectPath=${pgmname}.wixproj`" -dTargetDir=${bindir}\ `"-dTargetExt=.exe`" `"-dTargetFileName=${pgmname}.exe`" -dTargetName=${pgmname} `"-dTargetPath=${bindir}\${pgmname}.exe`" -out `"${objdir}\`" -arch x86 -ext `"${wix_dir}\WixUtilExtension.dll`" -ext `"${wix_dir}\WixBalExtension.dll`" $modules" #write-debug "candle_cmd = ${candle_cmd}" # compile #invoke-expression $candle_cmd if ($LASTEXITCODE -ne 0) { throw "Failed to compile $modules" } # link # invoke-expression "& `"${wix_dir}\Light.exe`" -out ${bindir}\${pgmname}.exe -pdbout ${bindir}\${pgmname}.wixpdb -ext `"${wix_dir}\\WixUtilExtension.dll`" -ext `"${wix_dir}\\WixBalExtension.dll`" -contentsfile ${objdir}\${pgmname}.wixproj.BindContentsFileList.txt -outputsfile ${objdir}\${pgmname}.wixproj.BindOutputsFileList.txt -builtoutputsfile ${objdir}\${pgmname}.wixproj.BindBuiltOutputsFileList.txt -wixprojectfile ${pgmname}.wixproj ${objs}" & ${wix_dir}\Light.exe -out ${bindir}\${pgmname}.exe -pdbout ${bindir}\${pgmname}.wixpdb -ext ${wix_dir}\\WixUtilExtension.dll -ext ${wix_dir}\\WixBalExtension.dll -contentsfile ${objdir}\${pgmname}.wixproj.BindContentsFileList.txt -outputsfile ${objdir}\${pgmname}.wixproj.BindOutputsFileList.txt -builtoutputsfile ${objdir}\${pgmname}.wixproj.BindBuiltOutputsFileList.txt -wixprojectfile "${pgmname}.wixproj" ${objs} if ($LASTEXITCODE -ne 0) { throw "Failed to link bootstrapper" } } catch [Exception] { Write-Host ".`Aborting build!" throw $error[0] } finally { popd } psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/psqlodbc-setup.wixproj000077500000000000000000000041611462406103600260360ustar00rootroot00000000000000 Debug x86 3.6 {748caa18-f40d-4308-bc52-2605d09c38b1} 2.0 psqlodbc-setup Bundle $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets bin\$(Configuration)\ obj\$(Configuration)\ Debug bin\$(Configuration)\ obj\$(Configuration)\ $(WixExtDir)\WixUtilExtension.dll WixUtilExtension $(WixExtDir)\WixBalExtension.dll WixBalExtension psqlodbc-REL-16_00_0005/installer/psqlodbc-setup/vcredist.wxs000077500000000000000000000035671462406103600240440ustar00rootroot00000000000000 psqlodbc-REL-16_00_0005/installer/psqlodbc_cpu.wxs000066400000000000000000000157161462406103600217260ustar00rootroot00000000000000 $(var.ALLUSERS) SELFFOUND AND NOT Installed NEWERFOUND AND NOT Installed REINSTALLMODE AND NOT Installed UPGRADEFOUND AND REINSTALLMODE UPGRADEFOUND AND NOT Installed psqlodbc-REL-16_00_0005/installer/psqlodbcm_cpu.wxs000066400000000000000000000246001462406103600220730ustar00rootroot00000000000000 psqlodbc-REL-16_00_0005/libs/000077500000000000000000000000001462406103600154275ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/libs/mimalloc/000077500000000000000000000000001462406103600172245ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/license.txt000066400000000000000000000622221462406103600166650ustar00rootroot00000000000000 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! psqlodbc-REL-16_00_0005/loadlib.c000066400000000000000000000162741462406103600162620ustar00rootroot00000000000000/*------ * Module: loadlib.c * * Description: This module contains routines related to * delay load import libraries. * * Comments: See "readme.txt" for copyright and license information. *------- */ #include #include #include #ifndef WIN32 #include #endif /* WIN32 */ #include "loadlib.h" #include "pgenlist.h" #include "misc.h" #ifdef WIN32 #ifdef _MSC_VER #pragma comment(lib, "Delayimp") #ifdef _HANDLE_ENLIST_IN_DTC_ #ifdef UNICODE_SUPPORT #pragma comment(lib, "pgenlist") #else #pragma comment(lib, "pgenlista") #endif /* UNICODE_SUPPORT */ #endif /* _HANDLE_ENLIST_IN_DTC_ */ // The followings works under VC++6.0 but doesn't work under VC++7.0. // Please add the equivalent linker options using command line etc. #if (_MSC_VER == 1200) && defined(DYNAMIC_LOAD) // VC6.0 #ifdef UNICODE_SUPPORT #pragma comment(linker, "/Delayload:pgenlist.dll") #else #pragma comment(linker, "/Delayload:pgenlista.dll") #endif /* UNICODE_SUPPORT */ #pragma comment(linker, "/Delay:UNLOAD") #endif /* _MSC_VER */ #endif /* _MSC_VER */ #if defined(DYNAMIC_LOAD) #define WIN_DYN_LOAD #ifdef UNICODE_SUPPORT CSTR pgenlist = "pgenlist"; CSTR pgenlistdll = "pgenlist.dll"; CSTR psqlodbc = "psqlodbc35w"; CSTR psqlodbcdll = "psqlodbc35w.dll"; #else CSTR pgenlist = "pgenlista"; CSTR pgenlistdll = "pgenlista.dll"; CSTR psqlodbc = "psqlodbc30a"; CSTR psqlodbcdll = "psqlodbc30a.dll"; #endif /* UNICODE_SUPPORT */ #if defined(_MSC_VER) && (_MSC_VER >= 1200) #define _MSC_DELAY_LOAD_IMPORT #endif /* MSC_VER */ #endif /* DYNAMIC_LOAD */ #endif /* WIN32 */ #if defined(_MSC_DELAY_LOAD_IMPORT) /* * Error hook function for delay load import. * Try to load a DLL based on psqlodbc path. */ #if (_MSC_VER >= 1900) /* vc14 or later */ #define TRY_DLI_HOOK \ __try { #define RELEASE_NOTIFY_HOOK #elif (_MSC_VER < 1300) /* vc6 */ extern PfnDliHook __pfnDliFailureHook; extern PfnDliHook __pfnDliNotifyHook; #define TRY_DLI_HOOK \ __try { \ __pfnDliFailureHook = DliErrorHook; \ __pfnDliNotifyHook = DliErrorHook; #define RELEASE_NOTIFY_HOOK \ __pfnDliNotifyHook = NULL; #else /* vc7 ~ 12 */ extern PfnDliHook __pfnDliFailureHook2; extern PfnDliHook __pfnDliNotifyHook2; #define TRY_DLI_HOOK \ __try { \ __pfnDliFailureHook2 = DliErrorHook; \ __pfnDliNotifyHook2 = DliErrorHook; #define RELEASE_NOTIFY_HOOK \ __pfnDliNotifyHook2 = NULL; #endif /* _MSC_VER */ #else #define TRY_DLI_HOOK \ __try { #define RELEASE_NOTIFY_HOOK #endif /* _MSC_DELAY_LOAD_IMPORT */ #if defined(_MSC_DELAY_LOAD_IMPORT) static BOOL loaded_pgenlist = FALSE; static HMODULE enlist_module = NULL; static BOOL loaded_psqlodbc = FALSE; /* * Load a DLL based on psqlodbc path. */ HMODULE MODULE_load_from_psqlodbc_path(const char *module_name) { extern HINSTANCE s_hModule; HMODULE hmodule = NULL; char szFileName[MAX_PATH]; if (GetModuleFileName(s_hModule, szFileName, sizeof(szFileName)) > 0) { char drive[_MAX_DRIVE], dir[_MAX_DIR], sysdir[MAX_PATH]; _splitpath(szFileName, drive, dir, NULL, NULL); GetSystemDirectory(sysdir, MAX_PATH); SPRINTF_FIXED(szFileName, "%s%s%s.dll", drive, dir, module_name); if (_strnicmp(szFileName, sysdir, strlen(sysdir)) != 0) { hmodule = LoadLibraryEx(szFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); MYLOG(0, "psqlodbc path based %s loaded module=%p\n", module_name, hmodule); } } return hmodule; } static FARPROC WINAPI DliErrorHook(unsigned dliNotify, PDelayLoadInfo pdli) { HMODULE hmodule = NULL; const char* call_module = NULL; MYLOG(0, "Dli%sHook %s Notify=%d\n", (dliFailLoadLib == dliNotify || dliFailGetProc == dliNotify) ? "Error" : "Notify", NULL != pdli->szDll ? pdli->szDll : pdli->dlp.szProcName, dliNotify); switch (dliNotify) { case dliNotePreLoadLibrary: case dliFailLoadLib: RELEASE_NOTIFY_HOOK if (_strnicmp(pdli->szDll, pgenlist, strlen(pgenlist)) == 0) call_module = pgenlist; else if (_strnicmp(pdli->szDll, psqlodbc, strlen(psqlodbc)) == 0) call_module = psqlodbc; if (call_module) { if (hmodule = MODULE_load_from_psqlodbc_path(call_module), NULL == hmodule) hmodule = LoadLibrary(call_module); if (NULL != hmodule) { if (pgenlist == call_module) loaded_pgenlist = TRUE; else if (psqlodbc == call_module) loaded_psqlodbc = TRUE; } } break; } return (FARPROC) hmodule; } void AlreadyLoadedPsqlodbc(void) { loaded_psqlodbc = TRUE; } /* * unload delay loaded libraries. */ typedef BOOL (WINAPI *UnloadFunc)(LPCSTR); void CleanupDelayLoadedDLLs(void) { BOOL success; #if (_MSC_VER < 1300) /* VC6 DELAYLOAD IMPORT */ UnloadFunc func = __FUnloadDelayLoadedDLL; #else UnloadFunc func = __FUnloadDelayLoadedDLL2; #endif /* The dll names are case sensitive for the unload helper */ if (loaded_pgenlist) { if (enlist_module != NULL) { MYLOG(0, "Freeing Library %s\n", pgenlistdll); FreeLibrary(enlist_module); } MYLOG(0, "%s unloading\n", pgenlistdll); success = (*func)(pgenlistdll); MYLOG(0, "%s unloaded success=%d\n", pgenlistdll, success); loaded_pgenlist = FALSE; } if (loaded_psqlodbc) { MYLOG(0, "%s unloading\n", psqlodbcdll); success = (*func)(psqlodbcdll); MYLOG(0, "%s unloaded success=%d\n", psqlodbcdll, success); loaded_psqlodbc = FALSE; } return; } #else void CleanupDelayLoadedDLLs(void) { return; } #endif /* _MSC_DELAY_LOAD_IMPORT */ #ifdef _HANDLE_ENLIST_IN_DTC_ RETCODE CALL_EnlistInDtc(ConnectionClass *conn, void *pTra, int method) { RETCODE ret; BOOL loaded = TRUE; #if defined(_MSC_DELAY_LOAD_IMPORT) if (!loaded_pgenlist) { TRY_DLI_HOOK ret = EnlistInDtc(conn, pTra, method); } __except ((GetExceptionCode() & 0xffff) == ERROR_MOD_NOT_FOUND ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { if (enlist_module = MODULE_load_from_psqlodbc_path(pgenlist), NULL == enlist_module) loaded = FALSE; else ret = EnlistInDtc(conn, pTra, method); } if (loaded) loaded_pgenlist = TRUE; RELEASE_NOTIFY_HOOK } else ret = EnlistInDtc(conn, pTra, method); #else ret = EnlistInDtc(conn, pTra, method); loaded_pgenlist = TRUE; #endif /* _MSC_DELAY_LOAD_IMPORT */ return ret; } RETCODE CALL_DtcOnDisconnect(ConnectionClass *conn) { if (loaded_pgenlist) return DtcOnDisconnect(conn); return FALSE; } RETCODE CALL_IsolateDtcConn(ConnectionClass *conn, BOOL continueConnection) { if (loaded_pgenlist) return IsolateDtcConn(conn, continueConnection); return FALSE; } void *CALL_GetTransactionObject(HRESULT *hres) { void *ret = NULL; BOOL loaded = TRUE; #if defined(_MSC_DELAY_LOAD_IMPORT) if (!loaded_pgenlist) { TRY_DLI_HOOK ret = GetTransactionObject(hres); } __except ((GetExceptionCode() & 0xffff) == ERROR_MOD_NOT_FOUND ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { if (enlist_module = MODULE_load_from_psqlodbc_path(pgenlist), NULL == enlist_module) loaded = FALSE; else ret = GetTransactionObject(hres); } if (loaded) loaded_pgenlist = TRUE; RELEASE_NOTIFY_HOOK } else ret = GetTransactionObject(hres); #else ret = GetTransactionObject(hres); loaded_pgenlist = TRUE; #endif /* _MSC_DELAY_LOAD_IMPORT */ return ret; } void CALL_ReleaseTransactionObject(void *pObj) { if (loaded_pgenlist) ReleaseTransactionObject(pObj); return; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ psqlodbc-REL-16_00_0005/loadlib.h000066400000000000000000000017431462406103600162620ustar00rootroot00000000000000/* File: loadlib.h * * Description: See "loadlib.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __LOADLIB_H__ #define __LOADLIB_H__ #include "psqlodbc.h" #ifdef HAVE_LIBLTDL #include #else #ifdef HAVE_DLFCN_H #include #endif /* HAVE_DLFCN_H */ #endif /* HAVE_LIBLTDL */ #include #ifdef __cplusplus extern "C" { #endif #ifdef _HANDLE_ENLIST_IN_DTC_ RETCODE CALL_EnlistInDtc(ConnectionClass *conn, void * pTra, int method); RETCODE CALL_DtcOnDisconnect(ConnectionClass *); RETCODE CALL_IsolateDtcConn(ConnectionClass *, BOOL); void *CALL_GetTransactionObject(HRESULT *); void CALL_ReleaseTransactionObject(void *); #endif /* _HANDLE_ENLIST_IN_DTC_ */ /* void UnloadDelayLoadedDLLs(BOOL); */ void CleanupDelayLoadedDLLs(void); #ifdef WIN32 HMODULE MODULE_load_from_psqlodbc_path(const char *module_name); void AlreadyLoadedPsqlodbc(void); #endif /* WIN32 */ #ifdef __cplusplus } #endif #endif /* __LOADLIB_H__ */ psqlodbc-REL-16_00_0005/lobj.c000066400000000000000000000076231462406103600156000ustar00rootroot00000000000000/*-------- * Module: lobj.c * * Description: This module contains routines related to manipulating * large objects. * * Classes: none * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *-------- */ #include "lobj.h" #include "connection.h" OID odbc_lo_creat(ConnectionClass *conn, int mode) { LO_ARG argv[1]; Int4 retval, result_len; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = mode; if (!CC_send_function(conn, "lo_creat", &retval, &result_len, 1, argv, 1)) return 0; /* invalid oid */ else return (OID) retval; } int odbc_lo_open(ConnectionClass *conn, int lobjId, int mode) { int fd; int result_len; LO_ARG argv[2]; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = lobjId; argv[1].isint = 1; argv[1].len = 4; argv[1].u.integer = mode; if (!CC_send_function(conn, "lo_open", &fd, &result_len, 1, argv, 2)) return -1; if (fd >= 0 && odbc_lo_lseek64(conn, fd, 0L, SEEK_SET) < 0) return -1; return fd; } int odbc_lo_close(ConnectionClass *conn, int fd) { LO_ARG argv[1]; int retval, result_len; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; if (!CC_send_function(conn, "lo_close", &retval, &result_len, 1, argv, 1)) return -1; else return retval; } Int4 odbc_lo_read(ConnectionClass *conn, int fd, char *buf, Int4 len) { LO_ARG argv[2]; Int4 result_len; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; argv[1].isint = 1; argv[1].len = 4; argv[1].u.integer = len; if (!CC_send_function(conn, "loread", (int *) buf, &result_len, 0, argv, 2)) return -1; else return result_len; } Int4 odbc_lo_write(ConnectionClass *conn, int fd, char *buf, Int4 len) { LO_ARG argv[2]; Int4 retval, result_len; if (len <= 0) return 0; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; argv[1].isint = 0; argv[1].len = len; argv[1].u.ptr = (char *) buf; if (!CC_send_function(conn, "lowrite", &retval, &result_len, 1, argv, 2)) return -1; else return retval; } Int4 odbc_lo_lseek(ConnectionClass *conn, int fd, int offset, Int4 whence) { LO_ARG argv[3]; Int4 retval, result_len; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; argv[1].isint = 1; argv[1].len = 4; argv[1].u.integer = offset; argv[2].isint = 1; argv[2].len = 4; argv[2].u.integer = whence; /* We use lo_lseek64 */ if (!CC_send_function(conn, "lo_lseek", &retval, &result_len, 1, argv, 3)) return -1; else return retval; } Int4 odbc_lo_tell(ConnectionClass *conn, int fd) { LO_ARG argv[1]; Int4 retval, result_len; argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; /* We use lo_tell64 */ if (!CC_send_function(conn, "lo_tell", &retval, &result_len, 1, argv, 1)) return -1; else return retval; } Int8 odbc_lo_lseek64(ConnectionClass *conn, int fd, Int8 offset, Int4 whence) { LO_ARG argv[3]; Int8 retval; Int4 result_len; if (PG_VERSION_LT(conn, 9.3)) { Int4 offset32; offset32 = (Int4) offset; if (offset != (Int8) offset32) { CC_set_error(conn, CONN_VALUE_OUT_OF_RANGE, "large object lseek64 is unavailable for the server", __FUNCTION__); return -1; } return (Int8) odbc_lo_lseek(conn, fd, offset32, whence); } argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; argv[1].isint = 2; argv[1].len = sizeof(offset); argv[1].u.integer64 = offset; argv[2].isint = 1; argv[2].len = 4; argv[2].u.integer = whence; if (!CC_send_function(conn, "lo_lseek64", &retval, &result_len, 2, argv, 3)) return -1; else return retval; } Int8 odbc_lo_tell64(ConnectionClass *conn, int fd) { LO_ARG argv[1]; Int8 retval; Int4 result_len; if (PG_VERSION_LT(conn, 9.3)) return (Int8) odbc_lo_tell(conn, fd); argv[0].isint = 1; argv[0].len = 4; argv[0].u.integer = fd; if (!CC_send_function(conn, "lo_tell64", &retval, &result_len, 2, argv, 1)) return -1; else return retval; } psqlodbc-REL-16_00_0005/lobj.h000066400000000000000000000016701462406103600156010ustar00rootroot00000000000000/* File: lobj.h * * Description: See "lobj.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __LOBJ_H__ #define __LOBJ_H__ #include "psqlodbc.h" struct lo_arg { int isint; int len; union { int integer; char *ptr; Int8 integer64; } u; }; #define INV_WRITE 0x00020000 #define INV_READ 0x00040000 OID odbc_lo_creat(ConnectionClass *conn, int mode); int odbc_lo_open(ConnectionClass *conn, int lobjId, int mode); int odbc_lo_close(ConnectionClass *conn, int fd); Int4 odbc_lo_read(ConnectionClass *conn, int fd, char *buf, Int4 len); Int4 odbc_lo_write(ConnectionClass *conn, int fd, char *buf, Int4 len); Int4 odbc_lo_lseek(ConnectionClass *conn, int fd, int offset, Int4 len); Int4 odbc_lo_tell(ConnectionClass *conn, int fd); Int8 odbc_lo_lseek64(ConnectionClass *conn, int fd, Int8 offset, Int4 len); Int8 odbc_lo_tell64(ConnectionClass *conn, int fd); #endif psqlodbc-REL-16_00_0005/misc.c000066400000000000000000000137301462406103600156010ustar00rootroot00000000000000/*------- * Module: misc.c * * Description: This module contains miscellaneous routines * such as for debugging/logging and string functions. * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "psqlodbc.h" #include "misc.h" #include #include #include #include #include #ifndef WIN32 #include #include #include #else #include /* Byron: is this where Windows keeps def. * of getpid ? */ #endif /* * returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied * (not including null term) */ ssize_t my_strcpy(char *dst, ssize_t dst_len, const char *src, ssize_t src_len) { if (dst_len <= 0) return STRCPY_FAIL; if (src_len == SQL_NULL_DATA) { dst[0] = '\0'; return STRCPY_NULL; } else if (src_len == SQL_NTS) src_len = strlen(src); if (src_len <= 0) return STRCPY_FAIL; else { if (src_len < dst_len) { memcpy(dst, src, src_len); dst[src_len] = '\0'; } else { memcpy(dst, src, dst_len - 1); dst[dst_len - 1] = '\0'; /* truncated */ return STRCPY_TRUNCATED; } } return strlen(dst); } /* * strncpy copies up to len characters, and doesn't terminate * the destination string if src has len characters or more. * instead, I want it to copy up to len-1 characters and always * terminate the destination string. */ size_t strncpy_null(char *dst, const char *src, ssize_t len) { int i; if (NULL != dst && len > 0) { for (i = 0; src[i] && i < len - 1; i++) dst[i] = src[i]; dst[i] = '\0'; } else return 0; if (src[i]) return strlen(src); return i; } /*------ * Create a null terminated string (handling the SQL_NTS thing): * 1. If buf is supplied, place the string in there * (assumes enough space) and return buf. * 2. If buf is not supplied, malloc space and return this string *------ */ char * make_string(const SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize) { size_t length; char *str; if (!s || SQL_NULL_DATA == len) return NULL; if (len >= 0) length =len; else if (SQL_NTS == len) length = strlen((char *) s); else { MYLOG(0, "invalid length=" FORMAT_INTEGER "\n", len); return NULL; } if (buf) { strncpy_null(buf, (char *) s, bufsize > length ? length + 1 : bufsize); return buf; } MYLOG(DETAIL_LOG_LEVEL, "malloc size=" FORMAT_SIZE_T "\n", length); str = malloc(length + 1); MYLOG(DETAIL_LOG_LEVEL, "str=%p\n", str); if (!str) return NULL; strncpy_null(str, (char *) s, length + 1); return str; } char * my_trim(char *s) { char *last; for (last = s + strlen(s) - 1; last >= s; last--) { if (*last == ' ') *last = '\0'; else break; } return s; } /* * snprintfcat is a extension to snprintf * It add format to buf at given pos */ #ifdef POSIX_SNPRINTF_REQUIRED static posix_vsnprintf(char *str, size_t size, const char *format, va_list ap); #define vsnprintf posix_vsnprintf #endif /* POSIX_SNPRINTF_REQUIRED */ int snprintfcat(char *buf, size_t size, const char *format, ...) { int len; size_t pos = strlen(buf); va_list arglist; va_start(arglist, format); len = vsnprintf(buf + pos, size - pos, format, arglist); va_end(arglist); return len + pos; } /* * snprintf_len is a extension to snprintf * It returns strlen of buf every time (not -1 when truncated) */ size_t snprintf_len(char *buf, size_t size, const char *format, ...) { ssize_t len; va_list arglist; va_start(arglist, format); if ((len = vsnprintf(buf, size, format, arglist)) < 0) len = size; va_end(arglist); return len; } /* * Windows doesn't have snprintf(). It has _snprintf() which is similar, * but it behaves differently wrt. truncation. This is a compatibility * function that uses _snprintf() to provide POSIX snprintf() behavior. * * Our strategy, if the output doesn't fit, is to create a temporary buffer * and call _snprintf() on that. If it still doesn't fit, enlarge the buffer * and repeat. */ #ifdef POSIX_SNPRINTF_REQUIRED static int posix_vsnprintf(char *str, size_t size, const char *format, va_list ap) { int len; char *tmp; size_t newsize; len = _vsnprintf(str, size, format, ap); if (len < 0) { if (size == 0) newsize = 100; else newsize = size; do { newsize *= 2; tmp = malloc(newsize); if (!tmp) return -1; len = _vsnprintf(tmp, newsize, format, ap); if (len >= 0) memcpy(str, tmp, size); free(tmp); } while (len < 0); } if (len >= size && size > 0) { /* Ensure the buffer is NULL-terminated */ str[size - 1] = '\0'; } return len; } int posix_snprintf(char *buf, size_t size, const char *format, ...) { int len; va_list arglist; va_start(arglist, format); len = posix_vsnprintf(buf, size, format, arglist); va_end(arglist); return len; } #endif /* POSIX_SNPRINTF_REQUIRED */ #ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t size) { size_t ttllen; char *pd = dst; const char *ps= src; for (ttllen = 0; ttllen < size; ttllen++, pd++) { if (0 == *pd) break; } if (ttllen >= size - 1) return ttllen + strlen(src); for (; ttllen < size - 1; ttllen++, pd++, ps++) { if (0 == (*pd = *ps)) return ttllen; } *pd = 0; for (; *ps; ttllen++, ps++) ; return ttllen; } #endif /* HAVE_STRLCAT */ /* * Proprly quote and escape a possibly schema-qualified table name. */ char * quote_table(const pgNAME schema, const pgNAME table, char *buf, int buf_size) { const char *ptr; int i; i = 0; if (NAME_IS_VALID(schema)) { buf[i++] = '"'; for (ptr = SAFE_NAME(schema); *ptr != '\0' && i < buf_size - 6; ptr++) { buf[i++] = *ptr; if (*ptr == '"') buf[i++] = '"'; /* escape quotes by doubling them */ } buf[i++] = '"'; buf[i++] = '.'; } buf[i++] = '"'; for (ptr = SAFE_NAME(table); *ptr != '\0' && i < buf_size - 3; ptr++) { buf[i++] = *ptr; if (*ptr == '"') buf[i++] = '"'; /* escape quotes by doubling them */ } buf[i++] = '"'; buf[i] = '\0'; return buf; } psqlodbc-REL-16_00_0005/misc.h000066400000000000000000000053121462406103600156030ustar00rootroot00000000000000/* File: misc.h * * Description: See "misc.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __MISC_H__ #define __MISC_H__ #include #ifndef WIN32 #include #endif #ifdef __cplusplus extern "C" { #endif size_t strncpy_null(char *dst, const char *src, ssize_t len); #ifndef HAVE_STRLCAT size_t strlcat(char *, const char *, size_t); #endif /* HAVE_STRLCAT */ int snprintfcat(char *buf, size_t size, const char *format, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4))); size_t snprintf_len(char *buf, size_t size, const char *format, ...); char *my_trim(char *string); char *make_string(const SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize); /* #define GET_SCHEMA_NAME(nspname) (stricmp(nspname, "public") ? nspname : "") */ char *quote_table(const pgNAME schema, const pgNAME table, char *buf, int nuf_size); #define GET_SCHEMA_NAME(nspname) (nspname) /* defines for return value of my_strcpy */ #define STRCPY_SUCCESS 1 #define STRCPY_FAIL 0 #define STRCPY_TRUNCATED (-1) #define STRCPY_NULL (-2) ssize_t my_strcpy(char *dst, ssize_t dst_len, const char *src, ssize_t src_len); /* * Macros to safely strcpy, strcat or sprintf to fixed arrays. * */ /* * With GCC, the macro CHECK_NOT_CHAR_P() causes a compilation error * when the target is pointer not a fixed array. */ #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 #define FUNCTION_BEGIN_MACRO ({ #define FUNCTION_END_MACRO ;}) #define CHECK_NOT_CHAR_P(t) \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wunused-variable\"") \ if (0) { typeof(t) dummy_for_check = {};} \ _Pragma ("GCC diagnostic pop") #else #define FUNCTION_BEGIN_MACRO #define FUNCTION_END_MACRO #define CHECK_NOT_CHAR_P(t) #endif /* macro to safely strcpy() to fixed arrays. */ #define STRCPY_FIXED(to, from) \ FUNCTION_BEGIN_MACRO \ CHECK_NOT_CHAR_P(to) \ strncpy_null((to), (from), sizeof(to)) \ FUNCTION_END_MACRO /* macro to safely strcat() to fixed arrays. */ #define STRCAT_FIXED(to, from) \ FUNCTION_BEGIN_MACRO \ CHECK_NOT_CHAR_P(to) \ strlcat((to), (from), sizeof(to)) \ FUNCTION_END_MACRO /* macro to safely sprintf() to fixed arrays. */ #define SPRINTF_FIXED(to, ...) \ FUNCTION_BEGIN_MACRO \ CHECK_NOT_CHAR_P(to) \ snprintf((to), sizeof(to), __VA_ARGS__) \ FUNCTION_END_MACRO /* macro to safely sprintf() & cat to fixed arrays. */ #define SPRINTFCAT_FIXED(to, ...) \ FUNCTION_BEGIN_MACRO \ CHECK_NOT_CHAR_P(to) \ snprintfcat((to), sizeof(to), __VA_ARGS__) \ FUNCTION_END_MACRO #define ITOA_FIXED(to, from) \ FUNCTION_BEGIN_MACRO \ CHECK_NOT_CHAR_P(to) \ snprintf((to), sizeof(to), "%d", from) \ FUNCTION_END_MACRO #ifdef __cplusplus } #endif #endif /* __MISC_H__ */ psqlodbc-REL-16_00_0005/msdtc_enlist.cpp000077500000000000000000000774251462406103600177140ustar00rootroot00000000000000/* Module: msdtc_enlist.cpp * * Description: * This module contains routines related to * the enlistment in MSDTC. * *------- */ #ifdef _HANDLE_ENLIST_IN_DTC_ #undef _MEMORY_DEBUG_ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif /* _WIN32_WINNT */ #define WIN32_LEAN_AND_MEAN #include #include /*#include */ #define _PGDTC_FUNCS_IMPORT_ #include "connexp.h" /*#define _SLEEP_FOR_TEST_*/ #include #include #include #include #include #ifndef WIN32 #include #endif /* WIN32 */ #include #define _MYLOG_FUNCS_IMPORT_ #include "mylog.h" #define _PGENLIST_FUNCS_IMPLEMENT_ #include "pgenlist.h" #include "xalibname.h" #ifdef WIN32 #ifndef snprintf #define snprintf _snprintf #endif /* snprintf */ #endif /* WIN32 */ /* Define a type for defining a constant string expression */ #ifndef CSTR #define CSTR static const char * const #endif /* CSTR */ EXTERN_C { HINSTANCE s_hModule; /* Saved module handle. */ } /* This is where the Driver Manager attaches to this Driver */ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: s_hModule = (HINSTANCE) hInst; /* Save for dialog boxes */ break; case DLL_PROCESS_DETACH: mylog("DETACHING pgenlist\n"); break; } return TRUE; } /* * A comment About locks used in this module * * the locks should be acquired with stronger to weaker order. * * 1:ELOCK -- the strongest per IAsyncPG object lock * When the *isolated* or *dtcconn* member of an IAsyncPG object * is changed, this lock should be held. * While an IAsyncPG object accesses a psqlodbc connection, * this lock should be held. * * 2:[CONN_CS] -- per psqlodbc connection lock * This lock would be held for a pretty long time while accessing * the psqlodbc connection assigned to an IAsyncPG object. You * can use the connection safely by holding a ELOCK for the * IAsyncPG object because the assignment is ensured to be * fixed while the ELOCK is held. * * 3:LIFELOCK -- a global lock to ensure the lives of IAsyncPG objects * While this lock is held, IAsyncPG objects would never die. * * 4:SLOCK -- the short term per IAsyncPG object lock * When any member of an IAsyncPG object is changed, this lock * should be held. */ // #define _LOCK_DEBUG_ static class INIT_CRIT { public: CRITICAL_SECTION life_cs; /* for asdum member of ConnectionClass */ INIT_CRIT() { InitializeCriticalSection(&life_cs); } ~INIT_CRIT() { DeleteCriticalSection(&life_cs); } } init_crit; #define LIFELOCK_ACQUIRE EnterCriticalSection(&init_crit.life_cs) #define LIFELOCK_RELEASE LeaveCriticalSection(&init_crit.life_cs) /* * Some helper macros about connection handling. */ #define CONN_CS_ACQUIRE(conn) PgDtc_lock_cntrl((conn), TRUE, FALSE) #define TRY_CONN_CS_ACQUIRE(conn) PgDtc_lock_cntrl((conn), TRUE, TRUE) #define CONN_CS_RELEASE(conn) PgDtc_lock_cntrl((conn), FALSE, FALSE) #define CONN_IS_IN_TRANS(conn) PgDtc_get_property((conn), inTrans) static const char *XidToText(const XID &xid, char *rtext) { int glen = xid.gtrid_length, blen = xid.bqual_length; int i, j; for (i = 0, j = 0; i < glen; i++, j += 2) sprintf(rtext + j, "%02x", (unsigned char) xid.data[i]); strcat(rtext, "-"); j++; for (; i < glen + blen; i++, j += 2) sprintf(rtext + j, "%02x", (unsigned char) xid.data[i]); return rtext; } static LONG g_cComponents = 0; static LONG g_cServerLocks = 0; // // ȉITransactionResourceAsyncIuWFNg͔Cӂ̃Xbh // RɃANZX”\Ȃ悤ɎBeRequesťʂԂ߂ // gpITransactionEnlistmentAsyncC^[tFCX̂悤 // ĂiƎvALQƁĵŌĂяoCOM̃Ap[ // ggӎ(CoMarshalInterThreadInterfaceInStream/CoGetIn // terfaceAndReleaseStreamgpjKv͂ȂB // DLLŎgpITransactionResourceAsyncITransactionEnlist // mentAsync̃C^[tFCX|C^[͔Cӂ̃Xbh璼ڎgp // 邱ƂłB // // OLE Transactions Standard // // OLE Transactions is the Microsoft interface standard for transaction // management. Applications use OLE Transactions-compliant interfaces to // initiate, commit, abort, and inquire about transactions. Resource // managers use OLE Transactions-compliant interfaces to enlist in // transactions, to propagate transactions to other resource managers, // to propagate transactions from process to process or from system to // system, and to participate in the two-phase commit protocol. // // The Microsoft DTC system implements most OLE Transactions-compliant // objects, interfaces, and methods. Resource managers that wish to use // OLE Transactions must implement some OLE Transactions-compliant objects, // interfaces, and methods. // // The OLE Transactions specification is based on COM but it differs in the // following respects: // // OLE Transactions objects cannot be created using the COM CoCreate APIs. // References to OLE Transactions objects are always direct. Therefore, // no proxies or stubs are created for inter-apartment, inter-process, // or inter-node calls and OLE Transactions references cannot be marshaled // using standard COM marshaling. // All references to OLE Transactions objects and their sinks are completely // free threaded and cannot rely upon COM concurrency control models. // For example, you cannot pass a reference to an IResourceManagerSink // interface on a single-threaded apartment and expect the callback to occur // only on the same single-threaded apartment. class IAsyncPG : public ITransactionResourceAsync { private: IDtcToXaHelperSinglePipe *helper; DWORD RMCookie; void *dtcconn; LONG refcnt; CRITICAL_SECTION as_spin; // to make this object Both CRITICAL_SECTION as_exec; // to make this object Both XID xid; bool isolated; bool prepared; bool done; bool abort; HANDLE eThread[3]; bool eFin[3]; bool requestAccepted; HRESULT prepare_result; HRESULT commit_result; #ifdef _LOCK_DEBUG_ int spin_cnt; int cs_cnt; #endif /* _LOCK_DEBUG_ */ public: enum { PrepareExec = 0 ,CommitExec ,AbortExec }; ITransactionEnlistmentAsync *enlist; HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); ULONG STDMETHODCALLTYPE AddRef(void); ULONG STDMETHODCALLTYPE Release(void); HRESULT STDMETHODCALLTYPE PrepareRequest(BOOL fRetaining, DWORD grfRM, BOOL fWantMoniker, BOOL fSinglePhase); HRESULT STDMETHODCALLTYPE CommitRequest(DWORD grfRM, XACTUOW * pNewUOW); HRESULT STDMETHODCALLTYPE AbortRequest(BOID * pboidReason, BOOL fRetaining, XACTUOW * pNewUOW); HRESULT STDMETHODCALLTYPE TMDown(void); IAsyncPG(); void SetHelper(IDtcToXaHelperSinglePipe *pHelper, DWORD dwRMCookie) {helper = pHelper; RMCookie = dwRMCookie;} HRESULT RequestExec(DWORD type, HRESULT res); HRESULT ReleaseConnection(void); void SetConnection(void *sconn) {SLOCK_ACQUIRE(); dtcconn = sconn; SLOCK_RELEASE();} void SetXid(const XID *ixid) {SLOCK_ACQUIRE(); xid = *ixid; SLOCK_RELEASE();} void *separateXAConn(bool spinAcquired, bool continueConnection); bool CloseThread(DWORD type); private: ~IAsyncPG(); void SLOCK_ACQUIRE() {EnterCriticalSection(&as_spin);} void SLOCK_RELEASE() {LeaveCriticalSection(&as_spin);} void ELOCK_ACQUIRE() {EnterCriticalSection(&as_exec);} void ELOCK_RELEASE() {LeaveCriticalSection(&as_exec);} void *getLockedXAConn(void); void *generateXAConn(bool spinAcquired); void *isolateXAConn(bool spinAcquired, bool continueConnection); void SetPrepareResult(HRESULT res) {SLOCK_ACQUIRE(); prepared = true; prepare_result = res; SLOCK_RELEASE();} void SetDone(HRESULT); void Wait_pThread(bool slock_hold); void Wait_cThread(bool slock_hold, bool once); }; IAsyncPG::IAsyncPG(void) : helper(NULL), RMCookie(0), enlist(NULL), dtcconn(NULL), refcnt(1), isolated(false), done(false), abort(false), prepared(false), requestAccepted(false) { InterlockedIncrement(&g_cComponents); InitializeCriticalSection(&as_spin); InitializeCriticalSection(&as_exec); eThread[0] = eThread[1] = eThread[2] = NULL; eFin[0] = eFin[1] = eFin[2] = false; memset(&xid, 0, sizeof(xid)); #ifdef _LOCK_DEBUG_ spin_cnt = 0; cs_cnt = 0; #endif /* _LOCK_DEBUG_ */ } // // invoked from *delete*. // When entered ELOCK -> LIFELOCK -> SLOCK are held // and they are released. // IAsyncPG::~IAsyncPG(void) { void *fconn = NULL; if (dtcconn) { if (isolated) fconn = dtcconn; PgDtc_set_async(dtcconn, NULL); dtcconn = NULL; } SLOCK_RELEASE(); LIFELOCK_RELEASE; if (fconn) { mylog("IAsyncPG Destructor is freeing the connection\n"); PgDtc_free_connect(fconn); } DeleteCriticalSection(&as_spin); ELOCK_RELEASE(); DeleteCriticalSection(&as_exec); InterlockedDecrement(&g_cComponents); } HRESULT STDMETHODCALLTYPE IAsyncPG::QueryInterface(REFIID riid, void ** ppvObject) { mylog("%p QueryInterface called\n", this); if (riid == IID_IUnknown || riid == IID_ITransactionResourceAsync) { *ppvObject = this; AddRef(); return S_OK; } *ppvObject = NULL; return E_NOINTERFACE; } // // acquire/releases SLOCK. // ULONG STDMETHODCALLTYPE IAsyncPG::AddRef(void) { mylog("%p->AddRef called\n", this); SLOCK_ACQUIRE(); refcnt++; SLOCK_RELEASE(); return refcnt; } // // acquire/releases [ELOCK -> LIFELOCK -> ] SLOCK. // ULONG STDMETHODCALLTYPE IAsyncPG::Release(void) { mylog("%p->Release called refcnt=%d\n", this, refcnt); SLOCK_ACQUIRE(); refcnt--; if (refcnt <= 0) { SLOCK_RELEASE(); ELOCK_ACQUIRE(); LIFELOCK_ACQUIRE; SLOCK_ACQUIRE(); if (refcnt <=0) { const int refcnt_copy = refcnt; mylog("delete %p\n", this); delete this; return refcnt_copy; } else { SLOCK_RELEASE(); LIFELOCK_RELEASE; ELOCK_RELEASE(); } } else SLOCK_RELEASE(); return refcnt; } // // Acquire/release SLOCK. // void IAsyncPG::Wait_pThread(bool slock_hold) { mylog("Wait_pThread %d in\n", slock_hold); HANDLE wThread; int wait_idx = PrepareExec; DWORD ret; if (!slock_hold) SLOCK_ACQUIRE(); while (NULL != (wThread = eThread[wait_idx]) && !eFin[wait_idx]) { SLOCK_RELEASE(); ret = WaitForSingleObject(wThread, 2000); SLOCK_ACQUIRE(); if (WAIT_TIMEOUT != ret) eFin[wait_idx] = true; } if (!slock_hold) SLOCK_RELEASE(); mylog("Wait_pThread out\n"); } // // Acquire/releases SLOCK. // void IAsyncPG::Wait_cThread(bool slock_hold, bool once) { HANDLE wThread; int wait_idx; DWORD ret; mylog("Wait_cThread %d,%d in\n", slock_hold, once); if (!slock_hold) SLOCK_ACQUIRE(); if (NULL != eThread[CommitExec]) wait_idx = CommitExec; else wait_idx = AbortExec; while (NULL != (wThread = eThread[wait_idx]) && !eFin[wait_idx]) { SLOCK_RELEASE(); ret = WaitForSingleObject(wThread, 2000); SLOCK_ACQUIRE(); if (WAIT_TIMEOUT != ret) eFin[wait_idx] = true; else if (once) break; } if (!slock_hold) SLOCK_RELEASE(); mylog("Wait_cThread out\n"); } /* Processing Prepare/Commit Request */ typedef struct RequestPara { DWORD type; LPVOID lpr; HRESULT res; } RequestPara; // // Acquire/releases LIFELOCK -> SLOCK. // may acquire/release ELOCK. // void IAsyncPG::SetDone(HRESULT res) { LIFELOCK_ACQUIRE; SLOCK_ACQUIRE(); done = true; if (E_FAIL == res || E_UNEXPECTED == res) abort = true; requestAccepted = true; commit_result = res; if (dtcconn) { PgDtc_set_async(dtcconn, NULL); if (isolated) { SLOCK_RELEASE(); LIFELOCK_RELEASE; ELOCK_ACQUIRE(); if (dtcconn) { mylog("Freeing isolated connection=%p\n", dtcconn); PgDtc_free_connect(dtcconn); SetConnection(NULL); } ELOCK_RELEASE(); } else { dtcconn = NULL; SLOCK_RELEASE(); LIFELOCK_RELEASE; } } else { SLOCK_RELEASE(); LIFELOCK_RELEASE; } } // // Acquire/releases [ELOCK -> LIFELOCK -> ] SLOCK. // void *IAsyncPG::generateXAConn(bool spinAcquired) { mylog("generateXAConn isolated=%d dtcconn=%p\n", isolated, dtcconn); if (!spinAcquired) SLOCK_ACQUIRE(); if (isolated || done) { SLOCK_RELEASE(); return dtcconn; } SLOCK_RELEASE(); ELOCK_ACQUIRE(); LIFELOCK_ACQUIRE; SLOCK_ACQUIRE(); if (dtcconn && !isolated && !done && prepared) { void *sconn = dtcconn; dtcconn = PgDtc_isolate(sconn, useAnotherRoom); isolated = true; SLOCK_RELEASE(); LIFELOCK_RELEASE; // PgDtc_connect(dtcconn); may be called in getLockedXAConn } else { SLOCK_RELEASE(); LIFELOCK_RELEASE; } ELOCK_RELEASE(); return dtcconn; } // // Acquire/releases [ELOCK -> LIFELOCK -> ] SLOCK. // void *IAsyncPG::isolateXAConn(bool spinAcquired, bool continueConnection) { void *sconn; mylog("isolateXAConn isolated=%d dtcconn=%p\n", isolated, dtcconn); if (!spinAcquired) SLOCK_ACQUIRE(); if (isolated || done || NULL == dtcconn) { SLOCK_RELEASE(); return dtcconn; } SLOCK_RELEASE(); ELOCK_ACQUIRE(); LIFELOCK_ACQUIRE; SLOCK_ACQUIRE(); if (isolated || done || NULL == dtcconn) { SLOCK_RELEASE(); LIFELOCK_RELEASE; ELOCK_RELEASE(); return dtcconn; } sconn = dtcconn; dtcconn = PgDtc_isolate(sconn, continueConnection ? 0 : disposingConnection); isolated = true; SLOCK_RELEASE(); LIFELOCK_RELEASE; if (continueConnection) { PgDtc_connect(sconn); } ELOCK_RELEASE(); return dtcconn; } // // Acquire/releases [ELOCK -> LIFELOCK -> ] SLOCK. // void *IAsyncPG::separateXAConn(bool spinAcquired, bool continueConnection) { mylog("%s isolated=%d dtcconn=%p\n", __FUNCTION__, isolated, dtcconn); if (!spinAcquired) SLOCK_ACQUIRE(); if (prepared) return generateXAConn(true); else return isolateXAConn(true, continueConnection); } // // [when entered] // ELOCK is held. // // Acquire/releases SLOCK. // Try to acquire CONN_CS also. // // [on exit] // ELOCK is kept held. // If the return connection != NULL // the CONN_CS lock for the connection is held. // void *IAsyncPG::getLockedXAConn() { SLOCK_ACQUIRE(); while (!done && !isolated && NULL != dtcconn) { /* * Note that COMMIT/ROLLBACK PREPARED command should be * issued outside the transaction. */ if (!prepared || !CONN_IS_IN_TRANS(dtcconn)) { if (TRY_CONN_CS_ACQUIRE(dtcconn)) { if (prepared && CONN_IS_IN_TRANS(dtcconn)) { CONN_CS_RELEASE(dtcconn); } else break; } } separateXAConn(true, true); SLOCK_ACQUIRE(); // SLOCK was released by separateXAConn() } SLOCK_RELEASE(); if (isolated && NULL != dtcconn) { CONN_CS_ACQUIRE(dtcconn); if (!PgDtc_get_property(dtcconn, connected)) PgDtc_connect(dtcconn); } return dtcconn; } // // Acquire/release ELOCK -> SLOCK. // HRESULT IAsyncPG::RequestExec(DWORD type, HRESULT res) { HRESULT ret; bool bReleaseEnlist = false; void *econn; char pgxid[258]; mylog("%p->RequestExec type=%d conn=%p\n", this, type, dtcconn); XidToText(xid, pgxid); #ifdef _SLEEP_FOR_TEST_ /*Sleep(2000);*/ #endif /* _SLEEP_FOR_TEST_ */ ELOCK_ACQUIRE(); switch (type) { case PrepareExec: if (done || NULL == dtcconn) { res = E_UNEXPECTED; break; } if (econn = getLockedXAConn(), NULL != econn) { PgDtc_set_property(econn, inprogress, (void *) 1); if (E_FAIL == res) PgDtc_one_phase_operation(econn, ABORT_GLOBAL_TRANSACTION); else if (XACT_S_SINGLEPHASE == res) { if (!PgDtc_one_phase_operation(econn, ONE_PHASE_COMMIT)) res = E_FAIL; } else { if (!PgDtc_two_phase_operation(econn, PREPARE_TRANSACTION, pgxid)) res = E_FAIL; } PgDtc_set_property(econn, inprogress, (void *) 0); CONN_CS_RELEASE(econn); } if (S_OK != res) { SetDone(res); bReleaseEnlist = true; } ret = enlist->PrepareRequestDone(res, NULL, NULL); SetPrepareResult(res); break; case CommitExec: Wait_pThread(false); if (E_FAIL != res) { econn = getLockedXAConn(); if (econn) { PgDtc_set_property(econn, inprogress, (void *) 1); if (!PgDtc_two_phase_operation(econn, COMMIT_PREPARED, pgxid)) res = E_FAIL; PgDtc_set_property(econn, inprogress, (void *) 0); CONN_CS_RELEASE(econn); } } SetDone(res); ret = enlist->CommitRequestDone(res); bReleaseEnlist = true; break; case AbortExec: Wait_pThread(false); if (prepared && !done) { econn = getLockedXAConn(); if (econn) { PgDtc_set_property(econn, inprogress, (void *) 1); if (!PgDtc_two_phase_operation(econn, ROLLBACK_PREPARED, pgxid)) res = E_FAIL; PgDtc_set_property(econn, inprogress, (void *) 0); CONN_CS_RELEASE(econn); } } SetDone(res); ret = enlist->AbortRequestDone(res); bReleaseEnlist = true; break; default: ret = -1; } if (bReleaseEnlist) { helper->ReleaseRMCookie(RMCookie, TRUE); enlist->Release(); } ELOCK_RELEASE(); mylog("%p->Done ret=%d\n", this, ret); return ret; } // // Acquire/releses SLOCK // or [ELOCK -> LIFELOCK -> ] SLOCK. // HRESULT IAsyncPG::ReleaseConnection(void) { mylog("%p->ReleaseConnection\n", this); SLOCK_ACQUIRE(); if (isolated || NULL == dtcconn) { SLOCK_RELEASE(); return SQL_SUCCESS; } Wait_pThread(true); if (NULL != eThread[CommitExec] || NULL != eThread[AbortExec] || requestAccepted) { if (!done) Wait_cThread(true, true); } if (!isolated && !done && dtcconn && PgDtc_get_property(dtcconn, connected)) { isolateXAConn(true, false); } else SLOCK_RELEASE(); mylog("%p->ReleaseConnection exit\n", this); return SQL_SUCCESS; } EXTERN_C static unsigned WINAPI DtcRequestExec(LPVOID para); EXTERN_C static void __cdecl ClosePrepareThread(LPVOID para); EXTERN_C static void __cdecl CloseCommitThread(LPVOID para); EXTERN_C static void __cdecl CloseAbortThread(LPVOID para); // // Acquire/release [ELOCK -> ] SLOCK. // HRESULT STDMETHODCALLTYPE IAsyncPG::PrepareRequest(BOOL fRetaining, DWORD grfRM, BOOL fWantMoniker, BOOL fSinglePhase) { HRESULT ret, res; RequestPara *reqp; const DWORD reqtype = PrepareExec; mylog("%p PrepareRequest called grhRM=%d enl=%p\n", this, grfRM, enlist); SLOCK_ACQUIRE(); if (dtcconn && 0 != PgDtc_get_property(dtcconn, errorNumber)) res = ret = E_FAIL; else { ret = S_OK; if (fSinglePhase) { res = XACT_S_SINGLEPHASE; mylog("XACT is singlePhase\n"); } else res = S_OK; } SLOCK_RELEASE(); ELOCK_ACQUIRE(); #ifdef _SLEEP_FOR_TEST_ Sleep(2000); #endif /* _SLEEP_FOR_TEST_ */ reqp = new RequestPara; reqp->type = reqtype; reqp->lpr = (LPVOID) this; reqp->res = res; #define DONT_CALL_RETURN_FROM_HERE ??? AddRef(); HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, DtcRequestExec, reqp, 0, NULL); if (NULL == hThread) { delete(reqp); ret = E_FAIL; } else { SLOCK_ACQUIRE(); eThread[reqtype] = hThread; SLOCK_RELEASE(); /* * We call here _beginthread not _beginthreadex * so as not to call CloseHandle() to clean up * the thread. */ _beginthread(ClosePrepareThread, 0, (void *) this); } ELOCK_RELEASE(); Release(); #undef return return ret; } // // Acquire/release [ELOCK -> ] SLOCK. // HRESULT STDMETHODCALLTYPE IAsyncPG::CommitRequest(DWORD grfRM, XACTUOW * pNewUOW) { HRESULT res = S_OK, ret = S_OK; RequestPara *reqp; const DWORD reqtype = CommitExec; mylog("%p CommitRequest called grfRM=%d enl=%p\n", this, grfRM, enlist); SLOCK_ACQUIRE(); if (!prepared || done) ret = E_UNEXPECTED; else if (S_OK != prepare_result) ret = E_UNEXPECTED; SLOCK_RELEASE(); if (S_OK != ret) return ret; #define DONT_CALL_RETURN_FROM_HERE ??? AddRef(); ELOCK_ACQUIRE(); #ifdef _SLEEP_FOR_TEST_ Sleep(1000); #endif /* _SLEEP_FOR_TEST_ */ reqp = new RequestPara; reqp->type = reqtype; reqp->lpr = (LPVOID) this; reqp->res = res; enlist->AddRef(); HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, DtcRequestExec, reqp, 0, NULL); if (NULL == hThread) { delete(reqp); enlist->Release(); ret = E_FAIL; } else { SLOCK_ACQUIRE(); eThread[reqtype] = hThread; SLOCK_RELEASE(); /* * We call here _beginthread not _beginthreadex * so as not to call CloseHandle() to clean up * the thread. */ _beginthread(CloseCommitThread, 0, (void *) this); } mylog("CommitRequest ret=%d\n", ret); requestAccepted = true; ELOCK_RELEASE(); Release(); #undef return return ret; } // // Acquire/release [ELOCK -> ] SLOCK. // HRESULT STDMETHODCALLTYPE IAsyncPG::AbortRequest(BOID * pboidReason, BOOL fRetaining, XACTUOW * pNewUOW) { HRESULT res = S_OK, ret = S_OK; RequestPara *reqp; const DWORD reqtype = AbortExec; mylog("%p AbortRequest called\n", this); SLOCK_ACQUIRE(); if (done) ret = E_UNEXPECTED; else if (prepared && S_OK != prepare_result) ret = E_UNEXPECTED; SLOCK_RELEASE(); if (S_OK != ret) return ret; #define return DONT_CALL_RETURN_FROM_HERE ??? AddRef(); ELOCK_ACQUIRE(); if (!prepared && dtcconn) { PgDtc_set_property(dtcconn, inprogress, (void *) 1); PgDtc_one_phase_operation(dtcconn, ONE_PHASE_ROLLBACK); PgDtc_set_property(dtcconn, inprogress, (void *) 0); } reqp = new RequestPara; reqp->type = reqtype; reqp->lpr = (LPVOID) this; reqp->res = res; enlist->AddRef(); HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, DtcRequestExec, reqp, 0, NULL); if (NULL == hThread) { delete(reqp); enlist->Release(); ret = E_FAIL; } else { SLOCK_ACQUIRE(); eThread[reqtype] = hThread; SLOCK_RELEASE(); /* * We call here _beginthread not _beginthreadex * so as not to call CloseHandle() to clean up * the thread. */ _beginthread(CloseAbortThread, 0, (void *) this); } mylog("AbortRequest ret=%d\n", ret); requestAccepted = true; ELOCK_RELEASE(); Release(); #undef return return ret; } HRESULT STDMETHODCALLTYPE IAsyncPG::TMDown(void) { mylog("%p TMDown called\n", this); return S_OK; } bool IAsyncPG::CloseThread(DWORD type) { CSTR func = "CloseThread"; HANDLE th; DWORD ret, excode = S_OK; bool rls_async = false; mylog("%s for %p thread=%d\n", func, this, eThread[type]); if (th = eThread[type], NULL == th || eFin[type]) return false; ret = WaitForSingleObject(th, INFINITE); if (WAIT_OBJECT_0 == ret) { switch (type) { case IAsyncPG::AbortExec: case IAsyncPG::CommitExec: rls_async = true; break; default: GetExitCodeThread(th, &excode); if (S_OK != excode) rls_async = true; } SLOCK_ACQUIRE(); eThread[type] = NULL; eFin[type] = true; SLOCK_RELEASE(); CloseHandle(th); } mylog("%s ret=%d\n", func, ret); return rls_async; } EXTERN_C static void __cdecl ClosePrepareThread(LPVOID para) { CSTR func = "ClosePrepareThread"; IAsyncPG *async = (IAsyncPG *) para; bool release; mylog("%s for %p", func, async); if (release = async->CloseThread(IAsyncPG::PrepareExec), release) async->Release(); mylog("%s release=%d\n", func, release); } EXTERN_C static void __cdecl CloseCommitThread(LPVOID para) { CSTR func = "CloseCommitThread"; IAsyncPG *async = (IAsyncPG *) para; bool release; mylog("%s for %p", func, async); if (release = async->CloseThread(IAsyncPG::CommitExec), release) async->Release(); mylog("%s release=%d\n", func, release); } EXTERN_C static void __cdecl CloseAbortThread(LPVOID para) { CSTR func = "CloseAbortThread"; IAsyncPG *async = (IAsyncPG *) para; bool release; mylog("%s for %p", func, async); if (release = async->CloseThread(IAsyncPG::AbortExec), release) async->Release(); mylog("%s release=%d\n", func, release); } EXTERN_C static unsigned WINAPI DtcRequestExec(LPVOID para) { RequestPara *reqp = (RequestPara *) para; DWORD type = reqp->type; IAsyncPG *async = (IAsyncPG *) reqp->lpr; HRESULT res = reqp->res, ret; mylog("DtcRequestExec type=%d", reqp->type); delete(reqp); ret = async->RequestExec(type, res); mylog(" Done ret=%d\n", ret); return ret; } CSTR regKey = "SOFTWARE\\Microsoft\\MSDTC\\XADLL"; static int regkeyCheck(const char *xalibname, const char *xalibpath) { int retcode = 0; LONG ret; HKEY sKey; DWORD rSize; ret = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey, 0, KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_64KEY, &sKey); switch (ret) { case ERROR_SUCCESS: break; case ERROR_FILE_NOT_FOUND: ret = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, regKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sKey, NULL); mylog("%s:CreateKeyEx ret=%d\n", __FUNCTION__, ret); break; default: mylog("%s:OpenKeyEx ret=%d\n", __FUNCTION__, ret); } if (ERROR_SUCCESS != ret) return -1; else { char keyval[1024]; rSize = sizeof(keyval); switch (ret = ::RegQueryValueEx(sKey, xalibname, NULL, NULL, (LPBYTE) keyval, &rSize)) { case ERROR_SUCCESS: if (rSize > 0) { if (0 == _stricmp(keyval, xalibpath)) break; mylog("%s:XADLL value %s is different from %s\n", __FUNCTION__, keyval, xalibpath); if (IsWow64()) { mylog("%s:avoid RegSetValue operation from wow64 process\n", __FUNCTION__); break; } } case ERROR_FILE_NOT_FOUND: mylog("%s:Setting value %s\n", __FUNCTION__, xalibpath); ret = ::RegSetValueEx(sKey, xalibname, 0, REG_SZ, (CONST BYTE *) xalibpath, (DWORD) strlen(xalibpath) + 1); if (ERROR_SUCCESS == ret) retcode = 1; else { retcode = -1; mylog("%s:SetValueEx ret=%d\n", __FUNCTION__, ret); } break; default: retcode = -1; mylog("%s:QueryValueEx ret=%d\n", __FUNCTION__, ret); break; } ::RegCloseKey(sKey); } return retcode; } RETCODE static EnlistInDtc_1pipe(void *conn, ITransaction *pTra, ITransactionDispenser *pDtc, int method) { CSTR func = "EnlistInDtc_1pipe"; static IDtcToXaHelperSinglePipe *pHelper = NULL; ITransactionResourceAsync *pRes = NULL; IAsyncPG *asdum; HRESULT res; DWORD dwRMCookie; XID xid; const char *xalibname = GetXaLibName(); const char *xalibpath = GetXaLibPath(); int recovLvl; char errmsg[256]; char reason[128]; if (!pHelper) { res = pDtc->QueryInterface(IID_IDtcToXaHelperSinglePipe, (void **) &pHelper); if (res != S_OK || !pHelper) { mylog("DtcToXaHelperSinglePipe get error %d\n", res); pHelper = NULL; return SQL_ERROR; } } res = (NULL != (asdum = new IAsyncPG)) ? S_OK : E_FAIL; if (S_OK != res) { mylog("CoCreateInstance error %d\n", res); return SQL_ERROR; } recovLvl = PgDtc_is_recovery_available(conn, reason, sizeof(reason)); switch (method) { case DTC_CHECK_BEFORE_LINK: if (0 == recovLvl) { snprintf(errmsg, sizeof(errmsg), "%s is unavailable in distributed transactions", reason); PgDtc_set_error(conn, errmsg, func); return SQL_ERROR; } } /*mylog("dllname=%s dsn=%s\n", xalibname, conn->connInfo.dsn); res = 0;*/ char dtcname[1024]; PgDtc_create_connect_string(conn, dtcname, sizeof(dtcname)); bool confirmedRegkey = false, confirmingLink = false, xarmerr = false; char error_header[64]; while (true) { res = pHelper->XARMCreate(dtcname, (char *) xalibname, &dwRMCookie); mylog("XARMcreate error code=%x (%d %d)\n", res, confirmedRegkey, confirmingLink); xarmerr = true; if (!confirmingLink) snprintf(error_header, sizeof(error_header), "XARMcreate error code=%x", res); switch (res) { case S_OK: if (confirmingLink) { switch (recovLvl) { case 0: snprintf(errmsg, sizeof(errmsg), "%s:%s is currently unavailable in distributed transactions", error_header, reason); break; case -1: snprintf(errmsg, sizeof(errmsg), "%s:Possibly you connect to the database whose authentication method is %s or ident", error_header, reason); break; case 1: snprintf(errmsg, sizeof(errmsg), "%s:Are you trying to connect to the database whose authentication method is ident?", error_header); break; } } else xarmerr = false; break; case XACT_E_XA_TX_DISABLED: snprintf(errmsg, sizeof(errmsg), "%s:Please enable XA transaction in MSDTC security configuration", error_header); break; case XACT_E_TMNOTAVAILABLE: snprintf(errmsg, sizeof(errmsg), "%s:Please start Distributed Transaction Coordinator service", error_header); break; case E_FAIL: if (!confirmedRegkey) { int retcode = regkeyCheck(xalibname, xalibpath); confirmedRegkey = true; if (retcode > 0) continue; } switch (method) { case DTC_CHECK_RM_CONNECTION: if (!confirmingLink) { confirmingLink = true; strcat(dtcname, ";" KEYWORD_DTC_CHECK "=0"); continue; } default: snprintf(errmsg, sizeof(errmsg), "%s:Failed to link with DTC service. Please look at the log of Event Viewer etc.", error_header); } break; case XACT_E_CONNECTION_DOWN: snprintf(errmsg, sizeof(errmsg), "%s:Lost connection with DTC transaction manager\nMSDTC has some trouble?", error_header); break; default: snprintf(errmsg, sizeof(errmsg), "%s\n", error_header); break; } break; } if (xarmerr) { PgDtc_set_error(conn, errmsg, func); return SQL_ERROR; } res = pHelper->ConvertTridToXID((DWORD *) pTra, dwRMCookie, &xid); if (res != S_OK) { mylog("ConvertTridToXid error %d\n", res); return SQL_ERROR; } { char pgxid[258]; XidToText(xid, pgxid); mylog("ConvertTridToXID -> %s\n", pgxid); } asdum->SetXid(&xid); /* Create an IAsyncPG instance by myself */ /* DLLGetClassObject(GUID_IAsyncPG, IID_ITransactionResourceAsync, (void **) &asdum); */ asdum->SetHelper(pHelper, dwRMCookie); res = pHelper->EnlistWithRM(dwRMCookie, pTra, asdum, &asdum->enlist); if (res != S_OK) { mylog("EnlistWithRM error %d\n", res); pHelper->ReleaseRMCookie(dwRMCookie, TRUE); return SQL_ERROR; } mylog("asdum=%p start transaction\n", asdum); asdum->SetConnection(conn); LIFELOCK_ACQUIRE; PgDtc_set_async(conn, asdum); LIFELOCK_RELEASE; return SQL_SUCCESS; } EXTERN_C RETCODE IsolateDtcConn(void *conn, BOOL continueConnection) { IAsyncPG *async; LIFELOCK_ACQUIRE; if (async = (IAsyncPG *) PgDtc_get_async(conn), NULL != async) { if (PgDtc_get_property(conn, idleInGlobalTransaction)) { async->AddRef(); LIFELOCK_RELEASE; async->separateXAConn(false, continueConnection ? true : false); async->Release(); } else LIFELOCK_RELEASE; } else LIFELOCK_RELEASE; return SQL_SUCCESS; } static ITransactionDispenser *getITransactionDispenser(DWORD grfOptions, HRESULT *hres) { static ITransactionDispenser *pDtc = NULL; HRESULT res = S_OK; if (!pDtc) { res = DtcGetTransactionManagerEx(NULL, NULL, IID_ITransactionDispenser, grfOptions, NULL, (void **) &pDtc); if (FAILED(res)) { mylog("DtcGetTransactionManager error %x\n", res); pDtc = NULL; } } if (hres) *hres = res; return pDtc; } EXTERN_C void *GetTransactionObject(HRESULT *hres) { ITransaction *pTra = NULL; ITransactionDispenser *pDtc = NULL; if (pDtc = getITransactionDispenser(OLE_TM_FLAG_NONE, hres), NULL == pDtc) return pTra; HRESULT res = pDtc->BeginTransaction(NULL, ISOLATIONLEVEL_READCOMMITTED, 0, NULL, &pTra); switch (res) { case S_OK: break; default: pTra = NULL; } if (hres) *hres = res; return pTra; } EXTERN_C void ReleaseTransactionObject(void *pObj) { ITransaction *pTra = (ITransaction *) pObj; if (!pTra) return; pTra->Release(); } EXTERN_C RETCODE EnlistInDtc(void *conn, void *pTra, int method) { ITransactionDispenser *pDtc = NULL; RETCODE ret; if (!pTra) { IAsyncPG *asdum = (IAsyncPG *) PgDtc_get_async(conn); PgDtc_set_property(conn, enlisted, (void *) 0); return SQL_SUCCESS; } if (CONN_IS_IN_TRANS(conn)) { PgDtc_one_phase_operation(conn, SHUTDOWN_LOCAL_TRANSACTION); } HRESULT hres; pDtc = getITransactionDispenser(OLE_TM_FLAG_NODEMANDSTART, &hres); if (!pDtc) { char errmsg[128]; snprintf(errmsg, sizeof(errmsg), "enlistment error:DtcGetTransactionManager error code=%x", hres); PgDtc_set_error(conn, errmsg, __FUNCTION__); return SQL_ERROR; } ret = EnlistInDtc_1pipe(conn, (ITransaction *) pTra, pDtc, method); if (SQL_SUCCEEDED(ret)) PgDtc_set_property(conn, enlisted, (void *) 1); return ret; } EXTERN_C RETCODE DtcOnDisconnect(void *conn) { mylog("DtcOnDisconnect\n"); LIFELOCK_ACQUIRE; IAsyncPG *asdum = (IAsyncPG *) PgDtc_get_async(conn); if (asdum) { asdum->AddRef(); LIFELOCK_RELEASE; asdum->ReleaseConnection(); asdum->Release(); } else LIFELOCK_RELEASE; return SQL_SUCCESS; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ psqlodbc-REL-16_00_0005/multibyte.c000066400000000000000000000236771462406103600166770ustar00rootroot00000000000000/*-------- * Module : multibyte.c * * Description: New Multibyte related additional function. * * Create 2001-03-03 Eiji Tokuya * New Create 2001-09-16 Eiji Tokuya *-------- */ #include "multibyte.h" #include "misc.h" #include "connection.h" #include "pgapifunc.h" #include #include #include #include #ifndef WIN32 #include #endif #ifndef TRUE #define TRUE 1 #endif typedef struct pg_CS { char *name; int code; } pg_CS; static pg_CS CS_Table[] = { { "SQL_ASCII", SQL_ASCII }, { "EUC_JP", EUC_JP }, { "EUC_CN", EUC_CN }, { "EUC_KR", EUC_KR }, { "EUC_TW", EUC_TW }, { "JOHAB", JOHAB }, /* since 7.3 */ { "UTF8", UTF8 }, /* since 7.2 */ { "MULE_INTERNAL",MULE_INTERNAL }, { "LATIN1", LATIN1 }, { "LATIN2", LATIN2 }, { "LATIN3", LATIN3 }, { "LATIN4", LATIN4 }, { "LATIN5", LATIN5 }, { "LATIN6", LATIN6 }, { "LATIN7", LATIN7 }, { "LATIN8", LATIN8 }, { "LATIN9", LATIN9 }, { "LATIN10", LATIN10 }, { "WIN1256", WIN1256 }, /* Arabic since 7.3 */ { "WIN1258", WIN1258 }, /* Vietnamese since 8.1 */ { "WIN866", WIN866 }, /* since 8.1 */ { "WIN874", WIN874 }, /* Thai since 7.3 */ { "KOI8", KOI8R }, { "WIN1251", WIN1251 }, /* Cyrillic */ { "WIN1252", WIN1252 }, /* Western Europe since 8.1 */ { "ISO_8859_5", ISO_8859_5 }, { "ISO_8859_6", ISO_8859_6 }, { "ISO_8859_7", ISO_8859_7 }, { "ISO_8859_8", ISO_8859_8 }, { "WIN1250", WIN1250 }, /* Central Europe */ { "WIN1253", WIN1253 }, /* Greek since 8.2 */ { "WIN1254", WIN1254 }, /* Turkish since 8.2 */ { "WIN1255", WIN1255 }, /* Hebrew since 8.2 */ { "WIN1257", WIN1257 }, /* Baltic(North Europe) since 8.2 */ { "EUC_JIS_2004", EUC_JIS_2004}, /* EUC for SHIFT-JIS-2004 Japanese, since 8.3 */ { "SJIS", SJIS }, { "BIG5", BIG5 }, { "GBK", GBK }, /* since 7.3 */ { "UHC", UHC }, /* since 7.3 */ { "GB18030", GB18030 }, /* since 7.3 */ { "SHIFT_JIS_2004", SHIFT_JIS_2004 }, /* SHIFT-JIS-2004 Japanese, standard JIS X 0213, since 8.3 */ { "OTHER", OTHER } }; static pg_CS CS_Alias[] = { { "UNICODE", UTF8 }, { "TCVN", WIN1258 }, { "ALT", WIN866 }, { "WIN", WIN1251 }, { "KOI8R", KOI8R }, { "OTHER", OTHER } }; int pg_CS_code(const char *characterset_string) { int i, c = -1; for(i = 0; CS_Table[i].code != OTHER; i++) { if (0 == stricmp(characterset_string, CS_Table[i].name)) { c = CS_Table[i].code; break; } } if (c < 0) { for(i = 0; CS_Alias[i].code != OTHER; i++) { if (0 == stricmp(characterset_string, CS_Alias[i].name)) { c = CS_Alias[i].code; break; } } } if (c < 0) c = OTHER; return (c); } char * check_client_encoding(const pgNAME conn_settings) { const char *cptr, *sptr = NULL; char *rptr; BOOL allowed_cmd = TRUE, in_quote = FALSE; int step = 0; size_t len = 0; if (NAME_IS_NULL(conn_settings)) return NULL; for (cptr = SAFE_NAME(conn_settings); *cptr; cptr++) { if (in_quote) { if (LITERAL_QUOTE == *cptr) { in_quote = FALSE; continue; } } if (';' == *cptr) { allowed_cmd = TRUE; step = 0; continue; } if (!allowed_cmd) continue; if (isspace((unsigned char) *cptr)) continue; switch (step) { case 0: if (0 != strnicmp(cptr, "set", 3)) { allowed_cmd = FALSE; continue; } step++; cptr += 3; break; case 1: if (0 != strnicmp(cptr, "client_encoding", 15)) { allowed_cmd = FALSE; continue; } step++; cptr += 15; if ('=' == *cptr) cptr--; break; case 2: if (0 == strnicmp(cptr, "to", 2)) cptr += 2; else if (0 == strnicmp(cptr, "=", 1)) ; else { allowed_cmd = FALSE; continue; } step++; break; case 3: if (LITERAL_QUOTE == *cptr) { cptr++; for (sptr = cptr; *cptr && *cptr != LITERAL_QUOTE; cptr++) ; } else { for (sptr = cptr; ';' != *cptr && IS_NOT_SPACE(*cptr); cptr++) ; } len = cptr - sptr; if (';' == *cptr) cptr--; step++; break; } } if (!sptr) return NULL; rptr = malloc(len + 1); if (!rptr) return NULL; memcpy(rptr, sptr, len); rptr[len] = '\0'; MYLOG(0, "extracted a client_encoding '%s' from conn_settings\n", rptr); return rptr; } int pg_mb_maxlen(int characterset_code) { switch (characterset_code) { case UTF8: return 4; case EUC_TW: return 4; case EUC_JIS_2004: case EUC_JP: case GB18030: return 3; case SHIFT_JIS_2004: case SJIS: case BIG5: case GBK: case UHC: case EUC_CN: case EUC_KR: case JOHAB: return 2; default: return 1; } } static int pg_CS_stat(int stat,unsigned int character,int characterset_code) { if (character == 0) stat = 0; switch (characterset_code) { case UTF8: { if (stat < 2 && character >= 0x80) { if (character >= 0xfc) stat = 6; else if (character >= 0xf8) stat = 5; else if (character >= 0xf0) stat = 4; else if (character >= 0xe0) stat = 3; else if (character >= 0xc0) stat = 2; } else if (stat >= 2 && character > 0x7f) stat--; else stat=0; } break; /* SHIFT_JIS_2004 Support. */ case SHIFT_JIS_2004: { if (stat < 2 && character >= 0x81 && character <= 0x9f) stat = 2; else if (stat < 2 && character >= 0xe0 && character <= 0xef) stat = 2; else if (stat < 2 && character >= 0xf0 && character <= 0xfc) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /* Shift-JIS Support. */ case SJIS: { if (stat < 2 && character > 0x80 && !(character > 0x9f && character < 0xe0)) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /* Chinese Big5 Support. */ case BIG5: { if (stat < 2 && character > 0xA0) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /* Chinese GBK Support. */ case GBK: { if (stat < 2 && character > 0x7F) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /* Korian UHC Support. */ case UHC: { if (stat < 2 && character > 0x7F) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; case EUC_JIS_2004: /* 0x8f is JIS X 0212 + JIS X 0213(2) 3 byte */ /* 0x8e is JIS X 0201 2 byte */ /* 0xa0-0xff is JIS X 0213(1) 2 byte */ case EUC_JP: /* 0x8f is JIS X 0212 3 byte */ /* 0x8e is JIS X 0201 2 byte */ /* 0xa0-0xff is JIS X 0208 2 byte */ { if (stat < 3 && character == 0x8f) /* JIS X 0212 */ stat = 3; else if (stat != 2 && (character == 0x8e || character > 0xa0)) /* Half Katakana HighByte & Kanji HighByte */ stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /* EUC_CN, EUC_KR, JOHAB Support */ case EUC_CN: case EUC_KR: case JOHAB: { if (stat < 2 && character > 0xa0) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; case EUC_TW: { if (stat < 4 && character == 0x8e) stat = 4; else if (stat == 4 && character > 0xa0) stat = 3; else if ((stat == 3 || stat < 2) && character > 0xa0) stat = 2; else if (stat == 2) stat = 1; else stat = 0; } break; /*Chinese GB18030 support.Added by Bill Huang */ case GB18030: { if (stat < 2 && character > 0x80) stat = 2; else if (stat == 2) { if (character >= 0x30 && character <= 0x39) stat = 3; else stat = 1; } else if (stat == 3) { if (character >= 0x30 && character <= 0x39) stat = 1; else stat = 3; } else stat = 0; } break; default: { stat = 0; } break; } return stat; } /* * This function is used to know the encoding corresponding to * the current locale. */ const char * derive_locale_encoding(const char *dbencoding) { const char *wenc = NULL; #ifdef WIN32 int acp; #else const char *loc, *ptr; #endif /* WIN32 */ if (wenc = getenv("PGCLIENTENCODING"), NULL != wenc) /* environmnt variable */ return wenc; #ifdef WIN32 acp = GetACP(); if (acp >= 1251 && acp <= 1258) { if (stricmp(dbencoding, "SQL_ASCII") == 0) return wenc; } switch (acp) { case 932: wenc = "SJIS"; break; case 936: wenc = "GBK"; break; case 949: wenc = "UHC"; break; case 950: wenc = "BIG5"; break; case 1250: wenc = "WIN1250"; break; case 1251: wenc = "WIN1251"; break; case 1256: wenc = "WIN1256"; break; case 1252: if (strnicmp(dbencoding, "LATIN", 5) == 0) break; wenc = "WIN1252"; break; case 1258: wenc = "WIN1258"; break; case 1253: wenc = "WIN1253"; break; case 1254: wenc = "WIN1254"; break; case 1255: wenc = "WIN1255"; break; case 1257: wenc = "WIN1257"; break; } #else /* * Derive the encoding from the codeset part of the current locale. */ loc = setlocale(LC_CTYPE, ""); if (loc && (ptr = strchr(loc, '.'))) { int enc_no; ptr++; if ((enc_no= pg_char_to_encoding(ptr)) >= 0) wenc = pg_encoding_to_char(enc_no); MYLOG(0, "locale=%s enc=%s\n", loc, wenc ? wenc : "(null)"); } #endif /* WIN32 */ return wenc; } void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str) { encstr->ccsc = ccsc; encstr->encstr = (const UCHAR *) str; encstr->pos = -1; encstr->ccst = 0; } int encoded_nextchar(encoded_str *encstr) { int chr; if (encstr->pos >= 0 && !encstr->encstr[encstr->pos]) return 0; chr = encstr->encstr[++encstr->pos]; encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc); return chr; } ssize_t encoded_position_shift(encoded_str *encstr, size_t shift) { encstr->pos += shift; return encstr->pos; } int encoded_byte_check(encoded_str *encstr, size_t abspos) { int chr; chr = encstr->encstr[encstr->pos = abspos]; encstr->ccst = pg_CS_stat(encstr->ccst, (unsigned int) chr, encstr->ccsc); return chr; } psqlodbc-REL-16_00_0005/multibyte.h000066400000000000000000000047161462406103600166750ustar00rootroot00000000000000#ifndef __MULTIBUYTE_H__ #define __MULTIBUYTE_H__ /* * * Multibyte library header ( psqlODBC Only ) * */ #include "psqlodbc.h" #include "qresult.h" /* PostgreSQL client encoding */ enum { SQL_ASCII = 0 /* SQL/ASCII */ ,EUC_JP /* EUC for Japanese */ ,EUC_CN /* EUC for Chinese */ ,EUC_KR /* EUC for Korean */ ,EUC_TW /* EUC for Taiwan */ ,JOHAB ,UTF8 /* Unicode UTF-8 */ ,MULE_INTERNAL /* Mule internal code */ ,LATIN1 /* ISO-8859 Latin 1 */ ,LATIN2 /* ISO-8859 Latin 2 */ ,LATIN3 /* ISO-8859 Latin 3 */ ,LATIN4 /* ISO-8859 Latin 4 */ ,LATIN5 /* ISO-8859 Latin 5 */ ,LATIN6 /* ISO-8859 Latin 6 */ ,LATIN7 /* ISO-8859 Latin 7 */ ,LATIN8 /* ISO-8859 Latin 8 */ ,LATIN9 /* ISO-8859 Latin 9 */ ,LATIN10 /* ISO-8859 Latin 10 */ ,WIN1256 /* Arabic Windows */ ,WIN1258 /* Vietnamese Windows */ ,WIN866 /* Alternativny Variant (MS-DOS CP866) */ ,WIN874 /* Thai Windows */ ,KOI8R /* KOI8-R/U */ ,WIN1251 /* Cyrillic Windows */ ,WIN1252 /* Western Europe Windows */ ,ISO_8859_5 /* ISO-8859-5 */ ,ISO_8859_6 /* ISO-8859-6 */ ,ISO_8859_7 /* ISO-8859-7 */ ,ISO_8859_8 /* ISO-8859-8 */ ,WIN1250 /* Central Europe Windows */ ,WIN1253 /* Greek Windows */ ,WIN1254 /* Turkish Windows */ ,WIN1255 /* Hebrew Windows */ ,WIN1257 /* Baltic(North Europe) Windows */ ,EUC_JIS_2004 /* EUC for SHIFT-JIS-2004 Japanese */ ,SJIS /* Shift JIS */ ,BIG5 /* Big5 */ ,GBK /* GBK */ ,UHC /* UHC */ ,GB18030 /* GB18030 */ ,SHIFT_JIS_2004 /* SHIFT-JIS-2004 Japanese, JIS X 0213 */ ,OTHER = -1 }; extern int pg_CS_code(const char *stat_string); /* Old Type Compatible */ typedef struct { int ccsc; const UCHAR *encstr; ssize_t pos; int ccst; } encoded_str; #define ENCODE_STATUS(enc) ((enc).ccst) #define ENCODE_PTR(enc) ((enc).encstr + (enc).pos) #define MBCS_NON_ASCII(enc) (0 != (enc).ccst || (enc).encstr[(enc).pos] >= 0x80) void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str); #define make_encoded_str(encstr, conn, str) encoded_str_constr(encstr, conn->ccsc, str) extern int encoded_nextchar(encoded_str *encstr); extern ssize_t encoded_position_shift(encoded_str *encstr, size_t shift); extern int encoded_byte_check(encoded_str *encstr, size_t abspos); /* #define check_client_encoding(X) pg_CS_name(pg_CS_code(X)) */ char *check_client_encoding(const pgNAME sql_string); const char *derive_locale_encoding(const char *dbencoding); int pg_mb_maxlen(int characterset_code); #endif /* __MULTIBUYTE_H__ */ psqlodbc-REL-16_00_0005/mylog.c000066400000000000000000000275221462406103600160010ustar00rootroot00000000000000/*------- * Module: mylog.c * * Description: This module contains miscellaneous routines * such as for debugging/logging and string functions. * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ #define _MYLOG_FUNCS_IMPLEMENT_ #include "psqlodbc.h" #include "dlg_specific.h" #include "misc.h" #include #include #include #include #include #include #ifndef WIN32 #include #include #include #include #define GENERAL_ERRNO (errno) #define GENERAL_ERRNO_SET(e) (errno = e) #else #define GENERAL_ERRNO (GetLastError()) #define GENERAL_ERRNO_SET(e) SetLastError(e) #include /* Byron: is this where Windows keeps def. * of getpid ? */ #endif #ifdef WIN32 #define DIRSEPARATOR "\\" #define PG_BINARY O_BINARY #define PG_BINARY_R "rb" #define PG_BINARY_W "wb" #define PG_BINARY_A "ab" #else #define DIRSEPARATOR "/" #define PG_BINARY 0 #define PG_BINARY_R "r" #define PG_BINARY_W "w" #define PG_BINARY_A "a" #endif /* WIN32 */ static char *logdir = NULL; void generate_filename(const char *dirname, const char *prefix, char *filename, size_t filenamelen) { const char *exename = GetExeProgramName(); #ifdef WIN32 int pid; pid = _getpid(); #else pid_t pid; struct passwd *ptr; ptr = getpwuid(getuid()); pid = getpid(); #endif if (dirname == 0 || filename == 0) return; snprintf(filename, filenamelen, "%s%s", dirname, DIRSEPARATOR); if (prefix != 0) strlcat(filename, prefix, filenamelen); if (exename[0]) snprintfcat(filename, filenamelen, "%s_", exename); #ifndef WIN32 if (ptr) strlcat(filename, ptr->pw_name, filenamelen); #endif snprintfcat(filename, filenamelen, "%u%s", pid, ".log"); return; } static void generate_homefile(const char *prefix, char *filename, size_t filenamelen) { char dir[PATH_MAX]; #ifdef WIN32 const char *ptr; dir[0] = '\0'; if (ptr=getenv("HOMEDRIVE"), NULL != ptr) strlcat(dir, ptr, filenamelen); if (ptr=getenv("HOMEPATH"), NULL != ptr) strlcat(dir, ptr, filenamelen); #else STRCPY_FIXED(dir, "~"); #endif /* WIN32 */ generate_filename(dir, prefix, filename, filenamelen); return; } #ifdef WIN32 static char exename[_MAX_FNAME]; #elif defined MAXNAMELEN static char exename[MAXNAMELEN]; #else static char exename[256]; #endif const char *GetExeProgramName() { static int init = 1; if (init) { UCHAR *p; #ifdef WIN32 char pathname[_MAX_PATH]; if (GetModuleFileName(NULL, pathname, sizeof(pathname)) > 0) _splitpath(pathname, NULL, NULL, exename, NULL); #else CSTR flist[] = {"/proc/self/exe", "/proc/curproc/file", "/proc/curproc/exe" }; int i; char path_name[256]; for (i = 0; i < sizeof(flist) / sizeof(flist[0]); i++) { if (readlink(flist[i], path_name, sizeof(path_name)) > 0) { /* fprintf(stderr, "i=%d pathname=%s\n", i, path_name); */ STRCPY_FIXED(exename, po_basename(path_name)); break; } } #endif /* WIN32 */ for (p = (UCHAR *) exename; '\0' != *p; p++) { if (isalnum(*p)) continue; switch (*p) { case '_': case '-': continue; } *p = '\0'; /* avoid multi bytes for safety */ break; } init = 0; } return exename; } #if defined(WIN_MULTITHREAD_SUPPORT) static CRITICAL_SECTION qlog_cs, mylog_cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) static pthread_mutex_t qlog_cs, mylog_cs; #endif /* WIN_MULTITHREAD_SUPPORT */ static int mylog_on = 0, qlog_on = 0; #if defined(WIN_MULTITHREAD_SUPPORT) #define INIT_QLOG_CS InitializeCriticalSection(&qlog_cs) #define ENTER_QLOG_CS EnterCriticalSection(&qlog_cs) #define LEAVE_QLOG_CS LeaveCriticalSection(&qlog_cs) #define DELETE_QLOG_CS DeleteCriticalSection(&qlog_cs) #define INIT_MYLOG_CS InitializeCriticalSection(&mylog_cs) #define ENTER_MYLOG_CS EnterCriticalSection(&mylog_cs) #define LEAVE_MYLOG_CS LeaveCriticalSection(&mylog_cs) #define DELETE_MYLOG_CS DeleteCriticalSection(&mylog_cs) #elif defined(POSIX_MULTITHREAD_SUPPORT) #define INIT_QLOG_CS pthread_mutex_init(&qlog_cs,0) #define ENTER_QLOG_CS pthread_mutex_lock(&qlog_cs) #define LEAVE_QLOG_CS pthread_mutex_unlock(&qlog_cs) #define DELETE_QLOG_CS pthread_mutex_destroy(&qlog_cs) #define INIT_MYLOG_CS pthread_mutex_init(&mylog_cs,0) #define ENTER_MYLOG_CS pthread_mutex_lock(&mylog_cs) #define LEAVE_MYLOG_CS pthread_mutex_unlock(&mylog_cs) #define DELETE_MYLOG_CS pthread_mutex_destroy(&mylog_cs) #else #define INIT_QLOG_CS #define ENTER_QLOG_CS #define LEAVE_QLOG_CS #define DELETE_QLOG_CS #define INIT_MYLOG_CS #define ENTER_MYLOG_CS #define LEAVE_MYLOG_CS #define DELETE_MYLOG_CS #endif /* WIN_MULTITHREAD_SUPPORT */ #define MYLOGFILE "mylog_" #ifndef WIN32 #define MYLOGDIR "/tmp" #else #define MYLOGDIR "c:" #endif /* WIN32 */ #define QLOGFILE "psqlodbc_" #ifndef WIN32 #define QLOGDIR "/tmp" #else #define QLOGDIR "c:" #endif /* WIN32 */ int get_mylog(void) { return mylog_on; } int get_qlog(void) { return qlog_on; } const char *po_basename(const char *path) { char *p; if (p = strrchr(path, DIRSEPARATOR[0]), NULL != p) return p + 1; return path; } void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) { static int mylog_on_count = 0, mylog_off_count = 0, qlog_on_count = 0, qlog_off_count = 0; ENTER_MYLOG_CS; if (mylog_onoff) mylog_on_count += cnopen; else mylog_off_count += cnopen; if (mylog_on_count > 0) { if (mylog_onoff > mylog_on) mylog_on = mylog_onoff; else if (mylog_on < 1) mylog_on = 1; } else if (mylog_off_count > 0) mylog_on = 0; else if (getGlobalDebug() > 0) mylog_on = getGlobalDebug(); LEAVE_MYLOG_CS; ENTER_QLOG_CS; if (qlog_onoff) qlog_on_count += cnopen; else qlog_off_count += cnopen; if (qlog_on_count > 0) { if (qlog_onoff > qlog_on) qlog_on = qlog_onoff; else if (qlog_on < 1) qlog_on = 1; } else if (qlog_off_count > 0) qlog_on = 0; else if (getGlobalCommlog() > 0) qlog_on = getGlobalCommlog(); LEAVE_QLOG_CS; MYLOG(0, "mylog_on=%d qlog_on=%d\n", mylog_on, qlog_on); } #ifdef WIN32 #define LOGGING_PROCESS_TIME #include #endif /* WIN32 */ #ifdef LOGGING_PROCESS_TIME #include static DWORD start_time = 0; #endif /* LOGGING_PROCESS_TIME */ static FILE *MLOGFP = NULL; static void MLOG_open() { char filebuf[80], errbuf[160]; BOOL open_error = FALSE; if (MLOGFP) return; generate_filename(logdir ? logdir : MYLOGDIR, MYLOGFILE, filebuf, sizeof(filebuf)); MLOGFP = fopen(filebuf, PG_BINARY_A); if (!MLOGFP) { int lasterror = GENERAL_ERRNO; open_error = TRUE; SPRINTF_FIXED(errbuf, "%s open error %d\n", filebuf, lasterror); generate_homefile(MYLOGFILE, filebuf, sizeof(filebuf)); MLOGFP = fopen(filebuf, PG_BINARY_A); } if (MLOGFP) { if (open_error) fputs(errbuf, MLOGFP); } } static int mylog_misc(unsigned int option, const char *fmt, va_list args) { // va_list args; int gerrno; BOOL log_threadid = option; gerrno = GENERAL_ERRNO; ENTER_MYLOG_CS; #ifdef LOGGING_PROCESS_TIME if (!start_time) start_time = timeGetTime(); #endif /* LOGGING_PROCESS_TIME */ // va_start(args, fmt); if (!MLOGFP) { MLOG_open(); if (!MLOGFP) mylog_on = 0; } if (MLOGFP) { if (log_threadid) { #ifdef WIN_MULTITHREAD_SUPPORT #ifdef LOGGING_PROCESS_TIME DWORD proc_time = timeGetTime() - start_time; fprintf(MLOGFP, "[%u-%d.%03d]", GetCurrentThreadId(), proc_time / 1000, proc_time % 1000); #else fprintf(MLOGFP, "[%u]", GetCurrentThreadId()); #endif /* LOGGING_PROCESS_TIME */ #endif /* WIN_MULTITHREAD_SUPPORT */ #if defined(POSIX_MULTITHREAD_SUPPORT) fprintf(MLOGFP, "[%lx]", (unsigned long int) pthread_self()); #endif /* POSIX_MULTITHREAD_SUPPORT */ } vfprintf(MLOGFP, fmt, args); fflush(MLOGFP); } // va_end(args); LEAVE_MYLOG_CS; GENERAL_ERRNO_SET(gerrno); return 1; } DLL_DECLARE int mylog(const char *fmt,...) { int ret = 0; unsigned int option = 1; va_list args; if (!mylog_on) return ret; va_start(args, fmt); ret = mylog_misc(option, fmt, args); va_end(args); return ret; } DLL_DECLARE int myprintf(const char *fmt,...) { int ret = 0; va_list args; va_start(args, fmt); ret = mylog_misc(0, fmt, args); va_end(args); return ret; } static void mylog_initialize(void) { INIT_MYLOG_CS; } static void mylog_finalize(void) { mylog_on = 0; if (MLOGFP) { fclose(MLOGFP); MLOGFP = NULL; } DELETE_MYLOG_CS; } static FILE *QLOGFP = NULL; static int qlog_misc(unsigned int option, const char *fmt, va_list args) { char filebuf[80]; int gerrno; if (!qlog_on) return 0; gerrno = GENERAL_ERRNO; ENTER_QLOG_CS; #ifdef LOGGING_PROCESS_TIME if (!start_time) start_time = timeGetTime(); #endif /* LOGGING_PROCESS_TIME */ if (!QLOGFP) { generate_filename(logdir ? logdir : QLOGDIR, QLOGFILE, filebuf, sizeof(filebuf)); QLOGFP = fopen(filebuf, PG_BINARY_A); if (!QLOGFP) { generate_homefile(QLOGFILE, filebuf, sizeof(filebuf)); QLOGFP = fopen(filebuf, PG_BINARY_A); } if (!QLOGFP) qlog_on = 0; } if (QLOGFP) { if (option) { #ifdef LOGGING_PROCESS_TIME DWORD proc_time = timeGetTime() - start_time; fprintf(QLOGFP, "[%d.%03d]", proc_time / 1000, proc_time % 1000); #endif /* LOGGING_PROCESS_TIME */ } vfprintf(QLOGFP, fmt, args); fflush(QLOGFP); } LEAVE_QLOG_CS; GENERAL_ERRNO_SET(gerrno); return 1; } int qlog(char *fmt,...) { int ret = 0; unsigned int option = 1; va_list args; if (!qlog_on) return ret; va_start(args, fmt); ret = qlog_misc(option, fmt, args); va_end(args); return ret; } int qprintf(char *fmt,...) { int ret = 0; va_list args; va_start(args, fmt); ret = qlog_misc(0, fmt, args); va_end(args); return ret; } static void qlog_initialize(void) { INIT_QLOG_CS; } static void qlog_finalize(void) { qlog_on = 0; if (QLOGFP) { fclose(QLOGFP); QLOGFP = NULL; } DELETE_QLOG_CS; } static int globalDebug = -1; int getGlobalDebug() { char temp[16]; if (globalDebug >=0) return globalDebug; /* Debug is stored in the driver section */ SQLGetPrivateProfileString(DBMS_NAME, INI_DEBUG, "", temp, sizeof(temp), ODBCINST_INI); if (temp[0]) globalDebug = atoi(temp); else globalDebug = DEFAULT_DEBUG; return globalDebug; } int setGlobalDebug(int val) { return (globalDebug = val); } static int globalCommlog = -1; int getGlobalCommlog() { char temp[16]; if (globalCommlog >= 0) return globalCommlog; /* Commlog is stored in the driver section */ SQLGetPrivateProfileString(DBMS_NAME, INI_COMMLOG, "", temp, sizeof(temp), ODBCINST_INI); if (temp[0]) globalCommlog = atoi(temp); else globalCommlog = DEFAULT_COMMLOG; return globalCommlog; } int setGlobalCommlog(int val) { return (globalCommlog = val); } int writeGlobalLogs() { char temp[10]; ITOA_FIXED(temp, globalDebug); SQLWritePrivateProfileString(DBMS_NAME, INI_DEBUG, temp, ODBCINST_INI); ITOA_FIXED(temp, globalCommlog); SQLWritePrivateProfileString(DBMS_NAME, INI_COMMLOG, temp, ODBCINST_INI); return 0; } int getLogDir(char *dir, int dirmax) { return SQLGetPrivateProfileString(DBMS_NAME, INI_LOGDIR, "", dir, dirmax, ODBCINST_INI); } int setLogDir(const char *dir) { return SQLWritePrivateProfileString(DBMS_NAME, INI_LOGDIR, dir, ODBCINST_INI); } /* * This function starts a logging out of connections according the ODBCINST.INI * portion of the DBMS_NAME registry. */ static void start_logging() { /* * GlobalDebug or GlobalCommlog means whether take mylog or commlog * out of the connection time or not but doesn't mean the default of * ci->drivers.debug(commlog). */ logs_on_off(0, 0, 0); mylog("\t%s:Global.debug&commlog=%d&%d\n", __FUNCTION__, getGlobalDebug(), getGlobalCommlog()); } void InitializeLogging(void) { char dir[PATH_MAX]; getLogDir(dir, sizeof(dir)); if (dir[0]) logdir = strdup(dir); mylog_initialize(); qlog_initialize(); start_logging(); } void FinalizeLogging(void) { mylog_finalize(); qlog_finalize(); if (logdir) { free(logdir); logdir = NULL; } } psqlodbc-REL-16_00_0005/mylog.h000066400000000000000000000062001462406103600157740ustar00rootroot00000000000000/* File: mylog.h * * Description: See "mylog.c" * * Comments: See "notice.txt" for copyright and license information. * */ #ifndef __MYLOG_H__ #define __MYLOG_H__ #undef DLL_DECLARE #ifdef WIN32 #ifdef _MYLOG_FUNCS_IMPLEMENT_ #define DLL_DECLARE _declspec(dllexport) #else #ifdef _MYLOG_FUNCS_IMPORT_ #define DLL_DECLARE _declspec(dllimport) #else #define DLL_DECLARE #endif /* _MYLOG_FUNCS_IMPORT_ */ #endif /* _MYLOG_FUNCS_IMPLEMENT_ */ #else #define DLL_DECLARE #endif /* WIN32 */ #include #ifndef WIN32 #include #endif #ifdef __cplusplus extern "C" { #endif #ifndef __GNUC__ #define __attribute__(x) #endif DLL_DECLARE int mylog(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); DLL_DECLARE int myprintf(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); extern int qlog(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); extern int qprintf(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); const char *po_basename(const char *path); #define PREPEND_FMT "%10.10s[%s]%d: " #define PREPEND_ITEMS ,po_basename(__FILE__), __FUNCTION__, __LINE__ #define QLOG_MARK "[QLOG]" #ifdef __GNUC__ #define MYLOG(level, fmt, ...) (level < get_mylog() ? mylog(PREPEND_FMT fmt PREPEND_ITEMS, ##__VA_ARGS__) : 0) #define MYPRINTF(level, fmt, ...) (level < get_mylog() ? myprintf((fmt), ##__VA_ARGS__) : 0) #define QLOG(level, fmt, ...) ((level < get_qlog() ? qlog((fmt), ##__VA_ARGS__) : 0), MYLOG(level, QLOG_MARK fmt, ##__VA_ARGS__)) #define QPRINTF(level, fmt, ...) ((level < get_qlog() ? qprintf((fmt), ##__VA_ARGS__) : 0), MYPRINTF(level, (fmt), ##__VA_ARGS__)) #elif defined WIN32 /* && _MSC_VER > 1800 */ #define MYLOG(level, fmt, ...) (level < get_mylog() ? mylog(PREPEND_FMT fmt PREPEND_ITEMS, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__))) #define MYPRINTF(level, fmt, ...) (level < get_mylog() ? myprintf(fmt, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__))) #define QLOG(level, fmt, ...) ((level < get_qlog() ? qlog((fmt), __VA_ARGS__) : (printf || printf(fmt, __VA_ARGS__))), MYLOG(level, QLOG_MARK fmt, __VA_ARGS__)) #define QPRINTF(level, fmt, ...) ((level < get_qlog() ? qprintf(fmt, __VA_ARGS__) : (printf || printf((fmt), __VA_ARGS__))), MYPRINTF(level, (fmt), __VA_ARGS__)) #else #define MYLOG(level, ...) (level < get_mylog() ? (mylog(PREPEND_FMT PREPEND_ITEMS), myprintf(__VA_ARGS__)) : 0) #define MYPRINTF(level, ...) (level < get_mylog() ? myprintf(__VA_ARGS__) : 0) #define QLOG(level, ...) ((level < get_qlog() ? qlog(__VA_ARGS__) : 0), MYLOG(level, QLOG_MARK), MYPRINTF(level, __VA_ARGS__)) #define QPRINTF(level, ...) ((level < get_qlog() ? qprintf(__VA_ARGS__) : 0), MYPRINTF(level, __VA_ARGS__)) #endif /* __GNUC__ */ #define MIN_LOG_LEVEL 0 #define TUPLE_LOG_LEVEL 1 #define DETAIL_LOG_LEVEL 2 int get_qlog(void); int get_mylog(void); int getGlobalDebug(); int setGlobalDebug(int val); int getGlobalCommlog(); int setGlobalCommlog(int val); int writeGlobalLogs(); int getLogDir(char *dir, int dirmax); int setLogDir(const char *dir); void InitializeLogging(void); void FinalizeLogging(void); #ifdef __cplusplus } #endif #endif /* __MYLOG_H__ */ psqlodbc-REL-16_00_0005/odbc-drop.sql000066400000000000000000000023171462406103600170730ustar00rootroot00000000000000DROP FUNCTION "char"(integer); DROP FUNCTION concat(text, text); DROP FUNCTION insert(text, integer, integer, text); DROP FUNCTION lcase(text); DROP FUNCTION left(text, integer); DROP FUNCTION locate(text, text); DROP FUNCTION locate(text, text, integer); DROP FUNCTION right(text, integer); DROP FUNCTION space(integer); DROP FUNCTION ucase(text); DROP FUNCTION ceiling(numeric); DROP FUNCTION log10(double precision); DROP FUNCTION log10(numeric); DROP FUNCTION power(double precision, double precision); DROP FUNCTION power(numeric, numeric); DROP FUNCTION rand(); DROP FUNCTION rand(double precision); DROP FUNCTION truncate(numeric, integer); DROP FUNCTION curdate(); DROP FUNCTION curtime(); DROP FUNCTION odbc_timestamp(); DROP FUNCTION dayname(timestamp); DROP FUNCTION dayofmonth(timestamp); DROP FUNCTION dayofweek(timestamp); DROP FUNCTION dayofyear(timestamp); DROP FUNCTION hour(timestamp); DROP FUNCTION minute(timestamp); DROP FUNCTION month(timestamp); DROP FUNCTION monthname(timestamp); DROP FUNCTION quarter(timestamp); DROP FUNCTION second(timestamp); DROP FUNCTION week(timestamp); DROP FUNCTION year(timestamp); DROP FUNCTION odbc_user(); DROP FUNCTION odbc_current_user(); DROP FUNCTION odbc_session_user(); psqlodbc-REL-16_00_0005/odbc.sql000066400000000000000000000145021462406103600161300ustar00rootroot00000000000000-- PostgreSQL catalog extensions for ODBC compatibility (odbc.sql) -- ODBC scalar functions are described here: -- Microsoft ODBC Programmer's Reference, Appendix E: Scalar Functions -- http://msdn.microsoft.com/library/ms711813.aspx -- Note: If we format this file consistently we can automatically -- generate a corresponding "drop script". Start "CREATE" in the first -- column, and keep everything up to and including the argument list on -- the same line. See also the makefile rule. -- String Functions -- ++++++++++++++++ -- -- Built-in: ASCII, BIT_LENGTH, CHAR_LENGTH, CHARACTER_LENGTH, LTRIM, -- OCTET_LENGTH, POSITION, REPEAT, RTRIM, SUBSTRING -- Missing: DIFFERENCE, REPLACE, SOUNDEX, LENGTH (ODBC sense) -- Keyword problems: CHAR -- CHAR(code) CREATE OR REPLACE FUNCTION "char"(integer) RETURNS text AS ' SELECT chr($1); ' LANGUAGE SQL; -- CONCAT(string1, string2) CREATE OR REPLACE FUNCTION concat(text, text) RETURNS text AS ' SELECT $1 || $2; ' LANGUAGE SQL; -- INSERT(string1, start, len, string2) CREATE OR REPLACE FUNCTION insert(text, integer, integer, text) RETURNS text AS ' SELECT substring($1 from 1 for $2 - 1) || $4 || substring($1 from $2 + $3); ' LANGUAGE SQL; -- LCASE(string) CREATE OR REPLACE FUNCTION lcase(text) RETURNS text AS ' SELECT lower($1); ' LANGUAGE SQL; -- LEFT(string, count) CREATE OR REPLACE FUNCTION left(text, integer) RETURNS text AS ' SELECT substring($1 for $2); ' LANGUAGE SQL; -- LOCATE(substring, string[, start]) CREATE OR REPLACE FUNCTION locate(text, text) RETURNS integer AS ' SELECT position($1 in $2); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION locate(text, text, integer) RETURNS integer AS ' SELECT position($1 in substring($2 from $3)) + $3 - 1; ' LANGUAGE SQL; -- RIGHT(string, count) CREATE OR REPLACE FUNCTION right(text, integer) RETURNS text AS ' SELECT substring($1 from char_length($1) - $2 + 1); ' LANGUAGE SQL; -- SPACE(count) CREATE OR REPLACE FUNCTION space(integer) RETURNS text AS ' SELECT repeat('' '', $1); ' LANGUAGE SQL; -- UCASE(string) CREATE OR REPLACE FUNCTION ucase(text) RETURNS text AS ' SELECT upper($1); ' LANGUAGE SQL; -- Numeric Functions -- +++++++++++++++++ -- -- Built-in: ABS, ACOS, ASIN, ATAN, ATAN2, COS, COT, DEGREES, EXP, -- FLOOR, MOD, PI, RADIANS, ROUND, SIGN, SIN, SQRT, TAN -- Missing: LOG (ODBC sense) -- CEILING(num) CREATE OR REPLACE FUNCTION ceiling(numeric) RETURNS numeric AS ' SELECT ceil($1); ' LANGUAGE SQL; -- LOG10(num) CREATE OR REPLACE FUNCTION log10(double precision) RETURNS double precision AS ' SELECT log($1); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION log10(numeric) RETURNS numeric AS ' SELECT log($1); ' LANGUAGE SQL; -- POWER(num, num) CREATE OR REPLACE FUNCTION power(double precision, double precision) RETURNS double precision AS ' SELECT pow($1, $2); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION power(numeric, numeric) RETURNS numeric AS ' SELECT pow($1, $2); ' LANGUAGE SQL; -- RAND([seed]) CREATE OR REPLACE FUNCTION rand() RETURNS double precision AS ' SELECT random(); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION rand(double precision) RETURNS double precision AS ' SELECT setseed($1); SELECT random(); ' LANGUAGE SQL; -- TRUNCATE(num, places) CREATE OR REPLACE FUNCTION truncate(numeric, integer) RETURNS numeric AS ' SELECT trunc($1, $2); ' LANGUAGE SQL; -- Time, Date, and Interval Functions -- ++++++++++++++++++++++++++++++++++ -- -- Built-in: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, EXTRACT, NOW -- Missing: none CREATE OR REPLACE FUNCTION curdate() RETURNS date AS ' SELECT current_date; ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION curtime() RETURNS time with time zone AS ' SELECT current_time; ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION odbc_timestamp() RETURNS timestamp with time zone AS ' SELECT current_timestamp; ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION dayname(timestamp) RETURNS text AS ' SELECT to_char($1,''Day''); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION dayofmonth(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(day FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION dayofweek(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(dow FROM $1) AS integer) + 1; ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION dayofyear(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(doy FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION hour(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(hour FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION minute(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(minute FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION month(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(month FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION monthname(timestamp) RETURNS text AS ' SELECT to_char($1, ''Month''); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION quarter(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(quarter FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION second(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(second FROM $1) AS integer); ' LANGUAGE SQL; /* -- The first argument is an integer constant denoting the units -- of the second argument. Until we know the actual values, we -- cannot implement these. - thomas 2000-04-11 xCREATE OR REPLACE FUNCTION timestampadd(integer, integer, timestamp) RETURNS timestamp AS ' SELECT CAST(($3 + ($2 * $1)) AS timestamp); ' LANGUAGE SQL; xCREATE OR REPLACE FUNCTION timestampdiff(integer, integer, timestamp) RETURNS timestamp AS ' SELECT CAST(($3 + ($2 * $1)) AS timestamp); ' LANGUAGE SQL; */ CREATE OR REPLACE FUNCTION week(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(week FROM $1) AS integer); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION year(timestamp) RETURNS integer AS ' SELECT CAST(EXTRACT(year FROM $1) AS integer); ' LANGUAGE SQL; -- System Functions -- ++++++++++++++++ -- -- Built-in: USER -- Missing: DATABASE, IFNULL CREATE OR REPLACE FUNCTION odbc_user() RETURNS text AS ' SELECT CAST(current_user AS TEXT); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION odbc_current_user() RETURNS text AS ' SELECT CAST(current_user AS TEXT); ' LANGUAGE SQL; CREATE OR REPLACE FUNCTION odbc_session_user() RETURNS text AS ' SELECT CAST(session_user AS TEXT); ' LANGUAGE SQL; psqlodbc-REL-16_00_0005/odbcapi.c000066400000000000000000001166131462406103600162530ustar00rootroot00000000000000/*------- * Module: odbcapi.c * * Description: This module contains routines related to * preparing and executing an SQL statement. * * Classes: n/a * * API functions: SQLAllocConnect, SQLAllocEnv, SQLAllocStmt, SQLBindCol, SQLCancel, SQLColumns, SQLConnect, SQLDataSources, SQLDescribeCol, SQLDisconnect, SQLError, SQLExecDirect, SQLExecute, SQLFetch, SQLFreeConnect, SQLFreeEnv, SQLFreeStmt, SQLGetConnectOption, SQLGetCursorName, SQLGetData, SQLGetFunctions, SQLGetInfo, SQLGetStmtOption, SQLGetTypeInfo, SQLNumResultCols, SQLParamData, SQLPrepare, SQLPutData, SQLRowCount, SQLSetConnectOption, SQLSetCursorName, SQLSetParam, SQLSetStmtOption, SQLSpecialColumns, SQLStatistics, SQLTables, SQLTransact, SQLColAttributes, SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch, SQLForeignKeys, SQLMoreResults, SQLNativeSql, SQLNumParams, SQLParamOptions, SQLPrimaryKeys, SQLProcedureColumns, SQLProcedures, SQLSetPos, SQLTablePrivileges, SQLBindParameter *------- */ #include "psqlodbc.h" #include #include #include "misc.h" #include "pgapifunc.h" #include "environ.h" #include "connection.h" #include "statement.h" #include "qresult.h" #include "loadlib.h" BOOL SC_connection_lost_check(StatementClass *stmt, const char *funcname) { ConnectionClass *conn = SC_get_conn(stmt); char message[64]; if (NULL != conn->pqconn) return FALSE; SC_clear_error(stmt); SPRINTF_FIXED(message, "%s unable due to the connection lost", funcname); SC_set_error(stmt, STMT_COMMUNICATION_ERROR, message, funcname); return TRUE; } RETCODE SQL_API SQLBindCol(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, PTR TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_BindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLCancel(HSTMT StatementHandle) { MYLOG(0, "Entering\n"); /* Not that neither ENTER_STMT_CS nor StartRollbackState is called */ /* SC_clear_error((StatementClass *) StatementHandle); maybe this neither */ if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__)) return SQL_ERROR; return PGAPI_Cancel(StatementHandle); } static BOOL theResultIsEmpty(const StatementClass *stmt) { QResultClass *res = SC_get_Result(stmt); if (NULL == res) return FALSE; return (0 == QR_get_num_total_tuples(res)); } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLColumns(HSTMT StatementHandle, SQLCHAR *CatalogName, SQLSMALLINT NameLength1, SQLCHAR *SchemaName, SQLSMALLINT NameLength2, SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLCHAR *ColumnName, SQLSMALLINT NameLength4) { CSTR func = "SQLColumns"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName, *clName = ColumnName; ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); UWORD flag = PODBC_SEARCH_PUBLIC_SCHEMA; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (atoi(ci->show_oid_column)) flag |= PODBC_SHOW_OID_COLUMN; if (atoi(ci->row_versioning)) flag |= PODBC_ROW_VERSIONING; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Columns(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, clName, NameLength4, flag, 0, 0); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (newCl = make_lstring_ifneeded(conn, ColumnName, NameLength4, ifallupper), NULL != newCl) { clName = newCl; reexec = TRUE; } if (reexec) { ret = PGAPI_Columns(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, clName, NameLength4, flag, 0, 0); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); if (newCl) free(newCl); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLConnect(HDBC ConnectionHandle, SQLCHAR *ServerName, SQLSMALLINT NameLength1, SQLCHAR *UserName, SQLSMALLINT NameLength2, SQLCHAR *Authentication, SQLSMALLINT NameLength3) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_Connect(ConnectionHandle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3); LEAVE_CONN_CS(conn); return ret; } RETCODE SQL_API SQLDriverConnect(HDBC hdbc, HWND hwnd, SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT * pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); LEAVE_CONN_CS(conn); return ret; } RETCODE SQL_API SQLBrowseConnect(HDBC hdbc, SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut); LEAVE_CONN_CS(conn); return ret; } RETCODE SQL_API SQLDataSources(HENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR *ServerName, SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, SQLCHAR *Description, SQLSMALLINT BufferLength2, SQLSMALLINT *NameLength2) { MYLOG(0, "Entering\n"); /* * return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, * BufferLength1, NameLength1, Description, BufferLength2, * NameLength2); */ return SQL_ERROR; } RETCODE SQL_API SQLDescribeCol(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType, SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_DescribeCol(StatementHandle, ColumnNumber, ColumnName, BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLDisconnect(HDBC ConnectionHandle) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; MYLOG(0, "Entering for %p\n", ConnectionHandle); #ifdef _HANDLE_ENLIST_IN_DTC_ if (CC_is_in_global_trans(conn)) CALL_DtcOnDisconnect(conn); #endif /* _HANDLE_ENLIST_IN_DTC_ */ ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_Disconnect(ConnectionHandle); LEAVE_CONN_CS(conn); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLExecDirect(HSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLExecDirect"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); flag |= PODBC_WITH_HOLD; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else { StartRollbackState(stmt); ret = PGAPI_ExecDirect(StatementHandle, StatementText, TextLength, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); } LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLExecute(HSTMT StatementHandle) { CSTR func = "SQLExecute"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); flag |= (PODBC_RECYCLE_STATEMENT | PODBC_WITH_HOLD); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else { StartRollbackState(stmt); stmt->exec_current_row = -1; //// SC_set_Result(StatementHandle, NULL); ret = PGAPI_Execute(StatementHandle, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); } LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLFetch(HSTMT StatementHandle) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; IRDFields *irdopts = SC_get_IRDF(stmt); ARDFields *ardopts = SC_get_ARDF(stmt); SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray; SQLULEN *pcRow = irdopts->rowsFetched; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0, pcRow, rowStatusArray, 0, ardopts->size_of_rowset); stmt->transition_status = STMT_TRANSITION_FETCH_SCROLL; ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLFreeStmt(HSTMT StatementHandle, SQLUSMALLINT Option) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn = NULL; MYLOG(0, "Entering\n"); if (stmt) { if (Option == SQL_DROP) { conn = stmt->hdbc; if (conn) ENTER_CONN_CS(conn); } else ENTER_STMT_CS(stmt); } ret = PGAPI_FreeStmt(StatementHandle, Option); if (stmt) { if (Option == SQL_DROP) { if (conn) LEAVE_CONN_CS(conn); } else LEAVE_STMT_CS(stmt); } return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLGetCursorName(HSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength, NameLength); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLGetData(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, PTR TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_GetData(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); if (FunctionId == SQL_API_ODBC3_ALL_FUNCTIONS) ret = PGAPI_GetFunctions30(ConnectionHandle, FunctionId, Supported); else ret = PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported); LEAVE_CONN_CS(conn); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLGetInfo(HDBC ConnectionHandle, SQLUSMALLINT InfoType, PTR InfoValue, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); MYLOG(0, "Entering\n"); if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength)) == SQL_ERROR) CC_log_error("SQLGetInfo(30)", "", conn); LEAVE_CONN_CS(conn); return ret; } RETCODE SQL_API SQLGetTypeInfo(HSTMT StatementHandle, SQLSMALLINT DataType) { CSTR func = "SQLGetTypeInfo"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else { StartRollbackState(stmt); ret = PGAPI_GetTypeInfo(StatementHandle, DataType); ret = DiscardStatementSvp(stmt, ret, FALSE); } LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLNumResultCols(HSTMT StatementHandle, SQLSMALLINT *ColumnCount) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_NumResultCols(StatementHandle, ColumnCount); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLParamData(HSTMT StatementHandle, PTR *Value) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); ret = PGAPI_ParamData(StatementHandle, Value); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLPrepare(HSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLPrepare"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else { StartRollbackState(stmt); ret = PGAPI_Prepare(StatementHandle, StatementText, TextLength); ret = DiscardStatementSvp(stmt, ret, FALSE); } LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLPutData(HSTMT StatementHandle, PTR Data, SQLLEN StrLen_or_Ind) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); ret = PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind); ret = DiscardStatementSvp(stmt, ret, TRUE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLRowCount(HSTMT StatementHandle, SQLLEN *RowCount) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_RowCount(StatementHandle, RowCount); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLSetCursorName(HSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_SetCursorName(StatementHandle, CursorName, NameLength); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLSetParam(HSTMT StatementHandle, SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, SQLSMALLINT ParameterType, SQLULEN LengthPrecision, SQLSMALLINT ParameterScale, PTR ParameterValue, SQLLEN *StrLen_or_Ind) { MYLOG(0, "Entering\n"); SC_clear_error((StatementClass *) StatementHandle); /* * return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType, * ParameterType, LengthPrecision, ParameterScale, ParameterValue, * StrLen_or_Ind); */ return SQL_ERROR; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLSpecialColumns(HSTMT StatementHandle, SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, SQLSMALLINT NameLength1, SQLCHAR *SchemaName, SQLSMALLINT NameLength2, SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Scope, SQLUSMALLINT Nullable) { CSTR func = "SQLSpecialColumns"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, Scope, Nullable); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (reexec) { ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, Scope, Nullable); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLStatistics(HSTMT StatementHandle, SQLCHAR *CatalogName, SQLSMALLINT NameLength1, SQLCHAR *SchemaName, SQLSMALLINT NameLength2, SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Unique, SQLUSMALLINT Reserved) { CSTR func = "SQLStatistics"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, Unique, Reserved); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (reexec) { ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, Unique, Reserved); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLTables(HSTMT StatementHandle, SQLCHAR *CatalogName, SQLSMALLINT NameLength1, SQLCHAR *SchemaName, SQLSMALLINT NameLength2, SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLCHAR *TableType, SQLSMALLINT NameLength4) { CSTR func = "SQLTables"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Tables(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, TableType, NameLength4, flag); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (reexec) { ret = PGAPI_Tables(StatementHandle, ctName, NameLength1, scName, NameLength2, tbName, NameLength3, TableType, NameLength4, flag); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLColumnPrivileges(HSTMT hstmt, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szTableName, SQLSMALLINT cbTableName, SQLCHAR *szColumnName, SQLSMALLINT cbColumnName) { CSTR func = "SQLColumnPrivileges"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *ctName = szCatalogName, *scName = szSchemaName, *tbName = szTableName, *clName = szColumnName; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, clName, cbColumnName, flag); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper), NULL != newCl) { clName = newCl; reexec = TRUE; } if (reexec) { ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, clName, cbColumnName, flag); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); if (newCl) free(newCl); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLDescribeParam(HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT *pfSqlType, SQLULEN *pcbParamDef, SQLSMALLINT *pibScale, SQLSMALLINT *pfNullable) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLExtendedFetch(HSTMT hstmt, SQLUSMALLINT fFetchType, SQLLEN irow, #if defined(WITH_UNIXODBC) && (SIZEOF_LONG_INT != 8) SQLROWSETSIZE *pcrow, #else SQLULEN *pcrow, #endif /* WITH_UNIXODBC */ SQLUSMALLINT *rgfRowStatus) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); #ifdef WITH_UNIXODBC { SQLULEN retrieved; ret = PGAPI_ExtendedFetch(hstmt, fFetchType, irow, &retrieved, rgfRowStatus, 0, SC_get_ARDF(stmt)->size_of_rowset_odbc2); if (pcrow) *pcrow = retrieved; } #else ret = PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus, 0, SC_get_ARDF(stmt)->size_of_rowset_odbc2); #endif /* WITH_UNIXODBC */ stmt->transition_status = STMT_TRANSITION_EXTENDED_FETCH; ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLForeignKeys(HSTMT hstmt, SQLCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName, SQLCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName, SQLCHAR *szPkTableName, SQLSMALLINT cbPkTableName, SQLCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName, SQLCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName, SQLCHAR *szFkTableName, SQLSMALLINT cbFkTableName) { CSTR func = "SQLForeignKeys"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *pkctName = szPkCatalogName, *pkscName = szPkSchemaName, *pktbName = szPkTableName, *fkctName = szFkCatalogName, *fkscName = szFkSchemaName, *fktbName = szFkTableName; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName, pkscName, cbPkSchemaName, pktbName, cbPkTableName, fkctName, cbFkCatalogName, fkscName, cbFkSchemaName, fktbName, cbFkTableName); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newPkct = NULL, *newPksc = NULL, *newPktb = NULL, *newFkct = NULL, *newFksc = NULL, *newFktb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newPkct = make_lstring_ifneeded(conn, szPkCatalogName, cbPkCatalogName, ifallupper), NULL != newPkct) { pkctName = newPkct; reexec = TRUE; } if (newPksc = make_lstring_ifneeded(conn, szPkSchemaName, cbPkSchemaName, ifallupper), NULL != newPksc) { pkscName = newPksc; reexec = TRUE; } if (newPktb = make_lstring_ifneeded(conn, szPkTableName, cbPkTableName, ifallupper), NULL != newPktb) { pktbName = newPktb; reexec = TRUE; } if (newFkct = make_lstring_ifneeded(conn, szFkCatalogName, cbFkCatalogName, ifallupper), NULL != newFkct) { fkctName = newFkct; reexec = TRUE; } if (newFksc = make_lstring_ifneeded(conn, szFkSchemaName, cbFkSchemaName, ifallupper), NULL != newFksc) { fkscName = newFksc; reexec = TRUE; } if (newFktb = make_lstring_ifneeded(conn, szFkTableName, cbFkTableName, ifallupper), NULL != newFktb) { fktbName = newFktb; reexec = TRUE; } if (reexec) { ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName, pkscName, cbPkSchemaName, pktbName, cbPkTableName, fkctName, cbFkCatalogName, fkscName, cbFkSchemaName, fktbName, cbFkTableName); if (newPkct) free(newPkct); if (newPksc) free(newPksc); if (newPktb) free(newPktb); if (newFkct) free(newFkct); if (newFksc) free(newFksc); if (newFktb) free(newFktb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLMoreResults(HSTMT hstmt) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_MoreResults(hstmt); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLNativeSql(HDBC hdbc, SQLCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLCHAR *szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); LEAVE_CONN_CS(conn); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLNumParams(HSTMT hstmt, SQLSMALLINT *pcpar) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_NumParams(hstmt, pcpar); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLPrimaryKeys(HSTMT hstmt, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szTableName, SQLSMALLINT cbTableName) { CSTR func = "SQLPrimaryKeys"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *ctName = szCatalogName, *scName = szSchemaName, *tbName = szTableName; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, 0); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (reexec) { ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, 0); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLProcedureColumns(HSTMT hstmt, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szProcName, SQLSMALLINT cbProcName, SQLCHAR *szColumnName, SQLSMALLINT cbColumnName) { CSTR func = "SQLProcedureColumns"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *ctName = szCatalogName, *scName = szSchemaName, *prName = szProcName, *clName = szColumnName; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName, scName, cbSchemaName, prName, cbProcName, clName, cbColumnName, flag); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newPr = NULL, *newCl = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper), NULL != newPr) { prName = newPr; reexec = TRUE; } if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper), NULL != newCl) { clName = newCl; reexec = TRUE; } if (reexec) { ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName, scName, cbSchemaName, prName, cbProcName, clName, cbColumnName, flag); if (newCt) free(newCt); if (newSc) free(newSc); if (newPr) free(newPr); if (newCl) free(newCl); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLProcedures(HSTMT hstmt, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szProcName, SQLSMALLINT cbProcName) { CSTR func = "SQLProcedures"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *ctName = szCatalogName, *scName = szSchemaName, *prName = szProcName; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName, scName, cbSchemaName, prName, cbProcName, flag); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newPr = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper), NULL != newPr) { prName = newPr; reexec = TRUE; } if (reexec) { ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName, scName, cbSchemaName, prName, cbProcName, flag); if (newCt) free(newCt); if (newSc) free(newSc); if (newPr) free(newPr); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLSetPos(HSTMT hstmt, SQLSETPOSIROW irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_SetPos(hstmt, irow, fOption, fLock); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX RETCODE SQL_API SQLTablePrivileges(HSTMT hstmt, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szTableName, SQLSMALLINT cbTableName) { CSTR func = "SQLTablePrivileges"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLCHAR *ctName = szCatalogName, *scName = szSchemaName, *tbName = szTableName; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, flag); if (SQL_SUCCESS == ret && theResultIsEmpty(stmt)) { BOOL ifallupper = TRUE, reexec = FALSE; SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL; ConnectionClass *conn = SC_get_conn(stmt); if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */ ifallupper = FALSE; if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt) { ctName = newCt; reexec = TRUE; } if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc) { scName = newSc; reexec = TRUE; } if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb) { tbName = newTb; reexec = TRUE; } if (reexec) { ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName, scName, cbSchemaName, tbName, cbTableName, 0); if (newCt) free(newCt); if (newSc) free(newSc); if (newTb) free(newTb); } } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ RETCODE SQL_API SQLBindParameter(HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fParamType, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_BindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } psqlodbc-REL-16_00_0005/odbcapi30.c000066400000000000000000000510401462406103600164060ustar00rootroot00000000000000/*------- * Module: odbcapi30.c * * Description: This module contains routines related to ODBC 3.0 * most of their implementations are temporary * and must be rewritten properly. * 2001/07/23 inoue * * Classes: n/a * * API functions: SQLAllocHandle, SQLBindParam, SQLCloseCursor, SQLColAttribute, SQLCopyDesc, SQLEndTran, SQLFetchScroll, SQLFreeHandle, SQLGetDescField, SQLGetDescRec, SQLGetDiagField, SQLGetDiagRec, SQLGetEnvAttr, SQLGetConnectAttr, SQLGetStmtAttr, SQLSetConnectAttr, SQLSetDescField, SQLSetDescRec, SQLSetEnvAttr, SQLSetStmtAttr, SQLBulkOperations *------- */ #include "psqlodbc.h" #include "misc.h" #include #include #include "environ.h" #include "connection.h" #include "statement.h" #include "pgapifunc.h" /* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */ RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE * OutputHandle) { RETCODE ret; ConnectionClass *conn; MYLOG(0, "Entering\n"); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_AllocEnv(OutputHandle); break; case SQL_HANDLE_DBC: ENTER_ENV_CS((EnvironmentClass *) InputHandle); ret = PGAPI_AllocConnect(InputHandle, OutputHandle); LEAVE_ENV_CS((EnvironmentClass *) InputHandle); break; case SQL_HANDLE_STMT: conn = (ConnectionClass *) InputHandle; CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); ret = PGAPI_AllocStmt(InputHandle, OutputHandle, PODBC_EXTERNAL_STATEMENT | PODBC_INHERIT_CONNECT_OPTIONS); if (*OutputHandle) ((StatementClass *) (*OutputHandle))->external = 1; LEAVE_CONN_CS(conn); break; case SQL_HANDLE_DESC: conn = (ConnectionClass *) InputHandle; CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); ret = PGAPI_AllocDesc(InputHandle, OutputHandle); LEAVE_CONN_CS(conn); MYLOG(DETAIL_LOG_LEVEL, "OutputHandle=%p\n", *OutputHandle); break; default: ret = SQL_ERROR; break; } return ret; } /* SQLBindParameter/SQLSetParam -> SQLBindParam */ RETCODE SQL_API SQLBindParam(HSTMT StatementHandle, SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, SQLSMALLINT ParameterType, SQLULEN LengthPrecision, SQLSMALLINT ParameterScale, PTR ParameterValue, SQLLEN *StrLen_or_Ind) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; int BufferLength = 512; /* Is it OK ? */ MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_BindParameter(StatementHandle, ParameterNumber, SQL_PARAM_INPUT, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, BufferLength, StrLen_or_Ind); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } /* New function */ RETCODE SQL_API SQLCloseCursor(HSTMT StatementHandle) { StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_FreeStmt(StatementHandle, SQL_CLOSE); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #ifndef UNICODE_SUPPORTXX /* SQLColAttributes -> SQLColAttribute */ SQLRETURN SQL_API SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, #if defined(_WIN64) || defined(SQLCOLATTRIBUTE_SQLLEN) SQLLEN *NumericAttribute #else SQLPOINTER NumericAttribute #endif ) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_ColAttributes(StatementHandle, ColumnNumber, FieldIdentifier, CharacterAttribute, BufferLength, StringLength, NumericAttribute); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ /* new function */ RETCODE SQL_API SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle) { RETCODE ret; MYLOG(0, "Entering\n"); ret = PGAPI_CopyDesc(SourceDescHandle, TargetDescHandle); return ret; } /* SQLTransact -> SQLEndTran */ RETCODE SQL_API SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType) { RETCODE ret; MYLOG(0, "Entering\n"); switch (HandleType) { case SQL_HANDLE_ENV: ENTER_ENV_CS((EnvironmentClass *) Handle); ret = PGAPI_Transact(Handle, SQL_NULL_HDBC, CompletionType); LEAVE_ENV_CS((EnvironmentClass *) Handle); break; case SQL_HANDLE_DBC: CC_examine_global_transaction((ConnectionClass *) Handle); ENTER_CONN_CS((ConnectionClass *) Handle); CC_clear_error((ConnectionClass *) Handle); ret = PGAPI_Transact(SQL_NULL_HENV, Handle, CompletionType); LEAVE_CONN_CS((ConnectionClass *) Handle); break; default: ret = SQL_ERROR; break; } return ret; } /* SQLExtendedFetch -> SQLFetchScroll */ RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) { CSTR func = "SQLFetchScroll"; StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret = SQL_SUCCESS; IRDFields *irdopts = SC_get_IRDF(stmt); SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray; SQLULEN *pcRow = irdopts->rowsFetched; SQLLEN bkmarkoff = 0; MYLOG(0, "Entering %d," FORMAT_LEN "\n", FetchOrientation, FetchOffset); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (FetchOrientation == SQL_FETCH_BOOKMARK) { if (stmt->options.bookmark_ptr) { bkmarkoff = FetchOffset; FetchOffset = *((Int4 *) stmt->options.bookmark_ptr); MYLOG(0, "bookmark=" FORMAT_LEN " FetchOffset = " FORMAT_LEN "\n", FetchOffset, bkmarkoff); } else { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Bookmark isn't specified yet", func); ret = SQL_ERROR; } } if (SQL_SUCCESS == ret) { ARDFields *opts = SC_get_ARDF(stmt); ret = PGAPI_ExtendedFetch(StatementHandle, FetchOrientation, FetchOffset, pcRow, rowStatusArray, bkmarkoff, opts->size_of_rowset); stmt->transition_status = STMT_TRANSITION_FETCH_SCROLL; } ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); if (ret != SQL_SUCCESS) MYLOG(0, "leaving return = %d\n", ret); return ret; } /* SQLFree(Connect/Env/Stmt) -> SQLFreeHandle */ RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) { RETCODE ret; StatementClass *stmt; ConnectionClass *conn = NULL; MYLOG(0, "Entering\n"); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_FreeEnv(Handle); break; case SQL_HANDLE_DBC: ret = PGAPI_FreeConnect(Handle); break; case SQL_HANDLE_STMT: stmt = (StatementClass *) Handle; if (stmt) { conn = stmt->hdbc; if (conn) ENTER_CONN_CS(conn); } ret = PGAPI_FreeStmt(Handle, SQL_DROP); if (conn) LEAVE_CONN_CS(conn); break; case SQL_HANDLE_DESC: ret = PGAPI_FreeDesc(Handle); break; default: ret = SQL_ERROR; break; } return ret; } #ifndef UNICODE_SUPPORTXX /* new function */ RETCODE SQL_API SQLGetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret; MYLOG(0, "Entering\n"); ret = PGAPI_GetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength, StringLength); return ret; } /* new function */ RETCODE SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLCHAR *Name, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLSMALLINT *Type, SQLSMALLINT *SubType, SQLLEN *Length, SQLSMALLINT *Precision, SQLSMALLINT *Scale, SQLSMALLINT *Nullable) { MYLOG(0, "Entering\n"); MYLOG(0, "Error not implemented\n"); return SQL_ERROR; } /* new function */ RETCODE SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, PTR DiagInfo, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength) { RETCODE ret; MYLOG(0, "Entering Handle=(%u,%p) Rec=%d Id=%d info=(%p,%d)\n", HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength); ret = PGAPI_GetDiagField(HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength, StringLength); return ret; } /* SQLError -> SQLDiagRec */ RETCODE SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) { RETCODE ret; MYLOG(0, "Entering\n"); ret = PGAPI_GetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength, TextLength); return ret; } #endif /* UNICODE_SUPPORTXX */ /* new function */ RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret; EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; MYLOG(0, "Entering " FORMAT_INTEGER "\n", Attribute); ENTER_ENV_CS(env); ret = SQL_SUCCESS; switch (Attribute) { case SQL_ATTR_CONNECTION_POOLING: *((unsigned int *) Value) = EN_is_pooling(env) ? SQL_CP_ONE_PER_DRIVER : SQL_CP_OFF; break; case SQL_ATTR_CP_MATCH: *((unsigned int *) Value) = SQL_CP_RELAXED_MATCH; break; case SQL_ATTR_ODBC_VERSION: *((unsigned int *) Value) = EN_is_odbc2(env) ? SQL_OV_ODBC2 : SQL_OV_ODBC3; break; case SQL_ATTR_OUTPUT_NTS: *((unsigned int *) Value) = SQL_TRUE; break; default: env->errornumber = CONN_INVALID_ARGUMENT_NO; ret = SQL_ERROR; } LEAVE_ENV_CS(env); return ret; } #ifndef UNICODE_SUPPORTXX /* SQLGetConnectOption -> SQLGetconnectAttr */ RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret; MYLOG(0, "Entering " FORMAT_UINTEGER "\n", Attribute); CC_examine_global_transaction((ConnectionClass*) ConnectionHandle); ENTER_CONN_CS((ConnectionClass *) ConnectionHandle); CC_clear_error((ConnectionClass *) ConnectionHandle); ret = PGAPI_GetConnectAttr(ConnectionHandle, Attribute,Value, BufferLength, StringLength); LEAVE_CONN_CS((ConnectionClass *) ConnectionHandle); return ret; } /* SQLGetStmtOption -> SQLGetStmtAttr */ RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering Handle=%p " FORMAT_INTEGER "\n", StatementHandle, Attribute); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_GetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } /* SQLSetConnectOption -> SQLSetConnectAttr */ RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; MYLOG(0, "Entering " FORMAT_INTEGER "\n", Attribute); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_SetConnectAttr(ConnectionHandle, Attribute, Value, StringLength); LEAVE_CONN_CS(conn); return ret; } /* new function */ RETCODE SQL_API SQLSetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret; MYLOG(0, "Entering h=%p rec=%d field=%d val=%p\n", DescriptorHandle, RecNumber, FieldIdentifier, Value); ret = PGAPI_SetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); return ret; } /* new function */ RETCODE SQL_API SQLSetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT Type, SQLSMALLINT SubType, SQLLEN Length, SQLSMALLINT Precision, SQLSMALLINT Scale, PTR Data, SQLLEN *StringLength, SQLLEN *Indicator) { MYLOG(0, "Entering\n"); MYLOG(0, "Error not implemented\n"); return SQL_ERROR; } #endif /* UNICODE_SUPPORTXX */ /* new function */ RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength) { RETCODE ret; EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; MYLOG(0, "Entering att=" FORMAT_INTEGER "," FORMAT_ULEN "\n", Attribute, (SQLULEN) Value); ENTER_ENV_CS(env); switch (Attribute) { case SQL_ATTR_CONNECTION_POOLING: switch ((ULONG_PTR) Value) { case SQL_CP_OFF: EN_unset_pooling(env); ret = SQL_SUCCESS; break; #if defined(WIN_MULTITHREAD_SUPPORT) || defined(POSIX_MULTITHREAD_SUPPORT) case SQL_CP_ONE_PER_DRIVER: EN_set_pooling(env); ret = SQL_SUCCESS; break; #endif /* WIN_MULTITHREAD_SUPPORT */ default: ret = SQL_SUCCESS_WITH_INFO; } break; case SQL_ATTR_CP_MATCH: /* *((unsigned int *) Value) = SQL_CP_RELAXED_MATCH; */ ret = SQL_SUCCESS; break; case SQL_ATTR_ODBC_VERSION: if (SQL_OV_ODBC2 == CAST_UPTR(SQLUINTEGER, Value)) EN_set_odbc2(env); else EN_set_odbc3(env); ret = SQL_SUCCESS; break; case SQL_ATTR_OUTPUT_NTS: if (SQL_TRUE == CAST_UPTR(SQLUINTEGER, Value)) ret = SQL_SUCCESS; else ret = SQL_SUCCESS_WITH_INFO; break; default: env->errornumber = CONN_INVALID_ARGUMENT_NO; ret = SQL_ERROR; } if (SQL_SUCCESS_WITH_INFO == ret) { env->errornumber = CONN_OPTION_VALUE_CHANGED; env->errormsg = "SetEnv changed to "; } LEAVE_ENV_CS(env); return ret; } #ifndef UNICODE_SUPPORTXX /* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */ RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength) { StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret; MYLOG(0, "Entering Handle=%p " FORMAT_INTEGER "," FORMAT_ULEN "\n", StatementHandle, Attribute, (SQLULEN) Value); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_SetStmtAttr(StatementHandle, Attribute, Value, StringLength); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } #endif /* UNICODE_SUPPORTXX */ #define SQL_FUNC_ESET(pfExists, uwAPI) \ (*(((UWORD*) (pfExists)) + ((uwAPI) >> 4)) \ |= (1 << ((uwAPI) & 0x000F)) \ ) RETCODE SQL_API PGAPI_GetFunctions30(HDBC hdbc, SQLUSMALLINT fFunction, SQLUSMALLINT FAR * pfExists) { ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci = &(conn->connInfo); MYLOG(DETAIL_LOG_LEVEL, "lie=%d\n", ci->drivers.lie); CC_examine_global_transaction(conn); CC_clear_error(conn); if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS) return SQL_ERROR; memset(pfExists, 0, sizeof(UWORD) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE); /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCSTMT); 3 deprecated */ /* * for (i = SQL_API_SQLBINDCOL; i <= 23; i++) SQL_FUNC_ESET(pfExists, * i); */ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCANCEL); /* 5 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLERROR); 10 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREECONNECT); 14 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEENV); 15 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPARAM); 22 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLTRANSACT); 23 deprecated */ /* * for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++) * SQL_FUNC_ESET(pfExists, i); */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTOPTION); 42 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTOPTION); 46 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTOPTION); 51 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSPECIALCOLUMNS); /* 52 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLES); /* 54 */ if (ci->drivers.lie) SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */ if (SUPPORT_DESCRIBE_PARAM(ci) || ci->drivers.lie) SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLEXTENDEDFETCH); /* 59 deprecated ? */ /* * for (++i; i < SQL_API_SQLBINDPARAMETER; i++) * SQL_FUNC_ESET(pfExists, i); */ SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMOPTIONS); 64 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPOS); /* 68 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); 69 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS); */ /* 71 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC); /* 1004 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 */ if (ci->drivers.lie) { SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented yet */ } SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 minimal implementation */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 */ if (ci->drivers.lie) { SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */ } SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */ if (0 != (ALLOW_BULK_OPERATIONS & ci->updatable_cursors)) SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS); /* 24 */ return SQL_SUCCESS; } RETCODE SQL_API SQLBulkOperations(HSTMT hstmt, SQLSMALLINT operation) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); MYLOG(0, "Entering Handle=%p %d\n", hstmt, operation); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_BulkOperations(hstmt, operation); ret = DiscardStatementSvp(stmt,ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } psqlodbc-REL-16_00_0005/odbcapi30w.c000066400000000000000000000256201462406103600166020ustar00rootroot00000000000000/*------- * Module: odbcapi30w.c * * Description: This module contains UNICODE routines * * Classes: n/a * * API functions: SQLColAttributeW, SQLGetStmtAttrW, SQLSetStmtAttrW, SQLSetConnectAttrW, SQLGetConnectAttrW, SQLGetDescFieldW, SQLGetDescRecW, SQLGetDiagFieldW, SQLGetDiagRecW, *------- */ #include "psqlodbc.h" #include "unicode_support.h" #include #include #include "pgapifunc.h" #include "connection.h" #include "statement.h" #include "misc.h" RETCODE SQL_API SQLGetStmtAttrW(SQLHSTMT hstmt, SQLINTEGER fAttribute, PTR rgbValue, SQLINTEGER cbValueMax, SQLINTEGER *pcbValue) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); ENTER_STMT_CS((StatementClass *) hstmt); SC_clear_error((StatementClass *) hstmt); StartRollbackState(stmt); ret = PGAPI_GetStmtAttr(hstmt, fAttribute, rgbValue, cbValueMax, pcbValue); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS((StatementClass *) hstmt); return ret; } RETCODE SQL_API SQLSetStmtAttrW(SQLHSTMT hstmt, SQLINTEGER fAttribute, PTR rgbValue, SQLINTEGER cbValueMax) { RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "Entering\n"); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_SetStmtAttr(hstmt, fAttribute, rgbValue, cbValueMax); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLGetConnectAttrW(HDBC hdbc, SQLINTEGER fAttribute, PTR rgbValue, SQLINTEGER cbValueMax, SQLINTEGER *pcbValue) { RETCODE ret; MYLOG(0, "Entering\n"); CC_examine_global_transaction((ConnectionClass *) hdbc); ENTER_CONN_CS((ConnectionClass *) hdbc); CC_clear_error((ConnectionClass *) hdbc); ret = PGAPI_GetConnectAttr(hdbc, fAttribute, rgbValue, cbValueMax, pcbValue); LEAVE_CONN_CS((ConnectionClass *) hdbc); return ret; } RETCODE SQL_API SQLSetConnectAttrW(HDBC hdbc, SQLINTEGER fAttribute, PTR rgbValue, SQLINTEGER cbValue) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); CC_set_in_unicode_driver(conn); ret = PGAPI_SetConnectAttr(hdbc, fAttribute, rgbValue, cbValue); LEAVE_CONN_CS(conn); return ret; } /* new function */ RETCODE SQL_API SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret; SQLLEN vallen; char *uval = NULL; BOOL val_alloced = FALSE; MYLOG(0, "Entering\n"); if (BufferLength > 0 || SQL_NTS == BufferLength) { switch (FieldIdentifier) { case SQL_DESC_BASE_COLUMN_NAME: case SQL_DESC_BASE_TABLE_NAME: case SQL_DESC_CATALOG_NAME: case SQL_DESC_LABEL: case SQL_DESC_LITERAL_PREFIX: case SQL_DESC_LITERAL_SUFFIX: case SQL_DESC_LOCAL_TYPE_NAME: case SQL_DESC_NAME: case SQL_DESC_SCHEMA_NAME: case SQL_DESC_TABLE_NAME: case SQL_DESC_TYPE_NAME: uval = ucs2_to_utf8(Value, BufferLength > 0 ? BufferLength / WCLEN : BufferLength, &vallen, FALSE); val_alloced = TRUE; break; } } if (!val_alloced) { uval = Value; vallen = BufferLength; } ret = PGAPI_SetDescField(DescriptorHandle, RecNumber, FieldIdentifier, uval, (SQLINTEGER) vallen); if (val_alloced) free(uval); return ret; } RETCODE SQL_API SQLGetDescFieldW(SQLHDESC hdesc, SQLSMALLINT iRecord, SQLSMALLINT iField, PTR rgbValue, SQLINTEGER cbValueMax, SQLINTEGER *pcbValue) { RETCODE ret; SQLINTEGER blen = 0, bMax, *pcbV; char *rgbV = NULL, *rgbVt; MYLOG(0, "Entering\n"); switch (iField) { case SQL_DESC_BASE_COLUMN_NAME: case SQL_DESC_BASE_TABLE_NAME: case SQL_DESC_CATALOG_NAME: case SQL_DESC_LABEL: case SQL_DESC_LITERAL_PREFIX: case SQL_DESC_LITERAL_SUFFIX: case SQL_DESC_LOCAL_TYPE_NAME: case SQL_DESC_NAME: case SQL_DESC_SCHEMA_NAME: case SQL_DESC_TABLE_NAME: case SQL_DESC_TYPE_NAME: bMax = cbValueMax * 3 / WCLEN; rgbV = malloc(bMax + 1); pcbV = &blen; for (rgbVt = rgbV;; bMax = blen + 1, rgbVt = realloc(rgbV, bMax)) { if (!rgbVt) { ret = SQL_ERROR; break; } rgbV = rgbVt; ret = PGAPI_GetDescField(hdesc, iRecord, iField, rgbV, bMax, pcbV); if (SQL_SUCCESS_WITH_INFO != ret || blen < bMax) break; } if (SQL_SUCCEEDED(ret)) { blen = (SQLINTEGER) utf8_to_ucs2(rgbV, blen, (SQLWCHAR *) rgbValue, cbValueMax / WCLEN); if (SQL_SUCCESS == ret && blen * WCLEN >= cbValueMax) { ret = SQL_SUCCESS_WITH_INFO; DC_set_error(hdesc, STMT_TRUNCATED, "The buffer was too small for the rgbDesc."); } if (pcbValue) *pcbValue = blen * WCLEN; } if (rgbV) free(rgbV); break; default: rgbV = rgbValue; bMax = cbValueMax; pcbV = pcbValue; ret = PGAPI_GetDescField(hdesc, iRecord, iField, rgbV, bMax, pcbV); break; } return ret; } RETCODE SQL_API SQLGetDiagRecW(SQLSMALLINT fHandleType, SQLHANDLE handle, SQLSMALLINT iRecord, SQLWCHAR *szSqlState, SQLINTEGER *pfNativeError, SQLWCHAR *szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT *pcbErrorMsg) { RETCODE ret; SQLSMALLINT buflen, tlen; char qstr_ansi[8], *mtxt = NULL; MYLOG(0, "Entering\n"); buflen = 0; if (szErrorMsg && cbErrorMsgMax > 0) { buflen = cbErrorMsgMax; mtxt = malloc(buflen); } ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, (SQLCHAR *) qstr_ansi, pfNativeError, (SQLCHAR *) mtxt, buflen, &tlen); if (SQL_SUCCEEDED(ret)) { if (szSqlState) utf8_to_ucs2(qstr_ansi, -1, szSqlState, 6); if (mtxt && tlen <= cbErrorMsgMax) { SQLULEN ulen = utf8_to_ucs2_lf(mtxt, tlen, FALSE, szErrorMsg, cbErrorMsgMax, TRUE); if (ulen == (SQLULEN) -1) tlen = (SQLSMALLINT) locale_to_sqlwchar((SQLWCHAR *) szErrorMsg, mtxt, cbErrorMsgMax, FALSE); else tlen = (SQLSMALLINT) ulen; if (tlen >= cbErrorMsgMax) ret = SQL_SUCCESS_WITH_INFO; else if (tlen < 0) { char errc[32]; SPRINTF_FIXED(errc, "Error: SqlState=%s", qstr_ansi); tlen = utf8_to_ucs2(errc, -1, szErrorMsg, cbErrorMsgMax); } } if (pcbErrorMsg) *pcbErrorMsg = tlen; } if (mtxt) free(mtxt); return ret; } SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT hstmt, SQLUSMALLINT iCol, SQLUSMALLINT iField, SQLPOINTER pCharAttr, SQLSMALLINT cbCharAttrMax, SQLSMALLINT *pcbCharAttr, #if defined(_WIN64) || defined(SQLCOLATTRIBUTE_SQLLEN) SQLLEN *pNumAttr #else SQLPOINTER pNumAttr #endif ) { CSTR func = "SQLColAttributeW"; RETCODE ret; StatementClass *stmt = (StatementClass *) hstmt; SQLSMALLINT *rgbL, blen = 0, bMax; char *rgbD = NULL, *rgbDt; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); switch (iField) { case SQL_DESC_BASE_COLUMN_NAME: case SQL_DESC_BASE_TABLE_NAME: case SQL_DESC_CATALOG_NAME: case SQL_DESC_LABEL: case SQL_DESC_LITERAL_PREFIX: case SQL_DESC_LITERAL_SUFFIX: case SQL_DESC_LOCAL_TYPE_NAME: case SQL_DESC_NAME: case SQL_DESC_SCHEMA_NAME: case SQL_DESC_TABLE_NAME: case SQL_DESC_TYPE_NAME: case SQL_COLUMN_NAME: bMax = cbCharAttrMax * 3 / WCLEN; rgbD = malloc(bMax); rgbL = &blen; for (rgbDt = rgbD;; bMax = blen + 1, rgbDt = realloc(rgbD, bMax)) { if (!rgbDt) { ret = SQL_ERROR; break; } rgbD = rgbDt; ret = PGAPI_ColAttributes(hstmt, iCol, iField, rgbD, bMax, rgbL, pNumAttr); if (SQL_SUCCESS_WITH_INFO != ret || blen < bMax) break; } if (SQL_SUCCEEDED(ret)) { blen = (SQLSMALLINT) utf8_to_ucs2(rgbD, blen, (SQLWCHAR *) pCharAttr, cbCharAttrMax / WCLEN); if (SQL_SUCCESS == ret && blen * WCLEN >= cbCharAttrMax) { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the pCharAttr.", func); } if (pcbCharAttr) *pcbCharAttr = blen * WCLEN; } if (rgbD) free(rgbD); break; default: rgbD = pCharAttr; bMax = cbCharAttrMax; rgbL = pcbCharAttr; ret = PGAPI_ColAttributes(hstmt, iCol, iField, rgbD, bMax, rgbL, pNumAttr); break; } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } RETCODE SQL_API SQLGetDiagFieldW(SQLSMALLINT fHandleType, SQLHANDLE handle, SQLSMALLINT iRecord, SQLSMALLINT fDiagField, SQLPOINTER rgbDiagInfo, SQLSMALLINT cbDiagInfoMax, SQLSMALLINT *pcbDiagInfo) { RETCODE ret; SQLSMALLINT *rgbL, blen = 0, bMax; char *rgbD = NULL, *rgbDt; MYLOG(0, "Entering Handle=(%u,%p) Rec=%d Id=%d info=(%p,%d)\n", fHandleType, handle, iRecord, fDiagField, rgbDiagInfo, cbDiagInfoMax); switch (fDiagField) { case SQL_DIAG_DYNAMIC_FUNCTION: case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_SUBCLASS_ORIGIN: bMax = cbDiagInfoMax * 3 / WCLEN + 1; if (rgbD = malloc(bMax), !rgbD) return SQL_ERROR; rgbL = &blen; for (rgbDt = rgbD;; bMax = blen + 1, rgbDt = realloc(rgbD, bMax)) { if (!rgbDt) { free(rgbD); return SQL_ERROR; } rgbD = rgbDt; ret = PGAPI_GetDiagField(fHandleType, handle, iRecord, fDiagField, rgbD, bMax, rgbL); if (SQL_SUCCESS_WITH_INFO != ret || blen < bMax) break; } if (SQL_SUCCEEDED(ret)) { SQLULEN ulen = (SQLSMALLINT) utf8_to_ucs2_lf(rgbD, blen, FALSE, (SQLWCHAR *) rgbDiagInfo, cbDiagInfoMax / WCLEN, TRUE); if (ulen == (SQLULEN) -1) blen = (SQLSMALLINT) locale_to_sqlwchar((SQLWCHAR *) rgbDiagInfo, rgbD, cbDiagInfoMax / WCLEN, FALSE); else blen = (SQLSMALLINT) ulen; if (SQL_SUCCESS == ret && blen * WCLEN >= cbDiagInfoMax) ret = SQL_SUCCESS_WITH_INFO; if (pcbDiagInfo) { *pcbDiagInfo = blen * WCLEN; } } if (rgbD) free(rgbD); break; default: rgbD = rgbDiagInfo; bMax = cbDiagInfoMax; rgbL = pcbDiagInfo; ret = PGAPI_GetDiagField(fHandleType, handle, iRecord, fDiagField, rgbD, bMax, rgbL); break; } return ret; } /* new function */ RETCODE SQL_API SQLGetDescRecW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLWCHAR *Name, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLSMALLINT *Type, SQLSMALLINT *SubType, SQLLEN *Length, SQLSMALLINT *Precision, SQLSMALLINT *Scale, SQLSMALLINT *Nullable) { MYLOG(0, "Entering\n"); MYLOG(0, "Error not implemented\n"); return SQL_ERROR; } /* new function */ RETCODE SQL_API SQLSetDescRecW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT Type, SQLSMALLINT SubType, SQLLEN Length, SQLSMALLINT Precision, SQLSMALLINT Scale, PTR Data, SQLLEN *StringLength, SQLLEN *Indicator) { MYLOG(0, "Entering\n"); MYLOG(0, "Error not implemented\n"); return SQL_ERROR; } psqlodbc-REL-16_00_0005/odbcapiw.c000066400000000000000000000677711462406103600164540ustar00rootroot00000000000000/*------- * Module: odbcapiw.c * * Description: This module contains UNICODE routines * * Classes: n/a * * API functions: SQLColumnPrivilegesW, SQLColumnsW, SQLConnectW, SQLDataSourcesW, SQLDescribeColW, SQLDriverConnectW, SQLExecDirectW, SQLForeignKeysW, SQLGetCursorNameW, SQLGetInfoW, SQLNativeSqlW, SQLPrepareW, SQLPrimaryKeysW, SQLProcedureColumnsW, SQLProceduresW, SQLSetCursorNameW, SQLSpecialColumnsW, SQLStatisticsW, SQLTablesW, SQLTablePrivilegesW, SQLGetTypeInfoW *------- */ #include "psqlodbc.h" #include "unicode_support.h" #include #include #include "pgapifunc.h" #include "connection.h" #include "statement.h" RETCODE SQL_API SQLColumnsW(HSTMT StatementHandle, SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLWCHAR *ColumnName, SQLSMALLINT NameLength4) { CSTR func = "SQLColumnsW"; RETCODE ret; char *ctName, *scName, *tbName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn; BOOL lower_id; UWORD flag = PODBC_SEARCH_PUBLIC_SCHEMA; ConnInfo *ci; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); ci = &(conn->connInfo); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id); clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (atoi(ci->show_oid_column)) flag |= PODBC_SHOW_OID_COLUMN; if (atoi(ci->row_versioning)) flag |= PODBC_ROW_VERSIONING; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Columns(StatementHandle, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, flag, 0, 0); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); if (clName) free(clName); return ret; } RETCODE SQL_API SQLConnectW(HDBC ConnectionHandle, SQLWCHAR *ServerName, SQLSMALLINT NameLength1, SQLWCHAR *UserName, SQLSMALLINT NameLength2, SQLWCHAR *Authentication, SQLSMALLINT NameLength3) { char *svName, *usName, *auth; SQLLEN nmlen1, nmlen2, nmlen3; RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); CC_set_in_unicode_driver(conn); svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1, FALSE); usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2, FALSE); auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3, FALSE); ret = PGAPI_Connect(ConnectionHandle, (SQLCHAR *) svName, (SQLSMALLINT) nmlen1, (SQLCHAR *) usName, (SQLSMALLINT) nmlen2, (SQLCHAR *) auth, (SQLSMALLINT) nmlen3); LEAVE_CONN_CS(conn); if (svName) free(svName); if (usName) free(usName); if (auth) free(auth); return ret; } RETCODE SQL_API SQLDriverConnectW(HDBC hdbc, HWND hwnd, SQLWCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, SQLWCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { CSTR func = "SQLDriverConnectW"; char *szIn, *szOut = NULL; SQLSMALLINT maxlen, obuflen = 0; SQLLEN inlen; SQLSMALLINT olen, *pCSO; RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); CC_set_in_unicode_driver(conn); szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE); maxlen = cbConnStrOutMax; pCSO = NULL; olen = 0; if (maxlen > 0) { obuflen = maxlen + 1; szOut = malloc(obuflen); if (!szOut) { CC_set_error(conn, CONN_NO_MEMORY_ERROR, "Could not allocate memory for output buffer", func); ret = SQL_ERROR; goto cleanup; } pCSO = &olen; } else if (pcbConnStrOut) pCSO = &olen; ret = PGAPI_DriverConnect(hdbc, hwnd, (SQLCHAR *) szIn, (SQLSMALLINT) inlen, (SQLCHAR *) szOut, maxlen, pCSO, fDriverCompletion); if (ret != SQL_ERROR && NULL != pCSO) { SQLLEN outlen = olen; if (olen < obuflen) outlen = utf8_to_ucs2(szOut, olen, szConnStrOut, cbConnStrOutMax); else utf8_to_ucs2(szOut, maxlen, szConnStrOut, cbConnStrOutMax); if (outlen >= cbConnStrOutMax && NULL != szConnStrOut && NULL != pcbConnStrOut) { MYLOG(DETAIL_LOG_LEVEL, "cbConnstrOutMax=%d pcb=%p\n", cbConnStrOutMax, pcbConnStrOut); if (SQL_SUCCESS == ret) { CC_set_error(conn, CONN_TRUNCATED, "the ConnStrOut is too small", func); ret = SQL_SUCCESS_WITH_INFO; } } if (pcbConnStrOut) *pcbConnStrOut = (SQLSMALLINT) outlen; } cleanup: LEAVE_CONN_CS(conn); if (szOut) free(szOut); if (szIn) free(szIn); return ret; } RETCODE SQL_API SQLBrowseConnectW(HDBC hdbc, SQLWCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, SQLWCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut) { CSTR func = "SQLBrowseConnectW"; char *szIn, *szOut; SQLLEN inlen; SQLUSMALLINT obuflen; SQLSMALLINT olen; RETCODE ret; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); CC_set_in_unicode_driver(conn); szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE); obuflen = cbConnStrOutMax + 1; szOut = malloc(obuflen); if (szOut) ret = PGAPI_BrowseConnect(hdbc, (SQLCHAR *) szIn, (SQLSMALLINT) inlen, (SQLCHAR *) szOut, cbConnStrOutMax, &olen); else { CC_set_error(conn, CONN_NO_MEMORY_ERROR, "Could not allocate memory for output buffer", func); ret = SQL_ERROR; } LEAVE_CONN_CS(conn); if (ret != SQL_ERROR) { SQLLEN outlen = utf8_to_ucs2(szOut, olen, szConnStrOut, cbConnStrOutMax); if (pcbConnStrOut) *pcbConnStrOut = (SQLSMALLINT) outlen; } free(szOut); if (szIn) free(szIn); return ret; } RETCODE SQL_API SQLDataSourcesW(HENV EnvironmentHandle, SQLUSMALLINT Direction, SQLWCHAR *ServerName, SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, SQLWCHAR *Description, SQLSMALLINT BufferLength2, SQLSMALLINT *NameLength2) { MYLOG(0, "Entering\n"); /* return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, BufferLength1, NameLength1, Description, BufferLength2, NameLength2); */ return SQL_ERROR; } RETCODE SQL_API SQLDescribeColW(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLWCHAR *ColumnName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType, SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) { CSTR func = "SQLDescribeColW"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; SQLSMALLINT buflen, nmlen; char *clName = NULL, *clNamet = NULL; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; buflen = 0; if (BufferLength > 0) buflen = BufferLength * 3; else if (NameLength) buflen = 32; if (buflen > 0) clNamet = malloc(buflen); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); for (;; buflen = nmlen + 1, clNamet = realloc(clName, buflen)) { if (!clNamet) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for column name", func); ret = SQL_ERROR; break; } clName = clNamet; ret = PGAPI_DescribeCol(StatementHandle, ColumnNumber, (SQLCHAR *) clName, buflen, &nmlen, DataType, ColumnSize, DecimalDigits, Nullable); if (SQL_SUCCESS_WITH_INFO != ret || nmlen < buflen) break; } if (SQL_SUCCEEDED(ret)) { SQLLEN nmcount = nmlen; if (nmlen < buflen) nmcount = utf8_to_ucs2(clName, nmlen, ColumnName, BufferLength); if (SQL_SUCCESS == ret && BufferLength > 0 && nmcount > BufferLength) { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "Column name too large", func); } if (NameLength) *NameLength = (SQLSMALLINT) nmcount; } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (clName) free(clName); return ret; } RETCODE SQL_API SQLExecDirectW(HSTMT StatementHandle, SQLWCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLExecDirectW"; RETCODE ret; char *stxt; SQLLEN slen; StatementClass *stmt = (StatementClass *) StatementHandle; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE); ENTER_STMT_CS(stmt); SC_clear_error(stmt); flag |= PODBC_WITH_HOLD; StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ExecDirect(StatementHandle, (SQLCHAR *) stxt, (SQLINTEGER) slen, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (stxt) free(stxt); return ret; } RETCODE SQL_API SQLGetCursorNameW(HSTMT StatementHandle, SQLWCHAR *CursorName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength) { CSTR func = "SQLGetCursorNameW"; RETCODE ret; StatementClass * stmt = (StatementClass *) StatementHandle; char *crName = NULL, *crNamet; SQLSMALLINT clen, buflen; MYLOG(0, "Entering\n"); if (BufferLength > 0) buflen = BufferLength * 3; else buflen = 32; crNamet = malloc(buflen); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); for (;; buflen = clen + 1, crNamet = realloc(crName, buflen)) { if (!crNamet) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for cursor name", func); ret = SQL_ERROR; break; } crName = crNamet; ret = PGAPI_GetCursorName(StatementHandle, (SQLCHAR *) crName, buflen, &clen); if (SQL_SUCCESS_WITH_INFO != ret || clen < buflen) break; } if (SQL_SUCCEEDED(ret)) { SQLLEN nmcount = clen; if (clen < buflen) nmcount = utf8_to_ucs2(crName, clen, CursorName, BufferLength); if (SQL_SUCCESS == ret && nmcount > BufferLength) { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "Cursor name too large", func); } if (NameLength) *NameLength = (SQLSMALLINT) nmcount; } ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); free(crName); return ret; } RETCODE SQL_API SQLGetInfoW(HDBC ConnectionHandle, SQLUSMALLINT InfoType, PTR InfoValue, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength) { ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret; CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_set_in_unicode_driver(conn); CC_clear_error(conn); MYLOG(0, "Entering\n"); if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength)) == SQL_ERROR) CC_log_error("SQLGetInfoW", "", conn); LEAVE_CONN_CS(conn); return ret; } RETCODE SQL_API SQLPrepareW(HSTMT StatementHandle, SQLWCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLPrepareW"; StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret; char *stxt; SQLLEN slen; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Prepare(StatementHandle, (SQLCHAR *) stxt, (SQLINTEGER) slen); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (stxt) free(stxt); return ret; } RETCODE SQL_API SQLSetCursorNameW(HSTMT StatementHandle, SQLWCHAR *CursorName, SQLSMALLINT NameLength) { RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; char *crName; SQLLEN nlen; MYLOG(0, "Entering\n"); crName = ucs2_to_utf8(CursorName, NameLength, &nlen, FALSE); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_SetCursorName(StatementHandle, (SQLCHAR *) crName, (SQLSMALLINT) nlen); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (crName) free(crName); return ret; } RETCODE SQL_API SQLSpecialColumnsW(HSTMT StatementHandle, SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Scope, SQLUSMALLINT Nullable) { CSTR func = "SQLSpecialColumnsW"; RETCODE ret; char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn; BOOL lower_id; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, Scope, Nullable); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); return ret; } RETCODE SQL_API SQLStatisticsW(HSTMT StatementHandle, SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Unique, SQLUSMALLINT Reserved) { CSTR func = "SQLStatisticsW"; RETCODE ret; char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn; BOOL lower_id; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Statistics(StatementHandle, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, Unique, Reserved); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); return ret; } RETCODE SQL_API SQLTablesW(HSTMT StatementHandle, SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLWCHAR *TableType, SQLSMALLINT NameLength4) { CSTR func = "SQLTablesW"; RETCODE ret; char *ctName, *scName, *tbName, *tbType; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id); tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4, FALSE); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Tables(StatementHandle, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, (SQLCHAR *) tbType, (SQLSMALLINT) nmlen4, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); if (tbType) free(tbType); return ret; } RETCODE SQL_API SQLColumnPrivilegesW(HSTMT hstmt, SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR *szTableName, SQLSMALLINT cbTableName, SQLWCHAR *szColumnName, SQLSMALLINT cbColumnName) { CSTR func = "SQLColumnPrivilegesW"; RETCODE ret; char *ctName, *scName, *tbName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id); clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ColumnPrivileges(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); if (clName) free(clName); return ret; } RETCODE SQL_API SQLForeignKeysW(HSTMT hstmt, SQLWCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName, SQLWCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName, SQLWCHAR *szPkTableName, SQLSMALLINT cbPkTableName, SQLWCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName, SQLWCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName, SQLWCHAR *szFkTableName, SQLSMALLINT cbFkTableName) { CSTR func = "SQLForeignKeysW"; RETCODE ret; char *ctName, *scName, *tbName, *fkctName, *fkscName, *fktbName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4, nmlen5, nmlen6; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2, lower_id); tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3, lower_id); fkctName = ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4, lower_id); fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5, lower_id); fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ForeignKeys(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, (SQLCHAR *) fkctName, (SQLSMALLINT) nmlen4, (SQLCHAR *) fkscName, (SQLSMALLINT) nmlen5, (SQLCHAR *) fktbName, (SQLSMALLINT) nmlen6); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); if (fkctName) free(fkctName); if (fkscName) free(fkscName); if (fktbName) free(fktbName); return ret; } RETCODE SQL_API SQLNativeSqlW(HDBC hdbc, SQLWCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLWCHAR *szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr) { CSTR func = "SQLNativeSqlW"; RETCODE ret; char *szIn, *szOut = NULL, *szOutt = NULL; SQLLEN slen; SQLINTEGER buflen, olen; ConnectionClass *conn = (ConnectionClass *) hdbc; MYLOG(0, "Entering\n"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); CC_set_in_unicode_driver(conn); szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen, FALSE); buflen = 3 * cbSqlStrMax; if (buflen > 0) szOutt = malloc(buflen); for (;; buflen = olen + 1, szOutt = realloc(szOut, buflen)) { if (!szOutt) { CC_set_error(conn, CONN_NO_MEMORY_ERROR, "Could not allocate memory for output buffer", func); ret = SQL_ERROR; break; } szOut = szOutt; ret = PGAPI_NativeSql(hdbc, (SQLCHAR *) szIn, (SQLINTEGER) slen, (SQLCHAR *) szOut, buflen, &olen); if (SQL_SUCCESS_WITH_INFO != ret || olen < buflen) break; } if (szIn) free(szIn); if (SQL_SUCCEEDED(ret)) { SQLLEN szcount = olen; if (olen < buflen) szcount = utf8_to_ucs2(szOut, olen, szSqlStr, cbSqlStrMax); if (SQL_SUCCESS == ret && szcount > cbSqlStrMax) { ConnectionClass *conn = (ConnectionClass *) hdbc; ret = SQL_SUCCESS_WITH_INFO; CC_set_error(conn, CONN_TRUNCATED, "Sql string too large", func); } if (pcbSqlStr) *pcbSqlStr = (SQLINTEGER) szcount; } LEAVE_CONN_CS(conn); free(szOut); return ret; } RETCODE SQL_API SQLPrimaryKeysW(HSTMT hstmt, SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR *szTableName, SQLSMALLINT cbTableName) { CSTR func = "SQLPrimaryKeysW"; RETCODE ret; char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_PrimaryKeys(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, 0); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); return ret; } RETCODE SQL_API SQLProcedureColumnsW(HSTMT hstmt, SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR *szProcName, SQLSMALLINT cbProcName, SQLWCHAR *szColumnName, SQLSMALLINT cbColumnName) { CSTR func = "SQLProcedureColumnsW"; RETCODE ret; char *ctName, *scName, *prName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(0, "Entering\n"); conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id); clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ProcedureColumns(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) prName, (SQLSMALLINT) nmlen3, (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (prName) free(prName); if (clName) free(clName); return ret; } RETCODE SQL_API SQLProceduresW(HSTMT hstmt, SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR *szProcName, SQLSMALLINT cbProcName) { CSTR func = "SQLProceduresW"; RETCODE ret; char *ctName, *scName, *prName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_Procedures(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) prName, (SQLSMALLINT) nmlen3, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) free(ctName); if (scName) free(scName); if (prName) free(prName); return ret; } RETCODE SQL_API SQLTablePrivilegesW(HSTMT hstmt, SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR *szTableName, SQLSMALLINT cbTableName) { CSTR func = "SQLTablePrivilegesW"; RETCODE ret; char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; conn = SC_get_conn(stmt); lower_id = SC_is_lower_case(stmt, conn); ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id); ENTER_STMT_CS((StatementClass *) hstmt); SC_clear_error(stmt); StartRollbackState(stmt); if (stmt->options.metadata_id) flag |= PODBC_NOT_SEARCH_PATTERN; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_TablePrivileges(hstmt, (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS((StatementClass *) hstmt); if (ctName) free(ctName); if (scName) free(scName); if (tbName) free(tbName); return ret; } RETCODE SQL_API SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType) { CSTR func = "SQLGetTypeInfoW"; RETCODE ret; StatementClass * stmt = (StatementClass *) StatementHandle; MYLOG(0, "Entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_GetTypeInfo(StatementHandle, DataType); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } psqlodbc-REL-16_00_0005/options.c000066400000000000000000000472761462406103600163550ustar00rootroot00000000000000/*-------- * Module: options.c * * Description: This module contains routines for getting/setting * connection and statement options. * * Classes: n/a * * API functions: SQLSetConnectOption, SQLSetStmtOption, SQLGetConnectOption, * SQLGetStmtOption * * Comments: See "readme.txt" for copyright and license information. *-------- */ #include "psqlodbc.h" #include "unicode_support.h" #include #include "misc.h" #include "environ.h" #include "connection.h" #include "statement.h" #include "qresult.h" #include "pgapifunc.h" static RETCODE set_statement_option(ConnectionClass *conn, StatementClass *stmt, SQLUSMALLINT fOption, SQLULEN vParam) { CSTR func = "set_statement_option"; char changed = FALSE; ConnInfo *ci = NULL; SQLULEN setval; if (conn) ci = &(conn->connInfo); else ci = &(SC_get_conn(stmt)->connInfo); switch (fOption) { case SQL_ASYNC_ENABLE: /* ignored */ break; case SQL_BIND_TYPE: /* now support multi-column and multi-row binding */ if (conn) conn->ardOptions.bind_size = (SQLUINTEGER) vParam; if (stmt) SC_get_ARDF(stmt)->bind_size = (SQLUINTEGER) vParam; break; case SQL_CONCURRENCY: /* * positioned update isn't supported so cursor concurrency is * read-only */ MYLOG(0, "SQL_CONCURRENCY = " FORMAT_LEN " ", vParam); setval = SQL_CONCUR_READ_ONLY; if (SQL_CONCUR_READ_ONLY == vParam) ; else if (ci->drivers.lie) setval = vParam; else if (0 != ci->updatable_cursors) setval = SQL_CONCUR_ROWVER; if (conn) conn->stmtOptions.scroll_concurrency = (SQLUINTEGER) setval; else if (stmt) { if (SC_get_Result(stmt)) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "The attr can't be changed because the cursor is open.", func); return SQL_ERROR; } stmt->options.scroll_concurrency = stmt->options_orig.scroll_concurrency = (SQLUINTEGER) setval; } if (setval != vParam) changed = TRUE; MYPRINTF(0, "-> " FORMAT_LEN "\n", setval); break; case SQL_CURSOR_TYPE: /* * if declare/fetch, then type can only be forward. otherwise, * it can only be forward or static. */ MYLOG(0, "SQL_CURSOR_TYPE = " FORMAT_LEN " ", vParam); setval = SQL_CURSOR_FORWARD_ONLY; if (ci->drivers.lie) setval = vParam; else if (SQL_CURSOR_STATIC == vParam) setval = vParam; else if (SQL_CURSOR_KEYSET_DRIVEN == vParam) { if (0 != (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) setval = vParam; else setval = SQL_CURSOR_STATIC; /* at least scrollable */ } else if (SQL_CURSOR_DYNAMIC == vParam) { if (0 != (ci->updatable_cursors & ALLOW_DYNAMIC_CURSORS)) setval = vParam; else if (0 != (ci->updatable_cursors & ALLOW_KEYSET_DRIVEN_CURSORS)) setval = SQL_CURSOR_KEYSET_DRIVEN; else setval = SQL_CURSOR_STATIC; /* at least scrollable */ } if (conn) conn->stmtOptions.cursor_type = (SQLUINTEGER) setval; else if (stmt) { if (SC_get_Result(stmt)) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "The attr can't be changed because the cursor is open.", func); return SQL_ERROR; } stmt->options_orig.cursor_type = stmt->options.cursor_type = (SQLUINTEGER) setval; } if (setval != vParam) changed = TRUE; MYPRINTF(0, "-> " FORMAT_LEN "\n", setval); break; case SQL_KEYSET_SIZE: /* ignored, but saved and returned */ MYLOG(0, "SQL_KEYSET_SIZE, vParam = " FORMAT_LEN "\n", vParam); if (conn) conn->stmtOptions.keyset_size = vParam; if (stmt) { stmt->options_orig.keyset_size = vParam; if (!SC_get_Result(stmt)) stmt->options.keyset_size = vParam; if (stmt->options.keyset_size != (SQLLEN) vParam) changed = TRUE; } break; case SQL_MAX_LENGTH: /* ignored, but saved */ MYLOG(0, "SQL_MAX_LENGTH, vParam = " FORMAT_LEN "\n", vParam); if (conn) conn->stmtOptions.maxLength = vParam; if (stmt) { stmt->options_orig.maxLength = vParam; if (!SC_get_Result(stmt)) stmt->options.maxLength = vParam; if (stmt->options.maxLength != (SQLLEN) vParam) changed = TRUE; } break; case SQL_MAX_ROWS: /* ignored, but saved */ MYLOG(0, "SQL_MAX_ROWS, vParam = " FORMAT_LEN "\n", vParam); if (conn) conn->stmtOptions.maxRows = vParam; if (stmt) { stmt->options_orig.maxRows = vParam; if (!SC_get_Result(stmt)) stmt->options.maxRows = vParam; if (stmt->options.maxRows != (SQLLEN)vParam) changed = TRUE; } break; case SQL_NOSCAN: /* ignored */ MYLOG(0, "SQL_NOSCAN, vParam = " FORMAT_LEN "\n", vParam); break; case SQL_QUERY_TIMEOUT: /* ignored */ MYLOG(0, "SQL_QUERY_TIMEOUT, vParam = " FORMAT_LEN "\n", vParam); if (conn) conn->stmtOptions.stmt_timeout = (SQLULEN) vParam; if (stmt) stmt->options.stmt_timeout = (SQLULEN) vParam; break; case SQL_RETRIEVE_DATA: MYLOG(0, "SQL_RETRIEVE_DATA, vParam = " FORMAT_LEN "\n", vParam); if (conn) conn->stmtOptions.retrieve_data = (SQLUINTEGER) vParam; if (stmt) stmt->options.retrieve_data = (SQLUINTEGER) vParam; break; case SQL_ROWSET_SIZE: MYLOG(0, "SQL_ROWSET_SIZE, vParam = " FORMAT_LEN "\n", vParam); if (vParam < 1) { vParam = 1; changed = TRUE; } if (conn) conn->ardOptions.size_of_rowset_odbc2 = vParam; if (stmt) SC_get_ARDF(stmt)->size_of_rowset_odbc2 = vParam; break; case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */ if (stmt) { SC_set_error(stmt, STMT_NOT_IMPLEMENTED_ERROR, "Simulated positioned update/delete not supported. Use the cursor library.", func); } if (conn) { CC_set_error(conn, CONN_NOT_IMPLEMENTED_ERROR, "Simulated positioned update/delete not supported. Use the cursor library.", func); } return SQL_ERROR; case SQL_USE_BOOKMARKS: if (stmt) { MYLOG(0, "USE_BOOKMARKS %s\n", (vParam == SQL_UB_OFF) ? "off" : ((vParam == SQL_UB_VARIABLE) ? "variable" : "fixed")); setval = vParam; stmt->options.use_bookmarks = (SQLUINTEGER) setval; } if (conn) conn->stmtOptions.use_bookmarks = (SQLUINTEGER) vParam; break; case 1204: /* SQL_COPT_SS_PRESERVE_CURSORS ? */ if (stmt) { SC_set_error(stmt, STMT_OPTION_NOT_FOR_THE_DRIVER, "The option may be for MS SQL Server(Set)", func); } else if (conn) { CC_set_error(conn, CONN_OPTION_NOT_FOR_THE_DRIVER, "The option may be for MS SQL Server(Set)", func); } return SQL_ERROR; case 1227: /* SQL_SOPT_SS_HIDDEN_COLUMNS ? */ case 1228: /* SQL_SOPT_SS_NOBROWSETABLE ? */ if (stmt) { #ifndef NOT_USED if (0 != vParam) changed = TRUE; break; #else SC_set_error(stmt, STMT_OPTION_NOT_FOR_THE_DRIVER, "The option may be for MS SQL Server(Set)", func); #endif /* NOT_USED */ } else if (conn) { CC_set_error(conn, CONN_OPTION_NOT_FOR_THE_DRIVER, "The option may be for MS SQL Server(Set)", func); } return SQL_ERROR; default: { char option[64]; if (stmt) { SC_set_error(stmt, STMT_NOT_IMPLEMENTED_ERROR, "Unknown statement option (Set)", func); SPRINTF_FIXED(option, "fOption=%d, vParam=" FORMAT_ULEN, fOption, vParam); SC_log_error(func, option, stmt); } if (conn) { CC_set_error(conn, CONN_NOT_IMPLEMENTED_ERROR, "Unknown statement option (Set)", func); SPRINTF_FIXED(option, "fOption=%d, vParam=" FORMAT_ULEN, fOption, vParam); CC_log_error(func, option, conn); } return SQL_ERROR; } } if (changed) { if (stmt) { SC_set_error(stmt, STMT_OPTION_VALUE_CHANGED, "Requested value changed.", func); } if (conn) { CC_set_error(conn, CONN_OPTION_VALUE_CHANGED, "Requested value changed.", func); } return SQL_SUCCESS_WITH_INFO; } else return SQL_SUCCESS; } /* Implements only SQL_AUTOCOMMIT */ RETCODE SQL_API PGAPI_SetConnectOption(HDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam) { CSTR func = "PGAPI_SetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; char changed = FALSE; RETCODE retval; BOOL autocomm_on; MYLOG(0, "entering fOption = %d vParam = " FORMAT_LEN "\n", fOption, vParam); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } switch (fOption) { /* * Statement Options (apply to all stmts on the connection and * become defaults for new stmts) */ case SQL_ASYNC_ENABLE: case SQL_BIND_TYPE: case SQL_CONCURRENCY: case SQL_CURSOR_TYPE: case SQL_KEYSET_SIZE: case SQL_MAX_LENGTH: case SQL_MAX_ROWS: case SQL_NOSCAN: case SQL_QUERY_TIMEOUT: case SQL_RETRIEVE_DATA: case SQL_ROWSET_SIZE: case SQL_SIMULATE_CURSOR: case SQL_USE_BOOKMARKS: /* * Become the default for all future statements on this * connection */ retval = set_statement_option(conn, NULL, fOption, vParam); if (retval == SQL_SUCCESS_WITH_INFO) changed = TRUE; else if (retval == SQL_ERROR) return SQL_ERROR; break; /* * Connection Options */ case SQL_ACCESS_MODE: /* ignored */ break; case SQL_AUTOCOMMIT: switch (vParam) { case SQL_AUTOCOMMIT_ON: autocomm_on = TRUE; break; case SQL_AUTOCOMMIT_OFF: autocomm_on = FALSE; break; default: CC_set_error(conn, CONN_INVALID_ARGUMENT_NO, "Illegal parameter value for SQL_AUTOCOMMIT", func); return SQL_ERROR; } if (autocomm_on && SQL_AUTOCOMMIT_OFF != conn->autocommit_public) break; else if (!autocomm_on && SQL_AUTOCOMMIT_OFF == conn->autocommit_public) break; conn->autocommit_public = (autocomm_on ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); MYLOG(0, "AUTOCOMMIT: transact_status=%d, vparam=" FORMAT_LEN "\n", conn->transact_status, vParam); #ifdef _HANDLE_ENLIST_IN_DTC_ if (CC_is_in_global_trans(conn)) { CC_set_error(conn, CONN_ILLEGAL_TRANSACT_STATE, "Don't change AUTOCOMMIT mode in a distributed transaction", func); return SQL_ERROR; } #endif /* _HANDLE_ENLIST_IN_DTC_ */ CC_set_autocommit(conn, autocomm_on); break; case SQL_CURRENT_QUALIFIER: /* ignored */ break; case SQL_LOGIN_TIMEOUT: conn->login_timeout = (SQLUINTEGER) vParam; break; case SQL_PACKET_SIZE: /* ignored */ break; case SQL_QUIET_MODE: /* ignored */ break; case SQL_TXN_ISOLATION: if (conn->isolation == vParam) break; /* * If the connection is not established, just record the setting to * reflect it upon connection. */ if (CC_not_connected(conn)) { conn->isolation = (UInt4) vParam; break; } /* The ODBC spec prohibits changing the isolation level while in manual transaction. */ if (CC_is_in_trans(conn)) { if (CC_does_autocommit(conn) && !CC_is_in_error_trans(conn)) CC_commit(conn); else { CC_set_error(conn, CONN_TRANSACT_IN_PROGRES, "Cannot switch isolation level while a transaction is in progress", func); return SQL_ERROR; } } if (!CC_set_transact(conn, (UInt4) vParam)) return SQL_ERROR; conn->isolation = (UInt4) vParam; break; /* These options should be handled by driver manager */ case SQL_ODBC_CURSORS: case SQL_OPT_TRACE: case SQL_OPT_TRACEFILE: case SQL_TRANSLATE_DLL: case SQL_TRANSLATE_OPTION: CC_log_error(func, "This connect option (Set) is only used by the Driver Manager", conn); break; default: { char option[64]; CC_set_error(conn, CONN_UNSUPPORTED_OPTION, "Unknown connect option (Set)", func); SPRINTF_FIXED(option, "fOption=%d, vParam=" FORMAT_LEN, fOption, vParam); #ifdef WIN32 if (fOption == 30002 && vParam) { int cmp; #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) { char *asPara = ucs2_to_utf8((SQLWCHAR *) vParam, SQL_NTS, NULL, FALSE); cmp = strcmp(asPara, "Microsoft Jet"); free(asPara); } else #endif /* UNICODE_SUPPORT */ cmp = strncmp((char *) vParam, "Microsoft Jet", 13); if (0 == cmp) { MYLOG(0, "Microsoft Jet !!!!\n"); CC_set_errornumber(conn, 0); conn->ms_jet = 1; return SQL_SUCCESS; } } #endif /* WIN32 */ CC_log_error(func, option, conn); return SQL_ERROR; } } if (changed) { CC_set_error(conn, CONN_OPTION_VALUE_CHANGED, "Requested value changed.", func); return SQL_SUCCESS_WITH_INFO; } else return SQL_SUCCESS; } /* This function just can tell you whether you are in Autcommit mode or not */ RETCODE SQL_API PGAPI_GetConnectOption(HDBC hdbc, SQLUSMALLINT fOption, PTR pvParam, SQLINTEGER *StringLength, SQLINTEGER BufferLength) { CSTR func = "PGAPI_GetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; const char *p = NULL; SQLLEN len = sizeof(SQLINTEGER); SQLRETURN result = SQL_SUCCESS; MYLOG(0, "entering...\n"); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } switch (fOption) { case SQL_ACCESS_MODE: /* NOT SUPPORTED */ *((SQLUINTEGER *) pvParam) = SQL_MODE_READ_WRITE; break; case SQL_AUTOCOMMIT: *((SQLUINTEGER *) pvParam) = conn->autocommit_public; break; case SQL_CURRENT_QUALIFIER: /* don't use qualifiers */ len = 0; p = CurrCatString(conn); break; case SQL_LOGIN_TIMEOUT: *((SQLUINTEGER *) pvParam) = conn->login_timeout; break; case SQL_PACKET_SIZE: /* NOT SUPPORTED */ *((SQLUINTEGER *) pvParam) = 4096; break; case SQL_QUERY_TIMEOUT: *((SQLULEN *) pvParam) = conn->stmtOptions.stmt_timeout; break; case SQL_QUIET_MODE: /* NOT SUPPORTED */ *((SQLULEN *) pvParam) = 0; break; case SQL_TXN_ISOLATION: if (conn->isolation == 0) { if (CC_not_connected(conn)) return SQL_NO_DATA; conn->isolation = CC_get_isolation(conn); } *((SQLUINTEGER *) pvParam) = conn->isolation; break; #ifdef SQL_ATTR_CONNECTION_DEAD case SQL_ATTR_CONNECTION_DEAD: #else case 1209: #endif /* SQL_ATTR_CONNECTION_DEAD */ MYLOG(0, "CONNECTION_DEAD status=%d", conn->status); *((SQLUINTEGER *) pvParam) = CC_not_connected(conn); MYPRINTF(0, " val=" FORMAT_UINTEGER "\n", *((SQLUINTEGER *) pvParam)); break; case SQL_ATTR_ANSI_APP: *((SQLUINTEGER *) pvParam) = CC_is_in_ansi_app(conn); MYLOG(0, "ANSI_APP val=" FORMAT_UINTEGER "\n", *((SQLUINTEGER *) pvParam)); break; /* These options should be handled by driver manager */ case SQL_ODBC_CURSORS: case SQL_OPT_TRACE: case SQL_OPT_TRACEFILE: case SQL_TRANSLATE_DLL: case SQL_TRANSLATE_OPTION: CC_log_error(func, "This connect option (Get) is only used by the Driver Manager", conn); break; default: { char option[64]; CC_set_error(conn, CONN_UNSUPPORTED_OPTION, "Unknown connect option (Get)", func); SPRINTF_FIXED(option, "fOption=%d", fOption); CC_log_error(func, option, conn); return SQL_ERROR; break; } } if (NULL != p && 0 == len) { /* char/binary data */ len = strlen(p); if (pvParam) { #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) { len = utf8_to_ucs2(p, len, (SQLWCHAR *) pvParam , BufferLength / WCLEN); len *= WCLEN; } else #endif /* UNICODE_SUPPORT */ strncpy_null((char *) pvParam, p, (size_t) BufferLength); if (len >= BufferLength) { result = SQL_SUCCESS_WITH_INFO; CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the pvParam.", func); } } } if (StringLength) *StringLength = (SQLINTEGER) len; return result; } RETCODE SQL_API PGAPI_SetStmtOption(HSTMT hstmt, SQLUSMALLINT fOption, SQLULEN vParam) { CSTR func = "PGAPI_SetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; RETCODE retval; MYLOG(0, " entering...\n"); /* * Though we could fake Access out by just returning SQL_SUCCESS all * the time, but it tries to set a huge value for SQL_MAX_LENGTH and * expects the driver to reduce it to the real value. */ if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } /* StartRollbackState(stmt); */ retval = set_statement_option(NULL, stmt, fOption, vParam); return retval; } RETCODE SQL_API PGAPI_GetStmtOption(HSTMT hstmt, SQLUSMALLINT fOption, PTR pvParam, SQLINTEGER *StringLength, SQLINTEGER BufferLength) { CSTR func = "PGAPI_GetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; SQLLEN ridx; SQLINTEGER len = sizeof(SQLINTEGER); Int4 bookmark; MYLOG(0, "entering...\n"); /* * thought we could fake Access out by just returning SQL_SUCCESS all * the time, but it tries to set a huge value for SQL_MAX_LENGTH and * expects the driver to reduce it to the real value */ if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } switch (fOption) { case SQL_GET_BOOKMARK: case SQL_ROW_NUMBER: res = SC_get_Curres(stmt); if (!res) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "The cursor has no result.", func); return SQL_ERROR; } ridx = GIdx2CacheIdx(stmt->currTuple, stmt, res); if (!SC_is_fetchcursor(stmt)) { /* make sure we're positioned on a valid row */ if ((ridx < 0) || (((SQLULEN) ridx) >= QR_get_num_cached_tuples(res))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row.", func); return SQL_ERROR; } } else { if (stmt->currTuple < 0 || !res->tupleField) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row.", func); return SQL_ERROR; } } if (fOption == SQL_GET_BOOKMARK && stmt->options.use_bookmarks == SQL_UB_OFF) { SC_set_error(stmt, STMT_OPERATION_INVALID, "Operation invalid because use bookmarks not enabled.", func); return SQL_ERROR; } bookmark = SC_make_int4_bookmark(stmt->currTuple); memcpy(pvParam, &bookmark, sizeof(UInt4)); break; case SQL_ASYNC_ENABLE: /* NOT SUPPORTED */ *((SQLINTEGER *) pvParam) = SQL_ASYNC_ENABLE_OFF; break; case SQL_BIND_TYPE: *((SQLINTEGER *) pvParam) = SC_get_ARDF(stmt)->bind_size; break; case SQL_CONCURRENCY: /* NOT REALLY SUPPORTED */ MYLOG(0, "SQL_CONCURRENCY " FORMAT_INTEGER "\n", stmt->options.scroll_concurrency); *((SQLINTEGER *) pvParam) = stmt->options.scroll_concurrency; break; case SQL_CURSOR_TYPE: /* PARTIAL SUPPORT */ MYLOG(0, "SQL_CURSOR_TYPE " FORMAT_INTEGER "\n", stmt->options.cursor_type); *((SQLINTEGER *) pvParam) = stmt->options.cursor_type; break; case SQL_KEYSET_SIZE: /* NOT SUPPORTED, but saved */ MYLOG(0, "SQL_KEYSET_SIZE\n"); *((SQLLEN *) pvParam) = stmt->options.keyset_size; break; case SQL_MAX_LENGTH: /* NOT SUPPORTED, but saved */ *((SQLLEN *) pvParam) = stmt->options.maxLength; break; case SQL_MAX_ROWS: /* NOT SUPPORTED, but saved */ *((SQLLEN *) pvParam) = stmt->options.maxRows; MYLOG(0, "MAX_ROWS, returning " FORMAT_LEN "\n", stmt->options.maxRows); break; case SQL_NOSCAN: /* NOT SUPPORTED */ *((SQLINTEGER *) pvParam) = SQL_NOSCAN_ON; break; case SQL_QUERY_TIMEOUT: /* NOT SUPPORTED */ *((SQLULEN *) pvParam) = stmt->options.stmt_timeout; break; case SQL_RETRIEVE_DATA: *((SQLINTEGER *) pvParam) = stmt->options.retrieve_data; break; case SQL_ROWSET_SIZE: *((SQLLEN *) pvParam) = SC_get_ARDF(stmt)->size_of_rowset_odbc2; break; case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */ *((SQLINTEGER *) pvParam) = SQL_SC_NON_UNIQUE; break; case SQL_USE_BOOKMARKS: *((SQLINTEGER *) pvParam) = stmt->options.use_bookmarks; break; case 1227: /* SQL_SOPT_SS_HIDDEN_COLUMNS ? */ case 1228: /* SQL_SOPT_SS_NOBROWSETABLE ? */ *((SQLINTEGER *) pvParam) = 0; break; default: { char option[64]; SC_set_error(stmt, STMT_NOT_IMPLEMENTED_ERROR, "Unknown statement option (Get)", func); SPRINTF_FIXED(option, "fOption=%d", fOption); SC_log_error(func, option, stmt); return SQL_ERROR; } } if (StringLength) *StringLength = len; return SQL_SUCCESS; } psqlodbc-REL-16_00_0005/parse.c000066400000000000000000001472411462406103600157650ustar00rootroot00000000000000/*-------- * Module: parse.c * * Description: This module contains routines related to parsing SQL * statements. This can be useful for two reasons: * * 1. So the query does not actually have to be executed * to return data about it * * 2. To be able to return information about precision, * nullability, aliases, etc. in the functions * SQLDescribeCol and SQLColAttributes. Currently, * Postgres doesn't return any information about * these things in a query. * * Classes: none * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *-------- */ /* Multibyte support Eiji Tokuya 2001-03-15 */ #include "psqlodbc.h" #include #include #include #include "statement.h" #include "connection.h" #include "qresult.h" #include "pgtypes.h" #include "pgapifunc.h" #include "catfunc.h" #include "multibyte.h" #include "misc.h" #define FLD_INCR 32 #define TAB_INCR 8 #define COLI_INCR 16 #define COLI_RECYCLE 128 static const char *getNextToken(int ccsc, char escape_in_literal, const char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric); static void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k); static char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi); static BOOL getColumnsInfo(ConnectionClass *, TABLE_INFO *, OID, StatementClass *); Int4 FI_precision(const FIELD_INFO *fi) { OID ftype; if (!fi) return -1; ftype = FI_type(fi); switch (ftype) { case PG_TYPE_NUMERIC: return fi->column_size; case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: return fi->decimal_digits; } return 0; } Int4 FI_scale(const FIELD_INFO *fi) { OID ftype; if (!fi) return -1; ftype = FI_type(fi); switch (ftype) { case PG_TYPE_NUMERIC: return fi->decimal_digits; } return 0; } static const char * getNextToken( int ccsc, /* client encoding */ char escape_ch, const char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric) { size_t out = 0; size_t taglen; char in_quote, in_dollar_quote, in_escape; const UCHAR *tag, *tagend; encoded_str encstr; char escape_in_literal; const UCHAR *tstr = (const UCHAR *) s; UCHAR tchar, qc; if (smax <= 1) return NULL; smax--; /* skip leading delimiters */ while (isspace(*tstr) || *tstr == ',') { /* MYLOG(0, "skipping '%c'\n", *tstr); */ tstr++; } if (*tstr == '\0') { token[0] = '\0'; return NULL; } if (quote) *quote = FALSE; if (dquote) *dquote = FALSE; if (numeric) *numeric = FALSE; encoded_str_constr(&encstr, ccsc, (const char *) tstr); /* get the next token */ for (tchar = encoded_nextchar(&encstr); tchar && out < smax; tstr++, tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) { token[out++] = tchar; continue; } if (isspace(tchar) || tchar == ',') break; /* Handle quoted stuff */ in_quote = in_dollar_quote = FALSE; taglen = 0; tag = NULL; escape_in_literal = '\0'; if (out == 0) { qc = tchar; if (qc == DOLLAR_QUOTE) { in_quote = in_dollar_quote = TRUE; tag = tstr; taglen = 1; if (tagend = (const UCHAR *) strchr((const char *) tstr + 1, DOLLAR_QUOTE), NULL != tagend) taglen = tagend - tstr + 1; tstr += (taglen - 1); encoded_position_shift(&encstr, taglen - 1); if (quote) *quote = TRUE; } else if (qc == LITERAL_QUOTE) { in_quote = TRUE; if (quote) *quote = TRUE; escape_in_literal = escape_ch; if (!escape_in_literal) { if (LITERAL_EXT == tstr[-1]) escape_in_literal = ESCAPE_IN_LITERAL; } } else if (qc == IDENTIFIER_QUOTE) { in_quote = TRUE; if (dquote) *dquote = TRUE; } } /* out == 0 */ if (in_quote) /* dquote, dollar_quote */ { in_escape = FALSE; for (tstr++, tchar = encoded_nextchar(&encstr); tchar != '\0' && out != smax; tstr++, tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) { token[out++] = tchar; continue; } if (in_escape) in_escape = FALSE; else if (tchar == qc) { if (!in_dollar_quote) { /* * Peek at the next byte to see if this is a '' or * "", i.e a quote character that has been escaped * by doubling it. */ if (tstr[1] == qc) { tstr++; tchar = encoded_nextchar(&encstr); } else break; } else if (strncmp((const char *) tstr, (const char *) tag, taglen) == 0) { tstr += (taglen - 1); tchar = encoded_position_shift(&encstr, taglen - 1); break; } token[out++] = tchar; } else if (LITERAL_QUOTE == qc && tchar == escape_in_literal) { in_escape = TRUE; } else { token[out++] = tchar; } } /* for */ if (tchar == qc) tstr++; break; } /* in_quote */ /* Check for numeric literals */ if (out == 0 && isdigit(tchar)) { if (numeric) *numeric = TRUE; token[out++] = tchar; tstr++; while ((isalnum(*tstr) || *tstr == '.') && out < smax) { token[out++] = *tstr; tstr++; } break; } if (ispunct(tchar) && tchar != '_') { MYLOG(0, "got ispunct: s[] = '%c'\n", tchar); if (out == 0) { token[out++] = tchar; tstr++; } break; } if (out < smax) token[out++] = tchar; } /* for */ /* MYLOG(0, "done -- s[] = '%c'\n", *tstr); */ token[out] = '\0'; /* find the delimiter */ while (isspace(*tstr)) tstr++; /* return the most priority delimiter */ if (*tstr == ',') { if (delim) *delim = *tstr; } else if (*tstr == '\0') { if (delim) *delim = '\0'; } else { if (delim) *delim = ' '; } /* skip trailing blanks */ while (isspace(*tstr)) tstr++; return (const char *) tstr; } static void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) { char *str; MYLOG(DETAIL_LOG_LEVEL, "entering non-manual result\n"); fi->dquote = TRUE; STR_TO_NAME(fi->column_name, QR_get_value_backend_text(col_info->result, k, COLUMNS_COLUMN_NAME)); fi->columntype = (OID) QR_get_value_backend_int(col_info->result, k, COLUMNS_FIELD_TYPE, NULL); fi->column_size = QR_get_value_backend_int(col_info->result, k, COLUMNS_PRECISION, NULL); fi->length = QR_get_value_backend_int(col_info->result, k, COLUMNS_LENGTH, NULL); if (str = QR_get_value_backend_text(col_info->result, k, COLUMNS_SCALE), str) fi->decimal_digits = atoi(str); else fi->decimal_digits = -1; fi->nullable = QR_get_value_backend_int(col_info->result, k, COLUMNS_NULLABLE, NULL); fi->display_size = QR_get_value_backend_int(col_info->result, k, COLUMNS_DISPLAY_SIZE, NULL); fi->auto_increment = QR_get_value_backend_int(col_info->result, k, COLUMNS_AUTO_INCREMENT, NULL); } static char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) { int k, cmp, attnum, atttypmod; OID basetype; const char *col; MYLOG(DETAIL_LOG_LEVEL, "entering num_cols=" FORMAT_ULEN " col=%s\n", QR_get_num_cached_tuples(col_info->result), PRINT_NAME(fi->column_name)); if (fi->attnum < 0) return FALSE; for (k = 0; k < QR_get_num_cached_tuples(col_info->result); k++) { if (fi->attnum > 0) { attnum = QR_get_value_backend_int(col_info->result, k, COLUMNS_PHYSICAL_NUMBER, NULL); if (basetype = (OID) strtoul(QR_get_value_backend_text(col_info->result, k, COLUMNS_BASE_TYPEID), NULL, 10), 0 == basetype) basetype = (OID) strtoul(QR_get_value_backend_text(col_info->result, k, COLUMNS_FIELD_TYPE), NULL, 10); atttypmod = QR_get_value_backend_int(col_info->result, k, COLUMNS_ATTTYPMOD, NULL); MYLOG(DETAIL_LOG_LEVEL, "%d attnum=%d\n", k, attnum); if (attnum == fi->attnum && basetype == fi->basetype && atttypmod == fi->typmod) { getColInfo(col_info, fi, k); MYLOG(0, "PARSE: searchColInfo by attnum=%d\n", attnum); return TRUE; } } else if (NAME_IS_VALID(fi->column_name)) { col = QR_get_value_backend_text(col_info->result, k, COLUMNS_COLUMN_NAME); MYLOG(DETAIL_LOG_LEVEL, "%d col=%s\n", k, col); if (fi->dquote) cmp = strcmp(col, GET_NAME(fi->column_name)); else cmp = stricmp(col, GET_NAME(fi->column_name)); if (!cmp) { if (!fi->dquote) STR_TO_NAME(fi->column_name, col); getColInfo(col_info, fi, k); MYLOG(0, "PARSE: \n"); return TRUE; } } } return FALSE; } /* * lower the unquoted name */ static void lower_the_name(char *name, ConnectionClass *conn, BOOL dquote) { if (!dquote) { char *ptr; encoded_str encstr; make_encoded_str(&encstr, conn, name); /* lower case table name */ for (ptr = name; *ptr; ptr++) { encoded_nextchar(&encstr); if (!MBCS_NON_ASCII(encstr)) *ptr = tolower((UCHAR) *ptr); } } } /* * Check relhasoids(before PG12), relhssubclass and get some relevant information. */ BOOL CheckPgClassInfo(StatementClass *stmt) { const COL_INFO *coli; int table_info; TABLE_INFO *ti; BOOL hasoids = FALSE, hassubclass =FALSE, keyFound = FALSE; MYLOG(0, "Entering\n"); if (0 != SC_checked_hasoids(stmt)) return TRUE; if (!stmt->ti || !stmt->ti[0]) return FALSE; ti = stmt->ti[0]; MYLOG(DETAIL_LOG_LEVEL, "ti->col_info=%p\n", ti->col_info); if (TI_checked_hasoids(ti)) ; else if (coli = ti->col_info, NULL != coli) { table_info = coli->table_info; if (0 == (table_info & TBINFO_HASSUBCLASS)) { TI_set_has_no_subclass(ti); } else { hassubclass = TRUE; TI_set_hassubclass(ti); STR_TO_NAME(ti->bestitem, TABLEOID_NAME); STRX_TO_NAME(ti->bestqual, "\"" TABLEOID_NAME "\" = %u"); } if (!hassubclass) { if (0 == (table_info & TBINFO_HASOIDS)) { TI_set_has_no_oids(ti); } else { hasoids = TRUE; TI_set_hasoids(ti); STR_TO_NAME(ti->bestitem, OID_NAME); STRX_TO_NAME(ti->bestqual, "\"" OID_NAME "\" = %u"); } } ti->table_oid = coli->table_oid; if (!hasoids && !hassubclass) { QResultClass *res = coli->result; int num_tuples = res ? QR_get_num_cached_tuples(res) : -1; if (num_tuples > 0) { int i; for (i = 0; i < num_tuples; i++) { if (QR_get_value_backend_int(res, i, COLUMNS_AUTO_INCREMENT, NULL) != 0&& QR_get_value_backend_int(res, i, COLUMNS_FIELD_TYPE, NULL) == PG_TYPE_INT4) { char query[512]; STR_TO_NAME(ti->bestitem, QR_get_value_backend_text(res, i, COLUMNS_COLUMN_NAME)); SPRINTF_FIXED(query, "\"%s\" = %%d", SAFE_NAME(ti->bestitem)); STRX_TO_NAME(ti->bestqual, query); break; } } } } TI_set_hasoids_checked(ti); } else return FALSE; stmt->num_key_fields = PG_NUM_NORMAL_KEYS; if (TI_has_subclass(ti)) keyFound = FALSE; else if (TI_has_oids(ti)) keyFound = TRUE; else if (NAME_IS_NULL(ti->bestqual)) { keyFound = TRUE; stmt->num_key_fields--; } else keyFound = TRUE; MYLOG(DETAIL_LOG_LEVEL, "subclass=%d oids=%d bestqual=%s keyFound=%d num_key_fields=%d\n", TI_has_subclass(ti), TI_has_oids(ti), PRINT_NAME(ti->bestqual), keyFound, stmt->num_key_fields); SC_set_checked_hasoids(stmt, keyFound); return TRUE; } static BOOL increaseNtab(StatementClass *stmt, const char *func) { TABLE_INFO **ti = stmt->ti, *wti; if (!(stmt->ntab % TAB_INCR)) { SC_REALLOC_return_with_error(ti, TABLE_INFO *, (stmt->ntab + TAB_INCR) * sizeof(TABLE_INFO *), stmt, "PGAPI_AllocStmt failed in parse_statement for TABLE_INFO", FALSE); stmt->ti = ti; } wti = ti[stmt->ntab] = (TABLE_INFO *) malloc(sizeof(TABLE_INFO)); if (wti == NULL) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for TABLE_INFO(2).", func); return FALSE; } TI_Constructor(wti, SC_get_conn(stmt)); stmt->ntab++; return TRUE; } static void setNumFields(IRDFields *irdflds, size_t numFields) { FIELD_INFO **fi = irdflds->fi; size_t nfields = irdflds->nfields; if (numFields < nfields) { int i; for (i = (int) numFields; i < (int) nfields; i++) { if (fi[i]) fi[i]->flag = 0; } } irdflds->nfields = (UInt4) numFields; } void SC_initialize_cols_info(StatementClass *stmt, BOOL DCdestroy, BOOL parseReset) { IRDFields *irdflds = SC_get_IRDF(stmt); /* Free the parsed table information */ if (stmt->ti) { TI_Destructor(stmt->ti, stmt->ntab); free(stmt->ti); stmt->ti = NULL; } stmt->ntab = 0; if (DCdestroy) /* Free the parsed field information */ DC_Destructor((DescriptorClass *) SC_get_IRD(stmt)); else setNumFields(irdflds, 0); if (parseReset) { stmt->parse_status = STMT_PARSE_NONE; SC_reset_updatable(stmt); } } static BOOL allocateFields(IRDFields *irdflds, size_t sizeRequested) { FIELD_INFO **fi = irdflds->fi; size_t alloc_size, incr_size; if (sizeRequested <= irdflds->allocated) return TRUE; alloc_size = (0 != irdflds->allocated ? irdflds->allocated : FLD_INCR); for (; alloc_size < sizeRequested; alloc_size *= 2) ; incr_size = sizeof(FIELD_INFO *) * (alloc_size - irdflds->allocated); fi = (FIELD_INFO **) realloc(fi, alloc_size * sizeof(FIELD_INFO *)); if (!fi) { irdflds->fi = NULL; irdflds->allocated = irdflds->nfields = 0; return FALSE; } memset(&fi[irdflds->allocated], 0, incr_size); irdflds->fi = fi; irdflds->allocated = (SQLSMALLINT) alloc_size; return TRUE; } /* * This function may not be called but when it is called ... */ static void xxxxx(StatementClass *stmt, FIELD_INFO *fi, QResultClass *res, int i) { STR_TO_NAME(fi->column_alias, QR_get_fieldname(res, i)); fi->basetype = QR_get_field_type(res, i); if (0 == fi->columntype) fi->columntype = fi->basetype; if (fi->attnum < 0) { fi->nullable = FALSE; fi->updatable = FALSE; } else if (fi->attnum > 0) { int unknowns_as = 0; int type = pg_true_type(SC_get_conn(stmt), fi->columntype, fi->basetype); fi->nullable = TRUE; /* probably ? */ fi->column_size = pgtype_column_size(stmt, type, i, unknowns_as); fi->length = pgtype_buffer_length(stmt, type, i, unknowns_as); fi->decimal_digits = pgtype_decimal_digits(stmt, type, i); fi->display_size = pgtype_display_size(stmt, type, i, unknowns_as); } if (NAME_IS_NULL(fi->column_name)) { switch (fi->attnum) { case CTID_ATTNUM: STR_TO_NAME(fi->column_name, "ctid"); break; case OID_ATTNUM: STR_TO_NAME(fi->column_name, OID_NAME); break; case XMIN_ATTNUM: STR_TO_NAME(fi->column_name, XMIN_NAME); break; } } } /* * SQLColAttribute tries to set the FIELD_INFO (using protocol 3). */ static BOOL ColAttSet(StatementClass *stmt, TABLE_INFO *rti) { CSTR func = "ColAttSet"; QResultClass *res = SC_get_ExecdOrParsed(stmt); IRDFields *irdflds = SC_get_IRDF(stmt); COL_INFO *col_info = NULL; FIELD_INFO **fi, *wfi; OID reloid = 0; Int2 attid; int i, num_fields; BOOL fi_reuse, updatable, call_xxxxx; MYLOG(0, "entering\n"); if (reloid = rti->table_oid, 0 == reloid) return FALSE; if (0 != (rti->flags & TI_COLATTRIBUTE)) return TRUE; col_info = rti->col_info; if (!QR_command_maybe_successful(res)) return FALSE; if (num_fields = QR_NumPublicResultCols(res), num_fields <= 0) return FALSE; fi = irdflds->fi; if (num_fields > (int) irdflds->allocated) { if (!allocateFields(irdflds, num_fields)) return FALSE; fi = irdflds->fi; } setNumFields(irdflds, num_fields); updatable = TI_is_updatable(rti); MYLOG(0, "updatable=%d tab=%d fields=%d", updatable, stmt->ntab, num_fields); if (updatable) { if (1 > stmt->ntab) updatable = FALSE; } MYPRINTF(0, "->%d\n", updatable); for (i = 0; i < num_fields; i++) { if (reloid == (OID) QR_get_relid(res, i)) { if (wfi = fi[i], NULL == wfi) { wfi = (FIELD_INFO *) malloc(sizeof(FIELD_INFO)); if (wfi == NULL) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for field info.", func); return FALSE; } fi_reuse = FALSE; fi[i] = wfi; } else if (FI_is_applicable(wfi)) continue; else fi_reuse = TRUE; FI_Constructor(wfi, fi_reuse); attid = (Int2) QR_get_attid(res, i); wfi->attnum = attid; wfi->basetype = QR_get_field_type(res, i); wfi->typmod = QR_get_atttypmod(res, i); call_xxxxx = TRUE; if (searchColInfo(col_info, wfi)) { STR_TO_NAME(wfi->column_alias, QR_get_fieldname(res, i)); wfi->basetype = QR_get_field_type(res, i); wfi->updatable = updatable; call_xxxxx = FALSE; } else { if (attid > 0) { if (getColumnsInfo(NULL, rti, reloid, stmt) && searchColInfo(col_info, wfi)) { STR_TO_NAME(wfi->column_alias, QR_get_fieldname(res, i)); wfi->basetype = QR_get_field_type(res, i); wfi->updatable = updatable; call_xxxxx= FALSE; } } } if (call_xxxxx) xxxxx(stmt, wfi, res, i); wfi->ti = rti; wfi->flag |= FIELD_COL_ATTRIBUTE; } } if (stmt->updatable < 0) { if (stmt->ntab > 1) updatable = FALSE; SC_set_updatable(stmt, updatable); } rti->flags |= TI_COLATTRIBUTE; return TRUE; } static BOOL getCOLIfromTable(ConnectionClass *conn, pgNAME *schema_name, pgNAME table_name, COL_INFO **coli) { int colidx; BOOL found = FALSE; *coli = NULL; if (NAME_IS_NULL(table_name)) return TRUE; if (NAME_IS_NULL(*schema_name)) { const char *curschema = CC_get_current_schema(conn); /* * Though current_schema() doesn't have * much sense in PostgreSQL, we first * check the current_schema() when no * explicit schema name is specified. */ if (curschema) { for (colidx = 0; colidx < conn->ntables; colidx++) { if (!NAMEICMP(conn->col_info[colidx]->table_name, table_name) && !stricmp(SAFE_NAME(conn->col_info[colidx]->schema_name), curschema)) { MYLOG(0, "FOUND col_info table='%s' current schema='%s'\n", PRINT_NAME(table_name), curschema); found = TRUE; STR_TO_NAME(*schema_name, curschema); break; } } } if (!found) { QResultClass *res; char token[256], relcnv[128]; BOOL tblFound = FALSE; /* * We also have to check as follows. */ SPRINTF_FIXED(token, "select nspname from pg_namespace n, pg_class c" " where c.relnamespace=n.oid and c.oid='%s'::regclass", identifierEscape((const SQLCHAR *) SAFE_NAME(table_name), SQL_NTS, conn, relcnv, sizeof(relcnv), TRUE)); res = CC_send_query(conn, token, NULL, READ_ONLY_QUERY, NULL); if (QR_command_maybe_successful(res)) { if (QR_get_num_total_tuples(res) == 1) { tblFound = TRUE; STR_TO_NAME(*schema_name, QR_get_value_backend_text(res, 0, 0)); } } QR_Destructor(res); if (!tblFound) return FALSE; } } if (!found && NAME_IS_VALID(*schema_name)) { for (colidx = 0; colidx < conn->ntables; colidx++) { if (!NAMEICMP(conn->col_info[colidx]->table_name, table_name) && !NAMEICMP(conn->col_info[colidx]->schema_name, *schema_name)) { MYLOG(0, "FOUND col_info table='%s' schema='%s'\n", PRINT_NAME(table_name), PRINT_NAME(*schema_name)); found = TRUE; break; } } } *coli = found ? conn->col_info[colidx] : NULL; return TRUE; /* success */ } static BOOL getColumnsInfo(ConnectionClass *conn, TABLE_INFO *wti, OID greloid, StatementClass *stmt) { BOOL found = FALSE; RETCODE result; HSTMT hcol_stmt = NULL; StatementClass *col_stmt; QResultClass *res; MYLOG(0, "entering Getting PG_Columns for table %u(%s)\n", greloid, PRINT_NAME(wti->table_name)); if (NULL == conn) conn = SC_get_conn(stmt); result = PGAPI_AllocStmt(conn, &hcol_stmt, 0); if (!SQL_SUCCEEDED(result)) { if (stmt) SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for columns.", __FUNCTION__); goto cleanup; } col_stmt = (StatementClass *) hcol_stmt; if (greloid) result = PGAPI_Columns(hcol_stmt, NULL, 0, NULL, 0, NULL, 0, NULL, 0, PODBC_SEARCH_BY_IDS, greloid, 0); else result = PGAPI_Columns(hcol_stmt, NULL, 0, (SQLCHAR *) SAFE_NAME(wti->schema_name), SQL_NTS, (SQLCHAR *) SAFE_NAME(wti->table_name), SQL_NTS, NULL, 0, PODBC_NOT_SEARCH_PATTERN, 0, 0); MYLOG(0, " Past PG_Columns\n"); res = SC_get_ExecdOrParsed(col_stmt); if (SQL_SUCCEEDED(result) && res != NULL && QR_get_num_cached_tuples(res) > 0) { BOOL coli_exist = FALSE; COL_INFO *coli = NULL, *ccoli = NULL, *tcoli; int k; time_t acctime = 0; MYLOG(0, " Success\n"); if (greloid != 0) { /* We have reloid. Try to find appropriate coli object from connection COL_INFO cache. */ for (k = 0; k < conn->ntables; k++) { tcoli = conn->col_info[k]; if (tcoli->table_oid == greloid) { /* We found appropriate coli object, so we will use it. */ coli = tcoli; coli_exist = TRUE; break; } } } if (!coli_exist) { /* Not found, try to find unused coli or oldest (if overflow) in connection COL_INFO cache. */ for (k = 0; k < conn->ntables; k++) { tcoli = conn->col_info[k]; if (1 < tcoli->refcnt) continue; /* This coli object is used somewhere else, skipping it. */ if ((0 == tcoli->table_oid && NAME_IS_NULL(tcoli->table_name)) || strnicmp(SAFE_NAME(tcoli->schema_name), "pg_temp_", 8) == 0) { /* Found unused coli object, taking it. */ coli = tcoli; coli_exist = TRUE; break; } if (NULL == ccoli || tcoli->acc_time < acctime) { /* Not yet found. Alongside, searching least recently used coli object. */ ccoli = tcoli; acctime = tcoli->acc_time; } } if (!coli_exist && NULL != ccoli && conn->ntables >= COLI_RECYCLE) { /* Not found unsed object. Amount of them is on limit. Taking least recently used coli object. */ coli_exist = TRUE; coli = ccoli; } } if (coli_exist) { /* We have ready to use coli object. Cleaning it. */ free_col_info_contents(coli); } else { /* We have no coli object. Must create a new one. */ if (conn->ntables >= conn->coli_allocated) { /* No place in connection COL_INFO cache table. Allocating or reallocating. */ Int2 new_alloc; COL_INFO **col_info; new_alloc = conn->coli_allocated * 2; if (new_alloc <= conn->ntables) new_alloc = COLI_INCR; MYLOG(0, "PARSE: Allocating col_info at ntables=%d\n", conn->ntables); col_info = (COL_INFO **) realloc(conn->col_info, new_alloc * sizeof(COL_INFO *)); if (!col_info) { if (stmt) SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for col_info.", __FUNCTION__); goto cleanup; } conn->col_info = col_info; conn->coli_allocated = new_alloc; } /* Allocating new COL_INFO object. */ MYLOG(0, "PARSE: malloc at conn->col_info[%d]\n", conn->ntables); coli = conn->col_info[conn->ntables] = (COL_INFO *) malloc(sizeof(COL_INFO)); } if (!coli) { if (stmt) SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for col_info(2).", __FUNCTION__); goto cleanup; } col_info_initialize(coli); coli->refcnt++; /* Counting one reference to coli object from connection COL_INFO cache table. */ coli->result = res; if (res && QR_get_num_cached_tuples(res) > 0) { int num_tuples = QR_get_num_cached_tuples(res); int i; if (!greloid) greloid = (OID) strtoul(QR_get_value_backend_text(res, 0, COLUMNS_TABLE_OID), NULL, 10); if (!wti->table_oid) wti->table_oid = greloid; if (NAME_IS_NULL(wti->schema_name)) STR_TO_NAME(wti->schema_name, QR_get_value_backend_text(res, 0, COLUMNS_SCHEMA_NAME)); if (NAME_IS_NULL(wti->table_name)) STR_TO_NAME(wti->table_name, QR_get_value_backend_text(res, 0, COLUMNS_TABLE_NAME)); for (i = 0; i < num_tuples; i++) { if (NULL != QR_get_value_backend_text(res, 0, COLUMNS_TABLE_INFO)) { coli->table_info = QR_get_value_backend_int(res, 0, COLUMNS_TABLE_INFO, NULL); break; } } } MYLOG(DETAIL_LOG_LEVEL, "#2 %p->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); /* * Store the table name and the SQLColumns result * structure */ if (NAME_IS_VALID(wti->schema_name)) { NAME_TO_NAME(coli->schema_name, wti->schema_name); } else NULL_THE_NAME(coli->schema_name); NAME_TO_NAME(coli->table_name, wti->table_name); coli->table_oid = wti->table_oid; /* * The connection will now free the result structures, so * make sure that the statement doesn't free it */ SC_init_Result(col_stmt); if (!coli_exist) conn->ntables++; if (res && QR_get_num_cached_tuples(res) > 0) MYLOG(DETAIL_LOG_LEVEL, "oid item == %s\n", (const char *) QR_get_value_backend_text(res, 0, 3)); MYLOG(0, "Created col_info table='%s', ntables=%d\n", PRINT_NAME(wti->table_name), conn->ntables); /* Associate a table from the statement with a SQLColumn info */ found = TRUE; coli->refcnt++; /* Counting another one reference to coli object from TABLE_INFO wti object. */ wti->col_info = coli; } cleanup: if (hcol_stmt) PGAPI_FreeStmt(hcol_stmt, SQL_DROP); return found; } BOOL getCOLIfromTI(const char *func, ConnectionClass *conn, StatementClass *stmt, const OID reloid, TABLE_INFO **pti) { BOOL colatt = FALSE, found = FALSE; OID greloid = reloid; TABLE_INFO *wti = *pti; COL_INFO *coli; MYLOG(DETAIL_LOG_LEVEL, "entering reloid=%u ti=%p\n", reloid, wti); if (!conn) conn = SC_get_conn(stmt); if (!wti) /* SQLColAttribute case */ { int i; if (0 == greloid) return FALSE; if (!stmt) return FALSE; colatt = TRUE; for (i = 0; i < stmt->ntab; i++) { if (stmt->ti[i]->table_oid == greloid) { wti = stmt->ti[i]; break; } } if (!wti) { MYLOG(DETAIL_LOG_LEVEL, "before increaseNtab\n"); if (!increaseNtab(stmt, func)) return FALSE; wti = stmt->ti[stmt->ntab - 1]; wti->table_oid = greloid; } *pti = wti; } MYLOG(DETAIL_LOG_LEVEL, "fi=%p greloid=%d col_info=%p\n", wti, greloid, wti->col_info); if (0 == greloid) greloid = wti->table_oid; if (NULL != wti->col_info) { found = TRUE; goto cleanup; } if (greloid != 0) { int colidx; for (colidx = 0; colidx < conn->ntables; colidx++) { if (conn->col_info[colidx]->table_oid == greloid) { MYLOG(0, "FOUND col_info table=%ul\n", greloid); found = TRUE; wti->col_info = conn->col_info[colidx]; wti->col_info->refcnt++; break; } } } else { if (!getCOLIfromTable(conn, &wti->schema_name, wti->table_name, &coli)) { if (stmt) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); SC_set_error(stmt, STMT_EXEC_ERROR, "Table not found", func); SC_reset_updatable(stmt); } return FALSE; } else if (NULL != coli) { found = TRUE; coli->refcnt++; wti->col_info = coli; } } if (found) goto cleanup; else if (0 != greloid || NAME_IS_VALID(wti->table_name)) found = getColumnsInfo(conn, wti, greloid, stmt); cleanup: if (found) { QResultClass *res = wti->col_info->result; if (res && QR_get_num_cached_tuples(res) > 0) { if (!greloid) greloid = (OID) strtoul(QR_get_value_backend_text(res, 0, COLUMNS_TABLE_OID), NULL, 10); if (!wti->table_oid) wti->table_oid = greloid; if (NAME_IS_NULL(wti->schema_name)) STR_TO_NAME(wti->schema_name, QR_get_value_backend_text(res, 0, COLUMNS_SCHEMA_NAME)); if (NAME_IS_NULL(wti->table_name)) STR_TO_NAME(wti->table_name, QR_get_value_backend_text(res, 0, COLUMNS_TABLE_NAME)); } MYLOG(DETAIL_LOG_LEVEL, "#1 %p->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); if (colatt /* SQLColAttribute case */ && 0 == (wti->flags & TI_COLATTRIBUTE)) { if (stmt) ColAttSet(stmt, wti); } wti->col_info->acc_time = SC_get_time(stmt); } else if (!colatt && stmt) SC_set_parse_status(stmt, STMT_PARSE_FATAL); MYLOG(DETAIL_LOG_LEVEL, "leaving returns %d\n", found); return found; } SQLRETURN SC_set_SS_columnkey(StatementClass *stmt) { IRDFields *irdflds = SC_get_IRDF(stmt); FIELD_INFO **fi = irdflds->fi, *tfi; size_t nfields = irdflds->nfields; HSTMT pstmt = NULL; SQLRETURN ret = SQL_SUCCESS; BOOL contains_key = FALSE; int i; MYLOG(DETAIL_LOG_LEVEL, "entering fields=" FORMAT_SIZE_T " ntab=%d\n", nfields, stmt->ntab); if (!fi) return ret; if (0 >= nfields) return ret; for (i = 0; i < stmt->ntab; i++) { TABLE_INFO **ti = stmt->ti, *oneti; ConnectionClass *conn = SC_get_conn(stmt); OID internal_asis_type = SQL_C_CHAR; char keycolnam[MAX_INFO_STRING]; SQLLEN keycollen; ret = PGAPI_AllocStmt(conn, &pstmt, 0); if (!SQL_SUCCEEDED(ret)) return ret; oneti = ti[i]; ret = PGAPI_PrimaryKeys(pstmt, NULL, 0, NULL, 0, NULL, 0, oneti->table_oid); if (!SQL_SUCCEEDED(ret)) goto cleanup; #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) internal_asis_type = INTERNAL_ASIS_TYPE; #endif /* UNICODE_SUPPORT */ ret = PGAPI_BindCol(pstmt, 4, internal_asis_type, keycolnam, MAX_INFO_STRING, &keycollen); if (!SQL_SUCCEEDED(ret)) goto cleanup; contains_key = TRUE; ret = PGAPI_Fetch(pstmt); while (SQL_SUCCEEDED(ret)) { int i; // different from i of outer loop for (i = 0; i < nfields; i++) { if (tfi = fi[i], NULL == tfi) continue; if (!FI_is_applicable(tfi)) continue; if (oneti == tfi->ti && strcmp(keycolnam, SAFE_NAME(tfi->column_name)) == 0) { MYLOG(DETAIL_LOG_LEVEL, "key %s found at %p\n", keycolnam, fi + i); tfi->columnkey = TRUE; break; } } if (i >= nfields) { MYLOG(0, "%s not found\n", keycolnam); break; } ret = PGAPI_Fetch(pstmt); } if (SQL_SUCCEEDED(ret)) contains_key = FALSE; else if (SQL_NO_DATA_FOUND != ret) goto cleanup; ret = SQL_SUCCESS; } MYLOG(DETAIL_LOG_LEVEL, "contains_key=%d\n", contains_key); for (i = 0; i < nfields; i++) { if (tfi = fi[i], NULL == tfi) continue; if (!FI_is_applicable(tfi)) continue; if (!contains_key || tfi->columnkey < 0) tfi->columnkey = FALSE; } cleanup: if (pstmt) PGAPI_FreeStmt(pstmt, SQL_DROP); return ret; } static BOOL include_alias_wo_as(const char *token, const char *btoken) { MYLOG(0, "alias ? token=%s btoken=%s\n", token, btoken); if ('\0' == btoken[0]) return FALSE; else if (0 == stricmp(")", token)) return FALSE; else if (0 == stricmp("as", btoken) || 0 == stricmp("and", btoken) || 0 == stricmp("or", btoken) || 0 == stricmp("not", btoken) || 0 == stricmp(",", btoken)) return FALSE; else { CSTR ops = "+-*/%^|!@&#~<>=."; const char *cptr, *optr; for (cptr = btoken; *cptr; cptr++) { for (optr = ops; *optr; optr++) { if (*optr != *cptr) return TRUE; } } } return FALSE; } static char *insert_as_to_the_statement(char *stmt, const char **pptr, const char **ptr) { size_t stsize = strlen(stmt), ppos = *pptr - stmt, remsize = stsize - ppos; const int ins_size = 3; char *newstmt = realloc(stmt, stsize + ins_size + 1); if (newstmt) { char *sptr = newstmt + ppos; memmove(sptr + ins_size, sptr, remsize + 1); sptr[0] = 'a'; sptr[1] = 's'; sptr[2] = ' '; *ptr = sptr + (*ptr - *pptr) + ins_size; *pptr = sptr + ins_size; } return newstmt; } #define TOKEN_SIZE 256 static char parse_the_statement(StatementClass *stmt, BOOL check_hasoids, BOOL sqlsvr_check) { CSTR func = "parse_the_statement"; char delimdsp[2], token[TOKEN_SIZE], stoken[TOKEN_SIZE], btoken[TOKEN_SIZE]; char delim, quote, dquote, numeric, unquoted; const char *ptr; const char *pptr = NULL; char in_select = FALSE, in_distinct = FALSE, in_on = FALSE, in_from = FALSE, in_where = FALSE, in_table = FALSE, out_table = TRUE; char in_field = FALSE, in_expr = FALSE, in_func = FALSE, in_dot = FALSE, in_as = FALSE; int j, i, k = 0, n, blevel = 0, old_blevel, subqlevel = 0, tbl_blevel = 0, allocated_size = -1, new_size, nfields; FIELD_INFO **fi, *wfi; TABLE_INFO **ti, *wti; char parse = FALSE; po_ind_t join_info = STMT_HAS_NO_JOIN; ConnectionClass *conn = SC_get_conn(stmt); IRDFields *irdflds; BOOL updatable = TRUE, column_has_alias = FALSE, fupdatable; MYLOG(0, "entering...\n"); if (SC_parsed_status(stmt) != STMT_PARSE_NONE) { if (check_hasoids) CheckPgClassInfo(stmt); return TRUE; } nfields = 0; wfi = NULL; wti = NULL; ptr = stmt->statement; if (sqlsvr_check) { irdflds = NULL; fi = NULL; ti = NULL; } else { SC_set_updatable(stmt, FALSE); irdflds = SC_get_IRDF(stmt); fi = irdflds->fi; ti = stmt->ti; allocated_size = irdflds->allocated; SC_initialize_cols_info(stmt, FALSE, TRUE); stmt->from_pos = -1; stmt->where_pos = -1; } #define return DONT_CALL_RETURN_FROM_HERE??? delim = '\0'; token[0] = '\0'; while (pptr = (const char *) ptr, (delim != ',') ? STRCPY_FIXED(btoken, token) : (btoken[0] = '\0', 0), (ptr = getNextToken(conn->ccsc, CC_get_escape(conn), pptr, token, sizeof(token), &delim, "e, &dquote, &numeric)) != NULL) { unquoted = !(quote || dquote); if (delim) { delimdsp[0] = delim; delimdsp[1] = '\0'; } else delimdsp[0] = '\0'; MYLOG(0, "unquoted=%d, quote=%d, dquote=%d, numeric=%d, delim='%s', token='%s', ptr='%s'\n", unquoted, quote, dquote, numeric, delimdsp, token, ptr); old_blevel = blevel; if (unquoted && blevel == 0) { if (in_select) { if (!stricmp(token, "distinct")) { in_distinct = TRUE; updatable = FALSE; MYLOG(0, "DISTINCT\n"); continue; } else if (!stricmp(token, "into")) { in_select = FALSE; MYLOG(0, "INTO\n"); stmt->statement_type = STMT_TYPE_CREATE; SC_set_parse_status(stmt, STMT_PARSE_FATAL); goto cleanup; } else if (!stricmp(token, "from")) { if (sqlsvr_check) { parse = TRUE; goto cleanup; } in_select = FALSE; in_from = TRUE; if (stmt->from_pos < 0 && (!strnicmp(pptr, "from", 4))) { MYLOG(0, "First From\n"); stmt->from_pos = pptr - stmt->statement; } else MYLOG(0, "FROM\n"); continue; } } /* in_select && unquoted && blevel == 0 */ else if ((!stricmp(token, "where") || !stricmp(token, "union") || !stricmp(token, "intersect") || !stricmp(token, "except") || !stricmp(token, "order") || !stricmp(token, "group") || !stricmp(token, "having"))) { in_from = FALSE; in_where = TRUE; if (stmt->where_pos < 0) stmt->where_pos = pptr - stmt->statement; MYLOG(0, "%s...\n", token); if (stricmp(token, "where") && stricmp(token, "order")) { updatable = FALSE; break; } continue; } } /* unquoted && blevel == 0 */ /* check the change of blevel etc */ if (unquoted) { if (!stricmp(token, "select")) { stoken[0] = '\0'; if (0 == blevel) { in_select = TRUE; MYLOG(0, "SELECT\n"); continue; } else { MYLOG(0, "SUBSELECT\n"); if (0 == subqlevel) subqlevel = blevel; } } else if (token[0] == '(') { blevel++; MYLOG(0, "blevel++ -> %d\n", blevel); /* aggregate function ? */ if (stoken[0] && updatable && 0 == subqlevel) { if (stricmp(stoken, "count") == 0 || stricmp(stoken, "sum") == 0 || stricmp(stoken, "avg") == 0 || stricmp(stoken, "max") == 0 || stricmp(stoken, "min") == 0 || stricmp(stoken, "variance") == 0 || stricmp(stoken, "stddev") == 0) updatable = FALSE; } } else if (token[0] == ')') { blevel--; MYLOG(0, "blevel-- = %d\n", blevel); if (blevel < subqlevel) subqlevel = 0; } if (blevel >= old_blevel && ',' != delim) STRCPY_FIXED(stoken, token); else stoken[0] = '\0'; } if (in_select) { MYLOG(0, "blevel=%d btoken=%s in_dot=%d in_field=%d tbname=%s\n", blevel, btoken, in_dot, in_field, wfi ? SAFE_NAME(wfi->column_alias) : ""); if (0 == blevel && sqlsvr_check && dquote && '\0' != btoken[0] && !in_dot && in_field && (!column_has_alias)) { if (include_alias_wo_as(token, btoken)) { char *news; column_has_alias = TRUE; if (NULL != wfi) STRX_TO_NAME(wfi->column_alias, token); news = insert_as_to_the_statement(stmt->statement, &pptr, &ptr); if (news != stmt->statement) { free(stmt->statement); stmt->statement = news; } } } if (in_expr || in_func) { /* just eat the expression */ MYLOG(0, "in_expr=%d or func=%d\n", in_expr, in_func); if (blevel == 0) { if (delim == ',') { MYLOG(0, "**** Got comma in_expr/func\n"); in_func = FALSE; in_expr = FALSE; in_field = FALSE; } else if (unquoted && !stricmp(token, "as")) { MYLOG(0, "got AS in_expr\n"); in_func = FALSE; in_expr = FALSE; in_as = TRUE; in_field = TRUE; } } continue; } /* (in_expr || in_func) && in_select */ if (in_distinct) { MYLOG(0, "in distinct\n"); if (unquoted && !stricmp(token, "on")) { in_on = TRUE; MYLOG(0, "got on\n"); continue; } if (in_on) { in_distinct = FALSE; in_on = FALSE; continue; /* just skip the unique on field */ } MYLOG(0, "done distinct\n"); in_distinct = FALSE; } /* in_distinct */ if (!in_field) { BOOL fi_reuse = FALSE; if (!token[0]) continue; column_has_alias = FALSE; if (!sqlsvr_check) { /* if (!(irdflds->nfields % FLD_INCR)) */ if (irdflds->nfields >= allocated_size) { MYLOG(0, "reallocing at nfld=%d\n", irdflds->nfields); new_size = irdflds->nfields + 1; if (!allocateFields(irdflds, new_size)) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for FIELD_INFO.", func); goto cleanup; } fi = irdflds->fi; allocated_size = irdflds->allocated; } wfi = fi[irdflds->nfields]; if (NULL != wfi) fi_reuse = TRUE; else wfi = fi[irdflds->nfields] = (FIELD_INFO *) malloc(sizeof(FIELD_INFO)); if (NULL == wfi) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in parse_statement for FIELD_INFO(2).", func); goto cleanup; } /* Initialize the field info */ FI_Constructor(wfi, fi_reuse); wfi->flag = FIELD_PARSING; } /* double quotes are for qualifiers */ if (dquote && NULL != wfi) wfi->dquote = TRUE; if (quote) { if (NULL != wfi) { wfi->quote = TRUE; wfi->column_size = (int) strlen(token); } } else if (numeric) { MYLOG(0, "**** got numeric: nfld = %d\n", nfields); if (NULL != wfi) wfi->numeric = TRUE; } else if (0 == old_blevel && blevel > 0) { /* expression */ MYLOG(0, "got EXPRESSION\n"); if (NULL != wfi) wfi->expr = TRUE; in_expr = TRUE; /* continue; */ } else if (NULL != wfi) { STRX_TO_NAME(wfi->column_name, token); NULL_THE_NAME(wfi->before_dot); } if (NULL != wfi) MYLOG(0, "got field='%s', dot='%s'\n", PRINT_NAME(wfi->column_name), PRINT_NAME(wfi->before_dot)); if (delim == ',') MYLOG(0, "comma (1)\n"); else in_field = TRUE; nfields++; if (NULL != irdflds) irdflds->nfields++; continue; } /* !in_field */ /* * We are in a field now */ if (!sqlsvr_check) wfi = fi[irdflds->nfields - 1]; if (in_dot) { if (NULL != wfi) { if (NAME_IS_VALID(wfi->before_dot)) { MOVE_NAME(wfi->schema_name, wfi->before_dot); } MOVE_NAME(wfi->before_dot, wfi->column_name); STRX_TO_NAME(wfi->column_name, token); } if (delim == ',') { MYLOG(0, "in_dot: got comma\n"); in_field = FALSE; } in_dot = FALSE; continue; } if (in_as) { column_has_alias = TRUE; if (NULL != wfi) { STRX_TO_NAME(wfi->column_alias, token); MYLOG(0, "alias for field '%s' is '%s'\n", PRINT_NAME(wfi->column_name), PRINT_NAME(wfi->column_alias)); } in_as = FALSE; in_field = FALSE; if (delim == ',') MYLOG(0, "comma(2)\n"); continue; } /* Function */ if (0 == old_blevel && blevel > 0) { in_dot = FALSE; in_func = TRUE; if (NULL != wfi) { wfi->func = TRUE; /* * name will have the function name -- maybe useful some * day */ MYLOG(0, "**** got function = '%s'\n", PRINT_NAME(wfi->column_name)); } continue; } if (token[0] == '.') { in_dot = TRUE; MYLOG(0, "got dot\n"); continue; } in_dot = FALSE; if (!stricmp(token, "as")) { in_as = TRUE; MYLOG(0, "got AS\n"); continue; } /* otherwise, it's probably an expression */ if (!column_has_alias) { in_expr = TRUE; if (NULL != wfi) { wfi->expr = TRUE; NULL_THE_NAME(wfi->column_name); wfi->column_size = 0; } MYLOG(0, "*** setting expression\n"); } else MYLOG(0, "*** may be an alias for a field\n"); if (0 == blevel && ',' == delim) { in_expr = in_func = in_field = FALSE; } } /* in_select end */ if (in_from || in_where) { if (token[0] == ';') /* end of the first command */ { in_select = in_from = in_where = in_table = FALSE; break; } } if (in_from) { switch (token[0]) { case '\0': continue; case ',': out_table = TRUE; continue; } if (out_table && !in_table) /* new table */ { BOOL is_table_name, is_subquery; in_dot = FALSE; join_info = STMT_HAS_NO_JOIN; if (!dquote) { if (token[0] == '(' || token[0] == ')') continue; } if (sqlsvr_check) wti = NULL; else { if (!increaseNtab(stmt, func)) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); goto cleanup; } ti = stmt->ti; wti = ti[stmt->ntab - 1]; } is_table_name = TRUE; is_subquery = FALSE; if (dquote) ; else if (0 == stricmp(token, "select")) { MYLOG(0, "got subquery lvl=%d\n", blevel); is_table_name = FALSE; is_subquery = TRUE; } else if ('(' == ptr[0]) { MYLOG(0, "got srf? = '%s'\n", token); is_table_name = FALSE; } if (NULL != wti) { if (is_table_name) { STRX_TO_NAME(wti->table_name, token); lower_the_name(GET_NAME(wti->table_name), conn, dquote); MYLOG(0, "got table = '%s'\n", PRINT_NAME(wti->table_name)); } else { NULL_THE_NAME(wti->table_name); TI_no_updatable(wti); } } if (0 == blevel && delim == ',') { out_table = TRUE; MYLOG(0, "more than 1 tables\n"); } else { out_table = FALSE; in_table = TRUE; if (is_subquery) tbl_blevel = blevel - 1; else tbl_blevel = blevel; } continue; } if (blevel > tbl_blevel) continue; /* out_table is FALSE here */ if (!dquote && !in_dot) { if (')' == token[0]) continue; if (stricmp(token, "LEFT") == 0 || stricmp(token, "RIGHT") == 0 || stricmp(token, "OUTER") == 0 || stricmp(token, "FULL") == 0) { join_info = STMT_HAS_OUTER_JOIN; in_table = FALSE; continue; } else if (stricmp(token, "INNER") == 0 || stricmp(token, "CROSS") == 0) { join_info = STMT_HAS_INNER_JOIN; in_table = FALSE; continue; } else if (stricmp(token, "JOIN") == 0) { in_table = FALSE; out_table = TRUE; if (join_info == STMT_HAS_OUTER_JOIN) { SC_set_outer_join(stmt); } else { SC_set_inner_join(stmt); } join_info = STMT_HAS_NO_JOIN; continue; } } join_info = STMT_HAS_NO_JOIN; if (in_table) { if (!sqlsvr_check) wti = ti[stmt->ntab - 1]; if (in_dot) { if (NULL != wfi) { MOVE_NAME(wti->schema_name, wti->table_name); STRX_TO_NAME(wti->table_name, token); lower_the_name(GET_NAME(wti->table_name), conn, dquote); } in_dot = FALSE; continue; } if (strcmp(token, ".") == 0) { in_dot = TRUE; continue; } if (dquote || stricmp(token, "as")) { if (!dquote) { if (stricmp(token, "ON") == 0) { in_table = FALSE; continue; } } if (NULL != wti) { STRX_TO_NAME(wti->table_alias, token); MYLOG(0, "alias for table '%s' is '%s'\n", PRINT_NAME(wti->table_name), PRINT_NAME(wti->table_alias)); } in_table = FALSE; if (delim == ',') { out_table = TRUE; MYLOG(0, "more than 1 tables\n"); } } } } /* in_from */ } /* * Resolve any possible field names with tables */ parse = TRUE; if (sqlsvr_check) goto cleanup; /* Resolve field names with tables */ for (i = 0; i < (int) irdflds->nfields; i++) { wfi = fi[i]; if (wfi->func || wfi->expr || wfi->numeric) { wfi->ti = NULL; wfi->columntype = wfi->basetype = (OID) 0; parse = FALSE; continue; } else if (wfi->quote) { /* handle as text */ wfi->ti = NULL; /* * wfi->type = PG_TYPE_TEXT; wfi->column_size = 0; the * following may be better */ wfi->basetype = PG_TYPE_UNKNOWN; if (wfi->column_size == 0) { wfi->basetype = PG_TYPE_VARCHAR; wfi->column_size = 254; } wfi->length = wfi->column_size; continue; } /* field name contains the schema name */ else if (NAME_IS_VALID(wfi->schema_name)) { int matchidx = -1; for (k = 0; k < stmt->ntab; k++) { wti = ti[k]; if (!NAMEICMP(wti->table_name, wfi->before_dot)) { if (!NAMEICMP(wti->schema_name, wfi->schema_name)) { wfi->ti = wti; break; } else if (NAME_IS_NULL(wti->schema_name)) { if (matchidx < 0) matchidx = k; else { SC_set_parse_status(stmt, STMT_PARSE_FATAL); SC_set_error(stmt, STMT_EXEC_ERROR, "duplicated Table name", func); SC_reset_updatable(stmt); goto cleanup; } } } } if (matchidx >= 0) wfi->ti = ti[matchidx]; } /* it's a dot, resolve to table or alias */ else if (NAME_IS_VALID(wfi->before_dot)) { for (k = 0; k < stmt->ntab; k++) { wti = ti[k]; if (!NAMEICMP(wti->table_alias, wfi->before_dot)) { wfi->ti = wti; break; } else if (!NAMEICMP(wti->table_name, wfi->before_dot)) { wfi->ti = wti; break; } } } else if (stmt->ntab == 1) wfi->ti = ti[0]; } MYLOG(0, "--------------------------------------------\n"); MYLOG(0, "nfld=%d, ntab=%d\n", irdflds->nfields, stmt->ntab); if (0 == stmt->ntab) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); goto cleanup; } for (i = 0; i < (int) irdflds->nfields; i++) { wfi = fi[i]; MYLOG(0, "Field %d: expr=%d, func=%d, quote=%d, dquote=%d, numeric=%d, name='%s', alias='%s', dot='%s'\n", i, wfi->expr, wfi->func, wfi->quote, wfi->dquote, wfi->numeric, PRINT_NAME(wfi->column_name), PRINT_NAME(wfi->column_alias), PRINT_NAME(wfi->before_dot)); if (wfi->ti) MYLOG(0, " ----> table_name='%s', table_alias='%s'\n", PRINT_NAME(wfi->ti->table_name), PRINT_NAME(wfi->ti->table_alias)); } for (i = 0; i < stmt->ntab; i++) { wti = ti[i]; MYLOG(0, "Table %d: name='%s', alias='%s'\n", i, PRINT_NAME(wti->table_name), PRINT_NAME(wti->table_alias)); } /* * Now save the SQLColumns Info for the parse tables */ /* Call SQLColumns for each table and store the result */ if (stmt->ntab > 1) updatable = FALSE; else if (stmt->from_pos < 0) updatable = FALSE; for (i = 0; i < stmt->ntab; i++) { /* See if already got it */ wti = ti[i]; if (!getCOLIfromTI(func, NULL, stmt, 0, &wti)) break; } if (STMT_PARSE_FATAL == SC_parsed_status(stmt)) { goto cleanup; } MYLOG(0, "Done PG_Columns\n"); /* * Now resolve the fields to point to column info */ for (i = 0; i < (int) irdflds->nfields;) { wfi = fi[i]; if (wfi->ti) fupdatable = updatable && TI_is_updatable(wfi->ti); else fupdatable = FALSE; wfi->updatable = fupdatable; /* Dont worry about functions or quotes */ if (wfi->func || wfi->quote || wfi->numeric) { wfi->updatable = FALSE; i++; continue; } /* Stars get expanded to all fields in the table */ else if (SAFE_NAME(wfi->column_name)[0] == '*') { char do_all_tables; Int2 total_cols, cols, increased_cols; MYLOG(0, "expanding field %d\n", i); total_cols = 0; if (wfi->ti) /* The star represents only the qualified * table */ total_cols = (Int2) QR_get_num_cached_tuples(wfi->ti->col_info->result); else { /* The star represents all tables */ /* Calculate the total number of columns after expansion */ for (k = 0; k < stmt->ntab; k++) total_cols += (Int2) QR_get_num_cached_tuples(ti[k]->col_info->result); } increased_cols = total_cols - 1; /* Allocate some more field pointers if necessary */ new_size = irdflds->nfields + increased_cols; MYLOG(0, "k=%d, increased_cols=%d, allocated_size=%d, new_size=%d\n", k, increased_cols, allocated_size, new_size); if (new_size > allocated_size) { int new_alloc = new_size; MYLOG(0, "need more cols: new_alloc = %d\n", new_alloc); if (!allocateFields(irdflds, new_alloc)) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); goto cleanup; } fi = irdflds->fi; allocated_size = irdflds->allocated; } /* * copy any other fields (if there are any) up past the * expansion */ for (j = irdflds->nfields - 1; j > i; j--) { MYLOG(0, "copying field %d to %d\n", j, increased_cols + j); fi[increased_cols + j] = fi[j]; } MYLOG(0, "done copying fields\n"); /* Set the new number of fields */ irdflds->nfields += increased_cols; MYLOG(0, "irdflds->nfields now at %d\n", irdflds->nfields); /* copy the new field info */ do_all_tables = (wfi->ti ? FALSE : TRUE); wfi = NULL; for (k = 0; k < (do_all_tables ? stmt->ntab : 1); k++) { TABLE_INFO *the_ti = do_all_tables ? ti[k] : fi[i]->ti; cols = (Int2) QR_get_num_cached_tuples(the_ti->col_info->result); for (n = 0; n < cols; n++) { FIELD_INFO *afi; BOOL reuse = TRUE; MYLOG(0, "creating field info: n=%d\n", n); /* skip malloc (already did it for the Star) */ if (k > 0 || n > 0) { MYLOG(0, "allocating field info at %d\n", n + i); fi[n + i] = (FIELD_INFO *) malloc(sizeof(FIELD_INFO)); if (fi[n + i] == NULL) { SC_set_parse_status(stmt, STMT_PARSE_FATAL); goto cleanup; } reuse = FALSE; } afi = fi[n + i]; /* Initialize the new space (or the * field) */ FI_Constructor(afi, reuse); afi->ti = the_ti; MYLOG(0, "about to copy at %d\n", n + i); getColInfo(the_ti->col_info, afi, n); afi->updatable = fupdatable; MYLOG(0, "done copying\n"); } i += cols; MYLOG(0, "i now at %d\n", i); } } /* * We either know which table the field was in because it was * qualified with a table name or alias -OR- there was only 1 * table. */ else if (wfi->ti) { if (!searchColInfo(fi[i]->ti->col_info, wfi)) { parse = FALSE; wfi->updatable = FALSE; } i++; } /* Don't know the table -- search all tables in "from" list */ else { for (k = 0; k < stmt->ntab; k++) { if (searchColInfo(ti[k]->col_info, wfi)) { wfi->ti = ti[k]; /* now know the table */ break; } } if (k >= stmt->ntab) { parse = FALSE; wfi->updatable = FALSE; } i++; } } if (check_hasoids && updatable) CheckPgClassInfo(stmt); SC_set_parse_status(stmt, parse ? STMT_PARSE_COMPLETE : STMT_PARSE_INCOMPLETE); for (i = 0; i < (int) irdflds->nfields; i++) { wfi = fi[i]; wfi->flag &= ~FIELD_PARSING; if (0 != wfi->columntype || 0 != wfi->basetype) wfi->flag |= FIELD_PARSED_OK; } if (updatable) { if (stmt->ntab > 1) updatable = FALSE; } SC_set_updatable(stmt, updatable); cleanup: #undef return if (!sqlsvr_check && STMT_PARSE_FATAL == SC_parsed_status(stmt)) { SC_initialize_cols_info(stmt, FALSE, FALSE); parse = FALSE; } MYLOG(0, "laving parse=%d, parse_status=%d\n", parse, SC_parsed_status(stmt)); return parse; } char parse_statement(StatementClass *stmt, BOOL check_hasoids) { return parse_the_statement(stmt, check_hasoids, FALSE); } char parse_sqlsvr(StatementClass *stmt) { return parse_the_statement(stmt, FALSE, TRUE); } psqlodbc-REL-16_00_0005/pgapi30.c000066400000000000000000001675521462406103600161250ustar00rootroot00000000000000/*------- * Module: pgapi30.c * * Description: This module contains routines related to ODBC 3.0 * most of their implementations are temporary * and must be rewritten properly. * 2001/07/23 inoue * * Classes: n/a * * API functions: PGAPI_ColAttribute, PGAPI_GetDiagRec, PGAPI_GetConnectAttr, PGAPI_GetStmtAttr, PGAPI_SetConnectAttr, PGAPI_SetStmtAttr *------- */ #include "psqlodbc.h" #include "misc.h" #include #include #include "environ.h" #include "connection.h" #include "statement.h" #include "descriptor.h" #include "qresult.h" #include "pgapifunc.h" #include "loadlib.h" #include "dlg_specific.h" /* SQLError -> SQLDiagRec */ RETCODE SQL_API PGAPI_GetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) { RETCODE ret; MYLOG(0, "entering type=%d rec=%d buffer=%d\n", HandleType, RecNumber, BufferLength); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_EnvError(Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength, TextLength, 0); break; case SQL_HANDLE_DBC: ret = PGAPI_ConnectError(Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength, TextLength, 0); break; case SQL_HANDLE_STMT: ret = PGAPI_StmtError(Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength, TextLength, 0); break; case SQL_HANDLE_DESC: ret = PGAPI_DescError(Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength, TextLength, 0); break; default: ret = SQL_ERROR; } MYLOG(0, "leaving %d\n", ret); return ret; } /* * Minimal implementation. * */ RETCODE SQL_API PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, PTR DiagInfoPtr, SQLSMALLINT BufferLength, SQLSMALLINT *StringLengthPtr) { RETCODE ret = SQL_ERROR, rtn; ConnectionClass *conn; StatementClass *stmt; SQLLEN rc; SQLSMALLINT pcbErrm; ssize_t rtnlen = -1; int rtnctype = SQL_C_CHAR; MYLOG(0, "entering rec=%d\n", RecNumber); switch (HandleType) { case SQL_HANDLE_ENV: switch (DiagIdentifier) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: rtnlen = 0; if (DiagInfoPtr && BufferLength > rtnlen) { ret = SQL_SUCCESS; *((char *) DiagInfoPtr) = '\0'; } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_MESSAGE_TEXT: ret = PGAPI_EnvError(Handle, RecNumber, NULL, NULL, DiagInfoPtr, BufferLength, StringLengthPtr, 0); break; case SQL_DIAG_NATIVE: rtnctype = SQL_C_LONG; ret = PGAPI_EnvError(Handle, RecNumber, NULL, (SQLINTEGER *) DiagInfoPtr, NULL, 0, NULL, 0); break; case SQL_DIAG_NUMBER: rtnctype = SQL_C_LONG; ret = PGAPI_EnvError(Handle, RecNumber, NULL, NULL, NULL, 0, NULL, 0); if (SQL_SUCCEEDED(ret)) { *((SQLINTEGER *) DiagInfoPtr) = 1; } break; case SQL_DIAG_SQLSTATE: rtnlen = 5; ret = PGAPI_EnvError(Handle, RecNumber, DiagInfoPtr, NULL, NULL, 0, NULL, 0); if (SQL_SUCCESS_WITH_INFO == ret) ret = SQL_SUCCESS; break; case SQL_DIAG_RETURNCODE: /* driver manager returns */ break; case SQL_DIAG_CURSOR_ROW_COUNT: case SQL_DIAG_ROW_COUNT: case SQL_DIAG_DYNAMIC_FUNCTION: case SQL_DIAG_DYNAMIC_FUNCTION_CODE: /* options for statement type only */ break; } break; case SQL_HANDLE_DBC: conn = (ConnectionClass *) Handle; switch (DiagIdentifier) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: rtnlen = 0; if (DiagInfoPtr && BufferLength > rtnlen) { ret = SQL_SUCCESS; *((char *) DiagInfoPtr) = '\0'; } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_SERVER_NAME: rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_MESSAGE_TEXT: ret = PGAPI_ConnectError(Handle, RecNumber, NULL, NULL, DiagInfoPtr, BufferLength, StringLengthPtr, 0); break; case SQL_DIAG_NATIVE: rtnctype = SQL_C_LONG; ret = PGAPI_ConnectError(Handle, RecNumber, NULL, (SQLINTEGER *) DiagInfoPtr, NULL, 0, NULL, 0); break; case SQL_DIAG_NUMBER: ret = SQL_NO_DATA_FOUND; *((SQLINTEGER *) DiagInfoPtr) = 0; rtnctype = SQL_C_LONG; { SQLCHAR msg[SQL_MAX_MESSAGE_LENGTH + 1]; ret = PGAPI_ConnectError(Handle, 1, NULL, NULL, msg, sizeof(msg), &pcbErrm, 0); MYLOG(0, "pcbErrm=%d\n", pcbErrm); } if (SQL_SUCCEEDED(ret)) { *((SQLINTEGER *) DiagInfoPtr) = (pcbErrm - 1) / SQL_MAX_MESSAGE_LENGTH + 1; ret = SQL_SUCCESS; } break; case SQL_DIAG_SQLSTATE: rtnlen = 5; ret = PGAPI_ConnectError(Handle, RecNumber, DiagInfoPtr, NULL, NULL, 0, NULL, 0); if (SQL_SUCCESS_WITH_INFO == ret) ret = SQL_SUCCESS; break; case SQL_DIAG_RETURNCODE: /* driver manager returns */ break; case SQL_DIAG_CURSOR_ROW_COUNT: case SQL_DIAG_ROW_COUNT: case SQL_DIAG_DYNAMIC_FUNCTION: case SQL_DIAG_DYNAMIC_FUNCTION_CODE: /* options for statement type only */ break; } break; case SQL_HANDLE_STMT: conn = (ConnectionClass *) SC_get_conn(((StatementClass *) Handle)); switch (DiagIdentifier) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: rtnlen = 0; if (DiagInfoPtr && BufferLength > rtnlen) { ret = SQL_SUCCESS; *((char *) DiagInfoPtr) = '\0'; } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_SERVER_NAME: rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_MESSAGE_TEXT: ret = PGAPI_StmtError(Handle, RecNumber, NULL, NULL, DiagInfoPtr, BufferLength, StringLengthPtr, 0); break; case SQL_DIAG_NATIVE: rtnctype = SQL_C_LONG; ret = PGAPI_StmtError(Handle, RecNumber, NULL, (SQLINTEGER *) DiagInfoPtr, NULL, 0, NULL, 0); break; case SQL_DIAG_NUMBER: rtnctype = SQL_C_LONG; *((SQLINTEGER *) DiagInfoPtr) = 0; ret = SQL_NO_DATA_FOUND; stmt = (StatementClass *) Handle; rtn = PGAPI_StmtError(Handle, -1, NULL, NULL, NULL, 0, &pcbErrm, 0); switch (rtn) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: ret = SQL_SUCCESS; if (pcbErrm > 0 && stmt->pgerror) *((SQLINTEGER *) DiagInfoPtr) = (pcbErrm - 1)/ stmt->pgerror->recsize + 1; break; default: break; } break; case SQL_DIAG_SQLSTATE: rtnlen = 5; ret = PGAPI_StmtError(Handle, RecNumber, DiagInfoPtr, NULL, NULL, 0, NULL, 0); if (SQL_SUCCESS_WITH_INFO == ret) ret = SQL_SUCCESS; break; case SQL_DIAG_CURSOR_ROW_COUNT: rtnctype = SQL_C_LONG; stmt = (StatementClass *) Handle; rc = -1; if (stmt->status == STMT_FINISHED) { QResultClass *res = SC_get_Curres(stmt); /*if (!res) return SQL_ERROR;*/ if (stmt->proc_return > 0) rc = 0; else if (res && QR_NumResultCols(res) > 0 && !SC_is_fetchcursor(stmt)) rc = QR_get_num_total_tuples(res) - res->dl_count; } *((SQLLEN *) DiagInfoPtr) = rc; MYLOG(DETAIL_LOG_LEVEL, "rc=" FORMAT_LEN "\n", rc); ret = SQL_SUCCESS; break; case SQL_DIAG_ROW_COUNT: rtnctype = SQL_C_LONG; stmt = (StatementClass *) Handle; *((SQLLEN *) DiagInfoPtr) = stmt->diag_row_count; ret = SQL_SUCCESS; break; case SQL_DIAG_ROW_NUMBER: rtnctype = SQL_C_LONG; *((SQLLEN *) DiagInfoPtr) = SQL_ROW_NUMBER_UNKNOWN; ret = SQL_SUCCESS; break; case SQL_DIAG_COLUMN_NUMBER: rtnctype = SQL_C_LONG; *((SQLINTEGER *) DiagInfoPtr) = SQL_COLUMN_NUMBER_UNKNOWN; ret = SQL_SUCCESS; break; case SQL_DIAG_RETURNCODE: /* driver manager returns */ break; } break; case SQL_HANDLE_DESC: conn = DC_get_conn(((DescriptorClass *) Handle)); switch (DiagIdentifier) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: rtnlen = 0; if (DiagInfoPtr && BufferLength > rtnlen) { ret = SQL_SUCCESS; *((char *) DiagInfoPtr) = '\0'; } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_SERVER_NAME: rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else ret = SQL_SUCCESS_WITH_INFO; break; case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_NATIVE: case SQL_DIAG_NUMBER: break; case SQL_DIAG_SQLSTATE: rtnlen = 5; ret = PGAPI_DescError(Handle, RecNumber, DiagInfoPtr, NULL, NULL, 0, NULL, 0); if (SQL_SUCCESS_WITH_INFO == ret) ret = SQL_SUCCESS; break; case SQL_DIAG_RETURNCODE: /* driver manager returns */ break; case SQL_DIAG_CURSOR_ROW_COUNT: case SQL_DIAG_ROW_COUNT: case SQL_DIAG_DYNAMIC_FUNCTION: case SQL_DIAG_DYNAMIC_FUNCTION_CODE: rtnctype = SQL_C_LONG; /* options for statement type only */ break; } break; default: ret = SQL_ERROR; } if (SQL_C_LONG == rtnctype) { if (SQL_SUCCESS_WITH_INFO == ret) ret = SQL_SUCCESS; if (StringLengthPtr) *StringLengthPtr = sizeof(SQLINTEGER); } else if (rtnlen >= 0) { if (rtnlen >= BufferLength) { if (SQL_SUCCESS == ret) ret = SQL_SUCCESS_WITH_INFO; if (BufferLength > 0) ((char *) DiagInfoPtr) [BufferLength - 1] = '\0'; } if (StringLengthPtr) *StringLengthPtr = (SQLSMALLINT) rtnlen; } MYLOG(0, "leaving %d\n", ret); return ret; } /* SQLGetConnectOption -> SQLGetconnectAttr */ RETCODE SQL_API PGAPI_GetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret = SQL_SUCCESS; SQLINTEGER len = 4; MYLOG(0, "entering " FORMAT_INTEGER "\n", Attribute); switch (Attribute) { case SQL_ATTR_ASYNC_ENABLE: *((SQLINTEGER *) Value) = SQL_ASYNC_ENABLE_OFF; break; case SQL_ATTR_AUTO_IPD: *((SQLINTEGER *) Value) = SQL_FALSE; break; case SQL_ATTR_CONNECTION_DEAD: *((SQLUINTEGER *) Value) = CC_not_connected(conn); break; case SQL_ATTR_CONNECTION_TIMEOUT: *((SQLUINTEGER *) Value) = 0; break; case SQL_ATTR_METADATA_ID: *((SQLUINTEGER *) Value) = conn->stmtOptions.metadata_id; break; case SQL_ATTR_PGOPT_DEBUG: *((SQLINTEGER *) Value) = conn->connInfo.drivers.debug; break; case SQL_ATTR_PGOPT_COMMLOG: *((SQLINTEGER *) Value) = conn->connInfo.drivers.commlog; break; case SQL_ATTR_PGOPT_PARSE: *((SQLINTEGER *) Value) = conn->connInfo.drivers.parse; break; case SQL_ATTR_PGOPT_USE_DECLAREFETCH: *((SQLINTEGER *) Value) = conn->connInfo.drivers.use_declarefetch; break; case SQL_ATTR_PGOPT_SERVER_SIDE_PREPARE: *((SQLINTEGER *) Value) = conn->connInfo.use_server_side_prepare; break; case SQL_ATTR_PGOPT_FETCH: *((SQLINTEGER *) Value) = conn->connInfo.drivers.fetch_max; break; case SQL_ATTR_PGOPT_UNKNOWNSIZES: *((SQLINTEGER *) Value) = conn->connInfo.drivers.unknown_sizes; break; case SQL_ATTR_PGOPT_TEXTASLONGVARCHAR: *((SQLINTEGER *) Value) = conn->connInfo.drivers.text_as_longvarchar; break; case SQL_ATTR_PGOPT_UNKNOWNSASLONGVARCHAR: *((SQLINTEGER *) Value) = conn->connInfo.drivers.unknowns_as_longvarchar; break; case SQL_ATTR_PGOPT_BOOLSASCHAR: *((SQLINTEGER *) Value) = conn->connInfo.drivers.bools_as_char; break; case SQL_ATTR_PGOPT_MAXVARCHARSIZE: *((SQLINTEGER *) Value) = conn->connInfo.drivers.max_varchar_size; break; case SQL_ATTR_PGOPT_MAXLONGVARCHARSIZE: *((SQLINTEGER *) Value) = conn->connInfo.drivers.max_longvarchar_size; break; case SQL_ATTR_PGOPT_MSJET: *((SQLINTEGER *) Value) = conn->ms_jet; break; case SQL_ATTR_PGOPT_BATCHSIZE: *((SQLINTEGER *) Value) = conn->connInfo.batch_size; break; case SQL_ATTR_PGOPT_IGNORETIMEOUT: *((SQLINTEGER *) Value) = conn->connInfo.ignore_timeout; break; default: ret = PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value, &len, BufferLength); } if (StringLength) *StringLength = len; return ret; } static SQLHDESC descHandleFromStatementHandle(HSTMT StatementHandle, SQLINTEGER descType) { StatementClass *stmt = (StatementClass *) StatementHandle; switch (descType) { case SQL_ATTR_APP_ROW_DESC: /* 10010 */ return (HSTMT) stmt->ard; case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ return (HSTMT) stmt->apd; case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ return (HSTMT) stmt->ird; case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ return (HSTMT) stmt->ipd; } return (HSTMT) 0; } static void column_bindings_set(ARDFields *opts, int cols, BOOL maxset) { int i; if (cols == opts->allocated) return; if (cols > opts->allocated) { extend_column_bindings(opts, cols); return; } if (maxset) return; for (i = opts->allocated; i > cols; i--) reset_a_column_binding(opts, i); opts->allocated = cols; if (0 == cols) { free(opts->bindings); opts->bindings = NULL; } } static RETCODE SQL_API ARDSetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret = SQL_SUCCESS; ARDFields *opts = &(desc->ardf); SQLSMALLINT row_idx; BOOL unbind = TRUE; switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: opts->size_of_rowset = CAST_UPTR(SQLULEN, Value); return ret; case SQL_DESC_ARRAY_STATUS_PTR: opts->row_operation_ptr = Value; return ret; case SQL_DESC_BIND_OFFSET_PTR: opts->row_offset_ptr = Value; return ret; case SQL_DESC_BIND_TYPE: opts->bind_size = CAST_UPTR(SQLUINTEGER, Value); return ret; case SQL_DESC_COUNT: column_bindings_set(opts, CAST_PTR(SQLSMALLINT, Value), FALSE); return ret; case SQL_DESC_TYPE: case SQL_DESC_DATETIME_INTERVAL_CODE: case SQL_DESC_CONCISE_TYPE: column_bindings_set(opts, RecNumber, TRUE); break; } if (RecNumber < 0 || RecNumber > opts->allocated) { DC_set_error(desc, DESC_INVALID_COLUMN_NUMBER_ERROR, "invalid column number"); return SQL_ERROR; } if (0 == RecNumber) /* bookmark column */ { BindInfoClass *bookmark = ARD_AllocBookmark(opts); switch (FieldIdentifier) { case SQL_DESC_DATA_PTR: bookmark->buffer = Value; break; case SQL_DESC_INDICATOR_PTR: bookmark->indicator = Value; break; case SQL_DESC_OCTET_LENGTH_PTR: bookmark->used = Value; break; default: DC_set_error(desc, DESC_INVALID_COLUMN_NUMBER_ERROR, "invalid column number"); ret = SQL_ERROR; } return ret; } row_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_TYPE: opts->bindings[row_idx].returntype = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_DATETIME_INTERVAL_CODE: switch (opts->bindings[row_idx].returntype) { case SQL_DATETIME: case SQL_C_TYPE_DATE: case SQL_C_TYPE_TIME: case SQL_C_TYPE_TIMESTAMP: switch ((LONG_PTR) Value) { case SQL_CODE_DATE: opts->bindings[row_idx].returntype = SQL_C_TYPE_DATE; break; case SQL_CODE_TIME: opts->bindings[row_idx].returntype = SQL_C_TYPE_TIME; break; case SQL_CODE_TIMESTAMP: opts->bindings[row_idx].returntype = SQL_C_TYPE_TIMESTAMP; break; } break; } break; case SQL_DESC_CONCISE_TYPE: opts->bindings[row_idx].returntype = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_DATA_PTR: unbind = FALSE; opts->bindings[row_idx].buffer = Value; break; case SQL_DESC_INDICATOR_PTR: unbind = FALSE; opts->bindings[row_idx].indicator = Value; break; case SQL_DESC_OCTET_LENGTH_PTR: unbind = FALSE; opts->bindings[row_idx].used = Value; break; case SQL_DESC_OCTET_LENGTH: opts->bindings[row_idx].buflen = CAST_PTR(SQLLEN, Value); break; case SQL_DESC_PRECISION: opts->bindings[row_idx].precision = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_SCALE: opts->bindings[row_idx].scale = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_ALLOC_TYPE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_LENGTH: case SQL_DESC_NUM_PREC_RADIX: default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } if (unbind) opts->bindings[row_idx].buffer = NULL; return ret; } static void parameter_bindings_set(APDFields *opts, int params, BOOL maxset) { int i; if (params == opts->allocated) return; if (params > opts->allocated) { extend_parameter_bindings(opts, params); return; } if (maxset) return; for (i = opts->allocated; i > params; i--) reset_a_parameter_binding(opts, i); opts->allocated = params; if (0 == params) { free(opts->parameters); opts->parameters = NULL; } } static void parameter_ibindings_set(IPDFields *opts, int params, BOOL maxset) { int i; if (params == opts->allocated) return; if (params > opts->allocated) { extend_iparameter_bindings(opts, params); return; } if (maxset) return; for (i = opts->allocated; i > params; i--) reset_a_iparameter_binding(opts, i); opts->allocated = params; if (0 == params) { free(opts->parameters); opts->parameters = NULL; } } static RETCODE SQL_API APDSetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret = SQL_SUCCESS; APDFields *opts = &(desc->apdf); SQLSMALLINT para_idx; BOOL unbind = TRUE; switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: opts->paramset_size = CAST_UPTR(SQLUINTEGER, Value); return ret; case SQL_DESC_ARRAY_STATUS_PTR: opts->param_operation_ptr = Value; return ret; case SQL_DESC_BIND_OFFSET_PTR: opts->param_offset_ptr = Value; return ret; case SQL_DESC_BIND_TYPE: opts->param_bind_type = CAST_UPTR(SQLUINTEGER, Value); return ret; case SQL_DESC_COUNT: parameter_bindings_set(opts, CAST_PTR(SQLSMALLINT, Value), FALSE); return ret; case SQL_DESC_TYPE: case SQL_DESC_DATETIME_INTERVAL_CODE: case SQL_DESC_CONCISE_TYPE: parameter_bindings_set(opts, RecNumber, TRUE); break; } if (RecNumber <=0) { MYLOG(DETAIL_LOG_LEVEL, "RecN=%d allocated=%d\n", RecNumber, opts->allocated); DC_set_error(desc, DESC_BAD_PARAMETER_NUMBER_ERROR, "bad parameter number"); return SQL_ERROR; } if (RecNumber > opts->allocated) { MYLOG(DETAIL_LOG_LEVEL, "RecN=%d allocated=%d\n", RecNumber, opts->allocated); parameter_bindings_set(opts, RecNumber, TRUE); /* DC_set_error(desc, DESC_BAD_PARAMETER_NUMBER_ERROR, "bad parameter number"); return SQL_ERROR;*/ } para_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_TYPE: opts->parameters[para_idx].CType = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_DATETIME_INTERVAL_CODE: switch (opts->parameters[para_idx].CType) { case SQL_DATETIME: case SQL_C_TYPE_DATE: case SQL_C_TYPE_TIME: case SQL_C_TYPE_TIMESTAMP: switch ((LONG_PTR) Value) { case SQL_CODE_DATE: opts->parameters[para_idx].CType = SQL_C_TYPE_DATE; break; case SQL_CODE_TIME: opts->parameters[para_idx].CType = SQL_C_TYPE_TIME; break; case SQL_CODE_TIMESTAMP: opts->parameters[para_idx].CType = SQL_C_TYPE_TIMESTAMP; break; } break; } break; case SQL_DESC_CONCISE_TYPE: opts->parameters[para_idx].CType = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_DATA_PTR: unbind = FALSE; opts->parameters[para_idx].buffer = Value; break; case SQL_DESC_INDICATOR_PTR: unbind = FALSE; opts->parameters[para_idx].indicator = Value; break; case SQL_DESC_OCTET_LENGTH: opts->parameters[para_idx].buflen = CAST_PTR(Int4, Value); break; case SQL_DESC_OCTET_LENGTH_PTR: unbind = FALSE; opts->parameters[para_idx].used = Value; break; case SQL_DESC_PRECISION: opts->parameters[para_idx].precision = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_SCALE: opts->parameters[para_idx].scale = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_ALLOC_TYPE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_LENGTH: case SQL_DESC_NUM_PREC_RADIX: default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } if (unbind) opts->parameters[para_idx].buffer = NULL; return ret; } static RETCODE SQL_API IRDSetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret = SQL_SUCCESS; IRDFields *opts = &(desc->irdf); switch (FieldIdentifier) { case SQL_DESC_ARRAY_STATUS_PTR: opts->rowStatusArray = (SQLUSMALLINT *) Value; break; case SQL_DESC_ROWS_PROCESSED_PTR: opts->rowsFetched = (SQLULEN *) Value; break; case SQL_DESC_ALLOC_TYPE: /* read-only */ case SQL_DESC_COUNT: /* read-only */ case SQL_DESC_AUTO_UNIQUE_VALUE: /* read-only */ case SQL_DESC_BASE_COLUMN_NAME: /* read-only */ case SQL_DESC_BASE_TABLE_NAME: /* read-only */ case SQL_DESC_CASE_SENSITIVE: /* read-only */ case SQL_DESC_CATALOG_NAME: /* read-only */ case SQL_DESC_CONCISE_TYPE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_CODE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: /* read-only */ case SQL_DESC_DISPLAY_SIZE: /* read-only */ case SQL_DESC_FIXED_PREC_SCALE: /* read-only */ case SQL_DESC_LABEL: /* read-only */ case SQL_DESC_LENGTH: /* read-only */ case SQL_DESC_LITERAL_PREFIX: /* read-only */ case SQL_DESC_LITERAL_SUFFIX: /* read-only */ case SQL_DESC_LOCAL_TYPE_NAME: /* read-only */ case SQL_DESC_NAME: /* read-only */ case SQL_DESC_NULLABLE: /* read-only */ case SQL_DESC_NUM_PREC_RADIX: /* read-only */ case SQL_DESC_OCTET_LENGTH: /* read-only */ case SQL_DESC_PRECISION: /* read-only */ case SQL_DESC_ROWVER: /* read-only */ case SQL_DESC_SCALE: /* read-only */ case SQL_DESC_SCHEMA_NAME: /* read-only */ case SQL_DESC_SEARCHABLE: /* read-only */ case SQL_DESC_TABLE_NAME: /* read-only */ case SQL_DESC_TYPE: /* read-only */ case SQL_DESC_TYPE_NAME: /* read-only */ case SQL_DESC_UNNAMED: /* read-only */ case SQL_DESC_UNSIGNED: /* read-only */ case SQL_DESC_UPDATABLE: /* read-only */ default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } return ret; } static RETCODE SQL_API IPDSetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { RETCODE ret = SQL_SUCCESS; IPDFields *ipdopts = &(desc->ipdf); SQLSMALLINT para_idx; switch (FieldIdentifier) { case SQL_DESC_ARRAY_STATUS_PTR: ipdopts->param_status_ptr = (SQLUSMALLINT *) Value; return ret; case SQL_DESC_ROWS_PROCESSED_PTR: ipdopts->param_processed_ptr = (SQLULEN *) Value; return ret; case SQL_DESC_COUNT: parameter_ibindings_set(ipdopts, CAST_PTR(SQLSMALLINT, Value), FALSE); return ret; case SQL_DESC_UNNAMED: /* only SQL_UNNAMED is allowed */ if (SQL_UNNAMED != CAST_PTR(SQLSMALLINT, Value)) { ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); return ret; } case SQL_DESC_NAME: case SQL_DESC_TYPE: case SQL_DESC_DATETIME_INTERVAL_CODE: case SQL_DESC_CONCISE_TYPE: parameter_ibindings_set(ipdopts, RecNumber, TRUE); break; } if (RecNumber <= 0 || RecNumber > ipdopts->allocated) { MYLOG(DETAIL_LOG_LEVEL, "RecN=%d allocated=%d\n", RecNumber, ipdopts->allocated); DC_set_error(desc, DESC_BAD_PARAMETER_NUMBER_ERROR, "bad parameter number"); return SQL_ERROR; } para_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_TYPE: if (ipdopts->parameters[para_idx].SQLType != CAST_PTR(SQLSMALLINT, Value)) { reset_a_iparameter_binding(ipdopts, RecNumber); ipdopts->parameters[para_idx].SQLType = CAST_PTR(SQLSMALLINT, Value); } break; case SQL_DESC_DATETIME_INTERVAL_CODE: switch (ipdopts->parameters[para_idx].SQLType) { case SQL_DATETIME: case SQL_TYPE_DATE: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: switch ((LONG_PTR) Value) { case SQL_CODE_DATE: ipdopts->parameters[para_idx].SQLType = SQL_TYPE_DATE; break; case SQL_CODE_TIME: ipdopts->parameters[para_idx].SQLType = SQL_TYPE_TIME; break; case SQL_CODE_TIMESTAMP: ipdopts->parameters[para_idx].SQLType = SQL_TYPE_TIMESTAMP; break; } break; } break; case SQL_DESC_CONCISE_TYPE: ipdopts->parameters[para_idx].SQLType = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_NAME: if (Value) STR_TO_NAME(ipdopts->parameters[para_idx].paramName, Value); else NULL_THE_NAME(ipdopts->parameters[para_idx].paramName); break; case SQL_DESC_PARAMETER_TYPE: ipdopts->parameters[para_idx].paramType = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_SCALE: ipdopts->parameters[para_idx].decimal_digits = CAST_PTR(SQLSMALLINT, Value); break; case SQL_DESC_UNNAMED: /* only SQL_UNNAMED is allowed */ if (SQL_UNNAMED != CAST_PTR(SQLSMALLINT, Value)) { ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } else NULL_THE_NAME(ipdopts->parameters[para_idx].paramName); break; case SQL_DESC_ALLOC_TYPE: /* read-only */ case SQL_DESC_CASE_SENSITIVE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_FIXED_PREC_SCALE: /* read-only */ case SQL_DESC_LENGTH: case SQL_DESC_LOCAL_TYPE_NAME: /* read-only */ case SQL_DESC_NULLABLE: /* read-only */ case SQL_DESC_NUM_PREC_RADIX: case SQL_DESC_OCTET_LENGTH: case SQL_DESC_PRECISION: case SQL_DESC_ROWVER: /* read-only */ case SQL_DESC_TYPE_NAME: /* read-only */ case SQL_DESC_UNSIGNED: /* read-only */ default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } return ret; } static RETCODE SQL_API ARDGetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret = SQL_SUCCESS; SQLLEN ival = 0; SQLINTEGER len, rettype = 0; PTR ptr = NULL; const ARDFields *opts = &(desc->ardf); SQLSMALLINT row_idx; len = sizeof(SQLINTEGER); if (0 == RecNumber) /* bookmark */ { BindInfoClass *bookmark = opts->bookmark; switch (FieldIdentifier) { case SQL_DESC_DATA_PTR: rettype = SQL_IS_POINTER; ptr = bookmark ? bookmark->buffer : NULL; break; case SQL_DESC_INDICATOR_PTR: rettype = SQL_IS_POINTER; ptr = bookmark ? bookmark->indicator : NULL; break; case SQL_DESC_OCTET_LENGTH_PTR: rettype = SQL_IS_POINTER; ptr = bookmark ? bookmark->used : NULL; break; } if (ptr) { *((void **) Value) = ptr; if (StringLength) *StringLength = len; return ret; } } switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: case SQL_DESC_ARRAY_STATUS_PTR: case SQL_DESC_BIND_OFFSET_PTR: case SQL_DESC_BIND_TYPE: case SQL_DESC_COUNT: break; default: if (RecNumber <= 0 || RecNumber > opts->allocated) { DC_set_error(desc, DESC_INVALID_COLUMN_NUMBER_ERROR, "invalid column number"); return SQL_ERROR; } } row_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: ival = opts->size_of_rowset; break; case SQL_DESC_ARRAY_STATUS_PTR: rettype = SQL_IS_POINTER; ptr = opts->row_operation_ptr; break; case SQL_DESC_BIND_OFFSET_PTR: rettype = SQL_IS_POINTER; ptr = opts->row_offset_ptr; break; case SQL_DESC_BIND_TYPE: ival = opts->bind_size; break; case SQL_DESC_TYPE: rettype = SQL_IS_SMALLINT; switch (opts->bindings[row_idx].returntype) { case SQL_C_TYPE_DATE: case SQL_C_TYPE_TIME: case SQL_C_TYPE_TIMESTAMP: ival = SQL_DATETIME; break; default: ival = opts->bindings[row_idx].returntype; } break; case SQL_DESC_DATETIME_INTERVAL_CODE: rettype = SQL_IS_SMALLINT; switch (opts->bindings[row_idx].returntype) { case SQL_C_TYPE_DATE: ival = SQL_CODE_DATE; break; case SQL_C_TYPE_TIME: ival = SQL_CODE_TIME; break; case SQL_C_TYPE_TIMESTAMP: ival = SQL_CODE_TIMESTAMP; break; default: ival = 0; break; } break; case SQL_DESC_CONCISE_TYPE: rettype = SQL_IS_SMALLINT; ival = opts->bindings[row_idx].returntype; break; case SQL_DESC_DATA_PTR: rettype = SQL_IS_POINTER; ptr = opts->bindings[row_idx].buffer; break; case SQL_DESC_INDICATOR_PTR: rettype = SQL_IS_POINTER; ptr = opts->bindings[row_idx].indicator; break; case SQL_DESC_OCTET_LENGTH_PTR: rettype = SQL_IS_POINTER; ptr = opts->bindings[row_idx].used; break; case SQL_DESC_COUNT: rettype = SQL_IS_SMALLINT; ival = opts->allocated; break; case SQL_DESC_OCTET_LENGTH: ival = opts->bindings[row_idx].buflen; break; case SQL_DESC_ALLOC_TYPE: /* read-only */ rettype = SQL_IS_SMALLINT; if (DC_get_embedded(desc)) ival = SQL_DESC_ALLOC_AUTO; else ival = SQL_DESC_ALLOC_USER; break; case SQL_DESC_PRECISION: rettype = SQL_IS_SMALLINT; ival = opts->bindings[row_idx].precision; break; case SQL_DESC_SCALE: rettype = SQL_IS_SMALLINT; ival = opts->bindings[row_idx].scale; break; case SQL_DESC_NUM_PREC_RADIX: ival = 10; break; case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_LENGTH: default: ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } switch (rettype) { case 0: case SQL_IS_INTEGER: len = sizeof(SQLINTEGER); *((SQLINTEGER *) Value) = (SQLINTEGER) ival; break; case SQL_IS_SMALLINT: len = sizeof(SQLSMALLINT); *((SQLSMALLINT *) Value) = (SQLSMALLINT) ival; break; case SQL_IS_POINTER: len = sizeof(SQLPOINTER); *((void **) Value) = ptr; break; } if (StringLength) *StringLength = len; return ret; } static RETCODE SQL_API APDGetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret = SQL_SUCCESS; SQLLEN ival = 0; SQLINTEGER len, rettype = 0; PTR ptr = NULL; const APDFields *opts = (const APDFields *) &(desc->apdf); SQLSMALLINT para_idx; len = sizeof(SQLINTEGER); switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: case SQL_DESC_ARRAY_STATUS_PTR: case SQL_DESC_BIND_OFFSET_PTR: case SQL_DESC_BIND_TYPE: case SQL_DESC_COUNT: break; default:if (RecNumber <= 0 || RecNumber > opts->allocated) { MYLOG(DETAIL_LOG_LEVEL, "RecN=%d allocated=%d\n", RecNumber, opts->allocated); DC_set_error(desc, DESC_BAD_PARAMETER_NUMBER_ERROR, "bad parameter number"); return SQL_ERROR; } } para_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_ARRAY_SIZE: rettype = SQL_IS_LEN; ival = opts->paramset_size; break; case SQL_DESC_ARRAY_STATUS_PTR: rettype = SQL_IS_POINTER; ptr = opts->param_operation_ptr; break; case SQL_DESC_BIND_OFFSET_PTR: rettype = SQL_IS_POINTER; ptr = opts->param_offset_ptr; break; case SQL_DESC_BIND_TYPE: ival = opts->param_bind_type; break; case SQL_DESC_TYPE: rettype = SQL_IS_SMALLINT; switch (opts->parameters[para_idx].CType) { case SQL_C_TYPE_DATE: case SQL_C_TYPE_TIME: case SQL_C_TYPE_TIMESTAMP: ival = SQL_DATETIME; break; default: ival = opts->parameters[para_idx].CType; } break; case SQL_DESC_DATETIME_INTERVAL_CODE: rettype = SQL_IS_SMALLINT; switch (opts->parameters[para_idx].CType) { case SQL_C_TYPE_DATE: ival = SQL_CODE_DATE; break; case SQL_C_TYPE_TIME: ival = SQL_CODE_TIME; break; case SQL_C_TYPE_TIMESTAMP: ival = SQL_CODE_TIMESTAMP; break; default: ival = 0; break; } break; case SQL_DESC_CONCISE_TYPE: rettype = SQL_IS_SMALLINT; ival = opts->parameters[para_idx].CType; break; case SQL_DESC_DATA_PTR: rettype = SQL_IS_POINTER; ptr = opts->parameters[para_idx].buffer; break; case SQL_DESC_INDICATOR_PTR: rettype = SQL_IS_POINTER; ptr = opts->parameters[para_idx].indicator; break; case SQL_DESC_OCTET_LENGTH: ival = opts->parameters[para_idx].buflen; break; case SQL_DESC_OCTET_LENGTH_PTR: rettype = SQL_IS_POINTER; ptr = opts->parameters[para_idx].used; break; case SQL_DESC_COUNT: rettype = SQL_IS_SMALLINT; ival = opts->allocated; break; case SQL_DESC_ALLOC_TYPE: /* read-only */ rettype = SQL_IS_SMALLINT; if (DC_get_embedded(desc)) ival = SQL_DESC_ALLOC_AUTO; else ival = SQL_DESC_ALLOC_USER; break; case SQL_DESC_NUM_PREC_RADIX: ival = 10; break; case SQL_DESC_PRECISION: rettype = SQL_IS_SMALLINT; ival = opts->parameters[para_idx].precision; break; case SQL_DESC_SCALE: rettype = SQL_IS_SMALLINT; ival = opts->parameters[para_idx].scale; break; case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_LENGTH: default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } switch (rettype) { case SQL_IS_LEN: len = sizeof(SQLLEN); *((SQLLEN *) Value) = ival; break; case 0: case SQL_IS_INTEGER: len = sizeof(SQLINTEGER); *((SQLINTEGER *) Value) = (SQLINTEGER) ival; break; case SQL_IS_SMALLINT: len = sizeof(SQLSMALLINT); *((SQLSMALLINT *) Value) = (SQLSMALLINT) ival; break; case SQL_IS_POINTER: len = sizeof(SQLPOINTER); *((void **) Value) = ptr; break; } if (StringLength) *StringLength = len; return ret; } static RETCODE SQL_API IRDGetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret = SQL_SUCCESS; SQLLEN ival = 0; SQLINTEGER len = 0, rettype = 0; PTR ptr = NULL; BOOL bCallColAtt = FALSE; const IRDFields *opts = &(desc->irdf); switch (FieldIdentifier) { case SQL_DESC_ARRAY_STATUS_PTR: rettype = SQL_IS_POINTER; ptr = opts->rowStatusArray; break; case SQL_DESC_ROWS_PROCESSED_PTR: rettype = SQL_IS_POINTER; ptr = opts->rowsFetched; break; case SQL_DESC_ALLOC_TYPE: /* read-only */ rettype = SQL_IS_SMALLINT; ival = SQL_DESC_ALLOC_AUTO; break; case SQL_DESC_COUNT: /* read-only */ case SQL_DESC_AUTO_UNIQUE_VALUE: /* read-only */ case SQL_DESC_CASE_SENSITIVE: /* read-only */ case SQL_DESC_CONCISE_TYPE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_CODE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: /* read-only */ case SQL_DESC_DISPLAY_SIZE: /* read-only */ case SQL_DESC_FIXED_PREC_SCALE: /* read-only */ case SQL_DESC_LENGTH: /* read-only */ case SQL_DESC_NULLABLE: /* read-only */ case SQL_DESC_NUM_PREC_RADIX: /* read-only */ case SQL_DESC_OCTET_LENGTH: /* read-only */ case SQL_DESC_PRECISION: /* read-only */ case SQL_DESC_ROWVER: /* read-only */ case SQL_DESC_SCALE: /* read-only */ case SQL_DESC_SEARCHABLE: /* read-only */ case SQL_DESC_TYPE: /* read-only */ case SQL_DESC_UNNAMED: /* read-only */ case SQL_DESC_UNSIGNED: /* read-only */ case SQL_DESC_UPDATABLE: /* read-only */ bCallColAtt = TRUE; break; case SQL_DESC_BASE_COLUMN_NAME: /* read-only */ case SQL_DESC_BASE_TABLE_NAME: /* read-only */ case SQL_DESC_CATALOG_NAME: /* read-only */ case SQL_DESC_LABEL: /* read-only */ case SQL_DESC_LITERAL_PREFIX: /* read-only */ case SQL_DESC_LITERAL_SUFFIX: /* read-only */ case SQL_DESC_LOCAL_TYPE_NAME: /* read-only */ case SQL_DESC_NAME: /* read-only */ case SQL_DESC_SCHEMA_NAME: /* read-only */ case SQL_DESC_TABLE_NAME: /* read-only */ case SQL_DESC_TYPE_NAME: /* read-only */ rettype = SQL_NTS; bCallColAtt = TRUE; break; default: ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } if (bCallColAtt) { SQLSMALLINT pcbL; StatementClass *stmt; stmt = opts->stmt; ret = PGAPI_ColAttributes(stmt, RecNumber, FieldIdentifier, Value, (SQLSMALLINT) BufferLength, &pcbL, &ival); len = pcbL; } switch (rettype) { case 0: case SQL_IS_INTEGER: len = sizeof(SQLINTEGER); *((SQLINTEGER *) Value) = (SQLINTEGER) ival; break; case SQL_IS_UINTEGER: len = sizeof(SQLUINTEGER); *((SQLUINTEGER *) Value) = (SQLUINTEGER) ival; break; case SQL_IS_SMALLINT: len = sizeof(SQLSMALLINT); *((SQLSMALLINT *) Value) = (SQLSMALLINT) ival; break; case SQL_IS_POINTER: len = sizeof(SQLPOINTER); *((void **) Value) = ptr; break; case SQL_NTS: break; } if (StringLength) *StringLength = len; return ret; } static RETCODE SQL_API IPDGetField(DescriptorClass *desc, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { RETCODE ret = SQL_SUCCESS; SQLINTEGER ival = 0, len = 0, rettype = 0; PTR ptr = NULL; const IPDFields *ipdopts = (const IPDFields *) &(desc->ipdf); SQLSMALLINT para_idx; switch (FieldIdentifier) { case SQL_DESC_ARRAY_STATUS_PTR: case SQL_DESC_ROWS_PROCESSED_PTR: case SQL_DESC_COUNT: break; default:if (RecNumber <= 0 || RecNumber > ipdopts->allocated) { MYLOG(DETAIL_LOG_LEVEL, "RecN=%d allocated=%d\n", RecNumber, ipdopts->allocated); DC_set_error(desc, DESC_BAD_PARAMETER_NUMBER_ERROR, "bad parameter number"); return SQL_ERROR; } } para_idx = RecNumber - 1; switch (FieldIdentifier) { case SQL_DESC_ARRAY_STATUS_PTR: rettype = SQL_IS_POINTER; ptr = ipdopts->param_status_ptr; break; case SQL_DESC_ROWS_PROCESSED_PTR: rettype = SQL_IS_POINTER; ptr = ipdopts->param_processed_ptr; break; case SQL_DESC_UNNAMED: rettype = SQL_IS_SMALLINT; ival = NAME_IS_NULL(ipdopts->parameters[para_idx].paramName) ? SQL_UNNAMED : SQL_NAMED; break; case SQL_DESC_TYPE: rettype = SQL_IS_SMALLINT; switch (ipdopts->parameters[para_idx].SQLType) { case SQL_TYPE_DATE: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: ival = SQL_DATETIME; break; default: ival = ipdopts->parameters[para_idx].SQLType; } break; case SQL_DESC_DATETIME_INTERVAL_CODE: rettype = SQL_IS_SMALLINT; switch (ipdopts->parameters[para_idx].SQLType) { case SQL_TYPE_DATE: ival = SQL_CODE_DATE; break; case SQL_TYPE_TIME: ival = SQL_CODE_TIME; break; case SQL_TYPE_TIMESTAMP: ival = SQL_CODE_TIMESTAMP; break; default: ival = 0; } break; case SQL_DESC_CONCISE_TYPE: rettype = SQL_IS_SMALLINT; ival = ipdopts->parameters[para_idx].SQLType; break; case SQL_DESC_COUNT: rettype = SQL_IS_SMALLINT; ival = ipdopts->allocated; break; case SQL_DESC_PARAMETER_TYPE: rettype = SQL_IS_SMALLINT; ival = ipdopts->parameters[para_idx].paramType; break; case SQL_DESC_PRECISION: rettype = SQL_IS_SMALLINT; switch (ipdopts->parameters[para_idx].SQLType) { case SQL_TYPE_DATE: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: case SQL_DATETIME: ival = ipdopts->parameters[para_idx].decimal_digits; break; } break; case SQL_DESC_SCALE: rettype = SQL_IS_SMALLINT; switch (ipdopts->parameters[para_idx].SQLType) { case SQL_NUMERIC: ival = ipdopts->parameters[para_idx].decimal_digits; break; } break; case SQL_DESC_ALLOC_TYPE: /* read-only */ rettype = SQL_IS_SMALLINT; ival = SQL_DESC_ALLOC_AUTO; break; case SQL_DESC_CASE_SENSITIVE: /* read-only */ case SQL_DESC_DATETIME_INTERVAL_PRECISION: case SQL_DESC_FIXED_PREC_SCALE: /* read-only */ case SQL_DESC_LENGTH: case SQL_DESC_LOCAL_TYPE_NAME: /* read-only */ case SQL_DESC_NAME: case SQL_DESC_NULLABLE: /* read-only */ case SQL_DESC_NUM_PREC_RADIX: case SQL_DESC_OCTET_LENGTH: case SQL_DESC_ROWVER: /* read-only */ case SQL_DESC_TYPE_NAME: /* read-only */ case SQL_DESC_UNSIGNED: /* read-only */ default:ret = SQL_ERROR; DC_set_error(desc, DESC_INVALID_DESCRIPTOR_IDENTIFIER, "invalid descriptor identifier"); } switch (rettype) { case 0: case SQL_IS_INTEGER: len = sizeof(SQLINTEGER); *((SQLINTEGER *) Value) = ival; break; case SQL_IS_SMALLINT: len = sizeof(SQLSMALLINT); *((SQLSMALLINT *) Value) = (SQLSMALLINT) ival; break; case SQL_IS_POINTER: len = sizeof(SQLPOINTER); *((void **)Value) = ptr; break; } if (StringLength) *StringLength = len; return ret; } /* SQLGetStmtOption -> SQLGetStmtAttr */ RETCODE SQL_API PGAPI_GetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { CSTR func = "PGAPI_GetStmtAttr"; StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret = SQL_SUCCESS; SQLINTEGER len = 0; MYLOG(0, "entering Handle=%p " FORMAT_INTEGER "\n", StatementHandle, Attribute); switch (Attribute) { case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ *((void **) Value) = stmt->options.bookmark_ptr; len = sizeof(SQLPOINTER); break; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ *((SQLULEN **) Value) = SC_get_APDF(stmt)->param_offset_ptr; len = sizeof(SQLPOINTER); break; case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ *((SQLUINTEGER *) Value) = SC_get_APDF(stmt)->param_bind_type; len = sizeof(SQLUINTEGER); break; case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ *((SQLUSMALLINT **) Value) = SC_get_APDF(stmt)->param_operation_ptr; len = sizeof(SQLPOINTER); break; case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ *((SQLUSMALLINT **) Value) = SC_get_IPDF(stmt)->param_status_ptr; len = sizeof(SQLPOINTER); break; case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ *((SQLULEN **) Value) = SC_get_IPDF(stmt)->param_processed_ptr; len = sizeof(SQLPOINTER); break; case SQL_ATTR_PARAMSET_SIZE: /* 22 */ *((SQLULEN *) Value) = SC_get_APDF(stmt)->paramset_size; len = sizeof(SQLUINTEGER); break; case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ *((SQLULEN **) Value) = SC_get_ARDF(stmt)->row_offset_ptr; len = 4; break; case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ *((SQLUSMALLINT **) Value) = SC_get_ARDF(stmt)->row_operation_ptr; len = 4; break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ *((SQLUSMALLINT **) Value) = SC_get_IRDF(stmt)->rowStatusArray; len = 4; break; case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ *((SQLULEN **) Value) = SC_get_IRDF(stmt)->rowsFetched; len = 4; break; case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ *((SQLULEN *) Value) = SC_get_ARDF(stmt)->size_of_rowset; len = 4; break; case SQL_ATTR_APP_ROW_DESC: /* 10010 */ case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ len = 4; *((HSTMT *) Value) = descHandleFromStatementHandle(StatementHandle, Attribute); break; case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ len = 4; if (SQL_CURSOR_FORWARD_ONLY == stmt->options.cursor_type) *((SQLUINTEGER *) Value) = SQL_NONSCROLLABLE; else *((SQLUINTEGER *) Value) = SQL_SCROLLABLE; break; case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ len = 4; if (SQL_CONCUR_READ_ONLY == stmt->options.scroll_concurrency) *((SQLUINTEGER *) Value) = SQL_INSENSITIVE; else *((SQLUINTEGER *) Value) = SQL_UNSPECIFIED; break; case SQL_ATTR_METADATA_ID: /* 10014 */ *((SQLUINTEGER *) Value) = stmt->options.metadata_id; break; case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ *((SQLUINTEGER *) Value) = SQL_FALSE; break; case SQL_ATTR_AUTO_IPD: /* 10001 */ /* case SQL_ATTR_ROW_BIND_TYPE: ** == SQL_BIND_TYPE(ODBC2.0) */ SC_set_error(stmt, DESC_INVALID_OPTION_IDENTIFIER, "Unsupported statement option (Get)", func); return SQL_ERROR; default: ret = PGAPI_GetStmtOption(StatementHandle, (SQLSMALLINT) Attribute, Value, &len, BufferLength); } if (ret == SQL_SUCCESS && StringLength) *StringLength = len; return ret; } /* SQLSetConnectOption -> SQLSetConnectAttr */ RETCODE SQL_API PGAPI_SetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength) { CSTR func = "PGAPI_SetConnectAttr"; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret = SQL_SUCCESS; BOOL unsupported = FALSE; int newValue; MYLOG(0, "entering for %p: " FORMAT_INTEGER " %p\n", ConnectionHandle, Attribute, Value); switch (Attribute) { case SQL_ATTR_METADATA_ID: conn->stmtOptions.metadata_id = CAST_UPTR(SQLUINTEGER, Value); break; case SQL_ATTR_ANSI_APP: if (SQL_AA_FALSE != CAST_PTR(SQLINTEGER, Value)) { MYLOG(0, "the application is ansi\n"); if (CC_is_in_unicode_driver(conn)) /* the driver is unicode */ CC_set_in_ansi_app(conn); /* but the app is ansi */ } else { MYLOG(0, "the application is unicode\n"); } /*return SQL_ERROR;*/ return SQL_SUCCESS; case SQL_ATTR_ENLIST_IN_DTC: #ifdef WIN32 #ifdef _HANDLE_ENLIST_IN_DTC_ MYLOG(0, "SQL_ATTR_ENLIST_IN_DTC %p request received\n", Value); if (conn->connInfo.xa_opt != 0) { /* * When a new global transaction is about * to begin, isolate the existent global * transaction. */ if (NULL != Value && CC_is_in_global_trans(conn)) CALL_IsolateDtcConn(conn, TRUE); return CALL_EnlistInDtc(conn, Value, conn->connInfo.xa_opt); } #endif /* _HANDLE_ENLIST_IN_DTC_ */ #endif /* WIN32 */ unsupported = TRUE; break; case SQL_ATTR_AUTO_IPD: if (SQL_FALSE != Value) unsupported = TRUE; break; case SQL_ATTR_ASYNC_ENABLE: case SQL_ATTR_CONNECTION_DEAD: case SQL_ATTR_CONNECTION_TIMEOUT: unsupported = TRUE; break; case SQL_ATTR_PGOPT_DEBUG: newValue = CAST_UPTR(SQLCHAR, Value); if (newValue > 0) { logs_on_off(-1, conn->connInfo.drivers.debug, 0); conn->connInfo.drivers.debug = newValue; logs_on_off(1, conn->connInfo.drivers.debug, 0); MYLOG(0, "debug => %d\n", conn->connInfo.drivers.debug); } else if (newValue == 0 && conn->connInfo.drivers.debug > 0) { MYLOG(0, "debug => %d\n", newValue); logs_on_off(-1, conn->connInfo.drivers.debug, 0); conn->connInfo.drivers.debug = newValue; logs_on_off(1, 0, 0); } break; case SQL_ATTR_PGOPT_COMMLOG: newValue = CAST_UPTR(SQLCHAR, Value); if (newValue > 0) { logs_on_off(-1, 0, conn->connInfo.drivers.commlog); conn->connInfo.drivers.commlog = newValue; logs_on_off(1, 0, conn->connInfo.drivers.commlog); MYLOG(0, "commlog => %d\n", conn->connInfo.drivers.commlog); } else if (newValue == 0 && conn->connInfo.drivers.commlog > 0) { MYLOG(0, "commlog => %d\n", newValue); logs_on_off(-1, 0, conn->connInfo.drivers.commlog); conn->connInfo.drivers.debug = newValue; logs_on_off(1, 0, 0); } break; case SQL_ATTR_PGOPT_PARSE: conn->connInfo.drivers.parse = CAST_UPTR(SQLCHAR, Value); MYLOG(0, "parse => %d\n", conn->connInfo.drivers.parse); break; case SQL_ATTR_PGOPT_USE_DECLAREFETCH: conn->connInfo.drivers.use_declarefetch = CAST_UPTR(SQLCHAR, Value); ci_updatable_cursors_set(&conn->connInfo); MYLOG(0, "declarefetch => %d\n", conn->connInfo.drivers.use_declarefetch); break; case SQL_ATTR_PGOPT_SERVER_SIDE_PREPARE: conn->connInfo.use_server_side_prepare = CAST_UPTR(SQLCHAR, Value); MYLOG(0, "server_side_prepare => %d\n", conn->connInfo.use_server_side_prepare); break; case SQL_ATTR_PGOPT_FETCH: conn->connInfo.drivers.fetch_max = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "fetch => %d\n", conn->connInfo.drivers.fetch_max); break; case SQL_ATTR_PGOPT_UNKNOWNSIZES: conn->connInfo.drivers.unknown_sizes = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "unknown_sizes => %d\n", conn->connInfo.drivers.unknown_sizes); break; case SQL_ATTR_PGOPT_TEXTASLONGVARCHAR: conn->connInfo.drivers.text_as_longvarchar = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "text_as_longvarchar => %d\n", conn->connInfo.drivers.text_as_longvarchar); break; case SQL_ATTR_PGOPT_UNKNOWNSASLONGVARCHAR: conn->connInfo.drivers.unknowns_as_longvarchar = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "unknowns_as_long_varchar => %d\n", conn->connInfo.drivers.unknowns_as_longvarchar); break; case SQL_ATTR_PGOPT_BOOLSASCHAR: conn->connInfo.drivers.bools_as_char = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "bools_as_char => %d\n", conn->connInfo.drivers.bools_as_char); break; case SQL_ATTR_PGOPT_MAXVARCHARSIZE: conn->connInfo.drivers.max_varchar_size = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "max_varchar_size => %d\n", conn->connInfo.drivers.max_varchar_size); break; case SQL_ATTR_PGOPT_MAXLONGVARCHARSIZE: conn->connInfo.drivers.max_longvarchar_size = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "max_longvarchar_size => %d\n", conn->connInfo.drivers.max_longvarchar_size); break; case SQL_ATTR_PGOPT_WCSDEBUG: conn->connInfo.wcs_debug = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "wcs_debug => %d\n", conn->connInfo.wcs_debug); break; case SQL_ATTR_PGOPT_MSJET: conn->ms_jet = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "ms_jet => %d\n", conn->ms_jet); break; case SQL_ATTR_PGOPT_BATCHSIZE: conn->connInfo.batch_size = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "batch size => %d\n", conn->connInfo.batch_size); break; case SQL_ATTR_PGOPT_IGNORETIMEOUT: conn->connInfo.ignore_timeout = CAST_PTR(SQLINTEGER, Value); MYLOG(0, "ignore_timeout => %d\n", conn->connInfo.ignore_timeout); break; default: if (Attribute < 65536) ret = PGAPI_SetConnectOption(ConnectionHandle, (SQLUSMALLINT) Attribute, (SQLLEN) Value); else unsupported = TRUE; } if (unsupported) { char msg[64]; SPRINTF_FIXED(msg, "Couldn't set unsupported connect attribute " FORMAT_INTEGER, Attribute); CC_set_error(conn, CONN_OPTION_NOT_FOR_THE_DRIVER, msg, func); return SQL_ERROR; } return ret; } /* new function */ RETCODE SQL_API PGAPI_GetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength) { CSTR func = "PGAPI_GetDescField"; RETCODE ret = SQL_SUCCESS; DescriptorClass *desc = (DescriptorClass *) DescriptorHandle; MYLOG(0, "entering h=%p rec=" FORMAT_SMALLI " field=" FORMAT_SMALLI " blen=" FORMAT_INTEGER "\n", DescriptorHandle, RecNumber, FieldIdentifier, BufferLength); switch (DC_get_desc_type(desc)) { case SQL_ATTR_APP_ROW_DESC: ret = ARDGetField(desc, RecNumber, FieldIdentifier, Value, BufferLength, StringLength); break; case SQL_ATTR_APP_PARAM_DESC: ret = APDGetField(desc, RecNumber, FieldIdentifier, Value, BufferLength, StringLength); break; case SQL_ATTR_IMP_ROW_DESC: ret = IRDGetField(desc, RecNumber, FieldIdentifier, Value, BufferLength, StringLength); break; case SQL_ATTR_IMP_PARAM_DESC: ret = IPDGetField(desc, RecNumber, FieldIdentifier, Value, BufferLength, StringLength); break; default:ret = SQL_ERROR; DC_set_error(desc, DESC_INTERNAL_ERROR, "Error not implemented"); } if (ret == SQL_ERROR) { if (!DC_get_errormsg(desc)) { switch (DC_get_errornumber(desc)) { case DESC_INVALID_DESCRIPTOR_IDENTIFIER: DC_set_errormsg(desc, "can't SQLGetDescField for this descriptor identifier"); break; case DESC_INVALID_COLUMN_NUMBER_ERROR: DC_set_errormsg(desc, "can't SQLGetDescField for this column number"); break; case DESC_BAD_PARAMETER_NUMBER_ERROR: DC_set_errormsg(desc, "can't SQLGetDescField for this parameter number"); break; } } DC_log_error(func, "", desc); } return ret; } /* new function */ RETCODE SQL_API PGAPI_SetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength) { CSTR func = "PGAPI_SetDescField"; RETCODE ret = SQL_SUCCESS; DescriptorClass *desc = (DescriptorClass *) DescriptorHandle; MYLOG(0, "entering h=%p(%d) rec=" FORMAT_SMALLI " field=" FORMAT_SMALLI " val=%p," FORMAT_INTEGER "\n", DescriptorHandle, DC_get_desc_type(desc), RecNumber, FieldIdentifier, Value, BufferLength); switch (DC_get_desc_type(desc)) { case SQL_ATTR_APP_ROW_DESC: ret = ARDSetField(desc, RecNumber, FieldIdentifier, Value, BufferLength); break; case SQL_ATTR_APP_PARAM_DESC: ret = APDSetField(desc, RecNumber, FieldIdentifier, Value, BufferLength); break; case SQL_ATTR_IMP_ROW_DESC: ret = IRDSetField(desc, RecNumber, FieldIdentifier, Value, BufferLength); break; case SQL_ATTR_IMP_PARAM_DESC: ret = IPDSetField(desc, RecNumber, FieldIdentifier, Value, BufferLength); break; default:ret = SQL_ERROR; DC_set_error(desc, DESC_INTERNAL_ERROR, "Error not implemented"); } if (ret == SQL_ERROR) { if (!DC_get_errormsg(desc)) { switch (DC_get_errornumber(desc)) { case DESC_INVALID_DESCRIPTOR_IDENTIFIER: DC_set_errormsg(desc, "can't SQLSetDescField for this descriptor identifier"); break; case DESC_INVALID_COLUMN_NUMBER_ERROR: DC_set_errormsg(desc, "can't SQLSetDescField for this column number"); break; case DESC_BAD_PARAMETER_NUMBER_ERROR: DC_set_errormsg(desc, "can't SQLSetDescField for this parameter number"); break; break; } } DC_log_error(func, "", desc); } return ret; } /* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */ RETCODE SQL_API PGAPI_SetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength) { RETCODE ret = SQL_SUCCESS; CSTR func = "PGAPI_SetStmtAttr"; StatementClass *stmt = (StatementClass *) StatementHandle; MYLOG(0, "entering Handle=%p " FORMAT_INTEGER "," FORMAT_ULEN "(%p)\n", StatementHandle, Attribute, (SQLULEN) Value, Value); switch (Attribute) { case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ if (SQL_FALSE == Value) break; case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ case SQL_ATTR_AUTO_IPD: /* 10001 */ SC_set_error(stmt, DESC_OPTION_NOT_FOR_THE_DRIVER, "Unsupported statement option (Set)", func); return SQL_ERROR; /* case SQL_ATTR_ROW_BIND_TYPE: ** == SQL_BIND_TYPE(ODBC2.0) */ case SQL_ATTR_IMP_ROW_DESC: /* 10012 (read-only) */ case SQL_ATTR_IMP_PARAM_DESC: /* 10013 (read-only) */ /* * case SQL_ATTR_PREDICATE_PTR: case * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */ SC_set_error(stmt, DESC_INVALID_OPTION_IDENTIFIER, "Unsupported statement option (Set)", func); return SQL_ERROR; case SQL_ATTR_METADATA_ID: /* 10014 */ stmt->options.metadata_id = CAST_UPTR(SQLUINTEGER, Value); break; case SQL_ATTR_APP_ROW_DESC: /* 10010 */ if (SQL_NULL_HDESC == Value) { stmt->ard = &(stmt->ardi); } else { stmt->ard = (DescriptorClass *) Value; MYLOG(DETAIL_LOG_LEVEL, "set ard=%p\n", stmt->ard); } break; case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ if (SQL_NULL_HDESC == Value) { stmt->apd = &(stmt->apdi); } else { stmt->apd = (DescriptorClass *) Value; } break; case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ stmt->options.bookmark_ptr = Value; break; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ SC_get_APDF(stmt)->param_offset_ptr = (SQLULEN *) Value; break; case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ SC_get_APDF(stmt)->param_bind_type = CAST_UPTR(SQLUINTEGER, Value); break; case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ SC_get_APDF(stmt)->param_operation_ptr = Value; break; case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ SC_get_IPDF(stmt)->param_status_ptr = (SQLUSMALLINT *) Value; break; case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ SC_get_IPDF(stmt)->param_processed_ptr = (SQLULEN *) Value; break; case SQL_ATTR_PARAMSET_SIZE: /* 22 */ SC_get_APDF(stmt)->paramset_size = CAST_UPTR(SQLULEN, Value); break; case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ SC_get_ARDF(stmt)->row_offset_ptr = (SQLULEN *) Value; break; case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ SC_get_ARDF(stmt)->row_operation_ptr = Value; break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ SC_get_IRDF(stmt)->rowStatusArray = (SQLUSMALLINT *) Value; break; case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ SC_get_IRDF(stmt)->rowsFetched = (SQLULEN *) Value; break; case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ SC_get_ARDF(stmt)->size_of_rowset = CAST_UPTR(SQLULEN, Value); break; default: return PGAPI_SetStmtOption(StatementHandle, (SQLUSMALLINT) Attribute, (SQLULEN) Value); } return ret; } /* SQL_NEED_DATA callback for PGAPI_BulkOperations */ typedef struct { StatementClass *stmt; SQLSMALLINT operation; char need_data_callback; char auto_commit_needed; ARDFields *opts; int idx, processed; } bop_cdata; static RETCODE bulk_ope_callback(RETCODE retcode, void *para) { CSTR func = "bulk_ope_callback"; RETCODE ret = retcode; bop_cdata *s = (bop_cdata *) para; SQLULEN global_idx; ConnectionClass *conn; QResultClass *res; IRDFields *irdflds; PG_BM pg_bm; if (s->need_data_callback) { MYLOG(0, "entering in\n"); s->processed++; s->idx++; } else { s->idx = s->processed = 0; } s->need_data_callback = FALSE; res = SC_get_Curres(s->stmt); for (; SQL_ERROR != ret && s->idx < s->opts->size_of_rowset; s->idx++) { if (SQL_ADD != s->operation) { pg_bm = SC_Resolve_bookmark(s->opts, s->idx); QR_get_last_bookmark(res, s->idx, &pg_bm.keys); global_idx = pg_bm.index; } /* Note opts->row_operation_ptr is ignored */ switch (s->operation) { case SQL_ADD: ret = SC_pos_add(s->stmt, (UWORD) s->idx); break; case SQL_UPDATE_BY_BOOKMARK: ret = SC_pos_update(s->stmt, (UWORD) s->idx, global_idx, &(pg_bm.keys)); break; case SQL_DELETE_BY_BOOKMARK: ret = SC_pos_delete(s->stmt, (UWORD) s->idx, global_idx, &(pg_bm.keys)); break; } if (SQL_NEED_DATA == ret) { bop_cdata *cbdata = (bop_cdata *) malloc(sizeof(bop_cdata)); if (!cbdata) { SC_set_error(s->stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for cbdata.", func); return SQL_ERROR; } memcpy(cbdata, s, sizeof(bop_cdata)); cbdata->need_data_callback = TRUE; if (0 == enqueueNeedDataCallback(s->stmt, bulk_ope_callback, cbdata)) ret = SQL_ERROR; return ret; } s->processed++; } conn = SC_get_conn(s->stmt); if (s->auto_commit_needed) CC_set_autocommit(conn, TRUE); irdflds = SC_get_IRDF(s->stmt); if (irdflds->rowsFetched) *(irdflds->rowsFetched) = s->processed; if (res) res->recent_processed_row_count = s->stmt->diag_row_count = s->processed; return ret; } RETCODE SQL_API PGAPI_BulkOperations(HSTMT hstmt, SQLSMALLINT operationX) { CSTR func = "PGAPI_BulkOperations"; bop_cdata s; RETCODE ret; ConnectionClass *conn; BindInfoClass *bookmark; MYLOG(0, "entering operation = %d\n", operationX); s.stmt = (StatementClass *) hstmt; s.operation = operationX; SC_clear_error(s.stmt); s.opts = SC_get_ARDF(s.stmt); s.auto_commit_needed = FALSE; if (SQL_FETCH_BY_BOOKMARK != s.operation) { conn = SC_get_conn(s.stmt); if (s.auto_commit_needed = (char) CC_does_autocommit(conn), s.auto_commit_needed) CC_set_autocommit(conn, FALSE); } if (SQL_ADD != s.operation) { if (!(bookmark = s.opts->bookmark) || !(bookmark->buffer)) { SC_set_error(s.stmt, DESC_INVALID_OPTION_IDENTIFIER, "bookmark isn't specified", func); return SQL_ERROR; } } /* StartRollbackState(s.stmt); */ if (SQL_FETCH_BY_BOOKMARK == operationX) ret = SC_fetch_by_bookmark(s.stmt); else { s.need_data_callback = FALSE; ret = bulk_ope_callback(SQL_SUCCESS, &s); } return ret; } psqlodbc-REL-16_00_0005/pgapifunc.h000066400000000000000000000326141462406103600166310ustar00rootroot00000000000000/*------- * Module: pgapifunc.h * *------- */ #ifndef _PG_API_FUNC_H__ #define _PG_API_FUNC_H__ #include "psqlodbc.h" #include #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Internal flags for catalog functions */ #define PODBC_NOT_SEARCH_PATTERN 1L #define PODBC_SEARCH_PUBLIC_SCHEMA (1L << 1) #define PODBC_SEARCH_BY_IDS (1L << 2) #define PODBC_SHOW_OID_COLUMN (1L << 3) #define PODBC_ROW_VERSIONING (1L << 4) /* Internal flags for PGAPI_AllocStmt functions */ #define PODBC_EXTERNAL_STATEMENT 1L /* visible to the driver manager */ #define PODBC_INHERIT_CONNECT_OPTIONS (1L << 1) /* Internal flags for PGAPI_Exec... functions */ #define PODBC_WITH_HOLD 1L #define PODBC_RDONLY (1L << 1) #define PODBC_RECYCLE_STATEMENT (1L << 2) /* Flags for the error handling */ #define PODBC_ALLOW_PARTIAL_EXTRACT 1L /* #define PODBC_ERROR_CLEAR (1L << 1) no longer used */ RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, HDBC * ConnectionHandle); RETCODE SQL_API PGAPI_AllocEnv(HENV * EnvironmentHandle); RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle, HSTMT *StatementHandle, UDWORD flag); RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, PTR TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind); RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle); RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle, const SQLCHAR *CatalogName, SQLSMALLINT NameLength1, const SQLCHAR *SchemaName, SQLSMALLINT NameLength2, const SQLCHAR *TableName, SQLSMALLINT NameLength3, const SQLCHAR *ColumnName, SQLSMALLINT NameLength4, UWORD flag, OID reloid, Int2 attnum); RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle, const SQLCHAR *ServerName, SQLSMALLINT NameLength1, const SQLCHAR *UserName, SQLSMALLINT NameLength2, const SQLCHAR *Authentication, SQLSMALLINT NameLength3); RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, const SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT * pcbConnStrOut, SQLUSMALLINT fDriverCompletion); RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc, const SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut); RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle, SQLUSMALLINT Direction, const SQLCHAR *ServerName, SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, const SQLCHAR *Description, SQLSMALLINT BufferLength2, SQLSMALLINT *NameLength2); RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType, SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable); RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle); RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle, HDBC ConnectionHandle, HSTMT StatementHandle, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength); /* Helper functions for Error handling */ RETCODE SQL_API PGAPI_EnvError(HENV EnvironmentHandle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength, UWORD flag); RETCODE SQL_API PGAPI_ConnectError(HDBC ConnectionHandle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength, UWORD flag); RETCODE SQL_API PGAPI_StmtError(HSTMT StatementHandle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength, UWORD flag); RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle, const SQLCHAR *StatementText, SQLINTEGER TextLength, UWORD flag); RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle, UWORD flag); RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle); RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle); RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle); RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle, SQLUSMALLINT Option); RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle, SQLUSMALLINT Option, PTR Value, SQLINTEGER *StringLength, SQLINTEGER BufferLength); RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength); RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, PTR TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind); RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle, SQLUSMALLINT InfoType, PTR InfoValue, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength); RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle, SQLUSMALLINT Option, PTR Value, SQLINTEGER *StringLength, SQLINTEGER BufferLength); RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle, SQLSMALLINT DataType); RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle, SQLSMALLINT *ColumnCount); RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle, PTR *Value); RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle, const SQLCHAR *StatementText, SQLINTEGER TextLength); RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle, PTR Data, SQLLEN StrLen_or_Ind); RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle, SQLLEN *RowCount); RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle, SQLUSMALLINT Option, SQLULEN Value); RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle, const SQLCHAR *CursorName, SQLSMALLINT NameLength); RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle, SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, SQLSMALLINT ParameterType, SQLULEN LengthPrecision, SQLSMALLINT ParameterScale, PTR ParameterValue, SQLLEN *StrLen_or_Ind); RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle, SQLUSMALLINT Option, SQLULEN Value); RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle, SQLUSMALLINT IdentifierType, const SQLCHAR *CatalogName, SQLSMALLINT NameLength1, const SQLCHAR *SchemaName, SQLSMALLINT NameLength2, const SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Scope, SQLUSMALLINT Nullable); RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle, const SQLCHAR *CatalogName, SQLSMALLINT NameLength1, const SQLCHAR *SchemaName, SQLSMALLINT NameLength2, const SQLCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Unique, SQLUSMALLINT Reserved); RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle, const SQLCHAR *CatalogName, SQLSMALLINT NameLength1, const SQLCHAR *SchemaName, SQLSMALLINT NameLength2, const SQLCHAR *TableName, SQLSMALLINT NameLength3, const SQLCHAR *TableType, SQLSMALLINT NameLength4, UWORD flag); RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle, HDBC ConnectionHandle, SQLUSMALLINT CompletionType); RETCODE SQL_API PGAPI_ColAttributes( HSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, PTR rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT *pcbDesc, SQLLEN *pfDesc); RETCODE SQL_API PGAPI_ColumnPrivileges( HSTMT hstmt, const SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, const SQLCHAR *szTableName, SQLSMALLINT cbTableName, const SQLCHAR *szColumnName, SQLSMALLINT cbColumnName, UWORD flag); RETCODE SQL_API PGAPI_DescribeParam( HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT *pfSqlType, SQLULEN *pcbParamDef, SQLSMALLINT *pibScale, SQLSMALLINT *pfNullable); RETCODE SQL_API PGAPI_ExtendedFetch( HSTMT hstmt, SQLUSMALLINT fFetchType, SQLLEN irow, SQLULEN *pcrow, SQLUSMALLINT *rgfRowStatus, SQLLEN FetchOffset, SQLLEN rowsetSize); RETCODE SQL_API PGAPI_ForeignKeys( HSTMT hstmt, const SQLCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName, const SQLCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName, const SQLCHAR *szPkTableName, SQLSMALLINT cbPkTableName, const SQLCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName, const SQLCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName, const SQLCHAR *szFkTableName, SQLSMALLINT cbFkTableName); RETCODE SQL_API PGAPI_MoreResults( HSTMT hstmt); RETCODE SQL_API PGAPI_NativeSql( HDBC hdbc, const SQLCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLCHAR *szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr); RETCODE SQL_API PGAPI_NumParams( HSTMT hstmt, SQLSMALLINT *pcpar); RETCODE SQL_API PGAPI_ParamOptions( HSTMT hstmt, SQLULEN crow, SQLULEN *pirow); RETCODE SQL_API PGAPI_PrimaryKeys( HSTMT hstmt, const SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, const SQLCHAR *szTableName, SQLSMALLINT cbTableName, OID reloid); RETCODE SQL_API PGAPI_ProcedureColumns( HSTMT hstmt, const SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, const SQLCHAR *szProcName, SQLSMALLINT cbProcName, const SQLCHAR *szColumnName, SQLSMALLINT cbColumnName, UWORD flag); RETCODE SQL_API PGAPI_Procedures( HSTMT hstmt, const SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, const SQLCHAR *szProcName, SQLSMALLINT cbProcName, UWORD flag); RETCODE SQL_API PGAPI_SetPos( HSTMT hstmt, SQLSETPOSIROW irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock); RETCODE SQL_API PGAPI_TablePrivileges( HSTMT hstmt, const SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, const SQLCHAR *szTableName, SQLSMALLINT cbTableName, UWORD flag); RETCODE SQL_API PGAPI_BindParameter( HSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fParamType, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue); RETCODE SQL_API PGAPI_SetScrollOptions( HSTMT hstmt, SQLUSMALLINT fConcurrency, SQLLEN crowKeyset, SQLUSMALLINT crowRowset); RETCODE SQL_API PGAPI_GetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength); RETCODE SQL_API PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, PTR DiagInfoPtr, SQLSMALLINT BufferLength, SQLSMALLINT *StringLengthPtr); RETCODE SQL_API PGAPI_GetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength); RETCODE SQL_API PGAPI_GetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength); /* Driver-specific connection attributes, for SQLSet/GetConnectAttr() */ enum { SQL_ATTR_PGOPT_DEBUG = 65536 ,SQL_ATTR_PGOPT_COMMLOG = 65537 ,SQL_ATTR_PGOPT_PARSE = 65538 ,SQL_ATTR_PGOPT_USE_DECLAREFETCH = 65539 ,SQL_ATTR_PGOPT_SERVER_SIDE_PREPARE = 65540 ,SQL_ATTR_PGOPT_FETCH = 65541 ,SQL_ATTR_PGOPT_UNKNOWNSIZES = 65542 ,SQL_ATTR_PGOPT_TEXTASLONGVARCHAR = 65543 ,SQL_ATTR_PGOPT_UNKNOWNSASLONGVARCHAR = 65544 ,SQL_ATTR_PGOPT_BOOLSASCHAR = 65545 ,SQL_ATTR_PGOPT_MAXVARCHARSIZE = 65546 ,SQL_ATTR_PGOPT_MAXLONGVARCHARSIZE = 65547 ,SQL_ATTR_PGOPT_WCSDEBUG = 65548 ,SQL_ATTR_PGOPT_MSJET = 65549 ,SQL_ATTR_PGOPT_BATCHSIZE = 65550 ,SQL_ATTR_PGOPT_IGNORETIMEOUT = 65551 }; RETCODE SQL_API PGAPI_SetConnectAttr(HDBC ConnectionHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength); RETCODE SQL_API PGAPI_SetStmtAttr(HSTMT StatementHandle, SQLINTEGER Attribute, PTR Value, SQLINTEGER StringLength); RETCODE SQL_API PGAPI_BulkOperations(HSTMT StatementHandle, SQLSMALLINT operation); RETCODE SQL_API PGAPI_AllocDesc(HDBC ConnectionHandle, SQLHDESC *DescriptorHandle); RETCODE SQL_API PGAPI_FreeDesc(SQLHDESC DescriptorHandle); RETCODE SQL_API PGAPI_CopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle); RETCODE SQL_API PGAPI_SetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength); RETCODE SQL_API PGAPI_GetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, PTR Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength); RETCODE SQL_API PGAPI_DescError(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength, UWORD flag); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* define_PG_API_FUNC_H__ */ psqlodbc-REL-16_00_0005/pgenlist.def000066400000000000000000000001041462406103600167760ustar00rootroot00000000000000LIBRARY pgenlist EXPORTS EnlistInDtc DtcOnDisconnect IsolateDtcConn psqlodbc-REL-16_00_0005/pgenlist.h000066400000000000000000000016411462406103600164760ustar00rootroot00000000000000/* File: enlist.h * * Description: See "msdtc_enlist.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __PGENLIST_H__ #define __PGENLIST_H__ #ifdef __cplusplus extern "C" { #endif #ifdef WIN32 #ifdef _HANDLE_ENLIST_IN_DTC_ #undef DLL_DECLARE #ifdef _PGENLIST_FUNCS_IMPLEMENT_ #define DLL_DECLARE _declspec(dllexport) #else #ifdef _PGENLIST_FUNCS_IMPORT_ #define DLL_DECLARE _declspec(dllimport) #else #define DLL_DECLARE #endif /* _PGENLIST_FUNCS_IMPORT_ */ #endif /* _PGENLIST_FUNCS_IMPLEMENT_ */ RETCODE EnlistInDtc(void *conn, void *pTra, int method); RETCODE DtcOnDisconnect(void *); RETCODE IsolateDtcConn(void *, BOOL continueConnection); // for testing DLL_DECLARE void *GetTransactionObject(HRESULT *hres); DLL_DECLARE void ReleaseTransactionObject(void *); #endif /* _HANDLE_ENLIST_IN_DTC_ */ #endif /* WIN32 */ #ifdef __cplusplus } #endif #endif /* __PGENLIST_H__ */ psqlodbc-REL-16_00_0005/pgenlista.def000066400000000000000000000001051462406103600171400ustar00rootroot00000000000000LIBRARY pgenlista EXPORTS EnlistInDtc DtcOnDisconnect IsolateDtcConn psqlodbc-REL-16_00_0005/pgtypes.c000066400000000000000000001412071462406103600163420ustar00rootroot00000000000000/*-------- * Module: pgtypes.c * * Description: This module contains routines for getting information * about the supported Postgres data types. Only the * function pgtype_to_sqltype() returns an unknown condition. * All other functions return a suitable default so that * even data types that are not directly supported can be * used (it is handled as char data). * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *-------- */ #include "pgtypes.h" #include "dlg_specific.h" #include "statement.h" #include "connection.h" #include "environ.h" #include "qresult.h" #define EXPERIMENTAL_CURRENTLY SQLSMALLINT ansi_to_wtype(const ConnectionClass *self, SQLSMALLINT ansitype) { #ifndef UNICODE_SUPPORT return ansitype; #else if (!ALLOW_WCHAR(self)) return ansitype; switch (ansitype) { case SQL_CHAR: return SQL_WCHAR; case SQL_VARCHAR: return SQL_WVARCHAR; case SQL_LONGVARCHAR: return SQL_WLONGVARCHAR; } return ansitype; #endif /* UNICODE_SUPPORT */ } Int4 getCharColumnSize(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); /* * these are the types we support. all of the pgtype_ functions should * return values for each one of these. * Even types not directly supported are handled as character types * so all types should work (points, etc.) */ /* * ALL THESE TYPES ARE NO LONGER REPORTED in SQLGetTypeInfo. Instead, all * the SQL TYPES are reported and mapped to a corresponding Postgres Type */ /* OID pgtypes_defined[][2] = { {PG_TYPE_CHAR, 0} ,{PG_TYPE_CHAR2, 0} ,{PG_TYPE_CHAR4, 0} ,{PG_TYPE_CHAR8, 0} ,{PG_TYPE_CHAR16, 0} ,{PG_TYPE_NAME, 0} ,{PG_TYPE_VARCHAR, 0} ,{PG_TYPE_BPCHAR, 0} ,{PG_TYPE_DATE, 0} ,{PG_TYPE_TIME, 0} ,{PG_TYPE_TIME_WITH_TMZONE, 0} ,{PG_TYPE_DATETIME, 0} ,{PG_TYPE_ABSTIME, 0} ,{PG_TYPE_TIMESTAMP_NO_TMZONE, 0} ,{PG_TYPE_TIMESTAMP, 0} ,{PG_TYPE_TEXT, 0} ,{PG_TYPE_INT2, 0} ,{PG_TYPE_INT4, 0} ,{PG_TYPE_FLOAT4, 0} ,{PG_TYPE_FLOAT8, 0} ,{PG_TYPE_OID, 0} ,{PG_TYPE_MONEY, 0} ,{PG_TYPE_BOOL, 0} ,{PG_TYPE_BYTEA, 0} ,{PG_TYPE_NUMERIC, 0} ,{PG_TYPE_XID, 0} ,{PG_TYPE_LO_UNDEFINED, 0} ,{0, 0} }; */ /* These are NOW the SQL Types reported in SQLGetTypeInfo. */ SQLSMALLINT sqlTypes[] = { SQL_BIGINT, /* SQL_BINARY, -- Commented out because VarBinary is more correct. */ SQL_BIT, SQL_CHAR, SQL_TYPE_DATE, SQL_DATE, SQL_DECIMAL, SQL_DOUBLE, SQL_FLOAT, SQL_INTEGER, SQL_LONGVARBINARY, SQL_LONGVARCHAR, SQL_NUMERIC, SQL_REAL, SQL_SMALLINT, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP, SQL_TIME, SQL_TIMESTAMP, SQL_TINYINT, SQL_VARBINARY, SQL_VARCHAR, #ifdef UNICODE_SUPPORT SQL_WCHAR, SQL_WVARCHAR, SQL_WLONGVARCHAR, #endif /* UNICODE_SUPPORT */ SQL_GUID, /* AFAIK SQL_INTERVAL types cause troubles in some spplications */ #ifdef PG_INTERVAL_AS_SQL_INTERVAL SQL_INTERVAL_MONTH, SQL_INTERVAL_YEAR, SQL_INTERVAL_YEAR_TO_MONTH, SQL_INTERVAL_DAY, SQL_INTERVAL_HOUR, SQL_INTERVAL_MINUTE, SQL_INTERVAL_SECOND, SQL_INTERVAL_DAY_TO_HOUR, SQL_INTERVAL_DAY_TO_MINUTE, SQL_INTERVAL_DAY_TO_SECOND, SQL_INTERVAL_HOUR_TO_MINUTE, SQL_INTERVAL_HOUR_TO_SECOND, SQL_INTERVAL_MINUTE_TO_SECOND, #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ 0 }; #ifdef ODBCINT64 #define ALLOWED_C_BIGINT SQL_C_SBIGINT /* #define ALLOWED_C_BIGINT SQL_C_CHAR */ /* Delphi should be either ? */ #else #define ALLOWED_C_BIGINT SQL_C_CHAR #endif OID pg_true_type(const ConnectionClass *conn, OID type, OID basetype) { if (0 == basetype) return type; else if (0 == type) return basetype; else if (type == conn->lobj_type) return type; return basetype; } #define MONTH_BIT (1 << 17) #define YEAR_BIT (1 << 18) #define DAY_BIT (1 << 19) #define HOUR_BIT (1 << 26) #define MINUTE_BIT (1 << 27) #define SECOND_BIT (1 << 28) static SQLSMALLINT get_interval_type(Int4 atttypmod, const char **name) { MYLOG(0, "entering atttypmod=%x\n", atttypmod); if ((-1) == atttypmod) return 0; if (0 != (YEAR_BIT & atttypmod)) { if (0 != (MONTH_BIT & atttypmod)) { if (name) *name = "interval year to month"; return SQL_INTERVAL_YEAR_TO_MONTH; } if (name) *name = "interval year"; return SQL_INTERVAL_YEAR; } else if (0 != (MONTH_BIT & atttypmod)) { if (name) *name = "interval month"; return SQL_INTERVAL_MONTH; } else if (0 != (DAY_BIT & atttypmod)) { if (0 != (SECOND_BIT & atttypmod)) { if (name) *name = "interval day to second"; return SQL_INTERVAL_DAY_TO_SECOND; } else if (0 != (MINUTE_BIT & atttypmod)) { if (name) *name = "interval day to minute"; return SQL_INTERVAL_DAY_TO_MINUTE; } else if (0 != (HOUR_BIT & atttypmod)) { if (name) *name = "interval day to hour"; return SQL_INTERVAL_DAY_TO_HOUR; } if (name) *name = "interval day"; return SQL_INTERVAL_DAY; } else if (0 != (HOUR_BIT & atttypmod)) { if (0 != (SECOND_BIT & atttypmod)) { if (name) *name = "interval hour to second"; return SQL_INTERVAL_HOUR_TO_SECOND; } else if (0 != (MINUTE_BIT & atttypmod)) { if (name) *name = "interval hour to minute"; return SQL_INTERVAL_HOUR_TO_MINUTE; } if (name) *name = "interval hour"; return SQL_INTERVAL_HOUR; } else if (0 != (MINUTE_BIT & atttypmod)) { if (0 != (SECOND_BIT & atttypmod)) { if (name) *name = "interval minute to second"; return SQL_INTERVAL_MINUTE_TO_SECOND; } if (name) *name = "interval minute"; return SQL_INTERVAL_MINUTE; } else if (0 != (SECOND_BIT & atttypmod)) { if (name) *name = "interval second"; return SQL_INTERVAL_SECOND; } if (name) *name = "interval"; return 0; } static Int4 getCharColumnSizeX(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { int p = -1, maxsize; const ConnInfo *ci = &(conn->connInfo); MYLOG(0, "entering type=%d, atttypmod=%d, adtsize_or=%d, unknown = %d\n", type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); /* Assign Maximum size based on parameters */ switch (type) { case PG_TYPE_TEXT: if (ci->drivers.text_as_longvarchar) maxsize = ci->drivers.max_longvarchar_size; else maxsize = ci->drivers.max_varchar_size; break; case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: maxsize = ci->drivers.max_varchar_size; break; default: if (ci->drivers.unknowns_as_longvarchar) maxsize = ci->drivers.max_longvarchar_size; else maxsize = ci->drivers.max_varchar_size; break; } #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn) && isSqlServr() && maxsize > 4000) maxsize = 4000; #endif /* UNICODE_SUPPORT */ if (maxsize == TEXT_FIELD_SIZE + 1) /* magic length for testing */ maxsize = 0; /* * Static ColumnSize (i.e., the Maximum ColumnSize of the datatype) This * has nothing to do with a result set. */ MYLOG(DETAIL_LOG_LEVEL, "!!! atttypmod < 0 ?\n"); if (atttypmod < 0 && adtsize_or_longestlen < 0) return maxsize; MYLOG(DETAIL_LOG_LEVEL, "!!! adtsize_or_logngest=%d\n", adtsize_or_longestlen); p = adtsize_or_longestlen; /* longest */ /* * Catalog Result Sets -- use assigned column width (i.e., from * set_tuplefield_string) */ MYLOG(DETAIL_LOG_LEVEL, "!!! catalog_result=%d\n", handle_unknown_size_as); if (UNKNOWNS_AS_LONGEST == handle_unknown_size_as) { MYLOG(0, "LONGEST: p = %d\n", p); if (p > 0 && (atttypmod < 0 || atttypmod > p)) return p; } if (TYPE_MAY_BE_ARRAY(type)) { if (p > 0) return p; return maxsize; } /* Size is unknown -- handle according to parameter */ if (atttypmod > 0) /* maybe the length is known */ { return atttypmod; } /* The type is really unknown */ switch (handle_unknown_size_as) { case UNKNOWNS_AS_DONTKNOW: return -1; case UNKNOWNS_AS_LONGEST: case UNKNOWNS_AS_MAX: break; default: return -1; } if (maxsize <= 0) return maxsize; switch (type) { case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: return maxsize; } if (p > maxsize) maxsize = p; return maxsize; } /* * Specify when handle_unknown_size_as parameter is unused */ #define UNUSED_HANDLE_UNKNOWN_SIZE_AS (-2) static SQLSMALLINT getNumericDecimalDigitsX(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int UNUSED_handle_unknown_size_as) { Int4 default_decimal_digits = 6; MYLOG(0, "entering type=%d, atttypmod=%d\n", type, atttypmod); if (atttypmod < 0 && adtsize_or_longest < 0) return default_decimal_digits; if (atttypmod > -1) return (atttypmod & 0xffff); if (adtsize_or_longest <= 0) return default_decimal_digits; adtsize_or_longest >>= 16; /* extract the scale part */ return adtsize_or_longest; } static Int4 /* PostgreSQL restritiction */ getNumericColumnSizeX(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int handle_unknown_size_as) { Int4 default_column_size = 28; const ConnInfo *ci = &(conn->connInfo); MYLOG(0, "entering type=%d, typmod=%d\n", type, atttypmod); if (atttypmod > -1) return (atttypmod >> 16) & 0xffff; switch (ci->numeric_as) { case SQL_VARCHAR: return ci->drivers.max_varchar_size; case SQL_LONGVARCHAR: return ci->drivers.max_longvarchar_size; case SQL_DOUBLE: return PG_DOUBLE_DIGITS; } switch (handle_unknown_size_as) { case UNKNOWNS_AS_DONTKNOW: return SQL_NO_TOTAL; } if (adtsize_or_longest <= 0) return default_column_size; adtsize_or_longest %= (1 << 16); /* extract the precision part */ switch (handle_unknown_size_as) { case UNKNOWNS_AS_MAX: return adtsize_or_longest > default_column_size ? adtsize_or_longest : default_column_size; default: if (adtsize_or_longest < 10) adtsize_or_longest = 10; } return adtsize_or_longest; } static SQLSMALLINT getTimestampDecimalDigitsX(const ConnectionClass *conn, OID type, int atttypmod) { MYLOG(0, "type=%d, atttypmod=%d\n", type, atttypmod); return (atttypmod > -1 ? atttypmod : 6); } static SQLSMALLINT getTimestampColumnSizeX(const ConnectionClass *conn, OID type, int atttypmod) { Int4 fixed, scale; MYLOG(0, "entering type=%d, atttypmod=%d\n", type, atttypmod); switch (type) { case PG_TYPE_TIME: fixed = 8; break; case PG_TYPE_TIME_WITH_TMZONE: fixed = 11; break; case PG_TYPE_TIMESTAMP_NO_TMZONE: fixed = 19; break; default: if (USE_ZONE) fixed = 22; else fixed = 19; break; } scale = getTimestampDecimalDigitsX(conn, type, atttypmod); return (scale > 0) ? fixed + 1 + scale : fixed; } static SQLSMALLINT getIntervalDecimalDigits(OID type, int atttypmod) { Int4 prec; MYLOG(0, "entering type=%d, atttypmod=%d\n", type, atttypmod); if ((atttypmod & SECOND_BIT) == 0) return 0; return (prec = atttypmod & 0xffff) == 0xffff ? 6 : prec ; } static SQLSMALLINT getIntervalColumnSize(OID type, int atttypmod) { Int4 ttl, leading_precision = 9, scale; MYLOG(0, "entering type=%d, atttypmod=%d\n", type, atttypmod); ttl = leading_precision; switch (get_interval_type(atttypmod, NULL)) { case 0: ttl = 25; break; case SQL_INTERVAL_YEAR: ttl = 16; break; case SQL_INTERVAL_MONTH: ttl = 16; break; case SQL_INTERVAL_DAY: ttl = 16; break; case SQL_INTERVAL_DAY_TO_SECOND: case SQL_INTERVAL_DAY_TO_MINUTE: case SQL_INTERVAL_DAY_TO_HOUR: ttl = 25; break; case SQL_INTERVAL_HOUR_TO_SECOND: case SQL_INTERVAL_HOUR_TO_MINUTE: case SQL_INTERVAL_HOUR: ttl = 17; break; case SQL_INTERVAL_MINUTE_TO_SECOND: case SQL_INTERVAL_MINUTE: ttl = 15; break; case SQL_INTERVAL_YEAR_TO_MONTH: ttl = 24; break; } scale = getIntervalDecimalDigits(type, atttypmod); return (scale > 0) ? ttl + 1 + scale : ttl; } SQLSMALLINT pgtype_attr_to_concise_type(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { const ConnInfo *ci = &(conn->connInfo); EnvironmentClass *env = (EnvironmentClass *) CC_get_env(conn); #ifdef PG_INTERVAL_AS_SQL_INTERVAL SQLSMALLINT sqltype; #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ BOOL bLongVarchar, bFixed = FALSE; switch (type) { case PG_TYPE_CHAR: return ansi_to_wtype(conn, SQL_CHAR); case PG_TYPE_NAME: case PG_TYPE_REFCURSOR: return ansi_to_wtype(conn, SQL_VARCHAR); case PG_TYPE_BPCHAR: bFixed = TRUE; case PG_TYPE_VARCHAR: if (getCharColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as) > ci->drivers.max_varchar_size) bLongVarchar = TRUE; else bLongVarchar = FALSE; return ansi_to_wtype(conn, bLongVarchar ? SQL_LONGVARCHAR : (bFixed ? SQL_CHAR : SQL_VARCHAR)); case PG_TYPE_TEXT: bLongVarchar = ci->drivers.text_as_longvarchar; if (bLongVarchar) { int column_size = getCharColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); if (column_size > 0 && column_size <= ci->drivers.max_varchar_size) bLongVarchar = FALSE; } return ansi_to_wtype(conn, bLongVarchar ? SQL_LONGVARCHAR : SQL_VARCHAR); case PG_TYPE_BYTEA: if (ci->bytea_as_longvarbinary) return SQL_LONGVARBINARY; else return SQL_VARBINARY; case PG_TYPE_LO_UNDEFINED: return SQL_LONGVARBINARY; case PG_TYPE_INT2: return SQL_SMALLINT; case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: return SQL_INTEGER; /* Change this to SQL_BIGINT for ODBC v3 bjm 2001-01-23 */ case PG_TYPE_INT8: if (ci->int8_as != 0) return ci->int8_as; if (conn->ms_jet) return SQL_NUMERIC; /* maybe a little better than SQL_VARCHAR */ return SQL_BIGINT; case PG_TYPE_NUMERIC: if (-1 == atttypmod && DEFAULT_NUMERIC_AS != ci->numeric_as) return ci->numeric_as; return SQL_NUMERIC; case PG_TYPE_FLOAT4: return SQL_REAL; case PG_TYPE_FLOAT8: return SQL_FLOAT; case PG_TYPE_DATE: if (EN_is_odbc3(env)) return SQL_TYPE_DATE; return SQL_DATE; case PG_TYPE_TIME: if (EN_is_odbc3(env)) return SQL_TYPE_TIME; return SQL_TIME; case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: if (EN_is_odbc3(env)) return SQL_TYPE_TIMESTAMP; return SQL_TIMESTAMP; case PG_TYPE_MONEY: return SQL_FLOAT; case PG_TYPE_BOOL: return ci->drivers.bools_as_char ? SQL_VARCHAR : SQL_BIT; case PG_TYPE_XML: return ansi_to_wtype(conn, SQL_LONGVARCHAR); case PG_TYPE_INET: case PG_TYPE_CIDR: case PG_TYPE_MACADDR: return ansi_to_wtype(conn, SQL_VARCHAR); case PG_TYPE_UUID: return SQL_GUID; case PG_TYPE_INTERVAL: #ifdef PG_INTERVAL_AS_SQL_INTERVAL if (sqltype = get_interval_type(atttypmod, NULL), 0 != sqltype) return sqltype; #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ return ansi_to_wtype(conn, SQL_VARCHAR); case PG_TYPE_BIT: if (1 == atttypmod) return SQL_BIT; else return SQL_VARCHAR; default: /* * first, check to see if 'type' is in list. If not, look up * with query. Add oid, name to list. If it's already in * list, just return. */ /* hack until permanent type is available */ if (type == conn->lobj_type) return SQL_LONGVARBINARY; bLongVarchar = ci->drivers.unknowns_as_longvarchar; if (bLongVarchar) { int column_size = getCharColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); if (column_size > 0 && column_size <= ci->drivers.max_varchar_size) bLongVarchar = FALSE; } #ifdef EXPERIMENTAL_CURRENTLY return ansi_to_wtype(conn, bLongVarchar ? SQL_LONGVARCHAR : SQL_VARCHAR); #endif /* EXPERIMENTAL_CURRENTLY */ return bLongVarchar ? SQL_LONGVARCHAR : SQL_VARCHAR; } } SQLSMALLINT pgtype_attr_to_sqldesctype(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { SQLSMALLINT rettype; #ifdef PG_INTERVAL_AS_SQL_INTERVAL if (PG_TYPE_INTERVAL == type) return SQL_INTERVAL; #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ switch (rettype = pgtype_attr_to_concise_type(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as)) { case SQL_TYPE_DATE: case SQL_TYPE_TIME: case SQL_TYPE_TIMESTAMP: return SQL_DATETIME; } return rettype; } SQLSMALLINT pgtype_attr_to_datetime_sub(const ConnectionClass *conn, OID type, int atttypmod) { SQLSMALLINT rettype; switch (rettype = pgtype_attr_to_concise_type(conn, type, atttypmod, PG_ADT_UNSET, PG_UNKNOWNS_UNSET)) { case SQL_TYPE_DATE: return SQL_CODE_DATE; case SQL_TYPE_TIME: return SQL_CODE_TIME; case SQL_TYPE_TIMESTAMP: return SQL_CODE_TIMESTAMP; case SQL_INTERVAL_MONTH: case SQL_INTERVAL_YEAR: case SQL_INTERVAL_YEAR_TO_MONTH: case SQL_INTERVAL_DAY: case SQL_INTERVAL_HOUR: case SQL_INTERVAL_MINUTE: case SQL_INTERVAL_SECOND: case SQL_INTERVAL_DAY_TO_HOUR: case SQL_INTERVAL_DAY_TO_MINUTE: case SQL_INTERVAL_DAY_TO_SECOND: case SQL_INTERVAL_HOUR_TO_MINUTE: case SQL_INTERVAL_HOUR_TO_SECOND: case SQL_INTERVAL_MINUTE_TO_SECOND: return rettype - 100; } return -1; } SQLSMALLINT pgtype_attr_to_ctype(const ConnectionClass *conn, OID type, int atttypmod) { const ConnInfo *ci = &(conn->connInfo); EnvironmentClass *env = (EnvironmentClass *) CC_get_env(conn); #ifdef PG_INTERVAL_AS_SQL_INTERVAL SQLSMALLINT ctype; #endif /* PG_INTERVAL_A_SQL_INTERVAL */ switch (type) { case PG_TYPE_INT8: if (!conn->ms_jet) return ALLOWED_C_BIGINT; return SQL_C_CHAR; case PG_TYPE_NUMERIC: return SQL_C_CHAR; case PG_TYPE_INT2: return SQL_C_SSHORT; case PG_TYPE_OID: case PG_TYPE_XID: return SQL_C_ULONG; case PG_TYPE_INT4: return SQL_C_SLONG; case PG_TYPE_FLOAT4: return SQL_C_FLOAT; case PG_TYPE_FLOAT8: return SQL_C_DOUBLE; case PG_TYPE_DATE: if (EN_is_odbc3(env)) return SQL_C_TYPE_DATE; return SQL_C_DATE; case PG_TYPE_TIME: if (EN_is_odbc3(env)) return SQL_C_TYPE_TIME; return SQL_C_TIME; case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: if (EN_is_odbc3(env)) return SQL_C_TYPE_TIMESTAMP; return SQL_C_TIMESTAMP; case PG_TYPE_MONEY: return SQL_C_FLOAT; case PG_TYPE_BOOL: return ci->drivers.bools_as_char ? SQL_C_CHAR : SQL_C_BIT; case PG_TYPE_BYTEA: return SQL_C_BINARY; case PG_TYPE_LO_UNDEFINED: return SQL_C_BINARY; case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: return ansi_to_wtype(conn, SQL_C_CHAR); case PG_TYPE_UUID: if (!conn->ms_jet) return SQL_C_GUID; return ansi_to_wtype(conn, SQL_C_CHAR); case PG_TYPE_INTERVAL: #ifdef PG_INTERVAL_AS_SQL_INTERVAL if (ctype = get_interval_type(atttypmod, NULL), 0 != ctype) return ctype; #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ return ansi_to_wtype(conn, SQL_CHAR); default: /* hack until permanent type is available */ if (type == conn->lobj_type) return SQL_C_BINARY; /* Experimental, Does this work ? */ #ifdef EXPERIMENTAL_CURRENTLY return ansi_to_wtype(conn, SQL_C_CHAR); #endif /* EXPERIMENTAL_CURRENTLY */ return SQL_C_CHAR; } } const char * pgtype_attr_to_name(const ConnectionClass *conn, OID type, int atttypmod, BOOL auto_increment) { const char *tname = NULL; switch (type) { case PG_TYPE_CHAR: return "char"; case PG_TYPE_INT8: return auto_increment ? "bigserial" : "int8"; case PG_TYPE_NUMERIC: return "numeric"; case PG_TYPE_VARCHAR: return "varchar"; case PG_TYPE_BPCHAR: return "char"; case PG_TYPE_TEXT: return "text"; case PG_TYPE_NAME: return "name"; case PG_TYPE_REFCURSOR: return "refcursor"; case PG_TYPE_INT2: return "int2"; case PG_TYPE_OID: return OID_NAME; case PG_TYPE_XID: return "xid"; case PG_TYPE_INT4: MYLOG(DETAIL_LOG_LEVEL, "pgtype_to_name int4\n"); return auto_increment ? "serial" : "int4"; case PG_TYPE_FLOAT4: return "float4"; case PG_TYPE_FLOAT8: return "float8"; case PG_TYPE_DATE: return "date"; case PG_TYPE_TIME: return "time"; case PG_TYPE_ABSTIME: return "abstime"; case PG_TYPE_DATETIME: return "timestamptz"; case PG_TYPE_TIMESTAMP_NO_TMZONE: return "timestamp without time zone"; case PG_TYPE_TIMESTAMP: return "timestamp"; case PG_TYPE_MONEY: return "money"; case PG_TYPE_BOOL: return "bool"; case PG_TYPE_BYTEA: return "bytea"; case PG_TYPE_XML: return "xml"; case PG_TYPE_MACADDR: return "macaddr"; case PG_TYPE_INET: return "inet"; case PG_TYPE_CIDR: return "cidr"; case PG_TYPE_UUID: return "uuid"; case PG_TYPE_VOID: return "void"; case PG_TYPE_INT2VECTOR: return "int2vector"; case PG_TYPE_OIDVECTOR: return "oidvector"; case PG_TYPE_ANY: return "any"; case PG_TYPE_INTERVAL: get_interval_type(atttypmod, &tname); return tname; case PG_TYPE_LO_UNDEFINED: return PG_TYPE_LO_NAME; default: /* hack until permanent type is available */ if (type == conn->lobj_type) return PG_TYPE_LO_NAME; /* * "unknown" can actually be used in alter table because it is * a real PG type! */ return "unknown"; } } Int4 /* PostgreSQL restriction */ pgtype_attr_column_size(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int handle_unknown_size_as) { const ConnInfo *ci = &(conn->connInfo); MYLOG(0, "entering type=%d, atttypmod=%d, adtsize_or=%d, unknown = %d\n", type, atttypmod, adtsize_or_longest, handle_unknown_size_as); switch (type) { case PG_TYPE_CHAR: return 1; case PG_TYPE_NAME: case PG_TYPE_REFCURSOR: { int value = 0; if (PG_VERSION_GT(conn, 7.4)) { /* * 'conn' argument is marked as const, * because this function just reads * stuff from the already-filled in * fields in the struct. But this is * an exception: CC_get_max_idlen() can * send a SHOW query to the backend to * get the identifier length. Thus cast * away the const here. */ value = CC_get_max_idlen((ConnectionClass *) conn); } #ifdef NAME_FIELD_SIZE else value = NAME_FIELD_SIZE; #endif /* NAME_FIELD_SIZE */ if (0 == value) value = NAMEDATALEN_V73; return value; } case PG_TYPE_INT2: return 5; case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: return 10; case PG_TYPE_INT8: return 19; /* signed */ case PG_TYPE_NUMERIC: return getNumericColumnSizeX(conn, type, atttypmod, adtsize_or_longest, handle_unknown_size_as); case PG_TYPE_MONEY: return 10; case PG_TYPE_FLOAT4: return PG_REAL_DIGITS; case PG_TYPE_FLOAT8: return PG_DOUBLE_DIGITS; case PG_TYPE_DATE: return 10; case PG_TYPE_TIME: return 8; case PG_TYPE_ABSTIME: case PG_TYPE_TIMESTAMP: return 22; case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: /* return 22; */ return getTimestampColumnSizeX(conn, type, atttypmod); case PG_TYPE_BOOL: return ci->drivers.bools_as_char ? PG_WIDTH_OF_BOOLS_AS_CHAR : 1; case PG_TYPE_MACADDR: return 17; case PG_TYPE_INET: case PG_TYPE_CIDR: return sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128"); case PG_TYPE_UUID: return sizeof("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); case PG_TYPE_LO_UNDEFINED: return SQL_NO_TOTAL; case PG_TYPE_INTERVAL: return getIntervalColumnSize(type, atttypmod); default: if (type == conn->lobj_type) /* hack until permanent * type is available */ return SQL_NO_TOTAL; if (PG_TYPE_BYTEA == type && ci->bytea_as_longvarbinary) return SQL_NO_TOTAL; /* Handle Character types and unknown types */ return getCharColumnSizeX(conn, type, atttypmod, adtsize_or_longest, handle_unknown_size_as); } } SQLSMALLINT pgtype_attr_precision(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int handle_unknown_size_as) { switch (type) { case PG_TYPE_NUMERIC: return getNumericColumnSizeX(conn, type, atttypmod, adtsize_or_longest, handle_unknown_size_as); case PG_TYPE_TIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: return getTimestampDecimalDigitsX(conn, type, atttypmod); #ifdef PG_INTERVAL_AS_SQL_INTERVAL case PG_TYPE_INTERVAL: return getIntervalDecimalDigits(type, atttypmod); #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ } return -1; } Int4 pgtype_attr_display_size(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { int dsize; switch (type) { case PG_TYPE_INT2: return 6; case PG_TYPE_OID: case PG_TYPE_XID: return 10; case PG_TYPE_INT4: return 11; case PG_TYPE_INT8: return 20; /* signed: 19 digits + sign */ case PG_TYPE_NUMERIC: dsize = getNumericColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); return dsize <= 0 ? dsize : dsize + 2; case PG_TYPE_MONEY: return 15; /* ($9,999,999.99) */ case PG_TYPE_FLOAT4: /* a sign, PG_REAL_DIGITS digits, a decimal point, the letter E, a sign, and 2 digits */ return (1 + PG_REAL_DIGITS + 1 + 1 + 3); case PG_TYPE_FLOAT8: /* a sign, PG_DOUBLE_DIGITS digits, a decimal point, the letter E, a sign, and 3 digits */ return (1 + PG_DOUBLE_DIGITS + 1 + 1 + 1 + 3); case PG_TYPE_MACADDR: return 17; case PG_TYPE_INET: case PG_TYPE_CIDR: return sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128"); case PG_TYPE_UUID: return 36; case PG_TYPE_INTERVAL: return 30; /* Character types use regular precision */ default: return pgtype_attr_column_size(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); } } Int4 pgtype_attr_buffer_length(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { int dsize; switch (type) { case PG_TYPE_INT2: return 2; /* sizeof(SQLSMALLINT) */ case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: return 4; /* sizeof(SQLINTEGER) */ case PG_TYPE_INT8: if (SQL_C_CHAR == pgtype_attr_to_ctype(conn, type, atttypmod)) return 20; /* signed: 19 digits + sign */ return 8; /* sizeof(SQLSBININT) */ case PG_TYPE_NUMERIC: dsize = getNumericColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); return dsize <= 0 ? dsize : dsize + 2; case PG_TYPE_FLOAT4: case PG_TYPE_MONEY: return 4; /* sizeof(SQLREAL) */ case PG_TYPE_FLOAT8: return 8; /* sizeof(SQLFLOAT) */ case PG_TYPE_DATE: case PG_TYPE_TIME: return 6; /* sizeof(DATE(TIME)_STRUCT) */ case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP: case PG_TYPE_TIMESTAMP_NO_TMZONE: return 16; /* sizeof(TIMESTAMP_STRUCT) */ case PG_TYPE_MACADDR: return 17; case PG_TYPE_INET: case PG_TYPE_CIDR: return sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128"); case PG_TYPE_UUID: return 16; /* sizeof(SQLGUID) */ /* Character types use the default precision */ case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: { int coef = 1; Int4 prec = pgtype_attr_column_size(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as), maxvarc; if (SQL_NO_TOTAL == prec) return prec; #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) return prec * WCLEN; #endif /* UNICODE_SUPPORT */ coef = conn->mb_maxbyte_per_char; if (coef < 2 && (conn->connInfo).lf_conversion) /* CR -> CR/LF */ coef = 2; if (coef == 1) return prec; maxvarc = conn->connInfo.drivers.max_varchar_size; if (prec <= maxvarc && prec * coef > maxvarc) return maxvarc; return coef * prec; } #ifdef PG_INTERVAL_AS_SQL_INTERVAL case PG_TYPE_INTERVAL: return sizeof(SQL_INTERVAL_STRUCT); #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ default: return pgtype_attr_column_size(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); } } /* */ Int4 pgtype_attr_desclength(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as) { int dsize; switch (type) { case PG_TYPE_INT2: return 2; case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: return 4; case PG_TYPE_INT8: return 20; /* signed: 19 digits + sign */ case PG_TYPE_NUMERIC: dsize = getNumericColumnSizeX(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); return dsize <= 0 ? dsize : dsize + 2; case PG_TYPE_FLOAT4: case PG_TYPE_MONEY: return 4; case PG_TYPE_FLOAT8: return 8; case PG_TYPE_DATE: case PG_TYPE_TIME: case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: return pgtype_attr_column_size(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); default: return pgtype_attr_column_size(conn, type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); } } Int2 pgtype_attr_decimal_digits(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int UNUSED_handle_unknown_size_as) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: case PG_TYPE_BOOL: /* * Number of digits to the right of the decimal point in * "yyyy-mm=dd hh:mm:ss[.f...]" */ case PG_TYPE_ABSTIME: case PG_TYPE_TIMESTAMP: return 0; case PG_TYPE_TIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: /* return 0; */ return getTimestampDecimalDigitsX(conn, type, atttypmod); case PG_TYPE_NUMERIC: return getNumericDecimalDigitsX(conn, type, atttypmod, adtsize_or_longestlen, UNUSED_handle_unknown_size_as); #ifdef PG_INTERVAL_AS_SQL_INTERVAL case PG_TYPE_INTERVAL: return getIntervalDecimalDigits(type, atttypmod); #endif /* PG_INTERVAL_AS_SQL_INTERVAL */ default: return -1; } } Int2 pgtype_attr_scale(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int UNUSED_handle_unknown_size_as) { switch (type) { case PG_TYPE_NUMERIC: return getNumericDecimalDigitsX(conn, type, atttypmod, adtsize_or_longestlen, UNUSED_handle_unknown_size_as); } return -1; } Int4 pgtype_attr_transfer_octet_length(const ConnectionClass *conn, OID type, int atttypmod, int handle_unknown_size_as) { int coef = 1; Int4 maxvarc, column_size; switch (type) { case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: case PG_TYPE_TEXT: case PG_TYPE_UNKNOWN: column_size = pgtype_attr_column_size(conn, type, atttypmod, PG_ADT_UNSET, handle_unknown_size_as); if (SQL_NO_TOTAL == column_size) return column_size; #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) return column_size * WCLEN; #endif /* UNICODE_SUPPORT */ coef = conn->mb_maxbyte_per_char; if (coef < 2 && (conn->connInfo).lf_conversion) /* CR -> CR/LF */ coef = 2; if (coef == 1) return column_size; maxvarc = conn->connInfo.drivers.max_varchar_size; if (column_size <= maxvarc && column_size * coef > maxvarc) return maxvarc; return coef * column_size; case PG_TYPE_BYTEA: return pgtype_attr_column_size(conn, type, atttypmod, PG_ADT_UNSET, handle_unknown_size_as); default: if (type == conn->lobj_type) return pgtype_attr_column_size(conn, type, atttypmod, PG_ADT_UNSET, handle_unknown_size_as); } return -1; } /* * This was used when binding a query parameter, to decide which PostgreSQL * datatype to send to the server, depending on the SQL datatype that was * used in the SQLBindParameter call. * * However it is inflexible and rather harmful. * Now this function always returns 0. * We use cast instead to keep regression test results * in order to keep regression test results. */ OID sqltype_to_bind_pgtype(const ConnectionClass *conn, SQLSMALLINT fSqlType) { OID pgType = 0; return pgType; } /* * Casting parameters e.g. ?::timestamp is much more flexible * than specifying parameter datatype oids determined by * sqltype_to_bind_pgtype() via parse message. */ const char * sqltype_to_pgcast(const ConnectionClass *conn, SQLSMALLINT fSqlType) { const char *pgCast = NULL_STRING; switch (fSqlType) { case SQL_BINARY: case SQL_VARBINARY: pgCast = "::bytea"; break; case SQL_TYPE_DATE: case SQL_DATE: pgCast = "::date"; break; case SQL_DECIMAL: case SQL_NUMERIC: pgCast = "::numeric"; break; case SQL_BIGINT: pgCast = "::int8"; break; case SQL_INTEGER: pgCast = "::int4"; break; case SQL_REAL: pgCast = "::float4"; break; case SQL_SMALLINT: case SQL_TINYINT: pgCast = "::int2"; break; case SQL_TIME: case SQL_TYPE_TIME: pgCast = "::time"; break; case SQL_TIMESTAMP: case SQL_TYPE_TIMESTAMP: pgCast = "::timestamp"; break; case SQL_GUID: if (PG_VERSION_GE(conn, 8.3)) pgCast = "::uuid"; break; case SQL_INTERVAL_MONTH: case SQL_INTERVAL_YEAR: case SQL_INTERVAL_YEAR_TO_MONTH: case SQL_INTERVAL_DAY: case SQL_INTERVAL_HOUR: case SQL_INTERVAL_MINUTE: case SQL_INTERVAL_SECOND: case SQL_INTERVAL_DAY_TO_HOUR: case SQL_INTERVAL_DAY_TO_MINUTE: case SQL_INTERVAL_DAY_TO_SECOND: case SQL_INTERVAL_HOUR_TO_MINUTE: case SQL_INTERVAL_HOUR_TO_SECOND: case SQL_INTERVAL_MINUTE_TO_SECOND: pgCast = "::interval"; break; } return pgCast; } OID sqltype_to_pgtype(const ConnectionClass *conn, SQLSMALLINT fSqlType) { OID pgType; const ConnInfo *ci = &(conn->connInfo); pgType = 0; /* ??? */ switch (fSqlType) { case SQL_BINARY: pgType = PG_TYPE_BYTEA; break; case SQL_CHAR: pgType = PG_TYPE_BPCHAR; break; #ifdef UNICODE_SUPPORT case SQL_WCHAR: pgType = PG_TYPE_BPCHAR; break; #endif /* UNICODE_SUPPORT */ case SQL_BIT: pgType = PG_TYPE_BOOL; break; case SQL_TYPE_DATE: case SQL_DATE: pgType = PG_TYPE_DATE; break; case SQL_DOUBLE: case SQL_FLOAT: pgType = PG_TYPE_FLOAT8; break; case SQL_DECIMAL: case SQL_NUMERIC: pgType = PG_TYPE_NUMERIC; break; case SQL_BIGINT: pgType = PG_TYPE_INT8; break; case SQL_INTEGER: pgType = PG_TYPE_INT4; break; case SQL_LONGVARBINARY: if (ci->bytea_as_longvarbinary) pgType = PG_TYPE_BYTEA; else pgType = conn->lobj_type; break; case SQL_LONGVARCHAR: pgType = ci->drivers.text_as_longvarchar ? PG_TYPE_TEXT : PG_TYPE_VARCHAR; break; #ifdef UNICODE_SUPPORT case SQL_WLONGVARCHAR: pgType = ci->drivers.text_as_longvarchar ? PG_TYPE_TEXT : PG_TYPE_VARCHAR; break; #endif /* UNICODE_SUPPORT */ case SQL_REAL: pgType = PG_TYPE_FLOAT4; break; case SQL_SMALLINT: case SQL_TINYINT: pgType = PG_TYPE_INT2; break; case SQL_TIME: case SQL_TYPE_TIME: pgType = PG_TYPE_TIME; break; case SQL_TIMESTAMP: case SQL_TYPE_TIMESTAMP: pgType = PG_TYPE_DATETIME; break; case SQL_VARBINARY: pgType = PG_TYPE_BYTEA; break; case SQL_VARCHAR: pgType = PG_TYPE_VARCHAR; break; #ifdef UNICODE_SUPPORT case SQL_WVARCHAR: pgType = PG_TYPE_VARCHAR; break; #endif /* UNICODE_SUPPORT */ case SQL_GUID: if (PG_VERSION_GE(conn, 8.3)) pgType = PG_TYPE_UUID; break; case SQL_INTERVAL_MONTH: case SQL_INTERVAL_YEAR: case SQL_INTERVAL_YEAR_TO_MONTH: case SQL_INTERVAL_DAY: case SQL_INTERVAL_HOUR: case SQL_INTERVAL_MINUTE: case SQL_INTERVAL_SECOND: case SQL_INTERVAL_DAY_TO_HOUR: case SQL_INTERVAL_DAY_TO_MINUTE: case SQL_INTERVAL_DAY_TO_SECOND: case SQL_INTERVAL_HOUR_TO_MINUTE: case SQL_INTERVAL_HOUR_TO_SECOND: case SQL_INTERVAL_MINUTE_TO_SECOND: pgType = PG_TYPE_INTERVAL; break; } return pgType; } static int getAtttypmodEtc(const StatementClass *stmt, int col, int *adtsize_or_longestlen) { int atttypmod = -1; if (NULL != adtsize_or_longestlen) *adtsize_or_longestlen = PG_ADT_UNSET; if (col >= 0) { const QResultClass *res; if (res = SC_get_ExecdOrParsed(stmt), NULL != res) { atttypmod = QR_get_atttypmod(res, col); if (NULL != adtsize_or_longestlen) { if (stmt->catalog_result) *adtsize_or_longestlen = QR_get_fieldsize(res, col); else { *adtsize_or_longestlen = QR_get_display_size(res, col); if (PG_TYPE_NUMERIC == QR_get_field_type(res, col) && atttypmod < 0 && *adtsize_or_longestlen > 0) { SQLULEN i; size_t sval, maxscale = 0; const char *tval, *sptr; for (i = 0; i < res->num_cached_rows; i++) { tval = QR_get_value_backend_text(res, i, col); if (NULL != tval) { sptr = strchr(tval, '.'); if (NULL != sptr) { sval = strlen(tval) - (sptr + 1 - tval); if (sval > maxscale) maxscale = sval; } } } *adtsize_or_longestlen += (int) (maxscale << 16); } } } } } return atttypmod; } /* * There are two ways of calling this function: * * 1. When going through the supported PG types (SQLGetTypeInfo) * * 2. When taking any type id (SQLColumns, SQLGetData) * * The first type will always work because all the types defined are returned here. * The second type will return a default based on global parameter when it does not * know. This allows for supporting * types that are unknown. All other pg routines in here return a suitable default. */ SQLSMALLINT pgtype_to_concise_type(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_to_concise_type(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); } SQLSMALLINT pgtype_to_sqldesctype(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int adtsize_or_longestlen; int atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_to_sqldesctype(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, handle_unknown_size_as); } SQLSMALLINT pgtype_to_datetime_sub(const StatementClass *stmt, OID type, int col) { int atttypmod = getAtttypmodEtc(stmt, col, NULL); return pgtype_attr_to_datetime_sub(SC_get_conn(stmt), type, atttypmod); } const char * pgtype_to_name(const StatementClass *stmt, OID type, int col, BOOL auto_increment) { int atttypmod = getAtttypmodEtc(stmt, col, NULL); return pgtype_attr_to_name(SC_get_conn(stmt), type, atttypmod, auto_increment); } /* * This corresponds to "precision" in ODBC 2.x. * * For PG_TYPE_VARCHAR, PG_TYPE_BPCHAR, PG_TYPE_NUMERIC, SQLColumns will * override this length with the atttypmod length from pg_attribute . * * If col >= 0, then will attempt to get the info from the result set. * This is used for functions SQLDescribeCol and SQLColAttributes. */ Int4 /* PostgreSQL restriction */ pgtype_column_size(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_column_size(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, stmt->catalog_result ? UNKNOWNS_AS_LONGEST : handle_unknown_size_as); } /* * precision in ODBC 3.x. */ SQLSMALLINT pgtype_precision(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_precision(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, stmt->catalog_result ? UNKNOWNS_AS_LONGEST : handle_unknown_size_as); } Int4 pgtype_display_size(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_display_size(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, stmt->catalog_result ? UNKNOWNS_AS_LONGEST : handle_unknown_size_as); } /* * The length in bytes of data transferred on an SQLGetData, SQLFetch, * or SQLFetchScroll operation if SQL_C_DEFAULT is specified. */ Int4 pgtype_buffer_length(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_buffer_length(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, stmt->catalog_result ? UNKNOWNS_AS_LONGEST : handle_unknown_size_as); } /* */ Int4 pgtype_desclength(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_desclength(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, stmt->catalog_result ? UNKNOWNS_AS_LONGEST : handle_unknown_size_as); } #ifdef NOT_USED /* * Transfer octet length. */ Int4 pgtype_transfer_octet_length(const StatementClass *stmt, OID type, int column_size) { ConnectionClass *conn = SC_get_conn(stmt); int coef = 1; Int4 maxvarc; switch (type) { case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: case PG_TYPE_TEXT: if (SQL_NO_TOTAL == column_size) return column_size; #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(conn)) return column_size * WCLEN; #endif /* UNICODE_SUPPORT */ coef = conn->mb_maxbyte_per_char; if (coef < 2 && (conn->connInfo).lf_conversion) /* CR -> CR/LF */ coef = 2; if (coef == 1) return column_size; maxvarc = conn->connInfo.drivers.max_varchar_size; if (column_size <= maxvarc && column_size * coef > maxvarc) return maxvarc; return coef * column_size; case PG_TYPE_BYTEA: return column_size; default: if (type == conn->lobj_type) return column_size; } return -1; } #endif /* NOT_USED */ /* * corresponds to "min_scale" in ODBC 2.x. */ Int2 pgtype_min_decimal_digits(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: case PG_TYPE_BOOL: case PG_TYPE_ABSTIME: case PG_TYPE_TIMESTAMP: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_NUMERIC: return 0; default: return -1; } } /* * corresponds to "max_scale" in ODBC 2.x. */ Int2 pgtype_max_decimal_digits(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: case PG_TYPE_BOOL: case PG_TYPE_ABSTIME: case PG_TYPE_TIMESTAMP: return 0; case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: return 38; case PG_TYPE_NUMERIC: return getNumericDecimalDigitsX(conn, type, -1, -1, UNUSED_HANDLE_UNKNOWN_SIZE_AS); default: return -1; } } /* * corresponds to "scale" in ODBC 2.x. */ Int2 pgtype_decimal_digits(const StatementClass *stmt, OID type, int col) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_decimal_digits(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, UNUSED_HANDLE_UNKNOWN_SIZE_AS); } /* * "scale" in ODBC 3.x. */ Int2 pgtype_scale(const StatementClass *stmt, OID type, int col) { int atttypmod, adtsize_or_longestlen; atttypmod = getAtttypmodEtc(stmt, col, &adtsize_or_longestlen); return pgtype_attr_scale(SC_get_conn(stmt), type, atttypmod, adtsize_or_longestlen, UNUSED_HANDLE_UNKNOWN_SIZE_AS); } Int2 pgtype_radix(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_XID: case PG_TYPE_OID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_NUMERIC: case PG_TYPE_FLOAT4: case PG_TYPE_MONEY: case PG_TYPE_FLOAT8: return 10; default: return -1; } } Int2 pgtype_nullable(const ConnectionClass *conn, OID type) { return SQL_NULLABLE; /* everything should be nullable */ } Int2 pgtype_auto_increment(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_FLOAT4: case PG_TYPE_MONEY: case PG_TYPE_BOOL: case PG_TYPE_FLOAT8: case PG_TYPE_INT8: case PG_TYPE_NUMERIC: case PG_TYPE_DATE: case PG_TYPE_TIME_WITH_TMZONE: case PG_TYPE_TIME: case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIMESTAMP: return FALSE; default: return -1; } } Int2 pgtype_case_sensitive(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_CHAR: case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: case PG_TYPE_TEXT: case PG_TYPE_NAME: case PG_TYPE_REFCURSOR: return TRUE; default: return FALSE; } } Int2 pgtype_money(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_MONEY: return TRUE; default: return FALSE; } } Int2 pgtype_searchable(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_CHAR: case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: case PG_TYPE_TEXT: case PG_TYPE_NAME: case PG_TYPE_REFCURSOR: return SQL_SEARCHABLE; default: if (conn && type == conn->lobj_type) return SQL_UNSEARCHABLE; return SQL_ALL_EXCEPT_LIKE; } } Int2 pgtype_unsigned(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_OID: case PG_TYPE_XID: return TRUE; case PG_TYPE_INT2: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_NUMERIC: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: return FALSE; default: return -1; } } const char * pgtype_literal_prefix(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_NUMERIC: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: return NULL; default: return "'"; } } const char * pgtype_literal_suffix(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_INT2: case PG_TYPE_OID: case PG_TYPE_XID: case PG_TYPE_INT4: case PG_TYPE_INT8: case PG_TYPE_NUMERIC: case PG_TYPE_FLOAT4: case PG_TYPE_FLOAT8: case PG_TYPE_MONEY: return NULL; default: return "'"; } } const char * pgtype_create_params(const ConnectionClass *conn, OID type) { switch (type) { case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: return "max. length"; case PG_TYPE_NUMERIC: return "precision, scale"; default: return NULL; } } SQLSMALLINT sqltype_to_default_ctype(const ConnectionClass *conn, SQLSMALLINT sqltype) { /* * from the table on page 623 of ODBC 2.0 Programmer's Reference * (Appendix D) */ switch (sqltype) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: case SQL_DECIMAL: case SQL_NUMERIC: return SQL_C_CHAR; case SQL_BIGINT: return ALLOWED_C_BIGINT; #ifdef UNICODE_SUPPORT case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: return ansi_to_wtype(conn, SQL_C_CHAR); #endif /* UNICODE_SUPPORT */ case SQL_BIT: return SQL_C_BIT; case SQL_TINYINT: return SQL_C_STINYINT; case SQL_SMALLINT: return SQL_C_SSHORT; case SQL_INTEGER: return SQL_C_SLONG; case SQL_REAL: return SQL_C_FLOAT; case SQL_FLOAT: case SQL_DOUBLE: return SQL_C_DOUBLE; case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: return SQL_C_BINARY; case SQL_DATE: return SQL_C_DATE; case SQL_TIME: return SQL_C_TIME; case SQL_TIMESTAMP: return SQL_C_TIMESTAMP; case SQL_TYPE_DATE: return SQL_C_TYPE_DATE; case SQL_TYPE_TIME: return SQL_C_TYPE_TIME; case SQL_TYPE_TIMESTAMP: return SQL_C_TYPE_TIMESTAMP; case SQL_GUID: if (conn->ms_jet) return SQL_C_CHAR; else return SQL_C_GUID; default: /* should never happen */ return SQL_C_CHAR; } } Int4 ctype_length(SQLSMALLINT ctype) { switch (ctype) { case SQL_C_SSHORT: case SQL_C_SHORT: return sizeof(SWORD); case SQL_C_USHORT: return sizeof(UWORD); case SQL_C_SLONG: case SQL_C_LONG: return sizeof(SDWORD); case SQL_C_ULONG: return sizeof(UDWORD); case SQL_C_FLOAT: return sizeof(SFLOAT); case SQL_C_DOUBLE: return sizeof(SDOUBLE); case SQL_C_BIT: return sizeof(UCHAR); case SQL_C_STINYINT: case SQL_C_TINYINT: return sizeof(SCHAR); case SQL_C_UTINYINT: return sizeof(UCHAR); case SQL_C_DATE: case SQL_C_TYPE_DATE: return sizeof(DATE_STRUCT); case SQL_C_TIME: case SQL_C_TYPE_TIME: return sizeof(TIME_STRUCT); case SQL_C_TIMESTAMP: case SQL_C_TYPE_TIMESTAMP: return sizeof(TIMESTAMP_STRUCT); case SQL_C_GUID: return sizeof(SQLGUID); case SQL_C_INTERVAL_YEAR: case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_YEAR_TO_MONTH: case SQL_C_INTERVAL_DAY: case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_DAY_TO_HOUR: case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_DAY_TO_MINUTE: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: return sizeof(SQL_INTERVAL_STRUCT); case SQL_C_NUMERIC: return sizeof(SQL_NUMERIC_STRUCT); case SQL_C_SBIGINT: case SQL_C_UBIGINT: return sizeof(SQLBIGINT); case SQL_C_BINARY: case SQL_C_CHAR: #ifdef UNICODE_SUPPORT case SQL_C_WCHAR: #endif /* UNICODE_SUPPORT */ return 0; default: /* should never happen */ return 0; } } psqlodbc-REL-16_00_0005/pgtypes.h000066400000000000000000000154021462406103600163440ustar00rootroot00000000000000/* File: pgtypes.h * * Description: See "pgtypes.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __PGTYPES_H__ #define __PGTYPES_H__ #include "psqlodbc.h" /* the type numbers are defined by the OID's of the types' rows */ /* in table pg_type */ #ifdef NOT_USED #define PG_TYPE_LO ???? /* waiting for permanent type */ #endif #define MS_ACCESS_SERIAL "int identity" #define PG_TYPE_BOOL 16 #define PG_TYPE_BYTEA 17 #define PG_TYPE_CHAR 18 #define PG_TYPE_NAME 19 #define PG_TYPE_INT8 20 #define PG_TYPE_INT2 21 #define PG_TYPE_INT2VECTOR 22 #define PG_TYPE_INT4 23 #define PG_TYPE_REGPROC 24 #define PG_TYPE_TEXT 25 #define PG_TYPE_OID 26 #define PG_TYPE_TID 27 #define PG_TYPE_XID 28 #define PG_TYPE_CID 29 #define PG_TYPE_OIDVECTOR 30 #define PG_TYPE_XML 142 #define PG_TYPE_XMLARRAY 143 #define PG_TYPE_CIDR 650 #define PG_TYPE_FLOAT4 700 #define PG_TYPE_FLOAT8 701 #define PG_TYPE_ABSTIME 702 #define PG_TYPE_UNKNOWN 705 #define PG_TYPE_MONEY 790 #define PG_TYPE_MACADDR 829 #define PG_TYPE_INET 869 #define PG_TYPE_TEXTARRAY 1009 #define PG_TYPE_BPCHARARRAY 1014 #define PG_TYPE_VARCHARARRAY 1015 #define PG_TYPE_BPCHAR 1042 #define PG_TYPE_VARCHAR 1043 #define PG_TYPE_DATE 1082 #define PG_TYPE_TIME 1083 #define PG_TYPE_TIMESTAMP_NO_TMZONE 1114 /* since 7.2 */ #define PG_TYPE_DATETIME 1184 /* timestamptz */ #define PG_TYPE_INTERVAL 1186 #define PG_TYPE_TIME_WITH_TMZONE 1266 /* since 7.1 */ #define PG_TYPE_TIMESTAMP 1296 /* deprecated since 7.0 */ #define PG_TYPE_BIT 1560 #define PG_TYPE_NUMERIC 1700 #define PG_TYPE_REFCURSOR 1790 #define PG_TYPE_RECORD 2249 #define PG_TYPE_ANY 2276 #define PG_TYPE_VOID 2278 #define PG_TYPE_UUID 2950 #define INTERNAL_ASIS_TYPE (-9999) #define TYPE_MAY_BE_ARRAY(type) ((type) == PG_TYPE_XMLARRAY || ((type) >= 1000 && (type) <= 1041)) /* extern Int4 pgtypes_defined[]; */ extern SQLSMALLINT sqlTypes[]; /* Defines for pgtype_precision */ #define PG_ATP_UNSET (-3) /* atttypmod */ #define PG_ADT_UNSET (-3) /* adtsize_or_longestlen */ #define PG_UNKNOWNS_UNSET 0 /* UNKNOWNS_AS_MAX */ #define PG_WIDTH_OF_BOOLS_AS_CHAR 5 /* * SQL_INTERVAL support is disabled because I found * some applications which are unhappy with it. * #define PG_INTERVAL_AS_SQL_INTERVAL */ OID pg_true_type(const ConnectionClass *, OID, OID); OID sqltype_to_pgtype(const ConnectionClass *conn, SQLSMALLINT fSqlType); OID sqltype_to_bind_pgtype(const ConnectionClass *conn, SQLSMALLINT fSqlType); const char *sqltype_to_pgcast(const ConnectionClass *conn, SQLSMALLINT fSqlType); SQLSMALLINT pgtype_to_concise_type(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); SQLSMALLINT pgtype_to_sqldesctype(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); SQLSMALLINT pgtype_to_datetime_sub(const StatementClass *stmt, OID type, int col); const char *pgtype_to_name(const StatementClass *stmt, OID type, int col, BOOL auto_increment); SQLSMALLINT pgtype_attr_to_concise_type(const ConnectionClass *conn, OID type, int typmod, int adtsize_or_longestlen,int handle_unknown_size_as); SQLSMALLINT pgtype_attr_to_sqldesctype(const ConnectionClass *conn, OID type, int typmod, int adtsize_or_longestlen, int handle_unknown_size_as); SQLSMALLINT pgtype_attr_to_datetime_sub(const ConnectionClass *conn, OID type, int typmod); SQLSMALLINT pgtype_attr_to_ctype(const ConnectionClass *conn, OID type, int typmod); const char *pgtype_attr_to_name(const ConnectionClass *conn, OID type, int typmod, BOOL auto_increment); Int4 pgtype_attr_column_size(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int handle_unknown_size_as); Int4 pgtype_attr_buffer_length(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as); Int4 pgtype_attr_display_size(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as); Int2 pgtype_attr_decimal_digits(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as); Int4 pgtype_attr_transfer_octet_length(const ConnectionClass *conn, OID type, int atttypmod, int handle_unknown_size_as); SQLSMALLINT pgtype_attr_precision(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longest, int handle_unknown_size_as); Int4 pgtype_attr_desclength(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as); Int2 pgtype_attr_scale(const ConnectionClass *conn, OID type, int atttypmod, int adtsize_or_longestlen, int handle_unknown_size_as); /* These functions can use static numbers or result sets(col parameter) */ Int4 pgtype_column_size(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); /* corresponds to "precision" in ODBC 2.x */ SQLSMALLINT pgtype_precision(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); /* "precision in ODBC 3.x */ /* the following size/length are of Int4 due to PG restriction */ Int4 pgtype_display_size(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); Int4 pgtype_buffer_length(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); Int4 pgtype_desclength(const StatementClass *stmt, OID type, int col, int handle_unknown_size_as); // Int4 pgtype_transfer_octet_length(const ConnectionClass *conn, OID type, int column_size); SQLSMALLINT pgtype_decimal_digits(const StatementClass *stmt, OID type, int col); /* corresponds to "scale" in ODBC 2.x */ SQLSMALLINT pgtype_min_decimal_digits(const ConnectionClass *conn, OID type); /* corresponds to "min_scale" in ODBC 2.x */ SQLSMALLINT pgtype_max_decimal_digits(const ConnectionClass *conn, OID type); /* corresponds to "max_scale" in ODBC 2.x */ SQLSMALLINT pgtype_scale(const StatementClass *stmt, OID type, int col); /* ODBC 3.x " */ Int2 pgtype_radix(const ConnectionClass *conn, OID type); Int2 pgtype_nullable(const ConnectionClass *conn, OID type); Int2 pgtype_auto_increment(const ConnectionClass *conn, OID type); Int2 pgtype_case_sensitive(const ConnectionClass *conn, OID type); Int2 pgtype_money(const ConnectionClass *conn, OID type); Int2 pgtype_searchable(const ConnectionClass *conn, OID type); Int2 pgtype_unsigned(const ConnectionClass *conn, OID type); const char *pgtype_literal_prefix(const ConnectionClass *conn, OID type); const char *pgtype_literal_suffix(const ConnectionClass *conn, OID type); const char *pgtype_create_params(const ConnectionClass *conn, OID type); SQLSMALLINT sqltype_to_default_ctype(const ConnectionClass *stmt, SQLSMALLINT sqltype); Int4 ctype_length(SQLSMALLINT ctype); SQLSMALLINT ansi_to_wtype(const ConnectionClass *self, SQLSMALLINT ansitype); #define USE_ZONE FALSE #endif psqlodbc-REL-16_00_0005/pgxalib.cpp000077500000000000000000000440231462406103600166360ustar00rootroot00000000000000/*------ * Module: pgxalib.cpp * * Description: * This module implements XA like routines * invoked from MSDTC process. * * xa_open(), xa_close(), xa_commit(), * xa_rollback() and xa_recover() * are really invoked AFAIC. *------- */ #include /*#define _SLEEP_FOR_TEST_*/ #include #include #include #include #include #include #include #include #include #include EXTERN_C static void mylog(const char *fmt,...); using namespace std; class XAConnection { private: string connstr; string dsnstr; HDBC xaconn; vector qvec; int pos; bool immediateConnection; string sqlState; string errMsg; void parse_xa_info(); public: XAConnection(LPCTSTR str) : connstr(str), xaconn(NULL), pos(-1), immediateConnection(false) {parse_xa_info();} ~XAConnection(); void Reset(void); HDBC ActivateConnection(void); void SetPos(int spos) {pos = spos;} HDBC GetConnection(void) const {return xaconn;} vector &GetResultVec(void) {return qvec;} int GetPos(void) {return pos;} const string &GetConnstr(void) {return connstr;} const string &GetDsnstr(void) {return dsnstr;} bool GetImmediateConnection(void) {return immediateConnection;} bool AuthenticationError(void) {return sqlState == "08001" && errMsg.find("could not connect") == std::string::npos;} }; static class INIT_CRIT { private: public: bool cs_init; CRITICAL_SECTION map_cs; CRITICAL_SECTION mylog_cs; map xatab; FILE *LOGFP; HENV env; INIT_CRIT() : LOGFP(NULL), env(NULL) { InitializeCriticalSection(&map_cs); InitializeCriticalSection(&mylog_cs); cs_init = true; } ~INIT_CRIT() { // mylog("Leaving INIT_CRIT\n"); leave(); } void leave() { if (cs_init) { mylog("leaving pgxadll\n"); xatab.clear(); FreeEnv(); if (LOGFP) fclose(LOGFP); LOGFP = NULL; DeleteCriticalSection(&mylog_cs); DeleteCriticalSection(&map_cs); cs_init = false; } } void finalize() { leave(); } void FreeEnv() { if (env) { mylog("Freeing env\n"); SQLFreeHandle(SQL_HANDLE_ENV, env); env = NULL; } } } init_crit; #define MLOCK_ACQUIRE EnterCriticalSection(&init_crit.map_cs) #define MLOCK_RELEASE LeaveCriticalSection(&init_crit.map_cs) static int dtclog = 0; XAConnection::~XAConnection() { } void XAConnection::Reset() { qvec.clear(); if (xaconn) { mylog("about to Disconnect\n"); SQLDisconnect(xaconn); mylog("Freeing HANDLE_DBC\n"); SQLFreeHandle(SQL_HANDLE_DBC, xaconn); } } HDBC XAConnection::ActivateConnection(void) { RETCODE ret; MLOCK_ACQUIRE; if (!init_crit.env) { ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &init_crit.env); if (!SQL_SUCCEEDED(ret)) { MLOCK_RELEASE; return NULL; } } MLOCK_RELEASE; if (xaconn) return xaconn; ret = SQLSetEnvAttr(init_crit.env, SQL_ATTR_ODBC_VERSION, (PTR) SQL_OV_ODBC3, 0); ret = SQLAllocHandle(SQL_HANDLE_DBC, init_crit.env, &xaconn); if (!SQL_SUCCEEDED(ret)) return NULL; ret = SQLDriverConnect(xaconn, NULL, (SQLCHAR *) dsnstr.c_str(), SQL_NTS, NULL, SQL_NULL_DATA, NULL, SQL_DRIVER_COMPLETE); if (SQL_SUCCEEDED(ret)) return xaconn; SQLCHAR sqlstate[8], errmsg[256]; SQLGetDiagRec(SQL_HANDLE_DBC, xaconn, 1, sqlstate, NULL, errmsg, sizeof(errmsg), NULL); mylog("first SQLDriverConnect return=%d sqlstate=%s error=%s\n", ret, sqlstate, errmsg); sqlState = (char *) sqlstate; errMsg = (char *) errmsg; if (!AuthenticationError()) { SQLFreeHandle(SQL_HANDLE_DBC, xaconn); return NULL; } sqlState.empty(); errMsg.empty(); ret = SQLDriverConnect(xaconn, NULL, (SQLCHAR *) (dsnstr + ";Username=postgres;Password=postgres;sslmode=allow").c_str(), SQL_NTS, NULL, SQL_NULL_DATA, NULL, SQL_DRIVER_COMPLETE); if (SQL_SUCCEEDED(ret)) { mylog("second SQLDriverConnect success\n"); return xaconn; } SQLGetDiagRec(SQL_HANDLE_DBC, xaconn, 1, sqlstate, NULL, errmsg, sizeof(errmsg), NULL); mylog("second SQLDriverConnect return=%d sqlstate=%s error=%s\n", ret, sqlstate, errmsg); sqlState = (char *) sqlstate; errMsg = (char *) errmsg; return NULL; } #define _BUILD_DLL_ #ifdef _BUILD_DLL_ EXTERN_C { #define DIRSEPARATOR "\\" #define PG_BINARY_A "ab" #define MYLOGDIR "c:" #define MYLOGFILE "mylog_" static void generate_filename(const char *dirname, const char *prefix, char *filename) { int pid = 0; pid = _getpid(); if (dirname == 0 || filename == 0) return; strcpy(filename, dirname); strcat(filename, DIRSEPARATOR); if (prefix != 0) strcat(filename, prefix); sprintf(filename, "%s%u%s", filename, pid, ".log"); return; } static void FreeEnv() { init_crit.FreeEnv(); } #define DTCLOGDIR "c:\\pgdtclog" #include static const char * const DBMSNAME = "PostgreSQL"; static const char * const KEY_NAME = "MsdtcLog"; static const char * const ODBCINST_INI = "ODBCINST.INI"; INT_PTR FAR WINAPI GetMsdtclog() { char temp[16]; SQLGetPrivateProfileString(DBMSNAME, KEY_NAME, "", temp, sizeof(temp), ODBCINST_INI); dtclog = atoi(temp); return dtclog; } INT_PTR FAR WINAPI SetMsdtclog(int dtclog) { char temp[16]; sprintf(temp, "%d", dtclog); SQLWritePrivateProfileString(DBMSNAME, KEY_NAME, temp, ODBCINST_INI); return dtclog; } static BOOL output_mylog() { return (0 != dtclog); } static void mylog(const char *fmt,...) { va_list args; char filebuf[80]; static BOOL init = TRUE; FILE *logfp = init_crit.LOGFP; if (!output_mylog()) return; EnterCriticalSection(&init_crit.mylog_cs); va_start(args, fmt); if (init) { if (!logfp) { generate_filename(MYLOGDIR, MYLOGFILE, filebuf); logfp = fopen(filebuf, PG_BINARY_A); } if (!logfp) { generate_filename(DTCLOGDIR, MYLOGFILE, filebuf); logfp = fopen(filebuf, PG_BINARY_A); #ifdef WIN32 if (NULL == logfp) { if (0 == _mkdir(DTCLOGDIR)) logfp = fopen(filebuf, PG_BINARY_A); } #endif /* WIN32 */ } if (logfp) { setbuf(logfp, NULL); init_crit.LOGFP = logfp; } } init = FALSE; if (logfp) { time_t ntime; char ctim[128]; time(&ntime); strcpy(ctim, ctime(&ntime)); ctim[strlen(ctim) - 1] = '\0'; fprintf(logfp, "[%d.%d(%s)]", GetCurrentProcessId(), GetCurrentThreadId(), ctim); vfprintf(logfp, fmt, args); } va_end(args); LeaveCriticalSection(&init_crit.mylog_cs); } static int initialize_globals(void) { static int init = 1; if (!init) init = 0; return 0; } static void XatabClear(void); static void finalize_globals(void) { /* my(q)log is unavailable from here */ mylog("DETACHING From MSDTC PROCESS\n"); init_crit.finalize(); } HINSTANCE s_hModule; /* Saved module handle. */ /* This is where the Driver Manager attaches to this Driver */ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { WORD wVersionRequested; WSADATA wsaData; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: s_hModule = (HINSTANCE) hInst; /* Save for dialog boxes */ /* Load the WinSock Library */ wVersionRequested = MAKEWORD(1, 1); if (WSAStartup(wVersionRequested, &wsaData)) return FALSE; /* Verify that this is the minimum version of WinSock */ if (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1) { WSACleanup(); return FALSE; } initialize_globals(); break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: finalize_globals(); WSACleanup(); return TRUE; case DLL_THREAD_DETACH: break; default: break; } return TRUE; } } /* end of EXTERN_C */ #endif /* _BUILD_DLL_ */ static void XatabClear(void) { init_crit.xatab.clear(); } static const char *XidToText(const XID &xid, char *rtext) { int glen = xid.gtrid_length, blen = xid.bqual_length; int i, j; for (i = 0, j = 0; i < glen; i++, j += 2) sprintf(rtext + j, "%02x", (unsigned char) xid.data[i]); strcat(rtext, "-"); j++; for (; i < glen + blen; i++, j += 2) sprintf(rtext + j, "%02x", (unsigned char) xid.data[i]); return rtext; } static int pg_hex2bin(const UCHAR *src, UCHAR *dst, int length) { UCHAR chr; const UCHAR *src_wk; UCHAR *dst_wk; int i, val; BOOL HByte = TRUE; for (i = 0, src_wk = src, dst_wk = dst; i < length; i++, src_wk++) { chr = *src_wk; if (!chr) break; if (chr >= 'a' && chr <= 'f') val = chr - 'a' + 10; else if (chr >= 'A' && chr <= 'F') val = chr - 'A' + 10; else val = chr - '0'; if (HByte) *dst_wk = (val << 4); else { *dst_wk += val; dst_wk++; } HByte = !HByte; } return length; } static int TextToXid(XID &xid, const char *rtext) { int slen, glen, blen; char *sptr; slen = (int) strlen(rtext); sptr = (char *)strchr(rtext, '-'); if (sptr) { glen = (int) (sptr - rtext); blen = slen - glen - 1; } else { glen = slen; blen = 0; } xid.gtrid_length = glen / 2; xid.bqual_length = blen / 2; pg_hex2bin((const UCHAR *) rtext, (UCHAR *) &xid.data[0], glen); pg_hex2bin((const UCHAR *) sptr + 1, (UCHAR *) &xid.data[glen / 2], blen); return (glen + blen) / 2; } static bool bImmediateConnectDefault = false; #define CHAR_OPENING_BRACE '{' #define CHAR_CLOSING_BRACE '}' #define CHAR_SEMI_COLON ';' #define CHAR_EQUAL '=' #define STR_OPENING_BRACE "{" #define STR_CLOSING_BRACE "}" #define STR_SEMI_COLON ";" #define STR_EQUAL "=" #define KEYWORD_DTC_CHECK "dtchk" #define KEYWORD_DEBUG "debug" #define KEYWORD_ABDEBUG "B2" void XAConnection::parse_xa_info() { const char *cstr, *pstr, *pnstr; char keyword[64], value[64]; bool keyhasbr, valhasbr; int debugv = -1; cstr = connstr.c_str(); immediateConnection = bImmediateConnectDefault; GetMsdtclog(); for (pstr = cstr; *pstr;) { keyhasbr = valhasbr = false; if (CHAR_OPENING_BRACE == *pstr) { keyhasbr = true; if (pnstr = strchr(pstr, (int) CHAR_CLOSING_BRACE), NULL != pnstr) strncpy_s(keyword, sizeof(keyword), pstr + 1, pnstr - pstr - 1); else break; pstr = pnstr + 1; if (CHAR_EQUAL != *pstr) break; } else { if (pnstr = strchr(pstr, (int) CHAR_EQUAL), NULL != pnstr) strncpy_s(keyword, sizeof(keyword), pstr, pnstr - pstr); else break; pstr = pnstr; } pstr++; if (CHAR_OPENING_BRACE == *pstr) { valhasbr = true; if (pnstr = strchr(pstr, (int) CHAR_CLOSING_BRACE), NULL != pnstr) strncpy_s(value, sizeof(value), pstr + 1, pnstr - pstr - 1); else break; pstr = pnstr + 1; } else { if (pnstr = strchr(pstr, (int) CHAR_SEMI_COLON), NULL != pnstr) { strncpy_s(value, sizeof(value), pstr, pnstr - pstr); pstr = pnstr; } else { strcpy(value, pstr); pstr = strchr(pstr, '\0'); } } if (0 == _stricmp(keyword, KEYWORD_DTC_CHECK)) immediateConnection = (0 != atoi(value)); else if (0 == _stricmp(keyword, KEYWORD_DEBUG) || 0 == _stricmp(keyword, KEYWORD_ABDEBUG)) debugv = atoi(value); else { if (keyhasbr) dsnstr += STR_OPENING_BRACE; dsnstr += keyword; if (keyhasbr) dsnstr += STR_CLOSING_BRACE; dsnstr += STR_EQUAL; if (valhasbr) dsnstr += STR_OPENING_BRACE; dsnstr += value; if (valhasbr) dsnstr += STR_CLOSING_BRACE; dsnstr += STR_SEMI_COLON; } if (NULL == pstr || CHAR_SEMI_COLON != *pstr) break; pstr++; } if (0 != dtclog) { char dbgopt[16]; if (debugv <= 0) debugv = 1; _snprintf(dbgopt, sizeof(dbgopt), KEYWORD_ABDEBUG "=%d;", debugv); dsnstr += dbgopt; } } EXTERN_C static int __cdecl xa_open(char *xa_info, int rmid, long flags) { int xartn = XA_OK; bool bActivateConnection = bImmediateConnectDefault; mylog("xa_open %s rmid=%d flags=%ld\n", xa_info, rmid, flags); MLOCK_ACQUIRE; init_crit.xatab.insert(pair(rmid, XAConnection(xa_info))); MLOCK_RELEASE; map::iterator p; p = init_crit.xatab.find(rmid); if (p == init_crit.xatab.end()) xartn = XAER_RMERR; else if (p->second.GetImmediateConnection()) { mylog("xa_open calls ActivateConnection %s\n", p->second.GetDsnstr().c_str()); if (p->second.ActivateConnection()) xartn = XA_OK; else xartn = XAER_RMERR; } mylog("xa_open %s rmid=%d returning %d\n", xa_info, rmid, xartn); return xartn; } EXTERN_C static int __cdecl xa_close(char *xa_info, int rmid, long flags) { mylog("xa_close rmid=%d flags=%ld\n", rmid, flags); map::iterator p; MLOCK_ACQUIRE; p = init_crit.xatab.find(rmid); if (p != init_crit.xatab.end()) p->second.Reset(); init_crit.xatab.erase(rmid); if (init_crit.xatab.size() == 0) FreeEnv(); GetMsdtclog(); MLOCK_RELEASE; return XA_OK; } // // Dummy implementation (not called from MSDTC). // EXTERN_C static int __cdecl xa_start(XID *xid, int rmid, long flags) { char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_start %s rmid=%d flags=%ld\n", pgxid, rmid, flags); init_crit.xatab.find(rmid)->second.ActivateConnection(); return XA_OK; } // // Dummy implementation (not called from MSDTC). // EXTERN_C static int __cdecl xa_end(XID *xid, int rmid, long flags) { char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_end %s rmid=%d flags=%ld\n", pgxid, rmid, flags); return XA_OK; } EXTERN_C static int __cdecl xa_rollback(XID *xid, int rmid, long flags) { int rmcode = XAER_RMERR; char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_rollback %s rmid=%d flags=%ld\n", pgxid, rmid, flags); map::iterator p; p = init_crit.xatab.find(rmid); if (p != init_crit.xatab.end()) { HDBC conn = p->second.ActivateConnection(); if (conn) { SQLCHAR cmdmsg[512], sqlstate[8]; HSTMT stmt; RETCODE ret; ret = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt); if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret) { mylog("Statement allocation error\n"); return rmcode; } _snprintf((char *) cmdmsg, sizeof(cmdmsg), "ROLLBACK PREPARED '%s'", pgxid); ret = SQLExecDirect(stmt, (SQLCHAR *) cmdmsg, SQL_NTS); switch (ret) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: rmcode = XA_OK; break; case SQL_ERROR: SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sqlstate, NULL, cmdmsg, sizeof(cmdmsg), NULL); mylog("xa_commit error %s '%s'\n", sqlstate, cmdmsg); if (_stricmp((char *) sqlstate, "42704") == 0) rmcode = XA_HEURHAZ; break; } SQLFreeHandle(SQL_HANDLE_STMT, stmt); } } return rmcode; } // // Dummy implementation (not called from MSDTC). // Anyway it's almost impossible to implement this routine properly. // EXTERN_C static int __cdecl xa_prepare(XID *xid, int rmid, long flags) { char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_prepare %s rmid=%d\n", pgxid, rmid); #ifdef _SLEEP_FOR_TEST_ Sleep(2000); #endif /* _SLEEP_FOR_TEST_ */ map::iterator p; p = init_crit.xatab.find(rmid); if (p != init_crit.xatab.end()) { HDBC conn = p->second.GetConnection(); if (conn) { } } return XAER_RMERR; } EXTERN_C static int __cdecl xa_commit(XID *xid, int rmid, long flags) { int rmcode = XAER_RMERR; char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_commit %s rmid=%d flags=%ld\n", pgxid, rmid, flags); #ifdef _SLEEP_FOR_TEST_ Sleep(2000); #endif /* _SLEEP_FOR_TEST_ */ map::iterator p; p = init_crit.xatab.find(rmid); if (p != init_crit.xatab.end()) { HDBC conn = p->second.ActivateConnection(); if (conn) { SQLCHAR cmdmsg[512], sqlstate[8]; HSTMT stmt; RETCODE ret; SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt); _snprintf((char *) cmdmsg, sizeof(cmdmsg), "COMMIT PREPARED '%s'", pgxid); ret = SQLExecDirect(stmt, (SQLCHAR *) cmdmsg, SQL_NTS); switch (ret) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: rmcode = XA_OK; break; case SQL_ERROR: SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sqlstate, NULL, cmdmsg, sizeof(cmdmsg), NULL); if (_stricmp((char *) sqlstate, "42704") == 0) rmcode = XA_HEURHAZ; break; } SQLFreeHandle(SQL_HANDLE_STMT, stmt); } } return rmcode; } EXTERN_C static int __cdecl xa_recover(XID *xids, long count, int rmid, long flags) { int rmcode = XAER_RMERR, rcount; mylog("xa_recover rmid=%d count=%d flags=%ld\n", rmid, count, flags); map::iterator p; p = init_crit.xatab.find(rmid); if (p == init_crit.xatab.end()) return rmcode; HDBC conn = p->second.ActivateConnection(); if (!conn) { if (p->second.AuthenticationError()) rmcode = 0; mylog("%s returns %d\n", __FUNCTION__, rmcode); return rmcode; } vector &vec = p->second.GetResultVec(); int pos = p->second.GetPos(); if ((flags & TMSTARTRSCAN) != 0) { HSTMT stmt; RETCODE ret; char buf[512]; vec.clear(); SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt); ret = SQLExecDirect(stmt, (SQLCHAR *) "select gid from pg_prepared_xacts", SQL_NTS); if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret) { SQLFreeHandle(SQL_HANDLE_STMT, stmt); pos = -1; goto onExit; } SQLBindCol(stmt, 1, SQL_C_CHAR, buf, sizeof(buf), NULL); ret = SQLFetch(stmt); while (SQL_NO_DATA_FOUND != ret) { vec.push_back(buf); ret = SQLFetch(stmt); } SQLFreeHandle(SQL_HANDLE_STMT, stmt); pos = 0; } rcount = (int) vec.size(); rmcode = rcount - pos; if (rmcode > count) rmcode = count; for (int i = 0; i < rmcode; i++, pos++) TextToXid(xids[i], vec[pos].c_str()); if ((flags & TMENDRSCAN) != 0) { vec.clear(); pos = -1; } mylog("return count=%d\n", rmcode); onExit: p->second.SetPos(pos); return rmcode; } // // I'm not sure if this is invoked from MSDTC // Anyway there's nothing to do with it. // EXTERN_C static int __cdecl xa_forget(XID *xid, int rmid, long flags) { char pgxid[258]; XidToText(*xid, pgxid); mylog("xa_forget %s rmid=%d\n", pgxid, rmid); return XA_OK; } // // I'm not sure if this can be invoked from MSDTC. // EXTERN_C static int __cdecl xa_complete(int *handle, int *retval, int rmid, long flags) { mylog("xa_complete rmid=%d\n", rmid); return XA_OK; } EXTERN_C static xa_switch_t xapsw = { "psotgres_xa", TMNOMIGRATE, 0, xa_open, xa_close, xa_start, xa_end, xa_rollback, xa_prepare, xa_commit, xa_recover, xa_forget, xa_complete}; EXTERN_C HRESULT __cdecl GetXaSwitch (XA_SWITCH_FLAGS XaSwitchFlags, xa_switch_t ** ppXaSwitch) { mylog("GetXaSwitch called\n"); GetMsdtclog(); *ppXaSwitch = &xapsw; return S_OK; } psqlodbc-REL-16_00_0005/pgxalib.def000066400000000000000000000001331462406103600166010ustar00rootroot00000000000000LIBRARY pgxalib EXPORTS DllMain @201 GetXaSwitch @203 GetMsdtclog @204 SetMsdtclog @205 psqlodbc-REL-16_00_0005/psqlodbc.c000066400000000000000000000100471462406103600164530ustar00rootroot00000000000000/*-------- * Module: psqlodbc.c * * Description: This module contains the main entry point (DllMain) * for the library. It also contains functions to get * and set global variables for the driver in the registry. * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *-------- */ #ifdef WIN32 #ifdef _DEBUG #include #endif /* _DEBUG */ #endif /* WIN32 */ #include "psqlodbc.h" #include "dlg_specific.h" #include "environ.h" #include "misc.h" #include #ifdef WIN32 #include "loadlib.h" #else #include #endif static int exepgm = 0; BOOL isMsAccess(void) {return 1 == exepgm;} BOOL isMsQuery(void) {return 2 == exepgm;} BOOL isSqlServr(void) {return 3 == exepgm;} RETCODE SQL_API SQLDummyOrdinal(void); #if defined(WIN_MULTITHREAD_SUPPORT) extern CRITICAL_SECTION conns_cs, common_cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) extern pthread_mutex_t conns_cs, common_cs; #ifdef POSIX_THREADMUTEX_SUPPORT #ifdef PG_RECURSIVE_MUTEXATTR static pthread_mutexattr_t recur_attr; const pthread_mutexattr_t* getMutexAttr(void) { static int init = 1; if (init) { if (0 != pthread_mutexattr_init(&recur_attr)) return NULL; if (0 != pthread_mutexattr_settype(&recur_attr, PG_RECURSIVE_MUTEXATTR)) return NULL; } init = 0; return &recur_attr; } #else const pthread_mutexattr_t* getMutexAttr(void) { return NULL; } #endif /* PG_RECURSIVE_MUTEXATTR */ #endif /* POSIX_THREADMUTEX_SUPPORT */ #endif /* WIN_MULTITHREAD_SUPPORT */ int initialize_global_cs(void) { static int init = 1; if (!init) return 0; init = 0; #ifdef WIN32 #ifdef _DEBUG #ifdef _MEMORY_DEBUG_ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); #endif /* _MEMORY_DEBUG_ */ #endif /* _DEBUG */ #endif /* WIN32 */ #ifdef POSIX_THREADMUTEX_SUPPORT getMutexAttr(); #endif /* POSIX_THREADMUTEX_SUPPORT */ InitializeLogging(); INIT_CONNS_CS; INIT_COMMON_CS; return 0; } static void finalize_global_cs(void) { DELETE_COMMON_CS; DELETE_CONNS_CS; FinalizeLogging(); #ifdef _DEBUG #ifdef _MEMORY_DEBUG_ // _CrtDumpMemoryLeaks(); #endif /* _MEMORY_DEBUG_ */ #endif /* _DEBUG */ } #ifdef WIN32 HINSTANCE s_hModule; /* Saved module handle. */ /* This is where the Driver Manager attaches to this Driver */ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { const char *exename = GetExeProgramName(); switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: s_hModule = hInst; /* Save for dialog boxes */ if (stricmp(exename, "msaccess") == 0) exepgm = 1; else if (strnicmp(exename, "msqry", 5) == 0) exepgm = 2; else if (strnicmp(exename, "sqlservr", 8) == 0) exepgm = 3; initialize_global_cs(); MYLOG(0, "exe name=%s\n", exename); break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: MYLOG(0, "DETACHING %s\n", DRIVER_FILE_NAME); CleanupDelayLoadedDLLs(); /* my(q)log is unavailable from here */ finalize_global_cs(); return TRUE; case DLL_THREAD_DETACH: break; default: break; } return TRUE; UNREFERENCED_PARAMETER(lpReserved); } #else /* not WIN32 */ #if defined(__GNUC__) || defined(__SUNPRO_C) /* Shared library initializer and destructor, using gcc's attributes */ static void __attribute__((constructor)) psqlodbc_init(void) { initialize_global_cs(); } static void __attribute__((destructor)) psqlodbc_fini(void) { finalize_global_cs(); } #else /* not __GNUC__ */ /* Shared library initialization on non-gcc systems. */ BOOL _init(void) { initialize_global_cs(); return TRUE; } BOOL _fini(void) { finalize_global_cs(); return TRUE; } #endif /* not __GNUC__ */ #endif /* not WIN32 */ /* * This function is used to cause the Driver Manager to * call functions by number rather than name, which is faster. * The ordinal value of this function must be 199 to have the * Driver Manager do this. Also, the ordinal values of the * functions must match the value of fFunction in SQLGetFunctions() */ RETCODE SQL_API SQLDummyOrdinal(void) { return SQL_SUCCESS; } psqlodbc-REL-16_00_0005/psqlodbc.def000066400000000000000000000041451462406103600167710ustar00rootroot00000000000000LIBRARY psqlodbc35w EXPORTS ;;SQLAllocConnect @1 ;;SQLAllocEnv @2 ;;SQLAllocStmt @3 SQLBindCol @4 SQLCancel @5 ;;SQLColAttributes @6 ;SQLConnect @7 ;SQLDescribeCol @8 SQLDisconnect @9 ;;SQLError @10 ;SQLExecDirect @11 SQLExecute @12 SQLFetch @13 ;;SQLFreeConnect @14 ;;SQLFreeEnv @15 SQLFreeStmt @16 ;SQLGetCursorName @17 SQLNumResultCols @18 ;SQLPrepare @19 SQLRowCount @20 ;SQLSetCursorName @21 ;;SQLTransact @23 ;SQLColumns @40 ;SQLDriverConnect @41 SQLGetData @43 SQLGetFunctions @44 ;SQLGetInfo @45 ;;SQLGetStmtOption @46 ;SQLGetTypeInfo @47 SQLParamData @48 SQLPutData @49 ;SQLSpecialColumns @52 ;SQLStatistics @53 ;SQLTables @54 SQLBrowseConnect @55 ;SQLColumnPrivileges @56 SQLDescribeParam @58 SQLExtendedFetch @59 ;SQLForeignKeys @60 SQLMoreResults @61 ;SQLNativeSql @62 SQLNumParams @63 ;;SQLParamOptions @64 ;SQLPrimaryKeys @65 ;SQLProcedureColumns @66 ;SQLProcedures @67 SQLSetPos @68 SQLSetScrollOptions @69 ;SQLTablePrivileges @70 SQLBindParameter @72 SQLAllocHandle @80 SQLBindParam @81 SQLCloseCursor @82 ;SQLColAttribute @83 SQLCopyDesc @84 SQLEndTran @85 SQLFetchScroll @86 SQLFreeHandle @87 ;SQLGetDescField @88 ;SQLGetDescRec @89 ;SQLGetDiagField @90 ;SQLGetDiagRec @91 SQLGetEnvAttr @92 ;SQLGetConnectAttr @93 ;SQLGetStmtAttr @94 ;SQLSetConnectAttr @95 ;SQLSetDescField @96 ;SQLSetDescRec @97 SQLSetEnvAttr @98 ;SQLSetStmtAttr @99 SQLBulkOperations @100 SQLDummyOrdinal @199 dconn_FDriverConnectProc @200 DllMain @201 ConfigDSN @202 ConfigDriver @203 SQLColAttributeW @101 SQLColumnPrivilegesW @102 SQLColumnsW @103 SQLConnectW @104 SQLDescribeColW @106 SQLExecDirectW @107 SQLForeignKeysW @108 SQLGetConnectAttrW @109 SQLGetCursorNameW @110 SQLGetInfoW @111 SQLNativeSqlW @112 SQLPrepareW @113 SQLPrimaryKeysW @114 SQLProcedureColumnsW @115 SQLProceduresW @116 SQLSetConnectAttrW @117 SQLSetCursorNameW @118 SQLSpecialColumnsW @119 SQLStatisticsW @120 SQLTablesW @121 SQLTablePrivilegesW @122 SQLDriverConnectW @123 SQLGetDiagRecW @124 SQLGetStmtAttrW @125 SQLSetStmtAttrW @126 SQLSetDescFieldW @127 SQLGetTypeInfoW @128 SQLGetDiagFieldW @129 SQLGetDescFieldW @130 SQLGetDescRecW @131 SQLSetDescRecW @132 psqlodbc-REL-16_00_0005/psqlodbc.dsp000066400000000000000000000203271462406103600170210ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="psqlODBC" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=psqlODBC - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "psqlodbc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "psqlodbc.mak" CFG="psqlODBC - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "psqlODBC - Win32 Release" ("Win32 (x86) Console Application") !MESSAGE "psqlODBC - Win32 Debug" ("Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "psqlODBC - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" /D "WIN_MULTITHREAD_SUPPORT" /D "DYNAMIC_LOAD" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /Fp"psqlodbc.pch" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "C:\Program Files\PostgreSQL\9.3\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" /D "WIN_MULTITHREAD_SUPPORT" /D "DYNAMIC_LOAD" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /Fp"psqlodbc.pch" /YX /FD" /c # ADD BASE RSC /l 0x411 /d "NDEBUG" # ADD RSC /l 0x411 /i "." /d "NDEBUG" # SUBTRACT RSC /x BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib XOleHlp.lib winmm.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 wsock32.lib XOleHlp.lib winmm.lib libpq.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /pdb:"psqlodbc35w.pdb" /machine:I386 /out:"psqlodbc35w.dll" /implib:"psqlodbc35w.lib" /libpath:"C:\Program Files\PostgreSQL\9.3\lib\ms" # SUBTRACT LINK32 /pdb:none /nodefaultlib !ELSEIF "$(CFG)" == "psqlODBC - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" /D "WIN_MULTITHREAD_SUPPORT" /D "DYNAMIC_LOAD" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "C:\Program Files\PostgreSQL\9.3\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PSQLODBC_EXPORTS" /D "DRIVER_CURSOR_IMPLEMENT" /D "WIN_MULTITHREAD_SUPPORT" /D "DYNAMIC_LOAD" /D "MULTIBYTE" /D "UNICODE_SUPPORT" /FR /YX /FD /c # SUBTRACT CPP /X # ADD BASE RSC /l 0x411 /d "_DEBUG" # ADD RSC /l 0x411 /i "." /d "_DEBUG" # SUBTRACT RSC /x BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib XOleHlp.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 # ADD LINK32 wsock32.lib XOleHlp.lib winmm.lib libpq.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /pdb:"psqlodbc35w.pdb" /debug /machine:I386 /out:"psqlodbc35w.dll" /implib:"psqlodbc35w.lib" /libpath:"C:\Program Files\PostgreSQL\9.3\lib\ms" # SUBTRACT LINK32 /pdb:none /nodefaultlib !ENDIF # Begin Target # Name "psqlODBC - Win32 Release" # Name "psqlODBC - Win32 Debug" # Begin Group "source" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=bind.c # End Source File # Begin Source File SOURCE=columninfo.c # End Source File # Begin Source File SOURCE=connection.c # End Source File # Begin Source File SOURCE=convert.c # End Source File # Begin Source File SOURCE=.\descriptor.c # End Source File # Begin Source File SOURCE=dlg_specific.c # End Source File # Begin Source File SOURCE=dlg_wingui.c # End Source File # Begin Source File SOURCE=drvconn.c # End Source File # Begin Source File SOURCE=environ.c # End Source File # Begin Source File SOURCE=execute.c # End Source File # Begin Source File SOURCE=info.c # End Source File # Begin Source File SOURCE=.\inouealc.c # End Source File # Begin Source File SOURCE=.\loadlib.c # End Source File # Begin Source File SOURCE=lobj.c # End Source File # Begin Source File SOURCE=misc.c # End Source File # Begin Source File SOURCE=multibyte.c # End Source File # Begin Source File SOURCE=.\mylog.c # End Source File # Begin Source File SOURCE=.\odbcapi.c # End Source File # Begin Source File SOURCE=.\odbcapi30.c # End Source File # Begin Source File SOURCE=.\odbcapi30w.c # End Source File # Begin Source File SOURCE=.\odbcapiw.c # End Source File # Begin Source File SOURCE=options.c # End Source File # Begin Source File SOURCE=parse.c # End Source File # Begin Source File SOURCE=pgapi30.c # End Source File # Begin Source File SOURCE=pgtypes.c # End Source File # Begin Source File SOURCE=psqlodbc.c # End Source File # Begin Source File SOURCE=qresult.c # End Source File # Begin Source File SOURCE=results.c # End Source File # Begin Source File SOURCE=setup.c # End Source File # Begin Source File SOURCE=statement.c # End Source File # Begin Source File SOURCE=tuple.c # End Source File # Begin Source File SOURCE=.\win_unicode.c # End Source File # End Group # Begin Group "include" # PROP Default_Filter "" # Begin Source File SOURCE=bind.h # End Source File # Begin Source File SOURCE=columninfo.h # End Source File # Begin Source File SOURCE=connection.h # End Source File # Begin Source File SOURCE=convert.h # End Source File # Begin Source File SOURCE=descriptor.h # End Source File # Begin Source File SOURCE=dlg_specific.h # End Source File # Begin Source File SOURCE=environ.h # End Source File # Begin Source File SOURCE=iodbc.h # End Source File # Begin Source File SOURCE=isql.h # End Source File # Begin Source File SOURCE=isqlext.h # End Source File # Begin Source File SOURCE=.\loadlib.h # End Source File # Begin Source File SOURCE=lobj.h # End Source File # Begin Source File SOURCE=misc.h # End Source File # Begin Source File SOURCE=multibyte.h # End Source File # Begin Source File SOURCE=pgapifunc.h # End Source File # Begin Source File SOURCE=pgtypes.h # End Source File # Begin Source File SOURCE=psqlodbc.h # End Source File # Begin Source File SOURCE=qresult.h # End Source File # Begin Source File SOURCE=socket.h # End Source File # Begin Source File SOURCE=statement.h # End Source File # Begin Source File SOURCE=tuple.h # End Source File # Begin Source File SOURCE=tuplelist.h # End Source File # Begin Source File SOURCE=win_setup.h # End Source File # End Group # Begin Group "resource" # PROP Default_Filter "" # Begin Source File SOURCE=.\psqlodbc.def # End Source File # Begin Source File SOURCE=.\psqlodbc.rc # End Source File # Begin Source File SOURCE=resource.h # End Source File # End Group # End Target # End Project psqlodbc-REL-16_00_0005/psqlodbc.h000066400000000000000000000501131462406103600164560ustar00rootroot00000000000000/* File: psqlodbc.h * * Description: This file contains defines and declarations that are related to * the entire driver. * * Comments: See "readme.txt" for copyright and license information. */ #ifndef __PSQLODBC_H__ #define __PSQLODBC_H__ /* #define __MS_REPORTS_ANSI_CHAR__ */ #ifndef WIN32 #include "config.h" #else #define WIN32_LEAN_AND_MEAN #include #endif #include /* for FILE* pointers: see GLOBAL_VALUES */ #ifdef POSIX_MULTITHREAD_SUPPORT #include #endif #include "version.h" #ifdef _MIMALLOC_ #include #else /* _MIMALLOC_ */ #ifdef WIN32 #ifdef _DEBUG #ifndef _MEMORY_DEBUG_ #include #if (_MSC_VER < 1400) /* in case of VC7 or under */ #include #endif /* _MSC_VER */ #define _CRTDBG_MAP_ALLOC #include #endif /* _MEMORY_DEBUG_ */ #else /* _DEBUG */ #include #endif /* _DEBUG */ #include #else /* WIN32 */ #include #endif /* WIN32 */ #endif /* _MIMALLOC_ */ #ifdef WIN32 #include #endif /* WIN32 */ #ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */ /* * Unfortunately #including postgres_fe.h causes various trobles. */ #include "postgres_fe.h" #else /* currently */ #if defined(__GNUC__) || defined(__IBMC__) #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 404 #define PG_PRINTF_ATTRIBUTE gnu_printf #else #define PG_PRINTF_ATTRIBUTE printf #endif #define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a))) #else #define __attribute__(x) #define pg_attribute_printf(f,a) #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 #ifndef WIN32 #define pg_strdup strdup #else #define pg_strdup _strdup #endif /* WIN32 */ #define pg_free free #endif /* _MIMALLOC_ */ #ifdef _MEMORY_DEBUG_ void *pgdebug_alloc(size_t); void *pgdebug_calloc(size_t, size_t); void *pgdebug_realloc(void *, size_t); char *pgdebug_strdup(const char *); void *pgdebug_memcpy(void *, const void *, size_t); void *pgdebug_memset(void *, int c, size_t); char *pgdebug_strcpy(char *, const char *); char *pgdebug_strncpy(char *, const char *, size_t); char *pgdebug_strncpy_null(char *, const char *, size_t); void pgdebug_free(void *); void debug_memory_check(void); #ifdef WIN32 #undef strdup #endif /* WIN32 */ #define malloc pgdebug_alloc #define realloc pgdebug_realloc #define calloc pgdebug_calloc #define strdup pgdebug_strdup #define free pgdebug_free #define strcpy pgdebug_strcpy #define strncpy pgdebug_strncpy /* #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 #include #endif /* WIN32 */ /* Must come before sql.h */ #define ODBCVER 0x0351 /* * Default NAMEDATALEN value in the server. The server can be compiled with * a different value, but this will do. */ #define NAMEDATALEN_V73 64 #ifndef NAMESTORAGELEN #define NAMESTORAGELEN 64 #endif /* NAMESTORAGELEN */ #ifndef WIN32 #undef WIN_MULTITHREAD_SUPPORT #endif #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC) #include #include #if defined(WIN32) && (_MSC_VER < 1300) /* in case of VC6 or under */ #define SQLLEN SQLINTEGER #define SQLULEN SQLUINTEGER #define SQLSETPOSIROW SQLUSMALLINT /* VC6 bypasses 64bit mode. */ #define DWLP_USER DWL_USER #define ULONG_PTR ULONG #define LONG_PTR LONG #define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam) #define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER); #endif #else #include "iodbc.h" #include "isql.h" #include "isqlext.h" #endif /* WIN32 */ #if defined(WIN32) #include #elif defined(WITH_UNIXODBC) #include #elif defined(WITH_IODBC) #include #endif #ifdef __cplusplus extern "C" { #endif #define Int4 int #define UInt4 unsigned int #define Int2 short #define UInt2 unsigned short typedef SQLBIGINT Int8; typedef UInt4 OID; #ifndef SQL_TRUE #define SQL_TRUE TRUE #endif /* SQL_TRUE */ #ifndef SQL_FALSE #define SQL_FALSE FALSE #endif /* SQL_FALSE */ #define FORMAT_SMALLI "%d" /* SQLSMALLINT */ #define FORMAT_USMALLI "%u" /* SQLUSMALLINT */ #ifdef WIN32 #ifndef SSIZE_T_DEFINED #define ssize_t SSIZE_T #define SSIZE_T_DEFINED #endif /* SSIZE_T */ #define FORMAT_SIZE_T "%Iu" /* size_t */ #define FORMAT_SSIZE_T "%Id" /* ssize_t */ #define FORMAT_INTEGER "%ld" /* SQLINTEGER */ #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ #define FORMATI64 "%I64d" /* SQLBIGINT */ #define FORMATI64U "%I64u" /* SQLUBIGINT */ #ifdef _WIN64 #define FORMAT_LEN "%I64d" /* SQLLEN */ #define FORMAT_ULEN "%I64u" /* SQLULEN */ #define FORMAT_POSIROW "%I64u" #else /* _WIN64 */ #define FORMAT_LEN "%ld" /* SQLLEN */ #define FORMAT_ULEN "%lu" /* SQLULEN */ #define FORMAT_POSIROW "%hu" #endif /* _WIN64 */ #else /* WIN32 */ #define FORMAT_SIZE_T "%zu" /* size_t */ #define FORMAT_SSIZE_T "%zd" /* ssize_t */ #ifndef HAVE_SSIZE_T typedef long ssize_t #endif /* HAVE_SSIZE_T */ #if (SIZEOF_VOID_P == SIZEOF_LONG) /* ILP32 or LP64 */ typedef long LONG_PTR; typedef unsigned long ULONG_PTR; #elif defined (HAVE_LONG_LONG) /* LLP64 */ typedef long long LONG_PTR; typedef unsigned long long ULONG_PTR; #else /* SIZEOF_VOID_P */ #error appropriate long pointer type not found #endif /* SIZEOF_VOID_P */ #if (SIZEOF_LONG == 8) /* LP64 */ #define FORMAT_INTEGER "%d" /* SQLINTEGER */ #define FORMAT_UINTEGER "%u" /* SQLUINTEGER */ #define FORMATI64 "%ld" /* SQLBIGINT */ #define FORMATI64U "%lu" /* SQLUBIGINT */ #if defined(WITH_UNIXODBC) && defined(BUILD_LEGACY_64_BIT_MODE) #define FORMAT_LEN "%d" /* SQLLEN */ #define FORMAT_ULEN "%u" /* SQLULEN */ #else /* WITH_UNIXODBC */ #define FORMAT_LEN "%ld" /* SQLLEN */ #define FORMAT_ULEN "%lu" /* SQLULEN */ #endif /* WITH_UNIXODBC */ #else /* SIZEOF_LONG */ #define FORMAT_INTEGER "%ld" /* SQLINTEGER */ #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ #if defined(HAVE_LONG_LONG) #define FORMATI64 "%lld" /* SQLBIGINT */ #define FORMATI64U "%llu" /* SQLUBIGINT */ #if (SIZEOF_VOID_P == 8) /* LLP64 */ #define FORMAT_LEN "%lld" /* SQLLEN */ #define FORMAT_ULEN "%llu" /* SQLULEN */ #else /* SIZEOF_VOID_P ILP32 */ #define FORMAT_LEN "%ld" /* SQLLEN */ #define FORMAT_ULEN "%lu" /* SQLULEN */ #endif /* SIZEOF_VOID_P */ #else /* HAVE_LONG_LONG */ #define FORMAT_LEN "%ld" /* SQLLEN */ #define FORMAT_ULEN "%lu" /* SQLULEN */ #endif /* HAVE_LONG_LONG */ #endif /* SIZEOF_LONG */ #if (SIZEOF_VOID_P == 8) && !defined(WITH_IODBC) #define FORMAT_POSIROW FORMAT_ULEN #else #define FORMAT_POSIROW "%u" #endif #endif /* WIN32 */ #define CAST_PTR(type, ptr) (type)((LONG_PTR)(ptr)) #define CAST_UPTR(type, ptr) (type)((ULONG_PTR)(ptr)) #ifndef SQL_IS_LEN #define SQL_IS_LEN (-1000) #endif /* SQL_IS_LEN */ #ifdef HAVE_SIGNED_CHAR typedef signed char po_ind_t; #else typedef char po_ind_t; #endif /* HAVE_SIGNED_CHAR */ #ifndef WIN32 #if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC) typedef float SFLOAT; typedef double SDOUBLE; #endif /* WITH_UNIXODBC */ #ifndef CALLBACK #define CALLBACK #endif /* CALLBACK */ #endif /* WIN32 */ #ifndef __cplusplus #ifdef PG_USE_STDBOOL #include #else #ifndef bool typedef unsigned char bool; #endif #ifndef true #define true ((bool) 1) #endif #ifndef false #define false ((bool) 0) #endif #endif /* not PG_USE_STDBOOL */ #endif /* not C++ */ #ifndef WIN32 #define stricmp strcasecmp #define strnicmp strncasecmp #ifndef TRUE #define TRUE (BOOL)1 #endif /* TRUE */ #ifndef FALSE #define FALSE (BOOL)0 #endif /* FALSE */ #else #if (_MSC_VER < 1900) /* vc12 or under */ #define POSIX_SNPRINTF_REQUIRED #define snprintf posix_snprintf extern int posix_snprintf(char *buf, size_t size, const char *format, ...); #endif /* _MSC_VER */ #ifndef strdup #define strdup _strdup #endif /* strdup */ #define strnicmp _strnicmp #define stricmp _stricmp #endif /* WIN32 */ #define IS_NOT_SPACE(c) ((c) && !isspace((UCHAR) c)) #ifndef SQL_ATTR_APP_ROW_DESC #define SQL_ATTR_APP_ROW_DESC 10010 #endif #ifndef SQL_ATTR_APP_PARAM_DESC #define SQL_ATTR_APP_PARAM_DESC 10011 #endif #ifndef SQL_ATTR_IMP_ROW_DESC #define SQL_ATTR_IMP_ROW_DESC 10012 #endif #ifndef SQL_ATTR_IMP_PARAM_DESC #define SQL_ATTR_IMP_PARAM_DESC 10013 #endif /* Driver stuff */ #define DRIVERNAME "PostgreSQL ODBC" #define DBMS_NAME_UNICODE "PostgreSQL Unicode" #define DBMS_NAME_ANSI "PostgreSQL ANSI" #define DRIVER_ODBC_VER "03.51" #ifdef UNICODE_SUPPORT #define WCLEN sizeof(SQLWCHAR) SQLULEN ucs2strlen(const SQLWCHAR *); #else #undef SQL_WCHAR #undef SQL_WVARCHAR #undef SQL_WLONGVARCHAR #undef SQL_C_WCHAR #define SQL_WCHAR SQL_WCHAR_IS_INHIBITED #define SQL_WVARCHAR SQL_WVARCHAR_IS_INHIBITED #define SQL_WLONGVARCHAR SQL_WLONGVARCHAR_IS_INHIBITED #define SQL_C_WCHAR SQL_C_WCHAR_IS_INHIBITED #endif #ifndef DBMS_NAME #ifdef _WIN64 #ifdef UNICODE_SUPPORT #define DBMS_NAME DBMS_NAME_UNICODE"(x64)" #else #define DBMS_NAME DBMS_NAME_ANSI"(x64)" #endif /* UNICODE_SUPPORT */ #else /* _WIN64 */ #ifdef UNICODE_SUPPORT #define DBMS_NAME DBMS_NAME_UNICODE #else #define DBMS_NAME DBMS_NAME_ANSI #endif /* UNICODE_SUPPORT */ #endif /* _WIN64 */ #endif /* DBMS_NAME */ #ifndef DBMS_NAME #define DBMS_NAME "PostgreSQL Legacy" #endif /* DBMS_NAME */ #ifdef WIN32 #ifdef UNICODE_SUPPORT #define DRIVER_FILE_NAME "PSQLODBC35W.DLL" #else #define DRIVER_FILE_NAME "PSQLODBC30A.DLL" #endif /* UNICODE_SUPPORT */ #else #ifdef UNICODE_SUPPORT #define DRIVER_FILE_NAME "psqlodbcw.so" #else #define DRIVER_FILE_NAME "psqlodbca.so" #endif #endif /* WIN32 */ BOOL isMsAccess(void); BOOL isMsQuery(void); BOOL isSqlServr(void); /* ESCAPEs */ #define ESCAPE_IN_LITERAL '\\' #define BYTEA_ESCAPE_CHAR '\\' #define SEARCH_PATTERN_ESCAPE '\\' #define LITERAL_QUOTE '\'' #define IDENTIFIER_QUOTE '\"' #define ODBC_ESCAPE_START '{' #define ODBC_ESCAPE_END '}' #define DOLLAR_QUOTE '$' #define LITERAL_EXT 'E' #define PG_CARRIAGE_RETURN '\r' #define PG_LINEFEED '\n' /* Limits */ #define MAXPGPATH 1024 /* see an easy way round this - DJP 24-1-2001 */ #define MAX_CONNECT_STRING 4096 #define FETCH_MAX 100 /* default number of rows to cache * for declare/fetch */ #define TUPLE_MALLOC_INC 100 #define MAX_CONNECTIONS 128 /* conns per environment * (arbitrary) */ #ifdef NAMEDATALEN #define MAX_SCHEMA_LEN NAMEDATALEN #define MAX_TABLE_LEN NAMEDATALEN #define MAX_COLUMN_LEN NAMEDATALEN #define NAME_FIELD_SIZE NAMEDATALEN /* size of name fields */ #if (NAMEDATALEN > NAMESTORAGELEN) #undef NAMESTORAGELEN #define NAMESTORAGELEN NAMEDATALEN #endif #endif /* NAMEDATALEN */ #define MAX_CURSOR_LEN 32 #define SCHEMA_NAME_STORAGE_LEN NAMESTORAGELEN #define TABLE_NAME_STORAGE_LEN NAMESTORAGELEN #define COLUMN_NAME_STORAGE_LEN NAMESTORAGELEN #define INDEX_KEYS_STORAGE_COUNT 32 /* Registry length limits */ #define LARGE_REGISTRY_LEN 4096 /* used for special cases */ #define MEDIUM_REGISTRY_LEN 256 /* normal size for * user,database,etc. */ #define SMALL_REGISTRY_LEN 10 /* for 1/0 settings */ /* These prefixes denote system tables */ #define POSTGRES_SYS_PREFIX "pg_" /* Info limits */ #define MAX_INFO_STRING 128 /* POSIX defines a PATH_MAX.( wondows is _MAX_PATH ..) */ #ifndef PATH_MAX #ifdef _MAX_PATH #define PATH_MAX _MAX_PATH #else #define PATH_MAX 1024 #endif /* _MAX_PATH */ #endif /* PATH_MAX */ typedef struct ConnectionClass_ ConnectionClass; typedef struct StatementClass_ StatementClass; typedef struct QResultClass_ QResultClass; typedef struct BindInfoClass_ BindInfoClass; typedef struct ParameterInfoClass_ ParameterInfoClass; typedef struct ParameterImplClass_ ParameterImplClass; typedef struct ColumnInfoClass_ ColumnInfoClass; typedef struct EnvironmentClass_ EnvironmentClass; typedef struct TupleField_ TupleField; typedef struct KeySet_ KeySet; typedef struct Rollback_ Rollback; typedef struct ARDFields_ ARDFields; typedef struct APDFields_ APDFields; typedef struct IRDFields_ IRDFields; typedef struct IPDFields_ IPDFields; typedef struct col_info COL_INFO; typedef struct lo_arg LO_ARG; typedef struct QResultHold_struct { QResultClass *first; QResultClass *last; } QResultHold; /* pgNAME type define */ typedef struct { char *name; } pgNAME; #define GET_NAME(the_name) ((the_name).name) #define SAFE_NAME(the_name) ((the_name).name ? (the_name).name : NULL_STRING) #define PRINT_NAME(the_name) ((the_name).name ? (the_name).name : PRINT_NULL) #define NAME_IS_NULL(the_name) (NULL == (the_name).name) #define NAME_IS_VALID(the_name) (NULL != (the_name).name) #define INIT_NAME(the_name) ((the_name).name = NULL) #define NULL_THE_NAME(the_name) \ do { \ if ((the_name).name) free((the_name).name); \ (the_name).name = NULL; \ } while (0) #define STR_TO_NAME(the_name, str) \ do { \ if ((the_name).name) \ free((the_name).name); \ (the_name).name = (str ? strdup((str)) : NULL); \ } while (0) #define STRX_TO_NAME(the_name, str) \ do { \ if ((the_name).name) \ free((the_name).name); \ (the_name).name = strdup((str)); \ } while (0) #define STRN_TO_NAME(the_name, str, n) \ do { \ if ((the_name).name) \ free((the_name).name); \ if (str) \ { \ (the_name).name = malloc((n) + 1); \ if ((the_name).name) \ { \ memcpy((the_name).name, str, (n)); \ (the_name).name[(n)] = '\0'; \ } \ } \ else \ (the_name).name = NULL; \ } while (0) #define NAME_TO_NAME(to, from) \ do { \ if ((to).name) \ free((to).name); \ if ((from).name) \ (to).name = strdup(from.name); \ else \ (to).name = NULL; \ } while (0) #define MOVE_NAME(to, from) \ do { \ if ((to).name) \ free((to).name); \ (to).name = (from).name; \ (from).name = NULL; \ } while (0) #define SET_NAME_DIRECTLY(the_name, str) ((the_name).name = (str)) #define NAMECMP(name1, name2) (strcmp(SAFE_NAME(name1), SAFE_NAME(name2))) #define NAMEICMP(name1, name2) (stricmp(SAFE_NAME(name1), SAFE_NAME(name2))) /* pgNAME define end */ typedef struct GlobalValues_ { pgNAME drivername; int fetch_max; int unknown_sizes; int max_varchar_size; int max_longvarchar_size; char debug; char commlog; char unique_index; char use_declarefetch; char text_as_longvarchar; char unknowns_as_longvarchar; char bools_as_char; char lie; char parse; char extra_systable_prefixes[MEDIUM_REGISTRY_LEN]; char protocol[SMALL_REGISTRY_LEN]; } GLOBAL_VALUES; void copy_globals(GLOBAL_VALUES *to, const GLOBAL_VALUES *from); void init_globals(GLOBAL_VALUES *glbv); void finalize_globals(GLOBAL_VALUES *glbv); typedef struct StatementOptions_ { SQLLEN maxRows; SQLLEN maxLength; SQLLEN keyset_size; SQLUINTEGER cursor_type; SQLUINTEGER scroll_concurrency; SQLUINTEGER retrieve_data; SQLUINTEGER use_bookmarks; void *bookmark_ptr; SQLUINTEGER metadata_id; SQLULEN stmt_timeout; } StatementOptions; /* Used to pass extra query info to send_query */ typedef struct QueryInfo_ { SQLLEN row_size; SQLLEN fetch_size; QResultClass *result_in; const char *cursor; } QueryInfo; /* Used to save the error information */ typedef struct { UInt4 status; Int2 errorsize; Int2 recsize; Int2 errorpos; char sqlstate[6]; SQLLEN diag_row_count; char __error_message[40]; } PG_ErrorInfo; PG_ErrorInfo *ER_Constructor(SDWORD errornumber, const char *errormsg); PG_ErrorInfo *ER_Dup(const PG_ErrorInfo *from); void ER_Destructor(PG_ErrorInfo *); RETCODE SQL_API ER_ReturnError(PG_ErrorInfo *, SQLSMALLINT, UCHAR *, SQLINTEGER *, UCHAR *, SQLSMALLINT, SQLSMALLINT *, UWORD); void logs_on_off(int cnopen, int, int); #define PG_TYPE_LO_UNDEFINED (-999) /* hack until permanent * type available */ #define PG_TYPE_LO_NAME "lo" #define CTID_ATTNUM (-1) /* the attnum of ctid */ #define OID_ATTNUM (-2) /* the attnum of oid */ #define XMIN_ATTNUM (-3) /* the attnum of xmin */ /* sizes */ #define TEXT_FIELD_SIZE 8190 /* size of default text fields * (not including null term) */ #define MAX_VARCHAR_SIZE 255 /* default maximum size of * varchar fields (not including null term) */ #define INFO_VARCHAR_SIZE 254 /* varchar field size * used in info.c */ #define PG_NUMERIC_MAX_PRECISION 1000 #define PG_NUMERIC_MAX_SCALE 1000 /* Sufficient digits to recover original float values */ #define PG_REAL_DIGITS 9 #define PG_DOUBLE_DIGITS 17 #define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for * queries used in info.c inoue * 2001/05/17 */ #define LENADDR_SHIFT(x, sft) ((x) ? (SQLLEN *)((char *)(x) + (sft)) : NULL) /* Structure to hold all the connection attributes for a specific connection (used for both registry and file, DSN and DRIVER) */ typedef struct { char dsn[MEDIUM_REGISTRY_LEN]; char desc[MEDIUM_REGISTRY_LEN]; char drivername[MEDIUM_REGISTRY_LEN]; char server[MEDIUM_REGISTRY_LEN]; char database[MEDIUM_REGISTRY_LEN]; char username[MEDIUM_REGISTRY_LEN]; pgNAME password; char port[SMALL_REGISTRY_LEN]; char sslmode[16]; char onlyread[SMALL_REGISTRY_LEN]; char fake_oid_index[SMALL_REGISTRY_LEN]; char show_oid_column[SMALL_REGISTRY_LEN]; char row_versioning[SMALL_REGISTRY_LEN]; char show_system_tables[SMALL_REGISTRY_LEN]; char translation_dll[MEDIUM_REGISTRY_LEN]; char translation_option[SMALL_REGISTRY_LEN]; char password_required; char conn_settings_in_str; char pqopt_in_str; pgNAME conn_settings; pgNAME pqopt; signed char allow_keyset; signed char updatable_cursors; signed char lf_conversion; signed char true_is_minus1; signed char int8_as; signed char bytea_as_longvarbinary; signed char use_server_side_prepare; signed char lower_case_identifier; signed char rollback_on_error; signed char force_abbrev_connstr; signed char bde_environment; signed char fake_mss; signed char cvt_null_date_string; signed char accessible_only; signed char ignore_round_trip_time; signed char disable_keepalive; signed char disable_convert_func; signed char wcs_debug; signed char numeric_as; signed char optional_errors; signed char ignore_timeout; signed char fetch_refcursors; UInt4 extra_opts; Int4 keepalive_idle; Int4 keepalive_interval; Int4 batch_size; #ifdef _HANDLE_ENLIST_IN_DTC_ signed char xa_opt; #endif /* _HANDLE_ENLIST_IN_DTC_ */ GLOBAL_VALUES drivers; /* moved from driver's option */ } ConnInfo; #define SUPPORT_DESCRIBE_PARAM(conninfo_) (conninfo_->use_server_side_prepare) int initialize_global_cs(void); enum { /* CC_conninfo_init option */ CLEANUP_FOR_REUSE = 1L /* reuse the info */ ,INIT_GLOBALS = (1L << 1) /* init globals members */ }; void CC_conninfo_init(ConnInfo *conninfo, UInt4 option); void CC_conninfo_release(ConnInfo *conninfo); void CC_copy_conninfo(ConnInfo *ci, const ConnInfo *sci); const char *GetExeProgramName(); #ifdef POSIX_MULTITHREAD_SUPPORT #if !defined(HAVE_ECO_THREAD_LOCKS) #define POSIX_THREADMUTEX_SUPPORT #endif /* HAVE_ECO_THREAD_LOCKS */ #endif /* POSIX_MULTITHREAD_SUPPORT */ #ifdef POSIX_THREADMUTEX_SUPPORT const pthread_mutexattr_t *getMutexAttr(void); #endif /* POSIX_THREADMUTEX_SUPPORT */ /* Define a type for defining a constant string expression */ #ifndef CSTR #define CSTR static const char * const #endif /* CSTR */ CSTR NULL_STRING = ""; CSTR PRINT_NULL = "(null)"; #define OID_NAME "oid" #define XMIN_NAME "xmin" #define TABLEOID_NAME "tableoid" enum { DISALLOW_UPDATABLE_CURSORS = 0, /* No cursors are updatable */ ALLOW_STATIC_CURSORS = 1L, /* Static cursors are updatable */ ALLOW_KEYSET_DRIVEN_CURSORS = (1L << 1), /* Keyset-driven cursors are updatable */ ALLOW_DYNAMIC_CURSORS = (1L << 2), /* Dynamic cursors are updatable */ ALLOW_BULK_OPERATIONS = (1L << 3), /* Bulk operations available */ SENSE_SELF_OPERATIONS = (1L << 4), /* Sense self update/delete/add */ }; #ifdef __cplusplus } #endif #include "mylog.h" #endif /* __PSQLODBC_H__ */ psqlodbc-REL-16_00_0005/psqlodbc.rc000066400000000000000000001133351462406103600166410ustar00rootroot00000000000000//Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winresrc.h" #ifndef IDC_STATIC #define IDC_STATIC (-1) #endif #include "version.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // Japanese resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) #ifdef _WIN32 LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT #pragma code_page(932) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // DLG_CONFIG DIALOGEX 65, 43, 359, 219 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU #ifdef UNICODE_SUPPORT CAPTION "PostgreSQL Unicode ODBC ZbgAbv" #else CAPTION "PostgreSQL ANSI ODBC ZbgAbv" #endif FONT 9, "lr SVbN", 0, 0, 0x1 BEGIN RTEXT "f|^\|X:(&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 RTEXT ":(&D)",IDC_DESCTEXT,5,31,60,16,SS_CENTERIMAGE | NOT WS_GROUP,WS_EX_TRANSPARENT | WS_EX_RIGHT EDITTEXT IDC_DESC,72,32,188,13,ES_AUTOHSCROLL,WS_EX_TRANSPARENT RTEXT "SSL Mode:(&L)",IDC_STATIC,16,49,49,9,NOT WS_GROUP COMBOBOX IDC_SSLMODE,72,47,90,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "libpqCuloads:SSLڑ͎gpł܂", IDC_NOTICE_USER,165,50,190,10 RTEXT "T|o|:(&S)",IDC_STATIC,17,68,48,15,NOT WS_GROUP EDITTEXT IDC_SERVER,72,66,203,14,ES_AUTOHSCROLL RTEXT "f|^x|X:(&b)",IDC_STATIC,5,91,60,15,NOT WS_GROUP EDITTEXT IDC_DATABASE,72,88,203,14,ES_AUTOHSCROLL RTEXT "&Port:",IDC_STATIC,281,101,22,11 EDITTEXT IDC_PORT,307,99,37,14,ES_AUTOHSCROLL RTEXT "|U|:(&U)",IDC_STATIC,18,139,47,15 EDITTEXT IDC_USER,72,135,162,14,ES_AUTOHSCROLL RTEXT "pX|h:(&w)",IDC_STATIC,21,159,46,15 EDITTEXT IDC_PASSWORD,72,157,162,13,ES_PASSWORD | ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,295,61,52,14,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,296,80,51,14 GROUPBOX "IvV (xȐݒ)",IDC_OPTIONS,249,119,99,59, BS_CENTER PUSHBUTTON "S̐ݒ",IDC_DRIVER,269,155,53,15 PUSHBUTTON "f|^\|X",IDC_DATASOURCE,269,132,53,15 GROUPBOX "̔F",IDC_STATIC,11,119,235,59 LTEXT "PostgreSQL Ver7.3 Copyright (C) 1998-2006; Insight Distribution Systems", IDC_STATIC,36,186,302,9 LTEXT "In the original form, Japanese patch Hiroshi-saito", IDC_STATIC,35,198,295,8 PUSHBUTTON "Ǘ",IDC_MANAGEDSN,295,10,50,14 PUSHBUTTON "eXg",IDC_TEST,296,30,51,14 END #define MISC_X #define MISC_Y 155 #define MISC_Y1 (MISC_Y+11) #define MISC_Y2 (MISC_Y+28) #define MISC_Y3 (MISC_Y+45) DLG_OPTIONS_DRV DIALOG DISCARDABLE 0, 0, 350, 241 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "xȐݒ (f[^\[XP)" FONT 9, "lr SVbN" BEGIN PUSHBUTTON "ݒ2",ID2NDPAGE,5,5,40,15 PUSHBUTTON "ݒ3",ID3RDPAGE,49,5,40,15 CONTROL "ʃOo͂(&L) (C:\\psqlodbc.log)",DRV_COMMLOG, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,24,167,10 EDITTEXT DS_COMMLOG,337,24,13,12,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT CONTROL "j|NCfbNXg(&I)",DRV_UNIQUEINDEX,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,129,10 CONTROL "^CAEg",DS_IGNORETIMEOUT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,167,56,129,10 CONTROL "Xe|gg̍\͂sȂ(&a)",DRV_PARSE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,167,40,152,10 CONTROL "Declare`Fetchgp(&U)",DRV_USEDECLAREFETCH, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,71,138,10 CONTROL "ڍ׃Oo͂(C:\\mylog_xxxx.log)",DRV_DEBUG, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,69,164,10 EDITTEXT DS_DEBUG,337,69,13,12,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT GROUPBOX "m̃TCY",IDC_STATIC,5,85,340,31 CONTROL "őƂ",DRV_UNKNOWN_MAX,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,98,57,10 CONTROL "肵Ȃ",DRV_UNKNOWN_DONTKNOW,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,99,98,59,10 CONTROL "ŒƂ",DRV_UNKNOWN_LONGEST,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,173,98,60,10 GROUPBOX "f|^ ^Cv IvV",IDC_STATIC,5,119,340,32 CONTROL "text𒷕ƂĈ",DRV_TEXT_LONGVARCHAR,"Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,12,132,107,10 CONTROL "s𒷕ƂĈ",DRV_UNKNOWNS_LONGVARCHAR, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,123,132,117,10 CONTROL "CharƂBools",DRV_BOOLS_CHAR,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,243,132,96,10 GROUPBOX "̑",IDC_STATIC,5,MISC_Y,340,57 LTEXT "ő&Varchar:",IDC_STATIC,13,MISC_Y1+1,54,8 EDITTEXT DRV_VARCHAR_SIZE,70,MISC_Y1,35,12,ES_AUTOHSCROLL LTEXT "őLon&gVarChar:",IDC_STATIC,148,MISC_Y1+2,66,8 EDITTEXT DRV_LONGVARCHAR_SIZE,219,MISC_Y1,35,12,ES_AUTOHSCROLL LTEXT ":",IDC_STATIC,21,MISC_Y2+1,39,8 EDITTEXT DRV_CACHE_SIZE,69,MISC_Y2-1,35,12,ES_AUTOHSCROLL LTEXT "ð ̨:",IDC_STATIC,140,MISC_Y2+1,74,9 EDITTEXT DRV_EXTRASYSTABLEPREFIXES,219,MISC_Y2-1,71,12,ES_AUTOHSCROLL LTEXT "ob`TCY:",IDC_STATIC,13,MISC_Y3+1,74,9 EDITTEXT DS_BATCH_SIZE,69,MISC_Y3-1,35,12,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,5,221,50,15,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,68,221,50,15 PUSHBUTTON "Kp",IDAPPLY,132,221,50,15 PUSHBUTTON "ftHg",IDDEFAULTS,295,221,50,15 END #define CONNSETTINGS_Y 185 // 191 #define KEEPALIVE_X 5 #define KEEPALIVE_Y 225 #define ENDLINE_Y 245 // 224 DLG_OPTIONS_DS DIALOG DISCARDABLE 0, 0, 306, 260 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "xȐݒ (f[^\[XQ)" FONT 9, "lr SVbN" BEGIN PUSHBUTTON "ݒ3",ID3RDPAGE,49,5,40,15 PUSHBUTTON "ݒ1",ID1STPAGE,5,5,40,15 CONTROL "|hIB(&R)",DS_READONLY,"Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,26,102,10 CONTROL "o|W\(&V)",DS_ROWVERSIONING,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,139,25,114,10 CONTROL "VXee|u\(&T)",DS_SHOWSYSTEMTABLES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,41,111,10 CONTROL "⏕IG[bZ[W\",DS_OPTIONALERRORS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,139,41,162,10 CONTROL "LF <-> CR/LF ϊs",DS_LFCONVERSION,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,106,10 CONTROL "-1 ^l(True)Ƃ",DS_TRUEISMINUS1,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,139,55,98,10 CONTROL "XV”\J[\",DS_UPDATABLECURSORS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,71,87,10 CONTROL "T[o[ Prepare(7.3Ȍ)",DS_SERVERSIDEPREPARE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,70,122,10 GROUPBOX "Int8 ̑֒`",IDC_STATIC,5,98,256,25 CONTROL "default",DS_INT8_AS_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,108,40,10 CONTROL "bigint",DS_INT8_AS_BIGINT,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,55,108,35,10 CONTROL "numeric",DS_INT8_AS_NUMERIC,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,108,40,10 CONTROL "varchar",DS_INT8_AS_VARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,141,108,40,10 CONTROL "double",DS_INT8_AS_DOUBLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,184,108,40,10 CONTROL "int4",DS_INT8_AS_INT4,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,227,108,29,10 LTEXT "ʂȃIvV",IDC_STATIC,227,158,66,8 EDITTEXT DS_EXTRA_OPTIONS,227,168,35,14,ES_AUTOHSCROLL GROUPBOX "Numeric(xwȂ) ̑֒`",IDC_STATIC,5,128,160,25 CONTROL "default",DS_NUMERIC_AS_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,140,40,10 // CONTROL "numeric",DS_NUMERIC_AS_NUMERIC,"Button",BS_AUTORADIOBUTTON | // WS_TABSTOP,50,140,40,10 CONTROL "memo",DS_NUMERIC_AS_LONGVARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,126,140,40,10 CONTROL "varchar",DS_NUMERIC_AS_VARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,50,140,40,10 CONTROL "double",DS_NUMERIC_AS_DOUBLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,90,140,36,10 GROUPBOX "G[̃[obNs",IDC_STATIC,170,128,130,25 CONTROL "",DS_NO_ROLLBACK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,175,139,30,10 CONTROL "Sݾ",DS_TRANSACTION_ROLLBACK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,205,140,50,10 CONTROL "P",DS_STATEMENT_ROLLBACK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,260,140,35,10 GROUPBOX "OID IvV",IDC_STATIC,5,158,206,25 CONTROL "J\(&C)",DS_SHOWOIDCOLUMN,"Button", BS_AUTOCHECKBOX | WS_GROUP,16,169,72,10 CONTROL "CfbNX𑕂(&I)",DS_FAKEOIDINDEX,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,107,169,95,10 LTEXT "ڑ ݒ:(&S)",IDC_STATIC,13,CONNSETTINGS_Y+3,69,10,NOT WS_GROUP EDITTEXT DS_CONNSETTINGS,90,CONNSETTINGS_Y,211,27,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_TABSTOP GROUPBOX "TCP KEEPALIVE(bP)",IDC_STATIC,KEEPALIVE_X,KEEPALIVE_Y-10,210,25 CONTROL "pȂ",DS_DISABLE_KEEPALIVE,"Button",BS_AUTOCHECKBOX | WS_GROUP, KEEPALIVE_X+5,KEEPALIVE_Y,50,10 LTEXT "҂",IDC_STATIC,KEEPALIVE_X+62,KEEPALIVE_Y,35,10,NOT WS_GROUP EDITTEXT DS_KEEPALIVETIME,KEEPALIVE_X+100,KEEPALIVE_Y,30,10, ES_AUTOHSCROLL | WS_TABSTOP LTEXT "Ҏ",IDC_STATIC,KEEPALIVE_X+137,KEEPALIVE_Y,40,10,NOT WS_GROUP EDITTEXT DS_KEEPALIVEINTERVAL,KEEPALIVE_X+180,KEEPALIVE_Y,30,10, ES_AUTOHSCROLL | WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,5,ENDLINE_Y,50,14,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,66,ENDLINE_Y,50,14 PUSHBUTTON "Kp",IDAPPLY,128,ENDLINE_Y,50,14 CONTROL "byteaLOƂĈ",DS_BYTEAASLONGVARBINARY,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,85,87,10 CONTROL "erefcursor猋ʂ擾܂",DS_FETCH_REFCURSORS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,139,85,140,10 END #define DTC_GRP_X 10 #define DTC_GRP_Y 60 #define DTC_GRP_WIDTH 200 #define DTC_GRP_HEIGHT 100 #define DTC_OPT_X (DTC_GRP_X) #define DTC_OPT_Y (DTC_GRP_Y+10) #define DTC_OPT_WIDTH 180 #define DTC_OPT_HEIGHT 45 #define DTC_LOG_X (DTC_GRP_X) #define DTC_LOG_Y (DTC_OPT_Y+60) #define LIBPQOPT_Y 185 DLG_OPTIONS_DS3 DIALOG DISCARDABLE 0, 0, 306, 243 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "xȐݒ (f[^\[XR)" FONT 9, "lr SVbN" BEGIN PUSHBUTTON "ݒ2",ID2NDPAGE,49,5,40,15 PUSHBUTTON "ݒ1",ID1STPAGE,5,5,40,15 GROUPBOX "UgUNV֘Aݒ",IDC_STATIC,DTC_GRP_X,DTC_GRP_Y,DTC_GRP_WIDTH,DTC_GRP_HEIGHT GROUPBOX "MSDTCJo[sڑ?",IDC_STATIC,DTC_OPT_X,DTC_OPT_Y,DTC_OPT_WIDTH,DTC_OPT_HEIGHT CONTROL "",DS_DTC_LINK_ONLY,"Button",BS_AUTORADIOBUTTON | WS_GROUP,DTC_OPT_X+5,DTC_OPT_Y+10,140,10 CONTROL "sslmode verify-[ca|full]",DS_DTC_SIMPLE_PRECHECK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,DTC_OPT_X+5,DTC_OPT_Y+20,140,10 CONTROL "Ȃ(ŏMSDTC̐ڑmF)",DS_DTC_CONFIRM_RM_CONNECTION,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,DTC_OPT_X+5,DTC_OPT_Y+30,170,10 PUSHBUTTON "ڑeXg",IDC_TEST,DTC_OPT_X+60,DTC_OPT_Y+75,51,14 LTEXT "libpqp[^:(&l)",IDC_STATIC,11,LIBPQOPT_Y+3,76,10,NOT WS_GROUP EDITTEXT DS_LIBPQOPT,90,LIBPQOPT_Y,211,27,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,5,224,50,14,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,66,224,50,14 PUSHBUTTON "Kp",IDAPPLY,128,224,50,14 END #undef ENDLINE_Y #define ENDLINE_Y 110 DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 130 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "xȐݒ(S)" FONT 9, "lr SVbN" BEGIN GROUPBOX "RlNVÕftHgMOIvV", IDC_STATIC,5,5,296,68 CONTROL "ʃO(&L) (C:\\psqlodbc_xxxx.log - R~jP|VO)", DRV_COMMLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,24, 249,10 CONTROL "pO (C:\\mylog_xxxx.log - ڍ׃fobOo̓O)", DRV_DEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,42, 220,10 RTEXT "MOptH_",IDC_STATIC,14,57,79,12 EDITTEXT DS_LOGDIR,98,55,188,13,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT GROUPBOX "MSDTCT|[g", IDC_STATIC,5,75,296,27 CONTROL "pO(C:\\pgdtclog\\mylog_xxxx.log - fobOo̓O)", DRV_DTCLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,87,260,10 DEFPUSHBUTTON "ۑ",IDOK,5,ENDLINE_Y,50,14,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,65,ENDLINE_Y,50,15 END DLG_DRIVER_CHANGE DIALOG DISCARDABLE 0, 0, 306, 87 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "hCo@Abv/_E" FONT 10, "Terminal" BEGIN DEFPUSHBUTTON "OK",IDOK,82,68,50,14,WS_GROUP PUSHBUTTON "LZ",IDCANCEL,172,67,50,15 GROUPBOX "hCoXg",IDC_STATIC,5,5,296,58 LTEXT "hCoIĂ",IDC_STATIC,11,33,105,8 LISTBOX IDC_DRIVER_LIST,124,19,170,33,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN DLG_CONFIG, DIALOG BEGIN VERTGUIDE, 65 VERTGUIDE, 72 VERTGUIDE, 260 BOTTOMMARGIN, 210 END DLG_OPTIONS_DRV, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 345 TOPMARGIN, 5 BOTTOMMARGIN, 236 END DLG_OPTIONS_DS, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 238 END DLG_OPTIONS_GLOBAL, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 82 END DLG_DRIVER_CHANGE, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 82 END END #endif // APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "#include ""version.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION PG_DRVFILE_VERSION PRODUCTVERSION PG_DRVFILE_VERSION FILEFLAGSMASK 0x3L #ifdef _DEBUG FILEFLAGS 0x9L #else FILEFLAGS 0x8L #endif FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "041104e4" BEGIN #ifdef UNICODE_SUPPORT VALUE "Comments", "PostgreSQL Unicode ODBC driver Japanese\0" #else VALUE "Comments", "PostgreSQL ANSI ODBC driver Japanese\0" #endif VALUE "CompanyName", "PostgreSQL Global Development Group\0" VALUE "FileDescription", "PostgreSQL ODBC Driver (Japanese)\0" VALUE "FileVersion", POSTGRES_RESOURCE_VERSION #ifdef UNICODE_SUPPORT VALUE "InternalName", "psqlodbc35w\0" #else VALUE "InternalName", "psqlodbc30a\0" #endif VALUE "LegalCopyright", "\0" VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation. Microsoft is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0" #ifdef UNICODE_SUPPORT VALUE "OriginalFilename", "psqlodbc35w.dll\0" #else VALUE "OriginalFilename", "psqlodbc30a.dll\0" #endif VALUE "PrivateBuild", "for Japanese by Hiroshi Inoue & Hiroshi Saito\0" VALUE "ProductName", "PostgreSQL\0" VALUE "ProductVersion", POSTGRES_RESOURCE_VERSION VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x411, 1252 END END #endif // !_MAC ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_BADDSN "DSNGg|słBēx`FbNݒ肵ĂB." IDS_MSGTITLE "DSNs" IDS_ADVANCE_OPTION_DEF "xȐݒ (ftHg)" IDS_ADVANCE_SAVE "ۑ" IDS_ADVANCE_OPTION_DSN1 "xȐݒ (%s ݒ1)" IDS_ADVANCE_OPTION_CON1 "xȐݒiRlNVݒPj" IDS_ADVANCE_OPTION_DSN2 "xȐݒ (%s ݒ2)" IDS_ADVANCE_OPTION_CON2 "xȐݒ (RlNVݒ2)" IDS_ADVANCE_OPTION_DSN3 "xȐݒ (%s ݒ3)" IDS_ADVANCE_OPTION_CON3 "xȐݒ (RlNVݒ3)" IDS_ADVANCE_CONNECTION "RlNV" END STRINGTABLE DISCARDABLE BEGIN IDS_SSLREQUEST_PREFER "D" IDS_SSLREQUEST_ALLOW "l" IDS_SSLREQUEST_REQUIRE "K{" IDS_SSLREQUEST_DISABLE "" IDS_SSLREQUEST_VERIFY_CA "K{:ؖF" IDS_SSLREQUEST_VERIFY_FULL "K{:ؖSF" END #endif // Japanese resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // DLG_CONFIG DIALOG DISCARDABLE 65, 43, 305, 142 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU #ifdef UNICODE_SUPPORT CAPTION "PostgreSQL Unicode ODBC Driver (psqlODBC) Setup" #else CAPTION "PostgreSQL ANSI ODBC Driver (psqlODBC) Setup" #endif FONT 8, "MS Sans Serif" BEGIN RTEXT "&Data Source",IDC_DSNAMETEXT,3,25,50,12,NOT WS_GROUP EDITTEXT IDC_DSNAME,57,24,72,12,ES_AUTOHSCROLL | WS_GROUP RTEXT "Des&cription",IDC_DESCTEXT,143,24,45,12,NOT WS_GROUP EDITTEXT IDC_DESC,192,22,104,12,ES_AUTOHSCROLL RTEXT "Data&base",IDC_STATIC,15,40,38,12,NOT WS_GROUP EDITTEXT IDC_DATABASE,57,39,72,12,ES_AUTOHSCROLL RTEXT "SS&L Mode",IDC_STATIC,143,40,45,12,NOT WS_GROUP COMBOBOX IDC_SSLMODE,192,36,104,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CTEXT "Couldn't load libpq - SSL mode is unavailable", IDC_NOTICE_USER,53,87,200,11,SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER RTEXT "&Server",IDC_STATIC,24,55,29,12,NOT WS_GROUP EDITTEXT IDC_SERVER,57,54,72,12,ES_AUTOHSCROLL RTEXT "&Port",IDC_STATIC,166,56,22,12 EDITTEXT IDC_PORT,192,54,37,12,ES_AUTOHSCROLL RTEXT "&User Name",IDC_STATIC,14,70,39,12 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 // 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 // PUSHBUTTON "Datasource",IDC_DATASOURCE,128,115,50,14 // PUSHBUTTON "Global",IDC_DRIVER,184,115,50,14 LTEXT "Please supply any missing information required to connect.", DRV_MSG_LABEL,12,5,249,10 // PUSHBUTTON "Manage DSN",IDC_MANAGEDSN,240,115,52,14 GROUPBOX "Options",IDC_OPTIONS,5,100,177,35,BS_LEFT PUSHBUTTON "Datasource",IDC_DATASOURCE,12,114,50,14 PUSHBUTTON "Global",IDC_DRIVER,67,114,50,14 PUSHBUTTON "Manage DSN",IDC_MANAGEDSN,122,114,52,14 PUSHBUTTON "Test",IDC_TEST,254,103,44,15 DEFPUSHBUTTON "OK",IDOK,203,121,44,15,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,254,121,44,15 END #undef MISC_Y #undef MISC_Y1 #undef MISC_Y2 #undef MISC_Y3 #define MISC_Y 145 #define MISC_Y1 (MISC_Y+15) #define MISC_Y2 (MISC_Y+32) #define MISC_Y3 (MISC_Y+49) DLG_OPTIONS_DRV DIALOG DISCARDABLE 0, 0, 287, 231 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Advanced Options (DataSource)" FONT 8, "MS Sans Serif" BEGIN PUSHBUTTON "Page 2",ID2NDPAGE,5,5,40,15 PUSHBUTTON "Page 3",ID3RDPAGE,49,5,40,15 CONTROL "Comm&Log (C:\\psqlodbc_xxxx.log)",DRV_COMMLOG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,149,26,121,10 EDITTEXT DS_COMMLOG,275,26,100,13,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT CONTROL "Recognize Unique &Indexes",DRV_UNIQUEINDEX,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,110,10 CONTROL "Ignore Timeout",DS_IGNORETIMEOUT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,149,56,110,10 CONTROL "P&arse Statements",DRV_PARSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,149,41,80,10 CONTROL "&Use Declare/Fetch",DRV_USEDECLAREFETCH,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,71,83,10 CONTROL "MyLog (C:\\mylog_xxxx.log)",DRV_DEBUG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,149,71,112,10 EDITTEXT DS_DEBUG,275,71,15,12,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT GROUPBOX "Unknown Sizes",IDC_STATIC,5,85,277,25 CONTROL "Maximum",DRV_UNKNOWN_MAX,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,96,45,10 CONTROL "Don't Know",DRV_UNKNOWN_DONTKNOW,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,105,96,53,10 CONTROL "Longest",DRV_UNKNOWN_LONGEST,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,215,95,50,10 GROUPBOX "Data Type Options",IDC_STATIC,5,115,277,25 CONTROL "Text as LongVarChar",DRV_TEXT_LONGVARCHAR,"Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,125,90,10 CONTROL "Unknowns as LongVarChar",DRV_UNKNOWNS_LONGVARCHAR, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,125,105,10 CONTROL "Bools as Char",DRV_BOOLS_CHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,215,125,67,10 GROUPBOX "Miscellaneous",IDC_STATIC,5,MISC_Y,277,62 LTEXT "Max &Varchar:",IDC_STATIC,13,MISC_Y1+1,54,8 EDITTEXT DRV_VARCHAR_SIZE,70,MISC_Y1,35,12,ES_AUTOHSCROLL LTEXT "Max Lon&gVarChar:",IDC_STATIC,125,MISC_Y1+1,67,8 EDITTEXT DRV_LONGVARCHAR_SIZE,199,MISC_Y1,35,12,ES_AUTOHSCROLL LTEXT "&Cache Size:",IDC_STATIC,14,MISC_Y2+1,52,8 EDITTEXT DRV_CACHE_SIZE,69,MISC_Y2-1,35,12,ES_AUTOHSCROLL LTEXT "SysTable &Prefixes:",IDC_STATIC,126,MISC_Y2+1,61,18 EDITTEXT DRV_EXTRASYSTABLEPREFIXES,199,MISC_Y2-1,71,12,ES_AUTOHSCROLL LTEXT "&Batch &Size:",IDC_STATIC,14,MISC_Y3+1,61,18 EDITTEXT DS_BATCH_SIZE,69,MISC_Y3-1,35,12,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,5,212,50,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,81,211,50,15 PUSHBUTTON "Apply",IDAPPLY,156,212,50,14 PUSHBUTTON "Defaults",IDDEFAULTS,232,211,50,15 END #undef CONNSETTINGS_Y #undef KEEPALIVE_X #undef KEEPALIVE_Y #undef ENDLINE_Y #define CONNSETTINGS_Y 185 // 189 #define KEEPALIVE_X 10 #define KEEPALIVE_Y 225 #define ENDLINE_Y 245 // 222 DLG_OPTIONS_DS DIALOG DISCARDABLE 0, 0, 306, 260 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Advanced Options (DataSource)" FONT 8, "MS Sans Serif" BEGIN PUSHBUTTON "Page 3",ID3RDPAGE,49,5,40,15 PUSHBUTTON "Page 1",ID1STPAGE,5,5,40,15 CONTROL "&Read Only",DS_READONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,26,102,10 CONTROL "Row &Versioning",DS_ROWVERSIONING,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,163,26,85,10 CONTROL "Show System &Tables",DS_SHOWSYSTEMTABLES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,41,100,10 CONTROL "Display Optional Error Message",DS_OPTIONALERRORS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,163,41,85,10 CONTROL "LF <-> CR/LF conversion",DS_LFCONVERSION,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,56,106,10 CONTROL "True is -1",DS_TRUEISMINUS1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,56,86,10 CONTROL "Updatable Cursors",DS_UPDATABLECURSORS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,71,87,10 CONTROL "Server side prepare",DS_SERVERSIDEPREPARE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,163,71,90,10 CONTROL "bytea as LO",DS_BYTEAASLONGVARBINARY,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,16,84,87,10 GROUPBOX "Int8 As",IDC_STATIC,5,97,256,25 CONTROL "default",DS_INT8_AS_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,107,40,10 CONTROL "Fetch result from each refcursor",DS_FETCH_REFCURSORS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,84,122,10 CONTROL "bigint",DS_INT8_AS_BIGINT,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,55,107,35,10 CONTROL "numeric",DS_INT8_AS_NUMERIC,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,107,40,10 CONTROL "varchar",DS_INT8_AS_VARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,141,107,40,10 CONTROL "double",DS_INT8_AS_DOUBLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,184,107,40,10 CONTROL "int4",DS_INT8_AS_INT4,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,227,107,29,10 LTEXT "Extra Opts",IDC_STATIC,264,98,40,17 EDITTEXT DS_EXTRA_OPTIONS,264,105,40,12,ES_AUTOHSCROLL GROUPBOX "Numeric(without precision) As",IDC_STATIC,5,126,160,25 CONTROL "default",DS_NUMERIC_AS_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,138,40,10 // CONTROL "numeric",DS_NUMERIC_AS_NUMERIC,"Button",BS_AUTORADIOBUTTON | // WS_TABSTOP,50,138,40,10 CONTROL "memo",DS_NUMERIC_AS_LONGVARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,126,138,40,10 CONTROL "varchar",DS_NUMERIC_AS_VARCHAR,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,50,138,40,10 CONTROL "double",DS_NUMERIC_AS_DOUBLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,90,138,36,10 GROUPBOX "OID Options",IDC_STATIC,5,157,296,25 CONTROL "Show &Column",DS_SHOWOIDCOLUMN,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,13,168,67,10 CONTROL "Fake &Index",DS_FAKEOIDINDEX,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,80,168,59,10 LTEXT "Connect &Settings:",IDC_STATIC,5,CONNSETTINGS_Y,57,11 EDITTEXT DS_CONNSETTINGS,90,CONNSETTINGS_Y,211,27,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN GROUPBOX "TCP KEEPALIVE setting (by sec)",IDC_STATIC,KEEPALIVE_X,KEEPALIVE_Y-10,210,25 CONTROL "disable",DS_DISABLE_KEEPALIVE,"Button",BS_AUTOCHECKBOX | WS_GROUP, KEEPALIVE_X+5,KEEPALIVE_Y,50,10 LTEXT "idle time",IDC_STATIC,KEEPALIVE_X+62,KEEPALIVE_Y,25,10,NOT WS_GROUP EDITTEXT DS_KEEPALIVETIME,KEEPALIVE_X+90,KEEPALIVE_Y,20,10, ES_AUTOHSCROLL | WS_TABSTOP LTEXT "interval",IDC_STATIC,KEEPALIVE_X+117,KEEPALIVE_Y,25,10,NOT WS_GROUP EDITTEXT DS_KEEPALIVEINTERVAL,KEEPALIVE_X+145,KEEPALIVE_Y,30,10, ES_AUTOHSCROLL | WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,5,ENDLINE_Y,50,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,81,ENDLINE_Y,50,14 PUSHBUTTON "Apply",IDAPPLY,156,ENDLINE_Y,50,14 GROUPBOX "Level of rollback on errors",IDC_STATIC,172,126,134,25 CONTROL "Nop",DS_NO_ROLLBACK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,176,138,36,9 CONTROL "Transaction",DS_TRANSACTION_ROLLBACK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,206,138,57,9 CONTROL "Statement",DS_STATEMENT_ROLLBACK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,257,138,47,9 END #undef DTC_GRP_X #undef DTC_GRP_Y #undef DTC_GRP_WIDTH #undef DTC_GRP_HEIGHT #undef DTC_OPT_X #undef DTC_OPT_Y #undef DTC_OPT_WIDTH #undef DTC_OPT_HEIGHT #undef DTC_LOG_X #undef DTC_LOG_Y #undef LIBPQOPT_Y #define DTC_GRP_X 10 #define DTC_GRP_Y 60 #define DTC_GRP_WIDTH 200 #define DTC_GRP_HEIGHT 100 #define DTC_OPT_X (DTC_GRP_X) #define DTC_OPT_Y (DTC_GRP_Y+10) #define DTC_OPT_WIDTH 180 #define DTC_OPT_HEIGHT 45 #define DTC_LOG_X (DTC_GRP_X) #define DTC_LOG_Y (DTC_OPT_Y+60) #define LIBPQOPT_Y 185 DLG_OPTIONS_DS3 DIALOG DISCARDABLE 0, 0, 306, 243 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Advanced Options(Datasource 3)" FONT 8, "MS Sans Serif" BEGIN PUSHBUTTON "Page 2",ID2NDPAGE,49,5,40,15 PUSHBUTTON "Page 1",ID1STPAGE,5,5,40,15 GROUPBOX "Distributed Transaction related settings",IDC_STATIC,DTC_GRP_X,DTC_GRP_Y,DTC_GRP_WIDTH,DTC_GRP_HEIGHT GROUPBOX "Allow connections unrecoverable by MSDTC?",IDC_STATIC,DTC_OPT_X,DTC_OPT_Y,DTC_OPT_WIDTH,DTC_OPT_HEIGHT CONTROL "yes",DS_DTC_LINK_ONLY,"Button",BS_AUTORADIOBUTTON | WS_GROUP,DTC_OPT_X+5,DTC_OPT_Y+10,40,10 CONTROL "rejects sslmode verify-[ca|full]",DS_DTC_SIMPLE_PRECHECK,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,DTC_OPT_X+5,DTC_OPT_Y+20,120,10 CONTROL "no (confirm the connectivity from MSDTC first)",DS_DTC_CONFIRM_RM_CONNECTION,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,DTC_OPT_X+5,DTC_OPT_Y+30,170,10 PUSHBUTTON "connection test",IDC_TEST,DTC_OPT_X+60,DTC_OPT_Y+75,55,14 LTEXT "libpq parameters:(&l)",IDC_STATIC,13,LIBPQOPT_Y+3,69,10,NOT WS_GROUP EDITTEXT DS_LIBPQOPT,85,LIBPQOPT_Y,215,27,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,5,224,50,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,66,224,50,14 PUSHBUTTON "Apply",IDAPPLY,128,224,50,14 END DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 110 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Global settings" FONT 8, "MS Sans Serif" BEGIN CONTROL "Comm&Log (C:\\psqlodbc_xxxx.log - Communications log)", DRV_COMMLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,24, 263,10 CONTROL "Mylog (C:\\mylog_xxxx.log - Detailed debug output)", DRV_DEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,42, 264,10 CONTROL "MSDTC log (C:\\pgdtclog\\mylog_xxxx.log - MSDTC debug output)", DRV_DTCLOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,60, 264,10 RTEXT "Folder for logging",IDC_STATIC,17,77,69,12 EDITTEXT DS_LOGDIR,98,75,188,13,ES_AUTOHSCROLL | WS_GROUP, WS_EX_TRANSPARENT DEFPUSHBUTTON "Save",IDOK,82,92,50,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,172,91,50,15 GROUPBOX "Pre-connection/default logging options",IDC_STATIC,5,5, 296,85 END DLG_DRIVER_CHANGE DIALOG DISCARDABLE 0, 0, 306, 87 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Driver up/downgrade" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,82,68,50,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,172,67,50,15 GROUPBOX "Drivers List",IDC_STATIC,5,5,296,58 LTEXT "Select the driver",IDC_STATIC,31,30,73,8 LISTBOX IDC_DRIVER_LIST,117,18,151,32,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN DLG_CONFIG, DIALOG BEGIN BOTTOMMARGIN, 141 END DLG_OPTIONS_DRV, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 282 TOPMARGIN, 5 BOTTOMMARGIN, 226 END DLG_OPTIONS_DS, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 238 HORZGUIDE, 136 END DLG_OPTIONS_GLOBAL, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 82 END DLG_DRIVER_CHANGE, DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 301 TOPMARGIN, 5 BOTTOMMARGIN, 82 END END #endif // APSTUDIO_INVOKED #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION PG_DRVFILE_VERSION PRODUCTVERSION PG_DRVFILE_VERSION FILEFLAGSMASK 0x3L #ifdef _DEBUG FILEFLAGS 0x9L #else FILEFLAGS 0x8L #endif FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN #ifdef UNICODE_SUPPORT VALUE "Comments", "PostgreSQL Unicode ODBC driver\0" #else VALUE "Comments", "PostgreSQL ANSI ODBC driver\0" #endif VALUE "CompanyName", "PostgreSQL Global Development Group\0" VALUE "FileDescription", "PostgreSQL ODBC Driver (English)\0" VALUE "FileVersion", POSTGRES_RESOURCE_VERSION #ifdef UNICODE_SUPPORT VALUE "InternalName", "psqlodbc35w\0" #else VALUE "InternalName", "psqlodbc30a\0" #endif VALUE "LegalCopyright", "Copyright \0" VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation. Microsoft? is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0" #ifdef UNICODE_SUPPORT VALUE "OriginalFilename", "psqlodbc35w.dll\0" #else VALUE "OriginalFilename", "psqlodbc30a.dll\0" #endif VALUE "PrivateBuild", "\0" VALUE "ProductName", "PostgreSQL\0" VALUE "ProductVersion", POSTGRES_RESOURCE_VERSION VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END #endif // !_MAC ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_BADDSN "Invalid DSN entry, please recheck." IDS_MSGTITLE "Invalid DSN" IDS_ADVANCE_OPTION_DEF "Advanced Options (Default)" IDS_ADVANCE_SAVE "Save" IDS_ADVANCE_OPTION_DSN1 "Advanced Options (%s) 1/3" IDS_ADVANCE_OPTION_CON1 "Advanced Options (Connection 1/3)" IDS_ADVANCE_OPTION_DSN2 "Advanced Options (%s) 2/3" IDS_ADVANCE_OPTION_DSN3 "Advanced Options (%s) 3/3" IDS_ADVANCE_OPTION_CON2 "Advanced Options (Connection 2/3)" IDS_ADVANCE_OPTION_CON3 "Advanced Options (Connection 3/3)" IDS_ADVANCE_CONNECTION "Connection" END STRINGTABLE DISCARDABLE BEGIN IDS_SSLREQUEST_PREFER "prefer" IDS_SSLREQUEST_ALLOW "allow" IDS_SSLREQUEST_REQUIRE "require" IDS_SSLREQUEST_DISABLE "disable" IDS_SSLREQUEST_VERIFY_CA "verify-ca" IDS_SSLREQUEST_VERIFY_FULL "verify-full" END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED P psqlodbc-REL-16_00_0005/psqlodbc.reg000066400000000000000000000012341462406103600170040ustar00rootroot00000000000000REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI] [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers] "PostgreSQL ANSI"="Installed" "PostgreSQL Unicode"="Installed" [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL ANSI] "APILevel"="1" "ConnectFunctions"="YYN" "Driver"="PSQLODBC30A.DLL" "DriverODBCVer"="03.00" "FileUsage"="0" "Setup"="PSQLODBC30A.DLL" "SQLLevel"="1" "UsageCount"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\PostgreSQL Unicode] "APILevel"="1" "ConnectFunctions"="YYN" "Driver"="PSQLODBC35W.DLL" "DriverODBCVer"="03.51" "FileUsage"="0" "Setup"="PSQLODBC35W.DLL" "SQLLevel"="1" "UsageCount"=dword:00000001 psqlodbc-REL-16_00_0005/psqlodbc.sln000066400000000000000000000021121462406103600170170ustar00rootroot00000000000000 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 Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C45ECB41-8473-4F11-8186-E5574CFBADCF}.Debug|Win32.ActiveCfg = Debug|Win32 {C45ECB41-8473-4F11-8186-E5574CFBADCF}.Debug|Win32.Build.0 = Debug|Win32 {C45ECB41-8473-4F11-8186-E5574CFBADCF}.Release|Win32.ActiveCfg = Release|Win32 {C45ECB41-8473-4F11-8186-E5574CFBADCF}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D4D16229-1A47-43D4-B881-F1D072436145} EndGlobalSection EndGlobal psqlodbc-REL-16_00_0005/psqlodbc.vcproj000066400000000000000000000550711462406103600175420ustar00rootroot00000000000000 psqlodbc-REL-16_00_0005/psqlodbca.def000066400000000000000000000027431462406103600171340ustar00rootroot00000000000000LIBRARY psqlodbc30a EXPORTS ;SQLAllocConnect @1 ;SQLAllocEnv @2 ;SQLAllocStmt @3 SQLBindCol @4 SQLCancel @5 ; SQLColAttributes @6 SQLConnect @7 SQLDescribeCol @8 SQLDisconnect @9 ;SQLError @10 SQLExecDirect @11 SQLExecute @12 SQLFetch @13 ;SQLFreeConnect @14 ;SQLFreeEnv @15 SQLFreeStmt @16 SQLGetCursorName @17 SQLNumResultCols @18 SQLPrepare @19 SQLRowCount @20 SQLSetCursorName @21 ;SQLTransact @23 SQLColumns @40 SQLDriverConnect @41 ;SQLGetConnectOption @42 SQLGetData @43 SQLGetFunctions @44 SQLGetInfo @45 ;SQLGetStmtOption @46 SQLGetTypeInfo @47 SQLParamData @48 SQLPutData @49 ;SQLSetConnectOption @50 ;SQLSetStmtOption @51 SQLSpecialColumns @52 SQLStatistics @53 SQLTables @54 SQLBrowseConnect @55 SQLColumnPrivileges @56 SQLDescribeParam @58 SQLExtendedFetch @59 SQLForeignKeys @60 SQLMoreResults @61 SQLNativeSql @62 SQLNumParams @63 ;SQLParamOptions @64 SQLPrimaryKeys @65 SQLProcedureColumns @66 SQLProcedures @67 SQLSetPos @68 SQLSetScrollOptions @69 SQLTablePrivileges @70 SQLBindParameter @72 SQLAllocHandle @80 SQLBindParam @81 SQLCloseCursor @82 SQLColAttribute @83 SQLCopyDesc @84 SQLEndTran @85 SQLFetchScroll @86 SQLFreeHandle @87 SQLGetDescField @88 SQLGetDescRec @89 SQLGetDiagField @90 SQLGetDiagRec @91 SQLGetEnvAttr @92 SQLGetConnectAttr @93 SQLGetStmtAttr @94 SQLSetConnectAttr @95 SQLSetDescField @96 SQLSetDescRec @97 SQLSetEnvAttr @98 SQLSetStmtAttr @99 SQLBulkOperations @100 SQLDummyOrdinal @199 dconn_FDriverConnectProc @200 DllMain @201 ConfigDSN @202 ConfigDriver @203 psqlodbc-REL-16_00_0005/psqlsetup.c000066400000000000000000000062471462406103600167130ustar00rootroot00000000000000#include #include "psqlodbc.h" #include "dlg_specific.h" #include "loadlib.h" #include "misc.h" HINSTANCE s_hModule; /* Saved module handle. */ #include #include #include RETCODE SQL_API SQLDummyOrdinal(void); /* * This function is used to cause the Driver Manager to * call functions by number rather than name, which is faster. * The ordinal value of this function must be 199 to have the * Driver Manager do this. Also, the ordinal values of the * functions must match the value of fFunction in SQLGetFunctions() */ RETCODE SQL_API SQLDummyOrdinal(void) { return SQL_SUCCESS; } static HINSTANCE s_hLModule = NULL; /* for libpq */ static HINSTANCE s_hLModule2 = NULL; /* This is where the Driver Manager attaches to this Driver */ int initialize_global_cs(void) { static int init = 1; if (!init) return 0; init = 0; InitializeLogging(); return 0; } static void finalize_global_cs(void) { FinalizeLogging(); #ifdef _DEBUG #ifdef _MEMORY_DEBUG_ // _CrtDumpMemoryLeaks(); #endif /* _MEMORY_DEBUG_ */ #endif /* _DEBUG */ } #ifdef UNICODE_SUPPORT CSTR psqlodbc = "psqlodbc35w"; #else CSTR psqlodbc = "psqlodbc30a"; #endif BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { char dllPath[MAX_PATH] = ""; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: s_hModule = hInst; /* Save for dialog boxes */ initialize_global_cs(); #ifdef PG_BIN if (s_hLModule = LoadLibraryEx(PG_BIN "\\libpq.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH), s_hLModule == NULL) MYLOG(0, "libpq in the folder %s couldn't be loaded\n", PG_BIN); #endif /* PG_BIN */ if (NULL == s_hLModule) { char message[MAX_PATH] = ""; SQLGetPrivateProfileString(DBMS_NAME, "Driver", "", dllPath, sizeof(dllPath), ODBCINST_INI); if (dllPath[0]) { char drive[_MAX_DRIVE], dir[_MAX_DIR]; _splitpath(dllPath, drive, dir, NULL, NULL); SPRINTF_FIXED(dllPath, "%s%slibpq.dll", drive, dir); if (s_hLModule = LoadLibraryEx(dllPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH), s_hLModule == NULL) { MYLOG(0, "libpq in the folder %s%s couldn't be loaded\n", drive, dir); SPRINTF_FIXED(message, "libpq in neither %s nor %s%s could be loaded", PG_BIN, drive, dir); } } #ifdef PG_BIN else SPRINTF_FIXED(message, "libpq in the folder %s couldn't be loaded", PG_BIN); #endif /* PG_BIN */ if (message[0]) MessageBox(NULL, message, "psqlsetup", MB_OK); } if (s_hLModule2 = MODULE_load_from_psqlodbc_path(psqlodbc), s_hLModule2 == NULL) { MessageBox(NULL, "psqlodbc load error", "psqlsetup", MB_OK); return TRUE; } else AlreadyLoadedPsqlodbc(); break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: MYLOG(0, "DETACHING psqlsetup\n"); CleanupDelayLoadedDLLs(); if (NULL != s_hLModule) { MYLOG(0, "Freeing Library libpq\n"); FreeLibrary(s_hLModule); } if (NULL != s_hLModule2) { MYLOG(0, "Freeing Library %s\n", psqlodbc); FreeLibrary(s_hLModule2); } finalize_global_cs(); return TRUE; case DLL_THREAD_DETACH: break; default: break; } return TRUE; UNREFERENCED_PARAMETER(lpReserved); } psqlodbc-REL-16_00_0005/psqlsetup.def000066400000000000000000000023521462406103600172200ustar00rootroot00000000000000LIBRARY psqlsetup EXPORTS DllMain @201 ConfigDSN @202 ConfigDriver @203 SQLBindCol @4 SQLCancel @5 SQLDisconnect @9 SQLExecute @12 SQLFetch @13 SQLFreeStmt @16 SQLNumResultCols @18 SQLRowCount @20 SQLGetData @43 SQLGetFunctions @44 SQLParamData @48 SQLPutData @49 SQLDescribeParam @58 SQLExtendedFetch @59 SQLMoreResults @61 SQLNumParams @63 SQLSetPos @68 SQLBindParameter @72 SQLAllocHandle @80 SQLBindParam @81 SQLCloseCursor @82 SQLCopyDesc @84 SQLEndTran @85 SQLFetchScroll @86 SQLFreeHandle @87 SQLGetEnvAttr @92 SQLSetEnvAttr @98 SQLBulkOperations @100 SQLDummyOrdinal @199 SQLColAttributeW @101 SQLColumnPrivilegesW @102 SQLColumnsW @103 SQLConnectW @104 SQLDescribeColW @106 SQLExecDirectW @107 SQLForeignKeysW @108 SQLGetConnectAttrW @109 SQLGetCursorNameW @110 SQLGetInfoW @111 SQLNativeSqlW @112 SQLPrepareW @113 SQLPrimaryKeysW @114 SQLProcedureColumnsW @115 SQLProceduresW @116 SQLSetConnectAttrW @117 SQLSetCursorNameW @118 SQLSpecialColumnsW @119 SQLStatisticsW @120 SQLTablesW @121 SQLTablePrivilegesW @122 SQLDriverConnectW @123 SQLGetDiagRecW @124 SQLGetStmtAttrW @125 SQLSetStmtAttrW @126 SQLSetDescFieldW @127 SQLGetTypeInfoW @128 SQLGetDiagFieldW @129 SQLGetDescFieldW @130 SQLGetDescRecW @131 SQLSetDescRecW @132 psqlodbc-REL-16_00_0005/psqlsetupa.def000066400000000000000000000022301462406103600173540ustar00rootroot00000000000000LIBRARY psqlsetupa EXPORTS DllMain @201 ConfigDSN @202 ConfigDriver @203 SQLBindCol @4 SQLCancel @5 SQLConnect @7 SQLDescribeCol @8 SQLDisconnect @9 SQLExecDirect @11 SQLExecute @12 SQLFetch @13 SQLFreeStmt @16 SQLGetCursorName @17 SQLNumResultCols @18 SQLPrepare @19 SQLRowCount @20 SQLSetCursorName @21 SQLColumns @40 SQLDriverConnect @41 SQLGetData @43 SQLGetFunctions @44 SQLGetInfo @45 SQLGetTypeInfo @47 SQLParamData @48 SQLPutData @49 SQLSpecialColumns @52 SQLStatistics @53 SQLTables @54 SQLColumnPrivileges @56 SQLDescribeParam @58 SQLExtendedFetch @59 SQLForeignKeys @60 SQLMoreResults @61 SQLNativeSql @62 SQLNumParams @63 SQLPrimaryKeys @65 SQLProcedureColumns @66 SQLProcedures @67 SQLSetPos @68 SQLTablePrivileges @70 SQLBindParameter @72 SQLAllocHandle @80 SQLBindParam @81 SQLCloseCursor @82 SQLColAttribute @83 SQLCopyDesc @84 SQLEndTran @85 SQLFetchScroll @86 SQLFreeHandle @87 SQLGetDescField @88 SQLGetDescRec @89 SQLGetDiagField @90 SQLGetDiagRec @91 SQLGetEnvAttr @92 SQLGetConnectAttr @93 SQLGetStmtAttr @94 SQLSetConnectAttr @95 SQLSetDescField @96 SQLSetDescRec @97 SQLSetEnvAttr @98 SQLSetStmtAttr @99 SQLBulkOperations @100 SQLDummyOrdinal @199 psqlodbc-REL-16_00_0005/qresult.c000066400000000000000000001130011462406103600163350ustar00rootroot00000000000000/*--------- * Module: qresult.c * * Description: This module contains functions related to * managing result information (i.e, fetching rows * from the backend, managing the tuple cache, etc.) * and retrieving it. Depending on the situation, a * QResultClass will hold either data from the backend * or a manually built result. * * Classes: QResultClass (Functions prefix: "QR_") * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *--------- */ #include "qresult.h" #include "statement.h" #include #include "misc.h" #include #include #include static BOOL QR_prepare_for_tupledata(QResultClass *self); static BOOL QR_read_tuples_from_pgres(QResultClass *, PGresult **pgres); /* * Used for building a Manual Result only * All info functions call this function to create the manual result set. */ void QR_set_num_fields(QResultClass *self, int new_num_fields) { if (!self) return; MYLOG(0, "entering\n"); CI_set_num_fields(QR_get_fields(self), new_num_fields); MYLOG(0, "leaving\n"); } void QR_set_position(QResultClass *self, SQLLEN pos) { self->tupleField = self->backend_tuples + ((QR_get_rowstart_in_cache(self) + pos) * self->num_fields); } void QR_set_cache_size(QResultClass *self, SQLLEN cache_size) { self->cache_size = cache_size; } void QR_set_reqsize(QResultClass *self, Int4 reqsize) { self->rowset_size_include_ommitted = reqsize; } void QR_set_cursor(QResultClass *self, const char *name) { ConnectionClass *conn = QR_get_conn(self); if (self->cursor_name) { if (name && 0 == strcmp(name, self->cursor_name)) return; free(self->cursor_name); if (conn) { CONNLOCK_ACQUIRE(conn); conn->ncursors--; CONNLOCK_RELEASE(conn); } self->cursTuple = -1; QR_set_no_cursor(self); } else if (NULL == name) return; if (name) { self->cursor_name = strdup(name); if (conn) { CONNLOCK_ACQUIRE(conn); conn->ncursors++; CONNLOCK_RELEASE(conn); } } else { self->cursor_name = NULL; /* * The isSqlServr() check below was added because the code was freeing * cursors prematurely when other results with open cursors exist. The * code was originally added for a scenario using SQL Server linked * servers in commit c07342d22d82ea6293d27057840babfc2ff6d750. */ if (isSqlServr()) { QResultClass *res; for (res = QR_nextr(self); NULL != res; res = QR_nextr(res)) { if (NULL != res->cursor_name) free(res->cursor_name); res->cursor_name = NULL; } } } } void QR_set_num_cached_rows(QResultClass *self, SQLLEN num_rows) { self->num_cached_rows = num_rows; if (QR_synchronize_keys(self)) self->num_cached_keys = self->num_cached_rows; } void QR_set_rowstart_in_cache(QResultClass *self, SQLLEN start) { if (QR_synchronize_keys(self)) self->key_base = start; self->base = start; } void QR_inc_rowstart_in_cache(QResultClass *self, SQLLEN base_inc) { if (!QR_has_valid_base(self)) MYLOG(0, " called while the cache is not ready\n"); self->base += base_inc; if (QR_synchronize_keys(self)) self->key_base = self->base; } void QR_set_fields(QResultClass *self, ColumnInfoClass *fields) { ColumnInfoClass *curfields = QR_get_fields(self); if (curfields == fields) return; /* * Unlink the old columninfo from this result set, freeing it if this * was the last reference. */ if (NULL != curfields) { if (curfields->refcount > 1) curfields->refcount--; else CI_Destructor(curfields); } self->fields = fields; if (NULL != fields) fields->refcount++; } /* * CLASS QResult */ QResultClass * QR_Constructor(void) { QResultClass *rv; MYLOG(0, "entering\n"); rv = (QResultClass *) malloc(sizeof(QResultClass)); if (rv != NULL) { ColumnInfoClass *fields; rv->rstatus = PORES_EMPTY_QUERY; rv->pstatus = 0; /* construct the column info */ rv->fields = NULL; if (fields = CI_Constructor(), NULL == fields) { free(rv); return NULL; } QR_set_fields(rv, fields); rv->backend_tuples = NULL; rv->sqlstate[0] = '\0'; rv->message = NULL; rv->messageref = NULL; rv->command = NULL; rv->notice = NULL; rv->conn = NULL; QR_nextr(rv) = NULL; rv->count_backend_allocated = 0; rv->count_keyset_allocated = 0; rv->num_total_read = 0; rv->num_cached_rows = 0; rv->num_cached_keys = 0; rv->fetch_number = 0; rv->flags = 0; /* must be cleared before calling QR_set_rowstart_in_cache() */ QR_set_rowstart_in_cache(rv, -1); rv->key_base = -1; rv->recent_processed_row_count = -1; rv->cursTuple = -1; rv->move_offset = 0; rv->num_fields = 0; rv->num_key_fields = PG_NUM_NORMAL_KEYS; /* CTID + OID */ rv->tupleField = NULL; rv->cursor_name = NULL; rv->aborted = FALSE; rv->cache_size = 0; rv->cmd_fetch_size = 0; rv->rowset_size_include_ommitted = 1; rv->move_direction = 0; rv->keyset = NULL; rv->reload_count = 0; rv->rb_alloc = 0; rv->rb_count = 0; rv->dataFilled = FALSE; rv->rollback = NULL; rv->ad_alloc = 0; rv->ad_count = 0; rv->added_keyset = NULL; rv->added_tuples = NULL; rv->up_alloc = 0; rv->up_count = 0; rv->updated = NULL; rv->updated_keyset = NULL; rv->updated_tuples = NULL; rv->dl_alloc = 0; rv->dl_count = 0; rv->deleted = NULL; rv->deleted_keyset = NULL; } MYLOG(0, "leaving %p\n", rv); return rv; } void QR_close_result(QResultClass *self, BOOL destroy) { ConnectionClass *conn; QResultClass *next; BOOL top = TRUE; if (!self) return; MYLOG(0, "entering\n"); while(self) { /* * If conn is defined, then we may have used "backend_tuples", so in * case we need to, free it up. Also, close the cursor. */ if ((conn = QR_get_conn(self)) && conn->pqconn) { if (CC_is_in_trans(conn) || QR_is_withhold(self)) { if (!QR_close(self)) /* close the cursor if there is one */ { } } } QR_free_memory(self); /* safe to call anyway */ /* * Should have been freed in the close() but just in case... * QR_set_cursor clears the cursor name of all the chained results too, * so we only need to do this for the first result in the chain. */ if (top) QR_set_cursor(self, NULL); /* Free up column info */ if (destroy) QR_set_fields(self, NULL); /* Free command info (this is from strdup()) */ if (self->command) { free(self->command); self->command = NULL; } /* Free message info (this is from strdup()) */ if (self->message) { free(self->message); self->message = NULL; } /* Free notice info (this is from strdup()) */ if (self->notice) { free(self->notice); self->notice = NULL; } /* Destruct the result object in the chain */ next = QR_nextr(self); QR_detach(self); if (destroy) free(self); /* Repeat for the next result in the chain */ self = next; destroy = TRUE; /* always destroy chained results */ top = FALSE; } MYLOG(0, "leaving\n"); } void QR_reset_for_re_execute(QResultClass *self) { MYLOG(0, "entering for %p\n", self); if (!self) return; QR_close_result(self, FALSE); /* reset flags etc */ self->flags = 0; QR_set_rowstart_in_cache(self, -1); self->recent_processed_row_count = -1; /* clear error info etc */ self->rstatus = PORES_EMPTY_QUERY; self->aborted = FALSE; self->sqlstate[0] = '\0'; self->messageref = NULL; MYLOG(0, "leaving\n"); } void QR_Destructor(QResultClass *self) { MYLOG(0, "entering\n"); if (!self) return; QR_close_result(self, TRUE); MYLOG(0, "leaving\n"); } void QR_set_command(QResultClass *self, const char *msg) { if (self->command) free(self->command); self->command = msg ? strdup(msg) : NULL; } void QR_set_message(QResultClass *self, const char *msg) { if (self->message) free(self->message); self->messageref = NULL; self->message = msg ? strdup(msg) : NULL; } void QR_add_message(QResultClass *self, const char *msg) { char *message = self->message; size_t alsize, pos, addlen; if (!msg || !msg[0]) return; addlen = strlen(msg); if (message) { pos = strlen(message) + 1; alsize = pos + addlen + 1; } else { pos = 0; alsize = addlen + 1; } if (message = realloc(message, alsize), NULL == message) return; if (pos > 0) message[pos - 1] = ';'; strncpy_null(message + pos, msg, addlen + 1); self->message = message; } void QR_set_notice(QResultClass *self, const char *msg) { if (self->notice) free(self->notice); self->notice = msg ? strdup(msg) : NULL; } void QR_add_notice(QResultClass *self, const char *msg) { char *message = self->notice; size_t alsize, pos, addlen; if (!msg || !msg[0]) return; addlen = strlen(msg); if (message) { pos = strlen(message) + 1; alsize = pos + addlen + 1; } else { pos = 0; alsize = addlen + 1; } if (message = realloc(message, alsize), NULL == message) return; if (pos > 0) message[pos - 1] = ';'; strncpy_null(message + pos, msg, addlen + 1); self->notice = message; } TupleField *QR_AddNew(QResultClass *self) { size_t alloc; UInt4 num_fields; if (!self) return NULL; MYLOG(DETAIL_LOG_LEVEL, FORMAT_ULEN "th row(%d fields) alloc=" FORMAT_LEN "\n", self->num_cached_rows, QR_NumResultCols(self), self->count_backend_allocated); if (num_fields = QR_NumResultCols(self), !num_fields) return NULL; if (self->num_fields <= 0) { self->num_fields = num_fields; QR_set_reached_eof(self); } alloc = self->count_backend_allocated; if (!self->backend_tuples) { self->num_cached_rows = 0; alloc = TUPLE_MALLOC_INC; QR_MALLOC_return_with_error(self->backend_tuples, TupleField, alloc * sizeof(TupleField) * num_fields, self, "Out of memory in QR_AddNew.", NULL); } else if (self->num_cached_rows >= self->count_backend_allocated) { alloc = self->count_backend_allocated * 2; QR_REALLOC_return_with_error(self->backend_tuples, TupleField, alloc * sizeof(TupleField) * num_fields, self, "Out of memory in QR_AddNew.", NULL); } self->count_backend_allocated = alloc; if (self->backend_tuples) { memset(self->backend_tuples + num_fields * self->num_cached_rows, 0, num_fields * sizeof(TupleField)); self->num_cached_rows++; self->ad_count++; } return self->backend_tuples + num_fields * (self->num_cached_rows - 1); } void QR_free_memory(QResultClass *self) { SQLLEN num_backend_rows = self->num_cached_rows; int num_fields = self->num_fields; MYLOG(0, "entering fcount=" FORMAT_LEN "\n", num_backend_rows); if (self->backend_tuples) { ClearCachedRows(self->backend_tuples, num_fields, num_backend_rows); free(self->backend_tuples); self->count_backend_allocated = 0; self->backend_tuples = NULL; self->dataFilled = FALSE; self->tupleField = NULL; } if (self->keyset) { ConnectionClass *conn = QR_get_conn(self); free(self->keyset); self->keyset = NULL; self->count_keyset_allocated = 0; if (self->reload_count > 0 && conn && conn->pqconn) { char plannm[32]; SPRINTF_FIXED(plannm, "_KEYSET_%p", self); if (CC_is_in_error_trans(conn)) { CC_mark_a_object_to_discard(conn, 's',plannm); } else { QResultClass *res; char cmd[64]; SPRINTF_FIXED(cmd, "DEALLOCATE \"%s\"", plannm); res = CC_send_query(conn, cmd, NULL, IGNORE_ABORT_ON_CONN | ROLLBACK_ON_ERROR, NULL); QR_Destructor(res); } } self->reload_count = 0; } if (self->rollback) { free(self->rollback); self->rb_alloc = 0; self->rb_count = 0; self->rollback = NULL; } if (self->deleted) { free(self->deleted); self->deleted = NULL; } if (self->deleted_keyset) { free(self->deleted_keyset); self->deleted_keyset = NULL; } self->dl_alloc = 0; self->dl_count = 0; /* clear added info */ if (self->added_keyset) { free(self->added_keyset); self->added_keyset = NULL; } if (self->added_tuples) { ClearCachedRows(self->added_tuples, num_fields, self->ad_count); free(self->added_tuples); self->added_tuples = NULL; } self->ad_alloc = 0; self->ad_count = 0; /* clear updated info */ if (self->updated) { free(self->updated); self->updated = NULL; } if (self->updated_keyset) { free(self->updated_keyset); self->updated_keyset = NULL; } if (self->updated_tuples) { ClearCachedRows(self->updated_tuples, num_fields, self->up_count); free(self->updated_tuples); self->updated_tuples = NULL; } self->up_alloc = 0; self->up_count = 0; self->num_total_read = 0; self->num_cached_rows = 0; self->num_cached_keys = 0; self->cursTuple = -1; self->pstatus = 0; MYLOG(0, "leaving\n"); } BOOL QR_from_PGresult(QResultClass *self, StatementClass *stmt, ConnectionClass *conn, const char *cursor, PGresult **pgres) { int num_io_params, num_cached_rows; int i; Int2 paramType; IPDFields *ipdopts; Int2 lf; int new_num_fields; OID new_adtid, new_relid = 0, new_attid = 0; Int2 new_adtsize; Int4 new_atttypmod = -1; char *new_field_name; Int2 dummy1, dummy2; int cidx; BOOL reached_eof_now = FALSE; if (NULL != conn) /* First, get column information */ QR_set_conn(self, conn); /* at first read in the number of fields that are in the query */ new_num_fields = PQnfields(*pgres); QLOG(0, "\tnFields: %d\n", new_num_fields); /* according to that allocate memory */ QR_set_num_fields(self, new_num_fields); if (NULL == QR_get_fields(self)->coli_array) return FALSE; /* now read in the descriptions */ for (lf = 0; lf < new_num_fields; lf++) { new_field_name = PQfname(*pgres, lf); new_relid = PQftable(*pgres, lf); new_attid = PQftablecol(*pgres, lf); new_adtid = (OID) PQftype(*pgres, lf); new_adtsize = (Int2) PQfsize(*pgres, lf); new_atttypmod = (Int4) PQfmod(*pgres, lf); /* Subtract the header length */ switch (new_adtid) { case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP_NO_TMZONE: case PG_TYPE_TIME: case PG_TYPE_TIME_WITH_TMZONE: break; default: new_atttypmod -= 4; } if (new_atttypmod < 0) new_atttypmod = -1; QLOG(0, "\tfieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d (rel,att)=(%d,%d)\n", new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid); CI_set_field_info(QR_get_fields(self), lf, new_field_name, new_adtid, new_adtsize, new_atttypmod, new_relid, new_attid); QR_set_rstatus(self, PORES_FIELDS_OK); self->num_fields = CI_get_num_fields(QR_get_fields(self)); if (QR_haskeyset(self)) self->num_fields -= self->num_key_fields; if (stmt && conn) { num_io_params = CountParameters(stmt, NULL, &dummy1, &dummy2); if (stmt->proc_return > 0 || num_io_params > 0) { ipdopts = SC_get_IPDF(stmt); extend_iparameter_bindings(ipdopts, stmt->num_params); for (i = 0, cidx = 0; i < stmt->num_params; i++) { if (i < stmt->proc_return) ipdopts->parameters[i].paramType = SQL_PARAM_OUTPUT; paramType =ipdopts->parameters[i].paramType; if (SQL_PARAM_OUTPUT == paramType || SQL_PARAM_INPUT_OUTPUT == paramType) { MYLOG(DETAIL_LOG_LEVEL, "[%d].PGType %u->%u\n", i, PIC_get_pgtype(ipdopts->parameters[i]), CI_get_oid(QR_get_fields(self), cidx)); PIC_set_pgtype(ipdopts->parameters[i], CI_get_oid(QR_get_fields(self), cidx)); cidx++; } } } } } /* Then, get the data itself */ num_cached_rows = self->num_cached_rows; if (!QR_read_tuples_from_pgres(self, pgres)) return FALSE; MYLOG(DETAIL_LOG_LEVEL, "!!%p->cursTup=" FORMAT_LEN " total_read=" FORMAT_ULEN "\n", self, self->cursTuple, self->num_total_read); if (!QR_once_reached_eof(self) && self->cursTuple >= (Int4) self->num_total_read) self->num_total_read = self->cursTuple + 1; /* EOF is 'fetched < fetch requested' */ if (self->num_cached_rows - num_cached_rows < self->cmd_fetch_size) { MYLOG(0, "detect EOF " FORMAT_ULEN " - %d < " FORMAT_ULEN "\n", self->num_cached_rows, num_cached_rows, self->cmd_fetch_size); reached_eof_now = TRUE; QR_set_reached_eof(self); } if (reached_eof_now && self->cursTuple < (Int4) self->num_total_read) self->cursTuple = self->num_total_read; if (NULL != conn) { /* Force a read to occur in next_tuple */ QR_set_next_in_cache(self, (SQLLEN) 0); QR_set_rowstart_in_cache(self, 0); self->key_base = 0; } /* * Also fill in command tag. (Typically, it's SELECT, but can also be * a FETCH.) */ QR_set_command(self, PQcmdStatus(*pgres)); QR_set_cursor(self, cursor); if (NULL == cursor) QR_set_reached_eof(self); return TRUE; } /* * Procedure needed when closing cursors. */ void QR_on_close_cursor(QResultClass *self) { QR_set_cursor(self, NULL); } /* * Close the cursor and end the transaction (if no cursors left) * We only close the cursor if other cursors are used. */ int QR_close(QResultClass *self) { ConnectionClass *conn; QResultClass *res; int ret = TRUE; conn = QR_get_conn(self); if (self && QR_get_cursor(self)) { if (CC_is_in_error_trans(conn)) { if (QR_is_withhold(self)) CC_mark_a_object_to_discard(conn, 'p', QR_get_cursor(self)); } else { BOOL does_commit = FALSE; unsigned int flag = 0; char buf[64]; flag = READ_ONLY_QUERY; if (QR_needs_survival_check(self)) flag |= (ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN); SPRINTF_FIXED(buf, "close \"%s\"", QR_get_cursor(self)); /* End the transaction if there are no cursors left on this conn */ if (CC_is_in_trans(conn) && CC_does_autocommit(conn) && CC_cursor_count(conn) <= 1) { MYLOG(0, "End transaction on conn=%p\n", conn); if ((ROLLBACK_ON_ERROR & flag) == 0) { STRCAT_FIXED(buf, ";commit"); flag |= END_WITH_COMMIT; QR_set_cursor(self, NULL); } else does_commit = TRUE; } MYLOG(DETAIL_LOG_LEVEL, " Case I CC_send_query %s flag=%x\n", buf, flag); res = CC_send_query(conn, buf, NULL, flag, NULL); QR_Destructor(res); if (does_commit) { if (!CC_commit(conn)) { QR_set_rstatus(self, PORES_FATAL_ERROR); QR_set_message(self, "Error ending transaction on autocommit."); ret = FALSE; } } } QR_on_close_cursor(self); if (!ret) return ret; #ifdef NOT_USED /* End the transaction if there are no cursors left on this conn */ if (CC_does_autocommit(conn) && CC_cursor_count(conn) == 0) { MYLOG(0, "End transaction on conn=%p\n", conn); if (!CC_commit(conn)) { QR_set_rstatus(self, PORES_FATAL_ERROR); QR_set_message(self, "Error ending transaction."); ret = FALSE; } } #endif /* NOT_USED */ } return ret; } /* * Allocate memory for receiving next tuple. */ static BOOL QR_prepare_for_tupledata(QResultClass *self) { BOOL haskeyset = QR_haskeyset(self); SQLULEN num_total_rows = QR_get_num_total_tuples(self); MYLOG(DETAIL_LOG_LEVEL, "entering %p->num_fields=%d\n", self, self->num_fields); if (!QR_get_cursor(self)) { if (self->num_fields > 0 && num_total_rows >= self->count_backend_allocated) { SQLLEN tuple_size = self->count_backend_allocated; MYLOG(0, "REALLOC: old_count = " FORMAT_LEN ", size = " FORMAT_SIZE_T "\n", tuple_size, (size_t) (self->num_fields * sizeof(TupleField) * tuple_size)); if (tuple_size < 1) tuple_size = TUPLE_MALLOC_INC; else tuple_size *= 2; QR_REALLOC_return_with_error(self->backend_tuples, TupleField, tuple_size * self->num_fields * sizeof(TupleField), self, "Out of memory while reading tuples.", FALSE); self->count_backend_allocated = tuple_size; } if (haskeyset && self->num_cached_keys >= self->count_keyset_allocated) { SQLLEN tuple_size = self->count_keyset_allocated; if (tuple_size < 1) tuple_size = TUPLE_MALLOC_INC; else tuple_size *= 2; QR_REALLOC_return_with_error(self->keyset, KeySet, sizeof(KeySet) * tuple_size, self, "Out of mwmory while allocating keyset", FALSE); memset(&self->keyset[self->count_keyset_allocated], 0, (tuple_size - self->count_keyset_allocated) * sizeof(KeySet)); self->count_keyset_allocated = tuple_size; } } return TRUE; } static SQLLEN enlargeKeyCache(QResultClass *self, SQLLEN add_size, const char *message) { size_t alloc, alloc_req; Int4 num_fields = self->num_fields; BOOL curs = (NULL != QR_get_cursor(self)); if (add_size <= 0) return self->count_keyset_allocated; alloc = self->count_backend_allocated; if (num_fields > 0 && ((alloc_req = (Int4)self->num_cached_rows + add_size) > alloc || !self->backend_tuples)) { if (1 > alloc) { if (curs) alloc = alloc_req; else alloc = (alloc_req > TUPLE_MALLOC_INC ? alloc_req : TUPLE_MALLOC_INC); } else { do { alloc *= 2; } while (alloc < alloc_req); } self->count_backend_allocated = 0; QR_REALLOC_return_with_error(self->backend_tuples, TupleField, num_fields * sizeof(TupleField) * alloc, self, message, -1); self->count_backend_allocated = alloc; } alloc = self->count_keyset_allocated; if (QR_haskeyset(self) && ((alloc_req = (Int4)self->num_cached_keys + add_size) > alloc || !self->keyset)) { if (1 > alloc) { if (curs) alloc = alloc_req; else alloc = (alloc_req > TUPLE_MALLOC_INC ? alloc_req : TUPLE_MALLOC_INC); } else { do { alloc *= 2; } while (alloc < alloc_req); } self->count_keyset_allocated = 0; QR_REALLOC_return_with_error(self->keyset, KeySet, sizeof(KeySet) * alloc, self, message, -1); self->count_keyset_allocated = alloc; } return alloc; } SQLLEN QR_move_cursor_to_last(QResultClass *self, StatementClass *stmt) { char movecmd[64]; QResultClass *res; SQLLEN moved; ConnectionClass *conn = SC_get_conn(stmt); if (!QR_get_cursor(self)) return 0; if (QR_once_reached_eof(self) && self->cursTuple >= self->num_total_read) return 0; SPRINTF_FIXED(movecmd, "move all in \"%s\"", QR_get_cursor(self)); res = CC_send_query(conn, movecmd, NULL, READ_ONLY_QUERY, stmt); if (!QR_command_maybe_successful(res)) { QR_Destructor(res); SC_set_error(stmt, STMT_EXEC_ERROR, "move error occurred", __FUNCTION__); return (-1); } moved = (-1); if (sscanf(res->command, "MOVE " FORMAT_ULEN, &moved) > 0) { moved++; self->cursTuple += moved; if (!QR_once_reached_eof(self)) { self->num_total_read = self->cursTuple; QR_set_reached_eof(self); } } QR_Destructor(res); return moved; } /* This function is called by fetch_tuples() AND SQLFetch() */ int QR_next_tuple(QResultClass *self, StatementClass *stmt) { CSTR func = "QR_next_tuple"; int ret = TRUE; /* Speed up access */ SQLLEN fetch_number = self->fetch_number, cur_fetch = 0; SQLLEN num_total_rows; SQLLEN num_backend_rows = self->num_cached_rows, num_rows_in; Int4 num_fields = self->num_fields, fetch_size, req_size; SQLLEN offset = 0, end_tuple; char boundary_adjusted = FALSE; TupleField *the_tuples = self->backend_tuples; QResultClass *res; /* QR_set_command() dups this string so doesn't need static */ char fetch[128]; QueryInfo qi; ConnectionClass *conn; ConnInfo *ci; BOOL reached_eof_now = FALSE, curr_eof; /* detecting EOF is pretty important */ MYLOG(DETAIL_LOG_LEVEL, "Oh %p->fetch_number=" FORMAT_LEN "\n", self, self->fetch_number); MYLOG(DETAIL_LOG_LEVEL, "in total_read=" FORMAT_ULEN " cursT=" FORMAT_LEN " currT=" FORMAT_LEN " ad=%d total=" FORMAT_ULEN " rowsetSize=%d\n", self->num_total_read, self->cursTuple, stmt->currTuple, self->ad_count, QR_get_num_total_tuples(self), self->rowset_size_include_ommitted); num_total_rows = QR_get_num_total_tuples(self); conn = QR_get_conn(self); curr_eof = FALSE; req_size = QR_get_reqsize(self); /* Determine the optimum cache size. */ ci = &(conn->connInfo); fetch_size = ci->drivers.fetch_max; if ((Int4)req_size > fetch_size) fetch_size = req_size; if (QR_once_reached_eof(self) && self->cursTuple >= (Int4) QR_get_num_total_read(self)) curr_eof = TRUE; #define return DONT_CALL_RETURN_FROM_HERE??? #define RETURN(code) { ret = code; goto cleanup;} ENTER_CONN_CS(conn); if (0 != self->move_offset) { char movecmd[256]; QResultClass *mres = NULL; SQLULEN movement, moved; movement = self->move_offset; if (QR_is_moving_backward(self)) { if (fetch_size > req_size) { SQLLEN incr_move = fetch_size - (req_size < 0 ? 1 : req_size); movement += incr_move; if (movement > (UInt4)(self->cursTuple + 1)) movement = self->cursTuple + 1; } else self->cache_size = req_size; MYLOG(DETAIL_LOG_LEVEL, "cache=" FORMAT_ULEN " rowset=%d movement=" FORMAT_ULEN "\n", self->cache_size, req_size, movement); SPRINTF_FIXED(movecmd, "move backward " FORMAT_ULEN " in \"%s\"", movement, QR_get_cursor(self)); } else if (QR_is_moving_forward(self)) SPRINTF_FIXED(movecmd, "move " FORMAT_ULEN " in \"%s\"", movement, QR_get_cursor(self)); else { SPRINTF_FIXED(movecmd, "move all in \"%s\"", QR_get_cursor(self)); movement = INT_MAX; } mres = CC_send_query(conn, movecmd, NULL, READ_ONLY_QUERY, stmt); if (!QR_command_maybe_successful(mres)) { QR_Destructor(mres); SC_set_error(stmt, STMT_EXEC_ERROR, "move error occurred", func); RETURN(-1) } moved = movement; if (sscanf(mres->command, "MOVE " FORMAT_ULEN, &moved) > 0) { MYLOG(DETAIL_LOG_LEVEL, "moved=" FORMAT_ULEN " ? " FORMAT_ULEN "\n", moved, movement); if (moved < movement) { if (0 < moved) moved++; else if (QR_is_moving_backward(self) && self->cursTuple < 0) ; else if (QR_is_moving_not_backward(self) && curr_eof) ; else moved++; if (QR_is_moving_not_backward(self)) { curr_eof = TRUE; if (!QR_once_reached_eof(self)) { self->num_total_read = self->cursTuple + moved; QR_set_reached_eof(self); } } } } /* ... by the following call */ QR_set_rowstart_in_cache(self, -1); if (QR_is_moving_backward(self)) { self->cursTuple -= moved; offset = moved - self->move_offset; } else { self->cursTuple += moved; offset = self->move_offset - moved; } QR_Destructor(mres); self->move_offset = 0; num_backend_rows = self->num_cached_rows; } else if (fetch_number < num_backend_rows) { if (!self->dataFilled) /* should never occur */ { SC_set_error(stmt, STMT_EXEC_ERROR, "Hmm where are fetched data?", func); RETURN(-1) } /* return a row from cache */ MYLOG(0, "fetch_number < fcount: returning tuple " FORMAT_LEN ", fcount = " FORMAT_LEN "\n", fetch_number, num_backend_rows); self->tupleField = the_tuples + (fetch_number * num_fields); MYLOG(DETAIL_LOG_LEVEL, "tupleField=%p\n", self->tupleField); /* move to next row */ QR_inc_next_in_cache(self); RETURN(TRUE) } else if (QR_once_reached_eof(self)) { BOOL reached_eod = FALSE; if (stmt->currTuple + 1 >= num_total_rows) reached_eod = TRUE; if (reached_eod) { MYLOG(0, "next_tuple: fetch end\n"); self->tupleField = NULL; /* end of tuples */ RETURN(-1) } } end_tuple = req_size + QR_get_rowstart_in_cache(self); /* * See if we need to fetch another group of rows. We may be being * called from send_query(), and if so, don't send another fetch, * just fall through and read the tuples. */ self->tupleField = NULL; if (!QR_get_cursor(self)) { MYLOG(0, "ALL_ROWS: done, fcount = " FORMAT_ULEN ", fetch_number = " FORMAT_LEN "\n", QR_get_num_total_tuples(self), fetch_number); self->tupleField = NULL; QR_set_reached_eof(self); RETURN(-1) /* end of tuples */ } if (QR_get_rowstart_in_cache(self) >= num_backend_rows || QR_is_moving(self)) { TupleField *tuple = self->backend_tuples; /* not a correction */ self->cache_size = fetch_size; /* clear obsolete tuples */ MYLOG(DETAIL_LOG_LEVEL, "clear obsolete " FORMAT_LEN " tuples\n", num_backend_rows); ClearCachedRows(tuple, num_fields, num_backend_rows); self->dataFilled = FALSE; QR_stop_movement(self); self->move_offset = 0; QR_set_next_in_cache(self, offset + 1); } else { /* * The rowset boundary doesn't match that of * the inner resultset. Enlarge the resultset * and fetch the rest of the rowset. */ /* The next fetch size is */ fetch_size = (Int4) (end_tuple - num_backend_rows); if (fetch_size <= 0) { MYLOG(0, "corrupted fetch_size end_tuple=" FORMAT_LEN " <= cached_rows=" FORMAT_LEN "\n", end_tuple, num_backend_rows); RETURN(-1) } /* and enlarge the cache size */ self->cache_size += fetch_size; offset = self->fetch_number; QR_inc_next_in_cache(self); boundary_adjusted = TRUE; } if (enlargeKeyCache(self, self->cache_size - num_backend_rows, "Out of memory while reading tuples") < 0) RETURN(FALSE) /* Send a FETCH command to get more rows */ SPRINTF_FIXED(fetch, "fetch %d in \"%s\"", fetch_size, QR_get_cursor(self)); MYLOG(0, "sending actual fetch (%d) query '%s'\n", fetch_size, fetch); if (!boundary_adjusted) { QR_set_num_cached_rows(self, 0); QR_set_rowstart_in_cache(self, offset); } num_rows_in = self->num_cached_rows; /* don't read ahead for the next tuple (self) ! */ qi.row_size = self->cache_size; qi.fetch_size = fetch_size; qi.result_in = self; qi.cursor = NULL; res = CC_send_query(conn, fetch, &qi, READ_ONLY_QUERY, stmt); if (!QR_command_maybe_successful(res)) { if (!QR_get_message(self)) QR_set_message(self, "Error fetching next group."); RETURN(FALSE) } cur_fetch = 0; self->tupleField = NULL; curr_eof = reached_eof_now = (QR_once_reached_eof(self) && self->cursTuple >= (Int4)self->num_total_read); MYLOG(DETAIL_LOG_LEVEL, "reached_eof_now=%d\n", reached_eof_now); MYLOG(0, ": PGresult: fetch_total = " FORMAT_ULEN " & this_fetch = " FORMAT_ULEN "\n", self->num_total_read, self->num_cached_rows); MYLOG(0, ": PGresult: cursTuple = " FORMAT_LEN ", offset = " FORMAT_LEN "\n", self->cursTuple, offset); cur_fetch = self->num_cached_rows - num_rows_in; if (!ret) RETURN(ret) { SQLLEN start_idx = 0; num_backend_rows = self->num_cached_rows; if (reached_eof_now) { MYLOG(0, "reached eof now\n"); QR_set_reached_eof(self); if (self->ad_count > 0 && cur_fetch < fetch_size) { /* We have to append the tuples(keys) info from the added tuples(keys) here */ SQLLEN add_size; TupleField *tuple, *added_tuple; start_idx = CacheIdx2GIdx(offset, stmt, self) - self->num_total_read; if (curr_eof && start_idx >= 0) { add_size = self->ad_count - start_idx; if (0 == num_backend_rows) { offset = 0; QR_set_rowstart_in_cache(self, offset); QR_set_next_in_cache(self, offset); } } else { start_idx = 0; add_size = self->ad_count; } if (add_size > fetch_size - cur_fetch) add_size = fetch_size - cur_fetch; else if (add_size < 0) add_size = 0; MYLOG(DETAIL_LOG_LEVEL, "will add " FORMAT_LEN " added_tuples from " FORMAT_LEN " and select the " FORMAT_LEN "th added tuple " FORMAT_LEN "\n", add_size, start_idx, offset - num_backend_rows + start_idx, cur_fetch); if (enlargeKeyCache(self, add_size, "Out of memory while adding tuples") < 0) RETURN(FALSE) /* append the KeySet info first */ memcpy(self->keyset + num_backend_rows, (void *)(self->added_keyset + start_idx), sizeof(KeySet) * add_size); /* and append the tuples info */ tuple = self->backend_tuples + num_fields * num_backend_rows; memset(tuple, 0, sizeof(TupleField) * num_fields * add_size); added_tuple = self->added_tuples + num_fields * start_idx; ReplaceCachedRows(tuple, added_tuple, num_fields, add_size); self->num_cached_rows += add_size; self->num_cached_keys += add_size; num_backend_rows = self->num_cached_rows; } } if (offset < num_backend_rows) { /* set to first row */ self->tupleField = self->backend_tuples + (offset * num_fields); } else { /* We are surely done here (we read 0 tuples) */ MYLOG(0, " 'C': DONE (fcount == " FORMAT_LEN ")\n", num_backend_rows); ret = -1; /* end of tuples */ } } /* If the cursor operation was invoked inside this function, we have to set the status bits here. */ if (self->keyset && (self->dl_count > 0 || self->up_count > 0)) { SQLLEN i, lf; SQLLEN lidx, hidx, lkidx, hkidx; SQLLEN *deleted = self->deleted, *updated = self->updated; num_backend_rows = QR_get_num_cached_tuples(self); lidx = CacheIdx2GIdx(num_rows_in, stmt, self); hidx = CacheIdx2GIdx(num_backend_rows, stmt, self); lkidx = GIdx2KResIdx(lidx, stmt, self); hkidx = GIdx2KResIdx(hidx, stmt, self); /* For simplicity, use CURS_NEEDS_REREAD bit to mark the row */ for (i = lkidx; i < hkidx; i++) self->keyset[i].status |= CURS_NEEDS_REREAD; /* deleted info */ for (i = 0; i < self->dl_count && hidx > deleted[i]; i++) { if (lidx <= deleted[i]) { lf = GIdx2KResIdx(deleted[i], stmt, self); if (lf >= 0 && lf < self->num_cached_keys) { self->keyset[lf].status = self->deleted_keyset[i].status; /* mark the row off */ self->keyset[lf].status &= (~CURS_NEEDS_REREAD); } } } for (i = self->up_count - 1; i >= 0; i--) { if (hidx > updated[i] && lidx <= updated[i]) { lf = GIdx2KResIdx(updated[i], stmt, self); /* in case the row is marked off */ if (0 == (self->keyset[lf].status & CURS_NEEDS_REREAD)) continue; self->keyset[lf] = self->updated_keyset[i]; ReplaceCachedRows(self->backend_tuples + lf * num_fields, self->updated_tuples + i * num_fields, num_fields, 1); self->keyset[lf].status &= (~CURS_NEEDS_REREAD); } } /* reset CURS_NEEDS_REREAD bit */ for (i = 0; i < num_backend_rows; i++) { self->keyset[i].status &= (~CURS_NEEDS_REREAD); /*MYLOG(DETAIL_LOG_LEVEL, "keyset[%d].status=%x\n", i, self->keyset[i].status);*/ } } cleanup: LEAVE_CONN_CS(conn); #undef RETURN #undef return MYLOG(DETAIL_LOG_LEVEL, "returning %d offset=" FORMAT_LEN "\n", ret, offset); return ret; } /* * Read tuples from a libpq PGresult object into QResultClass. * * The result status of the passed-in PGresult should be either * PGRES_TUPLES_OK, or PGRES_SINGLE_TUPLE. If it's PGRES_SINGLE_TUPLE, * this function will call PQgetResult() to read all the available tuples. */ static BOOL QR_read_tuples_from_pgres(QResultClass *self, PGresult **pgres) { Int2 field_lf; int len; char *value; char *buffer; int ci_num_fields = QR_NumResultCols(self); /* speed up access */ int num_fields = self->num_fields; /* speed up access */ ColumnInfoClass *flds; int effective_cols; char tidoidbuf[32]; int rowno; int nrows; int resStatus; int numTotalRows = 0; /* set the current row to read the fields into */ effective_cols = QR_NumPublicResultCols(self); flds = QR_get_fields(self); nextrow: resStatus = PQresultStatus(*pgres); switch (resStatus) { case PGRES_TUPLES_OK: QLOG(0, "\tok: - 'T' - %s\n", PQcmdStatus(*pgres)); break; case PGRES_SINGLE_TUPLE: break; case PGRES_NONFATAL_ERROR: case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: default: handle_pgres_error(self->conn, *pgres, "read_tuples", self, TRUE); QR_set_rstatus(self, PORES_FATAL_ERROR); return FALSE; } nrows = PQntuples(*pgres); numTotalRows += nrows; for (rowno = 0; rowno < nrows; rowno++) { TupleField *this_tuplefield; KeySet *this_keyset = NULL; if (!QR_prepare_for_tupledata(self)) return FALSE; this_tuplefield = self->backend_tuples + (self->num_cached_rows * num_fields); if (QR_haskeyset(self)) { /* this_keyset = self->keyset + self->cursTuple + 1; */ this_keyset = self->keyset + self->num_cached_keys; this_keyset->status = 0; } QLOG(TUPLE_LOG_LEVEL, "\t"); for (field_lf = 0; field_lf < ci_num_fields; field_lf++) { BOOL isnull = FALSE; isnull = PQgetisnull(*pgres, rowno, field_lf); if (isnull) { this_tuplefield[field_lf].len = 0; this_tuplefield[field_lf].value = 0; QPRINTF(TUPLE_LOG_LEVEL, " (null)"); continue; } else { len = PQgetlength(*pgres, rowno, field_lf); value = PQgetvalue(*pgres, rowno, field_lf); if (field_lf >= effective_cols) buffer = tidoidbuf; else { QR_MALLOC_return_with_error(buffer, char, len + 1, self, "Out of memory in allocating item buffer.", FALSE); } memcpy(buffer, value, len); buffer[len] = '\0'; QPRINTF(TUPLE_LOG_LEVEL, " '%s'(%d)", buffer, len); if (field_lf >= effective_cols) { if (NULL == this_keyset) { char emsg[128]; QR_set_rstatus(self, PORES_INTERNAL_ERROR); SPRINTF_FIXED(emsg, "Internal Error -- this_keyset == NULL ci_num_fields=%d effective_cols=%d", ci_num_fields, effective_cols); QR_set_message(self, emsg); return FALSE; } if (field_lf == effective_cols) sscanf(buffer, "(%u,%hu)", &this_keyset->blocknum, &this_keyset->offset); else this_keyset->oid = strtoul(buffer, NULL, 10); } else { this_tuplefield[field_lf].len = len; this_tuplefield[field_lf].value = buffer; /* * This can be used to set the longest length of the column * for any row in the tuple cache. It would not be accurate * for varchar and text fields to use this since a tuple cache * is only 100 rows. Bpchar can be handled since the strlen of * all rows is fixed, assuming there are not 100 nulls in a * row! */ if (flds && flds->coli_array && CI_get_display_size(flds, field_lf) < len) CI_get_display_size(flds, field_lf) = len; } } } QPRINTF(TUPLE_LOG_LEVEL, "\n"); self->cursTuple++; if (self->num_fields > 0) { QR_inc_num_cache(self); } else if (QR_haskeyset(self)) self->num_cached_keys++; if (self->cursTuple >= self->num_total_read) self->num_total_read = self->cursTuple + 1; } if (resStatus == PGRES_SINGLE_TUPLE) { /* Process next row */ PQclear(*pgres); *pgres = PQgetResult(self->conn->pqconn); goto nextrow; } self->dataFilled = TRUE; self->tupleField = self->backend_tuples + (self->fetch_number * self->num_fields); MYLOG(DETAIL_LOG_LEVEL, "tupleField=%p\n", self->tupleField); QR_set_rstatus(self, PORES_TUPLES_OK); return TRUE; } int QR_search_by_fieldname(const QResultClass *self, const char *name) { int i; char *col_name; for (i = 0; i < QR_NumResultCols(self); i++) { col_name = QR_get_fieldname(self, i); if (strcmp(col_name, name) == 0) return i; } return -1; } psqlodbc-REL-16_00_0005/qresult.h000066400000000000000000000307031462406103600163510ustar00rootroot00000000000000/* File: qresult.h * * Description: See "qresult.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __QRESULT_H__ #define __QRESULT_H__ #include "psqlodbc.h" #include "libpq-fe.h" #include "connection.h" #include "columninfo.h" #include "tuple.h" #ifdef __cplusplus extern "C" { #endif typedef enum QueryResultCode_ { PORES_EMPTY_QUERY = 0, PORES_COMMAND_OK, /* a query command that doesn't return * anything was executed properly by the backend */ PORES_TUPLES_OK, /* a query command that returns tuples * was executed properly by the backend, PGresult * contains the resulttuples */ PORES_COPY_OUT, PORES_COPY_IN, PORES_BAD_RESPONSE, /* an unexpected response was recv'd from * the backend */ PORES_NONFATAL_ERROR, PORES_FATAL_ERROR, PORES_NO_MEMORY_ERROR, PORES_FIELDS_OK = 100, /* field information from a query was * successful */ /* PORES_END_TUPLES, */ PORES_INTERNAL_ERROR } QueryResultCode; enum { FQR_REACHED_EOF = (1L << 1) /* reached eof */ ,FQR_HAS_VALID_BASE = (1L << 2) ,FQR_NEEDS_SURVIVAL_CHECK = (1L << 3) /* check if the cursor is open */ }; struct QResultClass_ { ColumnInfoClass *fields; /* the Column information */ ConnectionClass *conn; /* the connection this result is using * (backend) */ QResultClass *lnext; /* the following result class */ /* Stuff for declare/fetch tuples */ SQLULEN num_total_read; /* the highest absolute position ever read in + 1 */ SQLULEN count_backend_allocated;/* m(re)allocated count */ SQLULEN num_cached_rows; /* count of tuples kept in backend_tuples member */ SQLLEN fetch_number; /* 0-based index to the tuple to read next */ SQLLEN cursTuple; /* absolute current position in the servr's cursor used to retrieve tuples from the DB */ SQLULEN move_offset; SQLLEN base; /* relative position of rowset start in the current data cache(backend_tuples) */ UInt2 num_fields; /* number of fields in the result */ UInt2 num_key_fields; /* number of key fields in the result */ UInt4 rowset_size_include_ommitted; /* PG restriction */ SQLLEN recent_processed_row_count; SQLULEN cache_size; SQLULEN cmd_fetch_size; QueryResultCode rstatus; /* result status */ char sqlstate[8]; char *message; const char *messageref; char *cursor_name; /* The name of the cursor for select statements */ char *command; char *notice; TupleField *backend_tuples; /* data from the backend (the tuple cache) */ TupleField *tupleField; /* current backend tuple being retrieved */ char pstatus; /* processing status */ char aborted; /* was aborted ? */ char flags; /* this result contains keyset etc ? */ po_ind_t move_direction; /* must move before fetching this result set */ SQLULEN count_keyset_allocated; /* m(re)allocated count */ SQLULEN num_cached_keys; /* count of keys kept in backend_keys member */ KeySet *keyset; SQLLEN key_base; /* relative position of rowset start in the current keyset cache */ UInt2 reload_count; UInt2 rb_alloc; /* count of allocated rollback info */ UInt2 rb_count; /* count of rollback info */ char dataFilled; /* Cache is filled with data ? */ Rollback *rollback; UInt4 ad_alloc; /* count of allocated added info */ UInt4 ad_count; /* count of newly added rows */ KeySet *added_keyset; /* added keyset info */ TupleField *added_tuples; /* added data by myself */ UInt2 dl_alloc; /* count of allocated deleted info */ UInt2 dl_count; /* count of deleted info */ SQLLEN *deleted; /* deleted index info */ KeySet *deleted_keyset; /* deleted keyset info */ UInt2 up_alloc; /* count of allocated updated info */ UInt2 up_count; /* count of updated info */ SQLLEN *updated; /* updated index info */ KeySet *updated_keyset; /* uddated keyset info */ TupleField *updated_tuples; /* uddated data by myself */ }; enum { FQR_HASKEYSET = 1L ,FQR_WITHHOLD = (1L << 1) ,FQR_HOLDPERMANENT = (1L << 2) /* the cursor is alive across transactions */ ,FQR_SYNCHRONIZEKEYS = (1L<<3) /* synchronize the keyset range with that of cthe tuples cache */ }; #define QR_haskeyset(self) (0 != (self->flags & FQR_HASKEYSET)) #define QR_is_withhold(self) (0 != (self->flags & FQR_WITHHOLD)) #define QR_is_permanent(self) (0 != (self->flags & FQR_HOLDPERMANENT)) #define QR_synchronize_keys(self) (0 != (self->flags & FQR_SYNCHRONIZEKEYS)) #define QR_get_fields(self) (self->fields) /* These functions are for retrieving data from the qresult */ #define QR_get_value_backend(self, fieldno) (self->tupleField[fieldno].value) #define QR_get_value_backend_row(self, tupleno, fieldno) ((self->backend_tuples + (tupleno * self->num_fields))[fieldno].value) #define QR_get_value_backend_text(self, tupleno, fieldno) QR_get_value_backend_row(self, tupleno, fieldno) #define QR_get_value_backend_int(self, tupleno, fieldno, isNull) atoi(QR_get_value_backend_row(self, tupleno, fieldno)) /* These functions are used by both manual and backend results */ #define QR_NumResultCols(self) (CI_get_num_fields(self->fields)) #define QR_NumPublicResultCols(self) (QR_haskeyset(self) ? (CI_get_num_fields(self->fields) - self->num_key_fields) : CI_get_num_fields(self->fields)) #define QR_get_fieldname(self, fieldno_) (CI_get_fieldname(self->fields, fieldno_)) #define QR_get_fieldsize(self, fieldno_) (CI_get_fieldsize(self->fields, fieldno_)) #define QR_get_display_size(self, fieldno_) (CI_get_display_size(self->fields, fieldno_)) #define QR_get_atttypmod(self, fieldno_) (CI_get_atttypmod(self->fields, fieldno_)) #define QR_get_field_type(self, fieldno_) (CI_get_oid(self->fields, fieldno_)) #define QR_get_relid(self, fieldno_) (CI_get_relid(self->fields, fieldno_)) #define QR_get_attid(self, fieldno_) (CI_get_attid(self->fields, fieldno_)) /* These functions are used only for manual result sets */ #define QR_get_num_total_tuples(self) (QR_once_reached_eof(self) ? (self->num_total_read + self->ad_count) : self->num_total_read) #define QR_get_num_total_read(self) (self->num_total_read) #define QR_get_num_cached_tuples(self) (self->num_cached_rows) #define QR_set_field_info(self, field_num, name, adtid, adtsize, relid, attid) (CI_set_field_info(self->fields, field_num, name, adtid, adtsize, -1, relid, attid)) #define QR_set_field_info_v(self, field_num, name, adtid, adtsize) (CI_set_field_info(self->fields, field_num, name, adtid, adtsize, -1, 0, 0)) /* status macros */ #define QR_command_successful(self) (self && !(self->rstatus == PORES_BAD_RESPONSE || self->rstatus == PORES_NONFATAL_ERROR || self->rstatus == PORES_FATAL_ERROR || self->rstatus == PORES_NO_MEMORY_ERROR)) #define QR_command_maybe_successful(self) (self && !(self->rstatus == PORES_BAD_RESPONSE || self->rstatus == PORES_FATAL_ERROR || self->rstatus == PORES_NO_MEMORY_ERROR)) #define QR_command_nonfatal(self) ( self->rstatus == PORES_NONFATAL_ERROR) #define QR_set_conn(self, conn_) ( self->conn = conn_ ) #define QR_set_rstatus(self, condition) ( self->rstatus = condition ) #define QR_set_sqlstatus(self, status) strcpy(self->sqlstatus, status) #define QR_set_messageref(self, m) ((self)->messageref = m) #define QR_set_aborted(self, aborted_) ( self->aborted = aborted_) #define QR_set_haskeyset(self) (self->flags |= FQR_HASKEYSET) #define QR_set_synchronize_keys(self) (self->flags |= FQR_SYNCHRONIZEKEYS) #define QR_set_no_cursor(self) ((self)->flags &= ~(FQR_WITHHOLD | FQR_HOLDPERMANENT), (self)->pstatus &= ~FQR_NEEDS_SURVIVAL_CHECK) #define QR_set_withhold(self) (self->flags |= FQR_WITHHOLD) #define QR_set_permanent(self) (self->flags |= FQR_HOLDPERMANENT) #define QR_set_reached_eof(self) (self->pstatus |= FQR_REACHED_EOF) #define QR_set_has_valid_base(self) (self->pstatus |= FQR_HAS_VALID_BASE) #define QR_set_no_valid_base(self) (self->pstatus &= ~FQR_HAS_VALID_BASE) #define QR_set_survival_check(self) (self->pstatus |= FQR_NEEDS_SURVIVAL_CHECK) #define QR_set_no_survival_check(self) (self->pstatus &= ~FQR_NEEDS_SURVIVAL_CHECK) #define QR_inc_num_cache(self) \ do { \ self->num_cached_rows++; \ if (QR_haskeyset(self)) \ self->num_cached_keys++; \ } while (0) #define QR_set_next_in_cache(self, number) \ do { \ MYLOG(1, "set the number to " FORMAT_LEN " to read next\n", number); \ self->fetch_number = number; \ } while (0) #define QR_inc_next_in_cache(self) \ do { \ MYLOG(1, "increased the number " FORMAT_LEN, self->fetch_number); \ self->fetch_number++; \ MYLOG(1, "to " FORMAT_LEN " to next read\n", self->fetch_number); \ } while (0) #define QR_concat(self, a) ((self)->lnext=(a)) #define QR_detach(self) ((self)->lnext=NULL) #define QR_nextr(self) ((self)->lnext) #define QR_get_message(self) ((self)->message ? (self)->message : (self)->messageref) #define QR_get_command(self) (self->command) #define QR_get_notice(self) (self->notice) #define QR_get_rstatus(self) (self->rstatus) #define QR_get_aborted(self) (self->aborted) #define QR_get_conn(self) (self->conn) #define QR_get_cursor(self) (self->cursor_name) #define QR_get_rowstart_in_cache(self) (self->base) #define QR_once_reached_eof(self) ((self->pstatus & FQR_REACHED_EOF) != 0) #define QR_has_valid_base(self) (0 != (self->pstatus & FQR_HAS_VALID_BASE)) #define QR_needs_survival_check(self) (0 != (self->pstatus & FQR_NEEDS_SURVIVAL_CHECK)) #define QR_aborted(self) (!self || self->aborted) #define QR_get_reqsize(self) (self->rowset_size_include_ommitted) #define QR_stop_movement(self) (self->move_direction = 0) #define QR_is_moving(self) (0 != self->move_direction) #define QR_is_not_moving(self) (0 == self->move_direction) #define QR_set_move_forward(self) (self->move_direction = 1) #define QR_is_moving_forward(self) (1 == self->move_direction) #define QR_set_move_backward(self) (self->move_direction = -1) #define QR_is_moving_backward(self) (-1 == self->move_direction) #define QR_set_move_from_the_last(self) (self->move_direction = 2) #define QR_is_moving_from_the_last(self) (2 == self->move_direction) #define QR_is_moving_not_backward(self) (0 < self->move_direction) /* Core Functions */ QResultClass *QR_Constructor(void); void QR_Destructor(QResultClass *self); TupleField *QR_AddNew(QResultClass *self); int QR_next_tuple(QResultClass *self, StatementClass *); int QR_close(QResultClass *self); void QR_on_close_cursor(QResultClass *self); void QR_close_result(QResultClass *self, BOOL destroy); void QR_reset_for_re_execute(QResultClass *self); BOOL QR_from_PGresult(QResultClass *self, StatementClass *stmt, ConnectionClass *conn, const char *cursor, PGresult **pgres); void QR_free_memory(QResultClass *self); void QR_set_command(QResultClass *self, const char *msg); void QR_set_message(QResultClass *self, const char *msg); void QR_add_message(QResultClass *self, const char *msg); void QR_set_notice(QResultClass *self, const char *msg); void QR_add_notice(QResultClass *self, const char *msg); void QR_set_num_fields(QResultClass *self, int new_num_fields); /* catalog functions' result only */ void QR_set_fields(QResultClass *self, ColumnInfoClass *); void QR_set_num_cached_rows(QResultClass *, SQLLEN); void QR_set_rowstart_in_cache(QResultClass *, SQLLEN); void QR_inc_rowstart_in_cache(QResultClass *self, SQLLEN base_inc); void QR_set_cache_size(QResultClass *self, SQLLEN cache_size); void QR_set_reqsize(QResultClass *self, Int4 reqsize); void QR_set_position(QResultClass *self, SQLLEN pos); void QR_set_cursor(QResultClass *self, const char *name); SQLLEN getNthValid(const QResultClass *self, SQLLEN sta, UWORD orientation, SQLULEN nth, SQLLEN *nearest); SQLLEN QR_move_cursor_to_last(QResultClass *self, StatementClass *stmt); BOOL QR_get_last_bookmark(const QResultClass *self, Int4 index, KeySet *keyset); int QR_search_by_fieldname(const QResultClass *self, const char *name); #define QR_MALLOC_return_with_error(t, tp, s, a, m, r) \ do { \ if (t = (tp *) malloc(s), NULL == t) \ { \ QR_set_rstatus(a, PORES_NO_MEMORY_ERROR); \ qlog("QR_MALLOC_error\n"); \ QR_free_memory(a); \ QR_set_messageref(a, m); \ return r; \ } \ } while (0) #define QR_REALLOC_return_with_error(t, tp, s, a, m, r) \ do { \ tp *tmp; \ if (tmp = (tp *) realloc(t, s), NULL == tmp) \ { \ QR_set_rstatus(a, PORES_NO_MEMORY_ERROR); \ qlog("QR_REALLOC_error\n"); \ QR_free_memory(a); \ QR_set_messageref(a, m); \ return r; \ } \ t = tmp; \ } while (0) #define QR_REALLOC_gexit_with_error(t, tp, s, a, m, r) \ do { \ tp *tmp; \ if (tmp = (tp *) realloc(t, s), NULL == tmp) \ { \ QR_set_rstatus(a, PORES_NO_MEMORY_ERROR); \ QR_free_memory(a); \ QR_set_messageref(a, m); \ r; \ goto cleanup; \ } \ t = tmp; \ } while (0) #ifdef __cplusplus } #endif #endif /* __QRESULT_H__ */ psqlodbc-REL-16_00_0005/readme.txt000066400000000000000000000025271462406103600165020ustar00rootroot00000000000000 /******************************************************************** PSQLODBC.DLL - A library to talk to the PostgreSQL DBMS using ODBC. Copyright (C) 1998 Insight Distribution Systems Copyright (C) 1998 - 2024 The PostgreSQL Global Development Group Multibyte support was added by Sankyo Unyu Service, (C) 2001. The code contained in this library is based on code written by Christian Czezatke and Dan McGuirk, (C) 1996. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library (see "license.txt"); if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. How to contact the authors: email: pgsql-odbc@postgresql.org website: https://odbc.postgresql.org/ ***********************************************************************/ psqlodbc-REL-16_00_0005/readme_winbuild.txt000066400000000000000000000005421462406103600203720ustar00rootroot00000000000000This folder contains 4 batch scripts BuildAll.bat editConfiguration.bat regress.bat buildInstallers.bat which have the same functionalities as corresponding powershell scripts in winbuild folder. See docs\win32-compilation.html and winbuild\readme.txt for Windows compilation instructions. For info on building installers, see installer\README.txt psqlodbc-REL-16_00_0005/regress.bat000077500000000000000000000004531462406103600166450ustar00rootroot00000000000000:: :: regression test using MSBuild :: @echo off if "%1" == "/?" ( powershell Get-Help '%~dp0\winbuild\regress.ps1' -detailed ) else if "%1" == "-?" ( powershell Get-Help '%~dp0\winbuild\regress.ps1' %2 %3 %4 %5 %6 %7 %8 %9 ) else ( start powershell -noexit "& '%~dp0\winbuild\regress.ps1' %*" ) psqlodbc-REL-16_00_0005/resource.h000066400000000000000000000115771462406103600165110ustar00rootroot00000000000000//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by psqlodbc.rc // #define IDS_BADDSN 1 #define IDS_MSGTITLE 2 #define IDS_ADVANCE_OPTION_DEF 3 #define IDOK2 3 #define IDS_ADVANCE_SAVE 4 #define IDCANCEL2 4 #define IDS_ADVANCE_OPTION_DSN1 5 #define IDS_ADVANCE_OPTION_CON1 6 #define IDS_ADVANCE_OPTION_DSN2 7 #define IDS_ADVANCE_OPTION_CON2 8 #define IDS_ADVANCE_CONNECTION 9 #define IDS_ADVANCE_OPTION_DSN3 10 #define IDS_ADVANCE_OPTION_CON3 11 #define DLG_OPTIONS_DRV 102 #define DLG_OPTIONS_DS 103 #define DLG_OPTIONS_GLOBAL 104 #define DLG_OPTIONS_DS3 105 #define IDC_DSNAME 400 #define IDC_DSNAMETEXT 401 #define IDC_DESC 404 #define IDC_SERVER 407 #define IDC_DATABASE 408 #define IDC_SSLMODE 409 #define IDS_SSLREQUEST_PREFER 410 #define IDS_SSLREQUEST_ALLOW 411 #define IDS_SSLREQUEST_REQUIRE 412 #define IDS_SSLREQUEST_DISABLE 413 #define IDC_NOTICE_USER 414 #define IDS_SSLREQUEST_VERIFY_CA 415 #define IDS_SSLREQUEST_VERIFY_FULL 416 #define DLG_CONFIG 1001 #define IDC_PORT 1002 #define DLG_DRIVER_CHANGE 1002 #define IDC_USER 1006 #define IDC_PASSWORD 1009 #define DS_READONLY 1011 #define DS_SHOWOIDCOLUMN 1012 #define DS_FAKEOIDINDEX 1013 #define DRV_COMMLOG 1014 #define IDC_DATASOURCE 1018 #define DRV_OPTIMIZER 1019 #define DS_CONNSETTINGS 1020 #define IDC_DRIVER 1021 #define DRV_CONNSETTINGS 1031 #define DRV_UNIQUEINDEX 1032 #define DRV_UNKNOWN_MAX 1035 #define DRV_UNKNOWN_DONTKNOW 1036 #define DRV_READONLY 1037 #define IDC_DESCTEXT 1039 #define DRV_MSG_LABEL 1040 #define DRV_UNKNOWN_LONGEST 1041 #define DRV_TEXT_LONGVARCHAR 1043 #define DRV_UNKNOWNS_LONGVARCHAR 1044 #define DRV_CACHE_SIZE 1045 #define DRV_VARCHAR_SIZE 1046 #define DRV_LONGVARCHAR_SIZE 1047 #define IDDEFAULTS 1048 #define DRV_USEDECLAREFETCH 1049 #define DRV_BOOLS_CHAR 1050 #define DS_SHOWSYSTEMTABLES 1051 #define DRV_EXTRASYSTABLEPREFIXES 1051 #define DS_ROWVERSIONING 1052 #define DRV_PARSE 1052 #define DRV_CANCELASFREESTMT 1053 #define IDC_OPTIONS 1054 #define DRV_OR_DSN 1059 #define DRV_DEBUG 1060 #define DS_OPTIONALERRORS 1061 #define DS_LFCONVERSION 1062 #define DS_TRUEISMINUS1 1063 #define DS_UPDATABLECURSORS 1064 #define IDNEXTPAGE 1065 #define IDPREVPAGE 1066 #define DS_INT8_AS_DEFAULT 1067 #define DS_INT8_AS_BIGINT 1068 #define DS_INT8_AS_NUMERIC 1069 #define DS_INT8_AS_VARCHAR 1070 #define DS_INT8_AS_DOUBLE 1071 #define DS_INT8_AS_INT4 1072 #define DRV_MSG_LABEL2 1073 #define DS_BYTEAASLONGVARBINARY 1073 #define IDAPPLY 1074 #define DS_SERVERSIDEPREPARE 1075 #define IDC_DRIVERNAME 1076 #define IDC_MANAGEDSN 1077 #define IDC_DRIVER_LIST 1078 #define DS_NO_ROLLBACK 1080 #define DS_TRANSACTION_ROLLBACK 1081 #define DS_STATEMENT_ROLLBACK 1082 #define DRV_DTCLOG 1083 #define DS_EXTRA_OPTIONS 1084 #define IDC_TEST 1085 #define DS_LOGDIR 1086 #define DS_GSSAUTHUSEGSSAPI 1087 #define DS_DISABLE_KEEPALIVE 1088 #define DS_KEEPALIVETIME 1089 #define DS_KEEPALIVEINTERVAL 1090 #define DS_DEFAULT_DTCLOG 1091 #define DS_DTCLOG 1092 #define DS_NO_DTCLOG 1093 #define DS_DTC_NO_USE 1097 #define DS_DTC_LINK_ONLY 1098 #define DS_DTC_SIMPLE_PRECHECK 1099 #define DS_DTC_CONFIRM_RM_CONNECTION 1100 #define ID1STPAGE 1101 #define ID2NDPAGE 1102 #define ID3RDPAGE 1103 #define DS_LIBPQOPT 1104 #define DS_COMMLOG 1105 #define DS_DEBUG 1106 #define DS_NUMERIC_AS_DEFAULT 1107 #define DS_NUMERIC_AS_NUMERIC 1108 #define DS_NUMERIC_AS_VARCHAR 1109 #define DS_NUMERIC_AS_DOUBLE 1110 #define DS_NUMERIC_AS_LONGVARCHAR 1111 #define DS_BATCH_SIZE 1112 #define DS_IGNORETIMEOUT 1113 #define DS_FETCH_REFCURSORS 1114 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1115 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif psqlodbc-REL-16_00_0005/results.c000066400000000000000000004166511462406103600163600ustar00rootroot00000000000000/* * Module: results.c * * Description: This module contains functions related to * retrieving result information through the ODBC API. * * Classes: n/a * * API functions: SQLRowCount, SQLNumResultCols, SQLDescribeCol, * SQLColAttributes, SQLGetData, SQLFetch, SQLExtendedFetch, * SQLMoreResults, SQLSetPos, SQLSetScrollOptions(NI), * SQLSetCursorName, SQLGetCursorName * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "psqlodbc.h" #include #include "misc.h" #include "dlg_specific.h" #include "environ.h" #include "connection.h" #include "statement.h" #include "bind.h" #include "qresult.h" #include "convert.h" #include "pgtypes.h" #include #include #include "pgapifunc.h" /* Helper macro */ #define getEffectiveOid(conn, fi) pg_true_type((conn), (fi)->columntype, FI_type(fi)) #define NULL_IF_NULL(a) ((a) ? ((const char *)(a)) : "(null)") RETCODE SQL_API PGAPI_RowCount(HSTMT hstmt, SQLLEN * pcrow) { CSTR func = "PGAPI_RowCount"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; MYLOG(0, "entering...\n"); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } if (stmt->proc_return > 0) { *pcrow = 0; MYLOG(DETAIL_LOG_LEVEL, "returning RowCount=" FORMAT_LEN "\n", *pcrow); return SQL_SUCCESS; } res = SC_get_Curres(stmt); if (res) { if (stmt->status != STMT_FINISHED) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Can't get row count while statement is still executing.", func); return SQL_ERROR; } if (res->recent_processed_row_count >= 0) { *pcrow = res->recent_processed_row_count; MYLOG(0, "**** THE ROWS: *pcrow = " FORMAT_LEN "\n", *pcrow); return SQL_SUCCESS; } else if (QR_NumResultCols(res) > 0) { *pcrow = QR_get_cursor(res) ? -1 : QR_get_num_total_tuples(res) - res->dl_count; MYLOG(0, "RowCount=" FORMAT_LEN "\n", *pcrow); return SQL_SUCCESS; } } return SQL_SUCCESS; } static BOOL SC_describe_ok(StatementClass *stmt, BOOL build_fi, int col_idx, const char *func) { Int2 num_fields; QResultClass *result; BOOL exec_ok = TRUE; num_fields = SC_describe(stmt); result = SC_get_ExecdOrParsed(stmt); MYLOG(0, "entering result = %p, status = %d, numcols = %d\n", result, stmt->status, result != NULL ? QR_NumResultCols(result) : -1); /****if ((!result) || ((stmt->status != STMT_FINISHED) && (stmt->status != STMT_PREMATURE))) ****/ if (!QR_command_maybe_successful(result) || num_fields < 0) { /* no query has been executed on this statement */ SC_set_error(stmt, STMT_EXEC_ERROR, "No query has been executed with that handle", func); exec_ok = FALSE; } else if (col_idx >= 0 && col_idx < num_fields) { OID reloid = QR_get_relid(result, col_idx); IRDFields *irdflds = SC_get_IRDF(stmt); FIELD_INFO *fi; TABLE_INFO *ti = NULL; MYLOG(DETAIL_LOG_LEVEL, "build_fi=%d reloid=%u\n", build_fi, reloid); if (build_fi && 0 != QR_get_attid(result, col_idx)) getCOLIfromTI(func, NULL, stmt, reloid, &ti); MYLOG(DETAIL_LOG_LEVEL, "nfields=%d\n", irdflds->nfields); if (irdflds->fi && col_idx < (int) irdflds->nfields) { fi = irdflds->fi[col_idx]; if (fi) { if (ti) { if (NULL == fi->ti) fi->ti = ti; if (!FI_is_applicable(fi) && 0 != (ti->flags & TI_COLATTRIBUTE)) fi->flag |= FIELD_COL_ATTRIBUTE; } fi->basetype = QR_get_field_type(result, col_idx); if (0 == fi->columntype) fi->columntype = fi->basetype; } } } return exec_ok; } /* * This returns the number of columns associated with the database * attached to "hstmt". */ RETCODE SQL_API PGAPI_NumResultCols(HSTMT hstmt, SQLSMALLINT * pccol) { CSTR func = "PGAPI_NumResultCols"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *result; char parse_ok; RETCODE ret = SQL_SUCCESS; MYLOG(0, "entering...\n"); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } SC_clear_error(stmt); #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(stmt); */ if (stmt->proc_return > 0) { *pccol = 0; goto cleanup; } parse_ok = FALSE; if (!stmt->catalog_result && SC_is_parse_forced(stmt) && SC_can_parse_statement(stmt)) { if (SC_parsed_status(stmt) == STMT_PARSE_NONE) { MYLOG(0, "calling parse_statement on stmt=%p\n", stmt); parse_statement(stmt, FALSE); } if (SC_parsed_status(stmt) != STMT_PARSE_FATAL) { parse_ok = TRUE; *pccol = SC_get_IRDF(stmt)->nfields; MYLOG(0, "PARSE: *pccol = %d\n", *pccol); } } if (!parse_ok) { if (!SC_describe_ok(stmt, FALSE, -1, func)) { ret = SQL_ERROR; goto cleanup; } result = SC_get_ExecdOrParsed(stmt); *pccol = QR_NumPublicResultCols(result); } cleanup: #undef return return ret; } #define USE_FI(fi, unknown) (fi && UNKNOWNS_AS_LONGEST != unknown) /* * Return information about the database column the user wants * information about. */ RETCODE SQL_API PGAPI_DescribeCol(HSTMT hstmt, SQLUSMALLINT icol, SQLCHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT * pcbColName, SQLSMALLINT * pfSqlType, SQLULEN * pcbColDef, SQLSMALLINT * pibScale, SQLSMALLINT * pfNullable) { CSTR func = "PGAPI_DescribeCol"; /* gets all the information about a specific column */ StatementClass *stmt = (StatementClass *) hstmt; ConnectionClass *conn; IRDFields *irdflds; QResultClass *res = NULL; char *col_name = NULL; OID fieldtype = 0; SQLLEN column_size = 0; int unknown_sizes; SQLINTEGER decimal_digits = 0; ConnInfo *ci; FIELD_INFO *fi; char buf[255]; int len = 0; RETCODE result = SQL_SUCCESS; MYLOG(0, "entering.%d..\n", icol); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } conn = SC_get_conn(stmt); ci = &(conn->connInfo); unknown_sizes = ci->drivers.unknown_sizes; SC_clear_error(stmt); #define return DONT_CALL_RETURN_FROM_HERE??? irdflds = SC_get_IRDF(stmt); if (0 == icol) /* bookmark column */ { SQLSMALLINT fType = stmt->options.use_bookmarks == SQL_UB_VARIABLE ? SQL_BINARY : SQL_INTEGER; MYLOG(DETAIL_LOG_LEVEL, "answering bookmark info\n"); if (szColName && cbColNameMax > 0) *szColName = '\0'; if (pcbColName) *pcbColName = 0; if (pfSqlType) *pfSqlType = fType; if (pcbColDef) *pcbColDef = 10; if (pibScale) *pibScale = 0; if (pfNullable) *pfNullable = SQL_NO_NULLS; result = SQL_SUCCESS; goto cleanup; } /* * Dont check for bookmark column. This is the responsibility of the * driver manager. */ icol--; /* use zero based column numbers */ fi = NULL; if (icol < irdflds->nfields && irdflds->fi) fi = irdflds->fi[icol]; if (!FI_is_applicable(fi) && !stmt->catalog_result && SC_is_parse_forced(stmt) && SC_can_parse_statement(stmt)) { if (SC_parsed_status(stmt) == STMT_PARSE_NONE) { MYLOG(0, "calling parse_statement on stmt=%p\n", stmt); parse_statement(stmt, FALSE); } MYLOG(0, "PARSE: icol=%d, stmt=%p, stmt->nfld=%d, stmt->fi=%p\n", icol, stmt, irdflds->nfields, irdflds->fi); if (SC_parsed_status(stmt) != STMT_PARSE_FATAL && irdflds->fi) { if (icol < irdflds->nfields) fi = irdflds->fi[icol]; else { SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in DescribeCol.", func); result = SQL_ERROR; goto cleanup; } MYLOG(0, "getting info for icol=%d\n", icol); } } if (!FI_is_applicable(fi)) { /* * If couldn't parse it OR the field being described was not parsed * (i.e., because it was a function or expression, etc, then do it the * old fashioned way. */ BOOL build_fi = (NULL != pfNullable || NULL != pfSqlType); fi = NULL; if (!SC_describe_ok(stmt, build_fi, icol, func)) { result = SQL_ERROR; goto cleanup; } res = SC_get_ExecdOrParsed(stmt); if (icol >= QR_NumPublicResultCols(res)) { SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in DescribeCol.", func); SPRINTF_FIXED(buf, "Col#=%d, #Cols=%d,%d keys=%d", icol, QR_NumResultCols(res), QR_NumPublicResultCols(res), res->num_key_fields); SC_log_error(func, buf, stmt); result = SQL_ERROR; goto cleanup; } if (icol < irdflds->nfields && irdflds->fi) fi = irdflds->fi[icol]; } res = SC_get_ExecdOrParsed(stmt); #ifdef SUPPRESS_LONGEST_ON_CURSORS if (UNKNOWNS_AS_LONGEST == unknown_sizes) { if (QR_once_reached_eof(res)) unknown_sizes = UNKNOWNS_AS_LONGEST; else unknown_sizes = UNKNOWNS_AS_MAX; } #endif /* SUPPRESS_LONGEST_ON_CURSORS */ /* handle constants */ if (res && -2 == QR_get_fieldsize(res, icol)) unknown_sizes = UNKNOWNS_AS_LONGEST; if (FI_is_applicable(fi)) { fieldtype = getEffectiveOid(conn, fi); if (NAME_IS_VALID(fi->column_alias)) col_name = GET_NAME(fi->column_alias); else col_name = GET_NAME(fi->column_name); if (USE_FI(fi, unknown_sizes)) { column_size = fi->column_size; decimal_digits = fi->decimal_digits; } else { column_size = pgtype_column_size(stmt, fieldtype, icol, unknown_sizes); decimal_digits = pgtype_decimal_digits(stmt, fieldtype, icol); } MYLOG(0, "PARSE: fieldtype=%u, col_name='%s', column_size=" FORMAT_LEN "\n", fieldtype, NULL_IF_NULL(col_name), column_size); } else { col_name = QR_get_fieldname(res, icol); fieldtype = QR_get_field_type(res, icol); column_size = pgtype_column_size(stmt, fieldtype, icol, unknown_sizes); decimal_digits = pgtype_decimal_digits(stmt, fieldtype, icol); } MYLOG(0, "col %d fieldname = '%s'\n", icol, NULL_IF_NULL(col_name)); MYLOG(0, "col %d fieldtype = %d\n", icol, fieldtype); MYLOG(0, "col %d column_size = " FORMAT_LEN "\n", icol, column_size); result = SQL_SUCCESS; /* * COLUMN NAME */ len = col_name ? (int) strlen(col_name) : 0; if (pcbColName) *pcbColName = len; if (szColName && cbColNameMax > 0) { if (NULL != col_name) strncpy_null((char *) szColName, col_name, cbColNameMax); else szColName[0] = '\0'; if (len >= cbColNameMax) { result = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the colName.", func); } } /* * CONCISE(SQL) TYPE */ if (pfSqlType) { *pfSqlType = pgtype_to_concise_type(stmt, fieldtype, icol, unknown_sizes); MYLOG(0, "col %d *pfSqlType = %d\n", icol, *pfSqlType); } /* * COLUMN SIZE(PRECISION in 2.x) */ if (pcbColDef) { if (column_size < 0) column_size = 0; /* "I dont know" */ *pcbColDef = column_size; MYLOG(0, "Col: col %d *pcbColDef = " FORMAT_ULEN "\n", icol, *pcbColDef); } /* * DECIMAL DIGITS(SCALE in 2.x) */ if (pibScale) { if (decimal_digits < 0) decimal_digits = 0; *pibScale = (SQLSMALLINT) decimal_digits; MYLOG(0, "col %d *pibScale = %d\n", icol, *pibScale); } /* * NULLABILITY */ if (pfNullable) { if (SC_has_outer_join(stmt)) *pfNullable = TRUE; else *pfNullable = fi ? fi->nullable : pgtype_nullable(conn, fieldtype); MYLOG(0, "col %d *pfNullable = %d\n", icol, *pfNullable); } cleanup: #undef return return result; } /* Returns result column descriptor information for a result set. */ RETCODE SQL_API PGAPI_ColAttributes(HSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, PTR rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT * pcbDesc, SQLLEN * pfDesc) { CSTR func = "PGAPI_ColAttributes"; StatementClass *stmt = (StatementClass *) hstmt; IRDFields *irdflds; OID field_type = 0; Int2 col_idx; ConnectionClass *conn; ConnInfo *ci; int column_size, unknown_sizes; int cols = 0; RETCODE result; const char *p = NULL; SQLLEN value = 0; const FIELD_INFO *fi = NULL; const TABLE_INFO *ti = NULL; QResultClass *res; BOOL stmt_updatable; MYLOG(0, "entering..col=%d %d len=%d.\n", icol, fDescType, cbDescMax); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } stmt_updatable = SC_is_updatable(stmt) /* The following doesn't seem appropriate for client side cursors && stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY */ ; if (pcbDesc) *pcbDesc = 0; irdflds = SC_get_IRDF(stmt); conn = SC_get_conn(stmt); ci = &(conn->connInfo); /* * Dont check for bookmark column. This is the responsibility of the * driver manager. For certain types of arguments, the column number * is ignored anyway, so it may be 0. */ res = SC_get_ExecdOrParsed(stmt); if (0 == icol && SQL_DESC_COUNT != fDescType) /* bookmark column */ { MYLOG(DETAIL_LOG_LEVEL, "answering bookmark info\n"); switch (fDescType) { case SQL_DESC_OCTET_LENGTH: if (pfDesc) *pfDesc = 4; break; case SQL_DESC_TYPE: if (pfDesc) *pfDesc = stmt->options.use_bookmarks == SQL_UB_VARIABLE ? SQL_BINARY : SQL_INTEGER; break; } return SQL_SUCCESS; } col_idx = icol - 1; unknown_sizes = ci->drivers.unknown_sizes; /* not appropriate for SQLColAttributes() */ if (stmt->catalog_result) unknown_sizes = UNKNOWNS_AS_LONGEST; else if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) unknown_sizes = UNKNOWNS_AS_MAX; if (!stmt->catalog_result && SC_is_parse_forced(stmt) && SC_can_parse_statement(stmt)) { if (SC_parsed_status(stmt) == STMT_PARSE_NONE) { MYLOG(0, "calling parse_statement\n"); parse_statement(stmt, FALSE); } cols = irdflds->nfields; /* * Column Count is a special case. The Column number is ignored * in this case. */ if (fDescType == SQL_DESC_COUNT) { if (pfDesc) *pfDesc = cols; return SQL_SUCCESS; } if (SC_parsed_status(stmt) != STMT_PARSE_FATAL && irdflds->fi) { if (col_idx >= cols) { SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in ColAttributes.", func); return SQL_ERROR; } } } if (col_idx < irdflds->nfields && irdflds->fi) fi = irdflds->fi[col_idx]; if (FI_is_applicable(fi)) field_type = getEffectiveOid(conn, fi); else { BOOL build_fi = FALSE; fi = NULL; switch (fDescType) { case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_TABLE_NAME: case SQL_COLUMN_TYPE: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_AUTO_INCREMENT: case SQL_DESC_NULLABLE: case SQL_DESC_BASE_TABLE_NAME: case SQL_DESC_BASE_COLUMN_NAME: case SQL_COLUMN_UPDATABLE: case 1212: /* SQL_CA_SS_COLUMN_KEY ? */ build_fi = TRUE; break; } if (!SC_describe_ok(stmt, build_fi, col_idx, func)) return SQL_ERROR; res = SC_get_ExecdOrParsed(stmt); cols = QR_NumPublicResultCols(res); /* * Column Count is a special case. The Column number is ignored * in this case. */ if (fDescType == SQL_DESC_COUNT) { if (pfDesc) *pfDesc = cols; return SQL_SUCCESS; } if (col_idx >= cols) { SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in ColAttributes.", func); return SQL_ERROR; } field_type = QR_get_field_type(res, col_idx); if (col_idx < irdflds->nfields && irdflds->fi) fi = irdflds->fi[col_idx]; } if (FI_is_applicable(fi)) { ti = fi->ti; field_type = getEffectiveOid(conn, fi); } else { fi = NULL; } MYLOG(0, "col %d field_type=%d fi,ti=%p,%p\n", col_idx, field_type, fi, ti); #ifdef SUPPRESS_LONGEST_ON_CURSORS if (UNKNOWNS_AS_LONGEST == unknown_sizes) { if (QR_once_reached_eof(res)) unknown_sizes = UNKNOWNS_AS_LONGEST; else unknown_sizes = UNKNOWNS_AS_MAX; } #endif /* SUPPRESS_LONGEST_ON_CURSORS */ /* handle constants */ if (res && -2 == QR_get_fieldsize(res, col_idx)) unknown_sizes = UNKNOWNS_AS_LONGEST; column_size = (USE_FI(fi, unknown_sizes) && fi->column_size > 0) ? fi->column_size : pgtype_column_size(stmt, field_type, col_idx, unknown_sizes); switch (fDescType) { case SQL_COLUMN_AUTO_INCREMENT: /* == SQL_DESC_AUTO_UNIQUE_VALUE */ if (fi && fi->auto_increment) value = TRUE; else value = pgtype_auto_increment(conn, field_type); if (value == -1) /* non-numeric becomes FALSE (ODBC Doc) */ value = FALSE; MYLOG(0, "AUTO_INCREMENT=" FORMAT_LEN "\n", value); break; case SQL_COLUMN_CASE_SENSITIVE: /* == SQL_DESC_CASE_SENSITIVE */ value = pgtype_case_sensitive(conn, field_type); break; /* * This special case is handled above. * * case SQL_COLUMN_COUNT: */ case SQL_COLUMN_DISPLAY_SIZE: /* == SQL_DESC_DISPLAY_SIZE */ value = (USE_FI(fi, unknown_sizes) && 0 != fi->display_size) ? fi->display_size : pgtype_display_size(stmt, field_type, col_idx, unknown_sizes); MYLOG(0, "col %d, display_size= " FORMAT_LEN "\n", col_idx, value); break; case SQL_COLUMN_LABEL: /* == SQL_DESC_LABEL */ if (fi && (NAME_IS_VALID(fi->column_alias))) { p = GET_NAME(fi->column_alias); MYLOG(0, "COLUMN_LABEL = '%s'\n", p); break; } /* otherwise same as column name -- FALL THROUGH!!! */ case SQL_DESC_NAME: MYLOG(DETAIL_LOG_LEVEL, "fi=%p (alias, name)=", fi); if (fi) MYPRINTF(DETAIL_LOG_LEVEL, "(%s,%s)\n", PRINT_NAME(fi->column_alias), PRINT_NAME(fi->column_name)); else MYPRINTF(DETAIL_LOG_LEVEL, "NULL\n"); p = fi ? (NAME_IS_NULL(fi->column_alias) ? SAFE_NAME(fi->column_name) : GET_NAME(fi->column_alias)) : QR_get_fieldname(res, col_idx); MYLOG(0, "COLUMN_NAME = '%s'\n", p); break; case SQL_COLUMN_LENGTH: value = (USE_FI(fi, unknown_sizes) && fi->length > 0) ? fi->length : pgtype_buffer_length(stmt, field_type, col_idx, unknown_sizes); if (0 > value) /* if (-1 == value) I'm not sure which is right */ value = 0; MYLOG(0, "col %d, column_length = " FORMAT_LEN "\n", col_idx, value); break; case SQL_COLUMN_MONEY: /* == SQL_DESC_FIXED_PREC_SCALE */ value = pgtype_money(conn, field_type); MYLOG(DETAIL_LOG_LEVEL, "COLUMN_MONEY=" FORMAT_LEN "\n", value); break; case SQL_DESC_NULLABLE: if (SC_has_outer_join(stmt)) value = TRUE; else value = fi ? fi->nullable : pgtype_nullable(conn, field_type); MYLOG(DETAIL_LOG_LEVEL, "COLUMN_NULLABLE=" FORMAT_LEN "\n", value); break; case SQL_COLUMN_OWNER_NAME: /* == SQL_DESC_SCHEMA_NAME */ p = ti ? SAFE_NAME(ti->schema_name) : NULL_STRING; MYLOG(0, "SCHEMA_NAME = '%s'\n", p); break; case SQL_COLUMN_PRECISION: /* in 2.x */ value = column_size; if (value < 0) value = 0; MYLOG(0, "col %d, column_size = " FORMAT_LEN "\n", col_idx, value); break; case SQL_COLUMN_QUALIFIER_NAME: /* == SQL_DESC_CATALOG_NAME */ p = ti ? CurrCatString(conn) : NULL_STRING; /* empty string means *not supported* */ break; case SQL_COLUMN_SCALE: /* in 2.x */ value = pgtype_decimal_digits(stmt, field_type, col_idx); MYLOG(DETAIL_LOG_LEVEL, "COLUMN_SCALE=" FORMAT_LEN "\n", value); if (value < 0) value = 0; break; case SQL_COLUMN_SEARCHABLE: /* == SQL_DESC_SEARCHABLE */ value = pgtype_searchable(conn, field_type); break; case SQL_COLUMN_TABLE_NAME: /* == SQL_DESC_TABLE_NAME */ p = ti ? SAFE_NAME(ti->table_name) : NULL_STRING; MYLOG(0, "TABLE_NAME = '%s'\n", p); break; case SQL_COLUMN_TYPE: /* == SQL_DESC_CONCISE_TYPE */ value = pgtype_to_concise_type(stmt, field_type, col_idx, unknown_sizes); MYLOG(0, "COLUMN_TYPE=" FORMAT_LEN "\n", value); break; case SQL_COLUMN_TYPE_NAME: /* == SQL_DESC_TYPE_NAME */ p = pgtype_to_name(stmt, field_type, col_idx, fi && fi->auto_increment); break; case SQL_COLUMN_UNSIGNED: /* == SQL_DESC_UNSIGNED */ value = pgtype_unsigned(conn, field_type); if (value == -1) /* non-numeric becomes TRUE (ODBC Doc) */ value = SQL_TRUE; break; case SQL_COLUMN_UPDATABLE: /* == SQL_DESC_UPDATABLE */ /* * Neither Access or Borland care about this. * * if (field_type == PG_TYPE_OID) pfDesc = SQL_ATTR_READONLY; * else */ if (!stmt_updatable) value = SQL_ATTR_READONLY; else value = fi ? (fi->updatable ? SQL_ATTR_WRITE : SQL_ATTR_READONLY) : (QR_get_attid(res, col_idx) > 0 ? SQL_ATTR_WRITE : SQL_ATTR_READONLY); if (SQL_ATTR_READONLY != value) { const char *name = fi ? SAFE_NAME(fi->column_name) : QR_get_fieldname(res, col_idx); if (stricmp(name, OID_NAME) == 0 || stricmp(name, "ctid") == 0 || stricmp(name, XMIN_NAME) == 0) value = SQL_ATTR_READONLY; else if (conn->ms_jet && fi && fi->auto_increment) value = SQL_ATTR_READONLY; } MYLOG(0, "%s: UPDATEABLE = " FORMAT_LEN "\n", func, value); break; case SQL_DESC_BASE_COLUMN_NAME: p = fi ? SAFE_NAME(fi->column_name) : QR_get_fieldname(res, col_idx); MYLOG(0, "BASE_COLUMN_NAME = '%s'\n", p); break; case SQL_DESC_BASE_TABLE_NAME: /* the same as TABLE_NAME ok ? */ p = ti ? SAFE_NAME(ti->table_name) : NULL_STRING; MYLOG(0, "BASE_TABLE_NAME = '%s'\n", p); break; case SQL_DESC_LENGTH: /* different from SQL_COLUMN_LENGTH */ value = (fi && column_size > 0) ? column_size : pgtype_desclength(stmt, field_type, col_idx, unknown_sizes); if (-1 == value) value = 0; MYLOG(0, "col %d, desc_length = " FORMAT_LEN "\n", col_idx, value); break; case SQL_DESC_OCTET_LENGTH: value = (USE_FI(fi, unknown_sizes) && fi->length > 0) ? fi->length : pgtype_attr_transfer_octet_length(conn, field_type, column_size, unknown_sizes); if (-1 == value) value = 0; MYLOG(0, "col %d, octet_length = " FORMAT_LEN "\n", col_idx, value); break; case SQL_DESC_PRECISION: /* different from SQL_COLUMN_PRECISION */ if (value = FI_precision(fi), value <= 0) value = pgtype_precision(stmt, field_type, col_idx, unknown_sizes); if (value < 0) value = 0; MYLOG(0, "col %d, desc_precision = " FORMAT_LEN "\n", col_idx, value); break; case SQL_DESC_SCALE: /* different from SQL_COLUMN_SCALE */ value = pgtype_scale(stmt, field_type, col_idx); if (value < 0) value = 0; break; case SQL_DESC_LOCAL_TYPE_NAME: p = pgtype_to_name(stmt, field_type, col_idx, fi && fi->auto_increment); break; case SQL_DESC_TYPE: value = pgtype_to_sqldesctype(stmt, field_type, col_idx, unknown_sizes); break; case SQL_DESC_NUM_PREC_RADIX: value = pgtype_radix(conn, field_type); break; case SQL_DESC_LITERAL_PREFIX: p = pgtype_literal_prefix(conn, field_type); break; case SQL_DESC_LITERAL_SUFFIX: p = pgtype_literal_suffix(conn, field_type); break; case SQL_DESC_UNNAMED: value = (fi && NAME_IS_NULL(fi->column_name) && NAME_IS_NULL(fi->column_alias)) ? SQL_UNNAMED : SQL_NAMED; break; case 1211: /* SQL_CA_SS_COLUMN_HIDDEN ? */ value = 0; break; case 1212: /* SQL_CA_SS_COLUMN_KEY ? */ if (fi) { if (fi->columnkey < 0) { SC_set_SS_columnkey(stmt); } value = fi->columnkey; MYLOG(0, "SS_COLUMN_KEY=" FORMAT_LEN "\n", value); break; } SC_set_error(stmt, STMT_OPTION_NOT_FOR_THE_DRIVER, "this request may be for MS SQL Server", func); return SQL_ERROR; default: SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "ColAttribute for this type not implemented yet", func); return SQL_ERROR; } result = SQL_SUCCESS; if (p) { /* char/binary data */ size_t len = strlen(p); if (rgbDesc) { strncpy_null((char *) rgbDesc, p, (size_t) cbDescMax); if (len >= cbDescMax) { result = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the rgbDesc.", func); } } if (pcbDesc) *pcbDesc = (SQLSMALLINT) len; } else { /* numeric data */ if (pfDesc) *pfDesc = value; } return result; } /* Returns result data for a single column in the current row. */ RETCODE SQL_API PGAPI_GetData(HSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, PTR rgbValue, SQLLEN cbValueMax, SQLLEN * pcbValue) { CSTR func = "PGAPI_GetData"; QResultClass *res; StatementClass *stmt = (StatementClass *) hstmt; UInt2 num_cols; SQLLEN num_rows; OID field_type; int atttypmod; void *value = NULL; RETCODE result = SQL_SUCCESS; char get_bookmark = FALSE; SQLSMALLINT target_type; int precision = -1; #ifdef WITH_UNIXODBC SQLCHAR dum_rgb[2] = "\0\0"; #endif /* WITH_UNIXODBC */ MYLOG(0, "entering stmt=%p icol=%d\n", stmt, icol); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } res = SC_get_Curres(stmt); if (STMT_EXECUTING == stmt->status) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Can't get data while statement is still executing.", func); return SQL_ERROR; } if (stmt->status != STMT_FINISHED) { SC_set_error(stmt, STMT_STATUS_ERROR, "GetData can only be called after the successful execution on a SQL statement", func); return SQL_ERROR; } #ifdef WITH_UNIXODBC if (NULL == rgbValue) /* unixODBC allows rgbValue is NULL? */ { cbValueMax = 0; rgbValue = dum_rgb; /* to avoid a crash */ } #endif /* WITH_UNIXODBC */ if (SQL_ARD_TYPE == fCType) { ARDFields *opts; BindInfoClass *binfo = NULL; opts = SC_get_ARDF(stmt); if (0 == icol) binfo = opts->bookmark; else if (icol <= opts->allocated && opts->bindings) binfo = &opts->bindings[icol - 1]; if (binfo) { target_type = binfo->returntype; MYLOG(0, "SQL_ARD_TYPE=%d\n", target_type); precision = binfo->precision; } else { SC_set_error(stmt, STMT_STATUS_ERROR, "GetData can't determine the type via ARD", func); return SQL_ERROR; } } else target_type = fCType; if (icol == 0) { if (stmt->options.use_bookmarks == SQL_UB_OFF) { SC_set_error(stmt, STMT_COLNUM_ERROR, "Attempt to retrieve bookmark with bookmark usage disabled", func); return SQL_ERROR; } /* Make sure it is the bookmark data type */ switch (target_type) { case SQL_C_BOOKMARK: case SQL_C_VARBOOKMARK: break; default: MYLOG(DETAIL_LOG_LEVEL, "GetData Column 0 is type %d not of type SQL_C_BOOKMARK\n", target_type); SC_set_error(stmt, STMT_PROGRAM_TYPE_OUT_OF_RANGE, "Column 0 is not of type SQL_C_BOOKMARK", func); return SQL_ERROR; } get_bookmark = TRUE; } else { /* use zero-based column numbers */ icol--; /* make sure the column number is valid */ num_cols = QR_NumPublicResultCols(res); if (icol >= num_cols) { SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number.", func); return SQL_ERROR; } } #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(stmt); */ if (!SC_is_fetchcursor(stmt)) { /* make sure we're positioned on a valid row */ num_rows = QR_get_num_total_tuples(res); if ((stmt->currTuple < 0) || (stmt->currTuple >= num_rows)) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row for GetData.", func); result = SQL_ERROR; goto cleanup; } MYLOG(0, " num_rows = " FORMAT_LEN "\n", num_rows); if (!get_bookmark) { SQLLEN curt = GIdx2CacheIdx(stmt->currTuple, stmt, res); value = QR_get_value_backend_row(res, curt, icol); MYLOG(DETAIL_LOG_LEVEL, "currT=" FORMAT_LEN " base=" FORMAT_LEN " rowset=" FORMAT_LEN "\n", stmt->currTuple, QR_get_rowstart_in_cache(res), SC_get_rowset_start(stmt)); MYLOG(0, " value = '%s'\n", NULL_IF_NULL(value)); } } else { /* it's a SOCKET result (backend data) */ if (stmt->currTuple == -1 || !res || !res->tupleField) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row for GetData.", func); result = SQL_ERROR; goto cleanup; } if (!get_bookmark) { /** value = QR_get_value_backend(res, icol); maybe thiw doesn't work */ SQLLEN curt = GIdx2CacheIdx(stmt->currTuple, stmt, res); value = QR_get_value_backend_row(res, curt, icol); } MYLOG(0, " socket: value = '%s'\n", NULL_IF_NULL(value)); } if (get_bookmark) { BOOL contents_get = FALSE; if (rgbValue) { if (SQL_C_BOOKMARK == target_type || sizeof(UInt4) <= cbValueMax) { Int4 bookmark = SC_make_int4_bookmark(stmt->currTuple); contents_get = TRUE; memcpy(rgbValue, &bookmark, sizeof(bookmark)); } } if (pcbValue) *pcbValue = sizeof(Int4); if (contents_get) result = SQL_SUCCESS; else { SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the GetData.", func); result = SQL_SUCCESS_WITH_INFO; } goto cleanup; } field_type = QR_get_field_type(res, icol); atttypmod = QR_get_atttypmod(res, icol); MYLOG(0, "**** icol = %d, target_type = %d, field_type = %d, value = '%s'\n", icol, target_type, field_type, NULL_IF_NULL(value)); SC_set_current_col(stmt, icol); result = copy_and_convert_field(stmt, field_type, atttypmod, value, target_type, precision, rgbValue, cbValueMax, pcbValue, pcbValue); switch (result) { case COPY_OK: result = SQL_SUCCESS; break; case COPY_UNSUPPORTED_TYPE: SC_set_error(stmt, STMT_RESTRICTED_DATA_TYPE_ERROR, "Received an unsupported type from Postgres.", func); result = SQL_ERROR; break; case COPY_UNSUPPORTED_CONVERSION: SC_set_error(stmt, STMT_RESTRICTED_DATA_TYPE_ERROR, "Couldn't handle the necessary data type conversion.", func); result = SQL_ERROR; break; case COPY_RESULT_TRUNCATED: SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the GetData.", func); result = SQL_SUCCESS_WITH_INFO; break; case COPY_INVALID_STRING_CONVERSION: /* invalid string */ SC_set_error(stmt, STMT_STRING_CONVERSION_ERROR, "invalid string conversion occurred.", func); result = SQL_ERROR; break; case COPY_GENERAL_ERROR: /* error msg already filled in */ result = SQL_ERROR; break; case COPY_NO_DATA_FOUND: /* SC_log_error(func, "no data found", stmt); */ result = SQL_NO_DATA_FOUND; break; default: SC_set_error(stmt, STMT_INTERNAL_ERROR, "Unrecognized return value from copy_and_convert_field.", func); result = SQL_ERROR; break; } cleanup: #undef return MYLOG(DETAIL_LOG_LEVEL, "leaving %d\n", result); return result; } /* * Returns data for bound columns in the current row ("hstmt->iCursor"), * advances the cursor. */ RETCODE SQL_API PGAPI_Fetch(HSTMT hstmt) { CSTR func = "PGAPI_Fetch"; StatementClass *stmt = (StatementClass *) hstmt; ARDFields *opts; QResultClass *res; BindInfoClass *bookmark; RETCODE retval = SQL_SUCCESS; MYLOG(0, "entering stmt = %p, stmt->result= %p\n", stmt, stmt ? SC_get_Curres(stmt) : NULL); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } SC_clear_error(stmt); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in PGAPI_Fetch.", func); return SQL_ERROR; } /* Not allowed to bind a bookmark column when using SQLFetch. */ opts = SC_get_ARDF(stmt); if ((bookmark = opts->bookmark) && bookmark->buffer) { SC_set_error(stmt, STMT_COLNUM_ERROR, "Not allowed to bind a bookmark column when using PGAPI_Fetch", func); return SQL_ERROR; } if (stmt->status == STMT_EXECUTING) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Can't fetch while statement is still executing.", func); return SQL_ERROR; } if (stmt->status != STMT_FINISHED) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Fetch can only be called after the successful execution on a SQL statement", func); return SQL_ERROR; } if (opts->bindings == NULL) { if (!SC_may_fetch_rows(stmt)) return SQL_NO_DATA_FOUND; /* just to avoid a crash if the user insists on calling this */ /* function even if SQL_ExecDirect has reported an Error */ SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Bindings were not allocated properly.", func); return SQL_ERROR; } #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(stmt); */ if (stmt->rowset_start < 0) SC_set_rowset_start(stmt, 0, TRUE); QR_set_reqsize(res, 1); /* QR_inc_rowstart_in_cache(res, stmt->last_fetch_count_include_ommitted); */ SC_inc_rowset_start(stmt, stmt->last_fetch_count_include_ommitted); retval = SC_fetch(stmt); #undef return return retval; } static RETCODE SQL_API SC_pos_reload_needed(StatementClass *stmt, SQLULEN req_size, UDWORD flag); SQLLEN getNthValid(const QResultClass *res, SQLLEN sta, UWORD orientation, SQLULEN nth, SQLLEN *nearest) { SQLLEN i, num_tuples = QR_get_num_total_tuples(res), nearp; SQLULEN count; KeySet *keyset; if (!QR_once_reached_eof(res)) num_tuples = INT_MAX; /* Note that the parameter nth is 1-based */ MYLOG(DETAIL_LOG_LEVEL, "get " FORMAT_ULEN "th Valid data from " FORMAT_LEN " to %s [dlt=%d]", nth, sta, orientation == SQL_FETCH_PRIOR ? "backward" : "forward", res->dl_count); if (0 == res->dl_count) { MYPRINTF(DETAIL_LOG_LEVEL, "\n"); if (SQL_FETCH_PRIOR == orientation) { if (sta + 1 >= (SQLLEN) nth) { *nearest = sta + 1 - nth; return nth; } *nearest = -1; return -(SQLLEN)(sta + 1); } else { nearp = sta - 1 + nth; if (nearp < num_tuples) { *nearest = nearp; return nth; } *nearest = num_tuples; return -(SQLLEN)(num_tuples - sta); } } count = 0; if (QR_get_cursor(res)) { SQLLEN *deleted = res->deleted; SQLLEN delsta; if (SQL_FETCH_PRIOR == orientation) { *nearest = sta + 1 - nth; delsta = (-1); MYPRINTF(DETAIL_LOG_LEVEL, "deleted "); for (i = res->dl_count - 1; i >=0 && *nearest <= deleted[i]; i--) { MYPRINTF(DETAIL_LOG_LEVEL, "[" FORMAT_LEN "]=" FORMAT_LEN " ", i, deleted[i]); if (sta >= deleted[i]) { (*nearest)--; if (i > delsta) delsta = i; } } MYPRINTF(DETAIL_LOG_LEVEL, "nearest=" FORMAT_LEN "\n", *nearest); if (*nearest < 0) { *nearest = -1; count = sta - delsta; } else return nth; } else { MYPRINTF(DETAIL_LOG_LEVEL, "\n"); *nearest = sta - 1 + nth; delsta = res->dl_count; if (!QR_once_reached_eof(res)) num_tuples = INT_MAX; for (i = 0; i < res->dl_count && *nearest >= deleted[i]; i++) { if (sta <= deleted[i]) { (*nearest)++; if (i < delsta) delsta = i; } } if (*nearest >= num_tuples) { *nearest = num_tuples; count = *nearest - sta + delsta - res->dl_count; } else return nth; } } else if (SQL_FETCH_PRIOR == orientation) { for (i = sta, keyset = res->keyset + sta; i >= 0; i--, keyset--) { if (0 == (keyset->status & (CURS_SELF_DELETING | CURS_SELF_DELETED | CURS_OTHER_DELETED))) { *nearest = i; MYPRINTF(DETAIL_LOG_LEVEL, " nearest=" FORMAT_LEN "\n", *nearest); if (++count == nth) return count; } } *nearest = -1; } else { for (i = sta, keyset = res->keyset + sta; i < num_tuples; i++, keyset++) { if (0 == (keyset->status & (CURS_SELF_DELETING | CURS_SELF_DELETED | CURS_OTHER_DELETED))) { *nearest = i; MYPRINTF(DETAIL_LOG_LEVEL, " nearest=" FORMAT_LEN "\n", *nearest); if (++count == nth) return count; } } *nearest = num_tuples; } MYPRINTF(DETAIL_LOG_LEVEL, " nearest not found\n"); return -(SQLLEN)count; } static void move_cursor_position_if_needed(StatementClass *self, QResultClass *res) { SQLLEN move_offset; /* * The move direction must be initialized to is_not_moving or * is_moving_from_the_last in advance. */ if (!QR_get_cursor(res)) { QR_stop_movement(res); /* for safety */ res->move_offset = 0; return; } MYLOG(DETAIL_LOG_LEVEL, "BASE=" FORMAT_LEN " numb=" FORMAT_LEN " curr=" FORMAT_LEN " cursT=" FORMAT_LEN "\n", QR_get_rowstart_in_cache(res), res->num_cached_rows, self->currTuple, res->cursTuple); /* normal case */ res->move_offset = 0; move_offset = self->currTuple - res->cursTuple; if (QR_get_rowstart_in_cache(res) >= 0 && QR_get_rowstart_in_cache(res) <= res->num_cached_rows) { QR_set_next_in_cache(res, (QR_get_rowstart_in_cache(res) < 0) ? 0 : QR_get_rowstart_in_cache(res)); return; } if (0 == move_offset) return; if (move_offset > 0) { QR_set_move_forward(res); res->move_offset = move_offset; } else { QR_set_move_backward(res); res->move_offset = -move_offset; } } /* * return NO_DATA_FOUND macros * save_rowset_start or num_tuples must be defined */ #define EXTFETCH_RETURN_BOF(stmt, res) \ { \ MYLOG(DETAIL_LOG_LEVEL, "RETURN_BOF\n"); \ SC_set_rowset_start(stmt, -1, TRUE); \ stmt->currTuple = -1; \ /* move_cursor_position_if_needed(stmt, res); */ \ return SQL_NO_DATA_FOUND; \ } #define EXTFETCH_RETURN_EOF(stmt, res) \ { \ MYLOG(DETAIL_LOG_LEVEL, "RETURN_EOF\n"); \ SC_set_rowset_start(stmt, num_tuples, TRUE); \ stmt->currTuple = -1; \ /* move_cursor_position_if_needed(stmt, res); */ \ return SQL_NO_DATA_FOUND; \ } /* This fetches a block of data (rowset). */ RETCODE SQL_API PGAPI_ExtendedFetch(HSTMT hstmt, SQLUSMALLINT fFetchType, SQLLEN irow, SQLULEN * pcrow, SQLUSMALLINT * rgfRowStatus, SQLLEN bookmark_offset, SQLLEN rowsetSize) { CSTR func = "PGAPI_ExtendedFetch"; StatementClass *stmt = (StatementClass *) hstmt; ARDFields *opts; QResultClass *res; BindInfoClass *bookmark; SQLLEN num_tuples, i, fc_io; SQLLEN save_rowset_size, progress_size; SQLLEN rowset_start, rowset_end = (-1); RETCODE result = SQL_SUCCESS; char truncated, error, should_set_rowset_start = FALSE; SQLLEN currp; UWORD pstatus; BOOL currp_is_valid, reached_eof, useCursor; SQLLEN reqsize = rowsetSize; MYLOG(0, "entering stmt=%p rowsetSize=" FORMAT_LEN "\n", stmt, rowsetSize); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } /* if (SC_is_fetchcursor(stmt) && !stmt->manual_result) */ if (SQL_CURSOR_FORWARD_ONLY == stmt->options.cursor_type) { if (fFetchType != SQL_FETCH_NEXT) { SC_set_error(stmt, STMT_FETCH_OUT_OF_RANGE, "The fetch type for PGAPI_ExtendedFetch isn't allowed with ForwardOnly cursor.", func); return SQL_ERROR; } } SC_clear_error(stmt); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in PGAPI_ExtendedFetch.", func); return SQL_ERROR; } opts = SC_get_ARDF(stmt); /* * If a bookmark colunmn is bound but bookmark usage is off, then * error */ if ((bookmark = opts->bookmark) && bookmark->buffer && stmt->options.use_bookmarks == SQL_UB_OFF) { SC_set_error(stmt, STMT_COLNUM_ERROR, "Attempt to retrieve bookmark with bookmark usage disabled", func); return SQL_ERROR; } if (stmt->status == STMT_EXECUTING) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Can't fetch while statement is still executing.", func); return SQL_ERROR; } if (stmt->status != STMT_FINISHED) { SC_set_error(stmt, STMT_STATUS_ERROR, "ExtendedFetch can only be called after the successful execution on a SQL statement", func); return SQL_ERROR; } if (opts->bindings == NULL) { if (!SC_may_fetch_rows(stmt)) return SQL_NO_DATA_FOUND; /* just to avoid a crash if the user insists on calling this */ /* function even if SQL_ExecDirect has reported an Error */ SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Bindings were not allocated properly.", func); return SQL_ERROR; } /* Initialize to no rows fetched */ if (rgfRowStatus) for (i = 0; i < rowsetSize; i++) *(rgfRowStatus + i) = SQL_ROW_NOROW; if (pcrow) *pcrow = 0; useCursor = (SC_is_fetchcursor(stmt) && NULL != QR_get_cursor(res)); num_tuples = QR_get_num_total_tuples(res); reached_eof = QR_once_reached_eof(res) && QR_get_cursor(res); if (useCursor && !reached_eof) num_tuples = INT_MAX; MYLOG(DETAIL_LOG_LEVEL, "num_tuples=" FORMAT_LEN "\n", num_tuples); /* Save and discard the saved rowset size */ save_rowset_size = stmt->save_rowset_size; stmt->save_rowset_size = -1; rowset_start = SC_get_rowset_start(stmt); QR_stop_movement(res); res->move_offset = 0; switch (fFetchType) { int min_nth; SQLLEN bidx; case SQL_FETCH_NEXT: /* * From the odbc spec... If positioned before the start of the * RESULT SET, then this should be equivalent to * SQL_FETCH_FIRST. */ progress_size = (save_rowset_size > 0 ? save_rowset_size : rowsetSize); if (rowset_start < 0) SC_set_rowset_start(stmt, 0, TRUE); else if (res->keyset) { if (stmt->last_fetch_count <= progress_size) { SC_inc_rowset_start(stmt, stmt->last_fetch_count_include_ommitted); progress_size -= stmt->last_fetch_count; } if (progress_size > 0) { if (getNthValid(res, SC_get_rowset_start(stmt), SQL_FETCH_NEXT, progress_size + 1, &rowset_start) <= 0) { EXTFETCH_RETURN_EOF(stmt, res) } else should_set_rowset_start =TRUE; } } else SC_inc_rowset_start(stmt, progress_size); MYLOG(0, "SQL_FETCH_NEXT: num_tuples=" FORMAT_LEN ", currtuple=" FORMAT_LEN ", rowst=" FORMAT_LEN "\n", num_tuples, stmt->currTuple, rowset_start); break; case SQL_FETCH_PRIOR: MYLOG(0, "SQL_FETCH_PRIOR: num_tuples=" FORMAT_LEN ", currtuple=" FORMAT_LEN "\n", num_tuples, stmt->currTuple); /* * From the odbc spec... If positioned after the end of the * RESULT SET, then this should be equivalent to * SQL_FETCH_LAST. */ if (rowset_start <= 0) { EXTFETCH_RETURN_BOF(stmt, res) } if (rowset_start >= num_tuples && rowsetSize > num_tuples) { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch prior from eof and before the beginning", func); SC_set_rowset_start(stmt, 0, TRUE); } else if (QR_haskeyset(res)) { rowset_end = rowset_start - 1; if (min_nth = getNthValid(res, rowset_end, SQL_FETCH_PRIOR, rowsetSize, &rowset_start), min_nth <= 0) { if (min_nth == 0) { EXTFETCH_RETURN_BOF(stmt, res) } else { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch prior and before the beginning", func); rowset_end = (-1); SC_set_rowset_start(stmt, 0, TRUE); } } else { should_set_rowset_start = TRUE; reqsize = rowset_end - rowset_start + 1; } } else if (rowset_start < rowsetSize) { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch prior from eof and before the beginning", func); SC_set_rowset_start(stmt, 0, TRUE); } else SC_inc_rowset_start(stmt, -rowsetSize); break; case SQL_FETCH_FIRST: MYLOG(0, "SQL_FETCH_FIRST: num_tuples=" FORMAT_LEN ", currtuple=" FORMAT_LEN "\n", num_tuples, stmt->currTuple); SC_set_rowset_start(stmt, 0, TRUE); break; case SQL_FETCH_LAST: MYLOG(0, "SQL_FETCH_LAST: num_tuples=" FORMAT_LEN ", currtuple=" FORMAT_LEN "\n", num_tuples, stmt->currTuple); if (!reached_eof) { QR_move_cursor_to_last(res, stmt); num_tuples = QR_get_num_total_tuples(res); } rowset_end = num_tuples - 1; if (min_nth = getNthValid(res, rowset_end, SQL_FETCH_PRIOR, rowsetSize, &rowset_start), min_nth <= 0) { if (min_nth == 0) { EXTFETCH_RETURN_BOF(stmt, res) } else { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch last and before the beginning", func); rowset_end = (-1); SC_set_rowset_start(stmt, 0, TRUE); } } else { should_set_rowset_start = TRUE; reqsize = rowset_end - rowset_start + 1; } break; case SQL_FETCH_ABSOLUTE: MYLOG(0, "SQL_FETCH_ABSOLUTE: num_tuples=" FORMAT_LEN ", currtuple=" FORMAT_LEN ", irow=" FORMAT_LEN "\n", num_tuples, stmt->currTuple, irow); /* Position before result set, but dont fetch anything */ if (irow == 0) { EXTFETCH_RETURN_BOF(stmt, res) } /* Position before the desired row */ else if (irow > 0) { if (getNthValid(res, 0, SQL_FETCH_NEXT, irow, &rowset_start) <= 0) { EXTFETCH_RETURN_EOF(stmt, res) } else should_set_rowset_start = TRUE; } /* Position with respect to the end of the result set */ else { if (!reached_eof) { QR_move_cursor_to_last(res, stmt); num_tuples = QR_get_num_total_tuples(res); } if (min_nth = getNthValid(res, num_tuples - 1, SQL_FETCH_PRIOR, -irow, &rowset_start), min_nth <= 0) { if (min_nth == 0) { EXTFETCH_RETURN_BOF(stmt, res) } else { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch absolute and before the beginning", func); rowset_end = (-1); SC_set_rowset_start(stmt, 0, TRUE); } } else should_set_rowset_start = TRUE; } break; case SQL_FETCH_RELATIVE: /* * Refresh the current rowset -- not currently implemented, * but lie anyway */ if (irow == 0) break; if (irow > 0) { if (getNthValid(res, SC_get_rowset_start(stmt) + 1, SQL_FETCH_NEXT, irow, &rowset_start) <= 0) { EXTFETCH_RETURN_EOF(stmt, res) } else should_set_rowset_start = TRUE; } else { if (min_nth = getNthValid(res, SC_get_rowset_start(stmt) - 1, SQL_FETCH_PRIOR, -irow, &rowset_start), min_nth <= 0) { if (min_nth == 0) EXTFETCH_RETURN_BOF(stmt, res) else { SC_set_error(stmt, STMT_POS_BEFORE_RECORDSET, "fetch relative and before the beginning", func); rowset_end = (-1); SC_set_rowset_start(stmt, 0, TRUE); } } else should_set_rowset_start = TRUE; } break; case SQL_FETCH_BOOKMARK: bidx = SC_resolve_int4_bookmark(irow); if (bidx < 0) { if (!reached_eof) { QR_move_cursor_to_last(res, stmt); num_tuples = QR_get_num_total_tuples(res); } bidx = num_tuples - 1 - res->ad_count - bidx; } rowset_start = bidx; if (bookmark_offset >= 0) { if (getNthValid(res, bidx, SQL_FETCH_NEXT, bookmark_offset + 1, &rowset_start) <= 0) { EXTFETCH_RETURN_EOF(stmt, res) } else should_set_rowset_start = TRUE; } else if (getNthValid(res, bidx, SQL_FETCH_PRIOR, 1 - bookmark_offset, &rowset_start) <= 0) { stmt->currTuple = -1; EXTFETCH_RETURN_BOF(stmt, res) } else should_set_rowset_start = TRUE; break; default: SC_set_error(stmt, STMT_FETCH_OUT_OF_RANGE, "Unsupported PGAPI_ExtendedFetch Direction", func); return SQL_ERROR; } /* * CHECK FOR PROPER CURSOR STATE */ /* * Handle Declare Fetch style specially because the end is not really * the end... */ if (!should_set_rowset_start) rowset_start = SC_get_rowset_start(stmt); if (useCursor) { if (reached_eof && rowset_start >= num_tuples) { EXTFETCH_RETURN_EOF(stmt, res) } } else { /* If *new* rowset is after the result_set, return no data found */ if (rowset_start >= num_tuples) { EXTFETCH_RETURN_EOF(stmt, res) } } /* If *new* rowset is prior to result_set, return no data found */ if (rowset_start < 0) { if (rowset_start + rowsetSize <= 0) { EXTFETCH_RETURN_BOF(stmt, res) } else { /* overlap with beginning of result set, * so get first rowset */ SC_set_rowset_start(stmt, 0, TRUE); } should_set_rowset_start = FALSE; } #define return DONT_CALL_RETURN_FROM_HERE??? /* set the rowset_start if needed */ if (should_set_rowset_start) SC_set_rowset_start(stmt, rowset_start, TRUE); if (rowset_end < 0 && QR_haskeyset(res)) { getNthValid(res, rowset_start, SQL_FETCH_NEXT, rowsetSize, &rowset_end); reqsize = rowset_end - rowset_start + 1; } QR_set_reqsize(res, (Int4) reqsize); /* currTuple is always 1 row prior to the rowset start */ stmt->currTuple = RowIdx2GIdx(-1, stmt); if (SC_is_fetchcursor(stmt) || SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type) { move_cursor_position_if_needed(stmt, res); } else QR_set_rowstart_in_cache(res, SC_get_rowset_start(stmt)); if (res->keyset && !QR_get_cursor(res)) { UDWORD flag = 0; if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type) { if (fFetchType != SQL_FETCH_NEXT || QR_get_rowstart_in_cache(res) + reqsize > QR_get_num_cached_tuples(res)) { flag = 1; } } if (SQL_RD_ON == stmt->options.retrieve_data || flag != 0) { RETCODE ret = SC_pos_reload_needed(stmt, reqsize, flag); if (!SQL_SUCCEEDED(ret)) { result = ret; goto cleanup; } } } /* Physical Row advancement occurs for each row fetched below */ MYLOG(0, "new currTuple = " FORMAT_LEN "\n", stmt->currTuple); truncated = error = FALSE; currp = -1; stmt->bind_row = 0; /* set the binding location */ result = SC_fetch(stmt); if (SQL_ERROR == result) goto cleanup; if (SQL_NO_DATA_FOUND != result && res->keyset) { currp = GIdx2KResIdx(SC_get_rowset_start(stmt), stmt, res); MYLOG(DETAIL_LOG_LEVEL, "currp=" FORMAT_LEN "\n", currp); if (currp < 0) { result = SQL_ERROR; MYLOG(0, "rowset_start=" FORMAT_LEN " but currp=" FORMAT_LEN "\n", SC_get_rowset_start(stmt), currp); SC_set_error(stmt, STMT_INTERNAL_ERROR, "rowset_start not in the keyset", func); goto cleanup; } } for (i = 0, fc_io = 0; SQL_NO_DATA_FOUND != result && SQL_ERROR != result; currp++) { fc_io++; currp_is_valid = FALSE; if (res->keyset) { if (currp < res->num_cached_keys) { currp_is_valid = TRUE; res->keyset[currp].status &= ~CURS_IN_ROWSET; /* Off the flag first */ } else { MYLOG(0, "Umm current row is out of keyset\n"); break; } } MYLOG(DETAIL_LOG_LEVEL, "ExtFetch result=%d\n", result); if (currp_is_valid && SQL_SUCCESS_WITH_INFO == result && 0 == stmt->last_fetch_count) { MYLOG(DETAIL_LOG_LEVEL, "just skipping deleted row " FORMAT_LEN "\n", currp); if (rowsetSize - i + fc_io > reqsize) QR_set_reqsize(res, (Int4) (rowsetSize - i + fc_io)); result = SC_fetch(stmt); if (SQL_ERROR == result) break; continue; } /* Determine Function status */ if (result == SQL_SUCCESS_WITH_INFO) truncated = TRUE; else if (result == SQL_ERROR) error = TRUE; /* Determine Row Status */ if (rgfRowStatus) { if (result == SQL_ERROR) *(rgfRowStatus + i) = SQL_ROW_ERROR; else if (currp_is_valid) { pstatus = (res->keyset[currp].status & KEYSET_INFO_PUBLIC); if (pstatus != 0 && pstatus != SQL_ROW_ADDED) { rgfRowStatus[i] = pstatus; } else rgfRowStatus[i] = SQL_ROW_SUCCESS; /* refresh the status */ /* if (SQL_ROW_DELETED != pstatus) */ res->keyset[currp].status &= (~KEYSET_INFO_PUBLIC); } else *(rgfRowStatus + i) = SQL_ROW_SUCCESS; } if (SQL_ERROR != result && currp_is_valid) res->keyset[currp].status |= CURS_IN_ROWSET; /* This is the unique place where the CURS_IN_ROWSET bit is turned on */ i++; if (i >= rowsetSize) break; stmt->bind_row = (SQLSETPOSIROW) i; /* set the binding location */ result = SC_fetch(stmt); } if (SQL_ERROR == result) goto cleanup; /* Save the fetch count for SQLSetPos */ stmt->last_fetch_count = i; stmt->save_rowset_size = rowsetSize; /* currp = KResIdx2GIdx(currp, stmt, res); stmt->last_fetch_count_include_ommitted = GIdx2RowIdx(currp, stmt); */ stmt->last_fetch_count_include_ommitted = fc_io; /* Reset next binding row */ stmt->bind_row = 0; /* Move the cursor position to the first row in the result set. */ stmt->currTuple = RowIdx2GIdx(0, stmt); /* For declare/fetch, need to reset cursor to beginning of rowset */ if (useCursor) QR_set_position(res, 0); /* Set the number of rows retrieved */ if (pcrow) *pcrow = i; MYLOG(DETAIL_LOG_LEVEL, "pcrow=" FORMAT_LEN "\n", i); if (i == 0) /* Only DeclareFetch should wind up here */ result = SQL_NO_DATA_FOUND; else if (error) result = SQL_ERROR; else if (truncated) result = SQL_SUCCESS_WITH_INFO; else if (SC_get_errornumber(stmt) == STMT_POS_BEFORE_RECORDSET) result = SQL_SUCCESS_WITH_INFO; else result = SQL_SUCCESS; cleanup: #undef return return result; } /* * This determines whether there are more results sets available for * the "hstmt". */ /* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */ RETCODE SQL_API PGAPI_MoreResults(HSTMT hstmt) { StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; RETCODE ret = SQL_SUCCESS; MYLOG(0, "entering...\n"); res = SC_get_Curres(stmt); if (res) { res = QR_nextr(res); SC_set_Curres(stmt, res); } if (res) { SQLSMALLINT num_p; int errnum = 0, curerr; if (stmt->multi_statement < 0) PGAPI_NumParams(stmt, &num_p); if (stmt->multi_statement > 0) { const char *cmdstr; SC_initialize_cols_info(stmt, FALSE, TRUE); stmt->statement_type = STMT_TYPE_UNKNOWN; if (cmdstr = QR_get_command(res), NULL != cmdstr) stmt->statement_type = statement_type(cmdstr); stmt->join_info = 0; SC_clear_parse_method(stmt); } stmt->diag_row_count = res->recent_processed_row_count; SC_set_rowset_start(stmt, -1, FALSE); stmt->currTuple = -1; if (!QR_command_maybe_successful(res)) { ret = SQL_ERROR; errnum = STMT_EXEC_ERROR; } else if (NULL != QR_get_notice(res)) { ret = SQL_SUCCESS_WITH_INFO; errnum = STMT_INFO_ONLY; } if (0 != errnum) { curerr = SC_get_errornumber(stmt); if (0 == curerr || (0 > curerr && errnum > 0)) SC_set_errornumber(stmt, errnum); } } else { PGAPI_FreeStmt(hstmt, SQL_CLOSE); ret = SQL_NO_DATA_FOUND; } MYLOG(0, "leaving %d\n", ret); return ret; } /* * Stuff for updatable cursors. */ static Int2 getNumResultCols(const QResultClass *res) { Int2 res_cols = QR_NumPublicResultCols(res); return res_cols; } static OID getOid(const QResultClass *res, SQLLEN index) { return res->keyset[index].oid; } static void getTid(const QResultClass *res, SQLLEN index, UInt4 *blocknum, UInt2 *offset) { *blocknum = res->keyset[index].blocknum; *offset = res->keyset[index].offset; } static void KeySetSet(const TupleField *tuple, int num_fields, int num_key_fields, KeySet *keyset, BOOL statusInit) { if (statusInit) keyset->status = 0; sscanf(tuple[num_fields - num_key_fields].value, "(%u,%hu)", &keyset->blocknum, &keyset->offset); if (num_key_fields > 1) { const char *oval = tuple[num_fields - 1].value; if ('-' == oval[0]) sscanf(oval, "%d", &keyset->oid); else sscanf(oval, "%u", &keyset->oid); } else keyset->oid = 0; } static void AddRollback(StatementClass *stmt, QResultClass *res, SQLLEN index, const KeySet *keyset, Int4 dmlcode) { ConnectionClass *conn = SC_get_conn(stmt); Rollback *rollback; if (!CC_is_in_trans(conn)) return; MYLOG(DETAIL_LOG_LEVEL, "entering " FORMAT_LEN "(%u,%u) %s\n", index, keyset->blocknum, keyset->offset, dmlcode == SQL_ADD ? "ADD" : (dmlcode == SQL_UPDATE ? "UPDATE" : (dmlcode == SQL_DELETE ? "DELETE" : "REFRESH"))); if (!res->rollback) { res->rb_count = 0; res->rb_alloc = 10; rollback = res->rollback = malloc(sizeof(Rollback) * res->rb_alloc); if (!rollback) { res->rb_alloc = res->rb_count = 0; return; } } else { if (res->rb_count >= res->rb_alloc) { res->rb_alloc *= 2; if (rollback = realloc(res->rollback, sizeof(Rollback) * res->rb_alloc), !rollback) { res->rb_alloc = res->rb_count = 0; return; } res->rollback = rollback; } rollback = res->rollback + res->rb_count; } rollback->index = index; rollback->option = dmlcode; rollback->offset = 0; rollback->blocknum = 0; rollback->oid = 0; if (keyset) { rollback->blocknum = keyset->blocknum; rollback->offset = keyset->offset; rollback->oid = keyset->oid; } conn->result_uncommitted = 1; res->rb_count++; } SQLLEN ClearCachedRows(TupleField *tuple, int num_fields, SQLLEN num_rows) { SQLLEN i; for (i = 0; i < num_fields * num_rows; i++, tuple++) { if (tuple->value) { MYLOG(DETAIL_LOG_LEVEL, "freeing tuple[" FORMAT_LEN "][" FORMAT_LEN "].value=%p\n", i / num_fields, i % num_fields, tuple->value); free(tuple->value); tuple->value = NULL; } tuple->len = -1; } return i; } SQLLEN ReplaceCachedRows(TupleField *otuple, const TupleField *ituple, int num_fields, SQLLEN num_rows) { SQLLEN i; MYLOG(DETAIL_LOG_LEVEL, "entering %p num_fields=%d num_rows=" FORMAT_LEN "\n", otuple, num_fields, num_rows); for (i = 0; i < num_fields * num_rows; i++, ituple++, otuple++) { if (otuple->value) { free(otuple->value); otuple->value = NULL; } if (ituple->value) { otuple->value = strdup(ituple->value); MYLOG(DETAIL_LOG_LEVEL, "[" FORMAT_LEN "," FORMAT_LEN "] %s copied\n", i / num_fields, i % num_fields, (const char *) otuple->value); } if (otuple->value) otuple->len = ituple->len; else otuple->len = -1; } return i; } static int MoveCachedRows(TupleField *otuple, TupleField *ituple, Int2 num_fields, SQLLEN num_rows) { int i; MYLOG(DETAIL_LOG_LEVEL, "entering %p num_fields=%d num_rows=" FORMAT_LEN "\n", otuple, num_fields, num_rows); for (i = 0; i < num_fields * num_rows; i++, ituple++, otuple++) { if (otuple->value) { free(otuple->value); otuple->value = NULL; } if (ituple->value) { otuple->value = ituple->value; ituple->value = NULL; MYLOG(DETAIL_LOG_LEVEL, "[%d,%d] %s copied\n", i / num_fields, i % num_fields, (const char *) otuple->value); } otuple->len = ituple->len; ituple->len = -1; } return i; } static const char * ti_quote(StatementClass *stmt, OID tableoid, char *buf, int buf_size) { TABLE_INFO *ti = stmt->ti[0]; pgNAME rNAME; if (0 == tableoid || !TI_has_subclass(ti)) return quote_table(ti->schema_name, ti->table_name, buf, buf_size); else if (NAME_IS_VALID(rNAME = TI_From_IH(ti, tableoid))) return SAFE_NAME(rNAME); else { char query[200]; QResultClass *res; char *ret = ""; SPRINTF_FIXED(query, "select relname, nspname from pg_class c, pg_namespace n where c.oid=%u and c.relnamespace=n.oid", tableoid); res = CC_send_query(SC_get_conn(stmt), query, NULL, READ_ONLY_QUERY, stmt); if (QR_command_maybe_successful(res) && QR_get_num_cached_tuples(res) == 1) { pgNAME schema_name, table_name; SET_NAME_DIRECTLY(schema_name, QR_get_value_backend_text(res, 0, 1)); SET_NAME_DIRECTLY(table_name, QR_get_value_backend_text(res, 0, 0)); ret = quote_table(schema_name, table_name, buf, buf_size); TI_Ins_IH(ti, tableoid, ret); } QR_Destructor(res); return ret; } } static BOOL tupleExists(StatementClass *stmt, const KeySet *keyset) { PQExpBufferData selstr = {0}; const TABLE_INFO *ti = stmt->ti[0]; QResultClass *res; RETCODE ret = FALSE; const char *bestqual = GET_NAME(ti->bestqual); char table_fqn[256]; initPQExpBuffer(&selstr); printfPQExpBuffer(&selstr, "select 1 from %s where ctid = '(%u,%u)'", ti_quote(stmt, keyset->oid, table_fqn, sizeof(table_fqn)), keyset->blocknum, keyset->offset); if (NULL != bestqual && 0 != keyset->oid && !TI_has_subclass(ti)) { appendPQExpBuffer(&selstr, " and "); appendPQExpBuffer(&selstr, bestqual, keyset->oid); } if (PQExpBufferDataBroken(selstr)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in tupleExists()", __FUNCTION__); goto cleanup; } res = CC_send_query(SC_get_conn(stmt), selstr.data, NULL, READ_ONLY_QUERY, NULL); if (QR_command_maybe_successful(res) && 1 == res->num_cached_rows) ret = TRUE; QR_Destructor(res); cleanup: if (!PQExpBufferDataBroken(selstr)) termPQExpBuffer(&selstr); return ret; } static BOOL enlargeAdded(QResultClass *res, UInt4 number, const StatementClass *stmt) { UInt4 alloc; int num_fields = res->num_fields; alloc = res->ad_alloc; if (0 == alloc) alloc = number > 10 ? number : 10; else while (alloc < number) { alloc *= 2; } if (alloc <= res->ad_alloc) return TRUE; QR_REALLOC_return_with_error(res->added_keyset, KeySet, sizeof(KeySet) * alloc, res, "enlargeAdded failed", FALSE); if (SQL_CURSOR_KEYSET_DRIVEN != stmt->options.cursor_type) QR_REALLOC_return_with_error(res->added_tuples, TupleField, sizeof(TupleField) * num_fields * alloc, res, "enlargeAdded failed 2", FALSE); res->ad_alloc = alloc; return TRUE; } static void AddAdded(StatementClass *stmt, QResultClass *res, SQLLEN index, const TupleField *tuple_added) { KeySet *added_keyset, *keyset, keys; TupleField *added_tuples = NULL, *tuple; UInt4 ad_count; Int2 num_fields; if (!res) return; num_fields = res->num_fields; MYLOG(DETAIL_LOG_LEVEL, "entering index=" FORMAT_LEN ", tuple=%p, num_fields=%d\n", index, tuple_added, num_fields); ad_count = res->ad_count; res->ad_count++; if (QR_get_cursor(res)) index = -(SQLLEN)res->ad_count; if (!tuple_added) return; KeySetSet(tuple_added, num_fields + res->num_key_fields, res->num_key_fields, &keys, TRUE); keys.status = SQL_ROW_ADDED; if (CC_is_in_trans(SC_get_conn(stmt))) keys.status |= CURS_SELF_ADDING; else keys.status |= CURS_SELF_ADDED; AddRollback(stmt, res, index, &keys, SQL_ADD); if (!QR_get_cursor(res)) return; if (ad_count > 0 && 0 == res->ad_alloc) return; if (!enlargeAdded(res, ad_count + 1, stmt)) return; added_keyset = res->added_keyset; added_tuples = res->added_tuples; keyset = added_keyset + ad_count; *keyset = keys; if (added_tuples) { tuple = added_tuples + num_fields * ad_count; memset(tuple, 0, sizeof(TupleField) * num_fields); ReplaceCachedRows(tuple, tuple_added, num_fields, 1); } } static void RemoveAdded(QResultClass *, SQLLEN); static void RemoveUpdated(QResultClass *, SQLLEN); static void RemoveUpdatedAfterTheKey(QResultClass *, SQLLEN, const KeySet*); static void RemoveDeleted(QResultClass *, SQLLEN); static void RemoveAdded(QResultClass *res, SQLLEN index) { SQLLEN rmidx, mv_count; Int2 num_fields = res->num_fields; KeySet *added_keyset; TupleField *added_tuples; MYLOG(0, "entering index=" FORMAT_LEN "\n", index); if (index < 0) rmidx = -index - 1; else rmidx = index - res->num_total_read; if (rmidx >= res->ad_count) return; added_keyset = res->added_keyset + rmidx; added_tuples = res->added_tuples + num_fields * rmidx; ClearCachedRows(added_tuples, num_fields, 1); mv_count = res->ad_count - rmidx - 1; if (mv_count > 0) { memmove(added_keyset, added_keyset + 1, mv_count * sizeof(KeySet)); memmove(added_tuples, added_tuples + num_fields, mv_count * num_fields * sizeof(TupleField)); } RemoveDeleted(res, index); RemoveUpdated(res, index); res->ad_count--; MYLOG(0, "removed=1 count=%d\n", res->ad_count); } static void CommitAdded(QResultClass *res) { KeySet *added_keyset; int i; UWORD status; MYLOG(0, "entering res=%p\n", res); if (!res || !res->added_keyset) return; added_keyset = res->added_keyset; for (i = res->ad_count - 1; i >= 0; i--) { status = added_keyset[i].status; if (0 != (status & CURS_SELF_ADDING)) { status |= CURS_SELF_ADDED; status &= ~CURS_SELF_ADDING; } if (0 != (status & CURS_SELF_UPDATING)) { status |= CURS_SELF_UPDATED; status &= ~CURS_SELF_UPDATING; } if (0 != (status & CURS_SELF_DELETING)) { status |= CURS_SELF_DELETED; status &= ~CURS_SELF_DELETING; } if (status != added_keyset[i].status) { MYLOG(DETAIL_LOG_LEVEL, "!!Commit Added=" FORMAT_ULEN "(%d)\n", QR_get_num_total_read(res) + i, i); added_keyset[i].status = status; } } } static int AddDeleted(QResultClass *res, SQLULEN index, const KeySet *keyset) { int i; Int2 dl_count, new_alloc; SQLLEN *deleted; KeySet *deleted_keyset; UWORD status; MYLOG(DETAIL_LOG_LEVEL, "entering " FORMAT_ULEN "\n", index); dl_count = res->dl_count; res->dl_count++; if (!QR_get_cursor(res)) return TRUE; if (!res->deleted) { dl_count = 0; new_alloc = 10; QR_MALLOC_return_with_error(res->deleted, SQLLEN, sizeof(SQLLEN) * new_alloc, res, "Deleted index malloc error", FALSE); QR_MALLOC_return_with_error(res->deleted_keyset, KeySet, sizeof(KeySet) * new_alloc, res, "Deleted keyset malloc error", FALSE); deleted = res->deleted; deleted_keyset = res->deleted_keyset; res->dl_alloc = new_alloc; } else { if (dl_count >= res->dl_alloc) { new_alloc = res->dl_alloc * 2; res->dl_alloc = 0; QR_REALLOC_return_with_error(res->deleted, SQLLEN, sizeof(SQLLEN) * new_alloc, res, "Deleted index realloc error", FALSE); deleted = res->deleted; QR_REALLOC_return_with_error(res->deleted_keyset, KeySet, sizeof(KeySet) * new_alloc, res, "Deleted KeySet realloc error", FALSE); deleted_keyset = res->deleted_keyset; res->dl_alloc = new_alloc; } /* sort deleted indexes in ascending order */ for (i = 0, deleted = res->deleted, deleted_keyset = res->deleted_keyset; i < dl_count; i++, deleted++, deleted_keyset++) { if (index < *deleted) break; } memmove(deleted + 1, deleted, sizeof(SQLLEN) * (dl_count - i)); memmove(deleted_keyset + 1, deleted_keyset, sizeof(KeySet) * (dl_count - i)); } *deleted = index; *deleted_keyset = *keyset; status = keyset->status; status &= (~KEYSET_INFO_PUBLIC); status |= SQL_ROW_DELETED; if (CC_is_in_trans(QR_get_conn(res))) { status |= CURS_SELF_DELETING; QR_get_conn(res)->result_uncommitted = 1; } else { status &= ~(CURS_SELF_ADDING | CURS_SELF_UPDATING | CURS_SELF_DELETING); status |= CURS_SELF_DELETED; } deleted_keyset->status = status; res->dl_count = dl_count + 1; return TRUE; } static void RemoveDeleted(QResultClass *res, SQLLEN index) { int i, mv_count, rm_count = 0; SQLLEN pidx, midx; SQLLEN *deleted, num_read = QR_get_num_total_read(res); KeySet *deleted_keyset; MYLOG(0, "entering index=" FORMAT_LEN "\n", index); if (index < 0) { midx = index; pidx = num_read - index - 1; } else { pidx = index; if (index >= num_read) midx = num_read - index - 1; else midx = index; } for (i = 0; i < res->dl_count; i++) { if (pidx == res->deleted[i] || midx == res->deleted[i]) { mv_count = res->dl_count - i - 1; if (mv_count > 0) { deleted = res->deleted + i; deleted_keyset = res->deleted_keyset + i; memmove(deleted, deleted + 1, mv_count * sizeof(SQLLEN)); memmove(deleted_keyset, deleted_keyset + 1, mv_count * sizeof(KeySet)); } res->dl_count--; rm_count++; } } MYLOG(0, "removed count=%d,%d\n", rm_count, res->dl_count); } static void CommitDeleted(QResultClass *res) { int i; SQLLEN *deleted; KeySet *deleted_keyset; UWORD status; if (!res->deleted) return; for (i = 0, deleted = res->deleted, deleted_keyset = res->deleted_keyset; i < res->dl_count; i++, deleted++, deleted_keyset++) { status = deleted_keyset->status; if (0 != (status & CURS_SELF_ADDING)) { status |= CURS_SELF_ADDED; status &= ~CURS_SELF_ADDING; } if (0 != (status & CURS_SELF_UPDATING)) { status |= CURS_SELF_UPDATED; status &= ~CURS_SELF_UPDATING; } if (0 != (status & CURS_SELF_DELETING)) { status |= CURS_SELF_DELETED; status &= ~CURS_SELF_DELETING; } if (status != deleted_keyset->status) { MYLOG(DETAIL_LOG_LEVEL, "Deleted=" FORMAT_LEN "(%d)\n", *deleted, i); deleted_keyset->status = status; } } } static BOOL enlargeUpdated(QResultClass *res, Int4 number, const StatementClass *stmt) { Int2 alloc; alloc = res->up_alloc; if (0 == alloc) alloc = number > 10 ? number : 10; else while (alloc < number) { alloc *= 2; } if (alloc <= res->up_alloc) return TRUE; QR_REALLOC_return_with_error(res->updated, SQLLEN, sizeof(SQLLEN) * alloc, res, "enlargeUpdated failed", FALSE); QR_REALLOC_return_with_error(res->updated_keyset, KeySet, sizeof(KeySet) * alloc, res, "enlargeUpdated failed 2", FALSE); if (SQL_CURSOR_KEYSET_DRIVEN != stmt->options.cursor_type) QR_REALLOC_return_with_error(res->updated_tuples, TupleField, sizeof(TupleField) * res->num_fields * alloc, res, "enlargeUpdated failed 3", FALSE); res->up_alloc = alloc; return TRUE; } static void AddUpdated(StatementClass *stmt, SQLLEN index, const KeySet *keyset, const TupleField *tuple_updated) { QResultClass *res; SQLLEN *updated; KeySet *updated_keyset; TupleField *updated_tuples = NULL, *tuple; /* SQLLEN res_ridx; */ UInt2 up_count; BOOL is_in_trans; SQLLEN upd_idx, upd_add_idx; Int2 num_fields; int i; UWORD status; MYLOG(DETAIL_LOG_LEVEL, "entering index=" FORMAT_LEN "\n", index); if (!stmt) return; if (res = SC_get_Curres(stmt), !res) return; if (!keyset) return; if (!QR_get_cursor(res)) return; up_count = res->up_count; if (up_count > 0 && 0 == res->up_alloc) return; num_fields = res->num_fields; /* res_ridx = GIdx2CacheIdx(index, stmt, res); if (res_ridx >= 0 && res_ridx < QR_get_num_cached_tuples(res)) tuple_updated = res->backend_tuples + res_ridx * num_fields; */ if (!tuple_updated) return; upd_idx = -1; upd_add_idx = -1; updated = res->updated; is_in_trans = CC_is_in_trans(SC_get_conn(stmt)); updated_keyset = res->updated_keyset; status = keyset->status; status &= (~KEYSET_INFO_PUBLIC); status |= SQL_ROW_UPDATED; if (is_in_trans) status |= CURS_SELF_UPDATING; else { for (i = up_count - 1; i >= 0; i--) { if (updated[i] == index) break; } if (i >= 0) upd_idx = i; else { SQLLEN num_totals = QR_get_num_total_tuples(res); if (index >= num_totals) upd_add_idx = num_totals - index; } status |= CURS_SELF_UPDATED; status &= ~(CURS_SELF_ADDING | CURS_SELF_UPDATING | CURS_SELF_DELETING); } tuple = NULL; /* update the corresponding add(updat)ed info */ if (upd_add_idx >= 0) { res->added_keyset[upd_add_idx].status = status; if (res->added_tuples) { tuple = res->added_tuples + num_fields * upd_add_idx; ClearCachedRows(tuple, num_fields, 1); } } else if (upd_idx >= 0) { res->updated_keyset[upd_idx].status = status; if (res->updated_tuples) { tuple = res->added_tuples + num_fields * upd_add_idx; ClearCachedRows(tuple, num_fields, 1); } } else { if (!enlargeUpdated(res, res->up_count + 1, stmt)) return; updated = res->updated; updated_keyset = res->updated_keyset; updated_tuples = res->updated_tuples; upd_idx = up_count; updated[up_count] = index; updated_keyset[up_count] = *keyset; updated_keyset[up_count].status = status; if (updated_tuples) { tuple = updated_tuples + num_fields * up_count; memset(tuple, 0, sizeof(TupleField) * num_fields); } res->up_count++; } if (tuple) ReplaceCachedRows(tuple, tuple_updated, num_fields, 1); if (is_in_trans) SC_get_conn(stmt)->result_uncommitted = 1; MYLOG(0, "up_count=%d\n", res->up_count); } static void RemoveUpdated(QResultClass *res, SQLLEN index) { MYLOG(0, "entering index=" FORMAT_LEN "\n", index); RemoveUpdatedAfterTheKey(res, index, NULL); } static void RemoveUpdatedAfterTheKey(QResultClass *res, SQLLEN index, const KeySet *keyset) { SQLLEN *updated, num_read = QR_get_num_total_read(res); KeySet *updated_keyset; TupleField *updated_tuples = NULL; SQLLEN pidx, midx, mv_count; int i, num_fields = res->num_fields, rm_count = 0; MYLOG(0, "entering " FORMAT_LEN ",(%u,%u)\n", index, keyset ? keyset->blocknum : 0, keyset ? keyset->offset : 0); if (index < 0) { midx = index; pidx = num_read - index - 1; } else { pidx = index; if (index >= num_read) midx = num_read - index - 1; else midx = index; } for (i = 0; i < res->up_count; i++) { updated = res->updated + i; if (pidx == *updated || midx == *updated) { updated_keyset = res->updated_keyset + i; if (keyset && updated_keyset->blocknum == keyset->blocknum && updated_keyset->offset == keyset->offset) break; updated_tuples = NULL; if (res->updated_tuples) { updated_tuples = res->updated_tuples + i * num_fields; ClearCachedRows(updated_tuples, num_fields, 1); } mv_count = res->up_count - i -1; if (mv_count > 0) { memmove(updated, updated + 1, sizeof(SQLLEN) * mv_count); memmove(updated_keyset, updated_keyset + 1, sizeof(KeySet) * mv_count); if (updated_tuples) memmove(updated_tuples, updated_tuples + num_fields, sizeof(TupleField) * num_fields * mv_count); } res->up_count--; rm_count++; } } MYLOG(0, "removed count=%d,%d\n", rm_count, res->up_count); } static void CommitUpdated(QResultClass *res) { KeySet *updated_keyset; int i; UWORD status; MYLOG(0, "entering res=%p\n", res); if (!res) return; if (!QR_get_cursor(res)) return; if (res->up_count <= 0) return; if (updated_keyset = res->updated_keyset, !updated_keyset) return; for (i = res->up_count - 1; i >= 0; i--) { status = updated_keyset[i].status; if (0 != (status & CURS_SELF_UPDATING)) { status &= ~CURS_SELF_UPDATING; status |= CURS_SELF_UPDATED; } if (0 != (status & CURS_SELF_ADDING)) { status &= ~CURS_SELF_ADDING; status |= CURS_SELF_ADDED; } if (0 != (status & CURS_SELF_DELETING)) { status &= ~CURS_SELF_DELETING; status |= CURS_SELF_DELETED; } if (status != updated_keyset[i].status) { MYLOG(DETAIL_LOG_LEVEL, "!!Commit Updated=" FORMAT_LEN "(%d)\n", res->updated[i], i); updated_keyset[i].status = status; } } } static void DiscardRollback(StatementClass *stmt, QResultClass *res) { int i; SQLLEN index, kres_ridx; UWORD status; Rollback *rollback; KeySet *keyset; BOOL kres_is_valid; MYLOG(DETAIL_LOG_LEVEL, "entering\n"); if (QR_get_cursor(res)) { CommitAdded(res); CommitUpdated(res); CommitDeleted(res); return; } if (0 == res->rb_count || NULL == res->rollback) return; rollback = res->rollback; keyset = res->keyset; for (i = 0; i < res->rb_count; i++) { index = rollback[i].index; status = 0; kres_is_valid = FALSE; if (index >= 0) { kres_ridx = GIdx2KResIdx(index, stmt, res); if (kres_ridx >= 0 && kres_ridx < res->num_cached_keys) { kres_is_valid = TRUE; status = keyset[kres_ridx].status; } } if (kres_is_valid) { keyset[kres_ridx].status &= ~(CURS_SELF_DELETING | CURS_SELF_UPDATING | CURS_SELF_ADDING); keyset[kres_ridx].status |= ((status & (CURS_SELF_DELETING | CURS_SELF_UPDATING | CURS_SELF_ADDING)) << 3); } } free(rollback); res->rollback = NULL; res->rb_count = res->rb_alloc = 0; } static QResultClass *positioned_load(StatementClass *stmt, UInt4 flag, const UInt4 *oidint, const char *tid); static void UndoRollback(StatementClass *stmt, QResultClass *res, BOOL partial) { Int4 i, rollbp; SQLLEN index, ridx, kres_ridx; UWORD status; Rollback *rollback; KeySet *keyset, keys, *wkey = NULL; BOOL curs = (NULL != QR_get_cursor(res)), texist, kres_is_valid; if (0 == res->rb_count || NULL == res->rollback) return; rollback = res->rollback; keyset = res->keyset; rollbp = 0; if (partial) { SQLLEN pidx, midx; int rollbps; int doubtp; int j; MYLOG(DETAIL_LOG_LEVEL, " "); for (i = 0, doubtp = 0; i < res->rb_count; i++) { keys.status = 0; keys.blocknum = rollback[i].blocknum; keys.offset = rollback[i].offset; keys.oid = rollback[i].oid; texist = tupleExists(stmt, &keys); MYPRINTF(DETAIL_LOG_LEVEL, "texist[%d]=%d", i, texist); if (SQL_ADD == rollback[i].option) { if (texist) doubtp = i + 1; } else if (SQL_REFRESH == rollback[i].option) { if (texist || doubtp == i) doubtp = i + 1; } else { if (texist) break; if (doubtp == i) doubtp = i + 1; } MYPRINTF(DETAIL_LOG_LEVEL, " (doubtp=%d)", doubtp); } rollbp = i; MYPRINTF(DETAIL_LOG_LEVEL, " doubtp=%d,rollbp=%d\n", doubtp, rollbp); do { rollbps = rollbp; for (i = doubtp; i < rollbp; i++) { index = rollback[i].index; if (SQL_ADD == rollback[i].option) { MYLOG(DETAIL_LOG_LEVEL, "index[%d]=" FORMAT_LEN "\n", i, index); if (index < 0) { midx = index; pidx = res->num_total_read - index - 1; } else { pidx = index; midx = res->num_total_read - index - 1; } MYLOG(DETAIL_LOG_LEVEL, "pidx=" FORMAT_LEN ",midx=" FORMAT_LEN "\n", pidx, midx); for (j = rollbp - 1; j > i; j--) { if (rollback[j].index == midx || rollback[j].index == pidx) { if (SQL_DELETE == rollback[j].option) { MYLOG(DETAIL_LOG_LEVEL, "delete[%d].index=" FORMAT_LEN "\n", j, rollback[j].index); break; } /*else if (SQL_UPDATE == rollback[j].option) { MYLOG(DETAIL_LOG_LEVEL, "update[%d].index=%d\n", j, rollback[j].index); if (IndexExists(stmt, res, rollback + j)) break; }*/ } } if (j <= i) { rollbp = i; break; } } } } while (rollbp < rollbps); } MYLOG(DETAIL_LOG_LEVEL, "rollbp=%d\n", rollbp); for (i = res->rb_count - 1; i >= rollbp; i--) { MYLOG(DETAIL_LOG_LEVEL, "do %d(%d)\n", i, rollback[i].option); index = rollback[i].index; if (curs) { if (SQL_ADD == rollback[i].option) RemoveAdded(res, index); RemoveDeleted(res, index); keys.status = 0; keys.blocknum = rollback[i].blocknum; keys.offset = rollback[i].offset; keys.oid = rollback[i].oid; /* RemoveUpdatedAfterTheKey(res, index, &keys); is no longer needed? */ RemoveUpdated(res, index); } status = 0; kres_is_valid = FALSE; if (index >= 0) { kres_ridx = GIdx2KResIdx(index, stmt, res); if (kres_ridx >= 0 && kres_ridx < res->num_cached_keys) { kres_is_valid = TRUE; wkey = keyset + kres_ridx; status = wkey->status; } } MYLOG(DETAIL_LOG_LEVEL, " index=" FORMAT_LEN " status=%hx", index, status); if (kres_is_valid) { QResultClass *qres; Int2 num_fields = res->num_fields; ridx = GIdx2CacheIdx(index, stmt, res); if (SQL_ADD == rollback[i].option) { if (ridx >=0 && ridx < res->num_cached_rows) { TupleField *tuple = res->backend_tuples + res->num_fields * ridx; ClearCachedRows(tuple, res->num_fields, 1); res->num_cached_rows--; } res->num_cached_keys--; if (!curs) res->ad_count--; } else if (SQL_REFRESH == rollback[i].option) continue; else { MYPRINTF(DETAIL_LOG_LEVEL, " (%u, %u)", wkey->blocknum, wkey->offset); wkey->blocknum = rollback[i].blocknum; wkey->offset = rollback[i].offset; wkey->oid = rollback[i].oid; MYPRINTF(DETAIL_LOG_LEVEL, "->(%u, %u)", wkey->blocknum, wkey->offset); wkey->status &= ~KEYSET_INFO_PUBLIC; if (SQL_DELETE == rollback[i].option) wkey->status &= ~CURS_SELF_DELETING; else if (SQL_UPDATE == rollback[i].option) wkey->status &= ~CURS_SELF_UPDATING; wkey->status |= CURS_NEEDS_REREAD; if (ridx >=0 && ridx < res->num_cached_rows) { char tidval[32]; Oid oid = wkey->oid; SPRINTF_FIXED(tidval, "(%u,%u)", wkey->blocknum, wkey->offset); qres = positioned_load(stmt, 0, &oid, tidval); if (QR_command_maybe_successful(qres) && QR_get_num_cached_tuples(qres) == 1) { MoveCachedRows(res->backend_tuples + num_fields * ridx, qres->backend_tuples, num_fields, 1); wkey->status &= ~CURS_NEEDS_REREAD; } QR_Destructor(qres); } } } } MYPRINTF(DETAIL_LOG_LEVEL, "\n"); res->rb_count = rollbp; if (0 == rollbp) { free(rollback); res->rollback = NULL; res->rb_alloc = 0; } } void ProcessRollback(ConnectionClass *conn, BOOL undo, BOOL partial) { int i; StatementClass *stmt; QResultClass *res; for (i = 0; i < conn->num_stmts; i++) { if (stmt = conn->stmts[i], !stmt) continue; for (res = SC_get_Result(stmt); res; res = QR_nextr(res)) { if (undo) UndoRollback(stmt, res, partial); else DiscardRollback(stmt, res); } } } #define LATEST_TUPLE_LOAD 1L #define USE_INSERTED_TID (1L << 1) static QResultClass * positioned_load(StatementClass *stmt, UInt4 flag, const UInt4 *oidint, const char *tidval) { CSTR func = "positioned_load"; QResultClass *qres = NULL; PQExpBufferData selstr = {0}; BOOL latest = ((flag & LATEST_TUPLE_LOAD) != 0); TABLE_INFO *ti = stmt->ti[0]; const char *bestqual = GET_NAME(ti->bestqual); const ssize_t from_pos = stmt->load_from_pos; const char *load_stmt = stmt->load_statement; MYLOG(DETAIL_LOG_LEVEL, "entering bestitem=%s bestqual=%s\n", SAFE_NAME(ti->bestitem), SAFE_NAME(ti->bestqual)); initPQExpBuffer(&selstr); #define return DONT_CALL_RETURN_FROM_HERE??? if (TI_has_subclass(ti)) { OID tableoid = *oidint; char table_fqn[256]; const char *quoted_table; quoted_table = ti_quote(stmt, tableoid, table_fqn, sizeof(table_fqn)); if (tidval) { if (latest) { printfPQExpBuffer(&selstr, "%.*sfrom %s where ctid = (select currtid2('%s', '%s'))", (int) from_pos, load_stmt, quoted_table, quoted_table, tidval); } else printfPQExpBuffer(&selstr, "%.*sfrom %s where ctid = '%s'", (int) from_pos, load_stmt, quoted_table, tidval); } else if ((flag & USE_INSERTED_TID) != 0) printfPQExpBuffer(&selstr, "%.*sfrom %s where ctid = (select currtid(0, '(0,0)'))", (int) from_pos, load_stmt, quoted_table); /* else if (bestitem && oidint) { } */ else { SC_set_error(stmt,STMT_INTERNAL_ERROR, "can't find added and updating row because of the lack of oid", func); goto cleanup; } } else { CSTR andqual = " and "; BOOL andExist = TRUE; if (tidval) { if (latest) { char table_fqn[256]; printfPQExpBuffer(&selstr, "%s where ctid = (select currtid2('%s', '%s'))", load_stmt, ti_quote(stmt, 0, table_fqn, sizeof(table_fqn)), tidval); } else printfPQExpBuffer(&selstr, "%s where ctid = '%s'", load_stmt, tidval); } else if ((flag & USE_INSERTED_TID) != 0) printfPQExpBuffer(&selstr, "%s where ctid = (select currtid(0, '(0,0)'))", load_stmt); else if (bestqual) { andExist = FALSE; printfPQExpBuffer(&selstr, "%s where ", load_stmt); } else { SC_set_error(stmt,STMT_INTERNAL_ERROR, "can't find added and updating row because of the lack of oid", func); goto cleanup; } if (bestqual && oidint) { if (andExist) appendPQExpBufferStr(&selstr, andqual); appendPQExpBuffer(&selstr, bestqual, *oidint); } } if (PQExpBufferDataBroken(selstr)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory positioned_load()", func); goto cleanup; } MYLOG(0, "selstr=%s\n", selstr.data); qres = CC_send_query(SC_get_conn(stmt), selstr.data, NULL, READ_ONLY_QUERY, stmt); cleanup: #undef return if (!PQExpBufferDataBroken(selstr)) termPQExpBuffer(&selstr); return qres; } BOOL QR_get_last_bookmark(const QResultClass *res, Int4 index, KeySet *keyset) { int i; if (res->dl_count > 0 && res->deleted) { for (i = 0; i < res->dl_count; i++) { if (res->deleted[i] == index) { *keyset = res->deleted_keyset[i]; return TRUE; } if (res->deleted[i] > index) break; } } if (res->up_count > 0 && res->updated) { for (i = res->up_count - 1; i >= 0; i--) { if (res->updated[i] == index) { *keyset = res->updated_keyset[i]; return TRUE; } } } return FALSE; } static RETCODE SC_pos_reload_with_key(StatementClass *stmt, SQLULEN global_ridx, UInt2 *count, Int4 logKind, const KeySet *keyset) { CSTR func = "SC_pos_reload_with_key"; int res_cols; UInt2 rcnt; SQLLEN kres_ridx; OID oidint; QResultClass *res, *qres; IRDFields *irdflds = SC_get_IRDF(stmt); RETCODE ret = SQL_ERROR; char tidval[32]; BOOL use_ctid = TRUE; BOOL idx_exist = TRUE; MYLOG(0, "entering fi=%p ti=%p\n", irdflds->fi, stmt->ti); rcnt = 0; if (count) *count = 0; if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_reload.", func); return SQL_ERROR; } kres_ridx = GIdx2KResIdx(global_ridx, stmt, res); if (kres_ridx < 0 || kres_ridx >= res->num_cached_keys) { if (NULL == keyset || keyset->offset == 0) { SC_set_error(stmt, STMT_ROW_OUT_OF_RANGE, "the target keys are out of the rowset", func); return SQL_ERROR; } idx_exist = FALSE; } else if (0 != (res->keyset[kres_ridx].status & CURS_SELF_ADDING)) { if (NULL == keyset || keyset->offset == 0) { use_ctid = FALSE; MYLOG(0, "The tuple is currently being added and can't use ctid\n"); } } if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); /* not preferable */ if (!SC_is_updatable(stmt)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); return SQL_ERROR; } /* old oid & tid */ if (idx_exist) { UInt4 blocknum; UInt2 offset; if (!(oidint = getOid(res, kres_ridx))) { if (!strcmp(SAFE_NAME(stmt->ti[0]->bestitem), OID_NAME)) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the row was already deleted ?", func); return SQL_SUCCESS_WITH_INFO; } } getTid(res, kres_ridx, &blocknum, &offset); SPRINTF_FIXED(tidval, "(%u, %u)", blocknum, offset); } res_cols = getNumResultCols(res); if (keyset) /* after or update */ { char tid[32]; oidint = keyset->oid; SPRINTF_FIXED(tid, "(%u,%hu)", keyset->blocknum, keyset->offset); qres = positioned_load(stmt, 0, &oidint, tid); } else { if (use_ctid) qres = positioned_load(stmt, LATEST_TUPLE_LOAD, &oidint, tidval); else qres = positioned_load(stmt, 0, &oidint, NULL); keyset = res->keyset + kres_ridx; } if (!QR_command_maybe_successful(qres)) { ret = SQL_ERROR; SC_replace_error_with_res(stmt, STMT_ERROR_TAKEN_FROM_BACKEND, "positioned_load failed", qres, TRUE); } else if (rcnt = (UInt2) QR_get_num_cached_tuples(qres), rcnt == 1) { SQLLEN res_ridx; switch (logKind) { case 0: case SQL_FETCH_BY_BOOKMARK: break; case SQL_UPDATE: AddUpdated(stmt, global_ridx, keyset, qres->tupleField); break; default: AddRollback(stmt, res, global_ridx, keyset, logKind); } res_ridx = GIdx2CacheIdx(global_ridx, stmt, res); if (res_ridx >= 0 && res_ridx < QR_get_num_cached_tuples(res)) { TupleField *tuple_old, *tuple_new; int effective_fields = res_cols; tuple_old = res->backend_tuples + res->num_fields * res_ridx; QR_set_position(qres, 0); tuple_new = qres->tupleField; if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type && strcmp(tuple_new[qres->num_fields - res->num_key_fields].value, tidval)) res->keyset[kres_ridx].status |= SQL_ROW_UPDATED; KeySetSet(tuple_new, qres->num_fields, res->num_key_fields, res->keyset + kres_ridx, FALSE); MoveCachedRows(tuple_old, tuple_new, effective_fields, 1); } if (rcnt > 1) { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "more than one row were update/deleted?", func); } else ret = SQL_SUCCESS; } else { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the content was deleted after last fetch", func); ret = SQL_SUCCESS_WITH_INFO; AddRollback(stmt, res, global_ridx, keyset, logKind); if (idx_exist) { if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) { res->keyset[kres_ridx].status |= SQL_ROW_DELETED; } } } QR_Destructor(qres); if (count) *count = rcnt; return ret; } RETCODE SC_pos_reload(StatementClass *stmt, SQLULEN global_ridx, UInt2 *count, Int4 logKind) { return SC_pos_reload_with_key(stmt, global_ridx, count, logKind, NULL); } static const int pre_fetch_count = 32; static SQLLEN LoadFromKeyset(StatementClass *stmt, QResultClass * res, int rows_per_fetch, SQLLEN limitrow) { CSTR func = "LoadFromKeyset"; ConnectionClass *conn = SC_get_conn(stmt); SQLLEN i; int j, rowc, rcnt = 0; OID oid; UInt4 blocknum; SQLLEN kres_ridx; UInt2 offset; PQExpBufferData qval = {0}; int keys_per_fetch = 10; #define return DONT_CALL_RETURN_FROM_HERE??? for (i = SC_get_rowset_start(stmt), kres_ridx = GIdx2KResIdx(i, stmt, res), rowc = 0;; i++, kres_ridx++) { if (i >= limitrow) { if (!rowc) break; if (res->reload_count > 0) { for (j = rowc; j < keys_per_fetch; j++) { appendPQExpBufferStr(&qval, j ? ",NULL" : "NULL"); } } rowc = -1; /* end of loop */ } if (rowc < 0 || rowc >= keys_per_fetch) { QResultClass *qres; appendPQExpBufferStr(&qval, ")"); if (PQExpBufferDataBroken(qval)) { rcnt = -1; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in LoadFromKeyset()", func); goto cleanup; } qres = CC_send_query(conn, qval.data, NULL, CREATE_KEYSET | READ_ONLY_QUERY, stmt); if (QR_command_maybe_successful(qres)) { SQLLEN j, k, l; Int2 m; TupleField *tuple, *tuplew; UInt4 bln; UInt2 off; for (j = 0; j < QR_get_num_total_read(qres); j++) { oid = getOid(qres, j); getTid(qres, j, &blocknum, &offset); for (k = SC_get_rowset_start(stmt); k < limitrow; k++) { getTid(res, k, &bln, &off); if (oid == getOid(res, k) && bln == blocknum && off == offset) { l = GIdx2CacheIdx(k, stmt, res); tuple = res->backend_tuples + res->num_fields * l; tuplew = qres->backend_tuples + qres->num_fields * j; for (m = 0; m < res->num_fields; m++, tuple++, tuplew++) { if (tuple->len > 0 && tuple->value) free(tuple->value); tuple->value = tuplew->value; tuple->len = tuplew->len; tuplew->value = NULL; tuplew->len = -1; } res->keyset[k].status &= ~CURS_NEEDS_REREAD; break; } } } } else { SC_set_error(stmt, STMT_EXEC_ERROR, "Data Load Error", func); rcnt = -1; QR_Destructor(qres); break; } QR_Destructor(qres); if (rowc < 0) break; rowc = 0; } if (!rowc) { if (PQExpBufferDataBroken(qval)) { initPQExpBuffer(&qval); if (res->reload_count > 0) keys_per_fetch = res->reload_count; else { char planname[32]; int j; QResultClass *qres; if (rows_per_fetch >= pre_fetch_count * 2) keys_per_fetch = pre_fetch_count; else keys_per_fetch = rows_per_fetch; if (!keys_per_fetch) keys_per_fetch = 2; SPRINTF_FIXED(planname, "_KEYSET_%p", res); printfPQExpBuffer(&qval, "PREPARE \"%s\"", planname); for (j = 0; j < keys_per_fetch; j++) { appendPQExpBufferStr(&qval, j ? ",tid" : "(tid"); } appendPQExpBuffer(&qval, ") as %s where ctid in ", stmt->load_statement); for (j = 0; j < keys_per_fetch; j++) { if (j == 0) appendPQExpBufferStr(&qval, "($1"); else appendPQExpBuffer(&qval, ",$%d", j + 1); } appendPQExpBufferStr(&qval, ")"); if (PQExpBufferDataBroken(qval)) { rcnt = -1; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in LoadFromKeyset()", func); goto cleanup; } qres = CC_send_query(conn, qval.data, NULL, READ_ONLY_QUERY, stmt); if (QR_command_maybe_successful(qres)) { res->reload_count = keys_per_fetch; } else { SC_set_error(stmt, STMT_EXEC_ERROR, "Prepare for Data Load Error", func); rcnt = -1; SC_set_Result(stmt, qres); break; } QR_Destructor(qres); } } if (res->reload_count > 0) { printfPQExpBuffer(&qval, "EXECUTE \"_KEYSET_%p\"(", res); } else { printfPQExpBuffer(&qval, "%s where ctid in (", stmt->load_statement); } } if (rcnt >= 0 && 0 != (res->keyset[kres_ridx].status & CURS_NEEDS_REREAD)) { getTid(res, kres_ridx, &blocknum, &offset); if (rowc) appendPQExpBuffer(&qval, ",'(%u,%u)'", blocknum, offset); else appendPQExpBuffer(&qval, "'(%u,%u)'", blocknum, offset); rowc++; rcnt++; } } cleanup: #undef return if (!PQExpBufferDataBroken(qval)) termPQExpBuffer(&qval); return rcnt; } static SQLLEN LoadFromKeyset_inh(StatementClass *stmt, QResultClass * res, int rows_per_fetch, SQLLEN limitrow) { ConnectionClass *conn = SC_get_conn(stmt); SQLLEN i; int j, rowc, rcnt = 0; OID oid, new_oid; UInt4 blocknum; SQLLEN kres_ridx; UInt2 offset; PQExpBufferData qval = {0}; int keys_per_fetch = 10; const char *load_stmt = stmt->load_statement; const ssize_t from_pos = stmt->load_from_pos; MYLOG(0, "entering in rows_per_fetch=%d limitrow=" FORMAT_LEN "\n", rows_per_fetch, limitrow); new_oid = 0; #define return DONT_CALL_RETURN_FROM_HERE??? for (i = SC_get_rowset_start(stmt), kres_ridx = GIdx2KResIdx(i, stmt, res), rowc = 0, oid = 0;; i++, kres_ridx++) { if (i >= limitrow) { if (!rowc) break; rowc = -1; /* end of loop */ } else if (0 == (res->keyset[kres_ridx].status & CURS_NEEDS_REREAD)) continue; else new_oid = getOid(res, kres_ridx); if (rowc < 0 || rowc >= keys_per_fetch || (oid != 0 && new_oid != oid)) { QResultClass *qres; appendPQExpBufferStr(&qval, ")"); if (PQExpBufferDataBroken(qval)) { rcnt = -1; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in LoadFromKeyset_inh()", __FUNCTION__); goto cleanup; } qres = CC_send_query(conn, qval.data, NULL, CREATE_KEYSET | READ_ONLY_QUERY, stmt); if (QR_command_maybe_successful(qres)) { SQLLEN k, l; Int2 m; TupleField *tuple, *tuplew; UInt4 bln; UInt2 off; OID tbloid; for (j = 0; j < QR_get_num_total_read(qres); j++) { tbloid = getOid(qres, j); getTid(qres, j, &blocknum, &offset); for (k = SC_get_rowset_start(stmt); k < limitrow; k++) { getTid(res, k, &bln, &off); if (tbloid == getOid(res, k) && bln == blocknum && off == offset) { l = GIdx2CacheIdx(k, stmt, res); tuple = res->backend_tuples + res->num_fields * l; tuplew = qres->backend_tuples + qres->num_fields * j; for (m = 0; m < res->num_fields; m++, tuple++, tuplew++) { if (tuple->len > 0 && tuple->value) free(tuple->value); tuple->value = tuplew->value; tuple->len = tuplew->len; tuplew->value = NULL; tuplew->len = -1; } res->keyset[k].status &= ~CURS_NEEDS_REREAD; break; } } } } else { SC_set_error(stmt, STMT_EXEC_ERROR, "Data Load Error", __FUNCTION__); rcnt = -1; SC_set_Result(stmt, qres); break; } QR_Destructor(qres); if (rowc < 0) break; rowc = 0; } if (!rowc) { char table_fqn[256]; if (PQExpBufferDataBroken(qval)) { if (rows_per_fetch >= pre_fetch_count * 2) keys_per_fetch = pre_fetch_count; else keys_per_fetch = rows_per_fetch; if (!keys_per_fetch) keys_per_fetch = 2; initPQExpBuffer(&qval); } printfPQExpBuffer(&qval, "%.*sfrom %s where ctid in (", (int) from_pos, load_stmt, ti_quote(stmt, new_oid, table_fqn, sizeof(table_fqn))); } if (new_oid != oid) oid = new_oid; getTid(res, kres_ridx, &blocknum, &offset); if (rowc) appendPQExpBuffer(&qval, ",'(%u,%u)'", blocknum, offset); else appendPQExpBuffer(&qval, "'(%u,%u)'", blocknum, offset); rowc++; rcnt++; } cleanup: #undef return if (!PQExpBufferDataBroken(qval)) termPQExpBuffer(&qval); return rcnt; } static RETCODE SQL_API SC_pos_reload_needed(StatementClass *stmt, SQLULEN req_size, UDWORD flag) { CSTR func = "SC_pos_reload_needed"; Int4 req_rows_size; SQLLEN i, limitrow; UInt2 qcount; QResultClass *res; RETCODE ret = SQL_ERROR; SQLLEN kres_ridx, rowc; Int4 rows_per_fetch; BOOL create_from_scratch = (0 != flag); MYLOG(0, "entering\n"); #define return DONT_CALL_RETURN_FROM_HERE??? if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_reload_needed.", func); goto cleanup; } if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); /* not preferable */ if (!SC_is_updatable(stmt)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); goto cleanup; } rows_per_fetch = 0; req_rows_size = QR_get_reqsize(res); if (req_size > req_rows_size) req_rows_size = (UInt4) req_size; if (create_from_scratch) { rows_per_fetch = ((pre_fetch_count - 1) / req_rows_size + 1) * req_rows_size; limitrow = RowIdx2GIdx(rows_per_fetch, stmt); } else { limitrow = RowIdx2GIdx(req_rows_size, stmt); } if (limitrow > res->num_cached_keys) limitrow = res->num_cached_keys; if (create_from_scratch || !res->dataFilled) { ClearCachedRows(res->backend_tuples, res->num_fields, res->num_cached_rows); res->dataFilled = FALSE; } if (!res->dataFilled) { SQLLEN brows = GIdx2RowIdx(limitrow, stmt); if (brows > res->count_backend_allocated) { QR_REALLOC_gexit_with_error(res->backend_tuples, TupleField, sizeof(TupleField) * res->num_fields * brows, res, "pos_reload_needed failed", ret = SQL_ERROR); res->count_backend_allocated = brows; } if (brows > 0) memset(res->backend_tuples, 0, sizeof(TupleField) * res->num_fields * brows); QR_set_num_cached_rows(res, brows); QR_set_rowstart_in_cache(res, 0); if (SQL_RD_ON != stmt->options.retrieve_data) { ret = SQL_SUCCESS; goto cleanup; } for (i = SC_get_rowset_start(stmt), kres_ridx = GIdx2KResIdx(i, stmt,res); i < limitrow; i++, kres_ridx++) { if (0 == (res->keyset[kres_ridx].status & (CURS_SELF_DELETING | CURS_SELF_DELETED | CURS_OTHER_DELETED))) res->keyset[kres_ridx].status |= CURS_NEEDS_REREAD; } } if (TI_has_subclass(stmt->ti[0])) { if (rowc = LoadFromKeyset_inh(stmt, res, rows_per_fetch, limitrow), rowc < 0) { goto cleanup; } } else if (rowc = LoadFromKeyset(stmt, res, rows_per_fetch, limitrow), rowc < 0) { goto cleanup; } for (i = SC_get_rowset_start(stmt), kres_ridx = GIdx2KResIdx(i, stmt, res); i < limitrow; i++) { if (0 != (res->keyset[kres_ridx].status & CURS_NEEDS_REREAD)) { ret = SC_pos_reload(stmt, i, &qcount, 0); if (SQL_ERROR == ret) { goto cleanup; } if (SQL_ROW_DELETED == (res->keyset[kres_ridx].status & KEYSET_INFO_PUBLIC)) { res->keyset[kres_ridx].status |= CURS_OTHER_DELETED; } res->keyset[kres_ridx].status &= ~CURS_NEEDS_REREAD; } } ret = SQL_SUCCESS; res->dataFilled = TRUE; cleanup: #undef return return ret; } static RETCODE SQL_API SC_pos_newload(StatementClass *stmt, const UInt4 *oidint, BOOL tidRef, const char *tidval) { CSTR func = "SC_pos_newload"; int i; QResultClass *res, *qres; RETCODE ret = SQL_ERROR; MYLOG(0, "entering ti=%p\n", stmt->ti); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_newload.", func); return SQL_ERROR; } if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); /* not preferable */ if (!SC_is_updatable(stmt)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); return SQL_ERROR; } qres = positioned_load(stmt, (tidRef && NULL == tidval) ? USE_INSERTED_TID : 0, oidint, tidRef ? tidval : NULL); if (!qres || !QR_command_maybe_successful(qres)) { SC_set_error(stmt, STMT_ERROR_TAKEN_FROM_BACKEND, "positioned_load in pos_newload failed", func); } else { SQLLEN count = QR_get_num_cached_tuples(qres); QR_set_position(qres, 0); if (count == 1) { int effective_fields = res->num_fields; ssize_t tuple_size; SQLLEN num_total_rows, num_cached_rows, kres_ridx; BOOL appendKey = FALSE, appendData = FALSE; TupleField *tuple_old, *tuple_new; tuple_new = qres->tupleField; num_total_rows = QR_get_num_total_tuples(res); AddAdded(stmt, res, num_total_rows, tuple_new); num_cached_rows = QR_get_num_cached_tuples(res); kres_ridx = GIdx2KResIdx(num_total_rows, stmt, res); if (QR_haskeyset(res)) { if (!QR_get_cursor(res)) { appendKey = TRUE; if (num_total_rows == CacheIdx2GIdx(num_cached_rows, stmt, res)) appendData = TRUE; else { MYLOG(DETAIL_LOG_LEVEL, "total " FORMAT_LEN " <> backend " FORMAT_LEN " - base " FORMAT_LEN " + start " FORMAT_LEN " cursor_type=" FORMAT_UINTEGER "\n", num_total_rows, num_cached_rows, QR_get_rowstart_in_cache(res), SC_get_rowset_start(stmt), stmt->options.cursor_type); } } else if (kres_ridx >= 0 && kres_ridx < res->cache_size) { appendKey = TRUE; appendData = TRUE; } } if (appendKey) { if (res->num_cached_keys >= res->count_keyset_allocated) { if (!res->count_keyset_allocated) tuple_size = TUPLE_MALLOC_INC; else tuple_size = res->count_keyset_allocated * 2; QR_REALLOC_return_with_error(res->keyset, KeySet, sizeof(KeySet) * tuple_size, res, "pos_newload failed", SQL_ERROR); res->count_keyset_allocated = tuple_size; } KeySetSet(tuple_new, qres->num_fields, res->num_key_fields, res->keyset + kres_ridx, TRUE); res->num_cached_keys++; } if (appendData) { MYLOG(DETAIL_LOG_LEVEL, "total " FORMAT_LEN " == backend " FORMAT_LEN " - base " FORMAT_LEN " + start " FORMAT_LEN " cursor_type=" FORMAT_UINTEGER "\n", num_total_rows, num_cached_rows, QR_get_rowstart_in_cache(res), SC_get_rowset_start(stmt), stmt->options.cursor_type); if (num_cached_rows >= res->count_backend_allocated) { if (!res->count_backend_allocated) tuple_size = TUPLE_MALLOC_INC; else tuple_size = res->count_backend_allocated * 2; QR_REALLOC_return_with_error(res->backend_tuples, TupleField, res->num_fields * sizeof(TupleField) * tuple_size, res, "SC_pos_newload failed", SQL_ERROR); res->count_backend_allocated = tuple_size; } tuple_old = res->backend_tuples + res->num_fields * num_cached_rows; for (i = 0; i < effective_fields; i++) { tuple_old[i].len = tuple_new[i].len; tuple_new[i].len = -1; tuple_old[i].value = tuple_new[i].value; tuple_new[i].value = NULL; } res->num_cached_rows++; } ret = SQL_SUCCESS; } else if (0 == count) ret = SQL_NO_DATA_FOUND; else { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the driver could't identify inserted rows", func); ret = SQL_ERROR; } /* stmt->currTuple = SC_get_rowset_start(stmt) + ridx; */ } QR_Destructor(qres); return ret; } static RETCODE SQL_API irow_update(RETCODE ret, StatementClass *stmt, StatementClass *ustmt, SQLULEN global_ridx, const KeySet *old_keyset) { CSTR func = "irow_update"; if (ret != SQL_ERROR) { int updcnt; QResultClass *tres = SC_get_Curres(ustmt); const char *cmdstr = QR_get_command(tres); if (cmdstr && sscanf(cmdstr, "UPDATE %d", &updcnt) == 1) { if (updcnt == 1) { KeySet keys; if (NULL != tres->backend_tuples && 1 == QR_get_num_cached_tuples(tres)) { KeySetSet(tres->backend_tuples, QR_NumResultCols(tres), QR_NumResultCols(tres), &keys, TRUE); if (SQL_SUCCEEDED(ret = SC_pos_reload_with_key(stmt, global_ridx, (UInt2 *) 0, SQL_UPDATE, &keys))) AddRollback(stmt, SC_get_Curres(stmt), global_ridx, old_keyset, SQL_UPDATE); } else ret = SQL_ERROR; } else if (updcnt == 0) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the content was changed before updates", func); ret = SQL_SUCCESS_WITH_INFO; if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) SC_pos_reload(stmt, global_ridx, (UInt2 *) 0, 0); } else ret = SQL_ERROR; } else ret = SQL_ERROR; if (ret == SQL_ERROR && SC_get_errornumber(stmt) == 0) { SC_set_error(stmt, STMT_ERROR_TAKEN_FROM_BACKEND, "SetPos update return error", func); } } return ret; } /* SQL_NEED_DATA callback for SC_pos_update */ typedef struct { BOOL updyes; QResultClass *res; StatementClass *stmt, *qstmt; IRDFields *irdflds; SQLSETPOSIROW irow; SQLULEN global_ridx; KeySet old_keyset; } pup_cdata; static RETCODE pos_update_callback(RETCODE retcode, void *para) { RETCODE ret = retcode; pup_cdata *s = (pup_cdata *) para; SQLLEN kres_ridx; BOOL idx_exist = TRUE; if (s->updyes) { MYLOG(0, "entering\n"); ret = irow_update(ret, s->stmt, s->qstmt, s->global_ridx, &s->old_keyset); MYLOG(DETAIL_LOG_LEVEL, "irow_update ret=%d,%d\n", ret, SC_get_errornumber(s->qstmt)); if (ret != SQL_SUCCESS) SC_error_copy(s->stmt, s->qstmt, TRUE); PGAPI_FreeStmt(s->qstmt, SQL_DROP); s->qstmt = NULL; } s->updyes = FALSE; kres_ridx = GIdx2KResIdx(s->global_ridx, s->stmt, s->res); if (kres_ridx < 0 || kres_ridx >= s->res->num_cached_keys) { idx_exist = FALSE; } if (SQL_SUCCESS == ret && s->res->keyset && idx_exist) { ConnectionClass *conn = SC_get_conn(s->stmt); if (CC_is_in_trans(conn)) { s->res->keyset[kres_ridx].status |= (SQL_ROW_UPDATED | CURS_SELF_UPDATING); } else s->res->keyset[kres_ridx].status |= (SQL_ROW_UPDATED | CURS_SELF_UPDATED); } if (s->irdflds->rowStatusArray) { switch (ret) { case SQL_SUCCESS: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_UPDATED; break; case SQL_NO_DATA_FOUND: case SQL_SUCCESS_WITH_INFO: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_SUCCESS_WITH_INFO; ret = SQL_SUCCESS_WITH_INFO; break; case SQL_ERROR: default: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_ERROR; } } return ret; } RETCODE SC_pos_update(StatementClass *stmt, SQLSETPOSIROW irow, SQLULEN global_ridx, const KeySet *keyset) { CSTR func = "SC_pos_update"; int i, num_cols, upd_cols; pup_cdata s; ConnectionClass *conn; ARDFields *opts = SC_get_ARDF(stmt); BindInfoClass *bindings = opts->bindings; TABLE_INFO *ti; FIELD_INFO **fi; PQExpBufferData updstr = {0}; RETCODE ret = SQL_ERROR; OID oid; UInt4 blocknum; UInt2 pgoffset; SQLLEN offset; SQLLEN *used, kres_ridx; Int4 bind_size = opts->bind_size; BOOL idx_exist = TRUE; char table_fqn[256]; s.stmt = stmt; s.irow = irow; s.global_ridx = global_ridx; s.irdflds = SC_get_IRDF(s.stmt); fi = s.irdflds->fi; if (!(s.res = SC_get_Curres(s.stmt))) { SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_update.", func); return SQL_ERROR; } MYLOG(0, "entering " FORMAT_POSIROW "+" FORMAT_LEN " fi=%p ti=%p\n", s.irow, QR_get_rowstart_in_cache(s.res), fi, s.stmt->ti); if (SC_update_not_ready(stmt)) parse_statement(s.stmt, TRUE); /* not preferable */ if (!SC_is_updatable(s.stmt)) { s.stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(s.stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); return SQL_ERROR; } kres_ridx = GIdx2KResIdx(s.global_ridx, s.stmt, s.res); if (kres_ridx < 0 || kres_ridx >= s.res->num_cached_keys) { if (NULL == keyset || keyset->offset == 0) { SC_set_error(s.stmt, STMT_ROW_OUT_OF_RANGE, "the target keys are out of the rowset", func); return SQL_ERROR; } idx_exist = FALSE; } if (idx_exist) { if (!(oid = getOid(s.res, kres_ridx))) { if (!strcmp(SAFE_NAME(stmt->ti[0]->bestitem), OID_NAME)) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the row was already deleted ?", func); return SQL_ERROR; } } getTid(s.res, kres_ridx, &blocknum, &pgoffset); s.old_keyset = s.res->keyset[kres_ridx]; } else { oid = keyset->oid; blocknum = keyset->blocknum; pgoffset = keyset->offset; s.old_keyset = *keyset; } ti = s.stmt->ti[0]; initPQExpBuffer(&updstr); #define return DONT_CALL_RETURN_FROM_HERE??? printfPQExpBuffer(&updstr, "update %s set", ti_quote(stmt, oid, table_fqn, sizeof(table_fqn))); num_cols = s.irdflds->nfields; offset = opts->row_offset_ptr ? *opts->row_offset_ptr : 0; for (i = upd_cols = 0; i < num_cols; i++) { if (used = bindings[i].used, used != NULL) { used = LENADDR_SHIFT(used, offset); if (bind_size > 0) used = LENADDR_SHIFT(used, bind_size * s.irow); else used = LENADDR_SHIFT(used, s.irow * sizeof(SQLLEN)); MYLOG(0, "%d used=" FORMAT_LEN ",%p\n", i, *used, used); if (*used != SQL_IGNORE && fi[i]->updatable) { if (upd_cols) appendPQExpBuffer(&updstr, ", \"%s\" = ?", GET_NAME(fi[i]->column_name)); else appendPQExpBuffer(&updstr, " \"%s\" = ?", GET_NAME(fi[i]->column_name)); upd_cols++; } } else MYLOG(0, "%d null bind\n", i); } conn = SC_get_conn(s.stmt); s.updyes = FALSE; if (upd_cols > 0) { HSTMT hstmt; int j; ConnInfo *ci = &(conn->connInfo); APDFields *apdopts; IPDFields *ipdopts; OID fieldtype = 0; const char *bestitem = GET_NAME(ti->bestitem); const char *bestqual = GET_NAME(ti->bestqual); int unknown_sizes = ci->drivers.unknown_sizes; appendPQExpBuffer(&updstr, " where ctid = '(%u, %u)'", blocknum, pgoffset); if (bestqual) { appendPQExpBuffer(&updstr, " and "); appendPQExpBuffer(&updstr, bestqual, oid); } if (PG_VERSION_GE(conn, 8.2)) { appendPQExpBuffer(&updstr, " returning ctid"); if (bestitem) { appendPQExpBuffer(&updstr, ", "); appendPQExpBuffer(&updstr, "\"%s\"", bestitem); } } MYLOG(0, "updstr=%s\n", updstr.data); if (PGAPI_AllocStmt(conn, &hstmt, 0) != SQL_SUCCESS) { SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "internal AllocStmt error", func); goto cleanup; } s.qstmt = (StatementClass *) hstmt; apdopts = SC_get_APDF(s.qstmt); apdopts->param_bind_type = opts->bind_size; apdopts->param_offset_ptr = opts->row_offset_ptr; ipdopts = SC_get_IPDF(s.qstmt); SC_set_delegate(s.stmt, s.qstmt); extend_iparameter_bindings(ipdopts, num_cols); for (i = j = 0; i < num_cols; i++) { if (used = bindings[i].used, used != NULL) { used = LENADDR_SHIFT(used, offset); if (bind_size > 0) used = LENADDR_SHIFT(used, bind_size * s.irow); else used = LENADDR_SHIFT(used, s.irow * sizeof(SQLLEN)); MYLOG(0, "%d used=" FORMAT_LEN "\n", i, *used); if (*used != SQL_IGNORE && fi[i]->updatable) { /* fieldtype = QR_get_field_type(s.res, i); */ fieldtype = getEffectiveOid(conn, fi[i]); PIC_set_pgtype(ipdopts->parameters[j], fieldtype); PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++j, SQL_PARAM_INPUT, bindings[i].returntype, pgtype_to_concise_type(s.stmt, fieldtype, i, unknown_sizes), fi[i]->column_size > 0 ? fi[i]->column_size : pgtype_column_size(s.stmt, fieldtype, i, unknown_sizes), (SQLSMALLINT) fi[i]->decimal_digits, bindings[i].buffer, bindings[i].buflen, bindings[i].used); } } } s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow; s.updyes = TRUE; if (PQExpBufferDataBroken(updstr)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in SC_pos_updatet()", func); goto cleanup; } ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) updstr.data, SQL_NTS, 0); if (ret == SQL_NEED_DATA) { pup_cdata *cbdata = (pup_cdata *) malloc(sizeof(pup_cdata)); if (!cbdata) { SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for cbdata", func); ret = SQL_ERROR; goto cleanup; } memcpy(cbdata, &s, sizeof(pup_cdata)); if (0 == enqueueNeedDataCallback(s.stmt, pos_update_callback, cbdata)) ret = SQL_ERROR; goto cleanup; } /* else if (ret != SQL_SUCCESS) this is unnecessary SC_error_copy(s.stmt, s.qstmt, TRUE); */ } else { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "update list null", func); } ret = pos_update_callback(ret, &s); cleanup: #undef return if (!PQExpBufferDataBroken(updstr)) termPQExpBuffer(&updstr); return ret; } RETCODE SC_pos_delete(StatementClass *stmt, SQLSETPOSIROW irow, SQLULEN global_ridx, const KeySet *keyset) { CSTR func = "SC_pos_update"; UWORD offset; QResultClass *res, *qres; ConnectionClass *conn = SC_get_conn(stmt); IRDFields *irdflds = SC_get_IRDF(stmt); PQExpBufferData dltstr = {0}; RETCODE ret; SQLLEN kres_ridx; OID oid; UInt4 blocknum, qflag; TABLE_INFO *ti; const char *bestitem; const char *bestqual; BOOL idx_exist = TRUE; char table_fqn[256]; MYLOG(0, "entering ti=%p\n", stmt->ti); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_delete.", func); return SQL_ERROR; } if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); /* not preferable */ if (!SC_is_updatable(stmt)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); return SQL_ERROR; } kres_ridx = GIdx2KResIdx(global_ridx, stmt, res); if (kres_ridx < 0 || kres_ridx >= res->num_cached_keys) { if (NULL == keyset || keyset->offset == 0) { SC_set_error(stmt, STMT_ROW_OUT_OF_RANGE, "the target keys are out of the rowset", func); return SQL_ERROR; } idx_exist = FALSE; } ti = stmt->ti[0]; bestitem = GET_NAME(ti->bestitem); bestqual = GET_NAME(ti->bestqual); if (idx_exist) { if (!(oid = getOid(res, kres_ridx))) { if (bestitem && !strcmp(bestitem, OID_NAME)) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the row was already deleted ?", func); return SQL_ERROR; } } getTid(res, kres_ridx, &blocknum, &offset); keyset = res->keyset + kres_ridx; } else { oid = keyset->oid; blocknum = keyset->blocknum; offset = keyset->offset; } initPQExpBuffer(&dltstr); #define return DONT_CALL_RETURN_FROM_HERE??? printfPQExpBuffer(&dltstr, "delete from %s where ctid = '(%u, %u)'", ti_quote(stmt, oid, table_fqn, sizeof(table_fqn)), blocknum, offset); if (bestqual && !TI_has_subclass(ti)) { appendPQExpBuffer(&dltstr, " and "); appendPQExpBuffer(&dltstr, bestqual, oid); } if (PQExpBufferDataBroken(dltstr)) { ret = SQL_ERROR; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in SC_pos_delete()", func); goto cleanup; } MYLOG(0, "dltstr=%s\n", dltstr.data); qflag = 0; if (stmt->external && !CC_is_in_trans(conn) && (!CC_does_autocommit(conn))) qflag |= GO_INTO_TRANSACTION; qres = CC_send_query(conn, dltstr.data, NULL, qflag, stmt); ret = SQL_SUCCESS; if (QR_command_maybe_successful(qres)) { int dltcnt; const char *cmdstr = QR_get_command(qres); if (cmdstr && sscanf(cmdstr, "DELETE %d", &dltcnt) == 1) { if (dltcnt == 1) { RETCODE tret = SC_pos_reload_with_key(stmt, global_ridx, (UInt2 *) 0, SQL_DELETE, keyset); if (!SQL_SUCCEEDED(tret)) ret = tret; } else if (dltcnt == 0) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the content was changed before deletes", func); ret = SQL_SUCCESS_WITH_INFO; if (idx_exist && stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) SC_pos_reload(stmt, global_ridx, (UInt2 *) 0, 0); } else ret = SQL_ERROR; } else ret = SQL_ERROR; } else { ret = SQL_ERROR; if (qres) { STRCPY_FIXED(res->sqlstate, qres->sqlstate); res->message = qres->message; qres->message = NULL; } } if (ret == SQL_ERROR && SC_get_errornumber(stmt) == 0) { SC_set_error(stmt, STMT_ERROR_TAKEN_FROM_BACKEND, "SetPos delete return error", func); } if (qres) QR_Destructor(qres); if (SQL_SUCCESS == ret && keyset) AddDeleted(res, global_ridx, keyset); if (SQL_SUCCESS == ret && keyset && idx_exist) { res->keyset[kres_ridx].status &= (~KEYSET_INFO_PUBLIC); if (CC_is_in_trans(conn)) { res->keyset[kres_ridx].status |= (SQL_ROW_DELETED | CURS_SELF_DELETING); } else res->keyset[kres_ridx].status |= (SQL_ROW_DELETED | CURS_SELF_DELETED); MYLOG(DETAIL_LOG_LEVEL, ".status[" FORMAT_ULEN "]=%x\n", global_ridx, res->keyset[kres_ridx].status); } if (irdflds->rowStatusArray) { switch (ret) { case SQL_SUCCESS: irdflds->rowStatusArray[irow] = SQL_ROW_DELETED; break; case SQL_NO_DATA_FOUND: case SQL_SUCCESS_WITH_INFO: irdflds->rowStatusArray[irow] = SQL_ROW_DELETED; // SQL_ROW_SUCCESS_WITH_INFO; ret = SQL_SUCCESS_WITH_INFO; break; case SQL_ERROR: default: irdflds->rowStatusArray[irow] = SQL_ROW_ERROR; break; } } cleanup: #undef return if (!PQExpBufferDataBroken(dltstr)) termPQExpBuffer(&dltstr); return ret; } static RETCODE SQL_API irow_insert(RETCODE ret, StatementClass *stmt, StatementClass *istmt, SQLLEN addpos) { CSTR func = "irow_insert"; if (ret != SQL_ERROR) { int addcnt; OID oid, *poid = NULL; ARDFields *opts = SC_get_ARDF(stmt); QResultClass *ires = SC_get_Curres(istmt), *tres; const char *cmdstr; BindInfoClass *bookmark; tres = (QR_nextr(ires) ? QR_nextr(ires) : ires); cmdstr = QR_get_command(tres); if (cmdstr && sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 && addcnt == 1) { RETCODE qret; const char * tidval = NULL; char tidv[32]; KeySet keys; if (NULL != tres->backend_tuples && 1 == QR_get_num_cached_tuples(tres)) { KeySetSet(tres->backend_tuples, QR_NumResultCols(tres), QR_NumResultCols(tres), &keys, TRUE); oid = keys.oid; SPRINTF_FIXED(tidv, "(%u,%hu)", keys.blocknum, keys.offset); tidval = tidv; } if (0 != oid) poid = &oid; qret = SC_pos_newload(stmt, poid, TRUE, tidval); if (SQL_ERROR == qret) return qret; if (SQL_NO_DATA_FOUND == qret) { qret = SC_pos_newload(stmt, poid, FALSE, NULL); if (SQL_ERROR == qret) return qret; } bookmark = opts->bookmark; if (bookmark && bookmark->buffer) { SC_set_current_col(stmt, -1); SC_Create_bookmark(stmt, bookmark, stmt->bind_row, addpos, &keys); } } else { SC_set_error(stmt, STMT_ERROR_TAKEN_FROM_BACKEND, "SetPos insert return error", func); } } return ret; } /* SQL_NEED_DATA callback for SC_pos_add */ typedef struct { BOOL updyes; QResultClass *res; StatementClass *stmt, *qstmt; IRDFields *irdflds; SQLSETPOSIROW irow; } padd_cdata; static RETCODE pos_add_callback(RETCODE retcode, void *para) { RETCODE ret = retcode; padd_cdata *s = (padd_cdata *) para; SQLLEN addpos; if (s->updyes) { SQLSETPOSIROW brow_save; MYLOG(0, "entering ret=%d\n", ret); brow_save = s->stmt->bind_row; s->stmt->bind_row = s->irow; if (QR_get_cursor(s->res)) addpos = -(SQLLEN)(s->res->ad_count + 1); else addpos = QR_get_num_total_tuples(s->res); ret = irow_insert(ret, s->stmt, s->qstmt, addpos); s->stmt->bind_row = brow_save; } s->updyes = FALSE; SC_setInsertedTable(s->qstmt, ret); if (ret != SQL_SUCCESS) SC_error_copy(s->stmt, s->qstmt, TRUE); PGAPI_FreeStmt((HSTMT) s->qstmt, SQL_DROP); s->qstmt = NULL; if (SQL_SUCCESS == ret && s->res->keyset) { SQLLEN global_ridx = QR_get_num_total_tuples(s->res) - 1; ConnectionClass *conn = SC_get_conn(s->stmt); SQLLEN kres_ridx; UWORD status = SQL_ROW_ADDED; if (CC_is_in_trans(conn)) status |= CURS_SELF_ADDING; else status |= CURS_SELF_ADDED; kres_ridx = GIdx2KResIdx(global_ridx, s->stmt, s->res); if (kres_ridx >= 0 && kres_ridx < s->res->num_cached_keys) { s->res->keyset[kres_ridx].status = status; } } if (s->irdflds->rowStatusArray) { switch (ret) { case SQL_SUCCESS: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_ADDED; break; case SQL_NO_DATA_FOUND: case SQL_SUCCESS_WITH_INFO: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_SUCCESS_WITH_INFO; break; default: s->irdflds->rowStatusArray[s->irow] = SQL_ROW_ERROR; } } return ret; } RETCODE SC_pos_add(StatementClass *stmt, SQLSETPOSIROW irow) { CSTR func = "SC_pos_add"; int num_cols, add_cols, i; HSTMT hstmt; padd_cdata s; ConnectionClass *conn; ConnInfo *ci; ARDFields *opts = SC_get_ARDF(stmt); APDFields *apdopts; IPDFields *ipdopts; BindInfoClass *bindings = opts->bindings; FIELD_INFO **fi = SC_get_IRDF(stmt)->fi; PQExpBufferData addstr = {0}; RETCODE ret; SQLULEN offset; SQLLEN *used; Int4 bind_size = opts->bind_size; OID fieldtype; int unknown_sizes; int func_cs_count = 0; char table_fqn[256]; MYLOG(0, "entering fi=%p ti=%p\n", fi, stmt->ti); s.stmt = stmt; s.irow = irow; if (!(s.res = SC_get_Curres(s.stmt))) { SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_add.", func); return SQL_ERROR; } if (SC_update_not_ready(stmt)) parse_statement(s.stmt, TRUE); /* not preferable */ if (!SC_is_updatable(s.stmt)) { s.stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(s.stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", func); return SQL_ERROR; } s.irdflds = SC_get_IRDF(s.stmt); num_cols = s.irdflds->nfields; conn = SC_get_conn(s.stmt); if (PGAPI_AllocStmt(conn, &hstmt, 0) != SQL_SUCCESS) { SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "internal AllocStmt error", func); return SQL_ERROR; } initPQExpBuffer(&addstr); #define return DONT_CALL_RETURN_FROM_HERE??? printfPQExpBuffer(&addstr, "insert into %s (", ti_quote(s.stmt, 0, table_fqn, sizeof(table_fqn))); if (opts->row_offset_ptr) offset = *opts->row_offset_ptr; else offset = 0; s.qstmt = (StatementClass *) hstmt; apdopts = SC_get_APDF(s.qstmt); apdopts->param_bind_type = opts->bind_size; apdopts->param_offset_ptr = opts->row_offset_ptr; ipdopts = SC_get_IPDF(s.qstmt); SC_set_delegate(s.stmt, s.qstmt); ci = &(conn->connInfo); unknown_sizes = ci->drivers.unknown_sizes; extend_iparameter_bindings(ipdopts, num_cols); for (i = add_cols = 0; i < num_cols; i++) { if (used = bindings[i].used, used != NULL) { used = LENADDR_SHIFT(used, offset); if (bind_size > 0) used = LENADDR_SHIFT(used, bind_size * s.irow); else used = LENADDR_SHIFT(used, s.irow * sizeof(SQLLEN)); MYLOG(0, "%d used=" FORMAT_LEN "\n", i, *used); if (*used != SQL_IGNORE && fi[i]->updatable) { /* fieldtype = QR_get_field_type(s.res, i); */ fieldtype = getEffectiveOid(conn, fi[i]); if (add_cols) appendPQExpBuffer(&addstr, ", \"%s\"", GET_NAME(fi[i]->column_name)); else appendPQExpBuffer(&addstr, "\"%s\"", GET_NAME(fi[i]->column_name)); PIC_set_pgtype(ipdopts->parameters[add_cols], fieldtype); PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++add_cols, SQL_PARAM_INPUT, bindings[i].returntype, pgtype_to_concise_type(s.stmt, fieldtype, i, unknown_sizes), fi[i]->column_size > 0 ? fi[i]->column_size : pgtype_column_size(s.stmt, fieldtype, i, unknown_sizes), (SQLSMALLINT) fi[i]->decimal_digits, bindings[i].buffer, bindings[i].buflen, bindings[i].used); } } else MYLOG(0, "%d null bind\n", i); } s.updyes = FALSE; ENTER_INNER_CONN_CS(conn, func_cs_count); if (add_cols > 0) { appendPQExpBuffer(&addstr, ") values ("); for (i = 0; i < add_cols; i++) { if (i) appendPQExpBuffer(&addstr, ", ?"); else appendPQExpBuffer(&addstr, "?"); } appendPQExpBuffer(&addstr, ")"); if (PG_VERSION_GE(conn, 8.2)) { TABLE_INFO *ti = stmt->ti[0]; const char *bestitem = GET_NAME(ti->bestitem); appendPQExpBuffer(&addstr, " returning ctid"); if (bestitem) { appendPQExpBuffer(&addstr, ", "); appendPQExpBuffer(&addstr, "\"%s\"", bestitem); } } if (PQExpBufferDataBroken(addstr)) { ret = SQL_ERROR; SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory in SC_pos_add()", func); goto cleanup; } MYLOG(0, "addstr=%s\n", addstr.data); s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow; s.updyes = TRUE; ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) addstr.data, SQL_NTS, 0); if (ret == SQL_NEED_DATA) { padd_cdata *cbdata = (padd_cdata *) malloc(sizeof(padd_cdata)); if (!cbdata) { SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for cbdata", func); ret = SQL_ERROR; goto cleanup; } memcpy(cbdata, &s, sizeof(padd_cdata)); if (0 == enqueueNeedDataCallback(s.stmt, pos_add_callback, cbdata)) ret = SQL_ERROR; goto cleanup; } /* else if (ret != SQL_SUCCESS) this is unnecessary SC_error_copy(s.stmt, s.qstmt, TRUE); */ } else { ret = SQL_SUCCESS_WITH_INFO; SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "insert list null", func); } ret = pos_add_callback(ret, &s); cleanup: #undef return CLEANUP_FUNC_CONN_CS(func_cs_count, conn); if (!PQExpBufferDataBroken(addstr)) termPQExpBuffer(&addstr); return ret; } /* * Stuff for updatable cursors end. */ RETCODE SC_pos_refresh(StatementClass *stmt, SQLSETPOSIROW irow , SQLULEN global_ridx) { RETCODE ret; IRDFields *irdflds = SC_get_IRDF(stmt); /* save the last_fetch_count */ SQLLEN last_fetch = stmt->last_fetch_count; SQLLEN last_fetch2 = stmt->last_fetch_count_include_ommitted; SQLSETPOSIROW bind_save = stmt->bind_row; BOOL tuple_reload = FALSE; if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) tuple_reload = TRUE; else { QResultClass *res = SC_get_Curres(stmt); if (res && res->keyset) { SQLLEN kres_ridx = GIdx2KResIdx(global_ridx, stmt, res); if (kres_ridx >= 0 && kres_ridx < QR_get_num_cached_tuples(res)) { if (0 != (CURS_NEEDS_REREAD & res->keyset[kres_ridx].status)) tuple_reload = TRUE; } } } if (tuple_reload) { if (!SQL_SUCCEEDED(ret = SC_pos_reload(stmt, global_ridx, (UInt2 *) 0, 0))) return ret; } stmt->bind_row = irow; ret = SC_fetch(stmt); /* restore the last_fetch_count */ stmt->last_fetch_count = last_fetch; stmt->last_fetch_count_include_ommitted = last_fetch2; stmt->bind_row = bind_save; if (irdflds->rowStatusArray) { switch (ret) { case SQL_SUCCESS: irdflds->rowStatusArray[irow] = SQL_ROW_SUCCESS; break; case SQL_SUCCESS_WITH_INFO: irdflds->rowStatusArray[irow] = SQL_ROW_SUCCESS_WITH_INFO; break; case SQL_ERROR: default: irdflds->rowStatusArray[irow] = SQL_ROW_ERROR; break; } } return SQL_SUCCESS; } /* SQL_NEED_DATA callback for PGAPI_SetPos */ typedef struct { BOOL need_data_callback, auto_commit_needed; QResultClass *res; StatementClass *stmt; ARDFields *opts; GetDataInfo *gdata; SQLLEN idx, start_row, end_row, ridx; UWORD fOption; SQLSETPOSIROW irow, nrow, processed; } spos_cdata; static RETCODE spos_callback(RETCODE retcode, void *para) { CSTR func = "spos_callback"; RETCODE ret; spos_cdata *s = (spos_cdata *) para; QResultClass *res; ARDFields *opts; ConnectionClass *conn; SQLULEN global_ridx; SQLLEN kres_ridx, pos_ridx = 0; ret = retcode; MYLOG(0, "entering %d in\n", s->need_data_callback); if (s->need_data_callback) { s->processed++; if (SQL_ERROR != retcode) { s->nrow++; s->idx++; } } else { s->ridx = -1; s->idx = s->nrow = s->processed = 0; } res = s->res; opts = s->opts; if (!res || !opts) { SC_set_error(s->stmt, STMT_SEQUENCE_ERROR, "Passed res or opts for spos_callback is NULL", func); return SQL_ERROR; } s->need_data_callback = FALSE; for (; SQL_ERROR != ret && s->nrow <= s->end_row; s->idx++) { global_ridx = RowIdx2GIdx(s->idx, s->stmt); if (SQL_ADD != s->fOption) { if ((int) global_ridx >= QR_get_num_total_tuples(res)) break; if (res->keyset) { kres_ridx = GIdx2KResIdx(global_ridx, s->stmt, res); if (kres_ridx >= res->num_cached_keys) break; if (kres_ridx >= 0) /* the row may be deleted and not in the rowset */ { if (0 == (res->keyset[kres_ridx].status & CURS_IN_ROWSET)) continue; } } } if (s->nrow < s->start_row) { s->nrow++; continue; } s->ridx = s->nrow; pos_ridx = s->idx; if (0 != s->irow || !opts->row_operation_ptr || opts->row_operation_ptr[s->nrow] == SQL_ROW_PROCEED) { switch (s->fOption) { case SQL_UPDATE: ret = SC_pos_update(s->stmt, s->nrow, global_ridx, NULL); break; case SQL_DELETE: ret = SC_pos_delete(s->stmt, s->nrow, global_ridx, NULL); break; case SQL_ADD: ret = SC_pos_add(s->stmt, s->nrow); break; case SQL_REFRESH: ret = SC_pos_refresh(s->stmt, s->nrow, global_ridx); break; } if (SQL_NEED_DATA == ret) { spos_cdata *cbdata = (spos_cdata *) malloc(sizeof(spos_cdata)); if (!cbdata) { SC_set_error(s->stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for cbdata", func); return SQL_ERROR; } memcpy(cbdata, s, sizeof(spos_cdata)); cbdata->need_data_callback = TRUE; if (0 == enqueueNeedDataCallback(s->stmt, spos_callback, cbdata)) ret = SQL_ERROR; return ret; } s->processed++; } if (SQL_ERROR != ret) s->nrow++; } conn = SC_get_conn(s->stmt); if (s->auto_commit_needed) CC_set_autocommit(conn, TRUE); if (s->irow > 0) { if (SQL_ADD != s->fOption && s->ridx >= 0) /* for SQLGetData */ { s->stmt->currTuple = RowIdx2GIdx(pos_ridx, s->stmt); QR_set_position(res, pos_ridx); } } else if (SC_get_IRDF(s->stmt)->rowsFetched) *(SC_get_IRDF(s->stmt)->rowsFetched) = s->processed; res->recent_processed_row_count = s->stmt->diag_row_count = s->processed; if (opts) /* logging */ { MYLOG(DETAIL_LOG_LEVEL, "processed=" FORMAT_POSIROW " ret=%d rowset=" FORMAT_LEN, s->processed, ret, opts->size_of_rowset_odbc2); MYPRINTF(DETAIL_LOG_LEVEL, "," FORMAT_LEN "\n", opts->size_of_rowset); } return ret; } /* * This positions the cursor within a rowset, that was positioned using SQLExtendedFetch. * This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */ RETCODE SQL_API PGAPI_SetPos(HSTMT hstmt, SQLSETPOSIROW irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock) { CSTR func = "PGAPI_SetPos"; RETCODE ret; ConnectionClass *conn; SQLLEN rowsetSize; int i; UInt2 gdata_allocated; GetDataInfo *gdata_info; GetDataClass *gdata = NULL; spos_cdata s; s.stmt = (StatementClass *) hstmt; if (!s.stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } s.irow = irow; s.fOption = fOption; s.auto_commit_needed = FALSE; s.opts = SC_get_ARDF(s.stmt); gdata_info = SC_get_GDTI(s.stmt); gdata = gdata_info->gdata; MYLOG(0, "entering fOption=%d irow=" FORMAT_POSIROW " lock=%hu currt=" FORMAT_LEN "\n", s.fOption, s.irow, fLock, s.stmt->currTuple); if (s.stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) ; else if (s.fOption != SQL_POSITION && s.fOption != SQL_REFRESH) { SC_set_error(s.stmt, STMT_NOT_IMPLEMENTED_ERROR, "Only SQL_POSITION/REFRESH is supported for PGAPI_SetPos", func); return SQL_ERROR; } if (!(s.res = SC_get_Curres(s.stmt))) { SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in PGAPI_SetPos.", func); return SQL_ERROR; } rowsetSize = (s.stmt->transition_status == STMT_TRANSITION_EXTENDED_FETCH ? s.opts->size_of_rowset_odbc2 : s.opts->size_of_rowset); if (s.irow == 0) /* bulk operation */ { if (SQL_POSITION == s.fOption) { SC_set_error(s.stmt, STMT_INVALID_CURSOR_POSITION, "Bulk Position operations not allowed.", func); return SQL_ERROR; } s.start_row = 0; s.end_row = rowsetSize - 1; } else { if (SQL_ADD != s.fOption && s.irow > s.stmt->last_fetch_count) { SC_set_error(s.stmt, STMT_ROW_OUT_OF_RANGE, "Row value out of range", func); return SQL_ERROR; } s.start_row = s.end_row = s.irow - 1; } gdata_allocated = gdata_info->allocated; MYLOG(0, "num_cols=%d gdatainfo=%d\n", QR_NumPublicResultCols(s.res), gdata_allocated); /* Reset for SQLGetData */ if (gdata) { for (i = 0; i < gdata_allocated; i++) GETDATA_RESET(gdata[i]); } conn = SC_get_conn(s.stmt); switch (s.fOption) { case SQL_UPDATE: case SQL_DELETE: case SQL_ADD: if (s.auto_commit_needed = CC_does_autocommit(conn), s.auto_commit_needed) CC_set_autocommit(conn, FALSE); break; case SQL_POSITION: break; } s.need_data_callback = FALSE; #define return DONT_CALL_RETURN_FROM_HERE??? /* StartRollbackState(s.stmt); */ ret = spos_callback(SQL_SUCCESS, &s); #undef return if (SQL_SUCCEEDED(ret) && 0 == s.processed) { SC_set_error(s.stmt, STMT_ROW_OUT_OF_RANGE, "the row was deleted?", func); ret = SQL_ERROR; } MYLOG(0, "leaving %d\n", ret); return ret; } /* Sets options that control the behavior of cursors. */ RETCODE SQL_API PGAPI_SetScrollOptions(HSTMT hstmt, SQLUSMALLINT fConcurrency, SQLLEN crowKeyset, SQLUSMALLINT crowRowset) { CSTR func = "PGAPI_SetScrollOptions"; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "entering fConcurrency=%d crowKeyset=" FORMAT_LEN " crowRowset=%d\n", fConcurrency, crowKeyset, crowRowset); SC_set_error(stmt, STMT_NOT_IMPLEMENTED_ERROR, "SetScroll option not implemented", func); return SQL_ERROR; } /* Set the cursor name on a statement handle */ RETCODE SQL_API PGAPI_SetCursorName(HSTMT hstmt, const SQLCHAR * szCursor, SQLSMALLINT cbCursor) { CSTR func = "PGAPI_SetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "entering hstmt=%p, szCursor=%p, cbCursorMax=%d\n", hstmt, szCursor, cbCursor); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } NULL_THE_NAME(stmt->cursor_name); SET_NAME_DIRECTLY(stmt->cursor_name, make_string(szCursor, cbCursor, NULL, 0)); return SQL_SUCCESS; } /* Return the cursor name for a statement handle */ RETCODE SQL_API PGAPI_GetCursorName(HSTMT hstmt, SQLCHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT * pcbCursor) { CSTR func = "PGAPI_GetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; size_t len = 0; RETCODE result; MYLOG(0, "entering hstmt=%p, szCursor=%p, cbCursorMax=%d, pcbCursor=%p\n", hstmt, szCursor, cbCursorMax, pcbCursor); if (!stmt) { SC_log_error(func, NULL_STRING, NULL); return SQL_INVALID_HANDLE; } result = SQL_SUCCESS; len = strlen(SC_cursor_name(stmt)); if (szCursor) { strncpy_null((char *) szCursor, SC_cursor_name(stmt), cbCursorMax); if (len >= cbCursorMax) { result = SQL_SUCCESS_WITH_INFO; SC_set_error(stmt, STMT_TRUNCATED, "The buffer was too small for the GetCursorName.", func); } } if (pcbCursor) *pcbCursor = (SQLSMALLINT) len; /* * Because this function causes no db-access, there's * no need to call DiscardStatementSvp() */ return result; } RETCODE SC_fetch_by_bookmark(StatementClass *stmt) { UInt2 offset; SQLLEN kres_ridx; OID oidint; UInt4 blocknum; QResultClass *res, *qres; RETCODE ret = SQL_ERROR; HSTMT hstmt = NULL; StatementClass *fstmt; SQLLEN size_of_rowset, cached_rows; SQLULEN cRow; UInt2 num_fields; ARDFields *opts = SC_get_ARDF(stmt); SQLHDESC hdesc; APDFields *apdf; const int tidbuflen = 20; char *tidbuf = NULL, *query = NULL; int i, lodlen; BindInfoClass *bookmark_orig = opts->bookmark; TupleField *otuple, *ituple; SQLUSMALLINT *rowStatusArray; MYLOG(0, "entering\n"); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_fetch_by_bookmark.", __FUNCTION__); return SQL_ERROR; } if (SC_update_not_ready(stmt)) parse_statement(stmt, TRUE); /* not preferable */ if (!SC_is_updatable(stmt)) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "the statement is read-only", __FUNCTION__); return SQL_ERROR; } if (ret = PGAPI_AllocStmt(SC_get_conn(stmt), &hstmt, 0), !SQL_SUCCEEDED(ret)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "internal AllocStmt error", __FUNCTION__); return ret; } size_of_rowset = opts->size_of_rowset; SC_MALLOC_gexit_with_error(tidbuf, char, size_of_rowset * tidbuflen, stmt, "Couldn't allocate memory for tidbuf bind.", (ret = SQL_ERROR)); for (i = 0; i < size_of_rowset; i++) { PG_BM pg_bm; SQLLEN bidx; pg_bm = SC_Resolve_bookmark(opts, i); bidx = pg_bm.index; MYLOG(0, "i=%d bidx=" FORMAT_LEN " cached=" FORMAT_ULEN "\n", i, bidx, res->num_cached_keys); kres_ridx = GIdx2KResIdx(bidx, stmt, res); if (kres_ridx < 0 || kres_ridx >= res->num_cached_keys) { if (pg_bm.keys.offset > 0) { QR_get_last_bookmark(res, bidx, &pg_bm.keys); blocknum = pg_bm.keys.blocknum; offset = pg_bm.keys.offset; oidint = pg_bm.keys.oid; } else { SC_set_error(stmt, STMT_ROW_OUT_OF_RANGE, "the target rows is out of the rowset", __FUNCTION__); goto cleanup; } } else { if (!(oidint = getOid(res, kres_ridx))) { if (!strcmp(SAFE_NAME(stmt->ti[0]->bestitem), OID_NAME)) { SC_set_error(stmt, STMT_ROW_VERSION_CHANGED, "the row was already deleted ?", __FUNCTION__); } } getTid(res, kres_ridx, &blocknum, &offset); } snprintf(tidbuf + i * tidbuflen, tidbuflen, "(%u,%u)", blocknum, offset); MYLOG(0, "!!!! tidbuf=%s\n", tidbuf + i * tidbuflen); } if (!SQL_SUCCEEDED(PGAPI_BindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, tidbuflen, 0, tidbuf, tidbuflen, NULL))) goto cleanup; apdf = SC_get_APDF((StatementClass *) hstmt); apdf->paramset_size = size_of_rowset; if (!SQL_SUCCEEDED(PGAPI_GetStmtAttr(stmt, SQL_ATTR_APP_ROW_DESC, (SQLPOINTER) &hdesc, SQL_IS_POINTER, NULL))) goto cleanup; if (!SQL_SUCCEEDED(PGAPI_SetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, (SQLPOINTER) hdesc, SQL_IS_POINTER))) goto cleanup; lodlen = strlen(stmt->load_statement) + 15; SC_MALLOC_gexit_with_error(query, char, lodlen, stmt, "Couldn't allocate memory for query buf.", (ret = SQL_ERROR)); snprintf(query, lodlen, "%s where ctid=?", stmt->load_statement); if (!SQL_SUCCEEDED(ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) query, SQL_NTS, PODBC_RDONLY))) goto cleanup; /* * Combine multiple results into one */ fstmt = (StatementClass *) hstmt; res = SC_get_Result(fstmt); num_fields = QR_NumResultCols(res); cached_rows = QR_get_num_cached_tuples(res); if (size_of_rowset > res->count_backend_allocated) { SC_REALLOC_gexit_with_error(res->backend_tuples, TupleField, size_of_rowset * sizeof(TupleField) * num_fields, hstmt, "Couldn't realloc memory for backend.", (ret = SQL_ERROR)); res->count_backend_allocated = size_of_rowset; } memset(res->backend_tuples + num_fields * cached_rows, 0, (size_of_rowset - cached_rows) * num_fields * sizeof(TupleField)); QR_set_num_cached_rows(res, size_of_rowset); res->num_total_read = size_of_rowset; rowStatusArray = (SC_get_IRDF(stmt))->rowStatusArray; for (i = 0, qres = res; i < size_of_rowset && NULL != qres; i++, qres = QR_nextr(qres)) { if (1 == QR_get_num_cached_tuples(qres)) { otuple = res->backend_tuples + i * num_fields; ituple = qres->backend_tuples; if (otuple != ituple) MoveCachedRows(otuple, ituple, num_fields, 1); if (NULL != rowStatusArray) rowStatusArray[i] = SQL_ROW_SUCCESS; } else if (NULL != rowStatusArray) rowStatusArray[i] = SQL_ROW_DELETED; } /* Fetch and fill bind info */ cRow = 0; opts->bookmark = NULL; ret = PGAPI_ExtendedFetch(fstmt, SQL_FETCH_NEXT, 0, &cRow, NULL, 0, size_of_rowset); MYLOG(0, "cRow=" FORMAT_ULEN "\n", cRow); cleanup: if (NULL != hstmt) { PGAPI_SetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, (SQLPOINTER) NULL, SQL_IS_POINTER); PGAPI_FreeStmt(hstmt, SQL_DROP); } opts->bookmark = bookmark_orig; if (NULL != tidbuf) free(tidbuf); if (NULL != query) free(query); return ret; } psqlodbc-REL-16_00_0005/setup.c000066400000000000000000000470631462406103600160140ustar00rootroot00000000000000/*------- * Module: setup.c * * Description: This module contains the setup functions for * adding/modifying a Data Source in the ODBC.INI portion * of the registry. * * Classes: n/a * * API functions: ConfigDSN, ConfigDriver * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "psqlodbc.h" #include "pgenlist.h" #include "loadlib.h" #include "misc.h" // strncpy_null //#include "environ.h" #include #include #include #include "resource.h" #include "pgapifunc.h" #include "dlg_specific.h" #include "win_setup.h" #define INTFUNC __stdcall extern HINSTANCE s_hModule; /* Saved module handle. */ /* Constants */ #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAXKEYLEN (32+1) /* Max keyword length */ #define MAXDESC (255+1) /* Max description length */ #define MAXDSNAME (32+1) /* Max data source name length */ static void ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg); static BOOL SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg, DWORD *errcode); static BOOL SetDriverAttributes(LPCSTR lpszDriver, DWORD *pErrorCode, LPSTR pErrorMessage, WORD cbMessage); static void CenterDialog(HWND hdlg); /*-------- * ConfigDSN * * Description: ODBC Setup entry point * This entry point is called by the ODBC Installer * (see file header for more details) * Input : hwnd ----------- Parent window handle * fRequest ------- Request type (i.e., add, config, or remove) * lpszDriver ----- Driver name * lpszAttributes - data source attribute string * Output : TRUE success, FALSE otherwise *-------- */ BOOL CALLBACK ConfigDSN(HWND hwnd, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes) { BOOL fSuccess; /* Success/fail flag */ GLOBALHANDLE hglbAttr; LPSETUPDLG lpsetupdlg; /* Allocate attribute array */ hglbAttr = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(SETUPDLG)); if (!hglbAttr) return FALSE; lpsetupdlg = (LPSETUPDLG) GlobalLock(hglbAttr); /* First of all, parse attribute string only for DSN entry */ CC_conninfo_init(&(lpsetupdlg->ci), INIT_GLOBALS); if (lpszAttributes) ParseAttributes(lpszAttributes, lpsetupdlg); /* Save original data source name */ if (lpsetupdlg->ci.dsn[0]) STRCPY_FIXED(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn); else lpsetupdlg->szDSN[0] = '\0'; /* Remove data source */ if (ODBC_REMOVE_DSN == fRequest) { /* Fail if no data source name was supplied */ if (!lpsetupdlg->ci.dsn[0]) fSuccess = FALSE; /* Otherwise remove data source from ODBC.INI */ else fSuccess = SQLRemoveDSNFromIni(lpsetupdlg->ci.dsn); } /* Add or Configure data source */ else { /* Save passed variables for global access (e.g., dialog access) */ lpsetupdlg->hwndParent = hwnd; lpsetupdlg->lpszDrvr = lpszDriver; lpsetupdlg->fNewDSN = (ODBC_ADD_DSN == fRequest); lpsetupdlg->fDefault = !lstrcmpi(lpsetupdlg->ci.dsn, INI_DSN); /* Cleanup conninfo and restore data source name */ CC_conninfo_init(&(lpsetupdlg->ci), CLEANUP_FOR_REUSE | INIT_GLOBALS); STRCPY_FIXED(lpsetupdlg->ci.dsn, lpsetupdlg->szDSN); /* Get common attributes of Data Source */ getDSNinfo(&(lpsetupdlg->ci), lpsetupdlg->lpszDrvr); /* * Parse attribute string again * * NOTE: Values supplied in the attribute string will always * override settings in ODBC.INI */ if (lpszAttributes) ParseAttributes(lpszAttributes, lpsetupdlg); /* * Display the appropriate dialog (if parent window handle * supplied) */ if (hwnd) { /* Display dialog(s) */ fSuccess = (IDOK == DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_CONFIG), hwnd, ConfigDlgProc, (LPARAM) lpsetupdlg)); } else if (lpsetupdlg->ci.dsn[0]) { MYLOG(0, "SetDSNAttributes\n"); fSuccess = SetDSNAttributes(hwnd, lpsetupdlg, NULL); } else fSuccess = FALSE; } CC_conninfo_release(&(lpsetupdlg->ci)); GlobalUnlock(hglbAttr); GlobalFree(hglbAttr); return fSuccess; } /*-------- * ConfigDriver * * Description: ODBC Setup entry point * This entry point is called by the ODBC Installer * (see file header for more details) * Arguments : hwnd ----------- Parent window handle * fRequest ------- Request type (i.e., add, config, or remove) * lpszDriver ----- Driver name * lpszArgs ------- A null-terminated string containing arguments for a driver specific fRequest * lpszMsg -------- A null-terimated string containing an output message from the driver setup * cnMsgMax ------- Length of lpszMSg * pcbMsgOut ------ Total number of bytes available to return in lpszMsg * Returns : TRUE success, FALSE otherwise *-------- */ BOOL CALLBACK ConfigDriver(HWND hwnd, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszArgs, LPSTR lpszMsg, WORD cbMsgMax, WORD *pcbMsgOut) { DWORD errorCode = 0; BOOL fSuccess = TRUE; /* Success/fail flag */ if (cbMsgMax > 0 && NULL != lpszMsg) *lpszMsg = '\0'; if (NULL != pcbMsgOut) *pcbMsgOut = 0; /* Add the driver */ switch (fRequest) { case ODBC_INSTALL_DRIVER: fSuccess = SetDriverAttributes(lpszDriver, &errorCode, lpszMsg, cbMsgMax); if (cbMsgMax > 0 && NULL != lpszMsg) *pcbMsgOut = (WORD) strlen(lpszMsg); break; case ODBC_REMOVE_DRIVER: break; default: errorCode = ODBC_ERROR_INVALID_REQUEST_TYPE; fSuccess = FALSE; } if (!fSuccess) SQLPostInstallerError(errorCode, lpszMsg); return fSuccess; } /*------- * CenterDialog * * Description: Center the dialog over the frame window * Input : hdlg -- Dialog window handle * Output : None *------- */ static void CenterDialog(HWND hdlg) { HWND hwndFrame; RECT rcDlg, rcScr, rcFrame; int cx, cy; hwndFrame = GetParent(hdlg); GetWindowRect(hdlg, &rcDlg); cx = rcDlg.right - rcDlg.left; cy = rcDlg.bottom - rcDlg.top; GetClientRect(hwndFrame, &rcFrame); ClientToScreen(hwndFrame, (LPPOINT) (&rcFrame.left)); ClientToScreen(hwndFrame, (LPPOINT) (&rcFrame.right)); rcDlg.top = rcFrame.top + (((rcFrame.bottom - rcFrame.top) - cy) >> 1); rcDlg.left = rcFrame.left + (((rcFrame.right - rcFrame.left) - cx) >> 1); rcDlg.bottom = rcDlg.top + cy; rcDlg.right = rcDlg.left + cx; GetWindowRect(GetDesktopWindow(), &rcScr); if (rcDlg.bottom > rcScr.bottom) { rcDlg.bottom = rcScr.bottom; rcDlg.top = rcDlg.bottom - cy; } if (rcDlg.right > rcScr.right) { rcDlg.right = rcScr.right; rcDlg.left = rcDlg.right - cx; } if (rcDlg.left < 0) rcDlg.left = 0; if (rcDlg.top < 0) rcDlg.top = 0; MoveWindow(hdlg, rcDlg.left, rcDlg.top, cx, cy, TRUE); return; } /*------- * ConfigDlgProc * Description: Manage add data source name dialog * Input : hdlg --- Dialog window handle * wMsg --- Message * wParam - Message parameter * lParam - Message parameter * Output : TRUE if message processed, FALSE otherwise *------- */ LRESULT CALLBACK ConfigDlgProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { LPSETUPDLG lpsetupdlg; ConnInfo *ci; DWORD cmd; char strbuf[64]; switch (wMsg) { /* Initialize the dialog */ case WM_INITDIALOG: lpsetupdlg = (LPSETUPDLG) lParam; ci = &lpsetupdlg->ci; /* Hide the driver connect message */ ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE); LoadString(s_hModule, IDS_ADVANCE_SAVE, strbuf, sizeof(strbuf)); SetWindowText(GetDlgItem(hdlg, IDOK), strbuf); SetWindowLongPtr(hdlg, DWLP_USER, lParam); CenterDialog(hdlg); /* Center dialog */ /* Initialize dialog fields */ SetDlgStuff(hdlg, ci); /* Save drivername */ if (!(lpsetupdlg->ci.drivername[0])) STRCPY_FIXED(lpsetupdlg->ci.drivername, lpsetupdlg->lpszDrvr); if (lpsetupdlg->fNewDSN || !ci->dsn[0]) ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE); if (lpsetupdlg->fDefault) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } else SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L); return TRUE; /* Focus was not set */ /* Process buttons */ case WM_COMMAND: lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER); switch (cmd = GET_WM_COMMAND_ID(wParam, lParam)) { /* * Ensure the OK button is enabled only when a data * source name */ /* is entered */ case IDC_DSNAME: if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) { char szItem[MAXDSNAME]; /* Edit control text */ /* Enable/disable the OK button */ EnableWindow(GetDlgItem(hdlg, IDOK), GetDlgItemText(hdlg, IDC_DSNAME, szItem, sizeof(szItem))); return TRUE; } break; /* Accept results */ case IDOK: case IDAPPLY: /* Retrieve dialog values */ if (!lpsetupdlg->fDefault) GetDlgItemText(hdlg, IDC_DSNAME, lpsetupdlg->ci.dsn, sizeof(lpsetupdlg->ci.dsn)); /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); /* Update ODBC.INI */ SetDSNAttributes(hdlg, lpsetupdlg, NULL); if (IDAPPLY == cmd) break; /* Return to caller */ case IDCANCEL: EndDialog(hdlg, wParam); return TRUE; case IDC_TEST: { if (NULL != lpsetupdlg) { /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); test_connection(lpsetupdlg->hwndParent, &lpsetupdlg->ci, FALSE); return TRUE; } break; } case IDC_DATASOURCE: /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), hdlg, ds_options1Proc, (LPARAM) &lpsetupdlg->ci); return TRUE; case IDC_DRIVER: /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL), hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci); return TRUE; case IDC_MANAGEDSN: if (DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_DRIVER_CHANGE), hdlg, manage_dsnProc, (LPARAM) lpsetupdlg) > 0) EndDialog(hdlg, 0); return TRUE; } break; case WM_CTLCOLORSTATIC: if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER)) { HBRUSH hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH); SetTextColor((HDC)wParam, RGB(255, 0, 0)); return (LRESULT)hBrush; } break; } /* Message not processed */ return FALSE; } #ifdef USE_PROC_ADDRESS #define SQLALLOCHANDLEFUNC sqlallochandle #define SQLSETENVATTRFUNC sqlsetenvattr #define SQLDISCONNECTFUNC sqldisconnect #define SQLFREEHANDLEFUNC sqlfreehandle #ifdef UNICODE_SUPPORT #define SQLGETDIAGRECFUNC sqlgetdiagrecw #define SQLDRIVERCONNECTFUNC sqldriverconnectw #define SQLSETCONNECTATTRFUNC sqlsetconnectattrw #else #define SQLGETDIAGRECFUNC sqlgetdiagrec #define SQLDRIVERCONNECTFUNC sqldriverconnect #define SQLSETCONNECTATTRFUNC sqlsetconnectAttr #endif /* UNICODE_SUPPORT */ #else #define SQLALLOCHANDLEFUNC SQLAllocHandle #define SQLSETENVATTRFUNC SQLSetEnvAttr #define SQLDISCONNECTFUNC SQLDisconnect #define SQLFREEHANDLEFUNC SQLFreeHandle #ifdef UNICODE_SUPPORT #define SQLGETDIAGRECFUNC SQLGetDiagRecW #define SQLDRIVERCONNECTFUNC SQLDriverConnectW #define SQLSETCONNECTATTRFUNC SQLSetConnectAttrW #else #define SQLGETDIAGRECFUNC SQLGetDiagRec #define SQLDRIVERCONNECTFUNC SQLDriverConnect #define SQLSETCONNECTATTRFUNC SQLSetConnectAttr #endif /* UNICODE_SUPPORT */ #endif /* USE_PROC_ADDRESS */ #define MAX_CONNECT_STRING_LEN 2048 #ifdef UNICODE_SUPPORT #define MESSAGEBOXFUNC MessageBoxW #define _T(str) L ## str #define SNTPRINTF _snwprintf #else #define MESSAGEBOXFUNC MessageBoxA #define _T(str) str #define SNTPRINTF snprintf #endif /* UNICODE_SUPPORT */ void test_connection(HANDLE hwnd, ConnInfo *ci, BOOL withDTC) { int errnum; char out_conn[MAX_CONNECT_STRING_LEN]; SQLRETURN ret; SQLHENV env = SQL_NULL_HANDLE; SQLHDBC conn = SQL_NULL_HANDLE; SQLSMALLINT str_len; char dsn_1st; BOOL connected = FALSE; #ifdef UNICODE_SUPPORT SQLWCHAR wout_conn[MAX_CONNECT_STRING_LEN]; SQLWCHAR szMsg[SQL_MAX_MESSAGE_LENGTH]; const SQLWCHAR *ermsg = NULL; SQLWCHAR *conn_str; #else SQLCHAR szMsg[SQL_MAX_MESSAGE_LENGTH]; const SQLCHAR *ermsg = NULL; SQLCHAR *conn_str; #endif /* UNICODE_SUPPORT */ dsn_1st = ci->dsn[0]; ci->dsn[0] = '\0'; if (NAME_IS_VALID(ci->conn_settings)) ci->conn_settings_in_str = TRUE; if (NAME_IS_VALID(ci->pqopt)) ci->pqopt_in_str = TRUE; makeConnectString(out_conn, ci, sizeof(out_conn)); MYLOG(0, "conn_string=%s\n", out_conn); #ifdef UNICODE_SUPPORT MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, out_conn, -1, wout_conn, sizeof(wout_conn) / sizeof(wout_conn[0])); conn_str = wout_conn; #else conn_str = out_conn; #endif /* UNICODE_SUPPORT */ ci->dsn[0] = dsn_1st; if (!SQL_SUCCEEDED(ret = SQLALLOCHANDLEFUNC(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env))) { ermsg = _T("SQLAllocHandle for env error"); goto cleanup; } if (!SQL_SUCCEEDED(ret = SQLSETENVATTRFUNC(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0))) { SNTPRINTF(szMsg, _countof(szMsg), _T("SQLAllocHandle for env error=%d"), ret); goto cleanup; } if (!SQL_SUCCEEDED(ret = SQLALLOCHANDLEFUNC(SQL_HANDLE_DBC, env, &conn))) { SQLGETDIAGRECFUNC(SQL_HANDLE_ENV, env, 1, NULL, &errnum, szMsg, _countof(szMsg), &str_len); ermsg = szMsg; goto cleanup; } if (!SQL_SUCCEEDED(ret = SQLDRIVERCONNECTFUNC(conn, hwnd, conn_str, SQL_NTS, NULL, MAX_CONNECT_STRING_LEN, &str_len, SQL_DRIVER_NOPROMPT))) { SQLGETDIAGRECFUNC(SQL_HANDLE_DBC, conn, 1, NULL, &errnum, szMsg, _countof(szMsg), &str_len); ermsg = szMsg; goto cleanup; } connected = TRUE; ermsg = _T("Connection successful"); if (withDTC) { #ifdef _HANDLE_ENLIST_IN_DTC_ HRESULT res; void *pObj = NULL; pObj = CALL_GetTransactionObject(&res); if (NULL != pObj) { SQLRETURN ret = SQLSETCONNECTATTRFUNC(conn, SQL_ATTR_ENLIST_IN_DTC, (SQLPOINTER) pObj, 0); if (SQL_SUCCEEDED(ret)) { SQLSETCONNECTATTRFUNC(conn, SQL_ATTR_ENLIST_IN_DTC, SQL_DTC_DONE, 0); SNTPRINTF(szMsg, _countof(szMsg), _T("%s\nenlistment was successful\n"), ermsg); ermsg = szMsg; } else { int strl; SNTPRINTF(szMsg, _countof(szMsg), _T("%s\nMSDTC error:"), ermsg); for (strl = 0; strl < SQL_MAX_MESSAGE_LENGTH; strl++) { if (!szMsg[strl]) break; } SQLGETDIAGRECFUNC(SQL_HANDLE_DBC, conn, 1, NULL, &errnum, szMsg + strl, _countof(szMsg) - strl, &str_len); ermsg = szMsg; } CALL_ReleaseTransactionObject(pObj); } else if (FAILED(res)) { SNTPRINTF(szMsg, _countof(szMsg), _T("%s\nDistibuted Transaction enlistment error %x"), ermsg, res); ermsg = szMsg; } #else /* _HANDLE_ENLIST_IN_DTC_ */ SNTPRINTF(szMsg, _countof(szMsg), _T("%s\nDistibuted Transaction enlistment not supported by this driver"), ermsg); ermsg = szMsg; #endif } cleanup: if (NULL != ermsg && NULL != hwnd) { MESSAGEBOXFUNC(hwnd, ermsg, _T("Connection Test"), MB_ICONEXCLAMATION | MB_OK); } #undef _T if (NULL != conn) { if (connected) SQLDISCONNECTFUNC(conn); SQLFREEHANDLEFUNC(SQL_HANDLE_DBC, conn); } if (env) SQLFREEHANDLEFUNC(SQL_HANDLE_ENV, env); return; } /*------- * ParseAttributes * * Description: Parse attribute string moving values into the aAttr array * Input : lpszAttributes - Pointer to attribute string * Output : None (global aAttr normally updated) *------- */ static void ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg) { LPCSTR lpsz; LPCSTR lpszStart; char aszKey[MAXKEYLEN]; size_t cbKey; char value[MAXPGPATH]; for (lpsz = lpszAttributes; *lpsz; lpsz++) { /* * Extract key name (e.g., DSN), it must be terminated by an * equals */ lpszStart = lpsz; for (;; lpsz++) { if (!*lpsz) return; /* No key was found */ else if (*lpsz == '=') break; /* Valid key found */ } /* Determine the key's index in the key table (-1 if not found) */ cbKey = lpsz - lpszStart; if (cbKey < sizeof(aszKey)) { memcpy(aszKey, lpszStart, cbKey); aszKey[cbKey] = '\0'; } /* Locate end of key value */ lpszStart = ++lpsz; for (; *lpsz; lpsz++) ; /* lpsetupdlg->aAttr[iElement].fSupplied = TRUE; */ memcpy(value, lpszStart, MIN(lpsz - lpszStart + 1, MAXPGPATH)); MYLOG(0, "aszKey='%s', value='%s'\n", aszKey, value); /* Copy the appropriate value to the conninfo */ copyConnAttributes(&lpsetupdlg->ci, aszKey, value); } return; } /*-------- * SetDSNAttributes * * Description: Write data source attributes to ODBC.INI * Input : hwnd - Parent window handle (plus globals) * Output : TRUE if successful, FALSE otherwise *-------- */ static BOOL SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg, DWORD *errcode) { LPCSTR lpszDSN; /* Pointer to data source name */ lpszDSN = lpsetupdlg->ci.dsn; if (errcode) *errcode = 0; /* Validate arguments */ if (lpsetupdlg->fNewDSN && !*lpsetupdlg->ci.dsn) return FALSE; /* Write the data source name */ if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr)) { RETCODE ret = SQL_ERROR; DWORD err = SQL_ERROR; char szMsg[SQL_MAX_MESSAGE_LENGTH]; ret = SQLInstallerError(1, &err, szMsg, sizeof(szMsg), NULL); if (hwndParent) { char szBuf[MAXPGPATH]; if (SQL_SUCCESS != ret) { LoadString(s_hModule, IDS_BADDSN, szBuf, sizeof(szBuf)); SPRINTF_FIXED(szMsg, szBuf, lpszDSN); } LoadString(s_hModule, IDS_MSGTITLE, szBuf, sizeof(szBuf)); MessageBox(hwndParent, szMsg, szBuf, MB_ICONEXCLAMATION | MB_OK); } if (errcode) *errcode = err; return FALSE; } /* Update ODBC.INI */ write_Ci_Drivers(ODBC_INI, lpsetupdlg->ci.dsn, &(lpsetupdlg->ci.drivers)); writeDSNinfo(&lpsetupdlg->ci); /* If the data source name has changed, remove the old name */ if (lstrcmpi(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn)) SQLRemoveDSNFromIni(lpsetupdlg->szDSN); return TRUE; } /*-------- * SetDriverAttributes * * Description: Write driver information attributes to ODBCINST.INI * Input : lpszDriver - The driver name * Output : TRUE if successful, FALSE otherwise *-------- */ static BOOL SetDriverAttributes(LPCSTR lpszDriver, DWORD *pErrorCode, LPSTR message, WORD cbMessage) { BOOL ret = FALSE; char ver_string[8]; /* Validate arguments */ if (!lpszDriver || !lpszDriver[0]) { if (pErrorCode) *pErrorCode = ODBC_ERROR_INVALID_NAME; strncpy_null(message, "Driver name not specified", cbMessage); return FALSE; } if (!SQLWritePrivateProfileString(lpszDriver, "APILevel", "1", ODBCINST_INI)) goto cleanup; if (!SQLWritePrivateProfileString(lpszDriver, "ConnectFunctions", "YYN", ODBCINST_INI)) goto cleanup; SPRINTF_FIXED(ver_string, "%02x.%02x", ODBCVER / 256, ODBCVER % 256); if (!SQLWritePrivateProfileString(lpszDriver, "DriverODBCVer", ver_string, ODBCINST_INI)) goto cleanup; if (!SQLWritePrivateProfileString(lpszDriver, "FileUsage", "0", ODBCINST_INI)) goto cleanup; if (!SQLWritePrivateProfileString(lpszDriver, "SQLLevel", "1", ODBCINST_INI)) goto cleanup; ret = TRUE; cleanup: if (!ret) { if (pErrorCode) *pErrorCode = ODBC_ERROR_REQUEST_FAILED; strncpy_null(message, "Failed to WritePrivateProfileString", cbMessage); } return ret; } #ifdef WIN32 BOOL INTFUNC ChangeDriverName(HWND hwndParent, LPSETUPDLG lpsetupdlg, LPCSTR driver_name) { DWORD err = 0; ConnInfo *ci = &lpsetupdlg->ci; if (!ci->dsn[0]) { err = IDS_BADDSN; } else if (!driver_name || strnicmp(driver_name, "postgresql", 10)) { err = IDS_BADDSN; } else { LPCSTR lpszDrvr = lpsetupdlg->lpszDrvr; lpsetupdlg->lpszDrvr = driver_name; if (!SetDSNAttributes(hwndParent, lpsetupdlg, &err)) { if (!err) err = IDS_BADDSN; lpsetupdlg->lpszDrvr = lpszDrvr; } } return (err == 0); } #endif /* WIN32 */ psqlodbc-REL-16_00_0005/statement.c000066400000000000000000002524451462406103600166620ustar00rootroot00000000000000/*------ * Module: statement.c * * Description: This module contains functions related to creating * and manipulating a statement. * * Classes: StatementClass (Functions prefix: "SC_") * * API functions: SQLAllocStmt, SQLFreeStmt * * Comments: See "readme.txt" for copyright and license information. *------- */ #ifdef WIN_MULTITHREAD_SUPPORT #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif /* _WIN32_WINNT */ #endif /* WIN_MULTITHREAD_SUPPORT */ #include "statement.h" #include "misc.h" // strncpy_null #include "bind.h" #include "connection.h" #include "multibyte.h" #include "qresult.h" #include "convert.h" #include "environ.h" #include "loadlib.h" #include #include #include #include "pgapifunc.h" /* Map sql commands to statement types */ static const struct { int type; char *s; } Statement_Type[] = { { STMT_TYPE_SELECT, "SELECT" } ,{ STMT_TYPE_INSERT, "INSERT" } ,{ STMT_TYPE_UPDATE, "UPDATE" } ,{ STMT_TYPE_DELETE, "DELETE" } ,{ STMT_TYPE_PROCCALL, "CALL" } ,{ STMT_TYPE_PROCCALL, "{" } ,{ STMT_TYPE_SET, "SET" } ,{ STMT_TYPE_RESET, "RESET" } ,{ STMT_TYPE_CREATE, "CREATE" } ,{ STMT_TYPE_DECLARE, "DECLARE" } ,{ STMT_TYPE_FETCH, "FETCH" } ,{ STMT_TYPE_MOVE, "MOVE" } ,{ STMT_TYPE_CLOSE, "CLOSE" } ,{ STMT_TYPE_PREPARE, "PREPARE" } ,{ STMT_TYPE_EXECUTE, "EXECUTE" } ,{ STMT_TYPE_DEALLOCATE, "DEALLOCATE" } ,{ STMT_TYPE_DROP, "DROP" } ,{ STMT_TYPE_START, "BEGIN" } ,{ STMT_TYPE_START, "START" } ,{ STMT_TYPE_TRANSACTION, "SAVEPOINT" } ,{ STMT_TYPE_TRANSACTION, "RELEASE" } ,{ STMT_TYPE_TRANSACTION, "COMMIT" } ,{ STMT_TYPE_TRANSACTION, "END" } ,{ STMT_TYPE_TRANSACTION, "ROLLBACK" } ,{ STMT_TYPE_TRANSACTION, "ABORT" } ,{ STMT_TYPE_LOCK, "LOCK" } ,{ STMT_TYPE_ALTER, "ALTER" } ,{ STMT_TYPE_GRANT, "GRANT" } ,{ STMT_TYPE_REVOKE, "REVOKE" } ,{ STMT_TYPE_COPY, "COPY" } ,{ STMT_TYPE_ANALYZE, "ANALYZE" } ,{ STMT_TYPE_NOTIFY, "NOTIFY" } ,{ STMT_TYPE_EXPLAIN, "EXPLAIN" } /* * Special-commands that cannot be run in a transaction block. This isn't * as granular as it could be. VACUUM can never be run in a transaction * block, but some variants of REINDEX and CLUSTER can be. CHECKPOINT * doesn't throw an error if you do, but it cannot be rolled back so * there's no point in beginning a new transaction for it. */ ,{ STMT_TYPE_SPECIAL, "VACUUM" } ,{ STMT_TYPE_SPECIAL, "REINDEX" } ,{ STMT_TYPE_SPECIAL, "CLUSTER" } ,{ STMT_TYPE_SPECIAL, "CHECKPOINT" } ,{ STMT_TYPE_WITH, "WITH" } ,{ 0, NULL } }; static QResultClass *libpq_bind_and_exec(StatementClass *stmt); static void SC_set_errorinfo(StatementClass *self, QResultClass *res, int errkind); static void SC_set_error_if_not_set(StatementClass *self, int errornumber, const char *errmsg, const char *func); RETCODE SQL_API PGAPI_AllocStmt(HDBC hdbc, HSTMT * phstmt, UDWORD flag) { CSTR func = "PGAPI_AllocStmt"; ConnectionClass *conn = (ConnectionClass *) hdbc; StatementClass *stmt; ARDFields *ardopts; MYLOG(0, "entering...\n"); if (!conn) { CC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } stmt = SC_Constructor(conn); MYLOG(0, "**** : hdbc = %p, stmt = %p\n", hdbc, stmt); if (!stmt) { CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "No more memory to allocate a further SQL-statement", func); *phstmt = SQL_NULL_HSTMT; return SQL_ERROR; } if (!CC_add_statement(conn, stmt)) { CC_set_error(conn, CONN_STMT_ALLOC_ERROR, "Maximum number of statements exceeded.", func); SC_Destructor(stmt); *phstmt = SQL_NULL_HSTMT; return SQL_ERROR; } *phstmt = (HSTMT) stmt; stmt->iflag = flag; /* Copy default statement options based from Connection options */ if (0 != (PODBC_INHERIT_CONNECT_OPTIONS & flag)) { stmt->options = stmt->options_orig = conn->stmtOptions; stmt->ardi.ardf = conn->ardOptions; } else { InitializeStatementOptions(&stmt->options_orig); stmt->options = stmt->options_orig; InitializeARDFields(&stmt->ardi.ardf); } ardopts = SC_get_ARDF(stmt); ARD_AllocBookmark(ardopts); /* Save the handle for later */ stmt->phstmt = phstmt; return SQL_SUCCESS; } RETCODE SQL_API PGAPI_FreeStmt(HSTMT hstmt, SQLUSMALLINT fOption) { CSTR func = "PGAPI_FreeStmt"; StatementClass *stmt = (StatementClass *) hstmt; MYLOG(0, "entering...hstmt=%p, fOption=%hi\n", hstmt, fOption); if (!stmt) { SC_log_error(func, "", NULL); return SQL_INVALID_HANDLE; } SC_clear_error(stmt); if (fOption == SQL_DROP) { ConnectionClass *conn = stmt->hdbc; /* Remove the statement from the connection's statement list */ if (conn) { QResultClass *res; if (STMT_EXECUTING == stmt->status) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction.", func); return SQL_ERROR; /* stmt may be executing a transaction */ } if (conn->unnamed_prepared_stmt == stmt) conn->unnamed_prepared_stmt = NULL; /* * Free any cursors and discard any result info. * Don't detach the statement from the connection * before freeing the associated cursors. Otherwise * CC_cursor_count() would get wrong results. */ if (stmt->parsed) { QR_Destructor(stmt->parsed); stmt->parsed = NULL; } res = SC_get_Result(stmt); QR_Destructor(res); SC_init_Result(stmt); if (!CC_remove_statement(conn, stmt)) { SC_set_error(stmt, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction.", func); return SQL_ERROR; /* stmt may be executing a * transaction */ } } if (stmt->execute_delegate) { PGAPI_FreeStmt(stmt->execute_delegate, SQL_DROP); stmt->execute_delegate = NULL; } if (stmt->execute_parent) stmt->execute_parent->execute_delegate = NULL; /* Destroy the statement and free any results, cursors, etc. */ SC_Destructor(stmt); } else if (fOption == SQL_UNBIND) SC_unbind_cols(stmt); else if (fOption == SQL_CLOSE) { /* * this should discard all the results, but leave the statement * itself in place (it can be executed again) */ stmt->transition_status = STMT_TRANSITION_ALLOCATED; if (stmt->execute_delegate) { PGAPI_FreeStmt(stmt->execute_delegate, SQL_DROP); stmt->execute_delegate = NULL; } if (!SC_recycle_statement(stmt)) { return SQL_ERROR; } SC_set_Curres(stmt, NULL); } else if (fOption == SQL_RESET_PARAMS) SC_free_params(stmt, STMT_FREE_PARAMS_ALL); else { SC_set_error(stmt, STMT_OPTION_OUT_OF_RANGE_ERROR, "Invalid option passed to PGAPI_FreeStmt.", func); return SQL_ERROR; } return SQL_SUCCESS; } /* * StatementClass implementation */ void InitializeStatementOptions(StatementOptions *opt) { memset(opt, 0, sizeof(StatementOptions)); opt->scroll_concurrency = SQL_CONCUR_READ_ONLY; opt->cursor_type = SQL_CURSOR_FORWARD_ONLY; opt->retrieve_data = SQL_RD_ON; opt->use_bookmarks = SQL_UB_OFF; opt->metadata_id = SQL_FALSE; } static void SC_clear_parse_status(StatementClass *self, ConnectionClass *conn) { self->parse_status = STMT_PARSE_NONE; } static void SC_init_discard_output_params(StatementClass *self) { ConnectionClass *conn = SC_get_conn(self); if (!conn) return; self->discard_output_params = 0; if (!conn->connInfo.use_server_side_prepare) self->discard_output_params = 1; } static void SC_init_parse_method(StatementClass *self) { ConnectionClass *conn = SC_get_conn(self); self->parse_method = 0; if (!conn) return; if (0 == (PODBC_EXTERNAL_STATEMENT & self->iflag)) return; if (self->catalog_result) return; if (conn->connInfo.drivers.parse) SC_set_parse_forced(self); } StatementClass * SC_Constructor(ConnectionClass *conn) { StatementClass *rv; rv = (StatementClass *) malloc(sizeof(StatementClass)); if (rv) { rv->hdbc = conn; rv->phstmt = NULL; rv->rhold.first = rv->rhold.last = NULL; rv->curres = NULL; rv->parsed = NULL; rv->catalog_result = FALSE; rv->prepare = NON_PREPARE_STATEMENT; rv->prepared = NOT_YET_PREPARED; rv->status = STMT_ALLOCATED; rv->external = FALSE; rv->iflag = 0; rv->plan_name = NULL; rv->transition_status = STMT_TRANSITION_UNALLOCATED; rv->multi_statement = -1; /* unknown */ rv->num_params = -1; /* unknown */ rv->processed_statements = NULL; rv->__error_message = NULL; rv->__error_number = 0; rv->pgerror = NULL; rv->statement = NULL; rv->stmt_with_params = NULL; rv->load_statement = NULL; rv->statement_type = STMT_TYPE_UNKNOWN; rv->currTuple = -1; rv->rowset_start = 0; SC_set_rowset_start(rv, -1, FALSE); rv->current_col = -1; rv->bind_row = 0; rv->from_pos = rv->load_from_pos = rv->where_pos = -1; rv->last_fetch_count = rv->last_fetch_count_include_ommitted = 0; rv->save_rowset_size = -1; rv->data_at_exec = -1; rv->current_exec_param = -1; rv->exec_start_row = -1; rv->exec_end_row = -1; rv->exec_current_row = -1; rv->put_data = FALSE; rv->ref_CC_error = FALSE; rv->join_info = 0; SC_init_parse_method(rv); rv->lobj_fd = -1; INIT_NAME(rv->cursor_name); /* Parse Stuff */ rv->ti = NULL; rv->ntab = 0; rv->num_key_fields = -1; /* unknown */ SC_clear_parse_status(rv, conn); rv->proc_return = -1; SC_init_discard_output_params(rv); rv->cancel_info = 0; /* Clear Statement Options -- defaults will be set in AllocStmt */ memset(&rv->options, 0, sizeof(StatementOptions)); InitializeEmbeddedDescriptor((DescriptorClass *)&(rv->ardi), rv, SQL_ATTR_APP_ROW_DESC); InitializeEmbeddedDescriptor((DescriptorClass *)&(rv->apdi), rv, SQL_ATTR_APP_PARAM_DESC); InitializeEmbeddedDescriptor((DescriptorClass *)&(rv->irdi), rv, SQL_ATTR_IMP_ROW_DESC); InitializeEmbeddedDescriptor((DescriptorClass *)&(rv->ipdi), rv, SQL_ATTR_IMP_PARAM_DESC); rv->miscinfo = 0; rv->execinfo = 0; rv->rb_or_tc = 0; SC_reset_updatable(rv); rv->diag_row_count = 0; rv->stmt_time = 0; rv->execute_delegate = NULL; rv->execute_parent = NULL; rv->allocated_callbacks = 0; rv->num_callbacks = 0; rv->callbacks = NULL; GetDataInfoInitialize(SC_get_GDTI(rv)); PutDataInfoInitialize(SC_get_PDTI(rv)); rv->use_server_side_prepare = conn->connInfo.use_server_side_prepare; rv->lock_CC_for_rb = FALSE; // for batch execution memset(&rv->stmt_deffered, 0, sizeof(rv->stmt_deffered)); if ((rv->batch_size = conn->connInfo.batch_size) < 1) rv->batch_size = 1; rv->exec_type = DIRECT_EXEC; rv->count_of_deffered = 0; rv->has_notice = 0; INIT_STMT_CS(rv); } return rv; } char SC_Destructor(StatementClass *self) { CSTR func = "SC_Destructor"; QResultClass *res = SC_get_Result(self); MYLOG(0, "entering self=%p, self->result=%p, self->hdbc=%p\n", self, res, self->hdbc); SC_clear_error(self); if (STMT_EXECUTING == self->status) { SC_set_error(self, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction.", func); return FALSE; } if (res) { if (!self->hdbc) res->conn = NULL; /* prevent any dbase activity */ QR_Destructor(res); } if (self->parsed) { QR_Destructor(self->parsed); self->parsed = NULL; } SC_initialize_stmts(self, TRUE); /* Free the parsed table information */ SC_initialize_cols_info(self, FALSE, TRUE); NULL_THE_NAME(self->cursor_name); /* Free the parsed field information */ DC_Destructor((DescriptorClass *) SC_get_ARDi(self)); DC_Destructor((DescriptorClass *) SC_get_APDi(self)); DC_Destructor((DescriptorClass *) SC_get_IRDi(self)); DC_Destructor((DescriptorClass *) SC_get_IPDi(self)); GDATA_unbind_cols(SC_get_GDTI(self), TRUE); PDATA_free_params(SC_get_PDTI(self), STMT_FREE_PARAMS_ALL); if (self->__error_message) free(self->__error_message); if (self->pgerror) ER_Destructor(self->pgerror); cancelNeedDataState(self); if (self->callbacks) free(self->callbacks); if (!PQExpBufferDataBroken(self->stmt_deffered)) termPQExpBuffer(&self->stmt_deffered); DELETE_STMT_CS(self); free(self); MYLOG(0, "leaving\n"); return TRUE; } void SC_init_Result(StatementClass *self) { self->rhold.first = self->rhold.last = NULL; self->curres = NULL; MYLOG(0, "leaving(%p)\n", self); } void SC_set_Result(StatementClass *self, QResultClass *first) { if (first != self->rhold.first) { QResultClass *last = NULL, *res; MYLOG(0, "(%p, %p)\n", self, first); QR_Destructor(self->parsed); self->parsed = NULL; QR_Destructor(self->rhold.first); for (res = first; res; res = QR_nextr(res)) last = res; self->curres = first; self->rhold.first = first; self->rhold.last = last; } } void SC_set_ResultHold(StatementClass *self, QResultHold rhold) { if (rhold.first != self->rhold.first) { MYLOG(0, "(%p, {%p, %p})\n", self, rhold.first, rhold.last); QR_Destructor(self->parsed); self->parsed = NULL; QR_Destructor(self->rhold.first); self->curres = rhold.first; self->rhold = rhold; } else if (rhold.last != self->rhold.last) { self->rhold.last = rhold.last; if (QR_nextr(rhold.last) != NULL) SC_set_error(self, STMT_INTERNAL_ERROR, "last Result is not the last result", __FUNCTION__); } } /* * Free parameters and free the memory from the * data-at-execution parameters that was allocated in SQLPutData. */ void SC_free_params(StatementClass *self, char option) { if (option != STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY) { APD_free_params(SC_get_APDF(self), option); IPD_free_params(SC_get_IPDF(self), option); } PDATA_free_params(SC_get_PDTI(self), option); self->data_at_exec = -1; self->current_exec_param = -1; self->put_data = FALSE; if (option == STMT_FREE_PARAMS_ALL) { self->exec_start_row = -1; self->exec_end_row = -1; self->exec_current_row = -1; } } int statement_type(const char *statement) { int i; /* ignore leading whitespace in query string */ while (*statement && (isspace((UCHAR) *statement) || *statement == '(')) statement++; for (i = 0; Statement_Type[i].s; i++) if (!strnicmp(statement, Statement_Type[i].s, strlen(Statement_Type[i].s))) return Statement_Type[i].type; return STMT_TYPE_OTHER; } void SC_set_planname(StatementClass *stmt, const char *plan_name) { if (stmt->plan_name) free(stmt->plan_name); if (plan_name && plan_name[0]) stmt->plan_name = strdup(plan_name); else stmt->plan_name = NULL; } void SC_set_rowset_start(StatementClass *stmt, SQLLEN start, BOOL valid_base) { QResultClass *res = SC_get_Curres(stmt); SQLLEN incr = start - stmt->rowset_start; MYLOG(DETAIL_LOG_LEVEL, "%p->SC_set_rowstart " FORMAT_LEN "->" FORMAT_LEN "(%s) ", stmt, stmt->rowset_start, start, valid_base ? "valid" : "unknown"); if (res != NULL) { BOOL valid = QR_has_valid_base(res); MYPRINTF(DETAIL_LOG_LEVEL, ":(%p)QR is %s", res, QR_has_valid_base(res) ? "valid" : "unknown"); if (valid) { if (valid_base) QR_inc_rowstart_in_cache(res, incr); else QR_set_no_valid_base(res); } else if (valid_base) { QR_set_has_valid_base(res); if (start < 0) QR_set_rowstart_in_cache(res, -1); else QR_set_rowstart_in_cache(res, start); } if (!QR_get_cursor(res)) res->key_base = start; MYPRINTF(DETAIL_LOG_LEVEL, ":(%p)QR result=" FORMAT_LEN "(%s)", res, QR_get_rowstart_in_cache(res), QR_has_valid_base(res) ? "valid" : "unknown"); } stmt->rowset_start = start; MYPRINTF(DETAIL_LOG_LEVEL, ":stmt result=" FORMAT_LEN "\n", stmt->rowset_start); } void SC_inc_rowset_start(StatementClass *stmt, SQLLEN inc) { SQLLEN start = stmt->rowset_start + inc; SC_set_rowset_start(stmt, start, TRUE); } int SC_set_current_col(StatementClass *stmt, int col) { if (col == stmt->current_col) return col; if (col >= 0) reset_a_getdata_info(SC_get_GDTI(stmt), col + 1); stmt->current_col = col; return stmt->current_col; } void SC_set_prepared(StatementClass *stmt, int prepared) { if (prepared == stmt->prepared) ; else if (NOT_YET_PREPARED == prepared && PREPARED_PERMANENTLY == stmt->prepared) { ConnectionClass *conn = SC_get_conn(stmt); if (conn) { ENTER_CONN_CS(conn); if (CONN_CONNECTED == conn->status) { if (CC_is_in_error_trans(conn)) { CC_mark_a_object_to_discard(conn, 's', stmt->plan_name); } else { QResultClass *res; char dealloc_stmt[128]; SPRINTF_FIXED(dealloc_stmt, "DEALLOCATE \"%s\"", stmt->plan_name); res = CC_send_query(conn, dealloc_stmt, NULL, IGNORE_ABORT_ON_CONN | ROLLBACK_ON_ERROR, NULL); QR_Destructor(res); } } LEAVE_CONN_CS(conn); } } if (NOT_YET_PREPARED == prepared) SC_set_planname(stmt, NULL); stmt->prepared = prepared; } /* * Initialize stmt_with_params and load_statement member pointer * deallocating corresponding prepared plan. Also initialize * statement member pointer if specified. */ RETCODE SC_initialize_stmts(StatementClass *self, BOOL initializeOriginal) { ProcessedStmt *pstmt; ProcessedStmt *next_pstmt; ConnectionClass *conn = SC_get_conn(self); if (self->lock_CC_for_rb) { if (conn) LEAVE_CONN_CS(conn); self->lock_CC_for_rb = FALSE; } if (initializeOriginal) { if (self->statement) { free(self->statement); self->statement = NULL; } pstmt = self->processed_statements; while (pstmt) { if (pstmt->query) free(pstmt->query); next_pstmt = pstmt->next; free(pstmt); pstmt = next_pstmt; } self->processed_statements = NULL; self->prepare = NON_PREPARE_STATEMENT; SC_set_prepared(self, NOT_YET_PREPARED); self->statement_type = STMT_TYPE_UNKNOWN; /* unknown */ self->multi_statement = -1; /* unknown */ self->num_params = -1; /* unknown */ self->proc_return = -1; /* unknown */ self->join_info = 0; SC_init_parse_method(self); SC_init_discard_output_params(self); if (conn) self->use_server_side_prepare = conn->connInfo.use_server_side_prepare; } if (self->stmt_with_params) { free(self->stmt_with_params); self->stmt_with_params = NULL; } if (self->load_statement) { free(self->load_statement); self->load_statement = NULL; } self->has_notice = 0; return 0; } BOOL SC_opencheck(StatementClass *self, const char *func) { QResultClass *res; if (!self) return FALSE; if (self->status == STMT_EXECUTING) { SC_set_error(self, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction.", func); return TRUE; } /* * We can dispose the result of Describe-only any time. */ if (self->prepare && self->status == STMT_DESCRIBED) { MYLOG(0, "self->prepare && self->status == STMT_DESCRIBED\n"); return FALSE; } if (res = SC_get_Curres(self), NULL != res) { if (QR_command_maybe_successful(res) && res->backend_tuples) { SC_set_error(self, STMT_SEQUENCE_ERROR, "The cursor is open.", func); return TRUE; } } return FALSE; } RETCODE SC_initialize_and_recycle(StatementClass *self) { SC_initialize_stmts(self, TRUE); if (!SC_recycle_statement(self)) return SQL_ERROR; return SQL_SUCCESS; } void SC_reset_result_for_rerun(StatementClass *self) { QResultClass *res; ColumnInfoClass *flds; if (!self) return; if (res = SC_get_Result(self), NULL == res) return; flds = QR_get_fields(res); if (NULL == flds || 0 == CI_get_num_fields(flds)) SC_set_Result(self, NULL); else { QR_reset_for_re_execute(res); SC_set_Curres(self, NULL); } } /* * Called from SQLPrepare if STMT_PREMATURE, or * from SQLExecute if STMT_FINISHED, or * from SQLFreeStmt(SQL_CLOSE) */ char SC_recycle_statement(StatementClass *self) { CSTR func = "SC_recycle_statement"; ConnectionClass *conn; MYLOG(0, "entering self=%p\n", self); SC_clear_error(self); /* This would not happen */ if (self->status == STMT_EXECUTING) { SC_set_error(self, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction.", func); return FALSE; } if (SC_get_conn(self)->unnamed_prepared_stmt == self) SC_get_conn(self)->unnamed_prepared_stmt = NULL; conn = SC_get_conn(self); switch (self->status) { case STMT_ALLOCATED: /* this statement does not need to be recycled */ return TRUE; case STMT_READY: break; case STMT_DESCRIBED: break; case STMT_FINISHED: break; default: SC_set_error(self, STMT_INTERNAL_ERROR, "An internal error occurred while recycling statements", func); return FALSE; } switch (self->prepared) { case NOT_YET_PREPARED: case PREPARED_TEMPORARILY: /* Free the parsed table/field information */ SC_initialize_cols_info(self, TRUE, TRUE); MYLOG(DETAIL_LOG_LEVEL, "SC_clear_parse_status\n"); SC_clear_parse_status(self, conn); break; } /* Free any cursors */ if (SC_get_Result(self)) SC_set_Result(self, NULL); QR_Destructor(self->parsed); self->parsed = NULL; self->miscinfo = 0; self->execinfo = 0; /* self->rbonerr = 0; Never clear the bits here */ /* * Reset only parameters that have anything to do with results */ self->status = STMT_READY; self->catalog_result = FALSE; /* not very important */ self->currTuple = -1; SC_set_rowset_start(self, -1, FALSE); SC_set_current_col(self, -1); self->bind_row = 0; MYLOG(DETAIL_LOG_LEVEL, "statement=%p ommitted=0\n", self); self->last_fetch_count = self->last_fetch_count_include_ommitted = 0; self->__error_message = NULL; self->__error_number = 0; self->lobj_fd = -1; SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY); SC_initialize_stmts(self, FALSE); cancelNeedDataState(self); self->cancel_info = 0; /* * reset the current attr setting to the original one. */ self->options.scroll_concurrency = self->options_orig.scroll_concurrency; self->options.cursor_type = self->options_orig.cursor_type; self->options.keyset_size = self->options_orig.keyset_size; self->options.maxLength = self->options_orig.maxLength; self->options.maxRows = self->options_orig.maxRows; return TRUE; } /* * Scan the query wholly or partially (if the next_cmd param specified). * Also count the number of parameters respectviely. */ void SC_scanQueryAndCountParams(const char *query, const ConnectionClass *conn, ssize_t *next_cmd, SQLSMALLINT * pcpar, po_ind_t *multi_st, po_ind_t *proc_return) { const char *tstr, *tag = NULL; size_t taglen = 0; char tchar, bchar, escape_in_literal = '\0'; char in_literal = FALSE, in_ident_keyword = FALSE, in_dquote_identifier = FALSE, in_dollar_quote = FALSE, in_escape = FALSE, in_line_comment = FALSE, del_found = FALSE; int comment_level = 0; po_ind_t multi = FALSE; SQLSMALLINT num_p; encoded_str encstr; MYLOG(0, "entering...\n"); num_p = 0; if (proc_return) *proc_return = 0; if (next_cmd) *next_cmd = -1; tstr = query; make_encoded_str(&encstr, conn, tstr); for (bchar = '\0', tchar = encoded_nextchar(&encstr); tchar; tchar = encoded_nextchar(&encstr)) { if (MBCS_NON_ASCII(encstr)) /* multibyte char */ { if ((UCHAR) tchar >= 0x80) bchar = tchar; if (in_dquote_identifier || in_literal || in_dollar_quote || in_escape || in_line_comment || comment_level > 0) ; else in_ident_keyword = TRUE; continue; } if (!multi && del_found) { if (IS_NOT_SPACE(tchar)) { multi = TRUE; if (next_cmd) break; } } if (in_ident_keyword) { if (isalnum(tchar) || DOLLAR_QUOTE == tchar || '_' == tchar) { bchar = tchar; continue; } in_ident_keyword = FALSE; } if (in_dollar_quote) { if (tchar == DOLLAR_QUOTE) { if (strncmp((const char *) ENCODE_PTR(encstr), tag, taglen) == 0) { in_dollar_quote = FALSE; tag = NULL; encoded_position_shift(&encstr, taglen - 1); } } } else if (in_literal) { if (in_escape) in_escape = FALSE; else if (tchar == escape_in_literal) in_escape = TRUE; else if (tchar == LITERAL_QUOTE) in_literal = FALSE; } else if (in_dquote_identifier) { if (tchar == IDENTIFIER_QUOTE) in_dquote_identifier = FALSE; } else if (in_line_comment) { if (PG_LINEFEED == tchar) in_line_comment = FALSE; } else if (comment_level > 0) { if ('/' == tchar && '*' == ENCODE_PTR(encstr)[1]) { tchar = encoded_nextchar(&encstr); comment_level++; } else if ('*' == tchar && '/' == ENCODE_PTR(encstr)[1]) { tchar = encoded_nextchar(&encstr); comment_level--; } } else if (isalnum(tchar)) in_ident_keyword = TRUE; else { if (tchar == '?') { if (0 == num_p && bchar == '{') { if (proc_return) *proc_return = 1; } num_p++; } else if (tchar == ';') { del_found = TRUE; if (next_cmd) *next_cmd = encstr.pos; } else if (tchar == DOLLAR_QUOTE) { const char *ptr = (const char *) ENCODE_PTR(encstr); taglen = findTag(ptr, encstr.ccsc); if (taglen > 0) { in_dollar_quote = TRUE; tag = ptr; encoded_position_shift(&encstr, taglen - 1); } } else if (tchar == LITERAL_QUOTE) { in_literal = TRUE; escape_in_literal = CC_get_escape(conn); if (!escape_in_literal) { if (LITERAL_EXT == ENCODE_PTR(encstr)[-1]) escape_in_literal = ESCAPE_IN_LITERAL; } } else if (tchar == IDENTIFIER_QUOTE) in_dquote_identifier = TRUE; else if ('-' == tchar) { if ('-' == ENCODE_PTR(encstr)[1]) { tchar = encoded_nextchar(&encstr); in_line_comment = TRUE; } } else if ('/' == tchar) { if ('*' == ENCODE_PTR(encstr)[1]) { tchar = encoded_nextchar(&encstr); comment_level++; } } if (IS_NOT_SPACE(tchar)) bchar = tchar; } } if (pcpar) *pcpar = num_p; if (multi_st) *multi_st = multi; MYLOG(0, "leaving...num_p=%d multi=%d\n", num_p, multi); } /* * Describe the result set a statement will produce (for * SQLPrepare/SQLDescribeCol) * * returns # of fields if successful, -1 on error. */ Int4 SC_describe(StatementClass *self) { Int4 num_fields = -1; QResultClass *res; MYLOG(0, "entering status = %d\n", self->status); res = SC_get_ExecdOrParsed(self); if (NULL != res) { num_fields = QR_NumResultCols(res); if (num_fields > 0 || NULL != QR_get_command(res)) return num_fields; } if (self->status == STMT_READY) { MYLOG(0, " preprocess: status = READY\n"); self->miscinfo = 0; self->execinfo = 0; decideHowToPrepare(self, FALSE); switch (SC_get_prepare_method(self)) { case NAMED_PARSE_REQUEST: case PARSE_TO_EXEC_ONCE: if (SQL_SUCCESS != prepareParameters(self, FALSE)) return num_fields; break; case PARSE_REQ_FOR_INFO: if (SQL_SUCCESS != prepareParameters(self, FALSE)) return num_fields; self->status = STMT_DESCRIBED; break; default: if (SQL_SUCCESS != prepareParameters(self, TRUE)) return num_fields; self->status = STMT_DESCRIBED; break; } if (res = SC_get_ExecdOrParsed(self), NULL != res) { num_fields = QR_NumResultCols(res); return num_fields; } } return num_fields; } /* This is only called from SQLFreeStmt(SQL_UNBIND) */ char SC_unbind_cols(StatementClass *self) { ARDFields *opts = SC_get_ARDF(self); GetDataInfo *gdata = SC_get_GDTI(self); BindInfoClass *bookmark; ARD_unbind_cols(opts, FALSE); GDATA_unbind_cols(gdata, FALSE); if (bookmark = opts->bookmark, bookmark != NULL) { bookmark->buffer = NULL; bookmark->used = NULL; } return 1; } void SC_clear_error(StatementClass *self) { QResultClass *res; self->__error_number = 0; if (self->__error_message) { free(self->__error_message); self->__error_message = NULL; } if (self->pgerror) { ER_Destructor(self->pgerror); self->pgerror = NULL; } self->diag_row_count = 0; if (res = SC_get_ExecdOrParsed(self), res) { QR_set_message(res, NULL); QR_set_notice(res, NULL); res->sqlstate[0] = '\0'; } self->stmt_time = 0; memset(&self->localtime, 0, sizeof(self->localtime)); self->localtime.tm_sec = -1; SC_unref_CC_error(self); } /* * This function creates an error info which is the concatenation * of the result, statement, connection, and socket messages. */ /* Map sql commands to statement types */ static const struct { int number; const char ver3str[6]; const char ver2str[6]; } Statement_sqlstate[] = { { STMT_ERROR_IN_ROW, "01S01", "01S01" }, { STMT_OPTION_VALUE_CHANGED, "01S02", "01S02" }, { STMT_ROW_VERSION_CHANGED, "01001", "01001" }, /* data changed */ { STMT_POS_BEFORE_RECORDSET, "01S06", "01S06" }, { STMT_TRUNCATED, "01004", "01004" }, /* data truncated */ { STMT_INFO_ONLY, "00000", "00000" }, /* just an information that is returned, no error */ { STMT_OK, "00000", "00000" }, /* OK */ { STMT_EXEC_ERROR, "HY000", "S1000" }, /* also a general error */ { STMT_STATUS_ERROR, "HY010", "S1010" }, { STMT_SEQUENCE_ERROR, "HY010", "S1010" }, /* Function sequence error */ { STMT_NO_MEMORY_ERROR, "HY001", "S1001" }, /* memory allocation failure */ { STMT_COLNUM_ERROR, "07009", "S1002" }, /* invalid column number */ { STMT_NO_STMTSTRING, "HY001", "S1001" }, /* having no stmtstring is also a malloc problem */ { STMT_ERROR_TAKEN_FROM_BACKEND, "HY000", "S1000" }, /* general error */ { STMT_INTERNAL_ERROR, "HY000", "S1000" }, /* general error */ { STMT_STILL_EXECUTING, "HY010", "S1010" }, { STMT_NOT_IMPLEMENTED_ERROR, "HYC00", "S1C00" }, /* == 'driver not * capable' */ { STMT_BAD_PARAMETER_NUMBER_ERROR, "07009", "S1093" }, { STMT_OPTION_OUT_OF_RANGE_ERROR, "HY092", "S1092" }, { STMT_INVALID_COLUMN_NUMBER_ERROR, "07009", "S1002" }, { STMT_RESTRICTED_DATA_TYPE_ERROR, "07006", "07006" }, { STMT_INVALID_CURSOR_STATE_ERROR, "07005", "24000" }, { STMT_CREATE_TABLE_ERROR, "42S01", "S0001" }, /* table already exists */ { STMT_NO_CURSOR_NAME, "S1015", "S1015" }, { STMT_INVALID_CURSOR_NAME, "34000", "34000" }, { STMT_INVALID_ARGUMENT_NO, "HY024", "S1009" }, /* invalid argument value */ { STMT_ROW_OUT_OF_RANGE, "HY107", "S1107" }, { STMT_OPERATION_CANCELLED, "HY008", "S1008" }, { STMT_INVALID_CURSOR_POSITION, "HY109", "S1109" }, { STMT_VALUE_OUT_OF_RANGE, "HY019", "22003" }, { STMT_OPERATION_INVALID, "HY011", "S1011" }, { STMT_PROGRAM_TYPE_OUT_OF_RANGE, "?????", "?????" }, { STMT_BAD_ERROR, "08S01", "08S01" }, /* communication link failure */ { STMT_INVALID_OPTION_IDENTIFIER, "HY092", "HY092" }, { STMT_RETURN_NULL_WITHOUT_INDICATOR, "22002", "22002" }, { STMT_INVALID_DESCRIPTOR_IDENTIFIER, "HY091", "HY091" }, { STMT_OPTION_NOT_FOR_THE_DRIVER, "HYC00", "HYC00" }, { STMT_FETCH_OUT_OF_RANGE, "HY106", "S1106" }, { STMT_COUNT_FIELD_INCORRECT, "07002", "07002" }, { STMT_INVALID_NULL_ARG, "HY009", "S1009" }, { STMT_NO_RESPONSE, "08S01", "08S01" }, { STMT_COMMUNICATION_ERROR, "08S01", "08S01" } }; static PG_ErrorInfo * SC_create_errorinfo(const StatementClass *self, PG_ErrorInfo *pgerror_fail_safe) { QResultClass *res = SC_get_ExecdOrParsed(self); ConnectionClass *conn = SC_get_conn(self); Int4 errornum; size_t pos; BOOL resmsg = FALSE, detailmsg = FALSE, msgend = FALSE; BOOL looponce, loopend; char msg[4096], *wmsg; char *ermsg = NULL, *sqlstate = NULL; PG_ErrorInfo *pgerror; if (self->pgerror) return self->pgerror; errornum = self->__error_number; if (errornum == 0) return NULL; looponce = (SC_get_Result(self) != res); msg[0] = '\0'; for (loopend = FALSE; (NULL != res) && !loopend; res = QR_nextr(res)) { if (looponce) loopend = TRUE; if ('\0' != res->sqlstate[0]) { if (NULL != sqlstate && strnicmp(res->sqlstate, "00", 2) == 0) continue; sqlstate = res->sqlstate; if (!QR_command_maybe_successful(res)) loopend = TRUE; /* if ('0' != sqlstate[0] || '1' < sqlstate[1]) loopend = TRUE; */ } if (NULL != res->message) { STRCPY_FIXED(msg, res->message); detailmsg = resmsg = TRUE; } else if (NULL != res->messageref) { STRCPY_FIXED(msg, res->messageref); detailmsg = resmsg = TRUE; } if (msg[0]) ermsg = msg; else if (QR_get_notice(res)) { char *notice = QR_get_notice(res); size_t len = strlen(notice); if (len < sizeof(msg)) { memcpy(msg, notice, len); msg[len] = '\0'; ermsg = msg; } else { ermsg = notice; msgend = TRUE; } } } if (!msgend && (wmsg = SC_get_errormsg(self)) && wmsg[0]) { pos = strlen(msg); snprintf(&msg[pos], sizeof(msg) - pos, "%s%s", detailmsg ? ";\n" : "", wmsg); ermsg = msg; detailmsg = TRUE; } if (!self->ref_CC_error) msgend = TRUE; if (conn && !msgend) { if (!resmsg && (wmsg = CC_get_errormsg(conn)) && wmsg[0] != '\0') { pos = strlen(msg); snprintf(&msg[pos], sizeof(msg) - pos, ";\n%s", CC_get_errormsg(conn)); } ermsg = msg; } pgerror = ER_Constructor(self->__error_number, ermsg); if (!pgerror) { if (pgerror_fail_safe) { memset(pgerror_fail_safe, 0, sizeof(*pgerror_fail_safe)); pgerror = pgerror_fail_safe; pgerror->status = self->__error_number; pgerror->errorsize = sizeof(pgerror->__error_message); STRCPY_FIXED(pgerror->__error_message, ermsg); pgerror->recsize = -1; } else return NULL; } if (sqlstate) STRCPY_FIXED(pgerror->sqlstate, sqlstate); else if (conn) { if (!msgend && conn->sqlstate[0]) STRCPY_FIXED(pgerror->sqlstate, conn->sqlstate); else { EnvironmentClass *env = (EnvironmentClass *) CC_get_env(conn); errornum -= LOWEST_STMT_ERROR; if (errornum < 0 || errornum >= sizeof(Statement_sqlstate) / sizeof(Statement_sqlstate[0])) { errornum = 1 - LOWEST_STMT_ERROR; } STRCPY_FIXED(pgerror->sqlstate, EN_is_odbc3(env) ? Statement_sqlstate[errornum].ver3str : Statement_sqlstate[errornum].ver2str); } } return pgerror; } StatementClass *SC_get_ancestor(StatementClass *stmt) { StatementClass *child = stmt, *parent; MYLOG(DETAIL_LOG_LEVEL, "entering stmt=%p\n", stmt); for (child = stmt, parent = child->execute_parent; parent; child = parent, parent = child->execute_parent) { MYLOG(DETAIL_LOG_LEVEL, "parent=%p\n", parent); } return child; } void SC_reset_delegate(RETCODE retcode, StatementClass *stmt) { StatementClass *delegate = stmt->execute_delegate; if (!delegate) return; PGAPI_FreeStmt(delegate, SQL_DROP); } void SC_set_error(StatementClass *self, int number, const char *message, const char *func) { if (self->__error_message) free(self->__error_message); self->__error_number = number; self->__error_message = message ? strdup(message) : NULL; if (func && number != STMT_OK && number != STMT_INFO_ONLY) SC_log_error(func, "", self); } void SC_set_errormsg(StatementClass *self, const char *message) { if (self->__error_message) free(self->__error_message); self->__error_message = message ? strdup(message) : NULL; } void SC_replace_error_with_res(StatementClass *self, int number, const char *message, const QResultClass *from_res, BOOL check) { QResultClass *self_res; BOOL repstate; MYLOG(DETAIL_LOG_LEVEL, "entering %p->%p check=%i\n", from_res ,self, check); if (check) { if (0 == number) return; if (0 > number && /* SQL_SUCCESS_WITH_INFO */ 0 < self->__error_number) return; } if (!from_res) return; self->__error_number = number; if (!check || message) { if (self->__error_message) free(self->__error_message); self->__error_message = message ? strdup(message) : NULL; } if (self->pgerror) { ER_Destructor(self->pgerror); self->pgerror = NULL; } self_res = SC_get_ExecdOrParsed(self); if (!self_res) return; if (self_res == from_res) return; QR_add_message(self_res, QR_get_message(from_res)); QR_add_notice(self_res, QR_get_notice(from_res)); repstate = FALSE; if (!check) repstate = TRUE; else if (from_res->sqlstate[0]) { if (!self_res->sqlstate[0] || strncmp(self_res->sqlstate, "00", 2) == 0) repstate = TRUE; else if (strncmp(from_res->sqlstate, "01", 2) >= 0) repstate = TRUE; } if (repstate) STRCPY_FIXED(self_res->sqlstate, from_res->sqlstate); } void SC_error_copy(StatementClass *self, const StatementClass *from, BOOL check) { QResultClass *self_res, *from_res; BOOL repstate; MYLOG(DETAIL_LOG_LEVEL, "entering %p->%p check=%i\n", from ,self, check); if (!from) return; /* for safety */ if (self == from) return; /* for safety */ if (check) { if (0 == from->__error_number) /* SQL_SUCCESS */ return; if (0 > from->__error_number && /* SQL_SUCCESS_WITH_INFO */ 0 < self->__error_number) return; } self->__error_number = from->__error_number; if (!check || from->__error_message) { if (self->__error_message) free(self->__error_message); self->__error_message = from->__error_message ? strdup(from->__error_message) : NULL; } if (self->pgerror) { ER_Destructor(self->pgerror); self->pgerror = NULL; } self_res = SC_get_ExecdOrParsed(self); from_res = SC_get_ExecdOrParsed(from); if (!self_res || !from_res) return; QR_add_message(self_res, QR_get_message(from_res)); QR_add_notice(self_res, QR_get_notice(from_res)); repstate = FALSE; if (!check) repstate = TRUE; else if (from_res->sqlstate[0]) { if (!self_res->sqlstate[0] || strncmp(self_res->sqlstate, "00", 2) == 0) repstate = TRUE; else if (strncmp(from_res->sqlstate, "01", 2) >= 0) repstate = TRUE; } if (repstate) STRCPY_FIXED(self_res->sqlstate, from_res->sqlstate); } void SC_full_error_copy(StatementClass *self, const StatementClass *from, BOOL allres) { PG_ErrorInfo *pgerror; MYLOG(DETAIL_LOG_LEVEL, "entering %p->%p\n", from ,self); if (!from) return; /* for safety */ if (self == from) return; /* for safety */ if (self->__error_message) { free(self->__error_message); self->__error_message = NULL; } if (from->__error_message) self->__error_message = strdup(from->__error_message); self->__error_number = from->__error_number; if (from->pgerror) { if (self->pgerror) ER_Destructor(self->pgerror); self->pgerror = ER_Dup(from->pgerror); return; } else if (!allres) return; pgerror = SC_create_errorinfo(from, NULL); if (!pgerror || !pgerror->__error_message[0]) { ER_Destructor(pgerror); return; } if (self->pgerror) ER_Destructor(self->pgerror); self->pgerror = pgerror; } /* Returns the next SQL error information. */ RETCODE SQL_API PGAPI_StmtError(SQLHSTMT hstmt, SQLSMALLINT RecNumber, SQLCHAR * szSqlState, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT * pcbErrorMsg, UWORD flag) { /* CC: return an error of a hdesc */ PG_ErrorInfo *pgerror, error; StatementClass *stmt = (StatementClass *) hstmt; int errnum = SC_get_errornumber(stmt); if (pgerror = SC_create_errorinfo(stmt, &error), NULL == pgerror) return SQL_NO_DATA_FOUND; if (pgerror != &error) stmt->pgerror = pgerror; if (STMT_NO_MEMORY_ERROR == errnum && !pgerror->__error_message[0]) STRCPY_FIXED(pgerror->__error_message, "Memory Allocation Error??"); return ER_ReturnError(pgerror, RecNumber, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg, flag); } time_t SC_get_time(StatementClass *stmt) { if (!stmt) return time(NULL); if (0 == stmt->stmt_time) stmt->stmt_time = time(NULL); return stmt->stmt_time; } struct tm * SC_get_localtime(StatementClass *stmt) { #ifndef HAVE_LOCALTIME_R struct tm * tim; #endif /* HAVE_LOCALTIME_R */ if (stmt->localtime.tm_sec < 0) { SC_get_time(stmt); #ifdef HAVE_LOCALTIME_R localtime_r(&stmt->stmt_time, &(stmt->localtime)); #else tim = localtime(&stmt->stmt_time); stmt->localtime = *tim; #endif /* HAVE_LOCALTIME_R */ } return &(stmt->localtime); } RETCODE SC_fetch(StatementClass *self) { CSTR func = "SC_fetch"; QResultClass *res = SC_get_Curres(self); ARDFields *opts; GetDataInfo *gdata; int retval; RETCODE result; Int2 num_cols, lf; OID type; int atttypmod; char *value; ColumnInfoClass *coli; BindInfoClass *bookmark; BOOL useCursor; KeySet *keyset = NULL; /* TupleField *tupleField; */ MYLOG(DETAIL_LOG_LEVEL, "entering statement=%p res=%p ommitted=0\n", self, res); self->last_fetch_count = self->last_fetch_count_include_ommitted = 0; if (!res) return SQL_ERROR; coli = QR_get_fields(res); /* the column info */ MYLOG(0, "fetch_cursor=%d, %p->total_read=" FORMAT_LEN "\n", SC_is_fetchcursor(self), res, res->num_total_read); useCursor = (SC_is_fetchcursor(self) && (NULL != QR_get_cursor(res))); if (!useCursor) { if (self->currTuple >= (Int4) QR_get_num_total_tuples(res) - 1 || (self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1)) { /* * if at the end of the tuples, return "no data found" and set * the cursor past the end of the result set */ self->currTuple = QR_get_num_total_tuples(res); return SQL_NO_DATA_FOUND; } MYLOG(0, "**** : non-cursor_result\n"); (self->currTuple)++; } else { /* read from the cache or the physical next tuple */ retval = QR_next_tuple(res, self); if (retval < 0) { MYLOG(0, "**** : end_tuples\n"); if (QR_get_cursor(res) && SQL_CURSOR_FORWARD_ONLY == self->options.cursor_type && QR_once_reached_eof(res)) QR_close(res); return SQL_NO_DATA_FOUND; } else if (retval > 0) (self->currTuple)++; /* all is well */ else { SC_set_errorinfo(self, res, 1); return SQL_ERROR; } } if (QR_haskeyset(res)) { SQLLEN kres_ridx; kres_ridx = GIdx2KResIdx(self->currTuple, self, res); if (kres_ridx >= 0 && kres_ridx < res->num_cached_keys) { UWORD pstatus = res->keyset[kres_ridx].status; MYLOG(DETAIL_LOG_LEVEL, "SC_ pstatus[" FORMAT_LEN "]=%hx fetch_count=" FORMAT_LEN "\n", kres_ridx, pstatus, self->last_fetch_count); if (0 != (pstatus & (CURS_SELF_DELETING | CURS_SELF_DELETED))) return SQL_SUCCESS_WITH_INFO; if (SQL_ROW_DELETED != (pstatus & KEYSET_INFO_PUBLIC) && 0 != (pstatus & CURS_OTHER_DELETED)) { return SQL_SUCCESS_WITH_INFO; } if (0 != (CURS_NEEDS_REREAD & pstatus)) { UWORD qcount; result = SC_pos_reload(self, self->currTuple, &qcount, 0); if (SQL_ERROR == result) return result; pstatus &= ~CURS_NEEDS_REREAD; } keyset = res->keyset + kres_ridx; } } num_cols = QR_NumPublicResultCols(res); result = SQL_SUCCESS; self->last_fetch_count++; MYLOG(DETAIL_LOG_LEVEL, "stmt=%p ommitted++\n", self); self->last_fetch_count_include_ommitted++; opts = SC_get_ARDF(self); /* * If the bookmark column was bound then return a bookmark. Since this * is used with SQLExtendedFetch, and the rowset size may be greater * than 1, and an application can use row or column wise binding, use * the code in copy_and_convert_field() to handle that. */ if ((bookmark = opts->bookmark) && bookmark->buffer) { SC_set_current_col(self, -1); SC_Create_bookmark(self, bookmark, self->bind_row, self->currTuple, keyset); } if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */ return SQL_SUCCESS; /* The following adjustment would be needed after SQLMoreResults() */ if (opts->allocated < num_cols) extend_column_bindings(opts, num_cols); gdata = SC_get_GDTI(self); if (gdata->allocated != opts->allocated) extend_getdata_info(gdata, opts->allocated, TRUE); for (lf = 0; lf < num_cols; lf++) { MYLOG(0, "fetch: cols=%d, lf=%d, opts = %p, opts->bindings = %p, buffer[] = %p\n", num_cols, lf, opts, opts->bindings, opts->bindings[lf].buffer); /* reset for SQLGetData */ GETDATA_RESET(gdata->gdata[lf]); if (NULL == opts->bindings) continue; if (opts->bindings[lf].buffer != NULL) { /* this column has a binding */ /* type = QR_get_field_type(res, lf); */ type = CI_get_oid(coli, lf); /* speed things up */ atttypmod = CI_get_atttypmod(coli, lf); /* speed things up */ MYLOG(0, "type = %d, atttypmod = %d\n", type, atttypmod); if (useCursor) value = QR_get_value_backend(res, lf); else { SQLLEN curt = GIdx2CacheIdx(self->currTuple, self, res); MYLOG(DETAIL_LOG_LEVEL, "%p->base=" FORMAT_LEN " curr=" FORMAT_LEN " st=" FORMAT_LEN " valid=%d\n", res, QR_get_rowstart_in_cache(res), self->currTuple, SC_get_rowset_start(self), QR_has_valid_base(res)); MYLOG(DETAIL_LOG_LEVEL, "curt=" FORMAT_LEN "\n", curt); value = QR_get_value_backend_row(res, curt, lf); } MYLOG(0, "value = '%s'\n", (value == NULL) ? "" : value); retval = copy_and_convert_field_bindinfo(self, type, atttypmod, value, lf); MYLOG(0, "copy_and_convert: retval = %d\n", retval); switch (retval) { case COPY_OK: break; /* OK, do next bound column */ case COPY_UNSUPPORTED_TYPE: SC_set_error(self, STMT_RESTRICTED_DATA_TYPE_ERROR, "Received an unsupported type from Postgres.", func); result = SQL_ERROR; break; case COPY_UNSUPPORTED_CONVERSION: SC_set_error(self, STMT_RESTRICTED_DATA_TYPE_ERROR, "Couldn't handle the necessary data type conversion.", func); result = SQL_ERROR; break; case COPY_RESULT_TRUNCATED: SC_set_error(self, STMT_TRUNCATED, "Fetched item was truncated.", func); MYLOG(DETAIL_LOG_LEVEL, "The %dth item was truncated\n", lf + 1); MYLOG(DETAIL_LOG_LEVEL, "The buffer size = " FORMAT_LEN, opts->bindings[lf].buflen); MYLOG(DETAIL_LOG_LEVEL, " and the value is '%s'\n", value); result = SQL_SUCCESS_WITH_INFO; break; case COPY_INVALID_STRING_CONVERSION: /* invalid string */ SC_set_error(self, STMT_STRING_CONVERSION_ERROR, "invalid string conversion occurred.", func); result = SQL_ERROR; break; /* error msg already filled in */ case COPY_GENERAL_ERROR: result = SQL_ERROR; break; /* This would not be meaningful in SQLFetch. */ case COPY_NO_DATA_FOUND: break; default: SC_set_error(self, STMT_INTERNAL_ERROR, "Unrecognized return value from copy_and_convert_field.", func); result = SQL_ERROR; break; } } } return result; } #include "dlg_specific.h" RETCODE SC_execute(StatementClass *self) { CSTR func = "SC_execute"; ConnectionClass *conn; IPDFields *ipdopts; char was_ok, was_nonfatal; Int2 oldstatus, numcols; QueryInfo qi; ConnInfo *ci; unsigned int qflag = 0; BOOL is_in_trans, issue_begin, has_out_para; BOOL use_extended_protocol; int func_cs_count = 0, i; BOOL useCursor, isSelectType; int errnum_sav = STMT_OK, errnum; char *errmsg_sav = NULL; SQLULEN stmt_timeout; QResultHold rhold = {0}; conn = SC_get_conn(self); ci = &(conn->connInfo); errnum_sav = SC_get_errornumber(self); errmsg_sav = SC_get_errormsg(self); if (NULL != errmsg_sav) errmsg_sav = strdup(errmsg_sav); SC_set_error(self, STMT_OK, NULL, __FUNCTION__); /* Begin a transaction if one is not already in progress */ /* * Basically we don't have to begin a transaction in autocommit mode * because Postgres backend runs in autocomit mode. We issue "BEGIN" * in the following cases. 1) we use declare/fetch and the statement * is SELECT (because declare/fetch must be called in a transaction). * 2) we are in autocommit off state and the statement isn't of type * OTHER. */ #define return DONT_CALL_RETURN_FROM_HERE??? ENTER_INNER_CONN_CS(conn, func_cs_count); oldstatus = conn->status; if (CONN_EXECUTING == conn->status) { SC_set_error(self, STMT_SEQUENCE_ERROR, "Connection is already in use.", func); MYLOG(0, "problem with connection\n"); goto cleanup; } is_in_trans = CC_is_in_trans(conn); if ((useCursor = SC_is_fetchcursor(self))) { QResultClass *curres = SC_get_Curres(self); if (NULL != curres && curres->dataFilled) useCursor = (NULL != QR_get_cursor(curres)); } /* issue BEGIN ? */ issue_begin = TRUE; if (!self->external) issue_begin = FALSE; else if (is_in_trans) { issue_begin = FALSE; if (STMT_TYPE_START == self->statement_type && CC_does_autocommit(conn)) { CC_commit(conn); is_in_trans = CC_is_in_trans(conn); } } else if (CC_does_autocommit(conn) && (!useCursor /* || SC_is_with_hold(self) thiw would lose the performance */ )) issue_begin = FALSE; else if (self->statement_type == STMT_TYPE_SPECIAL) { /* * Some utility commands like VACUUM cannot be run in a transaction * block, so don't begin one even if auto-commit mode is disabled. * * An application should never issue an explicit BEGIN when * auto-commit mode is disabled (probably not even when it's enabled, * actually). We used to also suppress the implicit BEGIN when the * statement was of STMT_TYPE_START type, ie. if the application * issued an explicit BEGIN, but that actually seems like a bad idea. * First of all, if you issue a BEGIN twice the backend will give a * warning which can be helpful to spot mistakes in the application * (because it shouldn't be doing that). */ issue_begin = FALSE; } if (issue_begin) { MYLOG(0, " about to begin a transaction on statement = %p\n", self); qflag |= GO_INTO_TRANSACTION; } /* * If the session query timeout setting differs from the statement one, * change it. */ stmt_timeout = conn->connInfo.ignore_timeout ? 0 : self->options.stmt_timeout; if (conn->stmt_timeout_in_effect != stmt_timeout) { char query[64]; QResultClass *res; SPRINTF_FIXED(query, "SET statement_timeout = %d", (int) stmt_timeout * 1000); res = CC_send_query(conn, query, NULL, 0, NULL); if (QR_command_maybe_successful(res)) conn->stmt_timeout_in_effect = stmt_timeout; QR_Destructor(res); } if (!SC_SetExecuting(self, TRUE)) { SC_set_error(self, STMT_OPERATION_CANCELLED, "Cancel Request Accepted", func); goto cleanup; } conn->status = CONN_EXECUTING; /* If it's a SELECT statement, use a cursor. */ /* * Note that the declare cursor has already been prepended to the * statement */ /* in copy_statement... */ if (self->stmt_with_params) use_extended_protocol = FALSE; else { use_extended_protocol = TRUE; } isSelectType = (SC_may_use_cursor(self) || self->statement_type == STMT_TYPE_PROCCALL); if (use_extended_protocol) { QResultClass *first; if (issue_begin) CC_begin(conn); first = libpq_bind_and_exec(self); if (!first) { if (SC_get_errornumber(self) <= 0) { SC_set_error(self, STMT_NO_RESPONSE, "Could not receive the response, communication down ??", func); } goto cleanup; } rhold.first = rhold.last = first; } else if (isSelectType) { char fetch[128]; const char *appendq = NULL; QueryInfo *qryi = NULL; QResultClass *first; qflag |= (SQL_CONCUR_READ_ONLY != self->options.scroll_concurrency ? CREATE_KEYSET : 0); MYLOG(0, " Sending SELECT statement on stmt=%p, cursor_name='%s' qflag=%d," FORMAT_UINTEGER "\n", self, SC_cursor_name(self), qflag, self->options.scroll_concurrency); /* send the declare/select */ if (useCursor) { qi.result_in = NULL; qi.cursor = SC_cursor_name(self); qi.fetch_size = qi.row_size = ci->drivers.fetch_max; SPRINTF_FIXED(fetch, "fetch " FORMAT_LEN " in \"%s\"", qi.fetch_size, SC_cursor_name(self)); qryi = &qi; appendq = fetch; qflag &= (~READ_ONLY_QUERY); /* must be a SAVEPOINT after DECLARE */ } rhold = CC_send_query_append(conn, self->stmt_with_params, qryi, qflag, SC_get_ancestor(self), appendq); first = rhold.first; if (useCursor && QR_command_maybe_successful(first)) { /* * If we sent a DECLARE CURSOR + FETCH, throw away the result of * the DECLARE CURSOR statement, and only return the result of the * FETCH to the caller. However, if we received any NOTICEs as * part of the DECLARE CURSOR, carry those over. */ if (appendq) { QResultClass *qres, *nres; for (qres = first; qres;) { if (qres->command && strnicmp(qres->command, "fetch", 5) == 0) { break; } nres = QR_nextr(qres); if (nres && QR_get_notice(qres) != NULL) { if (QR_command_successful(nres) && QR_command_nonfatal(qres)) { QR_set_rstatus(nres, PORES_NONFATAL_ERROR); } QR_add_notice(nres, QR_get_notice(qres)); } QR_detach(qres); QR_Destructor(qres); qres = nres; /* * If we received fewer rows than requested, there are no * more rows to fetch. */ if (qres && qres->num_cached_rows < qi.row_size) /* check qres != NULL for safety */ QR_set_reached_eof(qres); } first = qres; rhold.first = first; } if (first && SC_is_with_hold(self)) QR_set_withhold(first); } MYLOG(0, " done sending the query:\n"); } else { /* not a SELECT statement so don't use a cursor */ MYLOG(0, " it's NOT a select statement: stmt=%p\n", self); rhold = CC_send_query_append(conn, self->stmt_with_params, NULL, qflag, SC_get_ancestor(self), NULL); } if (!isSelectType) { /* * We shouldn't send COMMIT. Postgres backend does the autocommit * if necessary. (Zoltan, 04/26/2000) */ /* * Above seems wrong. Even in case of autocommit, started * transactions must be committed. (Hiroshi, 02/11/2001) */ if (CC_is_in_trans(conn)) { if (!is_in_trans) CC_set_in_manual_trans(conn); if (self->external && CC_does_autocommit(conn)) CC_commit(conn); } } if (CONN_DOWN != conn->status) conn->status = oldstatus; self->status = STMT_FINISHED; MYLOG(0, "set %p STMT_FINISHED\n", self); LEAVE_INNER_CONN_CS(func_cs_count, conn); /* Check the status of the result */ if (rhold.first) { QResultClass *first = rhold.first; was_ok = QR_command_successful(first); was_nonfatal = QR_command_nonfatal(first); if (0 < SC_get_errornumber(self)) ; else if (was_ok) { if (self->has_notice && 0 == SC_get_errornumber(self)) SC_set_errornumber(self, STMT_INFO_ONLY); } else if (was_nonfatal) { self->has_notice = 1; if (0 == SC_get_errornumber(self)) SC_set_errornumber(self, STMT_INFO_ONLY); } else SC_set_errorinfo(self, first, 0); /* set cursor before the first tuple in the list */ self->currTuple = -1; SC_set_current_col(self, -1); SC_set_rowset_start(self, -1, FALSE); /* issue "ABORT" when query aborted */ if (QR_get_aborted(first)) { } else { QResultClass *tres; /* see if the query did return any result columns */ for (tres = first, numcols = 0; !numcols && tres; tres = QR_nextr(tres)) { numcols = QR_NumResultCols(tres); } /* now allocate the array to hold the binding info */ if (numcols > 0) { ARDFields *opts = SC_get_ARDF(self); extend_column_bindings(opts, numcols); if (opts->bindings == NULL) { QR_Destructor(first); SC_set_error(self, STMT_NO_MEMORY_ERROR,"Could not get enough free memory to store the binding information", func); goto cleanup; } } MYLOG(DETAIL_LOG_LEVEL, "!!%p->miscinfo=%x res=%p\n", self, self->miscinfo, first); /* * special handling of result for keyset driven cursors. * Use the columns info of the 1st query and * user the keyset info of the 2nd query. */ if (SQL_CURSOR_KEYSET_DRIVEN == self->options.cursor_type && SQL_CONCUR_READ_ONLY != self->options.scroll_concurrency && !useCursor) { if (tres = QR_nextr(first), tres) { QR_set_fields(tres, QR_get_fields(first)); QR_set_fields(first, NULL); tres->num_fields = first->num_fields; QR_detach(first); QR_Destructor(first); SC_set_Result(self, tres); rhold = self->rhold; } } } } else { /* Bad Error -- The error message will be in the Connection */ if (!conn->pqconn) SC_set_error(self, STMT_BAD_ERROR, CC_get_errormsg(conn), func); else if (self->statement_type == STMT_TYPE_CREATE) { SC_set_error(self, STMT_CREATE_TABLE_ERROR, "Error creating the table", func); /* * This would allow the table to already exists, thus * appending rows to it. BUT, if the table didn't have the * same attributes, it would fail. return * SQL_SUCCESS_WITH_INFO; */ } else { SC_set_error(self, STMT_EXEC_ERROR, CC_get_errormsg(conn), func); } } if (!SC_get_Result(self)) SC_set_ResultHold(self, rhold); else { if (self->rhold.last != rhold.first) QR_concat(self->rhold.last, rhold.first); self->rhold.last = rhold.last; } if (NULL == SC_get_Curres(self)) SC_set_Curres(self, SC_get_Result(self)); if (self->statement_type == STMT_TYPE_PROCCALL && (SC_get_errornumber(self) == STMT_OK || SC_get_errornumber(self) == STMT_INFO_ONLY)) { Int2 io, out; has_out_para = (CountParameters(self, NULL, &io, &out) > 0); if (has_out_para) { /* get the return value of the procedure call */ RETCODE ret; HSTMT hstmt = (HSTMT) self; ipdopts = SC_get_IPDF(self); self->bind_row = 0; ret = SC_fetch(hstmt); MYLOG(DETAIL_LOG_LEVEL, "!!SC_fetch return =%d\n", ret); if (SQL_SUCCEEDED(ret)) { APDFields *apdopts = SC_get_APDF(self); SQLULEN offset = apdopts->param_offset_ptr ? *apdopts->param_offset_ptr : 0; ARDFields *ardopts = SC_get_ARDF(self); const ParameterInfoClass *apara; const ParameterImplClass *ipara; int save_bind_size = ardopts->bind_size, gidx, num_p; ardopts->bind_size = apdopts->param_bind_type; num_p = self->num_params; if (ipdopts->allocated < num_p) num_p = ipdopts->allocated; for (i = 0, gidx = 0; i < num_p; i++) { int icol = gidx; ipara = ipdopts->parameters + i; if (ipara->paramType == SQL_PARAM_OUTPUT || ipara->paramType == SQL_PARAM_INPUT_OUTPUT) { if (NAME_IS_VALID(ipara->paramName)) { icol = QR_search_by_fieldname(rhold.first, GET_NAME(ipara->paramName)); if (icol < 0) { SC_set_error(self, STMT_EXEC_ERROR, "Named output parameter does not exist.", func); break; } } apara = apdopts->parameters + i; ret = PGAPI_GetData(hstmt, icol + 1, apara->CType, apara->buffer + offset, apara->buflen, apara->used ? LENADDR_SHIFT(apara->used, offset) : NULL); if (!SQL_SUCCEEDED(ret)) { SC_set_error(self, STMT_EXEC_ERROR, "GetData to Procedure return failed.", func); break; } gidx++; } } ardopts->bind_size = save_bind_size; /* restore */ } else { SC_set_error(self, STMT_EXEC_ERROR, "SC_fetch to get a Procedure return failed.", func); } } if (ci->fetch_refcursors) { char fetch[128]; QResultClass *last = NULL, *res; BOOL refcursor_found = FALSE; /* Iterate the columns in the result to look for refcursors */ numcols = QR_NumResultCols(rhold.first); for (i = 0; i < numcols; i++) { MYLOG(DETAIL_LOG_LEVEL, "!!! numfield=%d field_type=%u\n", numcols, QR_get_field_type(rhold.first, i)); if (PG_TYPE_REFCURSOR == QR_get_field_type(rhold.first, i)) { if (!CC_is_in_trans(conn)) { SC_set_error(self, STMT_EXEC_ERROR, "Query must be executed in a transaction when FetchRefcursors setting is enabled.", func); break; } refcursor_found = TRUE; STR_TO_NAME(self->cursor_name, QR_get_value_backend_text(rhold.first, 0, i)); /* Skip NULL refcursors (allows procedure to return a variable number of results) */ if (!SC_cursor_is_valid(self)) continue; SC_set_fetchcursor(self); qi.result_in = NULL; qi.cursor = SC_cursor_name(self); qi.fetch_size = qi.row_size = ci->drivers.fetch_max; SPRINTF_FIXED(fetch, "fetch " FORMAT_LEN " in \"%s\"", qi.fetch_size, SC_cursor_name(self)); res = CC_send_query(conn, fetch, &qi, qflag | READ_ONLY_QUERY, SC_get_ancestor(self)); if (NULL != res) { if (NULL == last) { /* Reinitialise with result fetched from first refcursor */ SC_init_Result(self); SC_set_Result(self, res); } else { /* Add another result fetched from the next refcursor */ QR_concat(last, res); self->multi_statement = TRUE; } last = res; if (!QR_command_maybe_successful(res)) { SC_set_errorinfo(self, res, 0); break; } } } } if (refcursor_found) { /* Discard original result */ if (NULL == last) SC_set_Result(self, QR_Constructor()); /* return empty result */ else QR_Destructor(rhold.first); } } } cleanup: #undef return SC_SetExecuting(self, FALSE); CLEANUP_FUNC_CONN_CS(func_cs_count, conn); if (CONN_DOWN != conn->status) conn->status = oldstatus; /* self->status = STMT_FINISHED; */ errnum = SC_get_errornumber(self); if (errnum_sav > STMT_OK) SC_set_error(self, errnum_sav, errmsg_sav, NULL); else if (errnum > STMT_OK) ; else if (errnum_sav < STMT_OK) SC_set_error(self, errnum_sav, errmsg_sav, NULL); if (NULL != errmsg_sav) free(errmsg_sav); if (errnum == STMT_OK) return SQL_SUCCESS; else if (errnum < STMT_OK) return SQL_SUCCESS_WITH_INFO; else { char *errmsg = SC_get_errormsg(self); if (!errmsg || !errmsg[0]) { if (STMT_NO_MEMORY_ERROR != errnum) SC_set_errormsg(self, "Error while executing the query"); SC_log_error(func, NULL, self); } return SQL_ERROR; } } #define CALLBACK_ALLOC_ONCE 4 int enqueueNeedDataCallback(StatementClass *stmt, NeedDataCallfunc func, void *data) { if (stmt->num_callbacks >= stmt->allocated_callbacks) { SC_REALLOC_return_with_error(stmt->callbacks, NeedDataCallback, sizeof(NeedDataCallback) * (stmt->allocated_callbacks + CALLBACK_ALLOC_ONCE), stmt, "NeedDataCallback enqueue error", 0); stmt->allocated_callbacks += CALLBACK_ALLOC_ONCE; } stmt->callbacks[stmt->num_callbacks].func = func; stmt->callbacks[stmt->num_callbacks].data = data; stmt->num_callbacks++; MYLOG(DETAIL_LOG_LEVEL, "stmt=%p, func=%p, count=%d\n", stmt, func, stmt->num_callbacks); return stmt->num_callbacks; } RETCODE dequeueNeedDataCallback(RETCODE retcode, StatementClass *stmt) { RETCODE ret; NeedDataCallfunc func; void *data; int i, cnt; MYLOG(0, "entering ret=%d count=%d\n", retcode, stmt->num_callbacks); if (SQL_NEED_DATA == retcode) return retcode; if (stmt->num_callbacks <= 0) return retcode; func = stmt->callbacks[0].func; data = stmt->callbacks[0].data; for (i = 1; i < stmt->num_callbacks; i++) stmt->callbacks[i - 1] = stmt->callbacks[i]; cnt = --stmt->num_callbacks; ret = (*func)(retcode, data); free(data); if (SQL_NEED_DATA != ret && cnt > 0) ret = dequeueNeedDataCallback(ret, stmt); return ret; } void cancelNeedDataState(StatementClass *stmt) { int cnt = stmt->num_callbacks, i; stmt->num_callbacks = 0; for (i = 0; i < cnt; i++) { if (stmt->callbacks[i].data) free(stmt->callbacks[i].data); } SC_reset_delegate(SQL_ERROR, stmt); } void SC_log_error(const char *func, const char *desc, const StatementClass *self) { const char *head; #define NULLCHECK(a) (a ? a : "(NULL)") if (self) { QResultClass *res = SC_get_Result(self); const ARDFields *opts = SC_get_ARDF(self); const APDFields *apdopts = SC_get_APDF(self); SQLLEN rowsetSize; const int level = 9; rowsetSize = (STMT_TRANSITION_EXTENDED_FETCH == self->transition_status ? opts->size_of_rowset_odbc2 : opts->size_of_rowset); if (SC_get_errornumber(self) <= 0) head = "STATEMENT WARNING"; else { head = "STATEMENT ERROR"; QLOG(level, "%s: func=%s, desc='%s', errnum=%d, errmsg='%s'\n",head, func, desc, self->__error_number, NULLCHECK(self->__error_message)); } MYLOG(0, "%s: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", head, func, desc, self->__error_number, NULLCHECK(self->__error_message)); if (SC_get_errornumber(self) > 0) { QLOG(level, " ------------------------------------------------------------\n"); QLOG(level, " hdbc=%p, stmt=%p, result=%p\n", self->hdbc, self, res); QLOG(level, " prepare=%d, external=%d\n", self->prepare, self->external); QLOG(level, " bindings=%p, bindings_allocated=%d\n", opts->bindings, opts->allocated); QLOG(level, " parameters=%p, parameters_allocated=%d\n", apdopts->parameters, apdopts->allocated); QLOG(level, " statement_type=%d, statement='%s'\n", self->statement_type, NULLCHECK(self->statement)); QLOG(level, " stmt_with_params='%s'\n", NULLCHECK(self->stmt_with_params)); QLOG(level, " data_at_exec=%d, current_exec_param=%d, put_data=%d\n", self->data_at_exec, self->current_exec_param, self->put_data); QLOG(level, " currTuple=" FORMAT_LEN ", current_col=%d, lobj_fd=%d\n", self->currTuple, self->current_col, self->lobj_fd); QLOG(level, " maxRows=" FORMAT_LEN ", rowset_size=" FORMAT_LEN ", keyset_size=" FORMAT_LEN ", cursor_type=" FORMAT_UINTEGER ", scroll_concurrency=" FORMAT_UINTEGER "\n", self->options.maxRows, rowsetSize, self->options.keyset_size, self->options.cursor_type, self->options.scroll_concurrency); QLOG(level, " cursor_name='%s'\n", SC_cursor_name(self)); QLOG(level, " ----------------QResult Info -------------------------------\n"); if (res) { QLOG(level, " fields=%p, backend_tuples=%p, tupleField=%p, conn=%p\n", QR_get_fields(res), res->backend_tuples, res->tupleField, res->conn); QLOG(level, " fetch_count=" FORMAT_LEN ", num_total_rows=" FORMAT_ULEN ", num_fields=%d, cursor='%s'\n", res->fetch_number, QR_get_num_total_tuples(res), res->num_fields, NULLCHECK(QR_get_cursor(res))); QLOG(level, " message='%s', command='%s', notice='%s'\n", NULLCHECK(QR_get_message(res)), NULLCHECK(res->command), NULLCHECK(res->notice)); QLOG(level, " status=%d\n", QR_get_rstatus(res)); } /* Log the connection error if there is one */ CC_log_error(func, desc, self->hdbc); } } else { MYLOG(0, "INVALID STATEMENT HANDLE ERROR: func=%s, desc='%s'\n", func, desc); } } /* * Extended Query */ static BOOL RequestStart(StatementClass *stmt, ConnectionClass *conn, const char *func) { BOOL ret = TRUE; unsigned int svpopt = 0; #ifdef _HANDLE_ENLIST_IN_DTC_ if (conn->asdum) CALL_IsolateDtcConn(conn, TRUE); #endif /* _HANDLE_ENLIST_IN_DTC_ */ if (NULL == conn->pqconn) { SC_set_error(stmt, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__); return SQL_ERROR; } if (CC_started_rbpoint(conn)) return TRUE; if (SC_is_readonly(stmt)) svpopt |= SVPOPT_RDONLY; if (SQL_ERROR == SetStatementSvp(stmt, svpopt)) { char emsg[128]; SPRINTF_FIXED(emsg, "internal savepoint error in %s", func); SC_set_error_if_not_set(stmt, STMT_INTERNAL_ERROR, emsg, func); return FALSE; } /* * In auto-commit mode, begin a new transaction implicitly if no * transaction is in progress yet. However, some special statements like * VACUUM and CLUSTER cannot be run in a transaction block. */ if (!CC_is_in_trans(conn) && CC_loves_visible_trans(conn) && stmt->statement_type != STMT_TYPE_SPECIAL) { ret = CC_begin(conn); } return ret; } static void log_params(int nParams, const Oid *paramTypes, const UCHAR * const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat) { int i, j; BOOL isBinary; for (i = 0; i < nParams; i++) { isBinary = paramFormats ? paramFormats[i] : FALSE; if (!paramValues[i]) QLOG(TUPLE_LOG_LEVEL, "\t%c (null) OID=%u\n", isBinary ? 'b' : 't', paramTypes ? paramTypes[i] : 0); else if (isBinary) { QLOG(TUPLE_LOG_LEVEL, "\tb '"); for (j = 0; j < paramLengths[i]; j++) QPRINTF(TUPLE_LOG_LEVEL, "%02x", paramValues[i][j]); QPRINTF(TUPLE_LOG_LEVEL, " OID=%u\n", paramTypes ? paramTypes[i] : 0); } else QLOG(TUPLE_LOG_LEVEL, "\tt '%s' OID=%u\n", paramValues[i], paramTypes ? paramTypes[i] : 0); } } static QResultClass *add_libpq_notice_receiver(StatementClass *stmt, notice_receiver_arg *nrarg) { QResultClass *res = NULL, *newres = NULL; newres = res = QR_Constructor(); nrarg->conn = SC_get_conn(stmt); nrarg->comment = __FUNCTION__; nrarg->res = res; nrarg->stmt = stmt; PQsetNoticeReceiver(nrarg->conn->pqconn, receive_libpq_notice, nrarg); return newres; } static QResultClass * libpq_bind_and_exec(StatementClass *stmt) { CSTR func = "libpq_bind_and_exec"; ConnectionClass *conn = SC_get_conn(stmt); int nParams; Oid *paramTypes = NULL; char **paramValues = NULL; int *paramLengths = NULL; int *paramFormats = NULL; int resultFormat; PGresult *pgres = NULL; int pgresstatus; QResultClass *newres = NULL; QResultClass *res = NULL; char *cmdtag; char *rowcount; notice_receiver_arg nrarg; if (!RequestStart(stmt, conn, func)) return NULL; #ifdef NOT_USED if (CC_is_in_trans(conn) && !CC_started_rbpoint(conn)) { if (SQL_ERROR == SetStatementSvp(stmt, 0)) { SC_set_error_if_not_set(stmt, STMT_INTERNAL_ERROR, "internal savepoint error in build_libpq_bind_params", func); return NULL; } } #endif /* NOT_USED */ /* 1. Bind */ MYLOG(0, "bind stmt=%p\n", stmt); if (!build_libpq_bind_params(stmt, &nParams, ¶mTypes, ¶mValues, ¶mLengths, ¶mFormats, &resultFormat)) { if (SC_get_errornumber(stmt) <= 0) SC_set_errornumber(stmt, STMT_NO_MEMORY_ERROR); goto cleanup; } /* 2. Execute */ MYLOG(0, "execute stmt=%p\n", stmt); if (!SC_is_fetchcursor(stmt)) { if (stmt->prepared == NOT_YET_PREPARED || (stmt->prepared == PREPARED_TEMPORARILY && conn->unnamed_prepared_stmt != stmt)) { SC_set_error(stmt, STMT_EXEC_ERROR, "about to execute a non-prepared statement", func); goto cleanup; } } /* 2.5 Prepare and Describe if needed */ if (stmt->prepared == PREPARING_TEMPORARILY || (stmt->prepared == PREPARED_TEMPORARILY && conn->unnamed_prepared_stmt != stmt)) { ProcessedStmt *pstmt; if (!stmt->processed_statements) { if (prepareParametersNoDesc(stmt, FALSE, EXEC_PARAM_CAST) == SQL_ERROR) goto cleanup; } pstmt = stmt->processed_statements; QLOG(0, "PQexecParams: %p '%s' nParams=%d\n", conn->pqconn, pstmt->query, nParams); log_params(nParams, paramTypes, (const UCHAR * const *) paramValues, paramLengths, paramFormats, resultFormat); /* set notice receiver */ newres = add_libpq_notice_receiver(stmt, &nrarg); pgres = PQexecParams(conn->pqconn, pstmt->query, nParams, paramTypes, (const char **) paramValues, paramLengths, paramFormats, resultFormat); } else { const char *plan_name; if (stmt->prepared == PREPARING_PERMANENTLY) { if (prepareParameters(stmt, FALSE) == SQL_ERROR) goto cleanup; } /* prepareParameters() set plan name, so don't fetch this earlier */ plan_name = stmt->plan_name ? stmt->plan_name : NULL_STRING; /* already prepared */ QLOG(0, "PQexecPrepared: %p plan=%s nParams=%d\n", conn->pqconn, plan_name, nParams); log_params(nParams, paramTypes, (const UCHAR * const *) paramValues, paramLengths, paramFormats, resultFormat); /* set notice receiver */ newres = add_libpq_notice_receiver(stmt, &nrarg); pgres = PQexecPrepared(conn->pqconn, plan_name, /* portal name == plan name */ nParams, (const char **) paramValues, paramLengths, paramFormats, resultFormat); } /* reset notice receiver */ PQsetNoticeReceiver(conn->pqconn, receive_libpq_notice, NULL); if (!(res = nrarg.res)) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory while allocating result set", func); goto cleanup; } /* 3. Receive results */ MYLOG(DETAIL_LOG_LEVEL, "get_Result=%p %p\n", res, SC_get_Result(stmt)); pgresstatus = PQresultStatus(pgres); switch (pgresstatus) { case PGRES_COMMAND_OK: /* portal query command, no tuples returned */ /* read in the return message from the backend */ cmdtag = PQcmdStatus(pgres); QLOG(0, "\tok: - 'C' - %s\n", cmdtag); QR_set_command(res, cmdtag); if (QR_command_successful(res)) QR_set_rstatus(res, PORES_COMMAND_OK); /* get rowcount */ rowcount = PQcmdTuples(pgres); if (rowcount && rowcount[0]) res->recent_processed_row_count = atoi(rowcount); else res->recent_processed_row_count = -1; break; case PGRES_EMPTY_QUERY: /* We return the empty query */ QR_set_rstatus(res, PORES_EMPTY_QUERY); break; case PGRES_NONFATAL_ERROR: handle_pgres_error(conn, pgres, "libpq_bind_and_exec", res, FALSE); break; case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: handle_pgres_error(conn, pgres, "libpq_bind_and_exec", res, TRUE); break; case PGRES_TUPLES_OK: if (!QR_from_PGresult(res, stmt, conn, NULL, &pgres)) goto cleanup; if (res->rstatus == PORES_TUPLES_OK && res->notice) QR_set_rstatus(res, PORES_NONFATAL_ERROR); break; case PGRES_COPY_OUT: case PGRES_COPY_IN: case PGRES_COPY_BOTH: default: /* skip the unexpected response if possible */ QR_set_rstatus(res, PORES_BAD_RESPONSE); CC_set_error(conn, CONNECTION_BACKEND_CRAZY, "Unexpected protocol character from backend (send_query)", func); CC_on_abort(conn, CONN_DEAD); QLOG(0, "PQexecXxxx error: - (%d) - %s\n", pgresstatus, CC_get_errormsg(conn)); break; } if (res != newres && NULL != newres) QR_Destructor(newres); cleanup: if (pgres) PQclear(pgres); if (paramValues) { int i; for (i = 0; i < nParams; i++) { if (paramValues[i] != NULL) free(paramValues[i]); } free(paramValues); } if (paramTypes) free(paramTypes); if (paramLengths) free(paramLengths); if (paramFormats) free(paramFormats); return res; } /* * Parse a query using libpq. * * 'res' is only passed here for error reporting purposes. If an error is * encountered, it is set in 'res', and the function returns FALSE. */ static BOOL ParseWithLibpq(StatementClass *stmt, const char *plan_name, const char *query, Int2 num_params, const char *comment, QResultClass *res) { CSTR func = "ParseWithLibpq"; ConnectionClass *conn = SC_get_conn(stmt); Int4 sta_pidx = -1, end_pidx = -1; const char *cstatus; Oid *paramTypes = NULL; BOOL retval = FALSE; PGresult *pgres = NULL; MYLOG(0, "entering plan_name=%s query=%s\n", plan_name, query); if (!RequestStart(stmt, conn, func)) return FALSE; if (stmt->discard_output_params) num_params = 0; else if (num_params != 0) { #ifdef NOT_USED sta_pidx += stmt->proc_return; #endif /* NOT_USED */ int pidx; sta_pidx = stmt->current_exec_param; if (num_params < 0) end_pidx = stmt->num_params - 1; else end_pidx = sta_pidx + num_params - 1; #ifdef NOT_USED num_params = end_pidx - sta_pidx + 1; #endif /* NOT_USED */ for (num_params = 0, pidx = sta_pidx - 1;;) { SC_param_next(stmt, &pidx, NULL, NULL); if (pidx > end_pidx) break; else if (pidx < end_pidx) { if (0 == num_params) sta_pidx = pidx; num_params++; } else { num_params++; break; } } MYLOG(0, "sta_pidx=%d end_pidx=%d num_p=%d\n", sta_pidx, end_pidx, num_params); } /* * We let the server deduce the right datatype for the parameters, except * for out parameters, which are sent as VOID. */ if (num_params > 0) { int i; int j; IPDFields *ipdopts = SC_get_IPDF(stmt); paramTypes = malloc(sizeof(Oid) * num_params); if (paramTypes == NULL) { SC_set_errornumber(stmt, STMT_NO_MEMORY_ERROR); goto cleanup; } MYLOG(0, "ipdopts->allocated: %d\n", ipdopts->allocated); j = 0; for (i = sta_pidx; i <= end_pidx; i++) { if (i < ipdopts->allocated) { if (SQL_PARAM_OUTPUT == ipdopts->parameters[i].paramType) paramTypes[j++] = PG_TYPE_VOID; else paramTypes[j++] = sqltype_to_bind_pgtype(conn, ipdopts->parameters[i].SQLType); } else { /* Unknown type of parameter. Let the server decide */ paramTypes[j++] = 0; } } } if (plan_name == NULL || plan_name[0] == '\0') conn->unnamed_prepared_stmt = NULL; /* Prepare */ QLOG(0, "PQprepare: %p '%s' plan=%s nParams=%d\n", conn->pqconn, query, plan_name, num_params); pgres = PQprepare(conn->pqconn, plan_name, query, num_params, paramTypes); if (PQresultStatus(pgres) != PGRES_COMMAND_OK) { handle_pgres_error(conn, pgres, "ParseWithlibpq", res, TRUE); goto cleanup; } cstatus = PQcmdStatus(pgres); QLOG(0, "\tok: - 'C' - %s\n", cstatus); if (stmt->plan_name) SC_set_prepared(stmt, PREPARED_PERMANENTLY); else SC_set_prepared(stmt, PREPARED_TEMPORARILY); if (plan_name == NULL || plan_name[0] == '\0') conn->unnamed_prepared_stmt = stmt; retval = TRUE; cleanup: if (paramTypes) free(paramTypes); if (pgres) PQclear(pgres); return retval; } /* * Parse and describe a query using libpq. * * Returns an empty result set that has the column information, or error code * and message, filled in. If 'res' is not NULL, it is the result set * returned, otherwise a new one is allocated. * * NB: The caller must set stmt->current_exec_param before calling this * function! */ QResultClass * ParseAndDescribeWithLibpq(StatementClass *stmt, const char *plan_name, const char *query_param, Int2 num_params, const char *comment, QResultClass *res) { CSTR func = "ParseAndDescribeWithLibpq"; ConnectionClass *conn = SC_get_conn(stmt); PGresult *pgres = NULL; int num_p; Int2 num_discard_params; IPDFields *ipdopts; int pidx; int i; Oid oid; SQLSMALLINT paramType; MYLOG(0, "entering plan_name=%s query=%s\n", plan_name, query_param); if (!RequestStart(stmt, conn, func)) return NULL; if (!res) res = QR_Constructor(); if (!res) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate memory for query", func); return NULL; } /* * We need to do Prepare + Describe as two different round-trips to the * server, while before we switched to use libpq, we used to send a Parse * and Describe message followed by a single Sync. */ if (!ParseWithLibpq(stmt, plan_name, query_param, num_params, comment, res)) goto cleanup; /* Describe */ QLOG(0, "\tPQdescribePrepared: %p plan_name=%s\n", conn->pqconn, plan_name); pgres = PQdescribePrepared(conn->pqconn, plan_name); switch (PQresultStatus(pgres)) { case PGRES_COMMAND_OK: QLOG(0, "\tok: - 'C' - %s\n", PQcmdStatus(pgres)); /* expected */ break; case PGRES_NONFATAL_ERROR: handle_pgres_error(conn, pgres, "ParseAndDescribeWithLibpq", res, FALSE); goto cleanup; case PGRES_FATAL_ERROR: handle_pgres_error(conn, pgres, "ParseAndDescribeWithLibpq", res, TRUE); goto cleanup; default: /* skip the unexpected response if possible */ CC_set_error(conn, CONNECTION_BACKEND_CRAZY, "Unexpected result from PQdescribePrepared", func); CC_on_abort(conn, CONN_DEAD); MYLOG(0, "PQdescribePrepared: error - %s\n", CC_get_errormsg(conn)); goto cleanup; } /* Extract parameter information from the result set */ num_p = PQnparams(pgres); MYLOG(DETAIL_LOG_LEVEL, "num_params=%d info=%d\n", stmt->num_params, num_p); if (get_qlog() > 0 || get_mylog() > 0) { int i; QLOG(0, "\tnParams=%d", num_p); for (i = 0; i < num_p; i++) QPRINTF(0, " %u", PQparamtype(pgres, i)); QPRINTF(0, "\n"); } num_discard_params = 0; if (stmt->discard_output_params) CountParameters(stmt, NULL, NULL, &num_discard_params); if (num_discard_params < stmt->proc_return) num_discard_params = stmt->proc_return; if (num_p + num_discard_params != (int) stmt->num_params) { MYLOG(0, "ParamInfo unmatch num_params(=%d) != info(=%d)+discard(=%d)\n", stmt->num_params, num_p, num_discard_params); /* stmt->num_params = (Int2) num_p + num_discard_params; it's possible in case of multi command queries */ } ipdopts = SC_get_IPDF(stmt); extend_iparameter_bindings(ipdopts, stmt->num_params); pidx = stmt->current_exec_param; if (pidx >= 0) pidx--; for (i = 0; i < num_p; i++) { SC_param_next(stmt, &pidx, NULL, NULL); if (pidx >= stmt->num_params) { MYLOG(0, "%dth parameter's position(%d) is out of bound[%d]\n", i, pidx, stmt->num_params); break; } oid = PQparamtype(pgres, i); paramType = ipdopts->parameters[pidx].paramType; if (SQL_PARAM_OUTPUT != paramType || PG_TYPE_VOID != oid) PIC_set_pgtype(ipdopts->parameters[pidx], oid); } /* Extract Portal information */ QR_set_conn(res, conn); if (CI_read_fields_from_pgres(QR_get_fields(res), pgres)) { Int2 dummy1, dummy2; int cidx; int num_io_params; QR_set_rstatus(res, PORES_FIELDS_OK); res->num_fields = CI_get_num_fields(QR_get_fields(res)); if (QR_haskeyset(res)) res->num_fields -= res->num_key_fields; num_io_params = CountParameters(stmt, NULL, &dummy1, &dummy2); if (stmt->proc_return > 0 || num_io_params > 0) { ipdopts = SC_get_IPDF(stmt); extend_iparameter_bindings(ipdopts, stmt->num_params); for (i = 0, cidx = 0; i < stmt->num_params; i++) { if (i < stmt->proc_return) ipdopts->parameters[i].paramType = SQL_PARAM_OUTPUT; paramType =ipdopts->parameters[i].paramType; if (SQL_PARAM_OUTPUT == paramType || SQL_PARAM_INPUT_OUTPUT == paramType) { MYLOG(DETAIL_LOG_LEVEL, "!![%d].PGType %u->%u\n", i, PIC_get_pgtype(ipdopts->parameters[i]), CI_get_oid(QR_get_fields(res), cidx)); PIC_set_pgtype(ipdopts->parameters[i], CI_get_oid(QR_get_fields(res), cidx)); cidx++; } } } } else { if (NULL == QR_get_fields(res)->coli_array) { QR_set_rstatus(res, PORES_NO_MEMORY_ERROR); QR_set_messageref(res, "Out of memory while reading field information"); } else { QR_set_rstatus(res, PORES_BAD_RESPONSE); QR_set_message(res, "Error reading field information"); } } cleanup: if (pgres) PQclear(pgres); return res; } enum { CancelRequestSet = 1L ,CancelRequestAccepted = (1L << 1) ,CancelCompleted = (1L << 2) }; /* commonly used for short term lock */ #if defined(WIN_MULTITHREAD_SUPPORT) extern CRITICAL_SECTION common_cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) extern pthread_mutex_t common_cs; #endif /* WIN_MULTITHREAD_SUPPORT */ BOOL SC_IsExecuting(const StatementClass *self) { BOOL ret; ENTER_COMMON_CS; /* short time blocking */ ret = (STMT_EXECUTING == self->status); LEAVE_COMMON_CS; return ret; } BOOL SC_SetExecuting(StatementClass *self, BOOL on) { BOOL exeSet = FALSE; ENTER_COMMON_CS; /* short time blocking */ if (on) { if (0 == (self->cancel_info & CancelRequestSet)) { self->status = STMT_EXECUTING; exeSet = TRUE; } } else { self->cancel_info = 0; self->status = STMT_FINISHED; MYLOG(0, "set %p STMT_FINISHED\n", self); exeSet = TRUE; } LEAVE_COMMON_CS; return exeSet; } #ifdef NOT_USED BOOL SC_SetCancelRequest(StatementClass *self) { BOOL enteredCS = FALSE; ENTER_COMMON_CS; if (0 != (self->cancel_info & CancelCompleted)) ; else if (STMT_EXECUTING == self->status) { self->cancel_info |= CancelRequestSet; } else { /* try to acquire */ if (TRY_ENTER_STMT_CS(self)) enteredCS = TRUE; else self->cancel_info |= CancelRequestSet; } LEAVE_COMMON_CS; return enteredCS; } #endif /* NOT_USED */ BOOL SC_AcceptedCancelRequest(const StatementClass *self) { BOOL shouldCancel = FALSE; ENTER_COMMON_CS; if (0 != (self->cancel_info & (CancelRequestSet | CancelRequestAccepted | CancelCompleted))) shouldCancel = TRUE; LEAVE_COMMON_CS; return shouldCancel; } static void SC_set_error_if_not_set(StatementClass *self, int errornumber, const char *errmsg, const char *func) { int errnum = SC_get_errornumber(self); if (errnum <= 0) { const char *emsg = SC_get_errormsg(self); if (emsg && 0 == errnum) SC_set_errornumber(self, errornumber); else SC_set_error(self, errornumber, errmsg, func); } } static void SC_set_errorinfo(StatementClass *self, QResultClass *res, int errkind) { ConnectionClass *conn = SC_get_conn(self); if (CC_not_connected(conn)) { SC_set_error_if_not_set(self, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__); return; } switch (QR_get_rstatus(res)) { case PORES_NO_MEMORY_ERROR: SC_set_error_if_not_set(self, STMT_NO_MEMORY_ERROR, "memory allocation error???", __FUNCTION__); break; case PORES_BAD_RESPONSE: SC_set_error_if_not_set(self, STMT_COMMUNICATION_ERROR, "communication error occurred", __FUNCTION__); break; case PORES_INTERNAL_ERROR: SC_set_error_if_not_set(self, STMT_INTERNAL_ERROR, "Internal error fetching next row", __FUNCTION__); break; default: switch (errkind) { case 1: SC_set_error_if_not_set(self, STMT_EXEC_ERROR, "Error while fetching the next result", __FUNCTION__); break; default: SC_set_error_if_not_set(self, STMT_EXEC_ERROR, "Error while executing the query", __FUNCTION__); break; } break; } } /* * Before 9.6, the driver offered very simple bookmark support -- it is just * the current row number. * Now the driver offers more verbose bookmarks which contain KeySet informations * (CTID (+ OID)). Though they consume 12bytes(row number + CTID) or 16bytes * (row number + CTID + OID), they are useful in declare/fetch mode. */ PG_BM SC_Resolve_bookmark(const ARDFields *opts, Int4 idx) { BindInfoClass *bookmark; SQLLEN *used; SQLULEN offset; SQLUINTEGER bind_size; size_t cpylen = sizeof(Int4); PG_BM pg_bm; bookmark = opts->bookmark; offset = opts->row_offset_ptr ? *(opts->row_offset_ptr) : 0; bind_size = opts->bind_size; memset(&pg_bm, 0, sizeof(pg_bm)); if (used = bookmark->used, used != NULL) { used = LENADDR_SHIFT(used, offset); if (bind_size > 0) used = LENADDR_SHIFT(used, idx * bind_size); else used = LENADDR_SHIFT(used, idx * sizeof(SQLLEN)); if (*used >= sizeof(pg_bm)) cpylen = sizeof(pg_bm); else if (*used >= 12) cpylen = 12; MYLOG(0, "used=" FORMAT_LEN " cpylen=" FORMAT_SIZE_T "\n", *used, cpylen); } memcpy(&pg_bm, CALC_BOOKMARK_ADDR(bookmark, offset, bind_size, idx), cpylen); MYLOG(0, "index=%d block=%d off=%d\n", pg_bm.index, pg_bm.keys.blocknum, pg_bm.keys.offset); pg_bm.index = SC_resolve_int4_bookmark(pg_bm.index); return pg_bm; } int SC_Create_bookmark(StatementClass *self, BindInfoClass *bookmark, Int4 bind_row, Int4 currTuple, const KeySet *keyset) { ARDFields *opts = SC_get_ARDF(self); SQLUINTEGER bind_size = opts->bind_size; SQLULEN offset = opts->row_offset_ptr ? *opts->row_offset_ptr : 0; size_t cvtlen = sizeof(Int4); PG_BM pg_bm; MYLOG(0, "entering type=%d buflen=" FORMAT_LEN " buf=%p\n", bookmark->returntype, bookmark->buflen, bookmark->buffer); memset(&pg_bm, 0, sizeof(pg_bm)); if (SQL_C_BOOKMARK == bookmark->returntype) ; else if (bookmark->buflen >= sizeof(pg_bm)) cvtlen = sizeof(pg_bm); else if (bookmark->buflen >= 12) cvtlen = 12; pg_bm.index = SC_make_int4_bookmark(currTuple); if (keyset) pg_bm.keys = *keyset; memcpy(CALC_BOOKMARK_ADDR(bookmark, offset, bind_size, bind_row), &pg_bm, cvtlen); if (bookmark->used) { SQLLEN *used = LENADDR_SHIFT(bookmark->used, offset); if (bind_size > 0) used = LENADDR_SHIFT(used, bind_row * bind_size); else used = LENADDR_SHIFT(used, bind_row * sizeof(SQLLEN)); *used = cvtlen; } MYLOG(0, "leaving cvtlen=" FORMAT_SIZE_T " ix(bl,of)=%d(%d,%d)\n", cvtlen, pg_bm.index, pg_bm.keys.blocknum, pg_bm.keys.offset); return COPY_OK; } psqlodbc-REL-16_00_0005/statement.h000066400000000000000000000502351462406103600166600ustar00rootroot00000000000000/* File: statement.hPD * * Description: See "statement.c" * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __STATEMENT_H__ #define __STATEMENT_H__ #include "psqlodbc.h" #include #include "pqexpbuffer.h" #include "pgtypes.h" #include "bind.h" #include "descriptor.h" #include "tuple.h" #if defined (POSIX_MULTITHREAD_SUPPORT) #include #endif typedef enum { STMT_ALLOCATED, /* The statement handle is allocated, but * not used so far */ STMT_READY, /* the statement is waiting to be executed */ STMT_DESCRIBED, /* ODBC states that it is legal to call * e.g. SQLDescribeCol before a call to * SQLExecute, but after SQLPrepare. To * get all the necessary information in * such a case, we parse the query _before_ * the actual call to SQLExecute, and the * result set contains only column information, * but no actual data. */ STMT_FINISHED, /* statement execution has finished */ STMT_EXECUTING /* statement execution is still going on */ } STMT_Status; /* * ERROR status code * * The code for warnings must be minus * and LOWEST_STMT_ERROR must be set to * the least code number. * The code for STMT_OK is 0 and error * codes follow after it. */ enum { LOWEST_STMT_ERROR = (-6) /* minus values mean warning returns */ ,STMT_ERROR_IN_ROW = (-6) ,STMT_OPTION_VALUE_CHANGED = (-5) ,STMT_ROW_VERSION_CHANGED = (-4) ,STMT_POS_BEFORE_RECORDSET = (-3) ,STMT_TRUNCATED = (-2) ,STMT_INFO_ONLY = (-1) /* not an error message, * just a notification * to be returned by * SQLError */ ,STMT_OK = 0 ,STMT_EXEC_ERROR ,STMT_STATUS_ERROR ,STMT_SEQUENCE_ERROR ,STMT_NO_MEMORY_ERROR ,STMT_COLNUM_ERROR ,STMT_NO_STMTSTRING ,STMT_ERROR_TAKEN_FROM_BACKEND ,STMT_INTERNAL_ERROR ,STMT_STILL_EXECUTING ,STMT_NOT_IMPLEMENTED_ERROR ,STMT_BAD_PARAMETER_NUMBER_ERROR ,STMT_OPTION_OUT_OF_RANGE_ERROR ,STMT_INVALID_COLUMN_NUMBER_ERROR ,STMT_RESTRICTED_DATA_TYPE_ERROR ,STMT_INVALID_CURSOR_STATE_ERROR ,STMT_CREATE_TABLE_ERROR ,STMT_NO_CURSOR_NAME ,STMT_INVALID_CURSOR_NAME ,STMT_INVALID_ARGUMENT_NO ,STMT_ROW_OUT_OF_RANGE ,STMT_OPERATION_CANCELLED ,STMT_INVALID_CURSOR_POSITION ,STMT_VALUE_OUT_OF_RANGE ,STMT_OPERATION_INVALID ,STMT_PROGRAM_TYPE_OUT_OF_RANGE ,STMT_BAD_ERROR ,STMT_INVALID_OPTION_IDENTIFIER ,STMT_RETURN_NULL_WITHOUT_INDICATOR ,STMT_INVALID_DESCRIPTOR_IDENTIFIER ,STMT_OPTION_NOT_FOR_THE_DRIVER ,STMT_FETCH_OUT_OF_RANGE ,STMT_COUNT_FIELD_INCORRECT ,STMT_INVALID_NULL_ARG ,STMT_NO_RESPONSE ,STMT_COMMUNICATION_ERROR ,STMT_STRING_CONVERSION_ERROR }; /* statement types */ enum { STMT_TYPE_UNKNOWN = -2 ,STMT_TYPE_OTHER = -1 ,STMT_TYPE_SELECT = 0 ,STMT_TYPE_WITH ,STMT_TYPE_PROCCALL ,STMT_TYPE_TRANSACTION ,STMT_TYPE_DECLARE ,STMT_TYPE_FETCH ,STMT_TYPE_CLOSE ,STMT_TYPE_INSERT ,STMT_TYPE_UPDATE ,STMT_TYPE_DELETE ,STMT_TYPE_CREATE ,STMT_TYPE_ALTER ,STMT_TYPE_DROP ,STMT_TYPE_GRANT ,STMT_TYPE_REVOKE ,STMT_TYPE_LOCK ,STMT_TYPE_PREPARE ,STMT_TYPE_EXECUTE ,STMT_TYPE_DEALLOCATE ,STMT_TYPE_ANALYZE ,STMT_TYPE_NOTIFY ,STMT_TYPE_EXPLAIN ,STMT_TYPE_SET ,STMT_TYPE_RESET ,STMT_TYPE_MOVE ,STMT_TYPE_COPY ,STMT_TYPE_START ,STMT_TYPE_SPECIAL }; #define STMT_UPDATE(stmt) ((stmt)->statement_type > STMT_TYPE_PROCCALL) /* Parsing status */ enum { STMT_PARSE_NONE = 0 ,STMT_PARSE_COMPLETE /* the driver parsed the statement */ ,STMT_PARSE_INCOMPLETE ,STMT_PARSE_FATAL ,STMT_PARSE_MASK = 3L ,STMT_PARSED_OIDS = (1L << 2) ,STMT_FOUND_KEY = (1L << 3) ,STMT_HAS_ROW_DESCRIPTION = (1L << 4) /* already got the col info */ ,STMT_REFLECTED_ROW_DESCRIPTION = (1L << 5) }; /* transition status */ enum { STMT_TRANSITION_UNALLOCATED = 0 ,STMT_TRANSITION_ALLOCATED = 1 ,STMT_TRANSITION_FETCH_SCROLL = 6 ,STMT_TRANSITION_EXTENDED_FETCH = 7 }; /* Result style */ enum { STMT_FETCH_NONE = 0, STMT_FETCH_NORMAL, STMT_FETCH_EXTENDED }; /* Type of the 3rd parameter of Exec_with_parameters_resolved() */ typedef enum { DIRECT_EXEC, DEFFERED_EXEC, LAST_EXEC } EXEC_TYPE; #define PG_NUM_NORMAL_KEYS 2 typedef RETCODE (*NeedDataCallfunc)(RETCODE, void *); typedef struct { NeedDataCallfunc func; void *data; } NeedDataCallback; /* * ProcessedStmt represents a fragment of the original SQL query, after * converting ? markers to $n style, processing ODBC escapes, and splitting * a multi-statement into individual statements. Each individual statement * is represented by one ProcessedStmt struct. */ struct ProcessedStmt { struct ProcessedStmt *next; char *query; int num_params; /* number of parameter markers in this, * fragment or -1 if not known */ }; typedef struct ProcessedStmt ProcessedStmt; /******** Statement Handle ***********/ struct StatementClass_ { ConnectionClass *hdbc; /* pointer to ConnectionClass this * statement belongs to */ QResultHold rhold; QResultClass *curres; /* the current result in the chain */ QResultClass *parsed; /* parsed result before exec */ HSTMT *phstmt; StatementOptions options; StatementOptions options_orig; /* attached descriptor handles */ DescriptorClass *ard; DescriptorClass *apd; DescriptorClass *ird; DescriptorClass *ipd; /* implicit descriptor handles */ DescriptorClass ardi; DescriptorClass irdi; DescriptorClass apdi; DescriptorClass ipdi; STMT_Status status; char *__error_message; int __error_number; PG_ErrorInfo *pgerror; SQLLEN currTuple; /* current absolute row number (GetData, * SetPos, SQLFetch) */ GetDataInfo gdata_info; SQLLEN save_rowset_size; /* saved rowset size in case of * change/FETCH_NEXT */ SQLLEN rowset_start; /* start of rowset (an absolute row * number) */ SQLSETPOSIROW bind_row; /* current offset for Multiple row/column * binding */ Int2 current_col; /* current column for GetData -- used to * handle multiple calls */ SQLLEN last_fetch_count; /* number of rows retrieved in * last fetch/extended fetch */ int lobj_fd; /* fd of the current large object */ char *statement; /* if non--null pointer to the SQL * statement that has been executed */ /* * processed_statements is the SQL after splitting multi-statement into * parts, and replacing ? markers with $n style markers, or injecting the * values in UseServerSidePrepare=0 mode. */ ProcessedStmt *processed_statements; TABLE_INFO **ti; Int2 ntab; Int2 num_key_fields; Int2 statement_type; /* According to the defines above */ Int2 num_params; Int2 data_at_exec; /* Number of params needing SQLPutData */ Int2 current_exec_param; /* The current parameter for * SQLPutData */ UDWORD iflag; /* PGAPI_AllocStmt parameter */ PutDataInfo pdata_info; po_ind_t parse_status; po_ind_t proc_return; po_ind_t put_data; /* Has SQLPutData been called ? */ po_ind_t catalog_result; /* Is this a result of catalog function ? */ po_ind_t prepare; /* is this a prepared statement ? */ po_ind_t prepared; /* is this statement already * prepared at the server ? */ po_ind_t external; /* Allocated via SQLAllocHandle() */ po_ind_t transition_status; /* Transition status */ po_ind_t multi_statement; /* -1:unknown 0:single 1:multi */ po_ind_t rb_or_tc; /* rollback on error */ po_ind_t discard_output_params; /* discard output parameters on parse stage */ po_ind_t cancel_info; /* cancel information */ po_ind_t ref_CC_error; /* refer to CC_error ? */ po_ind_t lock_CC_for_rb; /* lock CC for statement rollback ? */ po_ind_t join_info; /* have joins ? */ po_ind_t parse_method; /* parse_statement is forced or ? */ po_ind_t has_notice; /* exec result contains notice messages ? */ pgNAME cursor_name; char *plan_name; char *stmt_with_params; /* statement after parameter * substitution */ SQLLEN exec_start_row; SQLLEN exec_end_row; SQLLEN exec_current_row; unsigned char miscinfo; unsigned char execinfo; po_ind_t updatable; SQLLEN diag_row_count; char *load_statement; /* to (re)load updatable individual rows */ ssize_t from_pos; ssize_t load_from_pos; ssize_t where_pos; SQLLEN last_fetch_count_include_ommitted; time_t stmt_time; struct tm localtime; // for batch execution signed char use_server_side_prepare; int batch_size; EXEC_TYPE exec_type; int count_of_deffered; PQExpBufferData stmt_deffered; /* SQL_NEED_DATA Callback list */ StatementClass *execute_delegate; StatementClass *execute_parent; UInt2 allocated_callbacks; UInt2 num_callbacks; NeedDataCallback *callbacks; #if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION cs; #elif defined(POSIX_THREADMUTEX_SUPPORT) pthread_mutex_t cs; #endif /* WIN_MULTITHREAD_SUPPORT */ }; #define SC_get_conn(a) ((a)->hdbc) void SC_init_Result(StatementClass *self); void SC_set_Result(StatementClass *self, QResultClass *res); void SC_set_ResultHold(StatementClass *self, QResultHold rhold); QResultClass *SC_get_lastres(StatementClass *stmt); #define SC_get_Result(a) ((a)->rhold).first #define SC_set_Curres(a, b) ((a)->curres = b) #define SC_get_Curres(a) ((a)->curres) #define SC_get_ExecdOrParsed(a) ((a)->curres ? (a)->curres : (a)->parsed) #define SC_get_ARD(a) ((a)->ard) #define SC_get_APD(a) ((a)->apd) #define SC_get_IRD(a) ((a)->ird) #define SC_get_IPD(a) ((a)->ipd) #define SC_get_ARDF(a) (&(SC_get_ARD(a)->ardf)) #define SC_get_APDF(a) (&(SC_get_APD(a)->apdf)) #define SC_get_IRDF(a) (&(SC_get_IRD(a)->irdf)) #define SC_get_IPDF(a) (&(SC_get_IPD(a)->ipdf)) #define SC_get_ARDi(a) (&((a)->ardi)) #define SC_get_APDi(a) (&((a)->apdi)) #define SC_get_IRDi(a) (&((a)->irdi)) #define SC_get_IPDi(a) (&((a)->ipdi)) #define SC_get_GDTI(a) (&((a)->gdata_info)) #define SC_get_PDTI(a) (&((a)->pdata_info)) #define SC_get_errornumber(a) ((a)->__error_number) #define SC_set_errornumber(a, n) ((a)->__error_number = n) #define SC_get_errormsg(a) ((a)->__error_message) #define SC_is_prepare_statement(a) (0 != ((a)->prepare & PREPARE_STATEMENT)) #define SC_get_prepare_method(a) ((a)->prepare & (~PREPARE_STATEMENT)) #define SC_parsed_status(a) ((a)->parse_status & STMT_PARSE_MASK) #define SC_set_parse_status(a, s) ((a)->parse_status |= s) #define SC_update_not_ready(a) (SC_parsed_status(a) == STMT_PARSE_NONE || 0 == ((a)->parse_status & STMT_PARSED_OIDS)) #define SC_update_ready(a) (SC_parsed_status(a) == STMT_PARSE_COMPLETE && 0 != ((a)->parse_status & STMT_FOUND_KEY) && (a)->updatable) #define SC_set_checked_hasoids(a, b) ((a)->parse_status |= (STMT_PARSED_OIDS | (b ? STMT_FOUND_KEY : 0))) #define SC_checked_hasoids(a) (0 != ((a)->parse_status & STMT_PARSED_OIDS)) #define SC_set_delegate(p, c) ((p)->execute_delegate = c, (c)->execute_parent = p) #define SC_is_updatable(s) (0 < ((s)->updatable)) #define SC_reset_updatable(s) ((s)->updatable = -1) #define SC_set_updatable(s, b) ((s)->updatable = (b)) #define SC_clear_parse_method(s) ((s)->parse_method = 0) #define SC_is_parse_forced(s) (0 != ((s)->parse_method & 1L)) #define SC_set_parse_forced(s) ((s)->parse_method |= 1L) #define SC_cursor_is_valid(s) (NAME_IS_VALID((s)->cursor_name)) #define SC_cursor_name(s) (SAFE_NAME((s)->cursor_name)) void SC_reset_delegate(RETCODE, StatementClass *); StatementClass *SC_get_ancestor(StatementClass *); #define SC_is_lower_case(a, b) ((a)->options.metadata_id || (b)->connInfo.lower_case_identifier) #define SC_MALLOC_return_with_error(t, tp, s, a, m, r) \ do { \ if (t = (tp *) malloc(s), NULL == t) \ { \ SC_set_error(a, STMT_NO_MEMORY_ERROR, m, "SC_MALLOC"); \ return r; \ } \ } while (0) #define SC_MALLOC_gexit_with_error(t, tp, s, a, m, r) \ do { \ if (t = (tp *) malloc(s), NULL == t) \ { \ SC_set_error(a, STMT_NO_MEMORY_ERROR, m, "SC_MALLOC"); \ r; \ goto cleanup; \ } \ } while (0) #define SC_REALLOC_return_with_error(t, tp, s, a, m, r) \ do { \ tp *tmp; \ if (tmp = (tp *) realloc(t, s), NULL == tmp) \ { \ SC_set_error(a, STMT_NO_MEMORY_ERROR, m, "SC_REALLOC"); \ return r; \ } \ t = tmp; \ } while (0) #define SC_REALLOC_gexit_with_error(t, tp, s, a, m, r) \ do { \ tp *tmp; \ if (tmp = (tp *) realloc(t, s), NULL == tmp) \ { \ SC_set_error(a, STMT_NO_MEMORY_ERROR, m, __FUNCTION__); \ r; \ goto cleanup; \ } \ t = tmp; \ } while (0) /* options for SC_free_params() */ #define STMT_FREE_PARAMS_ALL 0 #define STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY 1 /* prepare state */ enum { NON_PREPARE_STATEMENT = 0 , PREPARE_STATEMENT = 1 , PREPARE_BY_THE_DRIVER = (1L << 1) , NAMED_PARSE_REQUEST = (3L << 1) , PARSE_TO_EXEC_ONCE = (4L << 1) , PARSE_REQ_FOR_INFO = (5L << 1) }; /* prepared state */ enum { NOT_YET_PREPARED = 0 ,PREPARING_PERMANENTLY ,PREPARING_TEMPORARILY ,PREPARED_PERMANENTLY ,PREPARED_TEMPORARILY /* Is currently, or once was, prepared as unnamed * statement. You must check * connection->unnamed_prepared_stmt to see if it * still is */ }; /* misc info */ #define SC_set_fetchcursor(a) ((a)->miscinfo |= (1L << 1)) #define SC_no_fetchcursor(a) ((a)->miscinfo &= ~(1L << 1)) #define SC_is_fetchcursor(a) (((a)->miscinfo & (1L << 1)) != 0) #define SC_miscinfo_clear(a) ((a)->miscinfo = 0) #define SC_set_with_hold(a) ((a)->execinfo |= 1L) #define SC_set_without_hold(a) ((a)->execinfo &= (~1L)) #define SC_is_with_hold(a) (((a)->execinfo & 1L) != 0) #define SC_set_readonly(a) ((a)->execinfo |= (1L << 1)) #define SC_set_no_readonly(a) ((a)->execinfo &= ~(1L << 1)) #define SC_is_readonly(a) (((a)->execinfo & (1L << 1)) != 0) #define SC_execinfo_clear(a) (((a)->execinfo = 0) #define STMT_HAS_NO_JOIN 0L #define STMT_HAS_OUTER_JOIN 1L #define STMT_HAS_INNER_JOIN (1L << 1) #define SC_has_join(a) (0 != (a)->join_info) #define SC_has_outer_join(a) (0 != (STMT_HAS_OUTER_JOIN & (a)->join_info)) #define SC_has_inner_join(a) (0 != (STMT_HAS_INNER_JOIN & (a)->join_info)) #define SC_set_outer_join(a) ((a)->join_info |= STMT_HAS_OUTER_JOIN) #define SC_set_inner_join(a) ((a)->join_info |= STMT_HAS_INNER_JOIN) #define SC_start_tc_stmt(a) ((a)->rb_or_tc = (1L << 1)) #define SC_is_tc_stmt(a) (((a)->rb_or_tc & (1L << 1)) != 0) #define SC_start_rb_stmt(a) ((a)->rb_or_tc = (1L << 2)) #define SC_is_rb_stmt(a) (((a)->rb_or_tc & (1L << 2)) != 0) #define SC_unref_CC_error(a) (((a)->ref_CC_error) = FALSE) #define SC_ref_CC_error(a) (((a)->ref_CC_error) = TRUE) #define SC_can_parse_statement(a) (STMT_TYPE_SELECT == (a)->statement_type) /* * DECLARE CURSOR + FETCH can only be used with SELECT-type queries. And * it's not currently supported with array-bound parameters. */ #define SC_may_use_cursor(a) \ (SC_get_APDF(a)->paramset_size <= 1 && \ (STMT_TYPE_SELECT == (a)->statement_type || STMT_TYPE_WITH == (a)->statement_type) ) #define SC_may_fetch_rows(a) (STMT_TYPE_SELECT == (a)->statement_type || STMT_TYPE_WITH == (a)->statement_type) /* For Multi-thread */ #if defined(WIN_MULTITHREAD_SUPPORT) #define INIT_STMT_CS(x) InitializeCriticalSection(&((x)->cs)) #define ENTER_STMT_CS(x) EnterCriticalSection(&((x)->cs)) #define TRY_ENTER_STMT_CS(x) TryEnterCriticalSection(&((x)->cs)) #define LEAVE_STMT_CS(x) LeaveCriticalSection(&((x)->cs)) #define DELETE_STMT_CS(x) DeleteCriticalSection(&((x)->cs)) #elif defined(POSIX_THREADMUTEX_SUPPORT) #define INIT_STMT_CS(x) pthread_mutex_init(&((x)->cs),0) #define ENTER_STMT_CS(x) pthread_mutex_lock(&((x)->cs)) #define TRY_ENTER_STMT_CS(x) (0 == pthread_mutex_trylock(&((x)->cs))) #define LEAVE_STMT_CS(x) pthread_mutex_unlock(&((x)->cs)) #define DELETE_STMT_CS(x) pthread_mutex_destroy(&((x)->cs)) #else #define INIT_STMT_CS(x) #define ENTER_STMT_CS(x) #define TRY_ENTER_STMT_CS(x) (1) #define LEAVE_STMT_CS(x) #define DELETE_STMT_CS(x) #endif /* WIN_MULTITHREAD_SUPPORT */ /* Statement prototypes */ StatementClass *SC_Constructor(ConnectionClass *); void InitializeStatementOptions(StatementOptions *opt); char SC_Destructor(StatementClass *self); BOOL SC_opencheck(StatementClass *self, const char *func); RETCODE SC_initialize_and_recycle(StatementClass *self); void SC_initialize_cols_info(StatementClass *self, BOOL DCdestroy, BOOL parseReset); void SC_reset_result_for_rerun(StatementClass *self); int statement_type(const char *statement); char parse_statement(StatementClass *stmt, BOOL); char parse_sqlsvr(StatementClass *stmt); SQLRETURN SC_set_SS_columnkey(StatementClass *stmt); Int4 SC_describe(StatementClass *self); char SC_unbind_cols(StatementClass *self); char SC_recycle_statement(StatementClass *self); void SC_clear_error(StatementClass *self); void SC_set_error(StatementClass *self, int errnum, const char *msg, const char *func); void SC_set_errormsg(StatementClass *self, const char *msg); void SC_error_copy(StatementClass *self, const StatementClass *from, BOOL); void SC_full_error_copy(StatementClass *self, const StatementClass *from, BOOL); void SC_replace_error_with_res(StatementClass *self, int errnum, const char *msg, const QResultClass*, BOOL); void SC_set_prepared(StatementClass *self, int); void SC_set_planname(StatementClass *self, const char *plan_name); void SC_set_rowset_start(StatementClass *self, SQLLEN, BOOL); void SC_inc_rowset_start(StatementClass *self, SQLLEN); RETCODE SC_initialize_stmts(StatementClass *self, BOOL); RETCODE SC_execute(StatementClass *self); RETCODE SC_fetch(StatementClass *self); void SC_free_params(StatementClass *self, char option); void SC_log_error(const char *func, const char *desc, const StatementClass *self); time_t SC_get_time(StatementClass *self); struct tm *SC_get_localtime(StatementClass *self); SQLLEN SC_get_int4_bookmark(StatementClass *self); RETCODE SC_pos_reload(StatementClass *self, SQLULEN index, UInt2 *, Int4); RETCODE SC_pos_update(StatementClass *self, SQLSETPOSIROW irow, SQLULEN index, const KeySet *keyset); RETCODE SC_pos_delete(StatementClass *self, SQLSETPOSIROW irow, SQLULEN index, const KeySet *keyset); RETCODE SC_pos_refresh(StatementClass *self, SQLSETPOSIROW irow, SQLULEN index); RETCODE SC_pos_fetch(StatementClass *self, const PG_BM *pg_bm); RETCODE SC_pos_add(StatementClass *self, SQLSETPOSIROW irow); RETCODE SC_fetch_by_bookmark(StatementClass *self); int SC_Create_bookmark(StatementClass *stmt, BindInfoClass *bookmark, Int4 row_pos, Int4 currTuple, const KeySet *keyset); PG_BM SC_Resolve_bookmark(const ARDFields *opts, Int4 idx); int SC_set_current_col(StatementClass *self, int col); void SC_setInsertedTable(StatementClass *, RETCODE); void SC_scanQueryAndCountParams(const char *, const ConnectionClass *, ssize_t *next_cmd, SQLSMALLINT *num_params, po_ind_t *multi, po_ind_t *proc_return); BOOL SC_IsExecuting(const StatementClass *self); BOOL SC_SetExecuting(StatementClass *self, BOOL on); BOOL SC_SetCancelRequest(StatementClass *self); BOOL SC_AcceptedCancelRequest(const StatementClass *self); BOOL SC_connection_lost_check(StatementClass *stmt, const char *funcname); int enqueueNeedDataCallback(StatementClass *self, NeedDataCallfunc, void *); RETCODE dequeueNeedDataCallback(RETCODE, StatementClass *self); void cancelNeedDataState(StatementClass *self); int StartRollbackState(StatementClass *self); RETCODE SetStatementSvp(StatementClass *self, unsigned int option); RETCODE DiscardStatementSvp(StatementClass *self, RETCODE, BOOL errorOnly); QResultClass *ParseAndDescribeWithLibpq(StatementClass *stmt, const char *plan_name, const char *query_p, Int2 num_params, const char *comment, QResultClass *res); BOOL CheckPgClassInfo(StatementClass *); /* * Macros to convert global index <-> relative index in resultset/rowset */ /* a global index to the relative index in a rowset */ #define SC_get_rowset_start(stmt) ((stmt)->rowset_start) #define GIdx2RowIdx(gidx, stmt) (gidx - (stmt)->rowset_start) /* a global index to the relative index in a resultset(not a rowset) */ #define GIdx2CacheIdx(gidx, s, r) (gidx - (QR_has_valid_base(r) ? ((s)->rowset_start - (r)->base) : 0)) #define GIdx2KResIdx(gidx, s, r) (gidx - (QR_has_valid_base(r) ? ((s)->rowset_start - (r)->key_base) : 0)) /* a relative index in a rowset to the global index */ #define RowIdx2GIdx(ridx, stmt) (ridx + (stmt)->rowset_start) /* a relative index in a resultset to the global index */ #define CacheIdx2GIdx(ridx, stmt, res) (ridx - (res)->base + (stmt)->rowset_start) #define KResIdx2GIdx(ridx, stmt, res) (ridx - (res)->key_base + (stmt)->rowset_start) #define BOOKMARK_SHIFT 1 #define SC_make_int4_bookmark(b) ((b < 0) ? (b) : (b + BOOKMARK_SHIFT)) #define SC_resolve_int4_bookmark(b) ((b < 0) ? (b) : (b - BOOKMARK_SHIFT)) #endif /* __STATEMENT_H__ */ psqlodbc-REL-16_00_0005/test/000077500000000000000000000000001462406103600154555ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/test/.gitignore000066400000000000000000000002611462406103600174440ustar00rootroot00000000000000/runsuite /runsuite.exe /reset-db /reset-db.exe # Generated by running the tests /results/ # Generated by autoconf /Makefile # Generated by odbcini-gen /odbc.ini /odbcinst.ini psqlodbc-REL-16_00_0005/test/Makefile.in000066400000000000000000000064731462406103600175340ustar00rootroot00000000000000# The list of test is stored in a separate file, so that it can be shared with # the Windows makefile, win.mak. origdir = @srcdir@ vpath %.c $(origdir) vpath %.sh $(origdir) include $(origdir)/tests # The included file defined variable TESTBINS, which is a list of program # names in format exe/-test. Extract the base test names from it. TESTNAMES = $(patsubst exe/%-test,%, $(TESTBINS)) # Set by autoconf LDFLAGS = @LDFLAGS@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ -I.. # config.h ODBC_CONFIG = @ODBC_CONFIG@ PROVE = @PROVE@ LIBODBC = @LIBODBC@ all: $(TESTBINS) runsuite reset-db odbc.ini: $(origdir)/odbcini-gen.sh $(odbc_ini_extras) installcheck: all odbc.ini reset-db runsuite rm -f regression.diffs @if test ! -d results; then mkdir -p results; fi ODBCSYSINI=. ODBCINSTINI=./odbcinst.ini ODBCINI=./odbc.ini ./reset-db < $(origdir)/sampletables.sql # If the perl 'prove' test running utility is available, use it. It produces # nice output. But otherwise just run the plain suite, it's usable as is too. ifdef PROVE prove -e ./runsuite $(TESTNAMES) :: --inputdir=$(origdir) else ./runsuite $(TESTNAMES) --inputdir=$(origdir) endif override CFLAGS += -Wno-pointer-sign $(CFLAGS_ADD) runsuite: runsuite.c reset-db: reset-db.c exe/common.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBODBC) exe/common.o: src/common.c @if test ! -d exe; then mkdir -p exe; fi $(COMPILE.c) -c $< -o $@ $(origdir)/src/wchar-char-test.c: $(wildcard $(origdir)/src/wchar-char-test-*.c) @touch -c $@ # For each test, compile the .c file. exe/%-test: src/%-test.c exe/common.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o exe/$*-test $(LIBODBC) # This target runs the regression tests with all combinations of # UseDeclareFetch, UseServerSidePrepare and Protocol options. installcheck-all: rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=1 Protocol=7.4-2" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=1 Protocol=7.4-1" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=1 Protocol=7.4-0" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=0 Protocol=7.4-2" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=0 Protocol=7.4-1" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=0 UseServerSidePrepare=0 Protocol=7.4-0" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=1 Protocol=7.4-2" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=1 Protocol=7.4-1" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=1 Protocol=7.4-0" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=0 Protocol=7.4-2" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=0 Protocol=7.4-1" rm -f odbc.ini odbcinst.ini $(MAKE) installcheck odbc_ini_extras="UseDeclareFetch=1 UseServerSidePrepare=0 Protocol=7.4-0" clean: rm -f $(TESTBINS) exe/*.o runsuite reset-db rm -f results/* psqlodbc-REL-16_00_0005/test/README.txt000066400000000000000000000032431462406103600171550ustar00rootroot00000000000000This directory contains a regression test suite for the psqlODBC driver. Prerequisites ------------- To run the regression tests, you must have a PostgreSQL server running and accepting connections from the host where you run the regression tests. By default in Linux, the regression tests use the driver built from the parent directory, ../.libs/psqlodbcw.so, for the tests. You can edit odbcinst.ini in this directory to test a different version. Running the tests ----------------- Linux ===== To run the test suite, type: make installcheck The test suite uses the normal ODBC / libpq defaults, which assume that the server is running on the same host, at port 5432, and the username is the same as the OS username. You can use PGHOST, PGUSER, etc. environment variables or .pgpass to override these defaults. You can also run "make installcheck-all" to run the regression suite with different combinations of configuration options. Windows ======= To run the test suite, you need first to build and install the driver, and create a Data Source with the name "psqlodbc_test_dsn". This DSN is used by all the regression tests, and it should point to a valid PostgreSQL server. Then type the following commands to run the tests: nmake /f win.mak nmake /f win.mak installcheck Development ----------- To add a test, add a *-test.c file to src/ directory, using one of the existing tests as example. Also add the test to the TESTS list in the "tests" file, and create an expected output file in expected/ directory. The current test suite only tests a small fraction of the codebase. Whenever you add a new feature, or fix a non-trivial bug, please add a test case to cover it. psqlodbc-REL-16_00_0005/test/RegisterRegdsn.c000077500000000000000000000164571462406103600205700ustar00rootroot00000000000000#include #include #include #include #define RETURN_1 \ { \ char gtlin[80]; \ fprintf(stderr, "Hit return key to continue ...\n"); \ fflush(stderr); \ fgets(gtlin, sizeof(gtlin), stdin); \ return 1; \ } DWORD err() { RETCODE ret; DWORD ErrorCode = 0; char szMsg[256]; WORD cbMsg; int i; for (i = 1; i <= 8; i++) { ret = SQLInstallerError(i, &ErrorCode, szMsg, sizeof(szMsg), &cbMsg); if (!SQL_SUCCEEDED(ret)) break; szMsg[cbMsg] = '\0'; fprintf(stderr, "SQLInstallDriverEx ErrorCode=%d:%s\n", ErrorCode, szMsg); switch (ErrorCode) { case ODBC_ERROR_COMPONENT_NOT_FOUND: case ODBC_ERROR_INVALID_NAME: return ErrorCode; } } return ErrorCode; } static int inst_driver(const char *driver, const char *pathIn, const char *key_value_pairs) { char szDriver[256], szOut[256]; DWORD usageCount; size_t pcnt; WORD cbMsg; char *psz, *pchr; memset(szDriver, 0, sizeof(szDriver)); psz = szDriver; strncpy(szDriver, driver, sizeof(szDriver)); pcnt = strlen(psz) + 1; psz += pcnt; strncpy(psz, key_value_pairs, sizeof(szDriver) - pcnt); for (pchr = psz; *pchr; pchr++) { if (*pchr == '|') *pchr = '\0'; } psz += (strlen(psz) + 1); if (!SQLInstallDriverEx(szDriver, pathIn, szOut, sizeof(szOut), &cbMsg, ODBC_INSTALL_COMPLETE, &usageCount)) { err(); fprintf(stderr, "SQLInstallDriverEx %s:%s:%s error\n", szDriver, szDriver + strlen(szDriver) + 2, pathIn); RETURN_1 } if (!SQLConfigDriver(NULL, ODBC_INSTALL_DRIVER, driver, "", szOut, sizeof(szOut), &cbMsg)) { err(); fprintf(stderr, "SQLConfigDriver %s error\n", driver); RETURN_1 } fprintf(stderr, "SQLInstallDriverEx driver=%s\n", driver); return 0; } static int uninst_driver(const char *driver) { DWORD usageCount; if (!SQLRemoveDriver(driver, FALSE, &usageCount)) { err(); fprintf(stderr, "SQLRemoveDriver %s error\n", driver); RETURN_1 } return 0; } static int add_dsn(const char *driver, const char *dsn, const char *key_value_pairs) { char szDsn[256]; char *psz, *pchr; size_t pcnt; memset(szDsn, 0, sizeof(szDsn)); psz = szDsn; _snprintf(psz, sizeof(szDsn), "DSN=%s", dsn); pcnt = strlen(psz) + 1; psz += pcnt; strncpy(psz, key_value_pairs, sizeof(szDsn) - pcnt); for (pchr = psz; *pchr; pchr++) { if (*pchr == '|') *pchr = '\0'; } psz += (strlen(psz) + 1); if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, driver, szDsn)) { switch (err()) { case ODBC_ERROR_COMPONENT_NOT_FOUND: case ODBC_ERROR_INVALID_NAME: return -1; } fprintf(stderr, "SQLConfigDataSource ADD_SYS_DSN %s error\n", driver); RETURN_1 } fprintf(stderr, "SQLConfigDataSource ADD_SYS_DSN %s\n", dsn); return 0; } typedef SQLRETURN (SQL_API *SQLAPIPROC)(); static int driverExists(const char *driver) { HMODULE hmodule; SQLHENV henv; int retcode = 1; char drvrname[64], drvratt[128]; SQLUSMALLINT direction = SQL_FETCH_FIRST; SQLSMALLINT drvrncount, drvracount; SQLRETURN ret; SQLAPIPROC addr; hmodule = LoadLibrary("ODBC32"); if (!hmodule) { fprintf(stderr, "LoadLibrary ODBC32 failed\n"); RETURN_1; } addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLAllocEnv"); if (!addr) { fprintf(stderr, "GetProcAddress for SQLAllocEnv failed\n"); RETURN_1; } ret = (*addr)(&henv); if (!SQL_SUCCEEDED(ret)) { fprintf(stderr, "SQLAllocEnv failed\n"); RETURN_1; } retcode = -2; do { ret = SQLDrivers(henv, direction, drvrname, sizeof(drvrname), &drvrncount, drvratt, sizeof(drvratt), &drvracount); if (!SQL_SUCCEEDED(ret)) break; if (_strnicmp(drvrname, driver, sizeof(drvrname)) == 0) { retcode = 0; break; } direction = SQL_FETCH_NEXT; } while (1); addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLFreeEnv"); if (addr) (*addr)(henv); FreeLibrary(hmodule); return retcode; } static int dsnExists(const char *dsn) { HMODULE hmodule; SQLHENV henv; int retcode = 1; char dsnname[64], dsnatt[128]; SQLUSMALLINT direction = SQL_FETCH_FIRST; SQLSMALLINT dsnncount, dsnacount; SQLRETURN ret; SQLAPIPROC addr; hmodule = LoadLibrary("ODBC32"); if (!hmodule) { fprintf(stderr, "LoadLibrary ODBC32 failed\n"); RETURN_1; } addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLAllocEnv"); if (!addr) { fprintf(stderr, "GetProcAddress for SQLAllocEnv failed\n"); RETURN_1; } ret = (*addr)(&henv); if (!SQL_SUCCEEDED(ret)) { fprintf(stderr, "SQLAllocEnv failed\n"); RETURN_1; } retcode = -1; do { ret = SQLDataSources(henv, direction, dsnname, sizeof(dsnname), &dsnncount, dsnatt, sizeof(dsnatt), &dsnacount); if (!SQL_SUCCEEDED(ret)) break; if (_strnicmp(dsnname, dsn, sizeof(dsnname)) == 0) { retcode = 0; break; } direction = SQL_FETCH_NEXT; } while (1); if (0 == retcode) { retcode = driverExists(dsnatt); if (-2 == retcode) { fprintf(stderr, "\t!! The driver %s of dsn %s does not exist\n", dsnatt, dsn); } } addr = (SQLAPIPROC) GetProcAddress(hmodule, "SQLFreeEnv"); if (addr) (*addr)(henv); FreeLibrary(hmodule); return retcode; } static int register_dsn(const char *driver, const char *dsn, const char *key_value_pairs, const char *pathIn, const char *driver_key_value_pairs) { int ret; if (ret = dsnExists(dsn), ret != -1) return ret; if (ret = add_dsn(driver, dsn, key_value_pairs), ret != -1) return ret; fprintf(stderr, "\tAdding driver %s of %s\n", driver, pathIn); if (ret = inst_driver(driver, pathIn, driver_key_value_pairs), ret != 0) return ret; return add_dsn(driver, dsn, key_value_pairs); } /* * SQLInstallDriverEx -> SQLConfigDriver * * SQLRemoveDriver <- SQConfigDriver(ODBC_REMOVE_DRIVER) */ #define FIRSTCHARS(c1, c2, c3, c4) \ ((unsigned)c1 + ((unsigned)c2 << 8) + ((unsigned)c3 << 16) + ((unsigned)c4 << 24)) int main(int argc, char **argv) { const char *driver = argv[2]; int retcode; if (argc < 3) { fprintf(stderr, "%s needs at least 2 parameters\n", argv[0]); return 1; } switch (FIRSTCHARS(argv[1][0], argv[1][1], argv[1][2], argv[1][3])) { // check_dsn case FIRSTCHARS('c', 'h', 'e', 'c'): return dsnExists(argv[2]); // register_dsn case FIRSTCHARS('r', 'e', 'g', 'i'): if (argc < 7) { fprintf(stderr, "register_dsn option needs 5 parameters\n"); return 1; } return register_dsn(driver, argv[3], argv[4], argv[5], argv[6]); // install_driver case FIRSTCHARS('i', 'n', 's', 't'): if (argc < 5) { fprintf(stderr, "install_driver option needs 3 parameters\n"); return 1; } return inst_driver(driver, argv[3], argv[4]); // reinstall_driver case FIRSTCHARS('r', 'e', 'i', 'n'): if (argc < 5) { fprintf(stderr, "reinstall_driver option needs 3 parameters\n"); return 1; } switch (retcode = driverExists(driver)) { case 0: retcode = uninst_driver(driver); if (0 != retcode) return retcode; break; case -2: break; default: return retcode; } return inst_driver(driver, argv[3], argv[4]); // uninstall_driver case FIRSTCHARS('u', 'n', 'i', 'n'): if (argc < 3) { fprintf(stderr, "uninstall_driver option needs 1 parameter\n"); return 1; } return uninst_driver(driver); // add_dsn case FIRSTCHARS('a', 'd', 'd', '_'): if (argc < 5) { fprintf(stderr, "add_dsn option needs 3 parameters\n"); return 1; } return add_dsn(driver, argv[3], argv[4]); } fprintf(stderr, "mode %s is invalid\n", argv[1]); return 1; } psqlodbc-REL-16_00_0005/test/expected/000077500000000000000000000000001462406103600172565ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/test/expected/alter.out000066400000000000000000000002101462406103600211070ustar00rootroot00000000000000connected Result set metadata: t: VARCHAR(40) digits: 0, nullable Result set metadata: t: VARCHAR(80) digits: 0, nullable disconnecting psqlodbc-REL-16_00_0005/test/expected/alter_1.out000066400000000000000000000002121462406103600213310ustar00rootroot00000000000000connected Result set metadata: t: WVARCHAR(40) digits: 0, nullable Result set metadata: t: WVARCHAR(80) digits: 0, nullable disconnecting psqlodbc-REL-16_00_0005/test/expected/arraybinding.out000066400000000000000000000007271462406103600224660ustar00rootroot00000000000000connected Parameter Status Result set: 10000 Result set: 0 columnwise 0 1 columnwise 1 100 columnwise 100 9999 columnwise 9999 Parameter Status Fetching result sets for array bound (5 results expected) 1: Result set: columnwise 100 2: Result set: columnwise 101 3: Result set: columnwise 102 4: Result set: columnwise 103 5: Result set: columnwise 104 Number of rows in table: Result set: 9995 Result set: 0 columnwise 0 1 columnwise 1 9999 columnwise 9999 disconnecting psqlodbc-REL-16_00_0005/test/expected/bindcol.out000066400000000000000000000001531462406103600214200ustar00rootroot00000000000000connected Result set: 1 foo1 2 foo2 3 foo3 4 foo3 5 foo3 6 foo6 7 foo7 7 foo7 7 foo7 7 foo10 disconnecting psqlodbc-REL-16_00_0005/test/expected/bookmark.out000066400000000000000000000012211462406103600216100ustar00rootroot00000000000000connected Getting bookmark to beginning of result set... fetched: foo1 Moving +100... fetched: foo101 Getting bookmark to middle of result set... Moving +100... fetched: foo201 Testing SQL_FETCH_BOOKMARK, begin (0)... fetched: foo1 Testing SQL_FETCH_BOOKMARK, begin (10)... fetched: foo11 Testing SQL_FETCH_BOOKMARK, middle (0)... fetched: foo101 Testing SQL_FETCH_BOOKMARK, middle (10)... fetched: foo111 Testing SQL_FETCH_BOOKMARK, middle (-10)... fetched: foo91 Getting bookmark with SQLBindCol... fetched: foo100 Unbinding boomark column... Moving +100... fetched: foo200 Goind back to bookmark acquired with SQLBindCol... fetched: foo100 disconnecting psqlodbc-REL-16_00_0005/test/expected/boolsaschar.out000066400000000000000000000003001462406103600223000ustar00rootroot00000000000000connected Result set metadata: b: VARCHAR(5) digits: 0, nullable Result set: 2 yes 1 Result set metadata: b: VARCHAR(5) digits: 0, nullable Result set: 1 yeah 1 2 yes 1 3 true 1 disconnecting psqlodbc-REL-16_00_0005/test/expected/bulkoperations.out000077500000000000000000000005641462406103600230600ustar00rootroot00000000000000connected Creating test table bulkoperations_test Opening a cursor for update, and fetching 10 rows 1 1 2 2 3 3 4 4 5 5 Updating result set 105 5 Testing bulk fetch of original, updated, and inserted rows row no #2: 2 - 2 updated row: 105 - 5 inserted row: 1234 - 5678 Querying the table again Result set: 1 1 2 2 3 3 4 4 105 5 6 6 7 7 9 9 10 10 1234 5678 disconnecting psqlodbc-REL-16_00_0005/test/expected/catalogfunctions.out000066400000000000000000000241311462406103600233530ustar00rootroot00000000000000connected Check for SQLTypeInfo Result set metadata: TYPE_NAME: VARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable LITERAL_PREFIX: VARCHAR(128) digits: 0, nullable LITERAL_SUFFIX: VARCHAR(128) digits: 0, nullable CREATE_PARAMS: VARCHAR(128) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable CASE_SENSITIVE: SMALLINT(5) digits: 0, nullable SEARCHABLE: SMALLINT(5) digits: 0, nullable UNSIGNED_ATTRIBUTE: SMALLINT(5) digits: 0, nullable FIXED_PREC_SCALE: SMALLINT(5) digits: 0, nullable AUTO_UNIQUE_VALUE: SMALLINT(5) digits: 0, nullable LOCAL_TYPE_NAME: VARCHAR(128) digits: 0, nullable MINIMUM_SCALE: SMALLINT(5) digits: 0, nullable MAXIMUM_SCALE: SMALLINT(5) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: INTEGER(10) digits: 0, nullable INTERVAL_PRECISION: SMALLINT(5) digits: 0, nullable Result set: varchar 12 255 ' ' max. length 1 1 3 NULL 0 NULL NULL NULL NULL 12 NULL NULL 0 Check for SQLTables Result set metadata: TABLE_CAT: VARCHAR(128) digits: 0, nullable TABLE_SCHEM: VARCHAR(128) digits: 0, nullable TABLE_NAME: VARCHAR(128) digits: 0, nullable TABLE_TYPE: VARCHAR(128) digits: 0, nullable REMARKS: VARCHAR(254) digits: 0, nullable Result set: contrib_regression public booltab TABLE contrib_regression public byteatab TABLE contrib_regression public intervaltable TABLE contrib_regression public lo_test_tab TABLE contrib_regression public testforeign FOREIGN TABLE contrib_regression public testmatview MATVIEW contrib_regression public testtab1 TABLE contrib_regression public testtab_fk TABLE Check for SQLColumns Result set metadata: TABLE_CAT: VARCHAR(128) digits: 0, nullable TABLE_SCHEM: VARCHAR(128) digits: 0, nullable TABLE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_NAME: VARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: SMALLINT(5) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable REMARKS: VARCHAR(254) digits: 0, nullable COLUMN_DEF: VARCHAR(254) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable ORDINAL_POSITION: INTEGER(10) digits: 0, nullable IS_NULLABLE: VARCHAR(254) digits: 0, nullable DISPLAY_SIZE: INTEGER(10) digits: 0, nullable FIELD_TYPE: INTEGER(10) digits: 0, nullable AUTO_INCREMENT: INTEGER(10) digits: 0, nullable PHYSICAL NUMBER: SMALLINT(5) digits: 0, nullable TABLE OID: INTEGER(10) digits: 0, nullable BASE TYPEID: INTEGER(10) digits: 0, nullable TYPMOD: INTEGER(10) digits: 0, nullable TABLE INFO: INTEGER(10) digits: 0, nullable Result set: contrib_regression public booltab id 4 int4 contrib_regression public booltab t 12 varchar contrib_regression public booltab b 12 bool contrib_regression public byteatab id 4 int4 contrib_regression public byteatab t -4 bytea contrib_regression public intervaltable id 4 int4 contrib_regression public intervaltable iv 12 interval contrib_regression public intervaltable d 12 varchar contrib_regression public lo_test_tab id 4 int4 contrib_regression public lo_test_tab large_data -4 lo contrib_regression public testforeign c1 4 int4 contrib_regression public testmatview id 4 int4 contrib_regression public testmatview t 12 varchar contrib_regression public testtab1 id 4 int4 contrib_regression public testtab1 t 12 varchar contrib_regression public testtab1_pkey id 4 int4 contrib_regression public testtab_fk id 4 int4 contrib_regression public testtab_fk t 12 varchar contrib_regression public testview id 4 int4 contrib_regression public testview t 12 varchar Check for SQLColumnPrivileges Result set metadata: table_cat: VARCHAR(63) digits: 0, nullable table_schem: VARCHAR(63) digits: 0, nullable table_name: VARCHAR(63) digits: 0, nullable column_name: VARCHAR(63) digits: 0, nullable grantor: VARCHAR(63) digits: 0, nullable grantee: VARCHAR(63) digits: 0, nullable privilege: VARCHAR(255) digits: 0, nullable is_grantable: VARCHAR(3) digits: 0, nullable Result set: contrib_regression public testtab1 id UPDATE YES contrib_regression public testtab1 id SELECT YES contrib_regression public testtab1 id REFERENCES YES contrib_regression public testtab1 id INSERT YES Check for SQLSpecialColumns Result set metadata: SCOPE: SMALLINT(5) digits: 0, nullable COLUMN_NAME: VARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable PSEUDO_COLUMN: SMALLINT(5) digits: 0, nullable Result set: NULL xmin 4 xid 10 4 0 2 Check for SQLStatistics Result set metadata: TABLE_CAT: VARCHAR(128) digits: 0, nullable TABLE_SCHEM: VARCHAR(128) digits: 0, nullable TABLE_NAME: VARCHAR(128) digits: 0, nullable NON_UNIQUE: SMALLINT(5) digits: 0, nullable INDEX_QUALIFIER: VARCHAR(128) digits: 0, nullable INDEX_NAME: VARCHAR(128) digits: 0, nullable TYPE: SMALLINT(5) digits: 0, nullable ORDINAL_POSITION: SMALLINT(5) digits: 0, nullable COLUMN_NAME: VARCHAR(128) digits: 0, nullable ASC_OR_DESC: CHAR(1) digits: 0, nullable CARDINALITY: INTEGER(10) digits: 0, nullable PAGES: INTEGER(10) digits: 0, nullable FILTER_CONDITION: VARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 0 public testtab1_pkey 3 1 id A NULL NULL NULL Check for SQLPrimaryKeys Result set metadata: TABLE_CAT: VARCHAR(128) digits: 0, nullable TABLE_SCHEM: VARCHAR(128) digits: 0, nullable TABLE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_NAME: VARCHAR(128) digits: 0, nullable KEY_SEQ: SMALLINT(5) digits: 0, nullable PK_NAME: VARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 id 1 testtab1_pkey Check for SQLForeignKeys Result set metadata: PKTABLE_CAT: VARCHAR(63) digits: 0, nullable PKTABLE_SCHEM: VARCHAR(63) digits: 0, not nullable PKTABLE_NAME: VARCHAR(63) digits: 0, not nullable PKCOLUMN_NAME: VARCHAR(63) digits: 0, not nullable FKTABLE_CAT: VARCHAR(63) digits: 0, nullable FKTABLE_SCHEM: VARCHAR(63) digits: 0, not nullable FKTABLE_NAME: VARCHAR(63) digits: 0, not nullable FKCOLUMN_NAME: VARCHAR(63) digits: 0, not nullable KEY_SEQ: SMALLINT(5) digits: 0, nullable UPDATE_RULE: SMALLINT(5) digits: 0, nullable DELETE_RULE: SMALLINT(5) digits: 0, nullable FK_NAME: VARCHAR(63) digits: 0, not nullable PK_NAME: VARCHAR(63) digits: 0, not nullable DEFERRABILITY: SMALLINT(5) digits: 0, nullable Result set: contrib_regression public testtab1 id contrib_regression public testtab_fk id 1 3 3 testtab_fk_id_fkey testtab1_pkey 7 Check for SQLProcedures Result set metadata: procedure_cat: VARCHAR(255) digits: 0, nullable procedure_schem: VARCHAR(63) digits: 0, not nullable procedure_name: VARCHAR(63) digits: 0, not nullable num_input_params: VARCHAR(255) digits: 0, nullable num_output_params: VARCHAR(255) digits: 0, nullable num_result_sets: VARCHAR(255) digits: 0, nullable remarks: VARCHAR(255) digits: 0, nullable procedure_type: SMALLINT(5) digits: 0, nullable Result set: public simple_add 2 Check for SQLProcedureColumns Result set metadata: PROCEDURE_CAT: VARCHAR(128) digits: 0, nullable PROCEDUR_SCHEM: VARCHAR(128) digits: 0, nullable PROCEDURE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_NAME: VARCHAR(128) digits: 0, nullable COLUMN_TYPE: SMALLINT(5) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: VARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: SMALLINT(5) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable REMARKS: VARCHAR(128) digits: 0, nullable COLUMN_DEF: VARCHAR(128) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable ORDINAL_POSITION: INTEGER(10) digits: 0, nullable IS_NULLABLE: VARCHAR(128) digits: 0, nullable Result set: contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 1 contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 2 contrib_regression public simple_add 4 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 3 Result set: contrib_regression pg_catalog set_byte 5 -4 bytea contrib_regression pg_catalog set_byte 1 -4 bytea contrib_regression pg_catalog set_byte 1 4 int4 contrib_regression pg_catalog set_byte 1 4 int4 Result set: contrib_regression public getfoo 1 4 int4 contrib_regression public getfoo id 4 4 int4 contrib_regression public getfoo t 4 12 varchar contrib_regression public getfoo b 4 12 bool Result set: contrib_regression public getboo 1 4 int4 contrib_regression public getboo id 3 4 int4 contrib_regression public getboo t 3 12 varchar contrib_regression public getboo b 3 12 bool Result set: contrib_regression public tbl_arg p_f1 1 4 int4 contrib_regression public tbl_arg p_f2 3 -1 text contrib_regression public tbl_arg p_f3 3 12 bool Result set: contrib_regression public set_of p_f1 1 4 int4 contrib_regression public set_of p_f2 3 -1 text contrib_regression public set_of p_f3 3 12 bool Check for SQLTablePrivileges Result set metadata: TABLE_CAT: VARCHAR(128) digits: 0, nullable TABLE_SCHEM: VARCHAR(128) digits: 0, nullable TABLE_NAME: VARCHAR(128) digits: 0, nullable GRANTOR: VARCHAR(128) digits: 0, nullable GRANTEE: VARCHAR(128) digits: 0, nullable PRIVILEGE: VARCHAR(128) digits: 0, nullable IS_GRANTABLE: VARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 _SYSTEM INSERT YES contrib_regression public testtab1 _SYSTEM SELECT YES contrib_regression public testtab1 _SYSTEM UPDATE YES contrib_regression public testtab1 _SYSTEM DELETE YES contrib_regression public testtab1 _SYSTEM REFERENCES YES Check for SQLGetInfo Term for "table": table Result set: contrib_regression public testtab1 TABLE contrib_regression public testtab_fk TABLE Result set: disconnecting connected Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/catalogfunctions_1.out000066400000000000000000000242411462406103600235750ustar00rootroot00000000000000connected Check for SQLTypeInfo Result set metadata: TYPE_NAME: WVARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable LITERAL_PREFIX: WVARCHAR(128) digits: 0, nullable LITERAL_SUFFIX: WVARCHAR(128) digits: 0, nullable CREATE_PARAMS: WVARCHAR(128) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable CASE_SENSITIVE: SMALLINT(5) digits: 0, nullable SEARCHABLE: SMALLINT(5) digits: 0, nullable UNSIGNED_ATTRIBUTE: SMALLINT(5) digits: 0, nullable FIXED_PREC_SCALE: SMALLINT(5) digits: 0, nullable AUTO_UNIQUE_VALUE: SMALLINT(5) digits: 0, nullable LOCAL_TYPE_NAME: WVARCHAR(128) digits: 0, nullable MINIMUM_SCALE: SMALLINT(5) digits: 0, nullable MAXIMUM_SCALE: SMALLINT(5) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: INTEGER(10) digits: 0, nullable INTERVAL_PRECISION: SMALLINT(5) digits: 0, nullable Result set: varchar 12 255 ' ' max. length 1 1 3 NULL 0 NULL NULL NULL NULL -9 NULL NULL 0 Check for SQLTables Result set metadata: TABLE_CAT: WVARCHAR(128) digits: 0, nullable TABLE_SCHEM: WVARCHAR(128) digits: 0, nullable TABLE_NAME: WVARCHAR(128) digits: 0, nullable TABLE_TYPE: WVARCHAR(128) digits: 0, nullable REMARKS: WVARCHAR(254) digits: 0, nullable Result set: contrib_regression public booltab TABLE contrib_regression public byteatab TABLE contrib_regression public intervaltable TABLE contrib_regression public lo_test_tab TABLE contrib_regression public testforeign FOREIGN TABLE contrib_regression public testmatview MATVIEW contrib_regression public testtab1 TABLE contrib_regression public testtab_fk TABLE Check for SQLColumns Result set metadata: TABLE_CAT: WVARCHAR(128) digits: 0, nullable TABLE_SCHEM: WVARCHAR(128) digits: 0, nullable TABLE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_NAME: WVARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: SMALLINT(5) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable REMARKS: WVARCHAR(254) digits: 0, nullable COLUMN_DEF: WVARCHAR(254) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable ORDINAL_POSITION: INTEGER(10) digits: 0, nullable IS_NULLABLE: WVARCHAR(254) digits: 0, nullable DISPLAY_SIZE: INTEGER(10) digits: 0, nullable FIELD_TYPE: INTEGER(10) digits: 0, nullable AUTO_INCREMENT: INTEGER(10) digits: 0, nullable PHYSICAL NUMBER: SMALLINT(5) digits: 0, nullable TABLE OID: INTEGER(10) digits: 0, nullable BASE TYPEID: INTEGER(10) digits: 0, nullable TYPMOD: INTEGER(10) digits: 0, nullable TABLE INFO: INTEGER(10) digits: 0, nullable Result set: contrib_regression public booltab id 4 int4 contrib_regression public booltab t -9 varchar contrib_regression public booltab b 12 bool contrib_regression public byteatab id 4 int4 contrib_regression public byteatab t -4 bytea contrib_regression public intervaltable id 4 int4 contrib_regression public intervaltable iv -9 interval contrib_regression public intervaltable d -9 varchar contrib_regression public lo_test_tab id 4 int4 contrib_regression public lo_test_tab large_data -4 lo contrib_regression public testforeign c1 4 int4 contrib_regression public testmatview id 4 int4 contrib_regression public testmatview t -9 varchar contrib_regression public testtab1 id 4 int4 contrib_regression public testtab1 t -9 varchar contrib_regression public testtab1_pkey id 4 int4 contrib_regression public testtab_fk id 4 int4 contrib_regression public testtab_fk t -9 varchar contrib_regression public testview id 4 int4 contrib_regression public testview t -9 varchar Check for SQLColumnPrivileges Result set metadata: table_cat: WVARCHAR(63) digits: 0, nullable table_schem: WVARCHAR(63) digits: 0, nullable table_name: WVARCHAR(63) digits: 0, nullable column_name: WVARCHAR(63) digits: 0, nullable grantor: WVARCHAR(63) digits: 0, nullable grantee: WVARCHAR(63) digits: 0, nullable privilege: WVARCHAR(255) digits: 0, nullable is_grantable: WVARCHAR(3) digits: 0, nullable Result set: contrib_regression public testtab1 id UPDATE YES contrib_regression public testtab1 id SELECT YES contrib_regression public testtab1 id REFERENCES YES contrib_regression public testtab1 id INSERT YES Check for SQLSpecialColumns Result set metadata: SCOPE: SMALLINT(5) digits: 0, nullable COLUMN_NAME: WVARCHAR(128) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable PSEUDO_COLUMN: SMALLINT(5) digits: 0, nullable Result set: NULL xmin 4 xid 10 4 0 2 Check for SQLStatistics Result set metadata: TABLE_CAT: WVARCHAR(128) digits: 0, nullable TABLE_SCHEM: WVARCHAR(128) digits: 0, nullable TABLE_NAME: WVARCHAR(128) digits: 0, nullable NON_UNIQUE: SMALLINT(5) digits: 0, nullable INDEX_QUALIFIER: WVARCHAR(128) digits: 0, nullable INDEX_NAME: WVARCHAR(128) digits: 0, nullable TYPE: SMALLINT(5) digits: 0, nullable ORDINAL_POSITION: SMALLINT(5) digits: 0, nullable COLUMN_NAME: WVARCHAR(128) digits: 0, nullable ASC_OR_DESC: WCHAR(1) digits: 0, nullable CARDINALITY: INTEGER(10) digits: 0, nullable PAGES: INTEGER(10) digits: 0, nullable FILTER_CONDITION: WVARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 0 public testtab1_pkey 3 1 id A NULL NULL NULL Check for SQLPrimaryKeys Result set metadata: TABLE_CAT: WVARCHAR(128) digits: 0, nullable TABLE_SCHEM: WVARCHAR(128) digits: 0, nullable TABLE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_NAME: WVARCHAR(128) digits: 0, nullable KEY_SEQ: SMALLINT(5) digits: 0, nullable PK_NAME: WVARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 id 1 testtab1_pkey Check for SQLForeignKeys Result set metadata: pktable_cat: WVARCHAR(63) digits: 0, nullable pktable_schem: WVARCHAR(63) digits: 0, not nullable pktable_name: WVARCHAR(63) digits: 0, not nullable pkcolumn_name: WVARCHAR(63) digits: 0, not nullable fktable_cat: WVARCHAR(63) digits: 0, nullable fktable_schem: WVARCHAR(63) digits: 0, not nullable fktable_name: WVARCHAR(63) digits: 0, not nullable fkcolumn_name: WVARCHAR(63) digits: 0, not nullable key_seq: SMALLINT(5) digits: 0, nullable update_rule: SMALLINT(5) digits: 0, nullable delete_rule: SMALLINT(5) digits: 0, nullable fk_name: WVARCHAR(63) digits: 0, not nullable pk_name: WVARCHAR(63) digits: 0, not nullable deferrablity: SMALLINT(5) digits: 0, nullable Result set: contrib_regression public testtab1 id contrib_regression public testtab_fk id 1 3 3 testtab_fk_id_fkey testtab1_pkey 7 Check for SQLProcedures Result set metadata: procedure_cat: WVARCHAR(255) digits: 0, nullable procedure_schem: WVARCHAR(63) digits: 0, not nullable procedure_name: WVARCHAR(63) digits: 0, not nullable num_input_params: WVARCHAR(255) digits: 0, nullable num_output_params: WVARCHAR(255) digits: 0, nullable num_result_sets: WVARCHAR(255) digits: 0, nullable remarks: WVARCHAR(255) digits: 0, nullable procedure_type: SMALLINT(5) digits: 0, nullable Result set: public simple_add 2 Check for SQLProcedureColumns Result set metadata: PROCEDURE_CAT: WVARCHAR(128) digits: 0, nullable PROCEDUR_SCHEM: WVARCHAR(128) digits: 0, nullable PROCEDURE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_TYPE: SMALLINT(5) digits: 0, nullable DATA_TYPE: SMALLINT(5) digits: 0, nullable TYPE_NAME: WVARCHAR(128) digits: 0, nullable COLUMN_SIZE: INTEGER(10) digits: 0, nullable BUFFER_LENGTH: INTEGER(10) digits: 0, nullable DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable NUM_PREC_RADIX: SMALLINT(5) digits: 0, nullable NULLABLE: SMALLINT(5) digits: 0, nullable REMARKS: WVARCHAR(128) digits: 0, nullable COLUMN_DEF: WVARCHAR(128) digits: 0, nullable SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable ORDINAL_POSITION: INTEGER(10) digits: 0, nullable IS_NULLABLE: WVARCHAR(128) digits: 0, nullable Result set: contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 1 contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 2 contrib_regression public simple_add 4 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 3 Result set: contrib_regression pg_catalog set_byte 5 -4 bytea contrib_regression pg_catalog set_byte 1 -4 bytea contrib_regression pg_catalog set_byte 1 4 int4 contrib_regression pg_catalog set_byte 1 4 int4 Result set: contrib_regression public getfoo 1 4 int4 contrib_regression public getfoo id 4 4 int4 contrib_regression public getfoo t 4 12 varchar contrib_regression public getfoo b 4 12 bool Result set: contrib_regression public getboo 1 4 int4 contrib_regression public getboo id 3 4 int4 contrib_regression public getboo t 3 12 varchar contrib_regression public getboo b 3 12 bool Result set: contrib_regression public tbl_arg p_f1 1 4 int4 contrib_regression public tbl_arg p_f2 3 -1 text contrib_regression public tbl_arg p_f3 3 12 bool Result set: contrib_regression public set_of p_f1 1 4 int4 contrib_regression public set_of p_f2 3 -1 text contrib_regression public set_of p_f3 3 12 bool Check for SQLTablePrivileges Result set metadata: TABLE_CAT: WVARCHAR(128) digits: 0, nullable TABLE_SCHEM: WVARCHAR(128) digits: 0, nullable TABLE_NAME: WVARCHAR(128) digits: 0, nullable GRANTOR: WVARCHAR(128) digits: 0, nullable GRANTEE: WVARCHAR(128) digits: 0, nullable PRIVILEGE: WVARCHAR(128) digits: 0, nullable IS_GRANTABLE: WVARCHAR(128) digits: 0, nullable Result set: contrib_regression public testtab1 _SYSTEM INSERT YES contrib_regression public testtab1 _SYSTEM SELECT YES contrib_regression public testtab1 _SYSTEM UPDATE YES contrib_regression public testtab1 _SYSTEM DELETE YES contrib_regression public testtab1 _SYSTEM REFERENCES YES Check for SQLGetInfo Term for "table": table Result set: contrib_regression public testtab1 TABLE contrib_regression public testtab_fk TABLE Result set: disconnecting connected Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/colattribute.out000077500000000000000000000034421462406103600225160ustar00rootroot00000000000000Running tests with UnknownSizes=0;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 32760 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 20 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=1;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 32760 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 20 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=2;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 24 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 56 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 20 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting psqlodbc-REL-16_00_0005/test/expected/colattribute_1.out000066400000000000000000000034341462406103600227340ustar00rootroot00000000000000Running tests with UnknownSizes=0;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 8190 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 5 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=1;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 8190 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 5 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=2;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 6 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 14 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 100 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 5 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting psqlodbc-REL-16_00_0005/test/expected/colattribute_2.out000066400000000000000000000034421462406103600227340ustar00rootroot00000000000000Running tests with UnknownSizes=0;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 16380 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 200 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 200 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 10 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=1;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 16380 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 200 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 200 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 10 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting Running tests with UnknownSizes=2;MaxVarcharSize=100... connected Testing SQLColAttribute... -- Column 1: intcol -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: int4 -- Column 2: textcol -- SQL_DESC_OCTET_LENGTH: 12 SQL_DESC_TYPE_NAME: text -- Column 3: varcharcol -- SQL_DESC_OCTET_LENGTH: 28 SQL_DESC_TYPE_NAME: varchar -- Column 4: empty_varchar_col -- SQL_DESC_OCTET_LENGTH: 200 SQL_DESC_TYPE_NAME: varchar -- Column 5: varchar5col -- SQL_DESC_OCTET_LENGTH: 10 SQL_DESC_TYPE_NAME: varchar -- Column 6: interval -- SQL_DESC_OCTET_LENGTH: 0 SQL_DESC_TYPE_NAME: interval day to second disconnecting psqlodbc-REL-16_00_0005/test/expected/commands.out000066400000000000000000000003241462406103600216070ustar00rootroot00000000000000connected Testing VACUUM with SQLExecDirect... Testing VACUUM with SQLPrepare/SQLExecute... Disabling autocommit... Testing VACUUM with SQLExecDirect... Testing VACUUM with SQLPrepare/SQLExecute... disconnecting psqlodbc-REL-16_00_0005/test/expected/connect.out000066400000000000000000000003111462406103600214330ustar00rootroot00000000000000connected disconnecting Connecting with SQLConnect...connected disconnecting Testing that autocommit persists SQLDriverConnect... connected autocommit is still off (correct). Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/cte.out000066400000000000000000000004141462406103600205610ustar00rootroot00000000000000connected Result set: 1 foo1 2 foo2 3 foo3 4 foo4 5 foo5 6 foo6 7 foo7 8 foo8 9 foo9 10 foo10 Result set: 1 foo1 2 foo2 disconnecting connected Result set: 1 foo1 2 foo2 3 foo3 4 foo4 5 foo5 6 foo6 7 foo7 8 foo8 9 foo9 10 foo10 Result set: 1 foo1 2 foo2 disconnecting psqlodbc-REL-16_00_0005/test/expected/cursor-block-delete.out000077500000000000000000000037111462406103600236610ustar00rootroot00000000000000connected orientation=2 delete count=0 orientation=4 delete count=30 orientation=1 delete count=53 orientation=4 delete count=70 orientation=1 delete count=83 orientation=4 delete count=93 orientation=1 delete count=100 orientation=4 delete count=105 orientation=1 delete count=109 orientation=4 delete count=112 orientation=1 delete count=114 orientation=4 delete count=116 orientation=1 delete count=117 orientation=4 delete count=118 orientation=1 delete count=119 orientation=4 delete count=120 delete all count 120 orientation=2 delete count=0 orientation=4 delete count=32 orientation=1 delete count=56 orientation=4 delete count=74 orientation=1 delete count=88 orientation=4 delete count=98 orientation=1 delete count=106 orientation=4 delete count=112 orientation=1 delete count=116 orientation=4 delete count=119 orientation=1 delete count=122 orientation=4 delete count=124 orientation=1 delete count=125 orientation=4 delete count=126 orientation=1 delete count=127 orientation=4 delete count=128 delete all count 128 orientation=2 delete count=0 orientation=4 delete count=31 orientation=1 delete count=55 orientation=4 delete count=73 orientation=1 delete count=86 orientation=4 delete count=96 orientation=1 delete count=103 orientation=4 delete count=109 orientation=1 delete count=113 orientation=4 delete count=116 orientation=1 delete count=118 orientation=4 delete count=120 orientation=1 delete count=121 orientation=4 delete count=122 orientation=1 delete count=123 orientation=4 delete count=124 delete all count 124 orientation=2 delete count=0 orientation=4 delete count=10 orientation=1 delete count=17 orientation=4 delete count=23 orientation=1 delete count=27 orientation=4 delete count=30 orientation=1 delete count=32 orientation=4 delete count=34 orientation=1 delete count=35 orientation=4 delete count=36 orientation=1 delete count=37 orientation=4 delete count=38 delete all count 38 disconnecting psqlodbc-REL-16_00_0005/test/expected/cursor-commit.out000066400000000000000000000000671462406103600226150ustar00rootroot00000000000000connected first row: 1 row 2: 2 row 3: 3 disconnecting psqlodbc-REL-16_00_0005/test/expected/cursor-movement.out000066400000000000000000000025661462406103600231650ustar00rootroot00000000000000connected SQL_CURSOR_COMMIT_BEHAVIOR: SQL_CB_PRESERVE SQL_CURSOR_ROLLBACK_BEHAVIOR: SQL_CB_PRESERVE fetched: foo1 fetched: foo2 fetched: foo3 fetched: foo4 fetched: foo5 fetched: foo6 fetched: foo7 fetched: foo8 fetched: foo9 fetched: foo10 Testing SQL_FETCH_NEXT... fetched: foo11 fetched: foo12 Testing SQL_FETCH_PRIOR... fetched: foo11 Testing SQL_FETCH_ABSOLUTE (5)... fetched: foo5 Testing SQL_FETCH_RELATIVE (+2)... fetched: foo7 Testing SQL_FETCH_RELATIVE (-2)... fetched: foo5 Testing SQL_FETCH_RELATIVE (+1)... fetched: foo6 Testing SQL_FETCH_RELATIVE (0, no movement)... fetched: foo6 Testing SQL_FETCH_FIRST... fetched: foo1 Testing SQL_FETCH_PRIOR before first row... Fetch: no data found Fetch: no data found Testing SQL_FETCH_NEXT... fetched: foo1 Testing SQL_FETCH_LAST... fetched: foo3210 Testing SQL_FETCH_LAST... fetched: foo3210 Testing SQL_FETCH_NEXT at the end of result set Fetch: no data found Testing SQL_FETCH_NEXT at the end of result set Fetch: no data found And SQL_FETCH_PRIOR... fetched: foo3210 Testing SQL_FETCH_RELATIVE (+10)... Fetch: no data found And SQL_FETCH_PRIOR... fetched: foo3210 Testing negative SQL_FETCH_ABSOLUTE (-5)... fetched: foo3206 Testing negative SQL_FETCH_ABSOLUTE, before start... got SUCCESS_WITH_INFO 01S06=fetch absolute and before the beginning fetched: foo1 Testing SQL_FETCH_ABSOLUTE, beoynd end... Fetch: no data found disconnecting psqlodbc-REL-16_00_0005/test/expected/cursor-movement_1.out000066400000000000000000000025631462406103600234020ustar00rootroot00000000000000connected SQL_CURSOR_COMMIT_BEHAVIOR: SQL_CB_PRESERVE SQL_CURSOR_ROLLBACK_BEHAVIOR: SQL_CB_CLOSE fetched: foo1 fetched: foo2 fetched: foo3 fetched: foo4 fetched: foo5 fetched: foo6 fetched: foo7 fetched: foo8 fetched: foo9 fetched: foo10 Testing SQL_FETCH_NEXT... fetched: foo11 fetched: foo12 Testing SQL_FETCH_PRIOR... fetched: foo11 Testing SQL_FETCH_ABSOLUTE (5)... fetched: foo5 Testing SQL_FETCH_RELATIVE (+2)... fetched: foo7 Testing SQL_FETCH_RELATIVE (-2)... fetched: foo5 Testing SQL_FETCH_RELATIVE (+1)... fetched: foo6 Testing SQL_FETCH_RELATIVE (0, no movement)... fetched: foo6 Testing SQL_FETCH_FIRST... fetched: foo1 Testing SQL_FETCH_PRIOR before first row... Fetch: no data found Fetch: no data found Testing SQL_FETCH_NEXT... fetched: foo1 Testing SQL_FETCH_LAST... fetched: foo3210 Testing SQL_FETCH_LAST... fetched: foo3210 Testing SQL_FETCH_NEXT at the end of result set Fetch: no data found Testing SQL_FETCH_NEXT at the end of result set Fetch: no data found And SQL_FETCH_PRIOR... fetched: foo3210 Testing SQL_FETCH_RELATIVE (+10)... Fetch: no data found And SQL_FETCH_PRIOR... fetched: foo3210 Testing negative SQL_FETCH_ABSOLUTE (-5)... fetched: foo3206 Testing negative SQL_FETCH_ABSOLUTE, before start... got SUCCESS_WITH_INFO 01S06=fetch absolute and before the beginning fetched: foo1 Testing SQL_FETCH_ABSOLUTE, beoynd end... Fetch: no data found disconnecting psqlodbc-REL-16_00_0005/test/expected/cursor-name.out000066400000000000000000000000641462406103600222420ustar00rootroot00000000000000connected cursor name prefix: SQL_CUR disconnecting psqlodbc-REL-16_00_0005/test/expected/cursors.out000066400000000000000000000012331462406103600215060ustar00rootroot00000000000000connected SQL_CURSOR_COMMIT_BEHAVIOR: SQL_CB_PRESERVE SQL_CURSOR_ROLLBACK_BEHAVIOR: SQL_CB_PRESERVE foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 foo11 foo12 foo13 foo14 foo15 foo16 foo17 foo18 foo19 foo20 ... foo3207 foo3208 foo3209 foo3210 Fetched 3210 rows altogether foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 Commit foo11 foo12 foo13 foo14 foo15 foo16 foo17 foo18 foo19 foo20 ... foo3207 foo3208 foo3209 foo3210 Fetched 3210 rows altogether foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 Rollback foo11 foo12 foo13 foo14 foo15 foo16 foo17 foo18 foo19 foo20 ... foo3207 foo3208 foo3209 foo3210 Fetched 3210 rows altogether disconnecting psqlodbc-REL-16_00_0005/test/expected/cursors_1.out000066400000000000000000000012251462406103600217270ustar00rootroot00000000000000connected SQL_CURSOR_COMMIT_BEHAVIOR: SQL_CB_PRESERVE SQL_CURSOR_ROLLBACK_BEHAVIOR: SQL_CB_CLOSE foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 foo11 foo12 foo13 foo14 foo15 foo16 foo17 foo18 foo19 foo20 ... foo3207 foo3208 foo3209 foo3210 Fetched 3210 rows altogether foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 Commit foo11 foo12 foo13 foo14 foo15 foo16 foo17 foo18 foo19 foo20 ... foo3207 foo3208 foo3209 foo3210 Fetched 3210 rows altogether foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10 Rollback SQLFetch failed with HY010 (which probably means that the cursor was closed at commit/rollback) Fetched 10 rows altogether disconnecting psqlodbc-REL-16_00_0005/test/expected/cvtnulldate.out000066400000000000000000000000631462406103600223330ustar00rootroot00000000000000connected Result set: 1 Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/dataatexecution.out000066400000000000000000000002251462406103600231700ustar00rootroot00000000000000connected Result set: 2 3 Parameter Status Fetching result sets for array bound (2 results expected) 1: Result set: 4 2: Result set: 5 disconnecting psqlodbc-REL-16_00_0005/test/expected/declare-fetch-block.out000066400000000000000000000004001462406103600235570ustar00rootroot00000000000000connected fetchIdx=1, fetched rows=84, total rows=84 fetchIdx=2, fetched rows=36, total rows=120 next total rows=120 prior total rows=120 next total rows=120 prior total rows=120 FetchScroll beyond the end failed 100 encountered EOF at 120 disconnecting psqlodbc-REL-16_00_0005/test/expected/declare-fetch-commit.out000066400000000000000000000000561462406103600237640ustar00rootroot00000000000000connected Result set: 1 2 3 4 5 disconnecting psqlodbc-REL-16_00_0005/test/expected/deprecated.out000066400000000000000000000012631462406103600221110ustar00rootroot00000000000000Check for SQLAllocEnv Check for SQLAllocConnect Check for SQLAllocStmt Check for SQLSetConnectOption Check for SQLGetConnectOption Access type is: read-write Check for SQLError Error check: ERROR: relation "table_not_here" does not exist; Error while executing the query Check for SQLSetParam Result set: 100 Check for SQLGetStmtOption Cursor type is: forward Check for SQLSetStmtOption Cursor type is: static Check for SQLSetScrollOptions Cursor type is: forward Check for SQLColAttributes Column 1: foo Column 2: bar Check for SQLParamOptions Status of execution Check for SQLFreeStmt Check for SQLFreeConnect Check for SQLFreeEnv connected Check for SQLTransact Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/deprecated_1.out000066400000000000000000000012751462406103600223340ustar00rootroot00000000000000Check for SQLAllocEnv Check for SQLAllocConnect Check for SQLAllocStmt Check for SQLSetConnectOption Check for SQLGetConnectOption Access type is: read-write Check for SQLError Error check: [unixODBC]ERROR: relation "table_not_here" does not exist; Error while executing the query Check for SQLSetParam Result set: 100 Check for SQLGetStmtOption Cursor type is: forward Check for SQLSetStmtOption Cursor type is: static Check for SQLSetScrollOptions Cursor type is: forward Check for SQLColAttributes Column 1: foo Column 2: bar Check for SQLParamOptions Status of execution Check for SQLFreeStmt Check for SQLFreeConnect Check for SQLFreeEnv connected Check for SQLTransact Result set: disconnecting psqlodbc-REL-16_00_0005/test/expected/diagnostic.out000077500000000000000000000110701462406103600221350ustar00rootroot00000000000000connected SQLExecDirect 42601=ERROR: syntax error at or near "broken"; Error while executing the query get same message again 42601=ERROR: syntax error at or near "broken"; Error while executing the query SQLExecDirect 42601=ERROR: syntax error at or near "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601 killing connection... 57P01=FATAL: terminating connection due to administrator command; The connection has been lost SQLGetDiagRec on connection says: 57P01=FATAL: terminating connection due to administrator command SQLGetDiagRec called again: 57P01=FATAL: terminating connection due to administrator command psqlodbc-REL-16_00_0005/test/expected/diagnostic_1.out000077500000000000000000000107401462406103600223600ustar00rootroot00000000000000connected SQLExecDirect 42601=ERROR: syntax error at or near "broken"; Error while executing the query get same message again 42601=ERROR: syntax error at or near "broken"; Error while executing the query SQLExecDirect 42601=ERROR: syntax error at or near "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601 killing connection... 57P01=FATAL: terminating connection due to administrator command; The connection has been lost SQLGetDiagRec on connection says: No error information SQLGetDiagRec called again: No error information psqlodbc-REL-16_00_0005/test/expected/diagnostic_2.out000077500000000000000000000106261462406103600223640ustar00rootroot00000000000000connected SQLExecDirect 42601=ERROR: syntax error at or near "broken"; Error while executing the query get same message again 42601=ERROR: syntax error at or near "broken"; Error while executing the query SQLExecDirect 42601=ERROR: syntax error at or near "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42601 killing connection... No error information SQLGetDiagRec on connection says: No error information SQLGetDiagRec called again: No error information psqlodbc-REL-16_00_0005/test/expected/error-rollback.out000066400000000000000000000030041462406103600227240ustar00rootroot00000000000000Test for rollback protocol 0 connected Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for type integer: "fail1"; Error while executing the query Rolling back with SQLEndTran Executing query that will succeed Result set: 1 disconnecting Test for rollback protocol 1 connected Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for type integer: "fail1"; Error while executing the query Executing query that will succeed Result set: 1 disconnecting Test for rollback protocol 2 connected Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will succeed Executing procedure call that will fail Failed to execute procedure call 42883=ERROR: function invalidfunction() does not exist; Error while executing the query Executing query that will succeed Executing query that will succeed Result set: 1 2 3 4 5 6 7 disconnecting psqlodbc-REL-16_00_0005/test/expected/error-rollback_1.out000066400000000000000000000027531462406103600231560ustar00rootroot00000000000000Test for rollback protocol 0 connected Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for integer: "fail1"; Error while executing the query Rolling back with SQLEndTran Executing query that will succeed Result set: 1 disconnecting Test for rollback protocol 1 connected Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for integer: "fail1"; Error while executing the query Executing query that will succeed Result set: 1 disconnecting Test for rollback protocol 2 connected Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for integer: "fail-1"; Error while executing the query Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for integer: "fail-1"; Error while executing the query Executing query that will fail Failed to execute statement 22P02=ERROR: invalid input syntax for integer: "fail-1"; Error while executing the query Executing query that will succeed Executing procedure call that will fail Failed to execute procedure call 42883=ERROR: function invalidfunction() does not exist; Error while executing the query Executing query that will succeed Executing query that will succeed Result set: 1 2 3 4 5 6 7 disconnecting psqlodbc-REL-16_00_0005/test/expected/errors.out000066400000000000000000000004271462406103600213260ustar00rootroot00000000000000connected 42703=ERROR: column "doesnotexist" does not exist; Error while executing the query 42703=ERROR: column "doesnotexist2" does not exist; Error while executing the query 42703=ERROR: column "doesnotexist3" does not exist; Error while preparing parameters disconnecting psqlodbc-REL-16_00_0005/test/expected/errors_1.out000066400000000000000000000004261462406103600215450ustar00rootroot00000000000000connected 42703=ERROR: column "doesnotexist" does not exist; Error while executing the query 42703=ERROR: column "doesnotexist2" does not exist; Error while executing the query 42703=ERROR: column "doesnotexist3" does not exist; Error while executing the query disconnecting psqlodbc-REL-16_00_0005/test/expected/errors_2.out000066400000000000000000000005521462406103600215460ustar00rootroot00000000000000connected 42703=ERROR: column "doesnotexist" does not exist; Error while executing the query 25P02=ERROR: current transaction is aborted, commands ignored until end of transaction block; Error while executing the query 25P02=ERROR: current transaction is aborted, commands ignored until end of transaction block; Error while executing the query disconnecting psqlodbc-REL-16_00_0005/test/expected/fetch-refcursors.out000066400000000000000000000021201462406103600232660ustar00rootroot00000000000000Creating procedure 'refproc' connected disconnecting -- TEST using Fetch=1;FetchRefcursors=0, autocommit=1, numresults=2 connected Output param num_cursor is 2 --1 Result set: 2 disconnecting -- TEST using Fetch=1;FetchRefcursors=1, autocommit=1, numresults=2 connected SQLExecute failed HY000=Query must be executed in a transaction when FetchRefcursors setting is enabled. -- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=0 connected Output param num_cursor is 0 --1 Result set: disconnecting -- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=1 connected Output param num_cursor is 1 --1 Result set: 1 foo 2 bar 3 foobar disconnecting -- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=2 connected Output param num_cursor is 2 --1 Result set: 1 foo 2 bar 3 foobar --2 Result set: foobar 3 bar 2 foo 1 disconnecting -- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=3 connected Output param num_cursor is 2 --1 Result set: 1 foo 2 bar 3 foobar --2 Result set: foobar 3 bar 2 foo 1 disconnecting psqlodbc-REL-16_00_0005/test/expected/getresult.out000066400000000000000000000002331462406103600220230ustar00rootroot00000000000000connected Result set: varcharcol: foo integercol: 123 intervalyears: 10 intervalmonths: 11 intervaldays: 12 bogus long string as interval: 0 disconnecting psqlodbc-REL-16_00_0005/test/expected/identity.out000066400000000000000000000003311462406103600216350ustar00rootroot00000000000000connected # of rows inserted: 1 Result set: 1 Result set: 1 simple # of rows inserted: 1 Result set: 1 Result set: 1 value.with.dots # of rows inserted: 1 Result set: 1 Result set: 1 space in table name disconnecting psqlodbc-REL-16_00_0005/test/expected/insertreturning.out000066400000000000000000000341021462406103600232510ustar00rootroot00000000000000Testing with UseServerSidePrepare=1 connected # of result cols before SQLExecute: 1, after: 1 Result set: foobar 0 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 1 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 2 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 3 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 4 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 5 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 6 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 7 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 8 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 9 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 10 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 11 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 12 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 13 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 14 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 15 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 16 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 17 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 18 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 19 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 20 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 21 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 22 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 23 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 24 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 25 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 26 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 27 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 28 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 29 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 30 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 31 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 32 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 33 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 34 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 35 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 36 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 37 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 38 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 39 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 40 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 41 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 42 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 43 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 44 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 45 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 46 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 47 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 48 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 49 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 50 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 51 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 52 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 53 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 54 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 55 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 56 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 57 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 58 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 59 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 60 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 61 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 62 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 63 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 64 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 65 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 66 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 67 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 68 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 69 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 70 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 71 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 72 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 73 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 74 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 75 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 76 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 77 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 78 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 79 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 80 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 81 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 82 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 83 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 84 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 85 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 86 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 87 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 88 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 89 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 90 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 91 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 92 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 93 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 94 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 95 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 96 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 97 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 98 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 99 SQLExecute UPDATE not found key i=0 SQLExecute UPDATE not found key i=1 SQLExecute UPDATE not found key i=2 SQLExecute UPDATE key i=3 value t=foobar 3 disconnecting Testing with UseServerSidePrepare=0 connected # of result cols before SQLExecute: 1, after: 1 Result set: foobar 0 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 1 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 2 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 3 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 4 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 5 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 6 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 7 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 8 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 9 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 10 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 11 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 12 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 13 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 14 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 15 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 16 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 17 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 18 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 19 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 20 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 21 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 22 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 23 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 24 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 25 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 26 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 27 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 28 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 29 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 30 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 31 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 32 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 33 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 34 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 35 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 36 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 37 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 38 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 39 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 40 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 41 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 42 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 43 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 44 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 45 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 46 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 47 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 48 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 49 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 50 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 51 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 52 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 53 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 54 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 55 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 56 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 57 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 58 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 59 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 60 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 61 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 62 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 63 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 64 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 65 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 66 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 67 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 68 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 69 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 70 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 71 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 72 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 73 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 74 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 75 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 76 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 77 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 78 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 79 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 80 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 81 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 82 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 83 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 84 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 85 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 86 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 87 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 88 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 89 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 90 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 91 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 92 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 93 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 94 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 95 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 96 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 97 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 98 # of result cols before SQLExecute: 1, after: 1 Result set: foobar 99 SQLExecute UPDATE not found key i=0 SQLExecute UPDATE not found key i=1 SQLExecute UPDATE not found key i=2 SQLExecute UPDATE key i=3 value t=foobar 3 disconnecting psqlodbc-REL-16_00_0005/test/expected/large-object-data-at-exec.out000066400000000000000000000005561462406103600246060ustar00rootroot00000000000000connected inserting large object with len 8... reading it back... hex: 0102030405060708 inserting large object with len 100... reading it back... hex: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F60616263 disconnecting psqlodbc-REL-16_00_0005/test/expected/large-object.out000066400000000000000000000001331462406103600223420ustar00rootroot00000000000000connected inserting large object... reading it back... hex: 0102030405060708 disconnecting psqlodbc-REL-16_00_0005/test/expected/lfconversion.out000066400000000000000000000006641462406103600225240ustar00rootroot00000000000000connected reading to char buffer... strlen 22, SQLGetData claims 22 reading to char buffer, with truncation... strlen 9, SQLGetData claims 22 reading to SQLWCHAR buffer... len 22 chars, SQLGetData claims 44 bytes reading to SQLWCHAR buffer, with truncation... len 4 chars, SQLGetData claims 44 bytes reading to SQLWCHAR buffer, with LF->CR+LF conversion causing truncation... len 20 chars, SQLGetData claims 44 bytes disconnecting psqlodbc-REL-16_00_0005/test/expected/multistmt.out000066400000000000000000000030071462406103600220510ustar00rootroot00000000000000connected --1 Result set metadata: ?column?: INTEGER(10) digits: 0, nullable Result set: ?column? 1 --2 Result set metadata: ?column?: INTEGER(10) digits: 0, nullable Result set: ?column? 2 --1 Result set metadata: ?column?: INTEGER(10) digits: 0, nullable Result set: ?column? 1 --2 Result set metadata: ?column?: LONGVARCHAR(8190) digits: 0, nullable ?column?: LONGVARCHAR(8190) digits: 0, nullable Result set: ?column? ?column? foo bar --3 Result set metadata: ?column?: INTEGER(10) digits: 0, nullable Result set: ?column? 3 --4 Result set metadata: ?column?: INTEGER(10) digits: 0, nullable Result set: ?column? 4 --1 Result set metadata: ?column?: LONGVARCHAR(8190) digits: 0, nullable ?column?: LONGVARCHAR(8190) digits: 0, nullable Result set: ?column? ?column? foo bar --2 Result set metadata: ?column?: LONGVARCHAR(8190) digits: 0, nullable Result set: ?column? foobar --1 Result set metadata: id: INTEGER(10) digits: 0, not nullable t: VARCHAR(20) digits: 0, nullable Result set: id t 1 foo 2 bar 3 foobar --2 Result set metadata: t: VARCHAR(20) digits: 0, nullable result: INTEGER(10) digits: 0, nullable Result set: t result foo 2 bar 2 foobar 2 # of result cols: 3 --1 Result set metadata: ?column?: LONGVARCHAR(8190) digits: 0, nullable id: INTEGER(10) digits: 0, not nullable t: VARCHAR(20) digits: 0, nullable Result set: ?column? id t first result set 1 foo --2 Result set metadata: ?column?: LONGVARCHAR(8190) digits: 0, nullable t: VARCHAR(20) digits: 0, nullable Result set: ?column? t second result set bar disconnecting psqlodbc-REL-16_00_0005/test/expected/notice.out000066400000000000000000000006531462406103600212740ustar00rootroot00000000000000connected got SUCCESS_WITH_INFO 00000=NOTICE: test notice: foo got SUCCESS_WITH_INFO 00000=NOTICE: test notice: foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo disconnecting psqlodbc-REL-16_00_0005/test/expected/numeric.out000066400000000000000000000042631462406103600214560ustar00rootroot00000000000000connected Testing SQL_NUMERIC_STRUCT params... sign 1 prec 5 scale 3 val 7C62: 25.212 sign 1 prec 41 scale 0 val 78563412 78563412 78563412 78563412: 24197857161011715162171839636988778104 sign 1 prec 38 scale 0 val 4EF338DE509049C4133302F0F6B04909: 12345678901234567890123456789012345678 sign 1 prec 50 scale 0 val FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF: 340282366920938463463374607431768211455 sign 1 prec 1 scale 0 val 00: 0 sign 0 prec 1 scale 0 val 00: 0 sign 1 prec 3 scale 2 val 0203: 7.70 sign 1 prec 1 scale 5 val 3930: 0.00005 sign 1 prec 2 scale 5 val 3930: 0.00045 sign 1 prec 3 scale 5 val 3930: 0.00345 sign 1 prec 4 scale 5 val 3930: 0.02345 sign 1 prec 5 scale 5 val 3930: 0.12345 sign 1 prec 6 scale 5 val 3930: 0.12345 sign 1 prec 3 scale 50 val 0203: 0.00000000000000000000000000000000000000000000000770 sign 1 prec 25 scale 80 val 0203: 0.00000000000000000000000000000000000000000000000000000000000000000000000000000770 sign 0 prec 40 scale 127 val FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF: -0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000340282366920938463463374607431768211455 sign 1 prec 3 scale 50 val 0203: 0.00000000000000000000000000000000000000000000000770 Testing SQL_NUMERIC_STRUCT results... 25.212: sign 1 prec 5 scale 3 val 7C620000000000000000000000000000 24197857161011715162171839636988778104: sign 1 prec 38 scale 0 val 78563412785634127856341278563412 12345678901234567890123456789012345678: sign 1 prec 38 scale 0 val 4EF338DE509049C4133302F0F6B04909 340282366920938463463374607431768211455: sign 1 prec 39 scale 0 val FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 340282366920938463463374607431768211456: sign 1 prec 39 scale 0 val 00000000000000000000000000000000 340282366920938463463374607431768211457: sign 1 prec 39 scale 0 val 01000000000000000000000000000000 -0: sign 1 prec 0 scale 0 val 00000000000000000000000000000000 0: sign 1 prec 0 scale 0 val 00000000000000000000000000000000 -7.70: sign 0 prec 3 scale 2 val 02030000000000000000000000000000 999999999999: sign 1 prec 12 scale 0 val FF0FA5D4E80000000000000000000000 disconnecting psqlodbc-REL-16_00_0005/test/expected/odbc-escapes.out000066400000000000000000000072761462406103600223530ustar00rootroot00000000000000connected -- TEST using SQLExecute after SQLPrepare Query: SELECT {fn CONCAT(?, ?) } Param 1: foo Param 2: bar Result set: foobar Query: SELECT {fn LOCATE(?, ?, 2) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 11 Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 10 Query: SELECT 'x' || {fn SPACE(10) } || 'x' Result set: x x Query: { call length(?) } Param 1: foobar Result set: 6 Query: { call right(?, ?) } Param 1: foobar Param 2: 3 Result set: bar Query: { ? = call length('foo') } Param 1 is an OUT parameter Result set: OUT param: 3 Query: { ? = call concat(?::text, ?::text) } Param 1 is an OUT parameter Param 2: foo Param 3: bar Result set: OUT param: foobar Query: SELECT {d '2014-12-21' } + '1 day'::interval Result set: 2014-12-22 00:00:00 Query: SELECT {t '20:30:40' } + '1 hour 1 minute 1 second'::interval Result set: 21:31:41 Query: SELECT {ts '2014-12-21 20:30:40' } + '1 day 1 hour 1 minute 1 second'::interval Result set: 2014-12-22 21:31:41 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 is an OUT parameter Param 2: 2017-02-23 11:34:46 Param 3 is an I-O parameter Param 4: 3.4 Param 5 is an OUT parameter Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (e) is an OUT parameter Param 2 (a) is an OUT parameter Param 3 (b): 2017-02-23 11:34:46 Param 4 (c) is an I-O parameter Param 5 (d): 3.4 Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (b): 2017-02-23 11:34:46 Param 2 (c) is an I-O parameter Param 3 (d): 3.4 Param 4 (e) is an OUT parameter Param 5 (a) is an OUT parameter Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 -- TEST using SQLExecDirect Query: SELECT {fn CONCAT(?, ?) } Param 1: foo Param 2: bar Result set: foobar Query: SELECT {fn LOCATE(?, ?, 2) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 11 Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 10 Query: SELECT 'x' || {fn SPACE(10) } || 'x' Result set: x x Query: { call length(?) } Param 1: foobar Result set: 6 Query: { call right(?, ?) } Param 1: foobar Param 2: 3 Result set: bar Query: { ? = call length('foo') } Param 1 is an OUT parameter Result set: OUT param: 3 Query: { ? = call concat(?::text, ?::text) } Param 1 is an OUT parameter Param 2: foo Param 3: bar Result set: OUT param: foobar Query: SELECT {d '2014-12-21' } + '1 day'::interval Result set: 2014-12-22 00:00:00 Query: SELECT {t '20:30:40' } + '1 hour 1 minute 1 second'::interval Result set: 21:31:41 Query: SELECT {ts '2014-12-21 20:30:40' } + '1 day 1 hour 1 minute 1 second'::interval Result set: 2014-12-22 21:31:41 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 is an OUT parameter Param 2: 2017-02-23 11:34:46 Param 3 is an I-O parameter Param 4: 3.4 Param 5 is an OUT parameter Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (e) is an OUT parameter Param 2 (a) is an OUT parameter Param 3 (b): 2017-02-23 11:34:46 Param 4 (c) is an I-O parameter Param 5 (d): 3.4 Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (b): 2017-02-23 11:34:46 Param 2 (c) is an I-O parameter Param 3 (d): 3.4 Param 4 (e) is an OUT parameter Param 5 (a) is an OUT parameter Result set: 6.8 7 2017-02-24 11:34:46 OUT params: 6.8 : 7 : 2017-02-24 11:34:46 disconnecting psqlodbc-REL-16_00_0005/test/expected/odbc-escapes_1.out000066400000000000000000000075621462406103600225710ustar00rootroot00000000000000connected -- TEST using SQLExecute after SQLPrepare Query: SELECT {fn CONCAT(?, ?) } Param 1: foo Param 2: bar Result set: foobar Query: SELECT {fn LOCATE(?, ?, 2) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 11 Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 10 Query: SELECT 'x' || {fn SPACE(10) } || 'x' Result set: x x Query: { call length(?) } Param 1: foobar Result set: 6 Query: { call right(?, ?) } Param 1: foobar Param 2: 3 Result set: bar Query: { ? = call length('foo') } Param 1 is an OUT parameter Result set: OUT param: 3 Query: { ? = call concat(?::text, ?::text) } Param 1 is an OUT parameter Param 2: foo Param 3: bar Result set: OUT param: foobar Query: SELECT {d '2014-12-21' } + '1 day'::interval Result set: 2014-12-22 00:00:00 Query: SELECT {t '20:30:40' } + '1 hour 1 minute 1 second'::interval Result set: 21:31:41 Query: SELECT {ts '2014-12-21 20:30:40' } + '1 day 1 hour 1 minute 1 second'::interval Result set: 2014-12-22 21:31:41 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 is an OUT parameter Param 2: 2017-02-23 11:34:46 Param 3 is an I-O parameter Param 4: 3.4 Param 5 is an OUT parameter Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (e) is an OUT parameter Param 2 (a) is an OUT parameter Param 3 (b): 2017-02-23 11:34:46 Param 4 (c) is an I-O parameter Param 5 (d): 3.4 Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (b): 2017-02-23 11:34:46 Param 2 (c) is an I-O parameter Param 3 (d): 3.4 Param 4 (e) is an OUT parameter Param 5 (a) is an OUT parameter Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 -- TEST using SQLExecDirect Query: SELECT {fn CONCAT(?, ?) } Param 1: foo Param 2: bar Result set: foobar Query: SELECT {fn LOCATE(?, ?, 2) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 11 Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) } Param 1: needle Param 2: this is a needle in an ol' haystack Result set: 10 Query: SELECT 'x' || {fn SPACE(10) } || 'x' Result set: x x Query: { call length(?) } Param 1: foobar Result set: 6 Query: { call right(?, ?) } Param 1: foobar Param 2: 3 Result set: bar Query: { ? = call length('foo') } Param 1 is an OUT parameter Result set: OUT param: 3 Query: { ? = call concat(?::text, ?::text) } Param 1 is an OUT parameter Param 2: foo Param 3: bar Result set: OUT param: foobar Query: SELECT {d '2014-12-21' } + '1 day'::interval Result set: 2014-12-22 00:00:00 Query: SELECT {t '20:30:40' } + '1 hour 1 minute 1 second'::interval Result set: 21:31:41 Query: SELECT {ts '2014-12-21 20:30:40' } + '1 day 1 hour 1 minute 1 second'::interval Result set: 2014-12-22 21:31:41 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 is an OUT parameter Param 2: 2017-02-23 11:34:46 Param 3 is an I-O parameter Param 4: 3.4 Param 5 is an OUT parameter Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (e) is an OUT parameter Param 2 (a) is an OUT parameter Param 3 (b): 2017-02-23 11:34:46 Param 4 (c) is an I-O parameter Param 5 (d): 3.4 Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 Query: {call a_b_c_d_e(?, ?, ?, ?, ?)} Param 1 (b): 2017-02-23 11:34:46 Param 2 (c) is an I-O parameter Param 3 (d): 3.4 Param 4 (e) is an OUT parameter Param 5 (a) is an OUT parameter Result set: 6.7999999999999998 7 2017-02-24 11:34:46 OUT params: 6.7999999999999998 : 7 : 2017-02-24 11:34:46 disconnecting psqlodbc-REL-16_00_0005/test/expected/param-conversions.out000066400000000000000000000104601462406103600234560ustar00rootroot00000000000000connected Testing conversions... Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... Result set: 1 Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... Result set: 0 Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... Result set: 1 Testing conversions whose result depend on whether the parameter is treated as a string or an integer... Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... SQLExecDirect failed 22003=ERROR: value "99999999999999999999999" is out of range for type integer; Error while executing the query Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type numeric: "3', 'injected, BAD!', '1"; Error while executing the query Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type numeric: "4 \'bad', '1"; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... Result set: 1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... Result set: 1234 Testing bytea conversions Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... Result set: 666f6f0a5c62617200 Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... Result set: 666f6f0001 Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... Result set: foo \bar Testing datetime conversions Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... Result set: 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... Result set: 2011-04-22 disconnecting psqlodbc-REL-16_00_0005/test/expected/param-conversions_1.out000066400000000000000000000103201462406103600236710ustar00rootroot00000000000000connected Testing conversions... Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... Result set: 1 Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... Result set: 0 Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... Result set: 1 Testing conversions whose result depend on whether the parameter is treated as a string or an integer... Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... Result set: 0 Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type double precision: "3', 'injected, BAD!', '1"; Error while executing the query Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type double precision: "4 \'bad', '1"; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type smallint: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... Result set: 1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... Result set: 1234 Testing bytea conversions Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... Result set: \x666F6F0A5C62617200 Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... Result set: \x666F6F0001 Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... Result set: foo \bar Testing datetime conversions Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... Result set: 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... Result set: 2011-04-22 disconnecting psqlodbc-REL-16_00_0005/test/expected/param-conversions_2.out000066400000000000000000000104121462406103600236740ustar00rootroot00000000000000connected Testing conversions... Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... Result set: 1 Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... Result set: 0 Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... Result set: 1 Testing conversions whose result depend on whether the parameter is treated as a string or an integer... Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... SQLExecDirect failed 22003=ERROR: value "99999999999999999999999" is out of range for type integer; Error while executing the query Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type numeric: "3', 'injected, BAD!', '1"; Error while executing the query Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type numeric: "4 \'bad', '1"; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... Result set: 1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... Result set: 1234 Testing bytea conversions Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... Result set: 666f6f0a5c62617200 Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... Result set: 666f6f0001 Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... Result set: foo \bar Testing datetime conversions Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... Result set: 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... Result set: 2011-04-22 disconnecting psqlodbc-REL-16_00_0005/test/expected/param-conversions_3.out000066400000000000000000000102521462406103600236770ustar00rootroot00000000000000connected Testing conversions... Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... Result set: 1 Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... Result set: 0 Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... Result set: 1 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... Result set: 1 Testing conversions whose result depend on whether the parameter is treated as a string or an integer... Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... Result set: 1 Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... Result set: 0 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... Result set: 0 Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type double precision: "3', 'injected, BAD!', '1"; Error while executing the query Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for type double precision: "4 \'bad', '1"; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... Result set: 2 Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed 22P02=ERROR: invalid input syntax for integer: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... Result set: 1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... Result set: -1234 Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... Result set: 1234 Testing bytea conversions Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... Result set: \x666F6F0A5C62617200 Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... Result set: \x666F6F0001 Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... Result set: foo \bar Testing datetime conversions Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... Result set: 2011-04-22 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... Result set: 01:23:45 Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... Result set: 2011-04-22 disconnecting psqlodbc-REL-16_00_0005/test/expected/params-batch-exec.out000066400000000000000000000026261462406103600233010ustar00rootroot00000000000000connected one by one execution insert into test_batch returns 1 row 0 status=success row 1 status=success_with_info row 2 status=success row 3 status=success row 4 status=success_with_info row 5 status=success row 6 status=success row 7 status=success_with_info row 8 status=success row 9 status=success insert into test_batch returns -1 22001=ERROR: value too long for type character varying(4); Error while executing the query row 0 status=success_with_info row 1 status=success_with_info row 2 status=success_with_info row 3 status=success_with_info row 4 status=success_with_info row 5 status=success_with_info row 6 status=success_with_info row 7 status=error row 8 status=unused row 9 status=unused batch execution insert into test_batch returns 1 row 0 status=success_with_info row 1 status=success_with_info row 2 status=success row 3 status=success row 4 status=success_with_info row 5 status=success_with_info row 6 status=success_with_info row 7 status=success_with_info row 8 status=success row 9 status=success insert into test_batch returns -1 22001=ERROR: value too long for type character varying(4); Error while executing the query row 0 status=success_with_info row 1 status=success_with_info row 2 status=success_with_info row 3 status=success_with_info row 4 status=success_with_info row 5 status=success_with_info row 6 status=error row 7 status=error row 8 status=unused row 9 status=unused disconnecting psqlodbc-REL-16_00_0005/test/expected/params.out000066400000000000000000000006001462406103600212660ustar00rootroot00000000000000connected # of result cols: 2 Result set: 1 0102030405060708 Testing SQLBindParameter with SQLExecDirect... Result set: foo bar Testing SQLBindParameter with NULL param... Result set: NULL Testing SQLBindParameter with integer NULL param... Testing SQLDescribeParam... Param 1: type INTEGER; size 10; dec digits -1; nullable # of result cols: 2 Result set: 3 foobar disconnecting psqlodbc-REL-16_00_0005/test/expected/params_1.out000066400000000000000000000005631462406103600215160ustar00rootroot00000000000000connected # of result cols: 2 Result set: 1 0102030405060708 Testing SQLBindParameter with SQLExecDirect... Result set: foo bar Testing SQLBindParameter with NULL param... Result set: NULL Testing SQLBindParameter with integer NULL param... Testing SQLDescribeParam... Skipped, SQLDescribeParam is not supported # of result cols: 2 Result set: 3 foobar disconnecting psqlodbc-REL-16_00_0005/test/expected/parse.out000066400000000000000000000005421462406103600211220ustar00rootroot00000000000000connected Result set metadata: id: INTEGER(10) digits: 0, not nullable t: VARCHAR(20) digits: 0, nullable Result set metadata: id: INTEGER(10) digits: 0, not nullable t: VARCHAR(20) digits: 0, nullable Result set metadata: id: INTEGER(10) digits: 0, not nullable t: VARCHAR(20) digits: 0, nullable con"stant: VARCHAR(7) digits: 0, nullable disconnecting psqlodbc-REL-16_00_0005/test/expected/parse_1.out000066400000000000000000000005461462406103600213460ustar00rootroot00000000000000connected Result set metadata: id: INTEGER(10) digits: 0, not nullable t: WVARCHAR(20) digits: 0, nullable Result set metadata: id: INTEGER(10) digits: 0, not nullable t: WVARCHAR(20) digits: 0, nullable Result set metadata: id: INTEGER(10) digits: 0, not nullable t: WVARCHAR(20) digits: 0, nullable con"stant: WVARCHAR(7) digits: 0, nullable disconnecting psqlodbc-REL-16_00_0005/test/expected/positioned-update.out000066400000000000000000000005431462406103600234460ustar00rootroot00000000000000connected Creating test table pos_update_test Opening a cursor for update, and fetching 10 rows exec cursor_type=3 1 1 2 2 3 3 4 4 5 5 Updating result set Re-fetching the rows in the result set 6 6 105 5 4 4 Querying the table again Result set: 1 1 2 2 3 3 4 4 105 5 7 7 8 8 9 9 10 10 Opening a cursor for update, and fetching 5000 rows disconnecting psqlodbc-REL-16_00_0005/test/expected/positioned-update_1.out000066400000000000000000000005511462406103600236650ustar00rootroot00000000000000connected Creating test table pos_update_test Opening a cursor for update, and fetching 10 rows exec cursor_type=1 1 1 2 2 3 3 4 4 5 5 Updating result set Re-fetching the rows in the result set NULL NULL 105 5 4 4 Querying the table again Result set: 1 1 2 2 3 3 4 4 105 5 7 7 8 8 9 9 10 10 Opening a cursor for update, and fetching 5000 rows disconnecting psqlodbc-REL-16_00_0005/test/expected/premature.out000066400000000000000000000006301462406103600220120ustar00rootroot00000000000000connected Preparing an INSERT statement # of result cols: 1 # of result cols: 1 Preparing an insert using a function # of result cols: 1 # of result cols: 1 Preparing a multi-statement # of result cols: 3 # of result cols: 3 Prepare with function, but execute with different param # of result cols: 1 Checking table contents. Should contain only one row. Result set: function insert right disconnecting psqlodbc-REL-16_00_0005/test/expected/prepare.out000066400000000000000000000034051462406103600214470ustar00rootroot00000000000000connected # of result cols: 2 Result set: 2 bar Result set: 3 foobar inserting bytea values... 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 done! Now reading them back... Result set: 4000 4000 4001 4001 4002 4002 4003 4003 4004 4004 4005 4005 4006 4006 4007 4007 4008 4008 4009 4009 4010 4010 4011 4011 4012 4012 4013 4013 4014 4014 4015 4015 4016 4016 4017 4017 4018 4018 4019 4019 4020 4020 4021 4021 4022 4022 4023 4023 4024 4024 4025 4025 4026 4026 4027 4027 4028 4028 4029 4029 4030 4030 4031 4031 4032 4032 4033 4033 4034 4034 4035 4035 4036 4036 4037 4037 4038 4038 4039 4039 4040 4040 4041 4041 4042 4042 4043 4043 4044 4044 4045 4045 4046 4046 4047 4047 4048 4048 4049 4049 4050 4050 4051 4051 4052 4052 4053 4053 4054 4054 4055 4055 4056 4056 4057 4057 4058 4058 4059 4059 4060 4060 4061 4061 4062 4062 4063 4063 4064 4064 4065 4065 4066 4066 4067 4067 4068 4068 4069 4069 4070 4070 4071 4071 4072 4072 4073 4073 4074 4074 4075 4075 4076 4076 4077 4077 4078 4078 4079 4079 4080 4080 4081 4081 4082 4082 4083 4083 4084 4084 4085 4085 4086 4086 4087 4087 4088 4088 4089 4089 4090 4090 4091 4091 4092 4092 4093 4093 4094 4094 4095 4095 4096 4096 4097 4097 4098 4098 4099 4099 Result set: 1 @ 1 day one day 2 @ 10 secs ten secs # of result cols: 2 col:1 name=id type=4 len=10 col:2 name=t type=12 len=25 Result set: 2 bar disconnecting psqlodbc-REL-16_00_0005/test/expected/quotes.out000066400000000000000000000044771462406103600213430ustar00rootroot00000000000000connected SET standard_conforming_strings=on Executing: SELECT 'foo', ?::text with param: param'quote Result set: foo param'quote Executing: SELECT 'foo', ?::text with param: param\backslash Result set: foo param\backslash Executing: SELECT 'foo', ?::text with param: ends with backslash\ Result set: foo ends with backslash\ Executing: SELECT 'doubled '' quotes', ?::text with param: param Result set: doubled ' quotes param Executing: SELECT E'escaped quote\' here', ?::text with param: param Result set: escaped quote' here param Executing: SELECT $$dollar quoted string$$, ?::text with param: param Result set: dollar quoted string param Executing: SELECT $xx$complex $dollar quotes$xx$, ?::text with param: param Result set: complex $dollar quotes param Executing: SELECT $dollar$morecomplex $dollar quotes$dollar$, ?::text with param: param Result set: morecomplex $dollar quotes param Executing: SELECT ?::text, '1' a$1 with param: $ in an identifier Result set: $ in an identifier 1 Executing: SELECT '1'::text a$$S1,?::text,$$2 $'s in an identifier$$::text with param: param Result set: 1 param 2 $'s in an identifier SET standard_conforming_strings=off Executing: SELECT 'foo', ?::text with param: param'quote Result set: foo param'quote Executing: SELECT 'foo', ?::text with param: param\backslash Result set: foo param\backslash Executing: SELECT 'foo', ?::text with param: ends with backslash\ Result set: foo ends with backslash\ Executing: SELECT 'doubled '' quotes', ?::text with param: param Result set: doubled ' quotes param Executing: SELECT E'escaped quote\' here', ?::text with param: param Result set: escaped quote' here param Executing: SELECT $$dollar quoted string$$, ?::text with param: param Result set: dollar quoted string param Executing: SELECT $xx$complex $dollar quotes$xx$, ?::text with param: param Result set: complex $dollar quotes param Executing: SELECT $dollar$morecomplex $dollar quotes$dollar$, ?::text with param: param Result set: morecomplex $dollar quotes param Executing: SELECT 'escaped quote\' here', ?::text with param: param Result set: escaped quote' here param Executing: SELECT ?::text, '1' a$1 with param: $ in an identifier Result set: $ in an identifier 1 Executing: SELECT '1'::text a$$S1,?::text,$$2 $'s in an identifier$$::text with param: param Result set: 1 param 2 $'s in an identifier disconnecting psqlodbc-REL-16_00_0005/test/expected/result-conversions.out000066400000000000000000002441101462406103600236750ustar00rootroot00000000000000connected Executed: SET intervalstyle=postgres Executed: SET bytea_output=escape Executed: SET lc_monetary='C' 'true' (boolean) as SQL_C_CHAR: 1 'true' (boolean) as SQL_C_WCHAR: 1 'true' (boolean) as SQL_C_SSHORT: 1 'true' (boolean) as SQL_C_USHORT: 1 'true' (boolean) as SQL_C_SLONG: 1 'true' (boolean) as SQL_C_ULONG: 1 'true' (boolean) as SQL_C_FLOAT: 1.000000 'true' (boolean) as SQL_C_DOUBLE: 1.000000 'true' (boolean) as SQL_C_BIT: 1 'true' (boolean) as SQL_C_STINYINT: 1 'true' (boolean) as SQL_C_UTINYINT: 1 'true' (boolean) as SQL_C_SBIGINT: 1 'true' (boolean) as SQL_C_UBIGINT: 1 'true' (boolean) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_BOOKMARK: 1 'true' (boolean) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'true' (boolean) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 'true' (boolean) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_CHAR: 464F4F '\x464F4F' (bytea) as SQL_C_WCHAR: 464F4F '\x464F4F' (bytea) as SQL_C_SSHORT: 0 '\x464F4F' (bytea) as SQL_C_USHORT: 0 '\x464F4F' (bytea) as SQL_C_SLONG: 0 '\x464F4F' (bytea) as SQL_C_ULONG: 0 '\x464F4F' (bytea) as SQL_C_FLOAT: 0.000000 '\x464F4F' (bytea) as SQL_C_DOUBLE: 0.000000 '\x464F4F' (bytea) as SQL_C_BIT: 0 '\x464F4F' (bytea) as SQL_C_STINYINT: 0 '\x464F4F' (bytea) as SQL_C_UTINYINT: 0 '\x464F4F' (bytea) as SQL_C_SBIGINT: 0 '\x464F4F' (bytea) as SQL_C_UBIGINT: 0 '\x464F4F' (bytea) as SQL_C_BINARY: hex: 464F4F '\x464F4F' (bytea) as SQL_C_BOOKMARK: 0 '\x464F4F' (bytea) as SQL_C_VARBOOKMARK: hex: 464F4F '\x464F4F' (bytea) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '\x464F4F' (bytea) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '\x464F4F' (bytea) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_CHAR: x 'x' (char) as SQL_C_WCHAR: x 'x' (char) as SQL_C_SSHORT: 0 'x' (char) as SQL_C_USHORT: 0 'x' (char) as SQL_C_SLONG: 0 'x' (char) as SQL_C_ULONG: 0 'x' (char) as SQL_C_FLOAT: 0.000000 'x' (char) as SQL_C_DOUBLE: 0.000000 'x' (char) as SQL_C_BIT: 0 'x' (char) as SQL_C_STINYINT: 0 'x' (char) as SQL_C_UTINYINT: 0 'x' (char) as SQL_C_SBIGINT: 0 'x' (char) as SQL_C_UBIGINT: 0 'x' (char) as SQL_C_BINARY: hex: 78 'x' (char) as SQL_C_BOOKMARK: 0 'x' (char) as SQL_C_VARBOOKMARK: hex: 78 'x' (char) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'x' (char) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'x' (char) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_CHAR: namedata 'namedata' (name) as SQL_C_WCHAR: namedata 'namedata' (name) as SQL_C_SSHORT: 0 'namedata' (name) as SQL_C_USHORT: 0 'namedata' (name) as SQL_C_SLONG: 0 'namedata' (name) as SQL_C_ULONG: 0 'namedata' (name) as SQL_C_FLOAT: 0.000000 'namedata' (name) as SQL_C_DOUBLE: 0.000000 'namedata' (name) as SQL_C_BIT: 0 'namedata' (name) as SQL_C_STINYINT: 0 'namedata' (name) as SQL_C_UTINYINT: 0 'namedata' (name) as SQL_C_SBIGINT: 0 'namedata' (name) as SQL_C_UBIGINT: 0 'namedata' (name) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_BOOKMARK: 0 'namedata' (name) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'namedata' (name) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'namedata' (name) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_CHAR: 1234567890 '1234567890' (int8) as SQL_C_WCHAR: 1234567890 '1234567890' (int8) as SQL_C_SSHORT: 722 '1234567890' (int8) as SQL_C_USHORT: 722 '1234567890' (int8) as SQL_C_SLONG: 1234567890 '1234567890' (int8) as SQL_C_ULONG: 1234567890 '1234567890' (int8) as SQL_C_FLOAT: 1234567936.000000 '1234567890' (int8) as SQL_C_DOUBLE: 1234567890.000000 '1234567890' (int8) as SQL_C_BIT: 210 '1234567890' (int8) as SQL_C_STINYINT: -46 '1234567890' (int8) as SQL_C_UTINYINT: 210 '1234567890' (int8) as SQL_C_SBIGINT: 1234567890 '1234567890' (int8) as SQL_C_UBIGINT: 1234567890 '1234567890' (int8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_BOOKMARK: 1234567890 '1234567890' (int8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567890' (int8) as SQL_C_NUMERIC: precision: 10 scale: 0 sign: 0 val: d2029649000000000000000000000000 '1234567890' (int8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_CHAR: 12345 '12345' (int2) as SQL_C_WCHAR: 12345 '12345' (int2) as SQL_C_SSHORT: 12345 '12345' (int2) as SQL_C_USHORT: 12345 '12345' (int2) as SQL_C_SLONG: 12345 '12345' (int2) as SQL_C_ULONG: 12345 '12345' (int2) as SQL_C_FLOAT: 12345.000000 '12345' (int2) as SQL_C_DOUBLE: 12345.000000 '12345' (int2) as SQL_C_BIT: 57 '12345' (int2) as SQL_C_STINYINT: 57 '12345' (int2) as SQL_C_UTINYINT: 57 '12345' (int2) as SQL_C_SBIGINT: 12345 '12345' (int2) as SQL_C_UBIGINT: 12345 '12345' (int2) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_BOOKMARK: 12345 '12345' (int2) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '12345' (int2) as SQL_C_NUMERIC: precision: 5 scale: 0 sign: 0 val: 39300000000000000000000000000000 '12345' (int2) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_CHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_WCHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_SSHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_USHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SLONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_ULONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_FLOAT: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_DOUBLE: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_BIT: 1 '1 2 3 4 5' (int2vector) as SQL_C_STINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UTINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_BOOKMARK: 1 '1 2 3 4 5' (int2vector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3 4 5' (int2vector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3 4 5' (int2vector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_CHAR: 1234567 '1234567' (int4) as SQL_C_WCHAR: 1234567 '1234567' (int4) as SQL_C_SSHORT: -10617 '1234567' (int4) as SQL_C_USHORT: 54919 '1234567' (int4) as SQL_C_SLONG: 1234567 '1234567' (int4) as SQL_C_ULONG: 1234567 '1234567' (int4) as SQL_C_FLOAT: 1234567.000000 '1234567' (int4) as SQL_C_DOUBLE: 1234567.000000 '1234567' (int4) as SQL_C_BIT: 135 '1234567' (int4) as SQL_C_STINYINT: -121 '1234567' (int4) as SQL_C_UTINYINT: 135 '1234567' (int4) as SQL_C_SBIGINT: 1234567 '1234567' (int4) as SQL_C_UBIGINT: 1234567 '1234567' (int4) as SQL_C_BINARY: hex: 87D61200 '1234567' (int4) as SQL_C_BOOKMARK: 1234567 '1234567' (int4) as SQL_C_VARBOOKMARK: hex: 87D61200 '1234567' (int4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567' (int4) as SQL_C_NUMERIC: precision: 7 scale: 0 sign: 0 val: 87d61200000000000000000000000000 '1234567' (int4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_CHAR: int4pl 'int4pl' (regproc) as SQL_C_WCHAR: int4pl 'int4pl' (regproc) as SQL_C_SSHORT: 0 'int4pl' (regproc) as SQL_C_USHORT: 0 'int4pl' (regproc) as SQL_C_SLONG: 0 'int4pl' (regproc) as SQL_C_ULONG: 0 'int4pl' (regproc) as SQL_C_FLOAT: 0.000000 'int4pl' (regproc) as SQL_C_DOUBLE: 0.000000 'int4pl' (regproc) as SQL_C_BIT: 0 'int4pl' (regproc) as SQL_C_STINYINT: 0 'int4pl' (regproc) as SQL_C_UTINYINT: 0 'int4pl' (regproc) as SQL_C_SBIGINT: 0 'int4pl' (regproc) as SQL_C_UBIGINT: 0 'int4pl' (regproc) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_BOOKMARK: 0 'int4pl' (regproc) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'int4pl' (regproc) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'int4pl' (regproc) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_CHAR: textdata 'textdata' (text) as SQL_C_WCHAR: textdata 'textdata' (text) as SQL_C_SSHORT: 0 'textdata' (text) as SQL_C_USHORT: 0 'textdata' (text) as SQL_C_SLONG: 0 'textdata' (text) as SQL_C_ULONG: 0 'textdata' (text) as SQL_C_FLOAT: 0.000000 'textdata' (text) as SQL_C_DOUBLE: 0.000000 'textdata' (text) as SQL_C_BIT: 0 'textdata' (text) as SQL_C_STINYINT: 0 'textdata' (text) as SQL_C_UTINYINT: 0 'textdata' (text) as SQL_C_SBIGINT: 0 'textdata' (text) as SQL_C_UBIGINT: 0 'textdata' (text) as SQL_C_BINARY: hex: 7465787464617461 'textdata' (text) as SQL_C_BOOKMARK: 0 'textdata' (text) as SQL_C_VARBOOKMARK: hex: 7465787464617461 'textdata' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'textdata' (text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'textdata' (text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_CHAR: (1,2) '(1,2)' (tid) as SQL_C_WCHAR: (1,2) '(1,2)' (tid) as SQL_C_SSHORT: 0 '(1,2)' (tid) as SQL_C_USHORT: 0 '(1,2)' (tid) as SQL_C_SLONG: 0 '(1,2)' (tid) as SQL_C_ULONG: 0 '(1,2)' (tid) as SQL_C_FLOAT: 0.000000 '(1,2)' (tid) as SQL_C_DOUBLE: 0.000000 '(1,2)' (tid) as SQL_C_BIT: 0 '(1,2)' (tid) as SQL_C_STINYINT: 0 '(1,2)' (tid) as SQL_C_UTINYINT: 0 '(1,2)' (tid) as SQL_C_SBIGINT: 0 '(1,2)' (tid) as SQL_C_UBIGINT: 0 '(1,2)' (tid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_BOOKMARK: 0 '(1,2)' (tid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '(1,2)' (tid) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '(1,2)' (tid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_CHAR: 1234 '1234' (xid) as SQL_C_WCHAR: 1234 '1234' (xid) as SQL_C_SSHORT: 1234 '1234' (xid) as SQL_C_USHORT: 1234 '1234' (xid) as SQL_C_SLONG: 1234 '1234' (xid) as SQL_C_ULONG: 1234 '1234' (xid) as SQL_C_FLOAT: 1234.000000 '1234' (xid) as SQL_C_DOUBLE: 1234.000000 '1234' (xid) as SQL_C_BIT: 210 '1234' (xid) as SQL_C_STINYINT: -46 '1234' (xid) as SQL_C_UTINYINT: 210 '1234' (xid) as SQL_C_SBIGINT: 1234 '1234' (xid) as SQL_C_UBIGINT: 1234 '1234' (xid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_BOOKMARK: 1234 '1234' (xid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234' (xid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: d2040000000000000000000000000000 '1234' (xid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_CHAR: 4321 '4321' (cid) as SQL_C_WCHAR: 4321 '4321' (cid) as SQL_C_SSHORT: 4321 '4321' (cid) as SQL_C_USHORT: 4321 '4321' (cid) as SQL_C_SLONG: 4321 '4321' (cid) as SQL_C_ULONG: 4321 '4321' (cid) as SQL_C_FLOAT: 4321.000000 '4321' (cid) as SQL_C_DOUBLE: 4321.000000 '4321' (cid) as SQL_C_BIT: 225 '4321' (cid) as SQL_C_STINYINT: -31 '4321' (cid) as SQL_C_UTINYINT: 225 '4321' (cid) as SQL_C_SBIGINT: 4321 '4321' (cid) as SQL_C_UBIGINT: 4321 '4321' (cid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_BOOKMARK: 4321 '4321' (cid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '4321' (cid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: e1100000000000000000000000000000 '4321' (cid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_CHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_WCHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_SSHORT: 1 '1 2 3' (oidvector) as SQL_C_USHORT: 1 '1 2 3' (oidvector) as SQL_C_SLONG: 1 '1 2 3' (oidvector) as SQL_C_ULONG: 1 '1 2 3' (oidvector) as SQL_C_FLOAT: 1.000000 '1 2 3' (oidvector) as SQL_C_DOUBLE: 1.000000 '1 2 3' (oidvector) as SQL_C_BIT: 1 '1 2 3' (oidvector) as SQL_C_STINYINT: 1 '1 2 3' (oidvector) as SQL_C_UTINYINT: 1 '1 2 3' (oidvector) as SQL_C_SBIGINT: 1 '1 2 3' (oidvector) as SQL_C_UBIGINT: 1 '1 2 3' (oidvector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_BOOKMARK: 1 '1 2 3' (oidvector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3' (oidvector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3' (oidvector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_CHAR: bar 'bar' (xml) as SQL_C_WCHAR: bar 'bar' (xml) as SQL_C_SSHORT: 0 'bar' (xml) as SQL_C_USHORT: 0 'bar' (xml) as SQL_C_SLONG: 0 'bar' (xml) as SQL_C_ULONG: 0 'bar' (xml) as SQL_C_FLOAT: 0.000000 'bar' (xml) as SQL_C_DOUBLE: 0.000000 'bar' (xml) as SQL_C_BIT: 0 'bar' (xml) as SQL_C_STINYINT: 0 'bar' (xml) as SQL_C_UTINYINT: 0 'bar' (xml) as SQL_C_SBIGINT: 0 'bar' (xml) as SQL_C_UBIGINT: 0 'bar' (xml) as SQL_C_BINARY: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_BOOKMARK: 0 'bar' (xml) as SQL_C_VARBOOKMARK: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'bar' (xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'bar' (xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_CHAR: {bar} '{bar}' (_xml) as SQL_C_WCHAR: {bar} '{bar}' (_xml) as SQL_C_SSHORT: 0 '{bar}' (_xml) as SQL_C_USHORT: 0 '{bar}' (_xml) as SQL_C_SLONG: 0 '{bar}' (_xml) as SQL_C_ULONG: 0 '{bar}' (_xml) as SQL_C_FLOAT: 0.000000 '{bar}' (_xml) as SQL_C_DOUBLE: 0.000000 '{bar}' (_xml) as SQL_C_BIT: 0 '{bar}' (_xml) as SQL_C_STINYINT: 0 '{bar}' (_xml) as SQL_C_UTINYINT: 0 '{bar}' (_xml) as SQL_C_SBIGINT: 0 '{bar}' (_xml) as SQL_C_UBIGINT: 0 '{bar}' (_xml) as SQL_C_BINARY: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_BOOKMARK: 0 '{bar}' (_xml) as SQL_C_VARBOOKMARK: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{bar}' (_xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{bar}' (_xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_CHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_WCHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_SSHORT: 10 '10.0.0.1' (cidr) as SQL_C_USHORT: 10 '10.0.0.1' (cidr) as SQL_C_SLONG: 10 '10.0.0.1' (cidr) as SQL_C_ULONG: 10 '10.0.0.1' (cidr) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (cidr) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (cidr) as SQL_C_BIT: 10 '10.0.0.1' (cidr) as SQL_C_STINYINT: 10 '10.0.0.1' (cidr) as SQL_C_UTINYINT: 10 '10.0.0.1' (cidr) as SQL_C_SBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_UBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_BOOKMARK: 10 '10.0.0.1' (cidr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (cidr) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (cidr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_CHAR: 1.234 '1.234' (float4) as SQL_C_WCHAR: 1.234 '1.234' (float4) as SQL_C_SSHORT: 1 '1.234' (float4) as SQL_C_USHORT: 1 '1.234' (float4) as SQL_C_SLONG: 1 '1.234' (float4) as SQL_C_ULONG: 1 '1.234' (float4) as SQL_C_FLOAT: 1.234000 '1.234' (float4) as SQL_C_DOUBLE: 1.234000 '1.234' (float4) as SQL_C_BIT: 1 '1.234' (float4) as SQL_C_STINYINT: 1 '1.234' (float4) as SQL_C_UTINYINT: 1 '1.234' (float4) as SQL_C_SBIGINT: 1 '1.234' (float4) as SQL_C_UBIGINT: 1 '1.234' (float4) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_BOOKMARK: 1 '1.234' (float4) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.234' (float4) as SQL_C_NUMERIC: precision: 4 scale: 3 sign: 3 val: d2040000000000000000000000000000 '1.234' (float4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_CHAR: 1.23456789012 '1.23456789012' (float8) as SQL_C_WCHAR: 1.23456789012 '1.23456789012' (float8) as SQL_C_SSHORT: 1 '1.23456789012' (float8) as SQL_C_USHORT: 1 '1.23456789012' (float8) as SQL_C_SLONG: 1 '1.23456789012' (float8) as SQL_C_ULONG: 1 '1.23456789012' (float8) as SQL_C_FLOAT: 1.234568 '1.23456789012' (float8) as SQL_C_DOUBLE: 1.234568 '1.23456789012' (float8) as SQL_C_BIT: 1 '1.23456789012' (float8) as SQL_C_STINYINT: 1 '1.23456789012' (float8) as SQL_C_UTINYINT: 1 '1.23456789012' (float8) as SQL_C_SBIGINT: 1 '1.23456789012' (float8) as SQL_C_UBIGINT: 1 '1.23456789012' (float8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_BOOKMARK: 1 '1.23456789012' (float8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23456789012' (float8) as SQL_C_NUMERIC: precision: 12 scale: 11 sign: 11 val: 141a99be1c0000000000000000000000 '1.23456789012' (float8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_CHAR: foo 'foo' (unknown) as SQL_C_WCHAR: foo 'foo' (unknown) as SQL_C_SSHORT: 0 'foo' (unknown) as SQL_C_USHORT: 0 'foo' (unknown) as SQL_C_SLONG: 0 'foo' (unknown) as SQL_C_ULONG: 0 'foo' (unknown) as SQL_C_FLOAT: 0.000000 'foo' (unknown) as SQL_C_DOUBLE: 0.000000 'foo' (unknown) as SQL_C_BIT: 0 'foo' (unknown) as SQL_C_STINYINT: 0 'foo' (unknown) as SQL_C_UTINYINT: 0 'foo' (unknown) as SQL_C_SBIGINT: 0 'foo' (unknown) as SQL_C_UBIGINT: 0 'foo' (unknown) as SQL_C_BINARY: hex: 666F6F 'foo' (unknown) as SQL_C_BOOKMARK: 0 'foo' (unknown) as SQL_C_VARBOOKMARK: hex: 666F6F 'foo' (unknown) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foo' (unknown) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foo' (unknown) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_CHAR: $1.23 '1.23' (money) as SQL_C_WCHAR: $1.23 '1.23' (money) as SQL_C_SSHORT: 1 '1.23' (money) as SQL_C_USHORT: 1 '1.23' (money) as SQL_C_SLONG: 1 '1.23' (money) as SQL_C_ULONG: 1 '1.23' (money) as SQL_C_FLOAT: 1.230000 '1.23' (money) as SQL_C_DOUBLE: 1.230000 '1.23' (money) as SQL_C_BIT: 1 '1.23' (money) as SQL_C_STINYINT: 1 '1.23' (money) as SQL_C_UTINYINT: 1 '1.23' (money) as SQL_C_SBIGINT: 1 '1.23' (money) as SQL_C_UBIGINT: 1 '1.23' (money) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_BOOKMARK: 1 '1.23' (money) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23' (money) as SQL_C_NUMERIC: precision: 3 scale: 2 sign: 2 val: 7b000000000000000000000000000000 '1.23' (money) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_CHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_WCHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_SSHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_USHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SLONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_ULONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_FLOAT: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_DOUBLE: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_BIT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_STINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UTINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_BOOKMARK: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 08000000000000000000000000000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_CHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_WCHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_SSHORT: 10 '10.0.0.1' (inet) as SQL_C_USHORT: 10 '10.0.0.1' (inet) as SQL_C_SLONG: 10 '10.0.0.1' (inet) as SQL_C_ULONG: 10 '10.0.0.1' (inet) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (inet) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (inet) as SQL_C_BIT: 10 '10.0.0.1' (inet) as SQL_C_STINYINT: 10 '10.0.0.1' (inet) as SQL_C_UTINYINT: 10 '10.0.0.1' (inet) as SQL_C_SBIGINT: 10 '10.0.0.1' (inet) as SQL_C_UBIGINT: 10 '10.0.0.1' (inet) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_BOOKMARK: 10 '10.0.0.1' (inet) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (inet) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (inet) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_SSHORT: 0 '{foo, bar}' (_text) as SQL_C_USHORT: 0 '{foo, bar}' (_text) as SQL_C_SLONG: 0 '{foo, bar}' (_text) as SQL_C_ULONG: 0 '{foo, bar}' (_text) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_text) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_text) as SQL_C_BIT: 0 '{foo, bar}' (_text) as SQL_C_STINYINT: 0 '{foo, bar}' (_text) as SQL_C_UTINYINT: 0 '{foo, bar}' (_text) as SQL_C_SBIGINT: 0 '{foo, bar}' (_text) as SQL_C_UBIGINT: 0 '{foo, bar}' (_text) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_text) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_USHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_SLONG: 0 '{foo, bar}' (_bpchar) as SQL_C_ULONG: 0 '{foo, bar}' (_bpchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_BIT: 0 '{foo, bar}' (_bpchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_bpchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_varchar) as SQL_C_USHORT: 0 '{foo, bar}' (_varchar) as SQL_C_SLONG: 0 '{foo, bar}' (_varchar) as SQL_C_ULONG: 0 '{foo, bar}' (_varchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_varchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_varchar) as SQL_C_BIT: 0 '{foo, bar}' (_varchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_varchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_CHAR: foobar 'foobar' (bpchar) as SQL_C_WCHAR: foobar 'foobar' (bpchar) as SQL_C_SSHORT: 0 'foobar' (bpchar) as SQL_C_USHORT: 0 'foobar' (bpchar) as SQL_C_SLONG: 0 'foobar' (bpchar) as SQL_C_ULONG: 0 'foobar' (bpchar) as SQL_C_FLOAT: 0.000000 'foobar' (bpchar) as SQL_C_DOUBLE: 0.000000 'foobar' (bpchar) as SQL_C_BIT: 0 'foobar' (bpchar) as SQL_C_STINYINT: 0 'foobar' (bpchar) as SQL_C_UTINYINT: 0 'foobar' (bpchar) as SQL_C_SBIGINT: 0 'foobar' (bpchar) as SQL_C_UBIGINT: 0 'foobar' (bpchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_BOOKMARK: 0 'foobar' (bpchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_CHAR: foobar 'foobar' (varchar) as SQL_C_WCHAR: foobar 'foobar' (varchar) as SQL_C_SSHORT: 0 'foobar' (varchar) as SQL_C_USHORT: 0 'foobar' (varchar) as SQL_C_SLONG: 0 'foobar' (varchar) as SQL_C_ULONG: 0 'foobar' (varchar) as SQL_C_FLOAT: 0.000000 'foobar' (varchar) as SQL_C_DOUBLE: 0.000000 'foobar' (varchar) as SQL_C_BIT: 0 'foobar' (varchar) as SQL_C_STINYINT: 0 'foobar' (varchar) as SQL_C_UTINYINT: 0 'foobar' (varchar) as SQL_C_SBIGINT: 0 'foobar' (varchar) as SQL_C_UBIGINT: 0 'foobar' (varchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (varchar) as SQL_C_BOOKMARK: 0 'foobar' (varchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_CHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_WCHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_SSHORT: 2011 '2011-02-13' (date) as SQL_C_USHORT: 2011 '2011-02-13' (date) as SQL_C_SLONG: 2011 '2011-02-13' (date) as SQL_C_ULONG: 2011 '2011-02-13' (date) as SQL_C_FLOAT: 2011.000000 '2011-02-13' (date) as SQL_C_DOUBLE: 2011.000000 '2011-02-13' (date) as SQL_C_BIT: 219 '2011-02-13' (date) as SQL_C_STINYINT: -37 '2011-02-13' (date) as SQL_C_UTINYINT: 219 '2011-02-13' (date) as SQL_C_SBIGINT: 2011 '2011-02-13' (date) as SQL_C_UBIGINT: 2011 '2011-02-13' (date) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_BOOKMARK: 2011 '2011-02-13' (date) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '2011-02-13' (date) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-13' (date) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_CHAR: 13:23:34 '13:23:34' (time) as SQL_C_WCHAR: 13:23:34 '13:23:34' (time) as SQL_C_SSHORT: 13 '13:23:34' (time) as SQL_C_USHORT: 13 '13:23:34' (time) as SQL_C_SLONG: 13 '13:23:34' (time) as SQL_C_ULONG: 13 '13:23:34' (time) as SQL_C_FLOAT: 13.000000 '13:23:34' (time) as SQL_C_DOUBLE: 13.000000 '13:23:34' (time) as SQL_C_BIT: 13 '13:23:34' (time) as SQL_C_STINYINT: 13 '13:23:34' (time) as SQL_C_UTINYINT: 13 '13:23:34' (time) as SQL_C_SBIGINT: 13 '13:23:34' (time) as SQL_C_UBIGINT: 13 '13:23:34' (time) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_BOOKMARK: 13 '13:23:34' (time) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_TYPE_TIME: h: 13 m: 23 s: 34 '13:23:34' (time) as SQL_C_NUMERIC: precision: 2 scale: 0 sign: 0 val: 0d000000000000000000000000000000 '13:23:34' (time) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_WCHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_SSHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_USHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_SLONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_ULONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_FLOAT: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_DOUBLE: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_BIT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_STINYINT: -37 '2011-02-15 15:49:18' (timestamp) as SQL_C_UTINYINT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_SBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_UBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_BOOKMARK: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_TYPE_TIME: h: 15 m: 49 s: 18 '2011-02-15 15:49:18' (timestamp) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_CHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_WCHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SSHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_USHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SLONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_ULONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_FLOAT: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DOUBLE: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BIT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_STINYINT: -37 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UTINYINT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BOOKMARK: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TYPE_TIME: h: 6 m: 49 s: 18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_CHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_WCHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SSHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_USHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SLONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_ULONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_FLOAT: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_DOUBLE: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BIT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_STINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UTINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_BOOKMARK: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 09000000000000000000000000000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MONTH: interval sign: 0 year: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 9 month: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_CHAR: 1 '1' (bit) as SQL_C_WCHAR: 1 '1' (bit) as SQL_C_SSHORT: 1 '1' (bit) as SQL_C_USHORT: 1 '1' (bit) as SQL_C_SLONG: 1 '1' (bit) as SQL_C_ULONG: 1 '1' (bit) as SQL_C_FLOAT: 1.000000 '1' (bit) as SQL_C_DOUBLE: 1.000000 '1' (bit) as SQL_C_BIT: 1 '1' (bit) as SQL_C_STINYINT: 1 '1' (bit) as SQL_C_UTINYINT: 1 '1' (bit) as SQL_C_SBIGINT: 1 '1' (bit) as SQL_C_UBIGINT: 1 '1' (bit) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_BOOKMARK: 1 '1' (bit) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1' (bit) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1' (bit) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_CHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_WCHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_SSHORT: 1234 '1234.567890' (numeric) as SQL_C_USHORT: 1234 '1234.567890' (numeric) as SQL_C_SLONG: 1234 '1234.567890' (numeric) as SQL_C_ULONG: 1234 '1234.567890' (numeric) as SQL_C_FLOAT: 1234.567871 '1234.567890' (numeric) as SQL_C_DOUBLE: 1234.567890 '1234.567890' (numeric) as SQL_C_BIT: 210 '1234.567890' (numeric) as SQL_C_STINYINT: -46 '1234.567890' (numeric) as SQL_C_UTINYINT: 210 '1234.567890' (numeric) as SQL_C_SBIGINT: 1234 '1234.567890' (numeric) as SQL_C_UBIGINT: 1234 '1234.567890' (numeric) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_BOOKMARK: 1234 '1234.567890' (numeric) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234.567890' (numeric) as SQL_C_NUMERIC: precision: 10 scale: 6 sign: 6 val: d2029649000000000000000000000000 '1234.567890' (numeric) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_CHAR: foocur 'foocur' (refcursor) as SQL_C_WCHAR: foocur 'foocur' (refcursor) as SQL_C_SSHORT: 0 'foocur' (refcursor) as SQL_C_USHORT: 0 'foocur' (refcursor) as SQL_C_SLONG: 0 'foocur' (refcursor) as SQL_C_ULONG: 0 'foocur' (refcursor) as SQL_C_FLOAT: 0.000000 'foocur' (refcursor) as SQL_C_DOUBLE: 0.000000 'foocur' (refcursor) as SQL_C_BIT: 0 'foocur' (refcursor) as SQL_C_STINYINT: 0 'foocur' (refcursor) as SQL_C_UTINYINT: 0 'foocur' (refcursor) as SQL_C_SBIGINT: 0 'foocur' (refcursor) as SQL_C_UBIGINT: 0 'foocur' (refcursor) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_BOOKMARK: 0 'foocur' (refcursor) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foocur' (refcursor) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foocur' (refcursor) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 Executed: SET bytea_output=hex '\x464F4F' (bytea) as SQL_C_CHAR: 464f4f '\x464F4F' (bytea) as SQL_C_WCHAR: 464f4f '543c5e21-435a-440b-943c-64af1ad571f1' (text) as SQL_C_GUID: d1: 543C5E21 d2: 435A d3: 440B d4: 943C64AF1AD571F1 '2011-02-13' (date) as SQL_C_DATE: y: 2011 m: 2 d: 13 '2011-02-13' (date) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 13 h: 0 m: 0 s: 0 f: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_DATE: y: 2011 m: 2 d: 15 '2011-02-15 15:49:18' (timestamp) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 15 h: 15 m: 49 s: 18 f: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DATE: y: 2011 m: 2 d: 16 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 16 h: 6 m: 49 s: 18 f: 0 '' (text) as SQL_C_TYPE_DATE: y: 0 m: 0 d: 0 '' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '' (text) as SQL_C_TYPE_TIMESTAMP: y: 0 m: 0 d: 0 h: 0 m: 0 s: 0 f: 0 'foobar' (text) as SQL_C_CHAR: foob (truncated) 'foobar' (text) as SQL_C_CHAR: fooba (truncated) 'foobar' (text) as SQL_C_CHAR: foobar 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: foobar '' (text) as SQL_C_CHAR: '' (text) as SQL_C_WCHAR: \FF00\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF (truncated) '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:1 (truncated) '2011-02-15 15:49:18 BC' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 (truncated) 'NaN' (float4) as SQL_C_FLOAT: nan 'Infinity' (float4) as SQL_C_FLOAT: inf '-Infinity' (float4) as SQL_C_FLOAT: -inf 'NaN' (float8) as SQL_C_FLOAT: nan 'Infinity' (float8) as SQL_C_FLOAT: inf '-Infinity' (float8) as SQL_C_FLOAT: -inf 'NaN' (float4) as SQL_C_DOUBLE: nan 'Infinity' (float4) as SQL_C_DOUBLE: inf '-Infinity' (float4) as SQL_C_DOUBLE: -inf 'NaN' (float8) as SQL_C_DOUBLE: nan 'Infinity' (float8) as SQL_C_DOUBLE: inf '-Infinity' (float8) as SQL_C_DOUBLE: -inf disconnecting psqlodbc-REL-16_00_0005/test/expected/result-conversions_1.out000066400000000000000000002441101462406103600241150ustar00rootroot00000000000000connected Executed: SET intervalstyle=postgres Executed: SET bytea_output=escape Executed: SET lc_monetary='C' 'true' (boolean) as SQL_C_CHAR: 1 'true' (boolean) as SQL_C_WCHAR: 1 'true' (boolean) as SQL_C_SSHORT: 1 'true' (boolean) as SQL_C_USHORT: 1 'true' (boolean) as SQL_C_SLONG: 1 'true' (boolean) as SQL_C_ULONG: 1 'true' (boolean) as SQL_C_FLOAT: 1.000000 'true' (boolean) as SQL_C_DOUBLE: 1.000000 'true' (boolean) as SQL_C_BIT: 1 'true' (boolean) as SQL_C_STINYINT: 1 'true' (boolean) as SQL_C_UTINYINT: 1 'true' (boolean) as SQL_C_SBIGINT: 1 'true' (boolean) as SQL_C_UBIGINT: 1 'true' (boolean) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_BOOKMARK: 1 'true' (boolean) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'true' (boolean) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 'true' (boolean) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_CHAR: 464F4F '\x464F4F' (bytea) as SQL_C_WCHAR: 464F4F '\x464F4F' (bytea) as SQL_C_SSHORT: 0 '\x464F4F' (bytea) as SQL_C_USHORT: 0 '\x464F4F' (bytea) as SQL_C_SLONG: 0 '\x464F4F' (bytea) as SQL_C_ULONG: 0 '\x464F4F' (bytea) as SQL_C_FLOAT: 0.000000 '\x464F4F' (bytea) as SQL_C_DOUBLE: 0.000000 '\x464F4F' (bytea) as SQL_C_BIT: 0 '\x464F4F' (bytea) as SQL_C_STINYINT: 0 '\x464F4F' (bytea) as SQL_C_UTINYINT: 0 '\x464F4F' (bytea) as SQL_C_SBIGINT: 0 '\x464F4F' (bytea) as SQL_C_UBIGINT: 0 '\x464F4F' (bytea) as SQL_C_BINARY: hex: 464F4F '\x464F4F' (bytea) as SQL_C_BOOKMARK: 0 '\x464F4F' (bytea) as SQL_C_VARBOOKMARK: hex: 464F4F '\x464F4F' (bytea) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '\x464F4F' (bytea) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '\x464F4F' (bytea) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_CHAR: x 'x' (char) as SQL_C_WCHAR: x 'x' (char) as SQL_C_SSHORT: 0 'x' (char) as SQL_C_USHORT: 0 'x' (char) as SQL_C_SLONG: 0 'x' (char) as SQL_C_ULONG: 0 'x' (char) as SQL_C_FLOAT: 0.000000 'x' (char) as SQL_C_DOUBLE: 0.000000 'x' (char) as SQL_C_BIT: 0 'x' (char) as SQL_C_STINYINT: 0 'x' (char) as SQL_C_UTINYINT: 0 'x' (char) as SQL_C_SBIGINT: 0 'x' (char) as SQL_C_UBIGINT: 0 'x' (char) as SQL_C_BINARY: hex: 78 'x' (char) as SQL_C_BOOKMARK: 0 'x' (char) as SQL_C_VARBOOKMARK: hex: 78 'x' (char) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'x' (char) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'x' (char) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_CHAR: namedata 'namedata' (name) as SQL_C_WCHAR: namedata 'namedata' (name) as SQL_C_SSHORT: 0 'namedata' (name) as SQL_C_USHORT: 0 'namedata' (name) as SQL_C_SLONG: 0 'namedata' (name) as SQL_C_ULONG: 0 'namedata' (name) as SQL_C_FLOAT: 0.000000 'namedata' (name) as SQL_C_DOUBLE: 0.000000 'namedata' (name) as SQL_C_BIT: 0 'namedata' (name) as SQL_C_STINYINT: 0 'namedata' (name) as SQL_C_UTINYINT: 0 'namedata' (name) as SQL_C_SBIGINT: 0 'namedata' (name) as SQL_C_UBIGINT: 0 'namedata' (name) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_BOOKMARK: 0 'namedata' (name) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'namedata' (name) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'namedata' (name) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_CHAR: 1234567890 '1234567890' (int8) as SQL_C_WCHAR: 1234567890 '1234567890' (int8) as SQL_C_SSHORT: 722 '1234567890' (int8) as SQL_C_USHORT: 722 '1234567890' (int8) as SQL_C_SLONG: 1234567890 '1234567890' (int8) as SQL_C_ULONG: 1234567890 '1234567890' (int8) as SQL_C_FLOAT: 1234567936.000000 '1234567890' (int8) as SQL_C_DOUBLE: 1234567890.000000 '1234567890' (int8) as SQL_C_BIT: 210 '1234567890' (int8) as SQL_C_STINYINT: -46 '1234567890' (int8) as SQL_C_UTINYINT: 210 '1234567890' (int8) as SQL_C_SBIGINT: 1234567890 '1234567890' (int8) as SQL_C_UBIGINT: 1234567890 '1234567890' (int8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_BOOKMARK: 1234567890 '1234567890' (int8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567890' (int8) as SQL_C_NUMERIC: precision: 10 scale: 0 sign: 0 val: d2029649000000000000000000000000 '1234567890' (int8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_CHAR: 12345 '12345' (int2) as SQL_C_WCHAR: 12345 '12345' (int2) as SQL_C_SSHORT: 12345 '12345' (int2) as SQL_C_USHORT: 12345 '12345' (int2) as SQL_C_SLONG: 12345 '12345' (int2) as SQL_C_ULONG: 12345 '12345' (int2) as SQL_C_FLOAT: 12345.000000 '12345' (int2) as SQL_C_DOUBLE: 12345.000000 '12345' (int2) as SQL_C_BIT: 57 '12345' (int2) as SQL_C_STINYINT: 57 '12345' (int2) as SQL_C_UTINYINT: 57 '12345' (int2) as SQL_C_SBIGINT: 12345 '12345' (int2) as SQL_C_UBIGINT: 12345 '12345' (int2) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_BOOKMARK: 12345 '12345' (int2) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '12345' (int2) as SQL_C_NUMERIC: precision: 5 scale: 0 sign: 0 val: 39300000000000000000000000000000 '12345' (int2) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_CHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_WCHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_SSHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_USHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SLONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_ULONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_FLOAT: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_DOUBLE: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_BIT: 1 '1 2 3 4 5' (int2vector) as SQL_C_STINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UTINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_BOOKMARK: 1 '1 2 3 4 5' (int2vector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3 4 5' (int2vector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3 4 5' (int2vector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_CHAR: 1234567 '1234567' (int4) as SQL_C_WCHAR: 1234567 '1234567' (int4) as SQL_C_SSHORT: -10617 '1234567' (int4) as SQL_C_USHORT: 54919 '1234567' (int4) as SQL_C_SLONG: 1234567 '1234567' (int4) as SQL_C_ULONG: 1234567 '1234567' (int4) as SQL_C_FLOAT: 1234567.000000 '1234567' (int4) as SQL_C_DOUBLE: 1234567.000000 '1234567' (int4) as SQL_C_BIT: 135 '1234567' (int4) as SQL_C_STINYINT: -121 '1234567' (int4) as SQL_C_UTINYINT: 135 '1234567' (int4) as SQL_C_SBIGINT: 1234567 '1234567' (int4) as SQL_C_UBIGINT: 1234567 '1234567' (int4) as SQL_C_BINARY: hex: 0012D687 '1234567' (int4) as SQL_C_BOOKMARK: 1234567 '1234567' (int4) as SQL_C_VARBOOKMARK: hex: 0012D687 '1234567' (int4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567' (int4) as SQL_C_NUMERIC: precision: 7 scale: 0 sign: 0 val: 87d61200000000000000000000000000 '1234567' (int4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_CHAR: int4pl 'int4pl' (regproc) as SQL_C_WCHAR: int4pl 'int4pl' (regproc) as SQL_C_SSHORT: 0 'int4pl' (regproc) as SQL_C_USHORT: 0 'int4pl' (regproc) as SQL_C_SLONG: 0 'int4pl' (regproc) as SQL_C_ULONG: 0 'int4pl' (regproc) as SQL_C_FLOAT: 0.000000 'int4pl' (regproc) as SQL_C_DOUBLE: 0.000000 'int4pl' (regproc) as SQL_C_BIT: 0 'int4pl' (regproc) as SQL_C_STINYINT: 0 'int4pl' (regproc) as SQL_C_UTINYINT: 0 'int4pl' (regproc) as SQL_C_SBIGINT: 0 'int4pl' (regproc) as SQL_C_UBIGINT: 0 'int4pl' (regproc) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_BOOKMARK: 0 'int4pl' (regproc) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'int4pl' (regproc) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'int4pl' (regproc) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_CHAR: textdata 'textdata' (text) as SQL_C_WCHAR: textdata 'textdata' (text) as SQL_C_SSHORT: 0 'textdata' (text) as SQL_C_USHORT: 0 'textdata' (text) as SQL_C_SLONG: 0 'textdata' (text) as SQL_C_ULONG: 0 'textdata' (text) as SQL_C_FLOAT: 0.000000 'textdata' (text) as SQL_C_DOUBLE: 0.000000 'textdata' (text) as SQL_C_BIT: 0 'textdata' (text) as SQL_C_STINYINT: 0 'textdata' (text) as SQL_C_UTINYINT: 0 'textdata' (text) as SQL_C_SBIGINT: 0 'textdata' (text) as SQL_C_UBIGINT: 0 'textdata' (text) as SQL_C_BINARY: hex: 7465787464617461 'textdata' (text) as SQL_C_BOOKMARK: 0 'textdata' (text) as SQL_C_VARBOOKMARK: hex: 7465787464617461 'textdata' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'textdata' (text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'textdata' (text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_CHAR: (1,2) '(1,2)' (tid) as SQL_C_WCHAR: (1,2) '(1,2)' (tid) as SQL_C_SSHORT: 0 '(1,2)' (tid) as SQL_C_USHORT: 0 '(1,2)' (tid) as SQL_C_SLONG: 0 '(1,2)' (tid) as SQL_C_ULONG: 0 '(1,2)' (tid) as SQL_C_FLOAT: 0.000000 '(1,2)' (tid) as SQL_C_DOUBLE: 0.000000 '(1,2)' (tid) as SQL_C_BIT: 0 '(1,2)' (tid) as SQL_C_STINYINT: 0 '(1,2)' (tid) as SQL_C_UTINYINT: 0 '(1,2)' (tid) as SQL_C_SBIGINT: 0 '(1,2)' (tid) as SQL_C_UBIGINT: 0 '(1,2)' (tid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_BOOKMARK: 0 '(1,2)' (tid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '(1,2)' (tid) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '(1,2)' (tid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_CHAR: 1234 '1234' (xid) as SQL_C_WCHAR: 1234 '1234' (xid) as SQL_C_SSHORT: 1234 '1234' (xid) as SQL_C_USHORT: 1234 '1234' (xid) as SQL_C_SLONG: 1234 '1234' (xid) as SQL_C_ULONG: 1234 '1234' (xid) as SQL_C_FLOAT: 1234.000000 '1234' (xid) as SQL_C_DOUBLE: 1234.000000 '1234' (xid) as SQL_C_BIT: 210 '1234' (xid) as SQL_C_STINYINT: -46 '1234' (xid) as SQL_C_UTINYINT: 210 '1234' (xid) as SQL_C_SBIGINT: 1234 '1234' (xid) as SQL_C_UBIGINT: 1234 '1234' (xid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_BOOKMARK: 1234 '1234' (xid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234' (xid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: d2040000000000000000000000000000 '1234' (xid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_CHAR: 4321 '4321' (cid) as SQL_C_WCHAR: 4321 '4321' (cid) as SQL_C_SSHORT: 4321 '4321' (cid) as SQL_C_USHORT: 4321 '4321' (cid) as SQL_C_SLONG: 4321 '4321' (cid) as SQL_C_ULONG: 4321 '4321' (cid) as SQL_C_FLOAT: 4321.000000 '4321' (cid) as SQL_C_DOUBLE: 4321.000000 '4321' (cid) as SQL_C_BIT: 225 '4321' (cid) as SQL_C_STINYINT: -31 '4321' (cid) as SQL_C_UTINYINT: 225 '4321' (cid) as SQL_C_SBIGINT: 4321 '4321' (cid) as SQL_C_UBIGINT: 4321 '4321' (cid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_BOOKMARK: 4321 '4321' (cid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '4321' (cid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: e1100000000000000000000000000000 '4321' (cid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_CHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_WCHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_SSHORT: 1 '1 2 3' (oidvector) as SQL_C_USHORT: 1 '1 2 3' (oidvector) as SQL_C_SLONG: 1 '1 2 3' (oidvector) as SQL_C_ULONG: 1 '1 2 3' (oidvector) as SQL_C_FLOAT: 1.000000 '1 2 3' (oidvector) as SQL_C_DOUBLE: 1.000000 '1 2 3' (oidvector) as SQL_C_BIT: 1 '1 2 3' (oidvector) as SQL_C_STINYINT: 1 '1 2 3' (oidvector) as SQL_C_UTINYINT: 1 '1 2 3' (oidvector) as SQL_C_SBIGINT: 1 '1 2 3' (oidvector) as SQL_C_UBIGINT: 1 '1 2 3' (oidvector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_BOOKMARK: 1 '1 2 3' (oidvector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3' (oidvector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3' (oidvector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_CHAR: bar 'bar' (xml) as SQL_C_WCHAR: bar 'bar' (xml) as SQL_C_SSHORT: 0 'bar' (xml) as SQL_C_USHORT: 0 'bar' (xml) as SQL_C_SLONG: 0 'bar' (xml) as SQL_C_ULONG: 0 'bar' (xml) as SQL_C_FLOAT: 0.000000 'bar' (xml) as SQL_C_DOUBLE: 0.000000 'bar' (xml) as SQL_C_BIT: 0 'bar' (xml) as SQL_C_STINYINT: 0 'bar' (xml) as SQL_C_UTINYINT: 0 'bar' (xml) as SQL_C_SBIGINT: 0 'bar' (xml) as SQL_C_UBIGINT: 0 'bar' (xml) as SQL_C_BINARY: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_BOOKMARK: 0 'bar' (xml) as SQL_C_VARBOOKMARK: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'bar' (xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'bar' (xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_CHAR: {bar} '{bar}' (_xml) as SQL_C_WCHAR: {bar} '{bar}' (_xml) as SQL_C_SSHORT: 0 '{bar}' (_xml) as SQL_C_USHORT: 0 '{bar}' (_xml) as SQL_C_SLONG: 0 '{bar}' (_xml) as SQL_C_ULONG: 0 '{bar}' (_xml) as SQL_C_FLOAT: 0.000000 '{bar}' (_xml) as SQL_C_DOUBLE: 0.000000 '{bar}' (_xml) as SQL_C_BIT: 0 '{bar}' (_xml) as SQL_C_STINYINT: 0 '{bar}' (_xml) as SQL_C_UTINYINT: 0 '{bar}' (_xml) as SQL_C_SBIGINT: 0 '{bar}' (_xml) as SQL_C_UBIGINT: 0 '{bar}' (_xml) as SQL_C_BINARY: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_BOOKMARK: 0 '{bar}' (_xml) as SQL_C_VARBOOKMARK: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{bar}' (_xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{bar}' (_xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_CHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_WCHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_SSHORT: 10 '10.0.0.1' (cidr) as SQL_C_USHORT: 10 '10.0.0.1' (cidr) as SQL_C_SLONG: 10 '10.0.0.1' (cidr) as SQL_C_ULONG: 10 '10.0.0.1' (cidr) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (cidr) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (cidr) as SQL_C_BIT: 10 '10.0.0.1' (cidr) as SQL_C_STINYINT: 10 '10.0.0.1' (cidr) as SQL_C_UTINYINT: 10 '10.0.0.1' (cidr) as SQL_C_SBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_UBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_BOOKMARK: 10 '10.0.0.1' (cidr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (cidr) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (cidr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_CHAR: 1.234 '1.234' (float4) as SQL_C_WCHAR: 1.234 '1.234' (float4) as SQL_C_SSHORT: 1 '1.234' (float4) as SQL_C_USHORT: 1 '1.234' (float4) as SQL_C_SLONG: 1 '1.234' (float4) as SQL_C_ULONG: 1 '1.234' (float4) as SQL_C_FLOAT: 1.234000 '1.234' (float4) as SQL_C_DOUBLE: 1.234000 '1.234' (float4) as SQL_C_BIT: 1 '1.234' (float4) as SQL_C_STINYINT: 1 '1.234' (float4) as SQL_C_UTINYINT: 1 '1.234' (float4) as SQL_C_SBIGINT: 1 '1.234' (float4) as SQL_C_UBIGINT: 1 '1.234' (float4) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_BOOKMARK: 1 '1.234' (float4) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.234' (float4) as SQL_C_NUMERIC: precision: 4 scale: 3 sign: 3 val: d2040000000000000000000000000000 '1.234' (float4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_CHAR: 1.23456789012 '1.23456789012' (float8) as SQL_C_WCHAR: 1.23456789012 '1.23456789012' (float8) as SQL_C_SSHORT: 1 '1.23456789012' (float8) as SQL_C_USHORT: 1 '1.23456789012' (float8) as SQL_C_SLONG: 1 '1.23456789012' (float8) as SQL_C_ULONG: 1 '1.23456789012' (float8) as SQL_C_FLOAT: 1.234568 '1.23456789012' (float8) as SQL_C_DOUBLE: 1.234568 '1.23456789012' (float8) as SQL_C_BIT: 1 '1.23456789012' (float8) as SQL_C_STINYINT: 1 '1.23456789012' (float8) as SQL_C_UTINYINT: 1 '1.23456789012' (float8) as SQL_C_SBIGINT: 1 '1.23456789012' (float8) as SQL_C_UBIGINT: 1 '1.23456789012' (float8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_BOOKMARK: 1 '1.23456789012' (float8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23456789012' (float8) as SQL_C_NUMERIC: precision: 12 scale: 11 sign: 11 val: 141a99be1c0000000000000000000000 '1.23456789012' (float8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_CHAR: foo 'foo' (unknown) as SQL_C_WCHAR: foo 'foo' (unknown) as SQL_C_SSHORT: 0 'foo' (unknown) as SQL_C_USHORT: 0 'foo' (unknown) as SQL_C_SLONG: 0 'foo' (unknown) as SQL_C_ULONG: 0 'foo' (unknown) as SQL_C_FLOAT: 0.000000 'foo' (unknown) as SQL_C_DOUBLE: 0.000000 'foo' (unknown) as SQL_C_BIT: 0 'foo' (unknown) as SQL_C_STINYINT: 0 'foo' (unknown) as SQL_C_UTINYINT: 0 'foo' (unknown) as SQL_C_SBIGINT: 0 'foo' (unknown) as SQL_C_UBIGINT: 0 'foo' (unknown) as SQL_C_BINARY: hex: 666F6F 'foo' (unknown) as SQL_C_BOOKMARK: 0 'foo' (unknown) as SQL_C_VARBOOKMARK: hex: 666F6F 'foo' (unknown) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foo' (unknown) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foo' (unknown) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_CHAR: $1.23 '1.23' (money) as SQL_C_WCHAR: $1.23 '1.23' (money) as SQL_C_SSHORT: 1 '1.23' (money) as SQL_C_USHORT: 1 '1.23' (money) as SQL_C_SLONG: 1 '1.23' (money) as SQL_C_ULONG: 1 '1.23' (money) as SQL_C_FLOAT: 1.230000 '1.23' (money) as SQL_C_DOUBLE: 1.230000 '1.23' (money) as SQL_C_BIT: 1 '1.23' (money) as SQL_C_STINYINT: 1 '1.23' (money) as SQL_C_UTINYINT: 1 '1.23' (money) as SQL_C_SBIGINT: 1 '1.23' (money) as SQL_C_UBIGINT: 1 '1.23' (money) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_BOOKMARK: 1 '1.23' (money) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23' (money) as SQL_C_NUMERIC: precision: 3 scale: 2 sign: 2 val: 7b000000000000000000000000000000 '1.23' (money) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_CHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_WCHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_SSHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_USHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SLONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_ULONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_FLOAT: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_DOUBLE: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_BIT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_STINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UTINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_BOOKMARK: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 08000000000000000000000000000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_CHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_WCHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_SSHORT: 10 '10.0.0.1' (inet) as SQL_C_USHORT: 10 '10.0.0.1' (inet) as SQL_C_SLONG: 10 '10.0.0.1' (inet) as SQL_C_ULONG: 10 '10.0.0.1' (inet) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (inet) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (inet) as SQL_C_BIT: 10 '10.0.0.1' (inet) as SQL_C_STINYINT: 10 '10.0.0.1' (inet) as SQL_C_UTINYINT: 10 '10.0.0.1' (inet) as SQL_C_SBIGINT: 10 '10.0.0.1' (inet) as SQL_C_UBIGINT: 10 '10.0.0.1' (inet) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_BOOKMARK: 10 '10.0.0.1' (inet) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (inet) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (inet) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_SSHORT: 0 '{foo, bar}' (_text) as SQL_C_USHORT: 0 '{foo, bar}' (_text) as SQL_C_SLONG: 0 '{foo, bar}' (_text) as SQL_C_ULONG: 0 '{foo, bar}' (_text) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_text) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_text) as SQL_C_BIT: 0 '{foo, bar}' (_text) as SQL_C_STINYINT: 0 '{foo, bar}' (_text) as SQL_C_UTINYINT: 0 '{foo, bar}' (_text) as SQL_C_SBIGINT: 0 '{foo, bar}' (_text) as SQL_C_UBIGINT: 0 '{foo, bar}' (_text) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_text) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_USHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_SLONG: 0 '{foo, bar}' (_bpchar) as SQL_C_ULONG: 0 '{foo, bar}' (_bpchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_BIT: 0 '{foo, bar}' (_bpchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_bpchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_varchar) as SQL_C_USHORT: 0 '{foo, bar}' (_varchar) as SQL_C_SLONG: 0 '{foo, bar}' (_varchar) as SQL_C_ULONG: 0 '{foo, bar}' (_varchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_varchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_varchar) as SQL_C_BIT: 0 '{foo, bar}' (_varchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_varchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_CHAR: foobar 'foobar' (bpchar) as SQL_C_WCHAR: foobar 'foobar' (bpchar) as SQL_C_SSHORT: 0 'foobar' (bpchar) as SQL_C_USHORT: 0 'foobar' (bpchar) as SQL_C_SLONG: 0 'foobar' (bpchar) as SQL_C_ULONG: 0 'foobar' (bpchar) as SQL_C_FLOAT: 0.000000 'foobar' (bpchar) as SQL_C_DOUBLE: 0.000000 'foobar' (bpchar) as SQL_C_BIT: 0 'foobar' (bpchar) as SQL_C_STINYINT: 0 'foobar' (bpchar) as SQL_C_UTINYINT: 0 'foobar' (bpchar) as SQL_C_SBIGINT: 0 'foobar' (bpchar) as SQL_C_UBIGINT: 0 'foobar' (bpchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_BOOKMARK: 0 'foobar' (bpchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_CHAR: foobar 'foobar' (varchar) as SQL_C_WCHAR: foobar 'foobar' (varchar) as SQL_C_SSHORT: 0 'foobar' (varchar) as SQL_C_USHORT: 0 'foobar' (varchar) as SQL_C_SLONG: 0 'foobar' (varchar) as SQL_C_ULONG: 0 'foobar' (varchar) as SQL_C_FLOAT: 0.000000 'foobar' (varchar) as SQL_C_DOUBLE: 0.000000 'foobar' (varchar) as SQL_C_BIT: 0 'foobar' (varchar) as SQL_C_STINYINT: 0 'foobar' (varchar) as SQL_C_UTINYINT: 0 'foobar' (varchar) as SQL_C_SBIGINT: 0 'foobar' (varchar) as SQL_C_UBIGINT: 0 'foobar' (varchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (varchar) as SQL_C_BOOKMARK: 0 'foobar' (varchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_CHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_WCHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_SSHORT: 2011 '2011-02-13' (date) as SQL_C_USHORT: 2011 '2011-02-13' (date) as SQL_C_SLONG: 2011 '2011-02-13' (date) as SQL_C_ULONG: 2011 '2011-02-13' (date) as SQL_C_FLOAT: 2011.000000 '2011-02-13' (date) as SQL_C_DOUBLE: 2011.000000 '2011-02-13' (date) as SQL_C_BIT: 219 '2011-02-13' (date) as SQL_C_STINYINT: -37 '2011-02-13' (date) as SQL_C_UTINYINT: 219 '2011-02-13' (date) as SQL_C_SBIGINT: 2011 '2011-02-13' (date) as SQL_C_UBIGINT: 2011 '2011-02-13' (date) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_BOOKMARK: 2011 '2011-02-13' (date) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '2011-02-13' (date) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-13' (date) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_CHAR: 13:23:34 '13:23:34' (time) as SQL_C_WCHAR: 13:23:34 '13:23:34' (time) as SQL_C_SSHORT: 13 '13:23:34' (time) as SQL_C_USHORT: 13 '13:23:34' (time) as SQL_C_SLONG: 13 '13:23:34' (time) as SQL_C_ULONG: 13 '13:23:34' (time) as SQL_C_FLOAT: 13.000000 '13:23:34' (time) as SQL_C_DOUBLE: 13.000000 '13:23:34' (time) as SQL_C_BIT: 13 '13:23:34' (time) as SQL_C_STINYINT: 13 '13:23:34' (time) as SQL_C_UTINYINT: 13 '13:23:34' (time) as SQL_C_SBIGINT: 13 '13:23:34' (time) as SQL_C_UBIGINT: 13 '13:23:34' (time) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_BOOKMARK: 13 '13:23:34' (time) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_TYPE_TIME: h: 13 m: 23 s: 34 '13:23:34' (time) as SQL_C_NUMERIC: precision: 2 scale: 0 sign: 0 val: 0d000000000000000000000000000000 '13:23:34' (time) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_WCHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_SSHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_USHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_SLONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_ULONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_FLOAT: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_DOUBLE: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_BIT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_STINYINT: -37 '2011-02-15 15:49:18' (timestamp) as SQL_C_UTINYINT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_SBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_UBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_BOOKMARK: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_TYPE_TIME: h: 15 m: 49 s: 18 '2011-02-15 15:49:18' (timestamp) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_CHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_WCHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SSHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_USHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SLONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_ULONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_FLOAT: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DOUBLE: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BIT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_STINYINT: -37 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UTINYINT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BOOKMARK: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TYPE_TIME: h: 6 m: 49 s: 18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_CHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_WCHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SSHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_USHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SLONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_ULONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_FLOAT: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_DOUBLE: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BIT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_STINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UTINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_BOOKMARK: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 09000000000000000000000000000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MONTH: interval sign: 0 year: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 9 month: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_CHAR: 1 '1' (bit) as SQL_C_WCHAR: 1 '1' (bit) as SQL_C_SSHORT: 1 '1' (bit) as SQL_C_USHORT: 1 '1' (bit) as SQL_C_SLONG: 1 '1' (bit) as SQL_C_ULONG: 1 '1' (bit) as SQL_C_FLOAT: 1.000000 '1' (bit) as SQL_C_DOUBLE: 1.000000 '1' (bit) as SQL_C_BIT: 1 '1' (bit) as SQL_C_STINYINT: 1 '1' (bit) as SQL_C_UTINYINT: 1 '1' (bit) as SQL_C_SBIGINT: 1 '1' (bit) as SQL_C_UBIGINT: 1 '1' (bit) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_BOOKMARK: 1 '1' (bit) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1' (bit) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1' (bit) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_CHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_WCHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_SSHORT: 1234 '1234.567890' (numeric) as SQL_C_USHORT: 1234 '1234.567890' (numeric) as SQL_C_SLONG: 1234 '1234.567890' (numeric) as SQL_C_ULONG: 1234 '1234.567890' (numeric) as SQL_C_FLOAT: 1234.567871 '1234.567890' (numeric) as SQL_C_DOUBLE: 1234.567890 '1234.567890' (numeric) as SQL_C_BIT: 210 '1234.567890' (numeric) as SQL_C_STINYINT: -46 '1234.567890' (numeric) as SQL_C_UTINYINT: 210 '1234.567890' (numeric) as SQL_C_SBIGINT: 1234 '1234.567890' (numeric) as SQL_C_UBIGINT: 1234 '1234.567890' (numeric) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_BOOKMARK: 1234 '1234.567890' (numeric) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234.567890' (numeric) as SQL_C_NUMERIC: precision: 10 scale: 6 sign: 6 val: d2029649000000000000000000000000 '1234.567890' (numeric) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_CHAR: foocur 'foocur' (refcursor) as SQL_C_WCHAR: foocur 'foocur' (refcursor) as SQL_C_SSHORT: 0 'foocur' (refcursor) as SQL_C_USHORT: 0 'foocur' (refcursor) as SQL_C_SLONG: 0 'foocur' (refcursor) as SQL_C_ULONG: 0 'foocur' (refcursor) as SQL_C_FLOAT: 0.000000 'foocur' (refcursor) as SQL_C_DOUBLE: 0.000000 'foocur' (refcursor) as SQL_C_BIT: 0 'foocur' (refcursor) as SQL_C_STINYINT: 0 'foocur' (refcursor) as SQL_C_UTINYINT: 0 'foocur' (refcursor) as SQL_C_SBIGINT: 0 'foocur' (refcursor) as SQL_C_UBIGINT: 0 'foocur' (refcursor) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_BOOKMARK: 0 'foocur' (refcursor) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foocur' (refcursor) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foocur' (refcursor) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 Executed: SET bytea_output=hex '\x464F4F' (bytea) as SQL_C_CHAR: 464f4f '\x464F4F' (bytea) as SQL_C_WCHAR: 464f4f '543c5e21-435a-440b-943c-64af1ad571f1' (text) as SQL_C_GUID: d1: 543C5E21 d2: 435A d3: 440B d4: 943C64AF1AD571F1 '2011-02-13' (date) as SQL_C_DATE: y: 2011 m: 2 d: 13 '2011-02-13' (date) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 13 h: 0 m: 0 s: 0 f: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_DATE: y: 2011 m: 2 d: 15 '2011-02-15 15:49:18' (timestamp) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 15 h: 15 m: 49 s: 18 f: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DATE: y: 2011 m: 2 d: 16 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 16 h: 6 m: 49 s: 18 f: 0 '' (text) as SQL_C_TYPE_DATE: y: 0 m: 0 d: 0 '' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '' (text) as SQL_C_TYPE_TIMESTAMP: y: 0 m: 0 d: 0 h: 0 m: 0 s: 0 f: 0 'foobar' (text) as SQL_C_CHAR: foob (truncated) 'foobar' (text) as SQL_C_CHAR: fooba (truncated) 'foobar' (text) as SQL_C_CHAR: foobar 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: foobar '' (text) as SQL_C_CHAR: '' (text) as SQL_C_WCHAR: \ FF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF (truncated) '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:1 (truncated) '2011-02-15 15:49:18 BC' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 (truncated) 'NaN' (float4) as SQL_C_FLOAT: nan 'Infinity' (float4) as SQL_C_FLOAT: inf '-Infinity' (float4) as SQL_C_FLOAT: -inf 'NaN' (float8) as SQL_C_FLOAT: nan 'Infinity' (float8) as SQL_C_FLOAT: inf '-Infinity' (float8) as SQL_C_FLOAT: -inf 'NaN' (float4) as SQL_C_DOUBLE: nan 'Infinity' (float4) as SQL_C_DOUBLE: inf '-Infinity' (float4) as SQL_C_DOUBLE: -inf 'NaN' (float8) as SQL_C_DOUBLE: nan 'Infinity' (float8) as SQL_C_DOUBLE: inf '-Infinity' (float8) as SQL_C_DOUBLE: -inf disconnecting psqlodbc-REL-16_00_0005/test/expected/result-conversions_2.out000066400000000000000000002441221462406103600241210ustar00rootroot00000000000000connected Executed: SET intervalstyle=postgres Executed: SET bytea_output=escape Executed: SET lc_monetary='C' 'true' (boolean) as SQL_C_CHAR: 1 'true' (boolean) as SQL_C_WCHAR: 1 'true' (boolean) as SQL_C_SSHORT: 1 'true' (boolean) as SQL_C_USHORT: 1 'true' (boolean) as SQL_C_SLONG: 1 'true' (boolean) as SQL_C_ULONG: 1 'true' (boolean) as SQL_C_FLOAT: 1.000000 'true' (boolean) as SQL_C_DOUBLE: 1.000000 'true' (boolean) as SQL_C_BIT: 1 'true' (boolean) as SQL_C_STINYINT: 1 'true' (boolean) as SQL_C_UTINYINT: 1 'true' (boolean) as SQL_C_SBIGINT: 1 'true' (boolean) as SQL_C_UBIGINT: 1 'true' (boolean) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_BOOKMARK: 1 'true' (boolean) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'true' (boolean) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 'true' (boolean) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_CHAR: 464F4F '\x464F4F' (bytea) as SQL_C_WCHAR: 464F4F '\x464F4F' (bytea) as SQL_C_SSHORT: 0 '\x464F4F' (bytea) as SQL_C_USHORT: 0 '\x464F4F' (bytea) as SQL_C_SLONG: 0 '\x464F4F' (bytea) as SQL_C_ULONG: 0 '\x464F4F' (bytea) as SQL_C_FLOAT: 0.000000 '\x464F4F' (bytea) as SQL_C_DOUBLE: 0.000000 '\x464F4F' (bytea) as SQL_C_BIT: 0 '\x464F4F' (bytea) as SQL_C_STINYINT: 0 '\x464F4F' (bytea) as SQL_C_UTINYINT: 0 '\x464F4F' (bytea) as SQL_C_SBIGINT: 0 '\x464F4F' (bytea) as SQL_C_UBIGINT: 0 '\x464F4F' (bytea) as SQL_C_BINARY: hex: 464F4F '\x464F4F' (bytea) as SQL_C_BOOKMARK: 0 '\x464F4F' (bytea) as SQL_C_VARBOOKMARK: hex: 464F4F '\x464F4F' (bytea) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '\x464F4F' (bytea) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '\x464F4F' (bytea) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_CHAR: x 'x' (char) as SQL_C_WCHAR: x 'x' (char) as SQL_C_SSHORT: 0 'x' (char) as SQL_C_USHORT: 0 'x' (char) as SQL_C_SLONG: 0 'x' (char) as SQL_C_ULONG: 0 'x' (char) as SQL_C_FLOAT: 0.000000 'x' (char) as SQL_C_DOUBLE: 0.000000 'x' (char) as SQL_C_BIT: 0 'x' (char) as SQL_C_STINYINT: 0 'x' (char) as SQL_C_UTINYINT: 0 'x' (char) as SQL_C_SBIGINT: 0 'x' (char) as SQL_C_UBIGINT: 0 'x' (char) as SQL_C_BINARY: hex: 78 'x' (char) as SQL_C_BOOKMARK: 0 'x' (char) as SQL_C_VARBOOKMARK: hex: 78 'x' (char) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'x' (char) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'x' (char) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_CHAR: namedata 'namedata' (name) as SQL_C_WCHAR: namedata 'namedata' (name) as SQL_C_SSHORT: 0 'namedata' (name) as SQL_C_USHORT: 0 'namedata' (name) as SQL_C_SLONG: 0 'namedata' (name) as SQL_C_ULONG: 0 'namedata' (name) as SQL_C_FLOAT: 0.000000 'namedata' (name) as SQL_C_DOUBLE: 0.000000 'namedata' (name) as SQL_C_BIT: 0 'namedata' (name) as SQL_C_STINYINT: 0 'namedata' (name) as SQL_C_UTINYINT: 0 'namedata' (name) as SQL_C_SBIGINT: 0 'namedata' (name) as SQL_C_UBIGINT: 0 'namedata' (name) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_BOOKMARK: 0 'namedata' (name) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'namedata' (name) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'namedata' (name) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_CHAR: 1234567890 '1234567890' (int8) as SQL_C_WCHAR: 1234567890 '1234567890' (int8) as SQL_C_SSHORT: 722 '1234567890' (int8) as SQL_C_USHORT: 722 '1234567890' (int8) as SQL_C_SLONG: 1234567890 '1234567890' (int8) as SQL_C_ULONG: 1234567890 '1234567890' (int8) as SQL_C_FLOAT: 1234567936.000000 '1234567890' (int8) as SQL_C_DOUBLE: 1234567890.000000 '1234567890' (int8) as SQL_C_BIT: 210 '1234567890' (int8) as SQL_C_STINYINT: -46 '1234567890' (int8) as SQL_C_UTINYINT: 210 '1234567890' (int8) as SQL_C_SBIGINT: 1234567890 '1234567890' (int8) as SQL_C_UBIGINT: 1234567890 '1234567890' (int8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_BOOKMARK: 1234567890 '1234567890' (int8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567890' (int8) as SQL_C_NUMERIC: precision: 10 scale: 0 sign: 0 val: d2029649000000000000000000000000 '1234567890' (int8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_CHAR: 12345 '12345' (int2) as SQL_C_WCHAR: 12345 '12345' (int2) as SQL_C_SSHORT: 12345 '12345' (int2) as SQL_C_USHORT: 12345 '12345' (int2) as SQL_C_SLONG: 12345 '12345' (int2) as SQL_C_ULONG: 12345 '12345' (int2) as SQL_C_FLOAT: 12345.000000 '12345' (int2) as SQL_C_DOUBLE: 12345.000000 '12345' (int2) as SQL_C_BIT: 57 '12345' (int2) as SQL_C_STINYINT: 57 '12345' (int2) as SQL_C_UTINYINT: 57 '12345' (int2) as SQL_C_SBIGINT: 12345 '12345' (int2) as SQL_C_UBIGINT: 12345 '12345' (int2) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_BOOKMARK: 12345 '12345' (int2) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '12345' (int2) as SQL_C_NUMERIC: precision: 5 scale: 0 sign: 0 val: 39300000000000000000000000000000 '12345' (int2) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_CHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_WCHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_SSHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_USHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SLONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_ULONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_FLOAT: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_DOUBLE: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_BIT: 1 '1 2 3 4 5' (int2vector) as SQL_C_STINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UTINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_BOOKMARK: 1 '1 2 3 4 5' (int2vector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3 4 5' (int2vector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3 4 5' (int2vector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_CHAR: 1234567 '1234567' (int4) as SQL_C_WCHAR: 1234567 '1234567' (int4) as SQL_C_SSHORT: -10617 '1234567' (int4) as SQL_C_USHORT: 54919 '1234567' (int4) as SQL_C_SLONG: 1234567 '1234567' (int4) as SQL_C_ULONG: 1234567 '1234567' (int4) as SQL_C_FLOAT: 1234567.000000 '1234567' (int4) as SQL_C_DOUBLE: 1234567.000000 '1234567' (int4) as SQL_C_BIT: 135 '1234567' (int4) as SQL_C_STINYINT: -121 '1234567' (int4) as SQL_C_UTINYINT: 135 '1234567' (int4) as SQL_C_SBIGINT: 1234567 '1234567' (int4) as SQL_C_UBIGINT: 1234567 '1234567' (int4) as SQL_C_BINARY: hex: 87D61200 '1234567' (int4) as SQL_C_BOOKMARK: 1234567 '1234567' (int4) as SQL_C_VARBOOKMARK: hex: 87D61200 '1234567' (int4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567' (int4) as SQL_C_NUMERIC: precision: 7 scale: 0 sign: 0 val: 87d61200000000000000000000000000 '1234567' (int4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_CHAR: int4pl 'int4pl' (regproc) as SQL_C_WCHAR: int4pl 'int4pl' (regproc) as SQL_C_SSHORT: 0 'int4pl' (regproc) as SQL_C_USHORT: 0 'int4pl' (regproc) as SQL_C_SLONG: 0 'int4pl' (regproc) as SQL_C_ULONG: 0 'int4pl' (regproc) as SQL_C_FLOAT: 0.000000 'int4pl' (regproc) as SQL_C_DOUBLE: 0.000000 'int4pl' (regproc) as SQL_C_BIT: 0 'int4pl' (regproc) as SQL_C_STINYINT: 0 'int4pl' (regproc) as SQL_C_UTINYINT: 0 'int4pl' (regproc) as SQL_C_SBIGINT: 0 'int4pl' (regproc) as SQL_C_UBIGINT: 0 'int4pl' (regproc) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_BOOKMARK: 0 'int4pl' (regproc) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'int4pl' (regproc) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'int4pl' (regproc) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_CHAR: textdata 'textdata' (text) as SQL_C_WCHAR: textdata 'textdata' (text) as SQL_C_SSHORT: 0 'textdata' (text) as SQL_C_USHORT: 0 'textdata' (text) as SQL_C_SLONG: 0 'textdata' (text) as SQL_C_ULONG: 0 'textdata' (text) as SQL_C_FLOAT: 0.000000 'textdata' (text) as SQL_C_DOUBLE: 0.000000 'textdata' (text) as SQL_C_BIT: 0 'textdata' (text) as SQL_C_STINYINT: 0 'textdata' (text) as SQL_C_UTINYINT: 0 'textdata' (text) as SQL_C_SBIGINT: 0 'textdata' (text) as SQL_C_UBIGINT: 0 'textdata' (text) as SQL_C_BINARY: hex: 7465787464617461 'textdata' (text) as SQL_C_BOOKMARK: 0 'textdata' (text) as SQL_C_VARBOOKMARK: hex: 7465787464617461 'textdata' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'textdata' (text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'textdata' (text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_CHAR: (1,2) '(1,2)' (tid) as SQL_C_WCHAR: (1,2) '(1,2)' (tid) as SQL_C_SSHORT: 0 '(1,2)' (tid) as SQL_C_USHORT: 0 '(1,2)' (tid) as SQL_C_SLONG: 0 '(1,2)' (tid) as SQL_C_ULONG: 0 '(1,2)' (tid) as SQL_C_FLOAT: 0.000000 '(1,2)' (tid) as SQL_C_DOUBLE: 0.000000 '(1,2)' (tid) as SQL_C_BIT: 0 '(1,2)' (tid) as SQL_C_STINYINT: 0 '(1,2)' (tid) as SQL_C_UTINYINT: 0 '(1,2)' (tid) as SQL_C_SBIGINT: 0 '(1,2)' (tid) as SQL_C_UBIGINT: 0 '(1,2)' (tid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_BOOKMARK: 0 '(1,2)' (tid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '(1,2)' (tid) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '(1,2)' (tid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_CHAR: 1234 '1234' (xid) as SQL_C_WCHAR: 1234 '1234' (xid) as SQL_C_SSHORT: 1234 '1234' (xid) as SQL_C_USHORT: 1234 '1234' (xid) as SQL_C_SLONG: 1234 '1234' (xid) as SQL_C_ULONG: 1234 '1234' (xid) as SQL_C_FLOAT: 1234.000000 '1234' (xid) as SQL_C_DOUBLE: 1234.000000 '1234' (xid) as SQL_C_BIT: 210 '1234' (xid) as SQL_C_STINYINT: -46 '1234' (xid) as SQL_C_UTINYINT: 210 '1234' (xid) as SQL_C_SBIGINT: 1234 '1234' (xid) as SQL_C_UBIGINT: 1234 '1234' (xid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_BOOKMARK: 1234 '1234' (xid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234' (xid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: d2040000000000000000000000000000 '1234' (xid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_CHAR: 4321 '4321' (cid) as SQL_C_WCHAR: 4321 '4321' (cid) as SQL_C_SSHORT: 4321 '4321' (cid) as SQL_C_USHORT: 4321 '4321' (cid) as SQL_C_SLONG: 4321 '4321' (cid) as SQL_C_ULONG: 4321 '4321' (cid) as SQL_C_FLOAT: 4321.000000 '4321' (cid) as SQL_C_DOUBLE: 4321.000000 '4321' (cid) as SQL_C_BIT: 225 '4321' (cid) as SQL_C_STINYINT: -31 '4321' (cid) as SQL_C_UTINYINT: 225 '4321' (cid) as SQL_C_SBIGINT: 4321 '4321' (cid) as SQL_C_UBIGINT: 4321 '4321' (cid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_BOOKMARK: 4321 '4321' (cid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '4321' (cid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: e1100000000000000000000000000000 '4321' (cid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_CHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_WCHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_SSHORT: 1 '1 2 3' (oidvector) as SQL_C_USHORT: 1 '1 2 3' (oidvector) as SQL_C_SLONG: 1 '1 2 3' (oidvector) as SQL_C_ULONG: 1 '1 2 3' (oidvector) as SQL_C_FLOAT: 1.000000 '1 2 3' (oidvector) as SQL_C_DOUBLE: 1.000000 '1 2 3' (oidvector) as SQL_C_BIT: 1 '1 2 3' (oidvector) as SQL_C_STINYINT: 1 '1 2 3' (oidvector) as SQL_C_UTINYINT: 1 '1 2 3' (oidvector) as SQL_C_SBIGINT: 1 '1 2 3' (oidvector) as SQL_C_UBIGINT: 1 '1 2 3' (oidvector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_BOOKMARK: 1 '1 2 3' (oidvector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3' (oidvector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3' (oidvector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_CHAR: bar 'bar' (xml) as SQL_C_WCHAR: bar 'bar' (xml) as SQL_C_SSHORT: 0 'bar' (xml) as SQL_C_USHORT: 0 'bar' (xml) as SQL_C_SLONG: 0 'bar' (xml) as SQL_C_ULONG: 0 'bar' (xml) as SQL_C_FLOAT: 0.000000 'bar' (xml) as SQL_C_DOUBLE: 0.000000 'bar' (xml) as SQL_C_BIT: 0 'bar' (xml) as SQL_C_STINYINT: 0 'bar' (xml) as SQL_C_UTINYINT: 0 'bar' (xml) as SQL_C_SBIGINT: 0 'bar' (xml) as SQL_C_UBIGINT: 0 'bar' (xml) as SQL_C_BINARY: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_BOOKMARK: 0 'bar' (xml) as SQL_C_VARBOOKMARK: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'bar' (xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'bar' (xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_CHAR: {bar} '{bar}' (_xml) as SQL_C_WCHAR: {bar} '{bar}' (_xml) as SQL_C_SSHORT: 0 '{bar}' (_xml) as SQL_C_USHORT: 0 '{bar}' (_xml) as SQL_C_SLONG: 0 '{bar}' (_xml) as SQL_C_ULONG: 0 '{bar}' (_xml) as SQL_C_FLOAT: 0.000000 '{bar}' (_xml) as SQL_C_DOUBLE: 0.000000 '{bar}' (_xml) as SQL_C_BIT: 0 '{bar}' (_xml) as SQL_C_STINYINT: 0 '{bar}' (_xml) as SQL_C_UTINYINT: 0 '{bar}' (_xml) as SQL_C_SBIGINT: 0 '{bar}' (_xml) as SQL_C_UBIGINT: 0 '{bar}' (_xml) as SQL_C_BINARY: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_BOOKMARK: 0 '{bar}' (_xml) as SQL_C_VARBOOKMARK: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{bar}' (_xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{bar}' (_xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_CHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_WCHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_SSHORT: 10 '10.0.0.1' (cidr) as SQL_C_USHORT: 10 '10.0.0.1' (cidr) as SQL_C_SLONG: 10 '10.0.0.1' (cidr) as SQL_C_ULONG: 10 '10.0.0.1' (cidr) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (cidr) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (cidr) as SQL_C_BIT: 10 '10.0.0.1' (cidr) as SQL_C_STINYINT: 10 '10.0.0.1' (cidr) as SQL_C_UTINYINT: 10 '10.0.0.1' (cidr) as SQL_C_SBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_UBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_BOOKMARK: 10 '10.0.0.1' (cidr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (cidr) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (cidr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_CHAR: 1.234 '1.234' (float4) as SQL_C_WCHAR: 1.234 '1.234' (float4) as SQL_C_SSHORT: 1 '1.234' (float4) as SQL_C_USHORT: 1 '1.234' (float4) as SQL_C_SLONG: 1 '1.234' (float4) as SQL_C_ULONG: 1 '1.234' (float4) as SQL_C_FLOAT: 1.234000 '1.234' (float4) as SQL_C_DOUBLE: 1.234000 '1.234' (float4) as SQL_C_BIT: 1 '1.234' (float4) as SQL_C_STINYINT: 1 '1.234' (float4) as SQL_C_UTINYINT: 1 '1.234' (float4) as SQL_C_SBIGINT: 1 '1.234' (float4) as SQL_C_UBIGINT: 1 '1.234' (float4) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_BOOKMARK: 1 '1.234' (float4) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.234' (float4) as SQL_C_NUMERIC: precision: 4 scale: 3 sign: 3 val: d2040000000000000000000000000000 '1.234' (float4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_CHAR: 1.2345678901199999 '1.23456789012' (float8) as SQL_C_WCHAR: 1.2345678901199999 '1.23456789012' (float8) as SQL_C_SSHORT: 1 '1.23456789012' (float8) as SQL_C_USHORT: 1 '1.23456789012' (float8) as SQL_C_SLONG: 1 '1.23456789012' (float8) as SQL_C_ULONG: 1 '1.23456789012' (float8) as SQL_C_FLOAT: 1.234568 '1.23456789012' (float8) as SQL_C_DOUBLE: 1.234568 '1.23456789012' (float8) as SQL_C_BIT: 1 '1.23456789012' (float8) as SQL_C_STINYINT: 1 '1.23456789012' (float8) as SQL_C_UTINYINT: 1 '1.23456789012' (float8) as SQL_C_SBIGINT: 1 '1.23456789012' (float8) as SQL_C_UBIGINT: 1 '1.23456789012' (float8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_BOOKMARK: 1 '1.23456789012' (float8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23456789012' (float8) as SQL_C_NUMERIC: precision: 17 scale: 16 sign: 16 val: 7fc46a5d54dc2b000000000000000000 '1.23456789012' (float8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_CHAR: foo 'foo' (unknown) as SQL_C_WCHAR: foo 'foo' (unknown) as SQL_C_SSHORT: 0 'foo' (unknown) as SQL_C_USHORT: 0 'foo' (unknown) as SQL_C_SLONG: 0 'foo' (unknown) as SQL_C_ULONG: 0 'foo' (unknown) as SQL_C_FLOAT: 0.000000 'foo' (unknown) as SQL_C_DOUBLE: 0.000000 'foo' (unknown) as SQL_C_BIT: 0 'foo' (unknown) as SQL_C_STINYINT: 0 'foo' (unknown) as SQL_C_UTINYINT: 0 'foo' (unknown) as SQL_C_SBIGINT: 0 'foo' (unknown) as SQL_C_UBIGINT: 0 'foo' (unknown) as SQL_C_BINARY: hex: 666F6F 'foo' (unknown) as SQL_C_BOOKMARK: 0 'foo' (unknown) as SQL_C_VARBOOKMARK: hex: 666F6F 'foo' (unknown) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foo' (unknown) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foo' (unknown) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_CHAR: $1.23 '1.23' (money) as SQL_C_WCHAR: $1.23 '1.23' (money) as SQL_C_SSHORT: 1 '1.23' (money) as SQL_C_USHORT: 1 '1.23' (money) as SQL_C_SLONG: 1 '1.23' (money) as SQL_C_ULONG: 1 '1.23' (money) as SQL_C_FLOAT: 1.230000 '1.23' (money) as SQL_C_DOUBLE: 1.230000 '1.23' (money) as SQL_C_BIT: 1 '1.23' (money) as SQL_C_STINYINT: 1 '1.23' (money) as SQL_C_UTINYINT: 1 '1.23' (money) as SQL_C_SBIGINT: 1 '1.23' (money) as SQL_C_UBIGINT: 1 '1.23' (money) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_BOOKMARK: 1 '1.23' (money) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23' (money) as SQL_C_NUMERIC: precision: 3 scale: 2 sign: 2 val: 7b000000000000000000000000000000 '1.23' (money) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_CHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_WCHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_SSHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_USHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SLONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_ULONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_FLOAT: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_DOUBLE: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_BIT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_STINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UTINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_BOOKMARK: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 08000000000000000000000000000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_CHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_WCHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_SSHORT: 10 '10.0.0.1' (inet) as SQL_C_USHORT: 10 '10.0.0.1' (inet) as SQL_C_SLONG: 10 '10.0.0.1' (inet) as SQL_C_ULONG: 10 '10.0.0.1' (inet) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (inet) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (inet) as SQL_C_BIT: 10 '10.0.0.1' (inet) as SQL_C_STINYINT: 10 '10.0.0.1' (inet) as SQL_C_UTINYINT: 10 '10.0.0.1' (inet) as SQL_C_SBIGINT: 10 '10.0.0.1' (inet) as SQL_C_UBIGINT: 10 '10.0.0.1' (inet) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_BOOKMARK: 10 '10.0.0.1' (inet) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (inet) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (inet) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_SSHORT: 0 '{foo, bar}' (_text) as SQL_C_USHORT: 0 '{foo, bar}' (_text) as SQL_C_SLONG: 0 '{foo, bar}' (_text) as SQL_C_ULONG: 0 '{foo, bar}' (_text) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_text) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_text) as SQL_C_BIT: 0 '{foo, bar}' (_text) as SQL_C_STINYINT: 0 '{foo, bar}' (_text) as SQL_C_UTINYINT: 0 '{foo, bar}' (_text) as SQL_C_SBIGINT: 0 '{foo, bar}' (_text) as SQL_C_UBIGINT: 0 '{foo, bar}' (_text) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_text) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_USHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_SLONG: 0 '{foo, bar}' (_bpchar) as SQL_C_ULONG: 0 '{foo, bar}' (_bpchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_BIT: 0 '{foo, bar}' (_bpchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_bpchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_varchar) as SQL_C_USHORT: 0 '{foo, bar}' (_varchar) as SQL_C_SLONG: 0 '{foo, bar}' (_varchar) as SQL_C_ULONG: 0 '{foo, bar}' (_varchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_varchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_varchar) as SQL_C_BIT: 0 '{foo, bar}' (_varchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_varchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_CHAR: foobar 'foobar' (bpchar) as SQL_C_WCHAR: foobar 'foobar' (bpchar) as SQL_C_SSHORT: 0 'foobar' (bpchar) as SQL_C_USHORT: 0 'foobar' (bpchar) as SQL_C_SLONG: 0 'foobar' (bpchar) as SQL_C_ULONG: 0 'foobar' (bpchar) as SQL_C_FLOAT: 0.000000 'foobar' (bpchar) as SQL_C_DOUBLE: 0.000000 'foobar' (bpchar) as SQL_C_BIT: 0 'foobar' (bpchar) as SQL_C_STINYINT: 0 'foobar' (bpchar) as SQL_C_UTINYINT: 0 'foobar' (bpchar) as SQL_C_SBIGINT: 0 'foobar' (bpchar) as SQL_C_UBIGINT: 0 'foobar' (bpchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_BOOKMARK: 0 'foobar' (bpchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_CHAR: foobar 'foobar' (varchar) as SQL_C_WCHAR: foobar 'foobar' (varchar) as SQL_C_SSHORT: 0 'foobar' (varchar) as SQL_C_USHORT: 0 'foobar' (varchar) as SQL_C_SLONG: 0 'foobar' (varchar) as SQL_C_ULONG: 0 'foobar' (varchar) as SQL_C_FLOAT: 0.000000 'foobar' (varchar) as SQL_C_DOUBLE: 0.000000 'foobar' (varchar) as SQL_C_BIT: 0 'foobar' (varchar) as SQL_C_STINYINT: 0 'foobar' (varchar) as SQL_C_UTINYINT: 0 'foobar' (varchar) as SQL_C_SBIGINT: 0 'foobar' (varchar) as SQL_C_UBIGINT: 0 'foobar' (varchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (varchar) as SQL_C_BOOKMARK: 0 'foobar' (varchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_CHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_WCHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_SSHORT: 2011 '2011-02-13' (date) as SQL_C_USHORT: 2011 '2011-02-13' (date) as SQL_C_SLONG: 2011 '2011-02-13' (date) as SQL_C_ULONG: 2011 '2011-02-13' (date) as SQL_C_FLOAT: 2011.000000 '2011-02-13' (date) as SQL_C_DOUBLE: 2011.000000 '2011-02-13' (date) as SQL_C_BIT: 219 '2011-02-13' (date) as SQL_C_STINYINT: -37 '2011-02-13' (date) as SQL_C_UTINYINT: 219 '2011-02-13' (date) as SQL_C_SBIGINT: 2011 '2011-02-13' (date) as SQL_C_UBIGINT: 2011 '2011-02-13' (date) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_BOOKMARK: 2011 '2011-02-13' (date) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '2011-02-13' (date) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-13' (date) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_CHAR: 13:23:34 '13:23:34' (time) as SQL_C_WCHAR: 13:23:34 '13:23:34' (time) as SQL_C_SSHORT: 13 '13:23:34' (time) as SQL_C_USHORT: 13 '13:23:34' (time) as SQL_C_SLONG: 13 '13:23:34' (time) as SQL_C_ULONG: 13 '13:23:34' (time) as SQL_C_FLOAT: 13.000000 '13:23:34' (time) as SQL_C_DOUBLE: 13.000000 '13:23:34' (time) as SQL_C_BIT: 13 '13:23:34' (time) as SQL_C_STINYINT: 13 '13:23:34' (time) as SQL_C_UTINYINT: 13 '13:23:34' (time) as SQL_C_SBIGINT: 13 '13:23:34' (time) as SQL_C_UBIGINT: 13 '13:23:34' (time) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_BOOKMARK: 13 '13:23:34' (time) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_TYPE_TIME: h: 13 m: 23 s: 34 '13:23:34' (time) as SQL_C_NUMERIC: precision: 2 scale: 0 sign: 0 val: 0d000000000000000000000000000000 '13:23:34' (time) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_WCHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_SSHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_USHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_SLONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_ULONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_FLOAT: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_DOUBLE: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_BIT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_STINYINT: -37 '2011-02-15 15:49:18' (timestamp) as SQL_C_UTINYINT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_SBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_UBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_BOOKMARK: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_TYPE_TIME: h: 15 m: 49 s: 18 '2011-02-15 15:49:18' (timestamp) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_CHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_WCHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SSHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_USHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SLONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_ULONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_FLOAT: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DOUBLE: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BIT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_STINYINT: -37 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UTINYINT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BOOKMARK: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TYPE_TIME: h: 6 m: 49 s: 18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_CHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_WCHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SSHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_USHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SLONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_ULONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_FLOAT: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_DOUBLE: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BIT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_STINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UTINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_BOOKMARK: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 09000000000000000000000000000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MONTH: interval sign: 0 year: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 9 month: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_CHAR: 1 '1' (bit) as SQL_C_WCHAR: 1 '1' (bit) as SQL_C_SSHORT: 1 '1' (bit) as SQL_C_USHORT: 1 '1' (bit) as SQL_C_SLONG: 1 '1' (bit) as SQL_C_ULONG: 1 '1' (bit) as SQL_C_FLOAT: 1.000000 '1' (bit) as SQL_C_DOUBLE: 1.000000 '1' (bit) as SQL_C_BIT: 1 '1' (bit) as SQL_C_STINYINT: 1 '1' (bit) as SQL_C_UTINYINT: 1 '1' (bit) as SQL_C_SBIGINT: 1 '1' (bit) as SQL_C_UBIGINT: 1 '1' (bit) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_BOOKMARK: 1 '1' (bit) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1' (bit) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1' (bit) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_CHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_WCHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_SSHORT: 1234 '1234.567890' (numeric) as SQL_C_USHORT: 1234 '1234.567890' (numeric) as SQL_C_SLONG: 1234 '1234.567890' (numeric) as SQL_C_ULONG: 1234 '1234.567890' (numeric) as SQL_C_FLOAT: 1234.567871 '1234.567890' (numeric) as SQL_C_DOUBLE: 1234.567890 '1234.567890' (numeric) as SQL_C_BIT: 210 '1234.567890' (numeric) as SQL_C_STINYINT: -46 '1234.567890' (numeric) as SQL_C_UTINYINT: 210 '1234.567890' (numeric) as SQL_C_SBIGINT: 1234 '1234.567890' (numeric) as SQL_C_UBIGINT: 1234 '1234.567890' (numeric) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_BOOKMARK: 1234 '1234.567890' (numeric) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234.567890' (numeric) as SQL_C_NUMERIC: precision: 10 scale: 6 sign: 6 val: d2029649000000000000000000000000 '1234.567890' (numeric) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_CHAR: foocur 'foocur' (refcursor) as SQL_C_WCHAR: foocur 'foocur' (refcursor) as SQL_C_SSHORT: 0 'foocur' (refcursor) as SQL_C_USHORT: 0 'foocur' (refcursor) as SQL_C_SLONG: 0 'foocur' (refcursor) as SQL_C_ULONG: 0 'foocur' (refcursor) as SQL_C_FLOAT: 0.000000 'foocur' (refcursor) as SQL_C_DOUBLE: 0.000000 'foocur' (refcursor) as SQL_C_BIT: 0 'foocur' (refcursor) as SQL_C_STINYINT: 0 'foocur' (refcursor) as SQL_C_UTINYINT: 0 'foocur' (refcursor) as SQL_C_SBIGINT: 0 'foocur' (refcursor) as SQL_C_UBIGINT: 0 'foocur' (refcursor) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_BOOKMARK: 0 'foocur' (refcursor) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foocur' (refcursor) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foocur' (refcursor) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 Executed: SET bytea_output=hex '\x464F4F' (bytea) as SQL_C_CHAR: 464f4f '\x464F4F' (bytea) as SQL_C_WCHAR: 464f4f '543c5e21-435a-440b-943c-64af1ad571f1' (text) as SQL_C_GUID: d1: 543C5E21 d2: 435A d3: 440B d4: 943C64AF1AD571F1 '2011-02-13' (date) as SQL_C_DATE: y: 2011 m: 2 d: 13 '2011-02-13' (date) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 13 h: 0 m: 0 s: 0 f: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_DATE: y: 2011 m: 2 d: 15 '2011-02-15 15:49:18' (timestamp) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 15 h: 15 m: 49 s: 18 f: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DATE: y: 2011 m: 2 d: 16 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 16 h: 6 m: 49 s: 18 f: 0 '' (text) as SQL_C_TYPE_DATE: y: 0 m: 0 d: 0 '' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '' (text) as SQL_C_TYPE_TIMESTAMP: y: 0 m: 0 d: 0 h: 0 m: 0 s: 0 f: 0 'foobar' (text) as SQL_C_CHAR: foob (truncated) 'foobar' (text) as SQL_C_CHAR: fooba (truncated) 'foobar' (text) as SQL_C_CHAR: foobar 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: foobar '' (text) as SQL_C_CHAR: '' (text) as SQL_C_WCHAR: \FF00\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF (truncated) '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:1 (truncated) '2011-02-15 15:49:18 BC' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 (truncated) 'NaN' (float4) as SQL_C_FLOAT: nan 'Infinity' (float4) as SQL_C_FLOAT: inf '-Infinity' (float4) as SQL_C_FLOAT: -inf 'NaN' (float8) as SQL_C_FLOAT: nan 'Infinity' (float8) as SQL_C_FLOAT: inf '-Infinity' (float8) as SQL_C_FLOAT: -inf 'NaN' (float4) as SQL_C_DOUBLE: nan 'Infinity' (float4) as SQL_C_DOUBLE: inf '-Infinity' (float4) as SQL_C_DOUBLE: -inf 'NaN' (float8) as SQL_C_DOUBLE: nan 'Infinity' (float8) as SQL_C_DOUBLE: inf '-Infinity' (float8) as SQL_C_DOUBLE: -inf disconnecting psqlodbc-REL-16_00_0005/test/expected/result-conversions_3.out000066400000000000000000002441221462406103600241220ustar00rootroot00000000000000connected Executed: SET intervalstyle=postgres Executed: SET bytea_output=escape Executed: SET lc_monetary='C' 'true' (boolean) as SQL_C_CHAR: 1 'true' (boolean) as SQL_C_WCHAR: 1 'true' (boolean) as SQL_C_SSHORT: 1 'true' (boolean) as SQL_C_USHORT: 1 'true' (boolean) as SQL_C_SLONG: 1 'true' (boolean) as SQL_C_ULONG: 1 'true' (boolean) as SQL_C_FLOAT: 1.000000 'true' (boolean) as SQL_C_DOUBLE: 1.000000 'true' (boolean) as SQL_C_BIT: 1 'true' (boolean) as SQL_C_STINYINT: 1 'true' (boolean) as SQL_C_UTINYINT: 1 'true' (boolean) as SQL_C_SBIGINT: 1 'true' (boolean) as SQL_C_UBIGINT: 1 'true' (boolean) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_BOOKMARK: 1 'true' (boolean) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'true' (boolean) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 'true' (boolean) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'true' (boolean) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'true' (boolean) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_CHAR: 464F4F '\x464F4F' (bytea) as SQL_C_WCHAR: 464F4F '\x464F4F' (bytea) as SQL_C_SSHORT: 0 '\x464F4F' (bytea) as SQL_C_USHORT: 0 '\x464F4F' (bytea) as SQL_C_SLONG: 0 '\x464F4F' (bytea) as SQL_C_ULONG: 0 '\x464F4F' (bytea) as SQL_C_FLOAT: 0.000000 '\x464F4F' (bytea) as SQL_C_DOUBLE: 0.000000 '\x464F4F' (bytea) as SQL_C_BIT: 0 '\x464F4F' (bytea) as SQL_C_STINYINT: 0 '\x464F4F' (bytea) as SQL_C_UTINYINT: 0 '\x464F4F' (bytea) as SQL_C_SBIGINT: 0 '\x464F4F' (bytea) as SQL_C_UBIGINT: 0 '\x464F4F' (bytea) as SQL_C_BINARY: hex: 464F4F '\x464F4F' (bytea) as SQL_C_BOOKMARK: 0 '\x464F4F' (bytea) as SQL_C_VARBOOKMARK: hex: 464F4F '\x464F4F' (bytea) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '\x464F4F' (bytea) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '\x464F4F' (bytea) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '\x464F4F' (bytea) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '\x464F4F' (bytea) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_CHAR: x 'x' (char) as SQL_C_WCHAR: x 'x' (char) as SQL_C_SSHORT: 0 'x' (char) as SQL_C_USHORT: 0 'x' (char) as SQL_C_SLONG: 0 'x' (char) as SQL_C_ULONG: 0 'x' (char) as SQL_C_FLOAT: 0.000000 'x' (char) as SQL_C_DOUBLE: 0.000000 'x' (char) as SQL_C_BIT: 0 'x' (char) as SQL_C_STINYINT: 0 'x' (char) as SQL_C_UTINYINT: 0 'x' (char) as SQL_C_SBIGINT: 0 'x' (char) as SQL_C_UBIGINT: 0 'x' (char) as SQL_C_BINARY: hex: 78 'x' (char) as SQL_C_BOOKMARK: 0 'x' (char) as SQL_C_VARBOOKMARK: hex: 78 'x' (char) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'x' (char) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'x' (char) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'x' (char) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'x' (char) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_CHAR: namedata 'namedata' (name) as SQL_C_WCHAR: namedata 'namedata' (name) as SQL_C_SSHORT: 0 'namedata' (name) as SQL_C_USHORT: 0 'namedata' (name) as SQL_C_SLONG: 0 'namedata' (name) as SQL_C_ULONG: 0 'namedata' (name) as SQL_C_FLOAT: 0.000000 'namedata' (name) as SQL_C_DOUBLE: 0.000000 'namedata' (name) as SQL_C_BIT: 0 'namedata' (name) as SQL_C_STINYINT: 0 'namedata' (name) as SQL_C_UTINYINT: 0 'namedata' (name) as SQL_C_SBIGINT: 0 'namedata' (name) as SQL_C_UBIGINT: 0 'namedata' (name) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_BOOKMARK: 0 'namedata' (name) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'namedata' (name) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'namedata' (name) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'namedata' (name) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'namedata' (name) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_CHAR: 1234567890 '1234567890' (int8) as SQL_C_WCHAR: 1234567890 '1234567890' (int8) as SQL_C_SSHORT: 722 '1234567890' (int8) as SQL_C_USHORT: 722 '1234567890' (int8) as SQL_C_SLONG: 1234567890 '1234567890' (int8) as SQL_C_ULONG: 1234567890 '1234567890' (int8) as SQL_C_FLOAT: 1234567936.000000 '1234567890' (int8) as SQL_C_DOUBLE: 1234567890.000000 '1234567890' (int8) as SQL_C_BIT: 210 '1234567890' (int8) as SQL_C_STINYINT: -46 '1234567890' (int8) as SQL_C_UTINYINT: 210 '1234567890' (int8) as SQL_C_SBIGINT: 1234567890 '1234567890' (int8) as SQL_C_UBIGINT: 1234567890 '1234567890' (int8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_BOOKMARK: 1234567890 '1234567890' (int8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567890' (int8) as SQL_C_NUMERIC: precision: 10 scale: 0 sign: 0 val: d2029649000000000000000000000000 '1234567890' (int8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567890' (int8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567890' (int8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_CHAR: 12345 '12345' (int2) as SQL_C_WCHAR: 12345 '12345' (int2) as SQL_C_SSHORT: 12345 '12345' (int2) as SQL_C_USHORT: 12345 '12345' (int2) as SQL_C_SLONG: 12345 '12345' (int2) as SQL_C_ULONG: 12345 '12345' (int2) as SQL_C_FLOAT: 12345.000000 '12345' (int2) as SQL_C_DOUBLE: 12345.000000 '12345' (int2) as SQL_C_BIT: 57 '12345' (int2) as SQL_C_STINYINT: 57 '12345' (int2) as SQL_C_UTINYINT: 57 '12345' (int2) as SQL_C_SBIGINT: 12345 '12345' (int2) as SQL_C_UBIGINT: 12345 '12345' (int2) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_BOOKMARK: 12345 '12345' (int2) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '12345' (int2) as SQL_C_NUMERIC: precision: 5 scale: 0 sign: 0 val: 39300000000000000000000000000000 '12345' (int2) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '12345' (int2) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '12345' (int2) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_CHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_WCHAR: 1 2 3 4 5 '1 2 3 4 5' (int2vector) as SQL_C_SSHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_USHORT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SLONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_ULONG: 1 '1 2 3 4 5' (int2vector) as SQL_C_FLOAT: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_DOUBLE: 1.000000 '1 2 3 4 5' (int2vector) as SQL_C_BIT: 1 '1 2 3 4 5' (int2vector) as SQL_C_STINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UTINYINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_SBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_UBIGINT: 1 '1 2 3 4 5' (int2vector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_BOOKMARK: 1 '1 2 3 4 5' (int2vector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3 4 5' (int2vector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3 4 5' (int2vector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3 4 5' (int2vector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_CHAR: 1234567 '1234567' (int4) as SQL_C_WCHAR: 1234567 '1234567' (int4) as SQL_C_SSHORT: -10617 '1234567' (int4) as SQL_C_USHORT: 54919 '1234567' (int4) as SQL_C_SLONG: 1234567 '1234567' (int4) as SQL_C_ULONG: 1234567 '1234567' (int4) as SQL_C_FLOAT: 1234567.000000 '1234567' (int4) as SQL_C_DOUBLE: 1234567.000000 '1234567' (int4) as SQL_C_BIT: 135 '1234567' (int4) as SQL_C_STINYINT: -121 '1234567' (int4) as SQL_C_UTINYINT: 135 '1234567' (int4) as SQL_C_SBIGINT: 1234567 '1234567' (int4) as SQL_C_UBIGINT: 1234567 '1234567' (int4) as SQL_C_BINARY: hex: 0012D687 '1234567' (int4) as SQL_C_BOOKMARK: 1234567 '1234567' (int4) as SQL_C_VARBOOKMARK: hex: 0012D687 '1234567' (int4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234567' (int4) as SQL_C_NUMERIC: precision: 7 scale: 0 sign: 0 val: 87d61200000000000000000000000000 '1234567' (int4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234567' (int4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234567' (int4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_CHAR: int4pl 'int4pl' (regproc) as SQL_C_WCHAR: int4pl 'int4pl' (regproc) as SQL_C_SSHORT: 0 'int4pl' (regproc) as SQL_C_USHORT: 0 'int4pl' (regproc) as SQL_C_SLONG: 0 'int4pl' (regproc) as SQL_C_ULONG: 0 'int4pl' (regproc) as SQL_C_FLOAT: 0.000000 'int4pl' (regproc) as SQL_C_DOUBLE: 0.000000 'int4pl' (regproc) as SQL_C_BIT: 0 'int4pl' (regproc) as SQL_C_STINYINT: 0 'int4pl' (regproc) as SQL_C_UTINYINT: 0 'int4pl' (regproc) as SQL_C_SBIGINT: 0 'int4pl' (regproc) as SQL_C_UBIGINT: 0 'int4pl' (regproc) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_BOOKMARK: 0 'int4pl' (regproc) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'int4pl' (regproc) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'int4pl' (regproc) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'int4pl' (regproc) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'int4pl' (regproc) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_CHAR: textdata 'textdata' (text) as SQL_C_WCHAR: textdata 'textdata' (text) as SQL_C_SSHORT: 0 'textdata' (text) as SQL_C_USHORT: 0 'textdata' (text) as SQL_C_SLONG: 0 'textdata' (text) as SQL_C_ULONG: 0 'textdata' (text) as SQL_C_FLOAT: 0.000000 'textdata' (text) as SQL_C_DOUBLE: 0.000000 'textdata' (text) as SQL_C_BIT: 0 'textdata' (text) as SQL_C_STINYINT: 0 'textdata' (text) as SQL_C_UTINYINT: 0 'textdata' (text) as SQL_C_SBIGINT: 0 'textdata' (text) as SQL_C_UBIGINT: 0 'textdata' (text) as SQL_C_BINARY: hex: 7465787464617461 'textdata' (text) as SQL_C_BOOKMARK: 0 'textdata' (text) as SQL_C_VARBOOKMARK: hex: 7465787464617461 'textdata' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'textdata' (text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'textdata' (text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'textdata' (text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'textdata' (text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_CHAR: (1,2) '(1,2)' (tid) as SQL_C_WCHAR: (1,2) '(1,2)' (tid) as SQL_C_SSHORT: 0 '(1,2)' (tid) as SQL_C_USHORT: 0 '(1,2)' (tid) as SQL_C_SLONG: 0 '(1,2)' (tid) as SQL_C_ULONG: 0 '(1,2)' (tid) as SQL_C_FLOAT: 0.000000 '(1,2)' (tid) as SQL_C_DOUBLE: 0.000000 '(1,2)' (tid) as SQL_C_BIT: 0 '(1,2)' (tid) as SQL_C_STINYINT: 0 '(1,2)' (tid) as SQL_C_UTINYINT: 0 '(1,2)' (tid) as SQL_C_SBIGINT: 0 '(1,2)' (tid) as SQL_C_UBIGINT: 0 '(1,2)' (tid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_BOOKMARK: 0 '(1,2)' (tid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '(1,2)' (tid) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '(1,2)' (tid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '(1,2)' (tid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '(1,2)' (tid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_CHAR: 1234 '1234' (xid) as SQL_C_WCHAR: 1234 '1234' (xid) as SQL_C_SSHORT: 1234 '1234' (xid) as SQL_C_USHORT: 1234 '1234' (xid) as SQL_C_SLONG: 1234 '1234' (xid) as SQL_C_ULONG: 1234 '1234' (xid) as SQL_C_FLOAT: 1234.000000 '1234' (xid) as SQL_C_DOUBLE: 1234.000000 '1234' (xid) as SQL_C_BIT: 210 '1234' (xid) as SQL_C_STINYINT: -46 '1234' (xid) as SQL_C_UTINYINT: 210 '1234' (xid) as SQL_C_SBIGINT: 1234 '1234' (xid) as SQL_C_UBIGINT: 1234 '1234' (xid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_BOOKMARK: 1234 '1234' (xid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234' (xid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: d2040000000000000000000000000000 '1234' (xid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234' (xid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234' (xid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_CHAR: 4321 '4321' (cid) as SQL_C_WCHAR: 4321 '4321' (cid) as SQL_C_SSHORT: 4321 '4321' (cid) as SQL_C_USHORT: 4321 '4321' (cid) as SQL_C_SLONG: 4321 '4321' (cid) as SQL_C_ULONG: 4321 '4321' (cid) as SQL_C_FLOAT: 4321.000000 '4321' (cid) as SQL_C_DOUBLE: 4321.000000 '4321' (cid) as SQL_C_BIT: 225 '4321' (cid) as SQL_C_STINYINT: -31 '4321' (cid) as SQL_C_UTINYINT: 225 '4321' (cid) as SQL_C_SBIGINT: 4321 '4321' (cid) as SQL_C_UBIGINT: 4321 '4321' (cid) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_BOOKMARK: 4321 '4321' (cid) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '4321' (cid) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: e1100000000000000000000000000000 '4321' (cid) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '4321' (cid) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '4321' (cid) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_CHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_WCHAR: 1 2 3 '1 2 3' (oidvector) as SQL_C_SSHORT: 1 '1 2 3' (oidvector) as SQL_C_USHORT: 1 '1 2 3' (oidvector) as SQL_C_SLONG: 1 '1 2 3' (oidvector) as SQL_C_ULONG: 1 '1 2 3' (oidvector) as SQL_C_FLOAT: 1.000000 '1 2 3' (oidvector) as SQL_C_DOUBLE: 1.000000 '1 2 3' (oidvector) as SQL_C_BIT: 1 '1 2 3' (oidvector) as SQL_C_STINYINT: 1 '1 2 3' (oidvector) as SQL_C_UTINYINT: 1 '1 2 3' (oidvector) as SQL_C_SBIGINT: 1 '1 2 3' (oidvector) as SQL_C_UBIGINT: 1 '1 2 3' (oidvector) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_BOOKMARK: 1 '1 2 3' (oidvector) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1 2 3' (oidvector) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1 2 3' (oidvector) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1 2 3' (oidvector) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1 2 3' (oidvector) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_CHAR: bar 'bar' (xml) as SQL_C_WCHAR: bar 'bar' (xml) as SQL_C_SSHORT: 0 'bar' (xml) as SQL_C_USHORT: 0 'bar' (xml) as SQL_C_SLONG: 0 'bar' (xml) as SQL_C_ULONG: 0 'bar' (xml) as SQL_C_FLOAT: 0.000000 'bar' (xml) as SQL_C_DOUBLE: 0.000000 'bar' (xml) as SQL_C_BIT: 0 'bar' (xml) as SQL_C_STINYINT: 0 'bar' (xml) as SQL_C_UTINYINT: 0 'bar' (xml) as SQL_C_SBIGINT: 0 'bar' (xml) as SQL_C_UBIGINT: 0 'bar' (xml) as SQL_C_BINARY: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_BOOKMARK: 0 'bar' (xml) as SQL_C_VARBOOKMARK: hex: 3C666F6F3E6261723C2F666F6F3E 'bar' (xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'bar' (xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'bar' (xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'bar' (xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'bar' (xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_CHAR: {bar} '{bar}' (_xml) as SQL_C_WCHAR: {bar} '{bar}' (_xml) as SQL_C_SSHORT: 0 '{bar}' (_xml) as SQL_C_USHORT: 0 '{bar}' (_xml) as SQL_C_SLONG: 0 '{bar}' (_xml) as SQL_C_ULONG: 0 '{bar}' (_xml) as SQL_C_FLOAT: 0.000000 '{bar}' (_xml) as SQL_C_DOUBLE: 0.000000 '{bar}' (_xml) as SQL_C_BIT: 0 '{bar}' (_xml) as SQL_C_STINYINT: 0 '{bar}' (_xml) as SQL_C_UTINYINT: 0 '{bar}' (_xml) as SQL_C_SBIGINT: 0 '{bar}' (_xml) as SQL_C_UBIGINT: 0 '{bar}' (_xml) as SQL_C_BINARY: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_BOOKMARK: 0 '{bar}' (_xml) as SQL_C_VARBOOKMARK: hex: 7B3C666F6F3E6261723C2F666F6F3E7D '{bar}' (_xml) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{bar}' (_xml) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{bar}' (_xml) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{bar}' (_xml) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{bar}' (_xml) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_CHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_WCHAR: 10.0.0.1/32 '10.0.0.1' (cidr) as SQL_C_SSHORT: 10 '10.0.0.1' (cidr) as SQL_C_USHORT: 10 '10.0.0.1' (cidr) as SQL_C_SLONG: 10 '10.0.0.1' (cidr) as SQL_C_ULONG: 10 '10.0.0.1' (cidr) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (cidr) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (cidr) as SQL_C_BIT: 10 '10.0.0.1' (cidr) as SQL_C_STINYINT: 10 '10.0.0.1' (cidr) as SQL_C_UTINYINT: 10 '10.0.0.1' (cidr) as SQL_C_SBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_UBIGINT: 10 '10.0.0.1' (cidr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_BOOKMARK: 10 '10.0.0.1' (cidr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (cidr) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (cidr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (cidr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (cidr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_CHAR: 1.234 '1.234' (float4) as SQL_C_WCHAR: 1.234 '1.234' (float4) as SQL_C_SSHORT: 1 '1.234' (float4) as SQL_C_USHORT: 1 '1.234' (float4) as SQL_C_SLONG: 1 '1.234' (float4) as SQL_C_ULONG: 1 '1.234' (float4) as SQL_C_FLOAT: 1.234000 '1.234' (float4) as SQL_C_DOUBLE: 1.234000 '1.234' (float4) as SQL_C_BIT: 1 '1.234' (float4) as SQL_C_STINYINT: 1 '1.234' (float4) as SQL_C_UTINYINT: 1 '1.234' (float4) as SQL_C_SBIGINT: 1 '1.234' (float4) as SQL_C_UBIGINT: 1 '1.234' (float4) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_BOOKMARK: 1 '1.234' (float4) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.234' (float4) as SQL_C_NUMERIC: precision: 4 scale: 3 sign: 3 val: d2040000000000000000000000000000 '1.234' (float4) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.234' (float4) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.234' (float4) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_CHAR: 1.2345678901199999 '1.23456789012' (float8) as SQL_C_WCHAR: 1.2345678901199999 '1.23456789012' (float8) as SQL_C_SSHORT: 1 '1.23456789012' (float8) as SQL_C_USHORT: 1 '1.23456789012' (float8) as SQL_C_SLONG: 1 '1.23456789012' (float8) as SQL_C_ULONG: 1 '1.23456789012' (float8) as SQL_C_FLOAT: 1.234568 '1.23456789012' (float8) as SQL_C_DOUBLE: 1.234568 '1.23456789012' (float8) as SQL_C_BIT: 1 '1.23456789012' (float8) as SQL_C_STINYINT: 1 '1.23456789012' (float8) as SQL_C_UTINYINT: 1 '1.23456789012' (float8) as SQL_C_SBIGINT: 1 '1.23456789012' (float8) as SQL_C_UBIGINT: 1 '1.23456789012' (float8) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_BOOKMARK: 1 '1.23456789012' (float8) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23456789012' (float8) as SQL_C_NUMERIC: precision: 17 scale: 16 sign: 16 val: 7fc46a5d54dc2b000000000000000000 '1.23456789012' (float8) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23456789012' (float8) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23456789012' (float8) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_CHAR: foo 'foo' (unknown) as SQL_C_WCHAR: foo 'foo' (unknown) as SQL_C_SSHORT: 0 'foo' (unknown) as SQL_C_USHORT: 0 'foo' (unknown) as SQL_C_SLONG: 0 'foo' (unknown) as SQL_C_ULONG: 0 'foo' (unknown) as SQL_C_FLOAT: 0.000000 'foo' (unknown) as SQL_C_DOUBLE: 0.000000 'foo' (unknown) as SQL_C_BIT: 0 'foo' (unknown) as SQL_C_STINYINT: 0 'foo' (unknown) as SQL_C_UTINYINT: 0 'foo' (unknown) as SQL_C_SBIGINT: 0 'foo' (unknown) as SQL_C_UBIGINT: 0 'foo' (unknown) as SQL_C_BINARY: hex: 666F6F 'foo' (unknown) as SQL_C_BOOKMARK: 0 'foo' (unknown) as SQL_C_VARBOOKMARK: hex: 666F6F 'foo' (unknown) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foo' (unknown) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foo' (unknown) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foo' (unknown) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foo' (unknown) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_CHAR: $1.23 '1.23' (money) as SQL_C_WCHAR: $1.23 '1.23' (money) as SQL_C_SSHORT: 1 '1.23' (money) as SQL_C_USHORT: 1 '1.23' (money) as SQL_C_SLONG: 1 '1.23' (money) as SQL_C_ULONG: 1 '1.23' (money) as SQL_C_FLOAT: 1.230000 '1.23' (money) as SQL_C_DOUBLE: 1.230000 '1.23' (money) as SQL_C_BIT: 1 '1.23' (money) as SQL_C_STINYINT: 1 '1.23' (money) as SQL_C_UTINYINT: 1 '1.23' (money) as SQL_C_SBIGINT: 1 '1.23' (money) as SQL_C_UBIGINT: 1 '1.23' (money) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_BOOKMARK: 1 '1.23' (money) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1.23' (money) as SQL_C_NUMERIC: precision: 3 scale: 2 sign: 2 val: 7b000000000000000000000000000000 '1.23' (money) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1.23' (money) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1.23' (money) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_CHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_WCHAR: 08:00:2b:01:02:03 '08-00-2b-01-02-03' (macaddr) as SQL_C_SSHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_USHORT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SLONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_ULONG: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_FLOAT: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_DOUBLE: 8.000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_BIT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_STINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UTINYINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_SBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_UBIGINT: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_BOOKMARK: 8 '08-00-2b-01-02-03' (macaddr) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 08000000000000000000000000000000 '08-00-2b-01-02-03' (macaddr) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '08-00-2b-01-02-03' (macaddr) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_CHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_WCHAR: 10.0.0.1 '10.0.0.1' (inet) as SQL_C_SSHORT: 10 '10.0.0.1' (inet) as SQL_C_USHORT: 10 '10.0.0.1' (inet) as SQL_C_SLONG: 10 '10.0.0.1' (inet) as SQL_C_ULONG: 10 '10.0.0.1' (inet) as SQL_C_FLOAT: 10.000000 '10.0.0.1' (inet) as SQL_C_DOUBLE: 10.000000 '10.0.0.1' (inet) as SQL_C_BIT: 10 '10.0.0.1' (inet) as SQL_C_STINYINT: 10 '10.0.0.1' (inet) as SQL_C_UTINYINT: 10 '10.0.0.1' (inet) as SQL_C_SBIGINT: 10 '10.0.0.1' (inet) as SQL_C_UBIGINT: 10 '10.0.0.1' (inet) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_BOOKMARK: 10 '10.0.0.1' (inet) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10.0.0.1' (inet) as SQL_C_NUMERIC: precision: 3 scale: 1 sign: 1 val: 64000000000000000000000000000000 '10.0.0.1' (inet) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10.0.0.1' (inet) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10.0.0.1' (inet) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_text) as SQL_C_SSHORT: 0 '{foo, bar}' (_text) as SQL_C_USHORT: 0 '{foo, bar}' (_text) as SQL_C_SLONG: 0 '{foo, bar}' (_text) as SQL_C_ULONG: 0 '{foo, bar}' (_text) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_text) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_text) as SQL_C_BIT: 0 '{foo, bar}' (_text) as SQL_C_STINYINT: 0 '{foo, bar}' (_text) as SQL_C_UTINYINT: 0 '{foo, bar}' (_text) as SQL_C_SBIGINT: 0 '{foo, bar}' (_text) as SQL_C_UBIGINT: 0 '{foo, bar}' (_text) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_text) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_text) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_text) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_text) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_text) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_bpchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_USHORT: 0 '{foo, bar}' (_bpchar) as SQL_C_SLONG: 0 '{foo, bar}' (_bpchar) as SQL_C_ULONG: 0 '{foo, bar}' (_bpchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_bpchar) as SQL_C_BIT: 0 '{foo, bar}' (_bpchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_bpchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_bpchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_bpchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_CHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_WCHAR: {foo,bar} '{foo, bar}' (_varchar) as SQL_C_SSHORT: 0 '{foo, bar}' (_varchar) as SQL_C_USHORT: 0 '{foo, bar}' (_varchar) as SQL_C_SLONG: 0 '{foo, bar}' (_varchar) as SQL_C_ULONG: 0 '{foo, bar}' (_varchar) as SQL_C_FLOAT: 0.000000 '{foo, bar}' (_varchar) as SQL_C_DOUBLE: 0.000000 '{foo, bar}' (_varchar) as SQL_C_BIT: 0 '{foo, bar}' (_varchar) as SQL_C_STINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_UTINYINT: 0 '{foo, bar}' (_varchar) as SQL_C_SBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_UBIGINT: 0 '{foo, bar}' (_varchar) as SQL_C_BINARY: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_BOOKMARK: 0 '{foo, bar}' (_varchar) as SQL_C_VARBOOKMARK: hex: 7B666F6F2C6261727D '{foo, bar}' (_varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '{foo, bar}' (_varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 '{foo, bar}' (_varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '{foo, bar}' (_varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '{foo, bar}' (_varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_CHAR: foobar 'foobar' (bpchar) as SQL_C_WCHAR: foobar 'foobar' (bpchar) as SQL_C_SSHORT: 0 'foobar' (bpchar) as SQL_C_USHORT: 0 'foobar' (bpchar) as SQL_C_SLONG: 0 'foobar' (bpchar) as SQL_C_ULONG: 0 'foobar' (bpchar) as SQL_C_FLOAT: 0.000000 'foobar' (bpchar) as SQL_C_DOUBLE: 0.000000 'foobar' (bpchar) as SQL_C_BIT: 0 'foobar' (bpchar) as SQL_C_STINYINT: 0 'foobar' (bpchar) as SQL_C_UTINYINT: 0 'foobar' (bpchar) as SQL_C_SBIGINT: 0 'foobar' (bpchar) as SQL_C_UBIGINT: 0 'foobar' (bpchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_BOOKMARK: 0 'foobar' (bpchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (bpchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (bpchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (bpchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (bpchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (bpchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_CHAR: foobar 'foobar' (varchar) as SQL_C_WCHAR: foobar 'foobar' (varchar) as SQL_C_SSHORT: 0 'foobar' (varchar) as SQL_C_USHORT: 0 'foobar' (varchar) as SQL_C_SLONG: 0 'foobar' (varchar) as SQL_C_ULONG: 0 'foobar' (varchar) as SQL_C_FLOAT: 0.000000 'foobar' (varchar) as SQL_C_DOUBLE: 0.000000 'foobar' (varchar) as SQL_C_BIT: 0 'foobar' (varchar) as SQL_C_STINYINT: 0 'foobar' (varchar) as SQL_C_UTINYINT: 0 'foobar' (varchar) as SQL_C_SBIGINT: 0 'foobar' (varchar) as SQL_C_UBIGINT: 0 'foobar' (varchar) as SQL_C_BINARY: hex: 666F6F626172 'foobar' (varchar) as SQL_C_BOOKMARK: 0 'foobar' (varchar) as SQL_C_VARBOOKMARK: hex: 666F6F626172 'foobar' (varchar) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foobar' (varchar) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foobar' (varchar) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foobar' (varchar) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foobar' (varchar) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_CHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_WCHAR: 2011-02-13 '2011-02-13' (date) as SQL_C_SSHORT: 2011 '2011-02-13' (date) as SQL_C_USHORT: 2011 '2011-02-13' (date) as SQL_C_SLONG: 2011 '2011-02-13' (date) as SQL_C_ULONG: 2011 '2011-02-13' (date) as SQL_C_FLOAT: 2011.000000 '2011-02-13' (date) as SQL_C_DOUBLE: 2011.000000 '2011-02-13' (date) as SQL_C_BIT: 219 '2011-02-13' (date) as SQL_C_STINYINT: -37 '2011-02-13' (date) as SQL_C_UTINYINT: 219 '2011-02-13' (date) as SQL_C_SBIGINT: 2011 '2011-02-13' (date) as SQL_C_UBIGINT: 2011 '2011-02-13' (date) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_BOOKMARK: 2011 '2011-02-13' (date) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '2011-02-13' (date) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-13' (date) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-13' (date) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-13' (date) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_CHAR: 13:23:34 '13:23:34' (time) as SQL_C_WCHAR: 13:23:34 '13:23:34' (time) as SQL_C_SSHORT: 13 '13:23:34' (time) as SQL_C_USHORT: 13 '13:23:34' (time) as SQL_C_SLONG: 13 '13:23:34' (time) as SQL_C_ULONG: 13 '13:23:34' (time) as SQL_C_FLOAT: 13.000000 '13:23:34' (time) as SQL_C_DOUBLE: 13.000000 '13:23:34' (time) as SQL_C_BIT: 13 '13:23:34' (time) as SQL_C_STINYINT: 13 '13:23:34' (time) as SQL_C_UTINYINT: 13 '13:23:34' (time) as SQL_C_SBIGINT: 13 '13:23:34' (time) as SQL_C_UBIGINT: 13 '13:23:34' (time) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_BOOKMARK: 13 '13:23:34' (time) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_TYPE_TIME: h: 13 m: 23 s: 34 '13:23:34' (time) as SQL_C_NUMERIC: precision: 2 scale: 0 sign: 0 val: 0d000000000000000000000000000000 '13:23:34' (time) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '13:23:34' (time) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '13:23:34' (time) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_WCHAR: 2011-02-15 15:49:18 '2011-02-15 15:49:18' (timestamp) as SQL_C_SSHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_USHORT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_SLONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_ULONG: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_FLOAT: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_DOUBLE: 2011.000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_BIT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_STINYINT: -37 '2011-02-15 15:49:18' (timestamp) as SQL_C_UTINYINT: 219 '2011-02-15 15:49:18' (timestamp) as SQL_C_SBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_UBIGINT: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_BOOKMARK: 2011 '2011-02-15 15:49:18' (timestamp) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_TYPE_TIME: h: 15 m: 49 s: 18 '2011-02-15 15:49:18' (timestamp) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-15 15:49:18' (timestamp) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_CHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_WCHAR: 2011-02-16 06:49:18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SSHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_USHORT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SLONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_ULONG: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_FLOAT: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DOUBLE: 2011.000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BIT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_STINYINT: -37 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UTINYINT: 219 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_SBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_UBIGINT: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_BOOKMARK: 2011 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TYPE_TIME: h: 6 m: 49 s: 18 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_NUMERIC: precision: 4 scale: 0 sign: 0 val: db070000000000000000000000000000 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 2011 month: 2 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_CHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_WCHAR: 9 years 1 mon -12 days +13:14:00 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SSHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_USHORT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SLONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_ULONG: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_FLOAT: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_DOUBLE: 9.000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BIT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_STINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UTINYINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_SBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_UBIGINT: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_BOOKMARK: 9 '10 years -11 months -12 days +13:14' (interval) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 09000000000000000000000000000000 '10 years -11 months -12 days +13:14' (interval) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MONTH: interval sign: 0 year: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 year 9 month: 1 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '10 years -11 months -12 days +13:14' (interval) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_CHAR: 1 '1' (bit) as SQL_C_WCHAR: 1 '1' (bit) as SQL_C_SSHORT: 1 '1' (bit) as SQL_C_USHORT: 1 '1' (bit) as SQL_C_SLONG: 1 '1' (bit) as SQL_C_ULONG: 1 '1' (bit) as SQL_C_FLOAT: 1.000000 '1' (bit) as SQL_C_DOUBLE: 1.000000 '1' (bit) as SQL_C_BIT: 1 '1' (bit) as SQL_C_STINYINT: 1 '1' (bit) as SQL_C_UTINYINT: 1 '1' (bit) as SQL_C_SBIGINT: 1 '1' (bit) as SQL_C_UBIGINT: 1 '1' (bit) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_BOOKMARK: 1 '1' (bit) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1' (bit) as SQL_C_NUMERIC: precision: 1 scale: 0 sign: 0 val: 01000000000000000000000000000000 '1' (bit) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1' (bit) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1' (bit) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_CHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_WCHAR: 1234.567890 '1234.567890' (numeric) as SQL_C_SSHORT: 1234 '1234.567890' (numeric) as SQL_C_USHORT: 1234 '1234.567890' (numeric) as SQL_C_SLONG: 1234 '1234.567890' (numeric) as SQL_C_ULONG: 1234 '1234.567890' (numeric) as SQL_C_FLOAT: 1234.567871 '1234.567890' (numeric) as SQL_C_DOUBLE: 1234.567890 '1234.567890' (numeric) as SQL_C_BIT: 210 '1234.567890' (numeric) as SQL_C_STINYINT: -46 '1234.567890' (numeric) as SQL_C_UTINYINT: 210 '1234.567890' (numeric) as SQL_C_SBIGINT: 1234 '1234.567890' (numeric) as SQL_C_UBIGINT: 1234 '1234.567890' (numeric) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_BOOKMARK: 1234 '1234.567890' (numeric) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '1234.567890' (numeric) as SQL_C_NUMERIC: precision: 10 scale: 6 sign: 6 val: d2029649000000000000000000000000 '1234.567890' (numeric) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. '1234.567890' (numeric) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 '1234.567890' (numeric) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_CHAR: foocur 'foocur' (refcursor) as SQL_C_WCHAR: foocur 'foocur' (refcursor) as SQL_C_SSHORT: 0 'foocur' (refcursor) as SQL_C_USHORT: 0 'foocur' (refcursor) as SQL_C_SLONG: 0 'foocur' (refcursor) as SQL_C_ULONG: 0 'foocur' (refcursor) as SQL_C_FLOAT: 0.000000 'foocur' (refcursor) as SQL_C_DOUBLE: 0.000000 'foocur' (refcursor) as SQL_C_BIT: 0 'foocur' (refcursor) as SQL_C_STINYINT: 0 'foocur' (refcursor) as SQL_C_UTINYINT: 0 'foocur' (refcursor) as SQL_C_SBIGINT: 0 'foocur' (refcursor) as SQL_C_UBIGINT: 0 'foocur' (refcursor) as SQL_C_BINARY: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_BOOKMARK: 0 'foocur' (refcursor) as SQL_C_VARBOOKMARK: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 'foocur' (refcursor) as SQL_C_NUMERIC: precision: 0 scale: 0 sign: 0 val: 00000000000000000000000000000000 'foocur' (refcursor) as SQL_C_GUID: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_YEAR_TO_MONTH: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_HOUR: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_MINUTE: SQLGetData failed 07006=Received an unsupported type from Postgres. 'foocur' (refcursor) as SQL_C_INTERVAL_DAY_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_MINUTE: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_HOUR_TO_SECOND: interval sign: 0 unknown interval type: 0 'foocur' (refcursor) as SQL_C_INTERVAL_MINUTE_TO_SECOND: interval sign: 0 unknown interval type: 0 Executed: SET bytea_output=hex '\x464F4F' (bytea) as SQL_C_CHAR: 464f4f '\x464F4F' (bytea) as SQL_C_WCHAR: 464f4f '543c5e21-435a-440b-943c-64af1ad571f1' (text) as SQL_C_GUID: d1: 543C5E21 d2: 435A d3: 440B d4: 943C64AF1AD571F1 '2011-02-13' (date) as SQL_C_DATE: y: 2011 m: 2 d: 13 '2011-02-13' (date) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 13 h: 0 m: 0 s: 0 f: 0 '2011-02-15 15:49:18' (timestamp) as SQL_C_DATE: y: 2011 m: 2 d: 15 '2011-02-15 15:49:18' (timestamp) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 15 h: 15 m: 49 s: 18 f: 0 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DATE: y: 2011 m: 2 d: 16 '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 16 h: 6 m: 49 s: 18 f: 0 '' (text) as SQL_C_TYPE_DATE: y: 0 m: 0 d: 0 '' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0 '' (text) as SQL_C_TYPE_TIMESTAMP: y: 0 m: 0 d: 0 h: 0 m: 0 s: 0 f: 0 'foobar' (text) as SQL_C_CHAR: foob (truncated) 'foobar' (text) as SQL_C_CHAR: fooba (truncated) 'foobar' (text) as SQL_C_CHAR: foobar 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: foob (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: fooba (truncated) 'foobar' (text) as SQL_C_WCHAR: foobar '' (text) as SQL_C_CHAR: '' (text) as SQL_C_WCHAR: \ FF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF\FFFF (truncated) '2011-02-15 15:49:18' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:1 (truncated) '2011-02-15 15:49:18 BC' (timestamp) as SQL_C_CHAR: 2011-02-15 15:49:18 (truncated) 'NaN' (float4) as SQL_C_FLOAT: nan 'Infinity' (float4) as SQL_C_FLOAT: inf '-Infinity' (float4) as SQL_C_FLOAT: -inf 'NaN' (float8) as SQL_C_FLOAT: nan 'Infinity' (float8) as SQL_C_FLOAT: inf '-Infinity' (float8) as SQL_C_FLOAT: -inf 'NaN' (float4) as SQL_C_DOUBLE: nan 'Infinity' (float4) as SQL_C_DOUBLE: inf '-Infinity' (float4) as SQL_C_DOUBLE: -inf 'NaN' (float8) as SQL_C_DOUBLE: nan 'Infinity' (float8) as SQL_C_DOUBLE: inf '-Infinity' (float8) as SQL_C_DOUBLE: -inf disconnecting psqlodbc-REL-16_00_0005/test/expected/select.out000066400000000000000000000154411462406103600212730ustar00rootroot00000000000000connected Result set: 1 2 Result set: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 disconnecting psqlodbc-REL-16_00_0005/test/expected/stmthandles.out000066400000000000000000000024741462406103600223440ustar00rootroot00000000000000connected 10 statements allocated... 20 statements allocated... 30 statements allocated... 40 statements allocated... 50 statements allocated... 60 statements allocated... 70 statements allocated... 80 statements allocated... 90 statements allocated... 100 statements allocated... 10 statements executed... 20 statements executed... 30 statements executed... 40 statements executed... 50 statements executed... 60 statements executed... 70 statements executed... 80 statements executed... 90 statements executed... 100 statements executed... Result set: stmt no 1 Result set: stmt no 11 Result set: stmt no 21 Result set: stmt no 31 Result set: stmt no 41 Result set: stmt no 51 Result set: stmt no 61 Result set: stmt no 71 Result set: stmt no 81 Result set: stmt no 91 Testing interleaving operations on multiple prepared statements # of result cols: 1 # of result cols: 2 # of result cols: 3 # of result cols: 4 # of result cols: 5 Result set: stmt no 0 stmt no 0 stmt no 0 Result set: stmt no 1 col 0 stmt no 1 col 0 stmt no 1 col 0 Result set: stmt no 2 col 0 col 1 stmt no 2 col 0 col 1 stmt no 2 col 0 col 1 Result set: stmt no 3 col 0 col 1 col 2 stmt no 3 col 0 col 1 col 2 stmt no 3 col 0 col 1 col 2 Result set: stmt no 4 col 0 col 1 col 2 col 3 stmt no 4 col 0 col 1 col 2 col 3 stmt no 4 col 0 col 1 col 2 col 3 disconnecting psqlodbc-REL-16_00_0005/test/expected/update.out000066400000000000000000000003351462406103600212720ustar00rootroot00000000000000connected # of rows inserted: 1 # of rows inserted: 1 # of rows inserted: 1 # of rows inserted: 1 # of rows inserted: 1 # of rows updated: 3 # of rows deleted: 2 Result set: 5 foobar 1 updated 1 3 updated 3 disconnecting psqlodbc-REL-16_00_0005/test/expected/wchar-char.out000066400000000000000000000003211462406103600220220ustar00rootroot00000000000000connected SJIS test ANSI=͈㔎jłBM͐ē_łˁH U+79C1U+306FU+4E95U+4E0AU+535AU+53F2U+3067U+3059U+3002U+8CB4U+65B9U+306FU+6589U+85E4U+6D69U+3055U+3093U+3067U+3059U+306DU+FF1F disconnecting psqlodbc-REL-16_00_0005/test/expected/wchar-char_1.out000077500000000000000000000013641462406103600222550ustar00rootroot00000000000000connected UTF8 test *** wcs_debug = 0 *** ANSI=私は井上博史です。貴方は斉藤浩さんですね? 𠀋𡈽𡌛𡑮𡢽𪐷𪗱𪘂 U+79C1U+306FU+4E95U+4E0AU+535AU+53F2U+3067U+3059U+3002U+8CB4U+65B9U+306FU+6589U+85E4U+6D69U+3055U+3093U+3067U+3059U+306DU+FF1FU+0020U+0020U+D840U+DC0BU+D844U+DE3DU+D844U+DF1BU+D845U+DC6EU+D846U+DCBDU+D869U+DC37U+D869U+DDF1U+D869U+DE02 *** wcs_debug = 1 *** ANSI=私は井上博史です。貴方は斉藤浩さんですね? 𠀋𡈽𡌛𡑮𡢽𪐷𪗱𪘂 U+79C1U+306FU+4E95U+4E0AU+535AU+53F2U+3067U+3059U+3002U+8CB4U+65B9U+306FU+6589U+85E4U+6D69U+3055U+3093U+3067U+3059U+306DU+FF1FU+0020U+0020U+D840U+DC0BU+D844U+DE3DU+D844U+DF1BU+D845U+DC6EU+D846U+DCBDU+D869U+DC37U+D869U+DDF1U+D869U+DE02 disconnecting psqlodbc-REL-16_00_0005/test/expected/wchar-char_2.out000077500000000000000000000005361462406103600222560ustar00rootroot00000000000000Unfortunately this program can't handle this locale Or you are testing an ansi driver Anyway bypass this program abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz psqlodbc-REL-16_00_0005/test/expected/wchar-char_3.out000066400000000000000000000003221462406103600222450ustar00rootroot00000000000000connected EUCJP test ANSI=ϰˤǤƣǤ͡ U+79C1U+306FU+4E95U+4E0AU+535AU+53F2U+3067U+3059U+3002U+8CB4U+65B9U+306FU+6589U+85E4U+6D69U+3055U+3093U+3067U+3059U+306DU+FF1F disconnecting psqlodbc-REL-16_00_0005/test/odbcini-gen.sh000077500000000000000000000043151462406103600201750ustar00rootroot00000000000000#!/bin/sh # # This isn't a test application. # Initial setting of odbc(inst).ini. # outini=odbc.ini outinstini=odbcinst.ini drvr=../.libs/psqlodbcw driver=${drvr}.so if test ! -e $driver ; then driver=${drvr}.dll if test ! -e $driver ; then echo Failure:driver ${drvr}.so\(.dll\) not found exit 2 fi fi drvra=../.libs/psqlodbca drivera=${drvra}.so if test ! -e $drivera ; then drivera=${drvra}.dll if test ! -e $drivera ; then echo Failure:driver ${drvra}.so\(.dll\) not found exit 2 fi fi echo creating $outinstini cat << _EOT_ > $outinstini [ODBC] Trace = off TraceFile = [PostgreSQL Unicode] Description = PostgreSQL ODBC driver (Unicode version), for regression tests Driver = $driver Debug = 0 CommLog = 0 [PostgreSQL ANSI] Description = PostgreSQL ODBC driver (ANSI version), for regression tests Driver = $drivera Debug = 0 CommLog = 0 _EOT_ echo creating $outini: $@ # Unicode cat << _EOT_ > $outini [psqlodbc_test_dsn] Description = psqlodbc regression test DSN Driver = PostgreSQL Unicode Trace = No TraceFile = Database = contrib_regression Servername = Username = Password = Port = ReadOnly = No RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings = set lc_messages='C' _EOT_ # Add any extra options from the command line for opt in "$@" do echo "${opt}" >> $outini done # ANSI cat << _EOT_ >> $outini [psqlodbc_test_dsn_ansi] Description = psqlodbc ansi regression test DSN Driver = PostgreSQL ANSI Trace = No TraceFile = Database = contrib_regression Servername = Username = Password = Port = ReadOnly = No RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings = set lc_messages='C' _EOT_ # Add any extra options from the command line for opt in "$@" do echo "${opt}" >> $outini done psqlodbc-REL-16_00_0005/test/reset-db.c000066400000000000000000000056041462406103600173330ustar00rootroot00000000000000/* * Initializes contrib_regression database. * * DROPs and CREATEs the database, then executes all statements passed in * stdin. Use "reset-db < sampletables.sql" to run. * * This uses the same psqlodbc_test_dsn datasource to connect that the * actual regression tests use. */ #include #include #ifdef WIN32 #include #define snprintf _snprintf #endif #include "src/common.h" static HSTMT hstmt = SQL_NULL_HSTMT; static void connect_to_db(char *dsn) { SQLRETURN ret; char errmsg[500]; SQLSMALLINT textlen; char sqlstate[20]; SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); ret = SQLDriverConnect(conn, NULL, (SQLCHAR *) dsn, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT); if (!SQL_SUCCEEDED(ret)) { printf("connection to %s failed\n", dsn); ret = SQLGetDiagRec(SQL_HANDLE_DBC, conn, 1, sqlstate, NULL, errmsg, sizeof(errmsg), &textlen); if (ret == SQL_INVALID_HANDLE) printf("Invalid handle\n"); else if (SQL_SUCCEEDED(ret)) printf("%s=%s\n", sqlstate, errmsg); exit(1); } printf("connected to %s\n", dsn); ret = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(ret)) { printf("SQLAllocHandle failed\n"); exit(1); } } static void run_statement(char *statement) { SQLRETURN ret; char errmsg[500]; SQLSMALLINT textlen; char sqlstate[20]; /* * Ignore BOM of UTF-8 */ if ((UCHAR) statement[0] == 0xEF && (UCHAR) statement[1] == 0xBB && (UCHAR) statement[2] == 0xBF) statement += 3; /* * Skip empty lines. The server would just ignore them too, but might as * well avoid the round-trip. */ if (statement[0] == '\0' || statement[0] == '\n') return; /* Skip comment lines too. */ if (statement[0] == '-' && statement[1] == '-') return; ret = SQLExecDirect(hstmt, (SQLCHAR *) statement, SQL_NTS); if (!SQL_SUCCEEDED(ret)) { printf("Statement failed: %s\n", statement); ret = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, sqlstate, NULL, errmsg, sizeof(errmsg), &textlen); if (ret == SQL_INVALID_HANDLE) printf("Invalid handle\n"); else if (SQL_SUCCEEDED(ret)) printf("%s=%s\n", sqlstate, errmsg); exit(1); } (void) SQLFreeStmt(hstmt, SQL_CLOSE); } int main(int argc, char **argv) { char line[500], dsn[100]; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); snprintf(dsn, sizeof(dsn), "DSN=%s;Database=postgres", get_test_dsn()); connect_to_db(dsn); printf("Dropping and creating database contrib_regression...\n"); run_statement("DROP DATABASE IF EXISTS contrib_regression"); run_statement("CREATE DATABASE contrib_regression"); snprintf(dsn, sizeof(dsn), "DSN=%s;Database=contrib_regression", get_test_dsn()); connect_to_db(dsn); printf("Running initialization script...\n"); while (fgets(line, sizeof(line), stdin) != NULL) run_statement(line); printf("Done!\n"); return 0; } psqlodbc-REL-16_00_0005/test/runsuite.c000066400000000000000000000233371462406103600175070ustar00rootroot00000000000000/* * A test driver for the psqlodbc regression tests. * * This program runs one regression tests from the exe/ directory, * and compares the output with the expected output in the expected/ directory. * Reports success or failure in TAP compatible fashion. */ #include #include #include #ifndef WIN32 #include #endif #include #include #include #include #include #ifdef WIN32 #include #define open _open #define read _read #define close _close #define snprintf _snprintf #define vsnprintf _vsnprintf #define strdup _strdup #endif static int rundiff(const char *testname, const char *inputdir); static int runtest(const char *binname, const char *testname, int testno, const char *inputdir); static char *slurpfile(const char *filename, size_t *len); static void bailout(const char *fmt, ...) { va_list argp; va_start(argp, fmt); printf("Bail out! "); vprintf(fmt, argp); va_end(argp); exit(1); } #ifdef WIN32 #define DIR_SEP '\\' #else #define DIR_SEP '/' #endif /* Given a test program's name, get the test name */ void parse_argument(const char *in, char *testname, char *binname) { const char *basename; #ifdef WIN32 const char *suffix = "-test.exe"; #else const char *suffix = "-test"; #endif size_t len; /* if the input is a plain test name, construct the binary name from it */ if (strchr(in, DIR_SEP) == NULL) { strcpy(testname, in); sprintf(binname, "exe%c%s-test", DIR_SEP, in); return; } /* * Otherwise the input is a binary name, and we'll construct the test name * from it. */ strcpy(binname, in); /* Find the last / or \ character */ basename = strrchr(in, DIR_SEP) + 1; /* Strip -test or -test.exe suffix */ if (strlen(basename) <= strlen(suffix)) { strcpy(testname, basename); return; } len = strlen(basename) - strlen(suffix); if (strcmp(&basename[len], suffix) != 0) { strcpy(testname, basename); return; } memcpy(testname, basename, len); testname[len] = '\0'; } int main(int argc, char **argv) { char binname[1000]; char testname[100]; int numtests; int i, j; int failures; const char *inputdir = "."; int sub_count = 1; if (argc < 2) { printf("Usage: runsuite ...\n"); exit(1); } if (strncmp(argv[argc - 1], "--inputdir=", 11) == 0) { sub_count++; inputdir = argv[argc - 1] + 11; } numtests = argc - sub_count; printf("TAP version 13\n"); printf("1..%d\n", numtests); /* * We accept either test binary name or plain test name. */ failures = 0; for (i = 1, j = 1; i <= numtests; i++, j++) { parse_argument(argv[j], testname, binname); if (runtest(binname, testname, i, inputdir) != 0) failures++; } exit(failures > 254 ? 254 : failures); } /* Return 0 on success, 1 on failure */ static int runtest(const char *binname, const char *testname, int testno, const char *inputdir) { char cmdline[1024]; int rc; int ret; int diff; /* * ODBCSYSINI=. tells unixodbc where to find the driver config file, * odbcinst.ini * * ODBCINSTINI=./odbcinst.ini tells the same for iodbc. iodbc also requires * ODBCINI=./odbc.ini to tell it where to find the datasource config. * * We wouldn't need to iodbc stuff when building with unixodbc and vice * versa, but it doesn't hurt either. */ #ifndef WIN32 snprintf(cmdline, sizeof(cmdline), "ODBCSYSINI=. ODBCINSTINI=./odbcinst.ini ODBCINI=./odbc.ini " "%s > results/%s.out", binname, testname); #else snprintf(cmdline, sizeof(cmdline), "%s > results\\%s.out", binname, testname); #endif rc = system(cmdline); diff = rundiff(testname, inputdir); if (rc != 0) { printf("not ok %d - %s test returned %d\n", testno, testname, rc); ret = 1; } else if (diff != 0) { printf("not ok %d - %s test output differs\n", testno, testname); ret = 1; } else { printf("ok %d - %s\n", testno, testname); ret = 0; } fflush(stdout); return ret; } #ifdef WIN32 static int first_call = 1; static const char * exec_diffpgm; struct diff_info { const char *cmdname; const char *cmd; }; static const struct diff_info diffi[] = { { "diff", "diff -c --strip-trailing-cr \"%s\" \"%s\" %s" } // cygwin etc , { "git", "git diff --no-index -w \"%s\" \"%s\" %s" } // git bash for Windows , { "wsl", "wsl diff -c --strip-trailing-cr \"`wslpath '%s'`\" \"`wslpath '%s'`\" %s" } // WSL , { "fc", "fc /N \"%s\" \"%s\" %s" } }; #endif /* WIN32 */ static int call_diff(const char *inputdir, const char *expected_dir, const char *testname, int outputno, const char *result_dir, const char *outspec) { char no_str[8]; char cmdline[1024], file1[256], file2[256]; int diff_rtn; if (0 == outputno) *no_str = '\0'; else snprintf(no_str, sizeof(no_str), "_%d", outputno); snprintf(file1, sizeof(file1), "%s%s%s%s.out", inputdir, expected_dir, testname, no_str); snprintf(file2, sizeof(file2), "%s%s.out", result_dir, testname); #ifdef WIN32 if (NULL == exec_diffpgm) return -1; snprintf(cmdline, sizeof(cmdline), exec_diffpgm, file1, file2, outspec); #else snprintf(cmdline, sizeof(cmdline), "diff -c %s %s %s", file1, file2, outspec); #endif /* WIN32 */ if ((diff_rtn = system(cmdline)) == -1) printf("# diff failed\n"); return diff_rtn; } static int rundiff(const char *testname, const char *inputdir) { char filename[1024]; int outputno, no_spec; char *result = NULL; size_t result_len; #ifdef WIN32 const char *expected_dir = "\\expected\\"; const char *result_dir = "results\\"; #else const char *expected_dir = "/expected/"; const char *result_dir = "results/"; #endif int diff_rtn; int i, j; const char CR = '\r', LF = '\n'; char se, sr; snprintf(filename, sizeof(filename), "%s%s.out", result_dir, testname); result = slurpfile(filename, &result_len); outputno = 0; for (;;) { char *expected; size_t expected_len; if (outputno == 0) snprintf(filename, sizeof(filename), "%s%s%s.out", inputdir, expected_dir, testname); else snprintf(filename, sizeof(filename), "%s%s%s_%d.out", inputdir, expected_dir, testname, outputno); expected = slurpfile(filename, &expected_len); if (expected == NULL) { if (outputno == 0) bailout("could not open file %s: %s\n", filename, strerror(ENOENT)); break; } if (expected_len == result_len && memcmp(expected, result, expected_len) == 0) { /* The files are equal. */ free(result); free(expected); return 0; } /* Ignore the difference between CR LF, LF and CR line break */ for (i = 0, j = 0, se = sr = '\0'; i < expected_len && j < result_len; se = expected[i], sr = result[j], i++, j++) { if (expected[i] == result[j]) continue; if (result[j] == LF) { if (expected[i] == CR) { i++; if (expected[i] != LF) i--; continue; } else if (sr == CR && se == CR) { i--; continue; } } else if (expected[i] == LF) { if (result[j] == CR) { j++; if (result[j] != LF) j--; continue; } else if (sr == CR && se == CR) { j--; continue; } } break; } if (i >= expected_len && j >= result_len) { /* The files are equal. */ free(result); free(expected); return 0; } free(expected); outputno++; } /* no matching output found */ if (NULL != result) free(result); /* * Try to run diff. If this fails on Windows system, use fc command * instead. */ #ifdef WIN32 if (first_call) { char cmdline[1024], file[256]; int i; for (i = 0; i < sizeof(diffi) / sizeof(diffi[0]); i++) { /* * test diff the same file */ snprintf(file, sizeof(file), "results\\%s.out", testname); snprintf(cmdline, sizeof(cmdline), diffi[i].cmd, file, file, " > nul 2>&1"); /* * If diff command exists, the system function would * return 0. */ if (system(cmdline) == 0) { exec_diffpgm = diffi[i].cmd; fprintf(stderr, "\tdiff command=%s\n", exec_diffpgm); break; } } first_call = 0; } #endif /* * We run the diff against all output files and print the smallest * diff. */ no_spec = 0; if (outputno > 1) { const char *tmpdiff = "tmpdiff.diffs"; char outfmt[32]; int fd, file_size; struct stat stbuf; int min_size = -1; snprintf(outfmt, sizeof(outfmt), "> %s", tmpdiff); for (i = 0; i < outputno; i++) { call_diff(inputdir, expected_dir, testname, i, result_dir, outfmt); if ((fd = open(tmpdiff, O_RDONLY)) < 0) break; if (fstat(fd, &stbuf) == -1) break; if (file_size = stbuf.st_size, file_size == 0) { min_size = 0; no_spec = i; } else if (min_size < 0) min_size = file_size; else if (file_size < min_size) { no_spec = i; min_size = file_size; } close(fd); } remove(tmpdiff); if (min_size == 0) return 0; } diff_rtn = call_diff(inputdir, expected_dir, testname, no_spec, result_dir, ">> regression.diffs"); return diff_rtn; } /* * Reads file to memory. The file is returned, or NULL if it doesn't exist. * Length is returned in *len. */ static char * slurpfile(const char *filename, size_t *len) { int fd; struct stat stbuf; int readlen; off_t filelen; char *p; #ifdef WIN32 fd = open(filename, O_RDONLY | O_BINARY, 0); #else fd = open(filename, O_RDONLY, 0); #endif if (fd == -1) { if (errno == ENOENT) return NULL; bailout("could not open file %s: %s\n", filename, strerror(errno)); } if (fstat(fd, &stbuf) < 0) bailout("fstat failed on file %s: %s\n", filename, strerror(errno)); filelen = stbuf.st_size; p = malloc(filelen + 1); if (!p) bailout("out of memory reading file %s\n", filename); readlen = read(fd, p, filelen); if (readlen != filelen) bailout("read only %d bytes out of %d from %s\n", (int) readlen, (int) filelen, filename); p[readlen] = '\0'; close(fd); *len = readlen; return p; } psqlodbc-REL-16_00_0005/test/sampletables.sql000066400000000000000000000053621462406103600206600ustar00rootroot00000000000000-- This file creates some tables to be used in the tests. -- -- Note that the reset-db program that reads this file is dumb and reads -- it one line at a time. Hence each statement must be on a single line. CREATE TABLE testtab1 (id integer PRIMARY KEY, t varchar(20)); INSERT INTO testtab1 VALUES (1, 'foo'); INSERT INTO testtab1 VALUES (2, 'bar'); INSERT INTO testtab1 VALUES (3, 'foobar'); CREATE TABLE testtab_fk (id integer REFERENCES testtab1, t varchar(20)); INSERT INTO testtab_fk VALUES (1, 'hoge'); INSERT INTO testtab_fk VALUES (2, 'pogno'); INSERT INTO testtab_fk VALUES (3, 'poco'); CREATE TABLE byteatab (id integer, t bytea); INSERT INTO byteatab VALUES (1, E'\\001\\002\\003\\004\\005\\006\\007\\010'::bytea); INSERT INTO byteatab VALUES (2, 'bar'); INSERT INTO byteatab VALUES (3, 'foobar'); INSERT INTO byteatab VALUES (4, 'foo'); INSERT INTO byteatab VALUES (5, 'barf'); CREATE TABLE intervaltable(id integer, iv interval, d varchar(100)); INSERT INTO intervaltable VALUES (1, '1 day', 'one day'); INSERT INTO intervaltable VALUES (2, '10 seconds', 'ten secs'); INSERT INTO intervaltable VALUES (3, '100 years', 'hundred years'); CREATE TABLE booltab (id integer, t varchar(5), b boolean); INSERT INTO booltab VALUES (1, 'yeah', true); INSERT INTO booltab VALUES (2, 'yes', true); INSERT INTO booltab VALUES (3, 'true', true); INSERT INTO booltab VALUES (4, 'false', false); INSERT INTO booltab VALUES (5, 'not', false); -- View CREATE VIEW testview AS SELECT * FROM testtab1; -- Materialized view CREATE MATERIALIZED VIEW testmatview AS SELECT * FROM testtab1; -- Foreign table CREATE FOREIGN DATA WRAPPER testfdw; CREATE SERVER testserver FOREIGN DATA WRAPPER testfdw; CREATE FOREIGN TABLE testforeign (c1 int) SERVER testserver; -- Procedure for catalog function checks CREATE FUNCTION simple_add(in int, in int, out int) AS $$ SELECT $1 + $2; $$ LANGUAGE SQL; -- Function Returning composite type CREATE FUNCTION getfoo(int) RETURNS booltab AS $$ SELECT * FROM booltab WHERE id = $1; $$ LANGUAGE SQL; -- Function Returning set of composite type CREATE FUNCTION getboo(int) RETURNS SETOF booltab AS $$ SELECT * FROM booltab WHERE id = $1; $$ LANGUAGE SQL; -- Function Returning table CREATE FUNCTION tbl_arg(in p_f1 int) returns table(p_f2 text, p_f3 boolean) AS $$ SELECT t, b from booltab where id = p_f1; $$ LANGUAGE SQL; -- The previous one is equivalent to using one or more OUT parameters -- plus marking the function as returning SETOF record (or SETOF a single -- output parameter's type, as appropriate). CREATE FUNCTION set_of(in p_f1 int, out p_f2 text, out p_f3 boolean) returns setof record AS $$ SELECT t, b from booltab where id = p_f1; $$ LANGUAGE SQL; -- Large object support CREATE DOMAIN lo AS oid; CREATE TABLE lo_test_tab (id int4, large_data lo); psqlodbc-REL-16_00_0005/test/src/000077500000000000000000000000001462406103600162445ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/test/src/.gitignore000066400000000000000000000000071462406103600202310ustar00rootroot00000000000000*-test psqlodbc-REL-16_00_0005/test/src/alter-test.c000066400000000000000000000024421462406103600204760ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Create a table to test with */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE testtbl(t varchar(40))", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /**** A simple query against the table, fetch column info ****/ rc = SQLExecDirect(hstmt, "SELECT * FROM testtbl", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Get column metadata */ print_result_meta(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Alter the table */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "ALTER TABLE testtbl ALTER COLUMN t TYPE varchar(80)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Run the query again, check if the metadata was updated */ rc = SQLExecDirect(hstmt, "SELECT * FROM testtbl", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Get column metadata */ print_result_meta(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/arraybinding-test.c000066400000000000000000000145101462406103600220370ustar00rootroot00000000000000#include #include #include "common.h" #define ARRAY_SIZE 10000 #define ARRAY_SIZE_SMALL 5 int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char *sql; int i; SQLUINTEGER int_array[ARRAY_SIZE]; SQLCHAR str_array[ARRAY_SIZE][30]; SQLCHAR str_array2[ARRAY_SIZE][6]; SQLLEN int_ind_array[ARRAY_SIZE]; SQLLEN str_ind_array[ARRAY_SIZE]; SQLUSMALLINT status_array[ARRAY_SIZE]; SQLULEN nprocessed; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } sql = "CREATE TEMPORARY TABLE tmptable (i int4, t text)"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * 1. Test column-wise binding */ for (i = 0; i < ARRAY_SIZE; i++) { int_array[i] = i; int_ind_array[i] = 0; sprintf(str_array[i], "columnwise %d", i); str_ind_array[i] = SQL_NTS; } SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &nprocessed, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) ARRAY_SIZE, 0); /* Bind the parameter arrays. */ SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, int_array, 0, int_ind_array); SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 29, 0, str_array, 30, str_ind_array); /* Execute */ sql = "INSERT INTO tmptable VALUES (?, ?)"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch results */ printf("Parameter Status\n"); for (i = 0; i < nprocessed; i++) { switch (status_array[i]) { case SQL_PARAM_SUCCESS: case SQL_PARAM_SUCCESS_WITH_INFO: break; case SQL_PARAM_ERROR: printf("%d\tError\n", i); break; case SQL_PARAM_UNUSED: printf("%d\tUnused\n", i); break; case SQL_PARAM_DIAG_UNAVAILABLE: printf("%d\tDiag unavailable\n", i); break; } } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Free and allocate a new handle for the next SELECT statement, as we don't * want to array bind that one. The parameters set with SQLSetStmtAttr * survive SQLFreeStmt. */ rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); CHECK_STMT_RESULT(rc, "SQLFreeHandle failed", hstmt); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Check that all the rows were inserted */ sql = "SELECT COUNT(*) FROM tmptable"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check the contents of a few rows */ sql = "SELECT * FROM tmptable WHERE i IN (0, 1, 100, 9999, 10000) ORDER BY i"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * 2. Test column-wise binding. With a column_size=5 VARCHAR param - that * causes the driver to do a server-side prepare, assuming BoolsAsChar=1. */ /* a small array will do for this test */ for (i = 0; i < ARRAY_SIZE_SMALL; i++) { sprintf(str_array2[i], "%d", 100+i); str_ind_array[i] = SQL_NTS; } SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &nprocessed, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) ARRAY_SIZE_SMALL, 0); /* Bind the parameter array. */ SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 5, 0, str_array2, 6, str_ind_array); /* Execute */ sql = "DELETE FROM tmptable WHERE i = ? RETURNING (t)"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch results */ printf("Parameter Status\n"); for (i = 0; i < nprocessed; i++) { switch (status_array[i]) { case SQL_PARAM_SUCCESS: case SQL_PARAM_SUCCESS_WITH_INFO: break; case SQL_PARAM_ERROR: printf("%d\tError\n", i); break; case SQL_PARAM_UNUSED: printf("%d\tUnused\n", i); break; case SQL_PARAM_DIAG_UNAVAILABLE: printf("%d\tDiag unavailable\n", i); break; } } printf ("Fetching result sets for array bound (%u results expected)\n", (unsigned int) nprocessed); for (i = 1; rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO; i++) { printf("%d: ", i); print_result(hstmt); rc = SQLMoreResults(hstmt); } if (rc != SQL_NO_DATA) CHECK_STMT_RESULT(rc, "SQLMoreResults failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Free and allocate a new handle for the next SELECT statement, as we don't * want to array bind that one. The parameters set with SQLSetStmtAttr * survive SQLFreeStmt. */ rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); CHECK_STMT_RESULT(rc, "SQLFreeHandle failed", hstmt); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Check that all the rows were inserted */ printf("Number of rows in table:\n"); sql = "SELECT COUNT(*) FROM tmptable"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check the contents of a few rows */ sql = "SELECT * FROM tmptable WHERE i IN (0, 1, 100, 9999, 10000) ORDER BY i"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/bindcol-test.c000066400000000000000000000045041462406103600210020ustar00rootroot00000000000000#include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; /* * NOTE: in the psqlodbc, we assume that SQL_C_LONG actually means a * variable of type SQLINTEGER. They are not the same on platforms where * "long" is a 64-bit integer. That seems a bit bogus, but it's too late * to change that without breaking applications that depend on it. * (on little-endian systems, you won't notice the difference if you reset * the high bits to zero before calling SQLBindCol.) */ SQLINTEGER longvalue; SQLLEN indLongvalue; char charvalue[100]; SQLLEN indCharvalue; int rowno; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLBindCol(hstmt, 1, SQL_C_LONG, &longvalue, 0, &indLongvalue); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLBindCol(hstmt, 2, SQL_C_CHAR, &charvalue, sizeof(charvalue), &indCharvalue); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, 'foo' || id FROM generate_series(1, 10) id", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); printf("Result set:\n"); rowno = 0; while(1) { rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc == SQL_SUCCESS) { printf("%ld %s\n", (long) longvalue, charvalue); } else { print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* * At row 3, unbind the text field. At row 5, bind it again. * At row 7, unbind both columns with SQLFreeStmt(SQL_UNBIND). * At row 9, bind text field again. */ rowno++; if (rowno == 3) { rc = SQLBindCol(hstmt, 2, SQL_C_CHAR, NULL, 0, NULL); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); } if (rowno == 7) { rc = SQLFreeStmt(hstmt, SQL_UNBIND); CHECK_STMT_RESULT(rc, "SQLFreeStmt(SQL_UNBIND) failed", hstmt); } if (rowno == 5 || rowno == 9) { rc = SQLBindCol(hstmt, 2, SQL_C_CHAR, &charvalue, sizeof(charvalue), &indCharvalue); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); } } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/bookmark-test.c000066400000000000000000000110611462406103600211710ustar00rootroot00000000000000#include #include #include #include "common.h" static void printFetchResult(HSTMT hstmt, int rc) { if (SQL_SUCCEEDED(rc)) { char buf[40]; SQLLEN ind; if (rc == SQL_SUCCESS_WITH_INFO) print_diag("got SUCCESS_WITH_INFO", SQL_HANDLE_STMT, hstmt); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("fetched: %s\n", buf); } else if (rc == SQL_NO_DATA) printf("Fetch: no data found\n"); /* expected */ else CHECK_STMT_RESULT(rc, "Fetch failed", hstmt); } static void testBookmarks(HSTMT hstmt) { char book_before[100]; SQLLEN book_before_ind; char book_middle[100]; SQLLEN book_middle_ind; int rc; /* Make the cursor scrollable */ rc = SQLSetStmtAttr(hstmt, SQL_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /* Enable bookmarks */ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_USE_BOOKMARKS, (SQLPOINTER) SQL_UB_VARIABLE, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /* * Fetch a large result set. */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo' || g FROM generate_series(1, 3210) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Get a bookmark that points to the beginning of the result set */ printf("Getting bookmark to beginning of result set...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); rc = SQLGetData(hstmt, 0, SQL_C_VARBOOKMARK, book_before, sizeof(book_before), &book_before_ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("Moving +100...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 100); printFetchResult(hstmt, rc); /* Get a bookmark that points to the middle of the result set */ printf("Getting bookmark to middle of result set...\n"); rc = SQLGetData(hstmt, 0, SQL_C_VARBOOKMARK, book_middle, sizeof(book_middle), &book_middle_ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); /*** Ok, test SQLFetchScroll with the bookmark ***/ printf("Moving +100...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 100); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_BOOKMARK, begin (0)...\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_FETCH_BOOKMARK_PTR, (SQLPOINTER) book_before, SQL_IS_POINTER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_BOOKMARK, begin (10)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, 10); printFetchResult(hstmt, rc); /*** Test SQLFetchScroll with the middle bookmark ***/ printf("Testing SQL_FETCH_BOOKMARK, middle (0)...\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_FETCH_BOOKMARK_PTR, (SQLPOINTER) book_middle, SQL_IS_POINTER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_BOOKMARK, middle (10)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, 10); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_BOOKMARK, middle (-10)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, -10); printFetchResult(hstmt, rc); /*** Test getting a bookmark with SQLBindCol */ printf("Getting bookmark with SQLBindCol...\n"); rc = SQLBindCol(hstmt, 0, SQL_C_VARBOOKMARK, book_middle, sizeof(book_middle), &book_middle_ind); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 100); printFetchResult(hstmt, rc); printf("Unbinding boomark column...\n"); rc = SQLBindCol(hstmt, 0, SQL_C_VARBOOKMARK, NULL, 0, NULL); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); printf("Moving +100...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 100); printFetchResult(hstmt, rc); printf("Goind back to bookmark acquired with SQLBindCol...\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_FETCH_BOOKMARK_PTR, (SQLPOINTER) book_middle, SQL_IS_POINTER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_BOOKMARK, 0); printFetchResult(hstmt, rc); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } testBookmarks(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/boolsaschar-test.c000066400000000000000000000043271462406103600216730ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char *param1; SQLLEN cbParam1; SQLSMALLINT colid; /* BoolsAsChar is the default, but just in case.. */ test_connect_ext("BoolsAsChar=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** A simple query with one text param ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t, b FROM booltab WHERE t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ param1 = "yes"; cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_VARCHAR, /* param type */ 5, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ colid = 3; print_result_meta_series(hstmt, &colid, 1); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** A simple query with one boolean param (passed as varchar) ****/ /* bind param */ param1 = "true"; cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_VARCHAR, /* param type */ 5, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, t, b FROM booltab WHERE b = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch result */ colid = 3; print_result_meta_series(hstmt, &colid, 1); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/bulkoperations-test.c000066400000000000000000000135751462406103600224410ustar00rootroot00000000000000/* * Test SQLBulkOperations() */ #include #include #include #include "common.h" void printCurrentRow(HSTMT hstmt) { char buf[40]; int col; SQLLEN ind; int rc; for (col = 1; col <= 2; col++) { rc = SQLGetData(hstmt, col, SQL_C_CHAR, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); exit(1); } if (ind == SQL_NULL_DATA) strcpy(buf, "NULL"); printf("%s%s", (col > 1) ? "\t" : "", buf); } printf("\n"); } #define BOOKMARK_SIZE 14 int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; int i; SQLINTEGER colvalue1; SQLINTEGER colvalue2; SQLLEN indColvalue1; SQLLEN indColvalue2; char bookmark[BOOKMARK_SIZE]; SQLLEN bookmark_ind; char saved_bookmarks[3][BOOKMARK_SIZE]; SQLLEN saved_bookmark_inds[3]; SQLINTEGER colvalues1[3]; SQLINTEGER colvalues2[3]; SQLLEN indColvalues1[3]; SQLLEN indColvalues2[3]; memset(bookmark, 0x7F, sizeof(bookmark)); memset(saved_bookmarks, 0xF7, sizeof(saved_bookmarks)); test_connect_ext("UpdatableCursors=1;Fetch=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Initialize a table with some test data. */ printf("Creating test table bulkoperations_test\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE bulkoperations_test(i int4, orig serial)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO bulkoperations_test SELECT g, g FROM generate_series(1, 10) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); printf("Opening a cursor for update, and fetching 10 rows\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /* Enable bookmarks */ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_USE_BOOKMARKS, (SQLPOINTER) SQL_UB_VARIABLE, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLBindCol(hstmt, 0, SQL_C_VARBOOKMARK, &bookmark, sizeof(bookmark), &bookmark_ind); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_LONG, &colvalue1, 0, &indColvalue1); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLBindCol(hstmt, 2, SQL_C_LONG, &colvalue2, 0, &indColvalue2); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM bulkoperations_test ORDER BY orig", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); for (i = 1; i <= 5; i++) { rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc == SQL_SUCCESS) printCurrentRow(hstmt); else { print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* Save row # 2's bookmark for fetch test */ if (i == 2) { memcpy(saved_bookmarks[0], bookmark, bookmark_ind); saved_bookmark_inds[0] = bookmark_ind; } } /* Do a positioned update and delete */ printf("\nUpdating result set\n"); colvalue1 += 100; rc = SQLBulkOperations(hstmt, SQL_UPDATE_BY_BOOKMARK); CHECK_STMT_RESULT(rc, "SQLBulkOperations failed", hstmt); /* Have to use an absolute position after SQLBulkOperations. */ rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 8); CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); rc = SQLBulkOperations(hstmt, SQL_DELETE_BY_BOOKMARK); CHECK_STMT_RESULT(rc, "SQLBulkOperations failed", hstmt); /* Have to use an absolute position after SQLBulkOperations. */ rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 5); CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); /* Print the updated row */ printCurrentRow(hstmt); /* remember its bookmark for later fetch */ memcpy(saved_bookmarks[1], bookmark, bookmark_ind); saved_bookmark_inds[1] = bookmark_ind; /* Perform an insertion */ colvalue1 = 1234; colvalue2 = 5678; rc = SQLBulkOperations(hstmt, SQL_ADD); CHECK_STMT_RESULT(rc, "SQLBulkOperations failed", hstmt); /* Remember the bookmark of the inserted row */ memcpy(saved_bookmarks[2], bookmark, bookmark_ind); saved_bookmark_inds[2] = bookmark_ind; /**** Test bulk fetch *****/ printf("Testing bulk fetch of original, updated, and inserted rows\n"); rc = SQLBindCol(hstmt, 0, SQL_C_VARBOOKMARK, saved_bookmarks, sizeof(bookmark), saved_bookmark_inds); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_LONG, colvalues1, 0, indColvalues1); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLBindCol(hstmt, 2, SQL_C_LONG, colvalues2, 0, indColvalues2); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) 3, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLBulkOperations(hstmt, SQL_FETCH_BY_BOOKMARK); CHECK_STMT_RESULT(rc, "SQLBulkOperations failed", hstmt); printf ("row no #2: %d - %d\n", colvalues1[0], colvalues2[0]); printf ("updated row: %d - %d\n", colvalues1[1], colvalues2[1]); printf ("inserted row: %d - %d\n", colvalues1[2], colvalues2[2]); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) 1, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /**** See if the updates really took effect ****/ printf("\nQuerying the table again\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM bulkoperations_test ORDER BY orig", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/catalogfunctions-test.c000066400000000000000000000245331462406103600227370ustar00rootroot00000000000000/* * This test is used to check the output and processing of the catalog * functions listed as below: * - SQLGetTypeInfo * - SQLTables * - SQLColumns * - SQLSpecialColumns * - SQLStatistics * - SQLPrimaryKeys * - SQLForeignKeys * - SQLProcedureColumns * - SQLTablePrivileges * - SQLColumnPrivileges * - SQLProcedures * - SQLGetInfo */ #include #include #include #include "common.h" /* define a macro to simplify function calls */ #define PRINT_RESULT_SERIES(hstmt, idarray, rowcount) print_result_series(hstmt, idarray, sizeof(idarray)/sizeof(idarray[0]), rowcount, FALSE) int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; /* Cases where output is limited to relevant information only */ SQLSMALLINT sql_tab_privileges_ids[6] = {1, 2, 3, 4, 6, 7}; SQLSMALLINT sql_column_privileges_ids[6] = {1, 2, 3, 4, 7, 8}; SQLSMALLINT sql_column_ids[6] = {1, 2, 3, 4, 5, 6}; SQLSMALLINT sql_pro_column_ids[] = {1, 2, 3, 4, 5, 6, 7}; char buf[1000]; char username[100]; SQLSMALLINT len; int i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } SQLExecDirect(hstmt, (SQLCHAR *) "drop table if exists testtab2", SQL_NTS); /* Check for SQLGetTypeInfo */ printf("Check for SQLTypeInfo\n"); rc = SQLGetTypeInfo(hstmt, SQL_VARCHAR); CHECK_STMT_RESULT(rc, "SQLGetTypeInfo failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLTables */ printf("Check for SQLTables\n"); rc = SQLTables(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "%", SQL_NTS, (SQLCHAR *) "TABLE", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLColumns */ printf("Check for SQLColumns\n"); rc = SQLColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "%", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLColumns failed", hstmt); print_result_meta(hstmt); /* * Print only the 6 first columns, we do not want for example * to get the OID in output, and this information looks to be * enough. */ PRINT_RESULT_SERIES(hstmt, sql_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLColumnPrivileges */ printf("Check for SQLColumnPrivileges\n"); rc = SQLColumnPrivileges(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS, (SQLCHAR *) "id", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLColumnPrivileges failed", hstmt); print_result_meta(hstmt); PRINT_RESULT_SERIES(hstmt, sql_column_privileges_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLSpecialColumns */ printf("Check for SQLSpecialColumns\n"); rc = SQLSpecialColumns(hstmt, SQL_ROWVER, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS, SQL_SCOPE_SESSION, SQL_NO_NULLS); CHECK_STMT_RESULT(rc, "SQLSpecialColumns failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLStatistics. It is important to note that this function * returns statistics like the number of pages used and the number of * index scans. */ printf("Check for SQLStatistics\n"); rc = SQLStatistics(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS, 0, 0); CHECK_STMT_RESULT(rc, "SQLStatistics failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLPrimaryKeys */ printf("Check for SQLPrimaryKeys\n"); rc = SQLPrimaryKeys(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrimaryKeys failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLForeignKeys */ printf("Check for SQLForeignKeys\n"); rc = SQLForeignKeys(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab_fk", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLForeignKeys failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLProcedures */ printf("Check for SQLProcedures\n"); rc = SQLProcedures(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "simple_add", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLProcedures failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLProcedureColumns */ printf("Check for SQLProcedureColumns\n"); rc = SQLProcedureColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "simple_add", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); print_result_meta(hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLProcedureColumns for a function * returning normal type */ rc = SQLProcedureColumns(hstmt, NULL, 0, NULL, 0, (SQLCHAR *) "set_byte", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); PRINT_RESULT_SERIES(hstmt, sql_pro_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLProcedureColumns for a function * returning composite type */ rc = SQLProcedureColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "getfoo", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); PRINT_RESULT_SERIES(hstmt, sql_pro_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLProcedureColumns for a function * returning setof composite type */ rc = SQLProcedureColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "getboo", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); PRINT_RESULT_SERIES(hstmt, sql_pro_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLProcedureColumns for a function * returning table */ rc = SQLProcedureColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "tbl_arg", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); PRINT_RESULT_SERIES(hstmt, sql_pro_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check for SQLProcedureColumns for a function with OUT * parameters returning setof * This is equivalent to tbl_arg. */ rc = SQLProcedureColumns(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "set_of", SQL_NTS, NULL, 0); CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); PRINT_RESULT_SERIES(hstmt, sql_pro_column_ids, -1); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check for SQLTablePrivileges */ printf("Check for SQLTablePrivileges\n"); rc = SQLTablePrivileges(hstmt, NULL, 0, (SQLCHAR *) "public", 0, (SQLCHAR *) "testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTablePrivileges failed", hstmt); print_result_meta(hstmt); PRINT_RESULT_SERIES(hstmt, sql_tab_privileges_ids, 5); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Test SQLGetInfo */ printf("Check for SQLGetInfo\n"); rc = SQLGetInfo(conn, SQL_TABLE_TERM, buf, sizeof(buf), &len); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); printf("Term for \"table\": %s\n", buf); /**** * Misc extra tests. */ /* * Older versions of the driver had a bug in handling table-types lists * longer than 32 entries. Check for that. */ rc = SQLTables(hstmt, "", SQL_NTS, "public", SQL_NTS, "testtab%", SQL_NTS, "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5, TABLES", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Older versions of the driver had a buffer overflow bug in handling table * patterns with lots of escapes, with standard_conforming_strings=off. * Check for that. */ for (i = 0; i < sizeof(buf) - 1; i++) buf[i] = '\\'; buf[i] = '\0'; rc = SQLTables(hstmt, "", SQL_NTS, "public", SQL_NTS, buf, SQL_NTS, "TABLES", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check that things work with an invalid search_path. current_schema() * returns NULL in that case, which used to cause a segfault. * * Perform these tests in a fresh connection, so that we don't use a * cached current_schema value. */ test_disconnect(); test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "failed to allocate stmt handle", conn); rc = SQLExecDirect(hstmt, (SQLCHAR *) "set search_path='bogus_schema'", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLGetInfo(conn, SQL_USER_NAME, username, sizeof(username), &len); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); rc = SQLTables(hstmt, "", SQL_NTS, username, SQL_NTS, "testtab%", SQL_NTS, "", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/colattribute-test.c000066400000000000000000000042561462406103600220750ustar00rootroot00000000000000/* * Test SQLColAttribute */ #include #include #include #include "common.h" static void runtest(char *extra_conn_options) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLUSMALLINT i; SQLSMALLINT numcols; printf("Running tests with %s...\n", extra_conn_options); /* The behavior of these tests depend on the UnknownSizes parameter */ test_connect_ext(extra_conn_options); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Get column attributes of a simple query. */ printf("Testing SQLColAttribute...\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT '1'::int AS intcol, 'foobar'::text AS textcol, 'varchar string'::varchar as varcharcol, ''::varchar as empty_varchar_col, 'varchar-5-col'::varchar(5) as varchar5col, '5 days'::interval day to second", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLNumResultCols(hstmt, &numcols); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); for (i = 1 ; i <= numcols; i++) { char buffer[64]; SQLLEN number; rc = SQLColAttribute(hstmt, i, SQL_DESC_LABEL, buffer, sizeof(buffer), NULL, NULL); CHECK_STMT_RESULT(rc, "SQLColAttribute failed", hstmt); printf("\n-- Column %d: %s --\n", i, buffer); rc = SQLColAttribute(hstmt, i, SQL_DESC_OCTET_LENGTH, NULL, SQL_IS_INTEGER, NULL, &number); CHECK_STMT_RESULT(rc, "SQLColAttribute failed", hstmt); printf("SQL_DESC_OCTET_LENGTH: %d\n", (int) number); rc = SQLColAttribute(hstmt, i, SQL_DESC_TYPE_NAME, buffer, sizeof(buffer), NULL, NULL); CHECK_STMT_RESULT(rc, "SQLColAttribute failed", hstmt); printf("SQL_DESC_TYPE_NAME: %s\n", buffer); } /* Clean up */ test_disconnect(); } int main(int argc, char **argv) { /* * The output of these tests depend on the UnknownSizes and * MaxVarcharSize parameters */ // runtest("UnknownSizes=-1;MaxVarcharSize=100"); meaningless runtest("UnknownSizes=0;MaxVarcharSize=100"); runtest("UnknownSizes=1;MaxVarcharSize=100"); runtest("UnknownSizes=2;MaxVarcharSize=100"); // runtest("UnknownSizes=100;MaxVarcharSize=100"); meaningless return 0; } psqlodbc-REL-16_00_0005/test/src/commands-test.c000066400000000000000000000047131462406103600211730ustar00rootroot00000000000000#include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Test VACUUM */ printf("Testing VACUUM with SQLExecDirect...\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "vacuum (analyze) testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Same with SQLPrepare/SQLExecute */ printf("Testing VACUUM with SQLPrepare/SQLExecute...\n"); rc = SQLPrepare(hstmt, (SQLCHAR *) "VACUUM ANALYZE testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Now the same with autocommit disabled. The driver should recognize * that the commands are VACUUMs, which cannot be run in a transaction * block, and not issue a BEGIN even it normally would in autocommit * mode. In other words, these commands should behave the same with or * without autocommit. But if you issued a normal query, like a SELECT, * first in the same transaction, and then tried to run a VACUUM, it * would fail with "VACUUM cannot run inside a transaction block" error. */ printf("Disabling autocommit...\n"); rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetConnectAttr failed", hstmt); /* Test VACUUM */ printf("Testing VACUUM with SQLExecDirect...\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "vacuum analyze testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Same with SQLPrepare/SQLExecute */ printf("Testing VACUUM with SQLPrepare/SQLExecute...\n"); rc = SQLPrepare(hstmt, (SQLCHAR *) "VACUUM (ANALYZE) testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/common.c000066400000000000000000000205361462406103600177060ustar00rootroot00000000000000#include "common.h" SQLHENV env; SQLHDBC conn; void print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle) { char sqlstate[32]; char message[1000]; SQLINTEGER nativeerror; SQLSMALLINT textlen; SQLRETURN ret; SQLSMALLINT recno = 0; if (msg) printf("%s\n", msg); do { recno++; ret = SQLGetDiagRec(htype, handle, recno, sqlstate, &nativeerror, message, sizeof(message), &textlen); if (ret == SQL_INVALID_HANDLE) printf("Invalid handle\n"); else if (SQL_SUCCEEDED(ret)) printf("%s=%s\n", sqlstate, message); } while (ret == SQL_SUCCESS); if (ret == SQL_NO_DATA && recno == 1) printf("No error information\n"); } const char * const default_dsn = "psqlodbc_test_dsn"; const char * const test_dsn_env = "PSQLODBC_TEST_DSN"; const char * const test_dsn_ansi = "psqlodbc_test_dsn_ansi"; const char *get_test_dsn(void) { char *env = getenv(test_dsn_env); if (NULL != env && env[0]) return env; return default_dsn; } int IsAnsi(void) { return (NULL != strstr(get_test_dsn(), "_ansi")); } void test_connect_ext(char *extraparams) { SQLRETURN ret; SQLCHAR str[1024]; SQLSMALLINT strl; SQLCHAR dsn[1024]; const char * const test_dsn = get_test_dsn(); char *envvar; /* * Use an environment variable to switch settings of connection * strings throughout the regression test. Note that extraparams * parameters have precedence over the environment variable. * ODBC spec says * If any keywords are repeated in the connection string, * the driver uses the value associated with the first * occurrence of the keyword. * But the current psqlodbc driver uses the value associated with * the last occurrence of the keyword. Here we place extraparams * both before and after the value of the environment variable * so as to protect the priority order whichever way we take. */ if ((envvar = getenv("COMMON_CONNECTION_STRING_FOR_REGRESSION_TEST")) != NULL && envvar[0] != '\0') { if (NULL == extraparams) snprintf(dsn, sizeof(dsn), "DSN=%s;%s", test_dsn, envvar); else snprintf(dsn, sizeof(dsn), "DSN=%s;%s;%s;%s", test_dsn, extraparams, envvar, extraparams); } else snprintf(dsn, sizeof(dsn), "DSN=%s;%s", test_dsn, extraparams ? extraparams : ""); SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); ret = SQLDriverConnect(conn, NULL, dsn, SQL_NTS, str, sizeof(str), &strl, SQL_DRIVER_COMPLETE); if (SQL_SUCCEEDED(ret)) { printf("connected\n"); } else { print_diag("SQLDriverConnect failed.", SQL_HANDLE_DBC, conn); fflush(stdout); exit(1); } } void test_connect(void) { test_connect_ext(NULL); } void test_disconnect(void) { SQLRETURN rc; printf("disconnecting\n"); rc = SQLDisconnect(conn); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLDisconnect failed", SQL_HANDLE_DBC, conn); fflush(stdout); exit(1); } rc = SQLFreeHandle(SQL_HANDLE_DBC, conn); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeHandle failed", SQL_HANDLE_DBC, conn); fflush(stdout); exit(1); } conn = NULL; rc = SQLFreeHandle(SQL_HANDLE_ENV, env); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeHandle failed", SQL_HANDLE_ENV, env); fflush(stdout); exit(1); } env = NULL; } const char * datatype_str(SQLSMALLINT datatype) { static char buf[100]; switch (datatype) { case SQL_CHAR: return "CHAR"; case SQL_VARCHAR: return "VARCHAR"; case SQL_LONGVARCHAR: return "LONGVARCHAR"; case SQL_WCHAR: return "WCHAR"; case SQL_WVARCHAR: return "WVARCHAR"; case SQL_WLONGVARCHAR: return "WLONGVARCHAR"; case SQL_DECIMAL: return "DECIMAL"; case SQL_NUMERIC: return "NUMERIC"; case SQL_SMALLINT: return "SMALLINT"; case SQL_INTEGER: return "INTEGER"; case SQL_REAL: return "REAL"; case SQL_FLOAT: return "FLOAT"; case SQL_DOUBLE: return "DOUBLE"; case SQL_BIT: return "BIT"; case SQL_TINYINT: return "TINYINT"; case SQL_BIGINT: return "BIGINT"; case SQL_BINARY: return "BINARY"; case SQL_VARBINARY: return "VARBINARY"; case SQL_LONGVARBINARY: return "LONGVARBINARY"; case SQL_TYPE_DATE: return "TYPE_DATE"; case SQL_TYPE_TIME: return "TYPE_TIME"; case SQL_TYPE_TIMESTAMP: return "TYPE_TIMESTAMP"; case SQL_GUID: return "GUID"; default: snprintf(buf, sizeof(buf), "unknown sql type %d", datatype); return buf; } } const char *nullable_str(SQLSMALLINT nullable) { static char buf[100]; switch(nullable) { case SQL_NO_NULLS: return "not nullable"; case SQL_NULLABLE: return "nullable"; case SQL_NULLABLE_UNKNOWN: return "nullable_unknown"; default: snprintf(buf, sizeof(buf), "unknown nullable value %d", nullable); return buf; } } void print_result_meta_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols) { int i; printf("Result set metadata:\n"); for (i = 0; i < numcols; i++) { SQLRETURN rc; SQLCHAR colname[50]; SQLSMALLINT colnamelen; SQLSMALLINT datatype; SQLULEN colsize; SQLSMALLINT decdigits; SQLSMALLINT nullable; rc = SQLDescribeCol(hstmt, colids[i], colname, sizeof(colname), &colnamelen, &datatype, &colsize, &decdigits, &nullable); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLDescribeCol failed", SQL_HANDLE_STMT, hstmt); return; } printf("%s: %s(%u) digits: %d, %s\n", colname, datatype_str(datatype), (unsigned int) colsize, decdigits, nullable_str(nullable)); } } void print_result_meta(HSTMT hstmt) { SQLRETURN rc; SQLSMALLINT numcols, i; SQLSMALLINT *colids; rc = SQLNumResultCols(hstmt, &numcols); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt); return; } colids = (SQLSMALLINT *) malloc(numcols * sizeof(SQLSMALLINT)); for (i = 0; i < numcols; i++) colids[i] = i + 1; print_result_meta_series(hstmt, colids, numcols); free(colids); } /* * Initialize a buffer with "XxXxXx..." to indicate an uninitialized value. */ static void invalidate_buf(char *buf, size_t len) { size_t i; for (i = 0; i < len; i++) { if (i % 2 == 0) buf[i] = 'X'; else buf[i] = 'x'; } buf[len - 1] = '\0'; } /* * Print result only for the selected columns. */ void print_result_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols, SQLINTEGER rowcount, BOOL printcolnames) { SQLRETURN rc; SQLINTEGER rowc = 0; char buf[40]; int i; printf("Result set:\n"); if (printcolnames) { for (i = 1; i <= numcols; i++) { invalidate_buf(buf, sizeof(buf)); rc = SQLColAttribute(hstmt, i, SQL_DESC_LABEL, buf, sizeof(buf), NULL, NULL); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLColAttribute failed", SQL_HANDLE_STMT, hstmt); return; } printf("%s%s", (i > 1) ? "\t" : "", buf); } printf("\n"); } while (rowcount <0 || rowc < rowcount) { rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc == SQL_SUCCESS) { SQLLEN ind; rowc++; for (i = 0; i < numcols; i++) { /* * Initialize the buffer with garbage, so that we see readily * if SQLGetData fails to set the value properly or forgets * to null-terminate it. */ invalidate_buf(buf, sizeof(buf)); rc = SQLGetData(hstmt, colids[i], SQL_C_CHAR, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); return; } if (ind == SQL_NULL_DATA) strcpy(buf, "NULL"); printf("%s%s", (i > 0) ? "\t" : "", buf); } printf("\n"); } else { print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt); fflush(stdout); exit(1); } } } /* * Print result on all the columns */ void print_result_all(HSTMT hstmt, BOOL printcolnames) { SQLRETURN rc; SQLSMALLINT numcols, i; SQLSMALLINT *colids; rc = SQLNumResultCols(hstmt, &numcols); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt); return; } colids = (SQLSMALLINT *) malloc(numcols * sizeof(SQLSMALLINT)); for (i = 0; i < numcols; i++) colids[i] = i + 1; print_result_series(hstmt, colids, numcols, -1, printcolnames); free(colids); } /* * Print result on all the columns (without column names) */ void print_result(HSTMT hstmt) { print_result_all(hstmt, FALSE); } /* * Print result on all the columns (with column names) */ void print_result_with_column_names(HSTMT hstmt) { print_result_all(hstmt, TRUE); } psqlodbc-REL-16_00_0005/test/src/common.h000066400000000000000000000026421462406103600177110ustar00rootroot00000000000000#include #include #include #ifdef WIN32 #include #else #include "config.h" #ifndef TRUE #define TRUE (BOOL)1 #endif /* TRUE */ #ifndef FALSE #define FALSE (BOOL)0 #endif /* FALSE */ #endif #include #include #ifdef WIN32 #define snprintf _snprintf #endif extern SQLHENV env; extern SQLHDBC conn; #define CHECK_STMT_RESULT(rc, msg, hstmt) \ if (!SQL_SUCCEEDED(rc)) \ { \ print_diag(msg, SQL_HANDLE_STMT, hstmt); \ exit(1); \ } #define CHECK_CONN_RESULT(rc, msg, hconn) \ if (!SQL_SUCCEEDED(rc)) \ { \ print_diag(msg, SQL_HANDLE_DBC, hconn); \ exit(1); \ } extern void print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle); extern const char *get_test_dsn(void); extern int IsAnsi(void); extern void test_connect_ext(char *extraparams); extern void test_connect(void); extern void test_disconnect(void); extern void print_result_meta_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols); extern void print_result_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols, SQLINTEGER rowcount, BOOL printcolnames); extern void print_result_meta(HSTMT hstmt); extern void print_result(HSTMT hstmt); extern void print_result_with_column_names(HSTMT hstmt); extern const char *datatype_str(SQLSMALLINT datatype); extern const char *nullable_str(SQLSMALLINT nullable); psqlodbc-REL-16_00_0005/test/src/connect-test.c000066400000000000000000000063661462406103600210310ustar00rootroot00000000000000/* * Test functions related to establishing a connection. */ #include #include #include "common.h" static void test_SQLConnect() { SQLRETURN ret; SQLCHAR *dsn = (SQLCHAR *) get_test_dsn(); SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); printf("Connecting with SQLConnect..."); ret = SQLConnect(conn, dsn, SQL_NTS, NULL, 0, NULL, 0); if (SQL_SUCCEEDED(ret)) { printf("connected\n"); } else { print_diag("SQLConnect failed.", SQL_HANDLE_DBC, conn); return; } } /* * Test that attributes can be set *before* establishing a connection. (We * used to have a bug where it got reset when the per-DSN options were read.) */ static void test_setting_attribute_before_connect() { SQLRETURN ret; SQLCHAR str[1024]; SQLSMALLINT strl; SQLCHAR dsn[1024]; SQLULEN value; HSTMT hstmt = SQL_NULL_HSTMT; snprintf(dsn, sizeof(dsn), "DSN=%s", get_test_dsn()); SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); printf("Testing that autocommit persists SQLDriverConnect...\n"); /* Disable autocommit */ SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, 0); /* Connect */ ret = SQLDriverConnect(conn, NULL, dsn, SQL_NTS, str, sizeof(str), &strl, SQL_DRIVER_COMPLETE); if (SQL_SUCCEEDED(ret)) { printf("connected\n"); } else { print_diag("SQLDriverConnect failed.", SQL_HANDLE_DBC, conn); return; } /*** Test that SQLGetConnectAttr says that it's still disabled. ****/ value = 0; ret = SQLGetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, &value, 0, /* BufferLength, ignored for an int attribute */ NULL); CHECK_CONN_RESULT(ret, "SQLGetConnectAttr failed", conn); if (value == SQL_AUTOCOMMIT_ON) printf("autocommit is on (should've been off!)\n"); else if (value == SQL_AUTOCOMMIT_OFF) printf("autocommit is still off (correct).\n"); else printf("unexpected autocommit value: %lu\n", (unsigned long) value); /* * Test that we're really not autocommitting. * * Insert a row, then rollback, and check that the row is not there * anymore. */ ret = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(ret)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); return; } ret = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO testtab1 VALUES (10000, 'shouldn''t be here!')", SQL_NTS); CHECK_STMT_RESULT(ret, "SQLExecDirect failed", hstmt); ret = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(ret, "SQLFreeStmt failed", hstmt); ret = SQLTransact(SQL_NULL_HENV, conn, SQL_ROLLBACK); CHECK_CONN_RESULT(ret, "SQLTransact failed", conn); ret = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM testtab1 WHERE id = 10000", SQL_NTS); CHECK_STMT_RESULT(ret, "SQLExecDirect failed", hstmt); print_result(hstmt); test_disconnect(); } int main(int argc, char **argv) { /* the common test_connect() function uses SQLDriverConnect */ test_connect(); test_disconnect(); test_SQLConnect(); test_disconnect(); test_setting_attribute_before_connect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cte-test.c000066400000000000000000000051441462406103600201440ustar00rootroot00000000000000#include #include #include #include "common.h" static void runTest(HSTMT hstmt) { int rc; SQLINTEGER intparam; SQLLEN cbParam1; /**** A simple WITH-query ****/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "with recursive cte as (select g, 'foo' || g as foocol from generate_series(1,10) as g) select * from cte;", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** Same with SQLPrepare/SQLExecute and an integer param ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "with cte as (select g, 'foo' || g as foocol from generate_series(1,10) as g) select * from cte WHERE g < ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ intparam = 3; cbParam1 = sizeof(intparam); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_INTEGER, /* value type */ SQL_INTEGER, /* param type */ 0, /* column size (ignored for SQL_INTEGER) */ 0, /* dec digits */ &intparam, /* param value ptr */ sizeof(intparam), /* buffer len (ignored for SQL_INTEGER) */ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; /**** Test WITH-queries in with and without UseDeclareFetch. ****/ /* * This used to not work with older versions of the driver, because of * a bug. It was not covered by any of the existing regression tests. */ test_connect_ext("UseDeclareFetch=0"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } runTest(hstmt); /* Clean up */ test_disconnect(); /**** And then the same with UseDeclareFetch = 1 ****/ test_connect_ext("UseDeclareFetch=1;Fetch=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } runTest(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cursor-block-delete-test.c000066400000000000000000000116611462406103600232370ustar00rootroot00000000000000/* * Test deleting tuples all with scrolling block cursors BOF -> * EOF -> BOF -> ... */ #include #include #include #include "common.h" #define TOTAL 120 #define BLOCK 4 static HSTMT hstmte = SQL_NULL_HSTMT; static SQLRETURN delete_loop(HSTMT hstmt) { SQLRETURN rc; BOOL use_first_last = 0; int delcnt = 0, delsav, loopcnt = 0; SQLSMALLINT orientation = SQL_FETCH_FIRST; do { printf("\torientation=%d delete count=%d\n", orientation, delcnt); delsav = delcnt; if (use_first_last) orientation = (orientation == SQL_FETCH_NEXT ? SQL_FETCH_FIRST : SQL_FETCH_LAST); while (rc = SQLFetchScroll(hstmt, orientation, 0), SQL_SUCCEEDED(rc)) { orientation = (orientation == SQL_FETCH_NEXT ? SQL_FETCH_NEXT : (orientation == SQL_FETCH_FIRST ? SQL_FETCH_NEXT : SQL_FETCH_PRIOR)); rc = SQLSetPos(hstmt, 1, SQL_DELETE, SQL_LCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos delete failed", hstmt); delcnt++; } if (SQL_NO_DATA != rc) { CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); } orientation = (orientation == SQL_FETCH_NEXT ? SQL_FETCH_PRIOR : SQL_FETCH_NEXT); if (++loopcnt == 4) SQLExecDirect(hstmte, (SQLCHAR *) "savepoint miho", SQL_NTS); } while (delcnt != delsav); printf("delete all count %d\n", delcnt); return SQL_SUCCESS; } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; int i, j, k; int count = TOTAL; char query[100]; SQLLEN rowArraySize = BLOCK; SQLULEN rowsFetched; SQLINTEGER id[BLOCK]; SQLLEN cbLen[BLOCK]; /**** * Run this test with Fetch=37 when UseDeclareFecth=1. */ test_connect_ext("UpdatableCursors=1;Fetch=37"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmte); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle2", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLExecDirect(hstmt, (SQLCHAR *) "create temporary table tmptable(id serial primary key)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect create table failed", hstmt); /* insert into a table */ for (i = 0; i < count; i++) { snprintf(query, sizeof(query), "insert into tmptable values (%d)", i); rc = SQLExecDirect(hstmt, (SQLCHAR *) query, SQL_NTS); CHECK_STMT_RESULT(rc, "insert into table failed", hstmt); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Block cursor */ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, (SQLPOINTER) &rowsFetched, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr ROWS_FETCHED_PTR failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_SLONG, &id, 0, cbLen); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) rowArraySize, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr ROW_ARRAY_SIZE failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CONCURRENCY failed", hstmt); rc = SQLSetConnectAttr(conn, SQL_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, 0); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CURSOR_TYPE failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "select * from tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "select failed", hstmt); rc = SQLExecDirect(hstmte, (SQLCHAR *) "savepoint yuuki", SQL_NTS); CHECK_STMT_RESULT(rc, "savepoint failed", hstmte); /* * Scroll next -> EOF -> prior -> BOF -> next -> EOF -> * ...... */ delete_loop(hstmt); /* the 1st loop */ rc = SQLExecDirect(hstmte, (SQLCHAR *) "rollback to yuuki;release yuuki", SQL_NTS); CHECK_STMT_RESULT(rc, "rollback failed", hstmte); for (i = 0, j = count, i = 0; i < 2; i++) { for (k = 0; k < rowArraySize; k++) { cbLen[k] = 0; id[k] = j++; } /* rc = SQLBulkOperations(hstmt, SQL_ADD); CHECK_STMT_RESULT(rc, "SQLBulkOperations SQL_ADD failed", hstmt); */ rc = SQLSetPos(hstmt, 0, SQL_ADD, SQL_LCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos SQL_ADD failed", hstmt); if (0 == i) { rc = SQLExecDirect(hstmte, (SQLCHAR *) "savepoint yuuki", SQL_NTS); CHECK_STMT_RESULT(rc, "savpoint failed", hstmte); } } delete_loop(hstmt); /* the 2nd loop */ rc = SQLExecDirect(hstmte, (SQLCHAR *) "rollback to yuuki;release yuuki", SQL_NTS); CHECK_STMT_RESULT(rc, "rollback failed", hstmte); delete_loop(hstmt); /* the 3rd loop */ rc = SQLExecDirect(hstmte, (SQLCHAR *) "rollback to miho;release miho", SQL_NTS); CHECK_STMT_RESULT(rc, "rollback failed", hstmte); delete_loop(hstmt); /* the 4th loop */ rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_ROLLBACK); CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cursor-commit-test.c000066400000000000000000000041531462406103600221730ustar00rootroot00000000000000/* * This test case tests for a bug in result set caching, with * UseDeclareFetch=1, that was fixed. The bug occurred when a cursor was * closed, due to transaction commit, before any rows were fetched from * it. That set the "base" of the internal cached rowset incorrectly, * off by one. */ #include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLCHAR charval[100]; SQLLEN len; int row; test_connect(); /* Start a transaction */ rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /* * Begin executing a query */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT g FROM generate_series(1,3) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &charval, sizeof(charval), &len); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); /* Commit. This implicitly closes the cursor in the server. */ rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_COMMIT); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to commit", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLFetchScroll(hstmt, SQL_FETCH_FIRST, 0); CHECK_STMT_RESULT(rc, "SQLFetchScroll(FIRST) failed", hstmt); if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) printf("first row: %s\n", charval); row = 1; while (1) { rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); if (rc == SQL_NO_DATA) break; row++; if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) printf("row %d: %s\n", row, charval); else { print_diag("SQLFetchScroll failed", SQL_HANDLE_STMT, hstmt); exit(1); } } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cursor-movement-test.c000066400000000000000000000126421462406103600225370ustar00rootroot00000000000000#include #include #include #include "common.h" static void printFetchResult(HSTMT hstmt, int rc) { if (SQL_SUCCEEDED(rc)) { char buf[40]; SQLLEN ind; if (rc == SQL_SUCCESS_WITH_INFO) print_diag("got SUCCESS_WITH_INFO", SQL_HANDLE_STMT, hstmt); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("fetched: %s\n", buf); } else if (rc == SQL_NO_DATA) printf("Fetch: no data found\n"); /* expected */ else CHECK_STMT_RESULT(rc, "Fetch failed", hstmt); } static void testLargeResult(HSTMT hstmt) { int rc; int i; /* Make the cursor scrollable */ rc = SQLSetStmtAttr(hstmt, SQL_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); /* * Fetch a large result set without cursor (in Declare/fetch mode, it will * be fetched in chunks) */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo' || g FROM generate_series(1, 3210) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch the first 10 rows */ for (i = 0; i < 10; i++) { rc = SQLFetch(hstmt); printFetchResult(hstmt, rc); } /* Test all the SQL_FETCH_* modes with SQLFetchScroll */ printf("Testing SQL_FETCH_NEXT...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_PRIOR...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_ABSOLUTE (5)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 5); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_RELATIVE (+2)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 2); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_RELATIVE (-2)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, -2); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_RELATIVE (+1)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 1); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_RELATIVE (0, no movement)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_FIRST...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_FIRST, 0); printFetchResult(hstmt, rc); /*** Ok, now test the behavior at "before first row" ***/ printf("Testing SQL_FETCH_PRIOR before first row...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0); printFetchResult(hstmt, rc); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_NEXT...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); /*** Test behavior at the end ***/ printf("Testing SQL_FETCH_LAST...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_LAST, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_LAST...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_LAST, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_NEXT at the end of result set\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_NEXT at the end of result set\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0); printFetchResult(hstmt, rc); printf("And SQL_FETCH_PRIOR...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_RELATIVE (+10)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 10); printFetchResult(hstmt, rc); printf("And SQL_FETCH_PRIOR...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0); printFetchResult(hstmt, rc); printf("Testing negative SQL_FETCH_ABSOLUTE (-5)...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, -5); printFetchResult(hstmt, rc); printf("Testing negative SQL_FETCH_ABSOLUTE, before start...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, -10000); printFetchResult(hstmt, rc); printf("Testing SQL_FETCH_ABSOLUTE, beoynd end...\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 10000); printFetchResult(hstmt, rc); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } static const char * sql_commit_behavior_str(SQLUINTEGER info) { static char buf[50]; switch(info) { case SQL_CB_DELETE: return "SQL_CB_DELETE"; case SQL_CB_CLOSE: return "SQL_CB_CLOSE"; case SQL_CB_PRESERVE: return "SQL_CB_PRESERVE"; default: sprintf(buf, "unknown (%u)", (unsigned int) info); return buf; } } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLUSMALLINT info; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Print out the current SQL_CURSOR_COMMIT_BEHAVIOR and * SQL_CURSOR_ROLLBACK settings. The result of this test case depends on * those. */ rc = SQLGetInfo(conn, SQL_CURSOR_COMMIT_BEHAVIOR, &info, sizeof(info), NULL); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); printf("SQL_CURSOR_COMMIT_BEHAVIOR: %s\n", sql_commit_behavior_str(info)); rc = SQLGetInfo(conn, SQL_CURSOR_ROLLBACK_BEHAVIOR, &info, sizeof(info), NULL); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); printf("SQL_CURSOR_ROLLBACK_BEHAVIOR: %s\n\n", sql_commit_behavior_str(info)); /* Run the test */ testLargeResult(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cursor-name-test.c000066400000000000000000000066231462406103600216270ustar00rootroot00000000000000#include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; HSTMT hstmt2 = SQL_NULL_HSTMT; char cursornamebuf[20]; SQLSMALLINT cursornamelen; char buf[40]; SQLLEN ind; /**** Test cursor names ****/ test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt2); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* first create a test table we can update */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "create temporary table cursortesttbl as " "SELECT id, 'foo' || id as t FROM generate_series(1,10) id", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLGetCursorName(hstmt, cursornamebuf, sizeof(cursornamebuf), &cursornamelen); CHECK_STMT_RESULT(rc, "SQLGetCursorName failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Per the ODBC spec, the cursor name should begin with SQL_CUR */ cursornamebuf[strlen("SQL_CUR")] = '\0'; printf("cursor name prefix: %s\n", cursornamebuf); /* Use a custom name */ rc = SQLSetCursorName(hstmt, (SQLCHAR *) "my_test_cursor", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLSetCursorName failed", hstmt); /* * Fetch a large result set without cursor (in Declare/fetch mode, it will * be fetched in chunks) */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM cursortesttbl WHERE id < 9", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch until we find the row with id = 5 */ do { rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); } while(strcmp(buf, "5") != 0); /* use the cursor's name for update */ /* * XXX: Disabled, because the driver doesn't support UPDATE ... WHERE * CURRENT OF. It works with some options (Fetch=1), but it's not reported * as supported so there's no guarantees. */ #ifdef NOT_SUPPORTED printf("Updating row with id=5...\n"); rc = SQLExecDirect(hstmt2, (SQLCHAR *) "UPDATE cursortesttbl SET t = 'updated' || id WHERE CURRENT OF my_test_cursor", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt2); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM cursortesttbl ORDER BY id FOR UPDATE", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); #endif rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * Test a cursor name that requires quoting. The ODBC spec recommends * not to use such a name, but we better handle it gracefully anyway. * * FIXME: the driver doesn't actually handle this. */ #ifdef BROKEN rc = SQLSetCursorName(hstmt, (SQLCHAR *) "my nasty \"quoted\" cur'sor", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLSetCursorName failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM cursortesttbl WHERE id < 4", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); #endif /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cursors-test.c000066400000000000000000000074471462406103600211010ustar00rootroot00000000000000#include #include #include #include "common.h" static void testLargeResult(HSTMT hstmt, int betweenstmts) { int rc; int i; rc = SQLSetConnectAttr(conn, SQL_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, 0); CHECK_CONN_RESULT(rc, "SQL_AUTOCOMMIT off failed", conn); /* * Fetch a large result set without cursor (in Declare/fetch mode, it will * be fetched in chunks) */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo' || g FROM generate_series(1, 3210) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch the first 10 rows */ for (i = 0; i < 10; i++) { char buf[40]; SQLLEN ind; rc = SQLFetch(hstmt); if (rc != SQL_SUCCESS) { CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); } rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("%s ", buf); } /* Now Commit, Rollback or do nothing depending on the argument */ switch (betweenstmts) { case 1: printf("\nCommit\n"); rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_COMMIT); CHECK_STMT_RESULT(rc, "SQLEndTran failed\n", hstmt); break; case 2: printf("\nRollback\n"); rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_ROLLBACK); CHECK_STMT_RESULT(rc, "SQLEndTran failed\n", hstmt); break; default: /* do nothing */ break; } /* * Try to fetch the rest of the result set. * (Will fail in SQL_CB_CLOSE mode and succeed in SQL_CB_PRESERVE). */ for (;; i++) { char buf[40]; SQLLEN ind; rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc != SQL_SUCCESS) { char sqlstate[32] = ""; SQLINTEGER nativeerror; SQLSMALLINT textlen; SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, sqlstate, &nativeerror, NULL, 0, &textlen); if (strcmp(sqlstate, "HY010") == 0) { /* This is expected in SQL_CB_CLOSE mode */ printf("SQLFetch failed with HY010 (which probably means that the cursor was closed at commit/rollback)"); break; } else CHECK_STMT_RESULT(rc, "SQLGetDiagRec failed", hstmt); } rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); if (i == 20) printf("... "); else if (20 < i && i <= 3205) { /* skip printing, to keep the output short */ } else printf("%s ", buf); } printf("\nFetched %d rows altogether\n\n", i); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } static const char * sql_commit_behavior_str(SQLUINTEGER info) { static char buf[50]; switch(info) { case SQL_CB_DELETE: return "SQL_CB_DELETE"; case SQL_CB_CLOSE: return "SQL_CB_CLOSE"; case SQL_CB_PRESERVE: return "SQL_CB_PRESERVE"; default: sprintf(buf, "unknown (%u)", (unsigned int) info); return buf; } } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLUSMALLINT info; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Print out the current SQL_CURSOR_COMMIT_BEHAVIOR and * SQL_CURSOR_ROLLBACK settings. The result of this test case depends on * those. */ rc = SQLGetInfo(conn, SQL_CURSOR_COMMIT_BEHAVIOR, &info, sizeof(info), NULL); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); printf("SQL_CURSOR_COMMIT_BEHAVIOR: %s\n", sql_commit_behavior_str(info)); rc = SQLGetInfo(conn, SQL_CURSOR_ROLLBACK_BEHAVIOR, &info, sizeof(info), NULL); CHECK_STMT_RESULT(rc, "SQLGetInfo failed", hstmt); printf("SQL_CURSOR_ROLLBACK_BEHAVIOR: %s\n\n", sql_commit_behavior_str(info)); /* Run three variations of the test */ testLargeResult(hstmt, 0); testLargeResult(hstmt, 1); testLargeResult(hstmt, 2); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/cvtnulldate-test.c000066400000000000000000000036171462406103600217210ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char *param1; SQLLEN cbParam1; test_connect_ext("AB=0x08;UseServerSidePrepare=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** A simple query with one text param ****/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE nulldate (d date)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* * Bind empty string to the date param. In cvt_null_date mode, the driver * maps it to NULL. (In normal mode, the driver fills in the current date) */ param1 = ""; cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 5, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO nulldate VALUES (?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Check the resulting table */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT d IS NULL FROM nulldate", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check how the NULL comes out when we read it back */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT d FROM nulldate", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/dataatexecution-test.c000066400000000000000000000122661462406103600225560ustar00rootroot00000000000000#include #include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char *param1; SQLLEN cbParam1, cbParam2; SQLLEN param1bytes; PTR paramid; SQLLEN str_ind_array[2]; SQLUSMALLINT status_array[2]; SQLULEN nprocessed = 0; int i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** * Bind with data-at-execution params. (VARBINARY) */ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id FROM byteatab WHERE t = ? OR t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* prepare the parameter values */ param1 = "bar"; param1bytes = strlen(param1); cbParam1 = SQL_DATA_AT_EXEC; cbParam2 = SQL_DATA_AT_EXEC; /* bind them. */ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_VARBINARY, /* param type */ param1bytes, /* column size */ 0, /* dec digits */ (void *) 1, /* param value ptr. For a data-at-exec * param, this is a "parameter id" */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_VARBINARY, /* param type */ 6, /* column size */ 0, /* dec digits */ (void *) 2, /* param value ptr. For a data-at-exec * param, this is a "parameter id" */ 0, /* buffer len */ &cbParam2 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); if (rc != SQL_NEED_DATA) CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* set parameters */ paramid = 0; while ((rc = SQLParamData(hstmt, ¶mid)) == SQL_NEED_DATA) { if (paramid == (void *) 1) { rc = SQLPutData(hstmt, param1, param1bytes); CHECK_STMT_RESULT(rc, "SQLPutData failed", hstmt); } else if (paramid == (void *) 2) { rc = SQLPutData(hstmt, "foo", 3); CHECK_STMT_RESULT(rc, "SQLPutData failed", hstmt); /* append more data */ rc = SQLPutData(hstmt, "bar", 3); CHECK_STMT_RESULT(rc, "SQLPutData failed", hstmt); } else { printf("unexpected parameter id returned by SQLParamData: %p\n", paramid); exit(1); } } CHECK_STMT_RESULT(rc, "SQLParamData failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * Array binding with data-at-execution params. */ /* prepare the parameter values */ str_ind_array[0] = SQL_DATA_AT_EXEC; str_ind_array[1] = SQL_DATA_AT_EXEC; /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id FROM byteatab WHERE t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &nprocessed, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) 2, 0); /* bind the array. */ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_VARBINARY, /* param type */ 5, /* column size */ 0, /* dec digits */ (void *) 1, /* param value ptr. For a data-at-exec * param, this is "parameter id" */ 0, /* buffer len */ str_ind_array /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); if (rc != SQL_NEED_DATA) CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* set parameters */ paramid = 0; while ((rc = SQLParamData(hstmt, ¶mid)) == SQL_NEED_DATA) { if (nprocessed == 1) rc = SQLPutData(hstmt, "foo", strlen("foo")); else if (nprocessed == 2) rc = SQLPutData(hstmt, "barf", strlen("barf")); else { printf("unexpected # of rows processed after SQL_NEED_DATA: %u\n", (unsigned int) nprocessed); exit(1); } CHECK_STMT_RESULT(rc, "SQLPutData failed", hstmt); } CHECK_STMT_RESULT(rc, "SQLParamData failed", hstmt); /* Fetch results */ printf("Parameter Status\n"); for (i = 0; i < nprocessed; i++) { switch (status_array[i]) { case SQL_PARAM_SUCCESS: case SQL_PARAM_SUCCESS_WITH_INFO: break; case SQL_PARAM_ERROR: printf("%d\tError\n", i); break; case SQL_PARAM_UNUSED: printf("%d\tUnused\n", i); break; case SQL_PARAM_DIAG_UNAVAILABLE: printf("%d\tDiag unavailable\n", i); break; } } printf ("Fetching result sets for array bound (%u results expected)\n", (unsigned int) nprocessed); for (i = 1; rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO; i++) { printf("%d: ", i); print_result(hstmt); rc = SQLMoreResults(hstmt); } if (rc != SQL_NO_DATA) CHECK_STMT_RESULT(rc, "SQLMoreResults failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/declare-fetch-block-test.c000066400000000000000000000103061462406103600231430ustar00rootroot00000000000000/* * Test what happens when using block cursors, scrolling next and prior, or * fetching a row "behind" the rowset by "fetch absolute". */ #include #include #include #include "common.h" #define TOTAL 120 #define BLOCK 84 int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; int i; int count = TOTAL; char query[100]; int totalRows = 0; int fetchIdx = 0; SQLLEN rowArraySize = BLOCK; SQLULEN rowsFetched; SQLINTEGER id[BLOCK]; SQLLEN cbLen[BLOCK]; /**** * Run this test with UseDeclareFetch = 1 and Fetch=100(default). */ test_connect_ext("UseDeclareFetch=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLExecDirect(hstmt, (SQLCHAR *) "create temporary table tmptable(id int4 primary key)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect create table failed", hstmt); /* insert into a table */ for (i = 0; i < count; i++) { snprintf(query, sizeof(query), "insert into tmptable values (%d)", i); rc = SQLExecDirect(hstmt, (SQLCHAR *) query, SQL_NTS); CHECK_STMT_RESULT(rc, "insert into table failed", hstmt); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Block cursor */ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) rowArraySize, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr ROW_ARRAY_SIZE failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, (SQLPOINTER) &rowsFetched, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr ROWS_FETCHED_PTR failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_SLONG, &id, 0, cbLen); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "select * from tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "select failed", hstmt); while (rc = SQLFetch(hstmt), SQL_SUCCEEDED(rc)) { fetchIdx++; totalRows += (int) rowsFetched; printf("fetchIdx=%d, fetched rows=%d, total rows=%d\n", fetchIdx, (int) rowsFetched, totalRows); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Scroll next -> EOF -> prior -> BOF -> next -> EOF -> prior -> BOF */ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) 1, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr ROW_ARRAY_SIZE failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CURSOR_TYPE failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CONCURRENCY failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "select * from tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "select failed", hstmt); for (i = 0; i < 2; i++) { totalRows = 0; while (rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0), SQL_SUCCEEDED(rc)) totalRows += (int) rowsFetched; if (SQL_NO_DATA != rc) CHECK_STMT_RESULT(rc, "fetch failed", hstmt); printf("next total rows=%d\n", totalRows); totalRows = 0; while (rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, 0), SQL_SUCCEEDED(rc)) totalRows += (int) rowsFetched; if (SQL_NO_DATA != rc) CHECK_STMT_RESULT(rc, "fetch failed", hstmt); printf("prior total rows=%d\n", totalRows); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * When fetching a row "behind" the rowset by "fetch absolute" only the first ones of the result set can be fetched? */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "select * from tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "select failed", hstmt); if (rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, count + 1), !SQL_SUCCEEDED(rc)) { printf("FetchScroll beyond the end failed %d\n", rc); } rc = SQLFetchScroll(hstmt, SQL_FETCH_ABSOLUTE, 1); CHECK_STMT_RESULT(rc, "FetchScroll the 1st row failed", hstmt); for (i = 1; i < count; i++) { if (!SQL_SUCCEEDED(rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0))) break; } printf("encountered EOF at %d\n", i); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/declare-fetch-commit-test.c000066400000000000000000000044171462406103600233470ustar00rootroot00000000000000/* * Test what happens when the transaction is committed while fetching from a * result set. */ #include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; int rows; /**** * Run this test with UseDeclareFetch = 1 and Fetch=1, so that we fetch * one row at a time. Protocol=-2 is required so that the cursors survives * the commit. */ test_connect_ext("UseDeclareFetch=1;Fetch=1;Protocol=7.4-2"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Disable autocommit, and execute a dummy UPDATE to start a transaction */ rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetConnectAttr failed", hstmt); SQLExecDirect(hstmt, (SQLCHAR *) "update testtbl1 set t = t where id = 123456", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** Start a cursor ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT * FROM generate_series(1, 5) g ", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ printf("Result set:\n"); rows = 0; while(1) { rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc == SQL_SUCCESS) { char buf[40]; SQLLEN ind; rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); exit(1); } printf("%s", buf); printf("\n"); } else { print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* In the middle of the result set, COMMIT */ if (rows == 2) { rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_COMMIT); CHECK_STMT_RESULT(rc, "SQLEndTran failed\n", hstmt); } rows++; } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/deprecated-test.c000066400000000000000000000232671462406103600214770ustar00rootroot00000000000000/* * Tests for deprecated functions. */ #include #include #include #include "common.h" void print_cursor_type(SQLINTEGER cursor_type) { printf("Cursor type is: "); if (cursor_type == SQL_CURSOR_FORWARD_ONLY) printf("forward\n"); else if (cursor_type == SQL_CURSOR_KEYSET_DRIVEN) printf("keyset driven\n"); else if (cursor_type == SQL_CURSOR_DYNAMIC) printf("dynamic\n"); else if (cursor_type == SQL_CURSOR_STATIC) printf("static\n"); else { printf("unknown type of cursor: %d\n", cursor_type); exit(1); } } void print_access_type(SQLINTEGER access_type) { printf("Access type is: "); if (access_type == SQL_MODE_READ_ONLY) printf("read-only\n"); else if (access_type == SQL_MODE_READ_WRITE) printf("read-write\n"); else { printf("Incorrect type of access\n"); exit(1); } } /* Array size for SQLParamOptions test */ #define ARRAY_SIZE 10 int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLHDBC conn2; SQLHENV env2; SQLSMALLINT val; SQLINTEGER valint; char buffer[256]; char message[1000]; int i; /* Parameters for SQLParamOptions */ SQLULEN nprocessed; SQLLEN int_ind_array[ARRAY_SIZE]; SQLLEN str_ind_array[ARRAY_SIZE]; SQLUSMALLINT status_array[ARRAY_SIZE]; SQLUINTEGER int_array[ARRAY_SIZE]; SQLCHAR str_array[ARRAY_SIZE][30]; /* * SQLAllocConnect -> SQLAllocHandle * SQLAllocEnv -> SQLAllocHandle * Get a connection. */ printf("Check for SQLAllocEnv\n"); rc = SQLAllocEnv(&env2); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLAllocEnv failed", SQL_HANDLE_ENV, env2); exit(1); } SQLSetEnvAttr(env2, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); printf("Check for SQLAllocConnect\n"); rc = SQLAllocConnect(env2, &conn2); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLAllocConnect failed", SQL_HANDLE_DBC, conn2); exit(1); } snprintf(buffer, sizeof(buffer), "DSN=%s;", get_test_dsn()); rc = SQLDriverConnect(conn2, NULL, buffer, SQL_NTS, NULL, 0, &val, SQL_DRIVER_COMPLETE); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLDriverConnect failed", SQL_HANDLE_DBC, conn2); exit(1); } /* * SQLAllocStmt -> SQLAllocHandle * Allocate a statement handle. */ printf("Check for SQLAllocStmt\n"); rc = SQLAllocStmt(conn2, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLAllocStmt failed", SQL_HANDLE_DBC, conn2); exit(1); } /* * SQLSetConnectOption -> SQLSetConnectAttr * SQLGetConnectOption -> SQLGetConnectAttr * Test connection attribute. */ printf("Check for SQLSetConnectOption\n"); rc = SQLSetConnectOption(conn2, SQL_ATTR_ACCESS_MODE, SQL_MODE_READ_WRITE); CHECK_STMT_RESULT(rc, "SQLSetConnectOption failed", hstmt); printf("Check for SQLGetConnectOption\n"); rc = SQLGetConnectOption(conn2, SQL_ATTR_ACCESS_MODE, &valint); CHECK_STMT_RESULT(rc, "SQLGetConnectOption failed", hstmt); print_access_type(valint); /* * SQLError -> SQLGetDiagRec * Trigger an error. */ printf("Check for SQLError\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO table_not_here VALUES (1)", SQL_NTS); rc = SQLError(env2, conn2, hstmt, buffer, &valint, message, 256, &val); CHECK_STMT_RESULT(rc, "SQLError failed", hstmt); printf("Error check: %s\n", (char *)message); /* * SQLSetParam[2] -> SQLBindParameter * Test for set parameter, somewhat similar to last example. */ printf("Check for SQLSetParam\n"); val = 100; SQLSetParam(hstmt, 1, SQL_C_SHORT, SQL_SMALLINT, 0, 0, &val, NULL); CHECK_STMT_RESULT(rc, "SQLSetParam failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT ?::int AS foo", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * SQLGetStmtOption -> SQLGetStmtAttr * SQLSetStmtOption -> SQLSetStmtAttr * SQLSetScrollOptions -> SQLSetStmtAttr * Test for statement and cursor options. */ /* Pointer should be forward-only here */ printf("Check for SQLGetStmtOption\n"); rc = SQLGetStmtOption(hstmt, SQL_CURSOR_TYPE, &valint); CHECK_STMT_RESULT(rc, "SQLGetStmtOption failed", hstmt); print_cursor_type(valint); /* Change it to static and check its new value */ printf("Check for SQLSetStmtOption\n"); rc = SQLSetStmtOption(hstmt, SQL_CURSOR_TYPE, SQL_CURSOR_STATIC); CHECK_STMT_RESULT(rc, "SQLSetStmtOption failed", hstmt); rc = SQLGetStmtOption(hstmt, SQL_CURSOR_TYPE, &valint); CHECK_STMT_RESULT(rc, "SQLGetStmtOption failed", hstmt); print_cursor_type(valint); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Change it now to dynamic using another function */ printf("Check for SQLSetScrollOptions\n"); rc = SQLSetScrollOptions(hstmt, SQL_CONCUR_READ_ONLY, SQL_SCROLL_FORWARD_ONLY, 1); CHECK_STMT_RESULT(rc, "SQLSetScrollOptions failed", hstmt); rc = SQLGetStmtOption(hstmt, SQL_CURSOR_TYPE, &valint); CHECK_STMT_RESULT(rc, "SQLGetStmtOption failed", hstmt); /* * The result on Windows is ununderstandable to me. * This deprecated-test doesn't seem to have much meaning. * So just suppress a diff output. */ #ifdef WIN32 printf("Cursor type is: forward\n"); #else print_cursor_type(valint); #endif rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * SQLColAttributes -> SQLColAttribute * Test for column attributes. Return column attributes of * a simple query. */ printf("Check for SQLColAttributes\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT '1'::int AS foo, 'foobar'::text AS bar", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); for (i = 0 ; i < 2; i++) { char buffer[64]; rc = SQLColAttribute(hstmt, (SQLUSMALLINT) i + 1, SQL_DESC_LABEL, buffer, 64, NULL, NULL); CHECK_STMT_RESULT(rc, "SQLColAttribute failed", hstmt); printf("Column %d: %s\n", i + 1, buffer); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * SQLParamOptions -> SQLSetStmtAttr * Test for parameter options. SQLParamOptions is mapped using * SQL_ATTR_PARAMS_PROCESSED_PTR and SQL_ATTR_PARAMSET_SIZE. Here * we insert a set of values in a temporary table. */ /* Fill in array values */ for (i = 0; i < ARRAY_SIZE; i++) { int_array[i] = i; int_ind_array[i] = 0; sprintf(str_array[i], "column num %d", i); str_ind_array[i] = SQL_NTS; } printf("Check for SQLParamOptions\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE tmptable (i int4, t text)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed for table creation", hstmt); rc = SQLParamOptions(hstmt, (SQLULEN) ARRAY_SIZE, &nprocessed); CHECK_STMT_RESULT(rc, "SQLParamOptions failed", hstmt); /* Set some extra parameters */ SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status_array, 0); /* Bind the parameter arrays. */ SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, int_array, 0, int_ind_array); SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 29, 0, str_array, 30, str_ind_array); /* Execute and fetch statuses */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO tmptable VALUES (?, ?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); printf("Status of execution\n"); for (i = 0; i < nprocessed; i++) { switch (status_array[i]) { case SQL_PARAM_SUCCESS: case SQL_PARAM_SUCCESS_WITH_INFO: break; case SQL_PARAM_ERROR: printf("%d\tError\n", i); break; case SQL_PARAM_UNUSED: printf("%d\tUnused\n", i); break; case SQL_PARAM_DIAG_UNAVAILABLE: printf("%d\tDiag unavailable\n", i); break; } } /* * SQLFreeStmt(SQL_DROP) -> SQLFreeHandle * * Free the statement handle used. SQL_DROP is deprecated, other * options are not. */ printf("Check for SQLFreeStmt\n"); rc = SQLFreeStmt(hstmt, SQL_DROP); CHECK_STMT_RESULT(rc, "SQLFreeStmt with SQL_DROP failed", hstmt); /* * SQLFreeConnect -> SQLFreeHandle * SQLFreeEnv -> SQLFreeHandle * Disconnect and free connection. */ rc = SQLDisconnect(conn2); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLDisconnect failed", SQL_HANDLE_DBC, conn2); exit(1); } printf("Check for SQLFreeConnect\n"); rc = SQLFreeConnect(conn2); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeConnect failed", SQL_HANDLE_DBC, conn2); exit(1); } printf("Check for SQLFreeEnv\n"); rc = SQLFreeEnv(env2); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeEnv failed", SQL_HANDLE_ENV, env2); exit(1); } /* Grab new connection and handle for the next tests */ test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * SQLTransact -> SQLEndTran * Check transaction ROLLBACK using SQLTransact. */ printf("Check for SQLTransact\n"); /* First disable autocommit */ rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER); /* Insert a row and rollback it */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO testtab1 VALUES (200, 'foo')", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLTransact(SQL_NULL_HENV, conn, SQL_ROLLBACK); CHECK_STMT_RESULT(rc, "SQLTransact failed", hstmt); /* Now check that the row is not inserted */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT t FROM testtab1 WHERE id = 200", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/diagnostic-test.c000066400000000000000000000043251462406103600215150ustar00rootroot00000000000000/* * Tests for error diagnostics (SQLGetDiagRec) */ #include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; SQLSMALLINT slen; char sqlstate[32]; char buf[10000]; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Execute an erroneous query, and call SQLGetDiagRec twice on the * statement. Should get the same result both times; SQLGetDiagRec is * not supposed to change the state of the statement. */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "broken query", SQL_NTS); print_diag("SQLExecDirect", SQL_HANDLE_STMT, hstmt); print_diag("get same message again", SQL_HANDLE_STMT, hstmt); /* * Test a very long error message. */ memset(buf, 'x', sizeof(buf) - 10); sprintf(buf + sizeof(buf) - 10, "END"); rc = SQLExecDirect(hstmt, (SQLCHAR *) buf, SQL_NTS); print_diag("SQLExecDirect", SQL_HANDLE_STMT, hstmt); rc = SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 1, SQL_DIAG_SQLSTATE, sqlstate, sizeof(sqlstate), &slen); if (rc == SQL_INVALID_HANDLE) printf("Invalid handle\n"); else if (SQL_SUCCEEDED(rc)) printf("%s\n", sqlstate); else printf("unexpected return code %d\n", rc); rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_ROLLBACK); CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_DROP); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* kill this connection */ printf ("killing connection...\n"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLExecDirect(hstmt, (SQLCHAR *) "select pg_terminate_backend(pg_backend_pid());select 1;select 1 ", SQL_NTS); print_diag(NULL, SQL_HANDLE_STMT, hstmt); /* * Test SQLGetDiagRec on the connection, after the backend connection is * dead. Twice, again to check that the first call doesn't clear the * error. */ print_diag("SQLGetDiagRec on connection says:", SQL_HANDLE_DBC, conn); print_diag("SQLGetDiagRec called again:", SQL_HANDLE_DBC, conn); return 0; } psqlodbc-REL-16_00_0005/test/src/error-rollback-test.c000066400000000000000000000123651462406103600223140ustar00rootroot00000000000000/* * Tests for the existing behaviors of rollback on errors: * 0 -> Do nothing and let the application do it * 1 -> Rollback the entire transaction * 2 -> Rollback only the statement */ #include #include #include #include "common.h" HSTMT hstmt = SQL_NULL_HSTMT; static void error_rollback_init(char *options) { SQLRETURN rc; /* Error if initialization is already done */ if (hstmt != SQL_NULL_HSTMT) { printf("Initialization already done, leaving...\n"); exit(1); } test_connect_ext(options); rc = SQLAllocStmt(conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Disable autocommit */ rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER); /* Create a table to use */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE errortab (i int4)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* And of course commit... */ rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_COMMIT); CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt); } static void error_rollback_clean(void) { SQLRETURN rc; /* Clean up everything */ rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); test_disconnect(); hstmt = SQL_NULL_HSTMT; } static void error_rollback_exec_success(int arg) { SQLRETURN rc; char buf[100]; printf("Executing query that will succeed\n"); /* Now execute the query */ snprintf(buf, sizeof(buf), "INSERT INTO errortab VALUES (%d)", arg); rc = SQLExecDirect(hstmt, (SQLCHAR *) buf, SQL_NTS); /* Print error if any, but do not exit */ CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); } /* Runs a query that's expected to fail */ static void error_rollback_exec_failure(int arg) { SQLRETURN rc; char buf[100]; printf("Executing query that will fail\n"); snprintf(buf, sizeof(buf), "INSERT INTO errortab VALUES ('fail%d')", arg); /* Now execute the query */ rc = SQLExecDirect(hstmt, (SQLCHAR *) buf, SQL_NTS); if (SQL_SUCCEEDED(rc)) { printf("SQLExecDirect should have failed but it succeeded\n"); exit(1); } /* Print error, it is expected */ print_diag("Failed to execute statement", SQL_HANDLE_STMT, hstmt); } /* * Runs another query that's expected to fail. * * This query uses the ODBC procedure call escape syntax, because such queries * go through a slightly different execution path in the driver. */ void error_rollback_exec_proccall_failure(void) { SQLRETURN rc; printf("Executing procedure call that will fail\n"); /* Now execute the query */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "{ call invalidfunction() }", SQL_NTS); if (SQL_SUCCEEDED(rc)) { printf("SQLExecDirect should have failed but it succeeded\n"); exit(1); } /* Print error, it is expected */ print_diag("Failed to execute procedure call", SQL_HANDLE_STMT, hstmt); } void error_rollback_print(void) { SQLRETURN rc; /* Create a table to use */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT i FROM errortab", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Show results */ print_result(hstmt); } int main(int argc, char **argv) { SQLRETURN rc; /* * Test for protocol at 0. * Do nothing when error occurs and let application do necessary * ROLLBACK on error. */ printf("Test for rollback protocol 0\n"); error_rollback_init("Protocol=7.4-0"); /* Insert a row correctly */ error_rollback_exec_success(1); /* Now trigger an error, the row previously inserted will disappear */ error_rollback_exec_failure(1); /* * Now rollback the transaction block, it is the responsibility of * application. */ printf("Rolling back with SQLEndTran\n"); rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_ROLLBACK); CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt); /* Insert row correctly now */ error_rollback_exec_success(1); /* Not yet committed... */ rc = SQLEndTran(SQL_HANDLE_DBC, conn, SQL_COMMIT); CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt); /* Print result */ error_rollback_print(); /* Clean up */ error_rollback_clean(); /* * Test for rollback protocol 1 * In case of an error rollback the entire transaction. */ printf("Test for rollback protocol 1\n"); error_rollback_init("Protocol=7.4-1"); /* * Insert a row, trigger an error, and re-insert a row. Only one * row should be visible here. */ error_rollback_exec_success(1); error_rollback_exec_failure(1); error_rollback_exec_success(1); error_rollback_print(); /* Clean up */ error_rollback_clean(); /* * Test for rollback protocol 2 * In the case of an error rollback only the latest statement. */ printf("Test for rollback protocol 2\n"); error_rollback_init("Protocol=7.4-2"); /* * Do a bunch of insertions and failures. */ error_rollback_exec_success(1); error_rollback_exec_success(2); error_rollback_exec_failure(-1); error_rollback_exec_success(3); error_rollback_exec_success(4); error_rollback_exec_failure(-1); error_rollback_exec_failure(-1); error_rollback_exec_success(5); error_rollback_exec_proccall_failure(); error_rollback_exec_success(6); error_rollback_exec_success(7); error_rollback_print(); /* Clean up */ error_rollback_clean(); return 0; } psqlodbc-REL-16_00_0005/test/src/errors-test.c000066400000000000000000000051611462406103600207040ustar00rootroot00000000000000/* * Test behavior when errors happen. Should get a proper error message, and * the connection should stay in a sane state. * * FIXME: With some combinations of settings, an error can leave a * transaction open, but in aborted state. That's a bug in the driver, but * because I'm not planning to fix it right now, there is an expected output * file (errors_2.out) for that. The bug should be fixed, and the expected * output removed. */ #include #include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[20] = "foo"; SQLLEN cbParam1; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Test a simple parse-time error */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT doesnotexist", SQL_NTS); /* Print error, it is expected */ if (!SQL_SUCCEEDED(rc)) print_diag("", SQL_HANDLE_STMT, hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* The same, but with a bind parameter */ /* bind param */ cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test a simple parse-time error */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT doesnotexist2 WHERE bogus = ?", SQL_NTS); /* Print error, it is expected */ if (!SQL_SUCCEEDED(rc)) print_diag("", SQL_HANDLE_STMT, hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test syntax error with SQLPrepare ***/ /* Test a simple parse-time error */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT doesnotexist3 WHERE bogus = ?", SQL_NTS); /* bind param */ cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test a simple parse-time error */ rc = SQLExecute(hstmt); /* Print error, it is expected */ if (!SQL_SUCCEEDED(rc)) print_diag("", SQL_HANDLE_STMT, hstmt); test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/fetch-refcursors-test.c000066400000000000000000000065241462406103600226600ustar00rootroot00000000000000/* * Test FetchRefcursors setting */ #include "common.h" static void print_all_results(HSTMT hstmt) { int i; int rc = SQL_SUCCESS; for (i = 1; rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO; i++) { printf("--%d ", i); print_result(hstmt); rc = SQLMoreResults(hstmt); } if (rc != SQL_NO_DATA) CHECK_STMT_RESULT(rc, "SQLMoreResults failed", hstmt); } static void setup_procedure() { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; printf("Creating procedure 'refproc'\n"); test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "failed to allocate stmt handle", conn); rc = SQLExecDirect(hstmt, "create or replace procedure refproc" "(inout num_cursor integer, inout ref1 refcursor default null, inout ref2 refcursor default null) as " "$procedure$ \n" "DECLARE \n" "BEGIN \n" "IF num_cursor > 0 THEN \n" " OPEN ref1 FOR SELECT id, t FROM testtab1 ORDER BY id ASC; \n" "END IF; \n" "IF num_cursor > 1 THEN \n" " OPEN ref2 FOR SELECT t, id FROM testtab1 ORDER BY id DESC; \n" "END IF; \n" "IF num_cursor > 2 THEN \n" " num_cursor := 2; \n" "END IF; \n" "END; \n" "$procedure$ \n" "LANGUAGE plpgsql\n" , SQL_NTS); CHECK_STMT_RESULT(rc, "create procedure refproc failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); test_disconnect(); } static void refcursor_test(char* connectparams, SQLUINTEGER autocommit, int numresults) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; int num_cursor = numresults; printf("\n-- TEST using %s, autocommit=%u, numresults=%d\n", connectparams, autocommit, numresults); test_connect_ext(connectparams); /* Conditionally start a transaction */ rc = SQLSetConnectAttr(conn, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) (SQLULEN) autocommit, SQL_IS_UINTEGER); CHECK_STMT_RESULT(rc, "SQLSetConnectAttr failed", hstmt); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "failed to allocate stmt handle", conn); rc = SQLPrepare(hstmt, "CALL refproc(?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT_OUTPUT, SQL_C_LONG, /* value type */ SQL_INTEGER, /* param type */ 0, /* column size */ 0, /* dec digits */ &num_cursor, /* param value ptr */ 0, /* buffer len */ NULL /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecute(hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecute failed", SQL_HANDLE_STMT, hstmt); return; } printf("Output param num_cursor is %d\n", num_cursor); print_all_results(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); test_disconnect(); } int main(int argc, char **argv) { setup_procedure(); /* Using a fetch cache size of 1 to test multiple fetches per cursor */ refcursor_test("Fetch=1;FetchRefcursors=0", SQL_AUTOCOMMIT_ON, 2); refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_ON, 2); refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 0); refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 1); refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 2); refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 3); return 0; } psqlodbc-REL-16_00_0005/test/src/getresult-test.c000066400000000000000000000053011462406103600214020ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; SQL_INTERVAL_STRUCT intervalval; char *sql; char buf[40]; SQLINTEGER ld; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * The interval stuff requires intervalstyle=postgres at the momemnt. * Someone should fix the driver to understand other formats, * postgres_verbose in particular... */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SET intervalstyle=postgres", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Run a query with a result set with all kinds of values */ sql = "SELECT " "'foo'::varchar(10) AS varcharcol,\n" "123::integer as integercol,\n" "'10 years'::interval AS intervalyears,\n" "'11 months'::interval AS intervalmonths,\n" "'12 days'::interval AS intervaldays,\n" "'1 ' || repeat('evil_long_string',100) || ' 2 still_evil'::text AS evil_interval\n"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch result */ rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("varcharcol: %s\n", buf); rc = SQLGetData(hstmt, 2, SQL_C_LONG, &ld, sizeof(ld), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("integercol: %ld\n", (long) ld); rc = SQLGetData(hstmt, 3, SQL_C_INTERVAL_YEAR, &intervalval, sizeof(intervalval), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("intervalyears: %ld\n", (long) intervalval.intval.year_month.year); rc = SQLGetData(hstmt, 4, SQL_C_INTERVAL_MONTH, &intervalval, sizeof(intervalval), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("intervalmonths: %ld\n", (long) intervalval.intval.year_month.month); rc = SQLGetData(hstmt, 5, SQL_C_INTERVAL_DAY, &intervalval, sizeof(intervalval), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("intervaldays: %ld\n", (long) intervalval.intval.day_second.day); rc = SQLGetData(hstmt, 6, SQL_C_INTERVAL_DAY, &intervalval, sizeof(intervalval), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("bogus long string as interval: %ld\n", (long) intervalval.intval.day_second.day); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/identity-test.c000066400000000000000000000060071462406103600212210ustar00rootroot00000000000000/* * Test @@identity */ #include #include #include "common.h" static HSTMT hstmt = SQL_NULL_HSTMT; /* * The driver has to parse the insert statement to extract the table name, * so it might or might not work depending on the table name. This function * tests it with a table whose name is given as argument. * * NOTE: The table name is injected directly into the SQL statement. It should * already contain any escaping or quoting needed! */ void test_identity_col(const char *createsql, const char *insertsql, const char *verifysql) { SQLRETURN rc; SQLLEN rowcount; /* Create the test table */ rc = SQLExecDirect(hstmt, (SQLCHAR *) createsql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt); /* Insert some rows using the statement given by the caller */ rc = SQLExecDirect(hstmt, (SQLCHAR *) insertsql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLRowCount(hstmt, &rowcount); CHECK_STMT_RESULT(rc, "SQLRowCount failed", hstmt); printf("# of rows inserted: %d\n", (int) rowcount); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT @@IDENTITY AS last_insert", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Print the contents of the table after the updates to verify */ rc = SQLExecDirect(hstmt, (SQLCHAR *) verifysql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { SQLRETURN rc; char server_version[32], v10 = 0; test_connect(); rc = SQLGetInfo(conn, SQL_DBMS_VER, server_version, sizeof(server_version), NULL); if (SQL_SUCCEEDED(rc)) { int top_ver = 0; if (sscanf(server_version, "%d.%*d", &top_ver) > 0) if (top_ver > 9) v10 = 1; } rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } test_identity_col( v10 ? "CREATE TEMPORARY TABLE tmptable (id int generated by default as identity primary key, t text)" : "CREATE TEMPORARY TABLE tmptable (id serial primary key, t text)", "INSERT INTO tmptable (t) VALUES ('simple')", "SELECT * FROM tmptable"); test_identity_col( v10 ? "CREATE TEMPORARY TABLE tmptable2 (id int generated always as identity primary key, t text)" : "CREATE TEMPORARY TABLE tmptable2 (id serial primary key, t text)", "INSERT INTO tmptable2 (t) VALUES ('value.with.dots')", "SELECT * FROM tmptable2"); test_identity_col( v10 ? "CREATE TEMPORARY TABLE \"tmp table\" (id int generated by default as identity primary key, t text)" : "CREATE TEMPORARY TABLE \"tmp table\" (id serial primary key, t text)", "INSERT INTO \"tmp table\" (t) VALUES ('space in table name')", "SELECT * FROM \"tmp table\""); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/insertreturning-test.c000066400000000000000000000113731462406103600226340ustar00rootroot00000000000000/* * INSERT RETURNING tests. */ #include #include #include "common.h" static void run_test(); int main(int argc, char **argv) { /* * SQLNumResultCols(), when run after SQLPrepare but before SQLExecute, * return 0 in UseServerSidePrepare=0 mode. Run the test in both modes, * mainly to make the output predictable regardless of the default * UseServerSidePrepare mode in effect. */ printf("Testing with UseServerSidePrepare=1\n"); test_connect_ext("UseServerSidePrepare=1"); run_test(); test_disconnect(); printf("Testing with UseServerSidePrepare=0\n"); test_connect_ext("UseServerSidePrepare=0"); run_test(); test_disconnect(); return 0; } static void run_test() { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[100]; int param2; SQLLEN cbParam1; SQLSMALLINT colcount1, colcount2; SQLCHAR *sql; int i; rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } sql = "CREATE TEMPORARY TABLE tmptable (i int4, t text)"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt); /* * We used to have a memory leak when SQLNumResultCols() was called on an * INSERT statement. It's been fixed, but this test case was useful to find * it, when you crank up the number of iterations. */ for (i = 0; i < 100; i++) { /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "INSERT INTO tmptable VALUES (1, ?) RETURNING (t)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ snprintf(param1, sizeof(param1), "foobar %d", i); cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount1); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Call SQLNumResultCols again, after SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount2); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols before SQLExecute: %d, after: %d\n", colcount1, colcount2); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } /* Test for UPDATE returning */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "TRUNCATE TABLE tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while truncating temp table", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO tmptable values(3,'foo')", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while nserting temp table", hstmt); /* Prepare a UPDATE statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "UPDATE tmptable set t=? where i=? RETURNING (t)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare for UPDATE failed", hstmt); /* bind params */ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter 1 failed", hstmt); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG, /* value type */ SQL_INTEGER, /* param type */ 0, /* column size */ 0, /* dec digits */ ¶m2, /* param value ptr */ 0, /* buffer len */ NULL /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter 2 failed", hstmt); for (i = 0; i < 4;i++) { snprintf(param1, sizeof(param1), "foobar %d", i); cbParam1 = SQL_NTS; param2 = i; rc = SQLExecute(hstmt); if (SQL_SUCCEEDED(rc)) { rc = SQLFetch(hstmt); if (SQL_NO_DATA == rc) printf("??? SQLFetch for UPDATE not found key i=%d\n", param2); else if (SQL_SUCCEEDED(rc)) printf("SQLExecute UPDATE key i=%d value t=%s\n", param2, param1); else CHECK_STMT_RESULT(rc, "SQLFetch for UPDATE failed", hstmt); SQLFreeStmt(hstmt, SQL_CLOSE); } else if (SQL_NO_DATA == rc) printf("SQLExecute UPDATE not found key i=%d\n", param2); else CHECK_STMT_RESULT(rc, "SQLExecute UPDATE failed", hstmt); } rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeHandle failed", SQL_HANDLE_STMT, hstmt); exit(1); } } psqlodbc-REL-16_00_0005/test/src/large-object-data-at-exec-test.c000066400000000000000000000074521462406103600241660ustar00rootroot00000000000000/* * Test data-at-execution, for a large object. */ #include #include #include #include "common.h" static void printhex(unsigned char *b, int len) { int i; printf("hex: "); for (i = 0; i < len; i++) printf("%02X", b[i]); } /* * Insert a large object to table, using a data-at-exec param. Then read it * back and print. */ static void do_test(HSTMT hstmt, int testno, int lobByteSize, char *lobData) { char sql[200]; int rc; SQLLEN cbParam1; char *buf; SQLLEN ind; /**** Insert a Large Object */ printf("inserting large object with len %d...\n", lobByteSize); snprintf(sql, sizeof(sql), "INSERT INTO lo_test_tab VALUES (%d, ?)", testno); rc = SQLPrepare(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind LO param as a data at execution parameter */ cbParam1 = SQL_DATA_AT_EXEC; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_LONGVARBINARY, /* param type */ 0, /* column size */ 0, /* dec digits */ lobData, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); /* Check for data-at-execute parameters */ if (SQL_NEED_DATA == rc) { SQLLEN lobChunkSize = 4096; SQLPOINTER pParamId = 0; const char *what = 0; int error; /* Get the parameter that needs data */ what = "SQLParamData failed (first call)"; rc = SQLParamData(hstmt, &pParamId); error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc; if (SQL_NEED_DATA == rc) { /* Send parameter data in chunks */ what = "SQLPutData failed (next chunk)"; while (!error && lobByteSize > lobChunkSize) { rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobChunkSize); lobByteSize -= (int) lobChunkSize; error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc; } /* Send final chunk */ if (!error) { what = "SQLPutData failed (final chunk)"; rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobByteSize); error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc; } /* Make final call */ if (!error) { what = "SQLParamData failed (final call)"; rc = SQLParamData(hstmt, &pParamId); error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc; } } CHECK_STMT_RESULT(rc, (char*)what, hstmt); } else { print_diag("SQLExecute didn't return SQL_NEED_DATA as expected", SQL_HANDLE_STMT, hstmt); exit(1); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** Read it back ****/ printf("reading it back...\n"); snprintf(sql, sizeof(sql), "SELECT id, large_data FROM lo_test_tab WHERE id = %d", testno); SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); buf = malloc(lobByteSize * 2); rc = SQLGetData(hstmt, 2, SQL_C_BINARY, buf, lobByteSize * 2, &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printhex(buf, (int) ind); printf("\n"); free(buf); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; char param2[100]; int i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } do_test(hstmt, 101, sizeof(param1), param1); for (i = 0; i < sizeof(param2); i++) { param2[i] = i % 200; } do_test(hstmt, 102, sizeof(param2), param2); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/large-object-test.c000066400000000000000000000034241462406103600217260ustar00rootroot00000000000000#include #include #include #include "common.h" static void printhex(unsigned char *b, int len) { int i; printf("hex: "); for (i = 0; i < len; i++) printf("%02X", b[i]); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[20] = { 1, 2, 3, 4, 5, 6, 7, 8 }; SQLLEN cbParam1; char buf[100]; SQLLEN ind; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** Insert a Large Object */ printf("inserting large object...\n"); rc = SQLPrepare(hstmt, (SQLCHAR *) "INSERT INTO lo_test_tab VALUES (1, ?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind LO param */ cbParam1 = 8; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_LONGVARBINARY, /* param type */ 200, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** Read it back ****/ printf("reading it back...\n"); SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, large_data FROM lo_test_tab WHERE id = 1", SQL_NTS); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 2, SQL_C_BINARY, buf, sizeof(buf), &ind); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printhex(buf, (int) ind); printf("\n"); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/lfconversion-test.c000066400000000000000000000065021462406103600220770ustar00rootroot00000000000000#include #include #include #if 0 #include #endif #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; SQLLEN ccharlen; SQLLEN wcharlen; HSTMT hstmt = SQL_NULL_HSTMT; char *sql; int i; char buf[1000]; SQLWCHAR wbuf[1000]; /* Enable LF -> CR+LF conversion */ test_connect_ext("CX=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Return several columns that all contain the same string, with newlines. * We want to try getting the column contents with several different * options, and the driver doesn't let you fetch the same column more than * once. */ sql = "SELECT E'string\nwith\nnewlines', E'string\nwith\nnewlines', " "E'string\nwith\nnewlines', E'string\nwith\nnewlines', " "E'string\nwith\nnewlines'"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); printf("reading to char buffer...\n"); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ccharlen); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("strlen %d, SQLGetData claims %d\n\n", (int) strlen(buf), (int) ccharlen); printf("reading to char buffer, with truncation...\n"); rc = SQLGetData(hstmt, 2, SQL_C_CHAR, buf, 10, &ccharlen); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("strlen %d, SQLGetData claims %d\n\n", (int) strlen(buf), (int) ccharlen); printf("reading to SQLWCHAR buffer...\n"); rc = SQLGetData(hstmt, 3, SQL_C_WCHAR, wbuf, sizeof(wbuf), &wcharlen); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); /* On some platforms, SQLWCHAR != wchar_t, so we cannot use wcslen here */ for (i = 0; i < sizeof(wbuf) && wbuf[i] != 0; i++); printf("len %d chars, SQLGetData claims %d bytes\n\n", i, (int) wcharlen); printf("reading to SQLWCHAR buffer, with truncation...\n"); rc = SQLGetData(hstmt, 4, SQL_C_WCHAR, wbuf, 10, &wcharlen); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); for (i = 0; i < sizeof(wbuf) && wbuf[i] != 0; i++); printf("len %d chars, SQLGetData claims %d bytes\n\n", i, (int) wcharlen); /* * Read into a buffer that's slightly too small, so that it would fit * if it wasn't for the LF->CR+LF conversion. */ printf("reading to SQLWCHAR buffer, with LF->CR+LF conversion causing truncation...\n"); rc = SQLGetData(hstmt, 5, SQL_C_WCHAR, wbuf, 42, &wcharlen); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); for (i = 0; i < sizeof(wbuf) && wbuf[i] != 0; i++); printf("len %d chars, SQLGetData claims %d bytes\n\n", i, (int) wcharlen); /* * Print out the string, but on Unix we have to convert it to UTF-8 first. * On Windows we could just use wprintf. */ #if 0 { iconv_t cd = iconv_open("UTF-8", "UCS-2"); char utf8buf[1000]; size_t l; size_t inbytes = wcharlen; size_t outbytes = sizeof(utf8buf); char *obuf = utf8buf; char *ibuf = (char *) wbuf; l = iconv(cd, &ibuf, &inbytes, &obuf, &outbytes); *obuf = 0; printf("inremains %d outremains %d l: %d s: %s\n", inbytes, outbytes, l, utf8buf); } #endif rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/multistmt-test.c000066400000000000000000000067721462406103600214430ustar00rootroot00000000000000#include #include #include #include "common.h" static void print_all_results(HSTMT hstmt) { int i; int rc = SQL_SUCCESS; for (i = 1; rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO; i++) { /*** Verify column metadata/name and row data in each result ***/ printf("--%d\n", i); print_result_meta(hstmt); print_result_with_column_names(hstmt); rc = SQLMoreResults(hstmt); } if (rc != SQL_NO_DATA) CHECK_STMT_RESULT(rc, "SQLMoreResults failed", hstmt); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char *param1; SQLLEN cbParam1; char *param2; SQLLEN cbParam2; SQLSMALLINT colcount; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /*** Simple multi-statement with two queries ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 1; SELECT 2", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_all_results(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** More queries ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 1; SELECT 'foo', 'bar'; SELECT 3; SELECT 4", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_all_results(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Spurious semicolons ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo', 'bar';;; SELECT 'foobar'; ", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_all_results(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Different column name, type and source between results for the same column index ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1; SELECT t, 2 result FROM testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_all_results(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Prepare/Execute a multi-statement with parameters ***/ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT 'first result set', id, t FROM testtab1 WHERE t = ?; SELECT 'second result set', t FROM testtab1 WHERE t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind params */ param1 = "foo"; cbParam1 = 8; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); param2 = "bar"; cbParam2 = 8; rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param2, /* param value ptr */ 0, /* buffer len */ &cbParam2 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); print_all_results(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/notice-test.c000066400000000000000000000034461462406103600206550ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char *sql; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } sql = "CREATE OR REPLACE FUNCTION raisenotice(s text) RETURNS void AS $$" "begin\n" " raise notice 'test notice: %',s;\n" "end;\n" "$$ LANGUAGE plpgsql"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecDirect failed", SQL_HANDLE_STMT, hstmt); exit(1); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeStmt failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* Call the function that gives a NOTICE */ sql = "SELECT raisenotice('foo')"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecDirect failed", SQL_HANDLE_STMT, hstmt); exit(1); } if (rc == SQL_SUCCESS_WITH_INFO) print_diag("got SUCCESS_WITH_INFO", SQL_HANDLE_STMT, hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeStmt failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* * The same, with a really long notice. */ sql = "SELECT raisenotice(repeat('foo', 100))"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecDirect failed", SQL_HANDLE_STMT, hstmt); exit(1); } if (rc == SQL_SUCCESS_WITH_INFO) print_diag("got SUCCESS_WITH_INFO", SQL_HANDLE_STMT, hstmt); rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeStmt failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/numeric-test.c000066400000000000000000000143641462406103600210370ustar00rootroot00000000000000/* * Test cases for dealing with SQL_NUMERIC_STRUCT */ #include #include #include "common.h" static unsigned char hex_to_int(char c) { char result; if (c >= '0' && c <= '9') result = c - '0'; else if (c >= 'a' && c <= 'f') result = c - 'a' + 10; else if (c >= 'A' && c <= 'F') result = c - 'A' + 10; else { fprintf(stderr, "invalid hex-encoded numeric value\n"); exit(1); } return (unsigned char) result; } static void build_numeric_struct(SQL_NUMERIC_STRUCT *numericparam, unsigned char sign, char *hexstr, unsigned char precision, unsigned char scale) { int len; /* parse the hex-encoded value */ memset(numericparam, 0, sizeof(SQL_NUMERIC_STRUCT)); numericparam->sign = sign; numericparam->precision = precision; numericparam->scale = scale; len = 0; while (*hexstr) { if (*hexstr == ' ') { hexstr++; continue; } if (len >= SQL_MAX_NUMERIC_LEN) { fprintf(stderr, "hex-encoded numeric value too long\n"); exit(1); } numericparam->val[len] = hex_to_int(*hexstr) << 4 | hex_to_int(*(hexstr + 1)); hexstr += 2; len++; } } static void test_numeric_param(HSTMT hstmt, unsigned char sign, char *hexval, unsigned char precision, unsigned char scale) { SQL_NUMERIC_STRUCT numericparam; SQLLEN cbParam1; SQLRETURN rc; char buf[200]; build_numeric_struct(&numericparam, sign, hexval, precision, scale); cbParam1 = sizeof(numericparam); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_NUMERIC, /* value type */ SQL_NUMERIC, /* param type */ 0, /* column size (ignored for SQL_INTERVAL_SECOND) */ 0, /* dec digits */ &numericparam, /* param value ptr */ sizeof(numericparam), /* buffer len (ignored for SQL_C_INTERVAL_SECOND) */ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_C_INTERVAL_SECOND) */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecute failed", SQL_HANDLE_STMT, hstmt); } else { /* print result */ rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("sign %u prec %u scale %d val %s:\n %s\n", sign, precision, scale, hexval, buf); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } static void test_numeric_result(HSTMT hstmt, char *numstr) { char sql[100]; SQL_NUMERIC_STRUCT numericres; SQLRETURN rc; /* * assume 'numstr' param to be well-formed (we're testing how the * results come out, not the input handling) */ snprintf(sql, sizeof(sql), "SELECT '%s'::numeric", numstr); rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 1, SQL_C_NUMERIC, &numericres, sizeof(numericres), NULL); CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt); printf("%s:\n sign %u prec %u scale %d val %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", numstr, numericres.sign, numericres.precision, numericres.scale, numericres.val[0], numericres.val[1], numericres.val[2], numericres.val[3], numericres.val[4], numericres.val[5], numericres.val[6], numericres.val[7], numericres.val[8], numericres.val[9], numericres.val[10], numericres.val[11], numericres.val[12], numericres.val[13], numericres.val[14], numericres.val[15]); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** Test binding SQL_NUMERIC_STRUCT params (SQL_C_NUMERIC) ****/ printf("Testing SQL_NUMERIC_STRUCT params...\n\n"); rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT ?::numeric", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* 25.212 (per Microsoft KB 22831) */ test_numeric_param(hstmt, 1, "7C62", 5, 3); /* 24197857161011715162171839636988778104 */ test_numeric_param(hstmt, 1, "78563412 78563412 78563412 78563412", 41, 0); /* 12345678901234567890123456789012345678 */ test_numeric_param(hstmt, 1, "4EF338DE509049C4133302F0F6B04909", 38, 0); /* highest possible non-scaled: 340282366920938463463374607431768211455 */ test_numeric_param(hstmt, 1, "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF", 50, 0); /* positive and negative zero */ test_numeric_param(hstmt, 1, "00", 1, 0); test_numeric_param(hstmt, 0, "00", 1, 0); /* -7.70 */ test_numeric_param(hstmt, 1, "0203", 3, 2); /* 0.12345, with 1-6 digit precision: */ test_numeric_param(hstmt, 1, "3930", 1, 5); test_numeric_param(hstmt, 1, "3930", 2, 5); test_numeric_param(hstmt, 1, "3930", 3, 5); test_numeric_param(hstmt, 1, "3930", 4, 5); test_numeric_param(hstmt, 1, "3930", 5, 5); test_numeric_param(hstmt, 1, "3930", 6, 5); /* large scale with small value */ test_numeric_param(hstmt, 1, "0203", 3, 50); /* medium-sized scale and precision */ test_numeric_param(hstmt, 1, "0203", 25, 80); /* max length output; negative with max scale and decimal dot */ test_numeric_param(hstmt, 0, "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF", 40, 127); /* large scale with small value */ test_numeric_param(hstmt, 1, "0203", 3, 50); /**** Test fetching SQL_NUMERIC_STRUCT results ****/ printf("Testing SQL_NUMERIC_STRUCT results...\n\n"); test_numeric_result(hstmt, "25.212"); test_numeric_result(hstmt, "24197857161011715162171839636988778104"); test_numeric_result(hstmt, "12345678901234567890123456789012345678"); /* highest number */ test_numeric_result(hstmt, "340282366920938463463374607431768211455"); /* overflow */ test_numeric_result(hstmt, "340282366920938463463374607431768211456"); test_numeric_result(hstmt, "340282366920938463463374607431768211457"); test_numeric_result(hstmt, "-0"); test_numeric_result(hstmt, "0"); test_numeric_result(hstmt, "-7.70"); test_numeric_result(hstmt, "999999999999"); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/odbc-escapes-test.c000066400000000000000000000167131462406103600217250ustar00rootroot00000000000000/* * Test ODBC escape syntax */ #include #include #include #include "common.h" static void setParamName(HSTMT hstmt, int paramno, const char *paramname) { SQLHDESC hIpd = NULL; SQLGetStmtAttr(hstmt, SQL_ATTR_IMP_PARAM_DESC, &hIpd, 0, 0); SQLSetDescField(hIpd, paramno, SQL_DESC_NAME, (SQLPOINTER) paramname, SQL_NTS); } /* bind string param as CHAR */ static void bindParamString(HSTMT hstmt, int paramno, const char *paramname, char *str) { SQLRETURN rc; static SQLLEN cbParams[10]; cbParams[paramno] = SQL_NTS; rc = SQLBindParameter(hstmt, paramno, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ str, /* param value ptr */ 0, /* buffer len */ &cbParams[paramno] /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); setParamName(hstmt, paramno, paramname); if (paramname) printf("Param %d (%s): %s\n", paramno, paramname, str); else printf("Param %d: %s\n", paramno, str); } static void bindOutParamString(HSTMT hstmt, int paramno, const char *paramname, char *outbuf, int outbuflen, BOOL inout) { SQLRETURN rc; static SQLLEN cbParams[10]; cbParams[paramno] = SQL_NTS; rc = SQLBindParameter(hstmt, paramno, inout ? SQL_PARAM_INPUT_OUTPUT : SQL_PARAM_OUTPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ outbuf, /* param value ptr */ outbuflen, /* buffer len */ &cbParams[paramno] /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); setParamName(hstmt, paramno, paramname); if (paramname) printf("Param %d (%s) is an %s parameter\n", paramno, paramname, inout ? "I-O": "OUT"); else printf("Param %d is an %s parameter\n", paramno, inout ? "I-O": "OUT"); } static BOOL execDirectMode = 0; static SQLCHAR saveQuery[128]; static void executeQuery(HSTMT hstmt) { SQLRETURN rc; if (execDirectMode) rc = SQLExecDirect(hstmt, saveQuery, SQL_NTS); else rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } static void prepareQuery(HSTMT hstmt, char *str) { SQLRETURN rc; if (execDirectMode) strcpy(saveQuery, str); else { rc = SQLPrepare(hstmt, (SQLCHAR *) str, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); } printf("\nQuery: %s\n", str); } static void escape_test(HSTMT hstmt) { char outbuf1[64], outbuf3[64], outbuf5[64]; BOOL variadic_test_success = 1; /**** Function escapes ****/ /* CONCAT */ prepareQuery(hstmt, "SELECT {fn CONCAT(?, ?) }"); bindParamString(hstmt, 1, NULL, "foo"); bindParamString(hstmt, 2, NULL, "bar"); executeQuery(hstmt); /* LOCATE */ prepareQuery(hstmt, "SELECT {fn LOCATE(?, ?, 2) }"); bindParamString(hstmt, 1, NULL, "needle"); bindParamString(hstmt, 2, NULL, "this is a needle in an ol' haystack"); executeQuery(hstmt); /* LOCATE(SUBSTRING, SUBSTRING) */ prepareQuery(hstmt, "SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) }"); /* using the same parameters */ bindParamString(hstmt, 1, NULL, "needle"); bindParamString(hstmt, 2, NULL, "this is a needle in an ol' haystack"); executeQuery(hstmt); /* SPACE */ prepareQuery(hstmt, "SELECT 'x' || {fn SPACE(10) } || 'x'"); executeQuery(hstmt); /**** CALL escapes ****/ prepareQuery(hstmt, "{ call length(?) }"); bindParamString(hstmt, 1, NULL, "foobar"); executeQuery(hstmt); prepareQuery(hstmt, "{ call right(?, ?) }"); bindParamString(hstmt, 1, NULL, "foobar"); bindParamString(hstmt, 2, NULL, "3"); executeQuery(hstmt); prepareQuery(hstmt, "{ ? = call length('foo') }"); memset(outbuf1, 0, sizeof(outbuf1)); bindOutParamString(hstmt, 1, NULL, outbuf1, sizeof(outbuf1) - 1, 0); executeQuery(hstmt); printf("OUT param: %s\n", outbuf1); /* It's preferable to cast VARIADIC any fields */ prepareQuery(hstmt, "{ ? = call concat(?::text, ?::text) }"); memset(outbuf1, 0, sizeof(outbuf1)); bindOutParamString(hstmt, 1, NULL, outbuf1, sizeof(outbuf1) - 1, 0); bindParamString(hstmt, 2, NULL, "foo"); bindParamString(hstmt, 3, NULL, "bar"); if (variadic_test_success) executeQuery(hstmt); else printf("skip this test because it fails\n"); printf("OUT param: %s\n", outbuf1); /**** Date, Time, and Timestamp literals ****/ prepareQuery(hstmt, "SELECT {d '2014-12-21' } + '1 day'::interval"); executeQuery(hstmt); prepareQuery(hstmt, "SELECT {t '20:30:40' } + '1 hour 1 minute 1 second'::interval"); executeQuery(hstmt); prepareQuery(hstmt, "SELECT {ts '2014-12-21 20:30:40' } + '1 day 1 hour 1 minute 1 second'::interval"); executeQuery(hstmt); /**** call procedure with out and i-o parameters ****/ prepareQuery(hstmt, "{call a_b_c_d_e(?, ?, ?, ?, ?)}"); memset(outbuf1, 0, sizeof(outbuf1)); bindOutParamString(hstmt, 1, NULL, outbuf1, sizeof(outbuf1) - 1, 0); bindParamString(hstmt, 2, NULL, "2017-02-23 11:34:46"); strcpy(outbuf3, "4"); bindOutParamString(hstmt, 3, NULL, outbuf3, sizeof(outbuf3) - 1, 1); bindParamString(hstmt, 4, NULL, "3.4"); memset(outbuf5, 0, sizeof(outbuf5)); bindOutParamString(hstmt, 5, NULL, outbuf5, sizeof(outbuf5) - 1, 0); executeQuery(hstmt); printf("OUT params: %s : %s : %s\n", outbuf1, outbuf3, outbuf5); /**** call procedure parameters by name (e,a,b,c,d) ****/ prepareQuery(hstmt, "{call a_b_c_d_e(?, ?, ?, ?, ?)}"); memset(outbuf5, 0, sizeof(outbuf5)); bindOutParamString(hstmt, 1, "e", outbuf5, sizeof(outbuf5) - 1, 0); memset(outbuf1, 0, sizeof(outbuf1)); bindOutParamString(hstmt, 2, "a", outbuf1, sizeof(outbuf1) - 1, 0); bindParamString(hstmt, 3, "b", "2017-02-23 11:34:46"); strcpy(outbuf3, "4"); bindOutParamString(hstmt, 4, "c", outbuf3, sizeof(outbuf3) - 1, 1); bindParamString(hstmt, 5, "d", "3.4"); executeQuery(hstmt); printf("OUT params: %s : %s : %s\n", outbuf1, outbuf3, outbuf5); /**** call procedure parameters by name (b,c,d,e,a) ****/ prepareQuery(hstmt, "{call a_b_c_d_e(?, ?, ?, ?, ?)}"); bindParamString(hstmt, 1, "b", "2017-02-23 11:34:46"); strcpy(outbuf3, "4"); bindOutParamString(hstmt, 2, "c", outbuf3, sizeof(outbuf3) - 1, 1); bindParamString(hstmt, 3, "d", "3.4"); memset(outbuf5, 0, sizeof(outbuf5)); bindOutParamString(hstmt, 4, "e", outbuf5, sizeof(outbuf5) - 1, 0); memset(outbuf1, 0, sizeof(outbuf1)); bindOutParamString(hstmt, 5, "a", outbuf1, sizeof(outbuf1) - 1, 0); executeQuery(hstmt); printf("OUT params: %s : %s : %s\n", outbuf1, outbuf3, outbuf5); } int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLExecDirect(hstmt, "create or replace function a_b_c_d_e" "(out a float8, in b timestamp, inout c integer, " "in d numeric, out e timestamp) returns record as " "$function$ \n" "DECLARE \n" "BEGIN \n" "a := 2 * d; \n" "e := b + '1 day'::interval; \n" "c := c + 3; \n" "END; \n" "$function$ \n" "LANGUAGE plpgsql\n" , SQL_NTS); CHECK_STMT_RESULT(rc, "create function a_b_c_d_e failed", hstmt); execDirectMode = 0; printf("\n-- TEST using SQLExecute after SQLPrepare\n"); escape_test(hstmt); execDirectMode = 1; printf("\n-- TEST using SQLExecDirect\n"); escape_test(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/param-conversions-test.c000066400000000000000000000142711462406103600230400ustar00rootroot00000000000000/* * Test conversion of parameter values from C to SQL datatypes. */ #include #include #include "common.h" #define TEST_CONVERT(sql, c_type, sql_type, value) \ test_convert(sql, c_type, #c_type, sql_type, #sql_type, value) static void test_convert(const char *sql, SQLSMALLINT c_type, const char *c_type_str, SQLSMALLINT sql_type, const char *sql_type_str, SQLPOINTER value); static HSTMT hstmt = SQL_NULL_HSTMT; int main(int argc, char **argv) { SQLRETURN rc; SQLINTEGER intparam; char byteaparam[] = { 'f', 'o', 'o', '\n', '\\', 'b', 'a', 'r', '\0' }; /* * let's not confuse the output with LF conversions. There's a separate * regression test for that. */ test_connect_ext("LFConversion=0"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /*** Test proper escaping of integer parameters ***/ printf("\nTesting conversions...\n"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_INTEGER, "2"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_INTEGER, "-2"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, "2"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, "-2"); TEST_CONVERT("SELECT 2.2 > ?", SQL_C_CHAR, SQL_FLOAT, "2.3"); TEST_CONVERT("SELECT 3.3 > ?", SQL_C_CHAR, SQL_DOUBLE, "3.01"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_CHAR, "5 escapes: \\ and '"); /* test boundary cases */ TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, "32767"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, "-32768"); /* * The result of these depend on whether the server treats the parameters * as a string or an integer. */ printf("\nTesting conversions whose result depend on whether the\n"); printf("parameter is treated as a string or an integer...\n"); TEST_CONVERT("SELECT '555' > ?", SQL_C_CHAR, SQL_INTEGER, "6"); TEST_CONVERT("SELECT '555' > ?", SQL_C_CHAR, SQL_SMALLINT, "6"); TEST_CONVERT("SELECT '555' > ?", SQL_C_CHAR, SQL_CHAR, "6"); /* * The result of this test depends on what datatype the server thinks * it's dealing with. If the driver sends it as a naked literal, the * server will treat it as a numeric because it doesn't fit in an int4. * But if the driver tells the server what the datatype is, int4, the * server will throw an error. In either case, this isn't something that * a correct application should be doing, because it's clearly not a * valid value for an SQL_INTEGER. But it's an interesting edge case to * test. */ TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_INTEGER, "99999999999999999999999"); printf("\nTesting conversions with invalid values...\n"); TEST_CONVERT("SELECT 2 > ?", SQL_C_CHAR, SQL_INTEGER, "2, 'injected, BAD!'"); TEST_CONVERT("SELECT 2 > ?", SQL_C_CHAR, SQL_SMALLINT, "2, 'injected, BAD!'"); TEST_CONVERT("SELECT 1.3 > ?", SQL_C_CHAR, SQL_FLOAT, "3', 'injected, BAD!', '1"); TEST_CONVERT("SELECT 1.4 > ?", SQL_C_CHAR, SQL_FLOAT, "4 \\'bad', '1"); TEST_CONVERT("SELECT 1-?", SQL_C_CHAR, SQL_INTEGER, "-1"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_INTEGER, "-"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_INTEGER, ""); TEST_CONVERT("SELECT 1-?", SQL_C_CHAR, SQL_SMALLINT, "-1"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, "-"); TEST_CONVERT("SELECT 1 > ?", SQL_C_CHAR, SQL_SMALLINT, ""); intparam = 1234; TEST_CONVERT("SELECT 0-?", SQL_C_SLONG, SQL_INTEGER, &intparam); intparam = -1234; TEST_CONVERT("SELECT 0-?", SQL_C_SLONG, SQL_INTEGER, &intparam); intparam = 1234; TEST_CONVERT("SELECT 0-?", SQL_C_SLONG, SQL_SMALLINT, &intparam); intparam = -1234; TEST_CONVERT("SELECT 0-?", SQL_C_SLONG, SQL_SMALLINT, &intparam); printf("\nTesting bytea conversions\n"); TEST_CONVERT("SELECT ?", SQL_C_BINARY, SQL_BINARY, byteaparam); TEST_CONVERT("SELECT ?", SQL_C_CHAR, SQL_BINARY, "666f6f0001"); TEST_CONVERT("SELECT ?::text", SQL_C_BINARY, SQL_CHAR, byteaparam); printf("\nTesting datetime conversions\n"); TEST_CONVERT("SELECT ?", SQL_C_CHAR, SQL_TIMESTAMP, "04-22-2011 01:23:45"); TEST_CONVERT("SELECT ?", SQL_C_CHAR, SQL_TIMESTAMP, "{ts '2011-04-22 01:23:45'}"); TEST_CONVERT("SELECT ?", SQL_C_CHAR, SQL_TIME, "{t '01:23:45'}"); TEST_CONVERT("SELECT ?", SQL_C_CHAR, SQL_DATE, "{d '2011-04-22'}"); /* Clean up */ test_disconnect(); return 0; } /* * Execute a query with one parameter, with given C and SQL types. Print * error or result. */ static void test_convert(const char *sql, SQLSMALLINT c_type, const char *c_type_str, SQLSMALLINT sql_type, const char *sql_type_str, SQLPOINTER value) { SQLRETURN rc; SQLLEN cbParam = SQL_NTS; int failed = 0; /* Print what we're doing */ switch (c_type) { case SQL_C_SLONG: printf("Testing \"%s\" with %s -> %s param %d...\n", sql, c_type_str, sql_type_str, *((SQLINTEGER *) value)); break; case SQL_C_CHAR: printf("Testing \"%s\" with %s -> %s param \"%s\"...\n", sql, c_type_str, sql_type_str, (char *) value); break; default: printf("Testing \"%s\" with %s -> %s param...\n", sql, c_type_str, sql_type_str); break; } if (c_type == SQL_BINARY) cbParam = strlen(value) + 1; else cbParam = SQL_NTS; /* ignored for non-character data */ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, c_type, /* value type */ sql_type, /* param type */ 20, /* column size */ 0, /* dec digits */ value, /* param value ptr */ 0, /* buffer len */ &cbParam /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecDirect failed", SQL_HANDLE_STMT, hstmt); failed = 1; } else print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * In error_on_rollback=0 mode, we don't currently recover from the error. * I think that's a bug in the driver, but meanwhile, let's just force * a rollback manually */ if (failed) { rc = SQLExecDirect(hstmt, (SQLCHAR *) "ROLLBACK /* clean up after failed test */", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect(ROLLBACK) failed", hstmt); } printf("\n"); } psqlodbc-REL-16_00_0005/test/src/params-batch-exec-test.c000066400000000000000000000076221462406103600226600ustar00rootroot00000000000000#include #include /* Must come before sql.h (declared in common.h) to suppress a warning */ #include "../../pgapifunc.h" #include "common.h" static void b_result(SQLRETURN rc, HSTMT stmt, int repcnt, SQLUSMALLINT status[]) { int i; printf("insert into test_batch returns %d\n", rc); if (!SQL_SUCCEEDED(rc)) print_diag("", SQL_HANDLE_STMT, stmt); /* if (SQL_SUCCESS != rc) disp_stmt_error(stmt); */ for (i = 0; i < repcnt; i++) { printf("row %d status=%s\n", i, (status[i] == SQL_PARAM_SUCCESS ? "success" : (status[i] == SQL_PARAM_UNUSED ? "unused" : (status[i] == SQL_PARAM_ERROR ? "error" : (status[i] == SQL_PARAM_SUCCESS_WITH_INFO ? "success_with_info" : "????") )))); } } #define BATCHCNT 10 static SQLRETURN BatchExecute(HDBC conn, int batch_size) { SQLRETURN rc; HSTMT hstmt; int vals[BATCHCNT] = { 0, 0, 1, 2, 2, 3, 4, 4, 5, 6}; SQLCHAR strs[BATCHCNT][10] = { "0", "0-2", "1", "2", "2-2", "3", "4", "4-2", "5", "6" }; SQLUSMALLINT status[BATCHCNT]; rc = SQLSetConnectAttr(conn, SQL_ATTR_PGOPT_BATCHSIZE, (SQLPOINTER)(SQLLEN)batch_size, 0); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLSetConnectAttr SQL_ATTR_PGOPT_BATCHSIZE failed", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); SQLSetStmtAttr(hstmt , SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)BATCHCNT, 0); SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, status, 0); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, vals, 0, NULL); CHECK_STMT_RESULT(rc, "SQLBindParameter 1 failed", hstmt); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(strs[0]), 0, strs, sizeof(strs[0]), NULL); CHECK_STMT_RESULT(rc, "SQLBindParameter 2 failed", hstmt); rc = SQLExecDirect(hstmt, "INSERT INTO test_batch VALUES (?, ?)" " ON CONFLICT (id) DO UPDATE SET dt=EXCLUDED.dt" , SQL_NTS); b_result(rc, hstmt, BATCHCNT, status); /** rc = SQLExecDirect(hstmt, "SELECT * FROM test_batch where id=?" , SQL_NTS); b_result(rc, hstmt, BATCHCNT, status); SQLCloseCursor(hstmt); **/ strncpy((SQLCHAR *) &strs[BATCHCNT - 3], "4-long", sizeof(strs[0])); rc = SQLExecDirect(hstmt, "INSERT INTO test_batch VALUES (?, ?)" " ON CONFLICT (id) DO UPDATE SET dt=EXCLUDED.dt" , SQL_NTS); b_result(rc, hstmt, BATCHCNT, status); rc = SQLFreeStmt(hstmt, SQL_DROP); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); return rc; } int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Drop the existent tables */ rc = SQLExecDirect(hstmt, "drop table if exists test_batch", SQL_NTS); CHECK_STMT_RESULT(rc, "drop table failed", hstmt); /* Create temp table */ rc = SQLExecDirect(hstmt, "create temporary table test_batch(id int4 primary key, dt varchar(4))", SQL_NTS); CHECK_STMT_RESULT(rc, "create table failed", hstmt); /* Create function */ rc = SQLExecDirect(hstmt, "CREATE OR REPLACE FUNCTION batch_update_notice() RETURNS TRIGGER" " AS $$" " BEGIN" " RAISE NOTICE 'id=% updated', NEW.id;" " RETURN NULL;" " END;" " $$ LANGUAGE plpgsql" , SQL_NTS); CHECK_STMT_RESULT(rc, "create function failed", hstmt); /* Create trigger */ rc = SQLExecDirect(hstmt, "CREATE TRIGGER batch_update_notice" " BEFORE update on test_batch" " FOR EACH ROW EXECUTE PROCEDURE batch_update_notice()" , SQL_NTS); CHECK_STMT_RESULT(rc, "create trigger failed", hstmt); /* 1 by 1 executiton */ printf("one by one execution\n"); BatchExecute(conn, 1); /* Truncate table */ rc = SQLExecDirect(hstmt, "truncate table test_batch", SQL_NTS); CHECK_STMT_RESULT(rc, "truncate table failed", hstmt); /* batch executiton batch_size=2*/ printf("batch execution\n"); BatchExecute(conn, 2); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/params-test.c000066400000000000000000000134711462406103600206560ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[20] = { 1, 2, 3, 4, 5, 6, 7, 8 }; SQLLEN cbParam1; SQLSMALLINT colcount; SQLSMALLINT dataType; SQLULEN paramSize; SQLSMALLINT decDigits; SQLSMALLINT nullable; SQLUSMALLINT supported; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Prepare a test table */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE tmptable (i int4, t text)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt); /**** Query with a bytea param ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM byteatab WHERE t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ cbParam1 = 8; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_BINARY, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test SQLBindParameter with SQLExecDirect ***/ printf("\nTesting SQLBindParameter with SQLExecDirect...\n"); /* bind param */ strcpy(param1, "bar"); cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo' UNION ALL SELECT ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test SQLBindParameter with NULL param ***/ printf("\nTesting SQLBindParameter with NULL param...\n"); cbParam1 = SQL_NULL_DATA; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ NULL, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT ? || 'foobar'", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test SQLBindParameter with an integer NULL param ***/ printf("\nTesting SQLBindParameter with integer NULL param...\n"); cbParam1 = SQL_NULL_DATA; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, /* value type */ SQL_INTEGER, /* param type */ 20, /* column size */ 0, /* dec digits */ NULL, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO tmptable (i) values (1 + ?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test SQLDescribeParam ***/ printf("\nTesting SQLDescribeParam...\n"); rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE id = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* * SQLDescribeParam is not supported in UseServerSidePrepare=0 mode, so * check for IM001 result and continue the test if we get that. */ rc = SQLGetFunctions(conn, SQL_API_SQLDESCRIBEPARAM, &supported); CHECK_CONN_RESULT(rc, "SQLGetFunctions failed", conn); if (supported) { rc = SQLDescribeParam(hstmt, 1, &dataType, ¶mSize, &decDigits, &nullable); CHECK_STMT_RESULT(rc, "SQLDescribeParam failed", hstmt); printf("Param 1: type %s; size %u; dec digits %d; %s\n", datatype_str(dataType), (unsigned int) paramSize, decDigits, nullable_str(nullable)); } else printf("Skipped, SQLDescribeParam is not supported\n"); /* bind param */ strcpy(param1, "3"); cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/parse-test.c000066400000000000000000000054131462406103600205020ustar00rootroot00000000000000/* * Test driver's query parsing functionality. * * (People should be using server-side parsing nowadays, though...) */ #include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect_ext("Parse=1;DisallowPremature=1"); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /*** Simple case ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result_meta(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test quoting ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT \"id\", \"t\" FROM \"testtab1\"", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result_meta(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Test quoting ***/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT \"id\", \"t\", 'foo''bar' AS \"con\"\"stant\" FROM \"testtab1\"", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result_meta(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Test handling of True(MSACCESS) * ("a_boolean_item" = 1) => ("a_boolean_item"='1') */ rc = SQLSetConnectAttr(conn, 65549, (SQLPOINTER) 1, 0); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT relname FROM pg_class where (\"relisshared\" = 1)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect for boolean = 1 for MSACCESS failed", hstmt); rc = SQLSetConnectAttr(conn, 65549, (SQLPOINTER) 0, 0); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*/ * Do the following 2 queries work in declare/fetch mode? */ /* Do the driver detect *for update* and suppress *Declare .. cursor for* clause? */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id FROM \"testtab1\"for update", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect for SELECT ... FOR UPDATE failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Do the driver detect *select .. into* and suppress *Declare .. cursor for* clause? */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT\"id\"into\"testtab2\"from\"testtab1\"", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect for SELECT .. INTO failed", hstmt); /* INSERT INTO ... () values () => INSERT INTO ... DEFAULT VALUES */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "insert into testtab2 () values ()", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect for INSERT INTO ... () failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/positioned-update-test.c000066400000000000000000000127151462406103600230300ustar00rootroot00000000000000#include #include #include #include "common.h" void printCurrentRow(HSTMT hstmt) { char buf[40]; int col; SQLLEN ind; int rc; for (col = 1; col <= 2; col++) { rc = SQLGetData(hstmt, col, SQL_C_CHAR, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); exit(1); } if (ind == SQL_NULL_DATA) strcpy(buf, "NULL"); printf("%s%s", (col > 1) ? "\t" : "", buf); } printf("\n"); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; int i; SQLUINTEGER cursor_type; SQLINTEGER colvalue; SQLLEN indColvalue; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * Initialize a table with some test data. */ printf("Creating test table pos_update_test\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE pos_update_test(i int4, orig int4 primary key)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO pos_update_test SELECT g, g FROM generate_series(1, 10) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); printf("Opening a cursor for update, and fetching 10 rows\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_LONG, &colvalue, 0, &indColvalue); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM pos_update_test ORDER BY orig", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLGetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) &cursor_type, 0, NULL); printf("exec cursor_type=%d\n", cursor_type); for (i = 0; i < 5; i++) { rc = SQLFetch(hstmt); if (rc == SQL_NO_DATA) break; if (rc == SQL_SUCCESS) { printCurrentRow(hstmt); } else { print_diag("SQLFetch failed", SQL_HANDLE_STMT, hstmt); exit(1); } } /* Do a positioned update and delete */ printf("\nUpdating result set\n"); colvalue += 50; rc = SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos 1st UPDATE failed", hstmt); colvalue += 50; rc = SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos 2nd UPDATE failed", hstmt); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLSetPos(hstmt, 1, SQL_REFRESH, SQL_LOCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos REFRESH failed", hstmt); rc = SQLSetPos(hstmt, 1, SQL_DELETE, SQL_LOCK_NO_CHANGE); CHECK_STMT_RESULT(rc, "SQLSetPos DELETE failed", hstmt); /**** See if the updates are reflected in the still-open result set ***/ printf("\nRe-fetching the rows in the result set\n"); rc = SQLFetchScroll(hstmt, SQL_FETCH_RELATIVE, 0); CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); printCurrentRow(hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, -1); CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); printCurrentRow(hstmt); rc = SQLFetchScroll(hstmt, SQL_FETCH_PRIOR, -1); CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt); printCurrentRow(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** See if the updates really took effect ****/ printf("\nQuerying the table again\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM pos_update_test ORDER BY orig", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /*** Check that the code can deal with large keysets correctly. * * There was a bug in the reallocation in old driver versions. */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO pos_update_test SELECT g, g FROM generate_series(100, 5000) g", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Set Fetch option, and create a new statement to reflect the new * setting. */ { SQLINTEGER fetch_val = 10000; rc = SQLSetConnectAttr(conn, 65541, /* SQL_ATTR_PGOPT_FETCH */ &fetch_val, SQL_IS_INTEGER); CHECK_STMT_RESULT(rc, "SQLSetConnectAttr failed", hstmt); } rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "SQLAllocHandle failed", conn); printf("\nOpening a cursor for update, and fetching 5000 rows\n"); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); CHECK_STMT_RESULT(rc, "SQLSetStmtAttr failed", hstmt); rc = SQLBindCol(hstmt, 1, SQL_C_LONG, &colvalue, 0, &indColvalue); CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM pos_update_test ORDER BY orig", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/premature-test.c000066400000000000000000000117061462406103600213760ustar00rootroot00000000000000/* * This test case tests the case that a query needs to be described before * executing it. That happens when an application calls e.h. SQLDescribeCol() * or SQLNumResultCols() after preparing a query with SQLPrepare(), but * before calling SQLExecute(). * * The driver used to have an option to do so-called "premature execution", * where it simply executed the driver prematurely, before the SQLExecute() * call. That was of course quite dangerous, if the query was not read-only, * and the application didn't follow through with the SQLExecute(). It could * be disabled with the DisallowPremature setting. The driver doesn't do * that anymore, but it's a good case to test. */ #include #include #include "common.h" static void runtest(const char *query, char *bind_before, char *bind_after, int execute) { SQLRETURN rc; HSTMT hstmt; SQLLEN cbParam1; SQLSMALLINT colcount; rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "SQLAllocHandle failed", conn); rc = SQLPrepare(hstmt, (SQLCHAR *) query, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); if (bind_before) { cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ bind_before, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); } /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); if (bind_after) { cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ bind_after, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); } /* Don't execute the statement! The row should not be inserted. */ /* And execute */ if (execute) { rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); } rc = SQLFreeStmt(hstmt, SQL_DROP); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); CHECK_CONN_RESULT(rc, "SQLAllocHandle failed", conn); /**** Set up a test table and function ****/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE premature_test (t text)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE OR REPLACE FUNCTION insertfunc (t text) RETURNS text AS " "$$ INSERT INTO premature_test VALUES ($1) RETURNING 'func insert'::text $$ " "LANGUAGE sql", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * First, try with a plain INSERT. Prepare the statement, run * SQLNumResultCols() which forces the statement to be sent and parsed * in the backend. */ printf("\nPreparing an INSERT statement\n"); runtest("INSERT INTO premature_test VALUES (?) RETURNING 'plain insert'::text", "plain insert", NULL, 0); /* same with no parameter bound */ runtest("INSERT INTO premature_test VALUES (?) RETURNING 'plain insert'::text", NULL, NULL, 0); /*** Now, do the same with the function ***/ printf("\nPreparing an insert using a function\n"); runtest("SELECT insertfunc(?)", "function insert", NULL, 0); runtest("SELECT insertfunc(?)", NULL, NULL, 0); /*** Same with the function, used in a multi-statement ***/ printf("\nPreparing a multi-statement\n"); runtest("SELECT 'foo', 2, 3; SELECT insertfunc(?), 2; SELECT 'bar'", "function insert in multi-statement", NULL, 0); runtest("SELECT 'foo', 2, 3; SELECT insertfunc(?), 2; SELECT 'bar'", NULL, NULL, 0); /*** Again with the function, but this time execute it too. With a * twist: we rebind a different parameter after the SQLNumResultCols * call. */ printf("\nPrepare with function, but execute with different param\n"); runtest("SELECT insertfunc(?)", "function insert wrong", "function insert right", 1); /*** Now check that the table contains only the last insertion ***/ printf("\nChecking table contents. Should contain only one row.\n"); rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM premature_test", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/prepare-test.c000066400000000000000000000176221462406103600210330ustar00rootroot00000000000000#include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char *param1; SQLLEN cbParam1; SQLINTEGER longparam; SQL_INTERVAL_STRUCT intervalparam; SQLSMALLINT colcount; char byteaParam[5000]; int i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /**** A simple query with one text param ****/ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SET intervalstyle=postgres_verbose", SQL_NTS); /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE t = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ param1 = "bar"; cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** A query with an integer param ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE id = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ longparam = 3; cbParam1 = sizeof(longparam); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, /* value type */ SQL_INTEGER, /* param type */ 0, /* column size (ignored for SQL_INTEGER) */ 0, /* dec digits */ &longparam, /* param value ptr */ sizeof(longparam), /* buffer len (ignored for SQL_INTEGER) */ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** Test a query with a bytea param of various sizes. ****/ /* * The driver has some special handling for byteas, as it sends them in * binary mode. This particular test case exercises an old bug where * the bind packet size was calculated incorrectly, and there was an * out-of-bounds write of two bytes when the total packet size was exactly * 4097 bytes. So, exercise packet sizes near that boundary. */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "CREATE TEMPORARY TABLE btest (len int4, b bytea)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "INSERT INTO btest VALUES(?, ?)", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* fill in test data */ for (i = 0; i < sizeof(byteaParam); i++) byteaParam[i] = (char) i; printf ("inserting bytea values..."); for (i = 4000; i < 4100; i++) { printf(" %d", i); fflush(stdout); /* bind int param */ longparam = i; cbParam1 = sizeof(longparam); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, /* value type */ SQL_INTEGER, /* param type */ 0, /* column size (ignored for SQL_INTEGER) */ 0, /* dec digits */ &longparam, /* param value ptr */ sizeof(longparam), /* buffer len (ignored for SQL_INTEGER) */ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */); CHECK_STMT_RESULT(rc, "\nSQLBindParameter failed", hstmt); cbParam1 = i; rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, /* value type */ SQL_VARBINARY, /* param type */ sizeof(byteaParam), /* column size */ 0, /* dec digits */ byteaParam, /* param value ptr */ sizeof(byteaParam), /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "\nSQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "\nSQLExecute failed", hstmt); } printf(" done!\n"); printf("Now reading them back...\n"); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Check the inserted data */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT len, length(b) FROM btest", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** A query with an interval param (SQL_C_INTERVAL_SECOND) ****/ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, iv, d FROM intervaltable WHERE iv < ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ intervalparam.interval_type = SQL_IS_SECOND; intervalparam.interval_sign = 0; intervalparam.intval.day_second.day = 1; intervalparam.intval.day_second.hour = 2; intervalparam.intval.day_second.minute = 3; intervalparam.intval.day_second.second = 4; intervalparam.intval.day_second.fraction = 5; cbParam1 = sizeof(intervalparam); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTERVAL_SECOND, /* value type */ SQL_INTERVAL_SECOND, /* param type */ 0, /* column size (ignored for SQL_INTERVAL_SECOND) */ 0, /* dec digits */ &intervalparam, /* param value ptr */ sizeof(intervalparam), /* buffer len (ignored for SQL_C_INTERVAL_SECOND) */ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_C_INTERVAL_SECOND) */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /**** * With BoolsAsChar=1, a varchar param with column_size=5 forces a * server-side Prepare. So test that. */ /* Prepare a statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE id = ?", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); /* bind param */ param1 = "2"; cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_VARCHAR, /* param type */ 5, /* column size. 5 Triggers special * behavior with BoolsAsChar=1 */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Test SQLNumResultCols/SQLDescribeCol, called before SQLExecute() */ rc = SQLNumResultCols(hstmt, &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); for (i = 1; i <= colcount; i++) { SQLCHAR colname[64]; SQLSMALLINT collen, type, scale; SQLULEN len; rc = SQLDescribeCol(hstmt, i, colname, sizeof(colname), &collen, &type, &len, &scale, NULL); CHECK_STMT_RESULT(rc, "SQLDescribeCol failed", hstmt); printf("col:%d name=%s type=%d len=%d\n", i, colname, type, (int) len); } /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Fetch result */ print_result(hstmt); rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLFreeStmt failed", SQL_HANDLE_STMT, hstmt); exit(1); } /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/quotes-test.c000066400000000000000000000063731462406103600207160ustar00rootroot00000000000000/* Test parameter quoting, with standard_conforming_strings on/off */ #include #include #include #include "common.h" static void execWithParam(HSTMT hstmt, char *sql, char *param) { SQLLEN cbParam1; int rc; printf("Executing: %s with param: %s\n", sql, param); /* bind param */ cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } void runtest(HSTMT hstmt, int scs) { /* Turn standard_conforming_strings on or off, as requested by caller */ char sql[50]; int rc; snprintf(sql, sizeof(sql), "SET standard_conforming_strings=%s", scs ? "on" : "off"); printf("\n%s\n", sql); rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* * Check that the driver escapes quotes correctly when sending * parameters to the server. (This is mostly of concern with * UseServerSidePrepare=0, but it's worth checking with * UseServerSidePrepare=1 too, to make sure that the driver doesn't * incorrectly quote values sent as out-of-band parameters when it * shouldn't do so. */ execWithParam(hstmt, "SELECT 'foo', ?::text", "param'quote"); execWithParam(hstmt, "SELECT 'foo', ?::text", "param\\backslash"); execWithParam(hstmt, "SELECT 'foo', ?::text", "ends with backslash\\"); /* * Check that the driver's built-in parser interprets quotes * correctly. It needs to know about quoting so that it can * distinguish between ? parameter markers and ? question marks * within string literals. */ execWithParam(hstmt, "SELECT 'doubled '' quotes', ?::text", "param"); execWithParam(hstmt, "SELECT E'escaped quote\\' here', ?::text", "param"); execWithParam(hstmt, "SELECT $$dollar quoted string$$, ?::text", "param"); execWithParam(hstmt, "SELECT $xx$complex $dollar quotes$xx$, ?::text", "param"); execWithParam(hstmt, "SELECT $dollar$morecomplex $dollar quotes$dollar$, ?::text", "param"); /* * With standards_conforming_strings off, also test backslash escaping * without the E'' syntax. */ if (!scs) execWithParam(hstmt, "SELECT 'escaped quote\\' here', ?::text", "param"); /* Some tests with '$'s in identifiers. */ execWithParam(hstmt, "SELECT ?::text, '1' a$1", "$ in an identifier"); execWithParam(hstmt, "SELECT '1'::text a$$S1,?::text,$$2 $'s in an identifier$$::text", "param"); } int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } runtest(hstmt, 1); runtest(hstmt, 0); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/result-conversions-test.c000066400000000000000000000462571462406103600232670ustar00rootroot00000000000000/* * Test conversion of values received from server to SQL datatypes. * */ #include #include #include #include #include #ifdef WIN32 #include #endif #include "common.h" /* Visual Studio didn't have isinf and isinf until VS2013. */ #if defined (WIN32) && (_MSC_VER < 1800) #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF)) #define isnan(x) _isnan(x) #endif static const char *pgtypes[] = { /* * This query uses every PostgreSQL data type the driver recognizes, * i.e. that has a PG_TYPE_* code. */ "true", "boolean", "\\x464F4F", "bytea", "x", "char", "namedata", "name", "1234567890", "int8", "12345", "int2", "1 2 3 4 5", "int2vector", "1234567", "int4", "int4pl", "regproc", "textdata", "text", /* "3234567901", "oid", */ /* OID can be confused with large objects */ "(1,2)", "tid", "1234", "xid", "4321", "cid", "1 2 3", "oidvector", "bar", "xml", "{bar}", "_xml", "10.0.0.1", "cidr", "1.234", "float4", "1.23456789012", "float8", // "2011-01-14 16:49:18+03", "abstime", // abstime was removed in PG12 "foo", "unknown", "1.23", "money", "08-00-2b-01-02-03", "macaddr", "10.0.0.1", "inet", "{foo, bar}", "_text", "{foo, bar}", "_bpchar", "{foo, bar}", "_varchar", "foobar", "bpchar", "foobar", "varchar", "2011-02-13", "date", "13:23:34", "time", "2011-02-15 15:49:18", "timestamp", "2011-02-16 17:49:18+03", "timestamptz", "10 years -11 months -12 days +13:14", "interval", "1", "bit", "1234.567890", "numeric", "foocur", "refcursor", NULL }; #define X(sqltype) { sqltype, #sqltype } static const struct { int sqltype; char *str; } sqltypes[] = { X(SQL_C_CHAR), X(SQL_C_WCHAR), X(SQL_C_SSHORT), X(SQL_C_USHORT), X(SQL_C_SLONG), X(SQL_C_ULONG), X(SQL_C_FLOAT), X(SQL_C_DOUBLE), X(SQL_C_BIT), X(SQL_C_STINYINT), X(SQL_C_UTINYINT), X(SQL_C_SBIGINT), X(SQL_C_UBIGINT), X(SQL_C_BINARY), X(SQL_C_BOOKMARK), X(SQL_C_VARBOOKMARK), /* * Converting arbitrary things to date and timestamp produces results that * depend on the current timestamp, because the driver substitutes the * current year/month/datefor missing values. Disable for now, to get a * reproducible result. */ /* X(SQL_C_TYPE_DATE), */ X(SQL_C_TYPE_TIME), /* X(SQL_C_TYPE_TIMESTAMP), */ X(SQL_C_NUMERIC), X(SQL_C_GUID), X(SQL_C_INTERVAL_YEAR), X(SQL_C_INTERVAL_MONTH), X(SQL_C_INTERVAL_DAY), X(SQL_C_INTERVAL_HOUR), X(SQL_C_INTERVAL_MINUTE), X(SQL_C_INTERVAL_SECOND), X(SQL_C_INTERVAL_YEAR_TO_MONTH), X(SQL_C_INTERVAL_DAY_TO_HOUR), X(SQL_C_INTERVAL_DAY_TO_MINUTE), X(SQL_C_INTERVAL_DAY_TO_SECOND), X(SQL_C_INTERVAL_HOUR_TO_MINUTE), X(SQL_C_INTERVAL_HOUR_TO_SECOND), X(SQL_C_INTERVAL_MINUTE_TO_SECOND), { 0, NULL } }; static HSTMT hstmt = SQL_NULL_HSTMT; void printwchar(SQLWCHAR *wstr) { int i = 0; /* * a backstop to make sure we terminate if the string isn't null-terminated * properly */ int MAXLEN = 50; while(*wstr && i < MAXLEN) { if ((*wstr & 0xFFFFFF00) == 0 && isprint(*wstr)) printf("%c", *wstr); else printf("\\%4X", *wstr); wstr++; i++; } } void printhex(unsigned char *b, SQLLEN len) { SQLLEN i; printf("hex: "); for (i = 0; i < len; i++) printf("%02X", b[i]); } void printdouble(double d) { /* * printf() can print NaNs and infinite values too, but the output is * platform dependent. */ if (isnan(d)) printf("nan"); else if (d < 0 && isinf(d)) printf("-inf"); else if (isinf(d)) printf("inf"); else printf("%f", d); } void print_sql_type(int sql_c_type, void *buf, SQLLEN strlen_or_ind, int use_time) { switch(sql_c_type) { case SQL_C_CHAR: printf("%s", (char *) buf); break; case SQL_C_WCHAR: printwchar((SQLWCHAR *) buf); break; case SQL_C_SSHORT: printf("%hd", *((short *) buf)); break; case SQL_C_USHORT: printf("%hu", *((unsigned short *) buf)); break; case SQL_C_SLONG: /* always 32-bits, regardless of native 'long' type */ printf("%d", (int) *((SQLINTEGER *) buf)); break; case SQL_C_ULONG: printf("%u", (unsigned int) *((SQLUINTEGER *) buf)); break; case SQL_C_FLOAT: printdouble(*((SQLREAL *) buf)); break; case SQL_C_DOUBLE: printdouble(*((SQLDOUBLE *) buf)); break; case SQL_C_BIT: printf("%u", *((unsigned char *) buf)); break; case SQL_C_STINYINT: printf("%d", *((signed char *) buf)); break; case SQL_C_UTINYINT: printf("%u", *((unsigned char *) buf)); break; case SQL_C_SBIGINT: /* XXX: the %ld format string won't handle the full 64-bit range on * all platforms. */ printf("%ld", (long) *((SQLBIGINT *) buf)); break; case SQL_C_UBIGINT: /* XXX: the %lu format string won't handle the full 64-bit range on * all platforms. */ printf("%lu", (unsigned long) *((SQLUBIGINT *) buf)); break; case SQL_C_BINARY: printhex((unsigned char *) buf, strlen_or_ind); break; /* SQL_C_BOOKMARK has same value as SQL_C_UBIGINT */ /* SQL_C_VARBOOKMARK has same value as SQL_C_BINARY */ case SQL_C_TYPE_DATE: { DATE_STRUCT *ds = (DATE_STRUCT *) buf; if (use_time != 0) { time_t t = 0; struct tm *tim; t = time(NULL); tim = localtime(&t); printf("y: %d m: %u d: %u", ds->year - (tim->tm_year + 1900), ds->month - (tim->tm_mon + 1), ds->day - tim->tm_mday); } else printf("y: %d m: %u d: %u", ds->year, ds->month, ds->day); } break; case SQL_C_TYPE_TIME: { TIME_STRUCT *ts = (TIME_STRUCT *) buf; if (use_time != 0) { time_t t = 0; t = time(NULL); } else printf("h: %d m: %u s: %u", ts->hour, ts->minute, ts->second); } break; case SQL_C_TYPE_TIMESTAMP: { TIMESTAMP_STRUCT *tss = (TIMESTAMP_STRUCT *) buf; if (use_time) { time_t t = 0; struct tm *tim; t = time(NULL); tim = localtime(&t); printf("y: %d m: %u d: %u h: %d m: %u s: %u f: %u", tss->year - (tim->tm_year + 1900), tss->month - (tim->tm_mon + 1), tss->day - tim->tm_mday, tss->hour, tss->minute, tss->second, (unsigned int) tss->fraction); } else printf("y: %d m: %u d: %u h: %d m: %u s: %u f: %u", tss->year, tss->month, tss->day, tss->hour, tss->minute, tss->second, (unsigned int) tss->fraction); } break; case SQL_C_NUMERIC: { SQL_NUMERIC_STRUCT *ns = (SQL_NUMERIC_STRUCT *) buf; int i; printf("precision: %u scale: %d sign: %d val: ", ns->precision, ns->scale, ns->scale); for (i = 0; i < SQL_MAX_NUMERIC_LEN; i++) printf("%02x", ns->val[i]); } break; case SQL_C_GUID: { SQLGUID *g = (SQLGUID *) buf; printf("d1: %04X d2: %04X d3: %04X d4: %02X%02X%02X%02X%02X%02X%02X%02X", (unsigned int) g->Data1, g->Data2, g->Data3, g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3], g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]); } break; case SQL_C_INTERVAL_YEAR: case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_DAY: case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_YEAR_TO_MONTH: case SQL_C_INTERVAL_DAY_TO_HOUR: case SQL_C_INTERVAL_DAY_TO_MINUTE: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: { SQL_INTERVAL_STRUCT *s = (SQL_INTERVAL_STRUCT *) buf; printf("interval sign: %u ", s->interval_sign); switch(s->interval_type) { case SQL_IS_YEAR: printf("year: %u", (unsigned int) s->intval.year_month.year); break; case SQL_IS_MONTH: printf("year: %u", (unsigned int) s->intval.year_month.month); break; case SQL_IS_DAY: printf("day: %u", (unsigned int) s->intval.day_second.day); break; case SQL_IS_HOUR: printf("hour: %u", (unsigned int) s->intval.day_second.hour); break; case SQL_IS_MINUTE: printf("minute: %u", (unsigned int) s->intval.day_second.minute); break; case SQL_IS_SECOND: printf("second: %u", (unsigned int) s->intval.day_second.second); break; case SQL_IS_YEAR_TO_MONTH: printf("year %u month: %u", (unsigned int) s->intval.year_month.year, (unsigned int) s->intval.year_month.month); break; case SQL_IS_DAY_TO_HOUR: printf("day: %u hour: %u", (unsigned int) s->intval.day_second.day, (unsigned int) s->intval.day_second.hour); break; case SQL_IS_DAY_TO_MINUTE: printf("day: %u hour: %u minute: %u", (unsigned int) s->intval.day_second.day, (unsigned int) s->intval.day_second.hour, (unsigned int) s->intval.day_second.minute); break; case SQL_IS_DAY_TO_SECOND: printf("day: %u hour: %u minute: %u second: %u fraction: %u", (unsigned int) s->intval.day_second.day, (unsigned int) s->intval.day_second.hour, (unsigned int) s->intval.day_second.minute, (unsigned int) s->intval.day_second.second, (unsigned int) s->intval.day_second.fraction); break; case SQL_IS_HOUR_TO_MINUTE: printf("hour: %u minute: %u", (unsigned int) s->intval.day_second.hour, (unsigned int) s->intval.day_second.minute); break; case SQL_IS_HOUR_TO_SECOND: printf("hour: %u minute: %u second: %u fraction: %u", (unsigned int) s->intval.day_second.hour, (unsigned int) s->intval.day_second.minute, (unsigned int) s->intval.day_second.second, (unsigned int) s->intval.day_second.fraction); break; case SQL_IS_MINUTE_TO_SECOND: printf("minute: %u second: %u fraction: %u", (unsigned int) s->intval.day_second.minute, (unsigned int) s->intval.day_second.second, (unsigned int) s->intval.day_second.fraction); break; default: printf("unknown interval type: %u", s->interval_type); break; } } break; default: printf("unknown SQL C type: %u", sql_c_type); break; } } /* * Get the size of fixed-length data types, or -1 for var-length types */ int get_sql_type_size(int sql_c_type) { switch(sql_c_type) { case SQL_C_CHAR: return -1; case SQL_C_WCHAR: return -1; case SQL_C_SSHORT: return sizeof(short); case SQL_C_USHORT: return sizeof(unsigned short); case SQL_C_SLONG: /* always 32-bits, regardless of native 'long' type */ return sizeof(SQLINTEGER); case SQL_C_ULONG: return sizeof(SQLUINTEGER); case SQL_C_FLOAT: return sizeof(SQLREAL); case SQL_C_DOUBLE: return sizeof(SQLDOUBLE); case SQL_C_BIT: return sizeof(unsigned char); case SQL_C_STINYINT: return sizeof(signed char); case SQL_C_UTINYINT: return sizeof(unsigned char); case SQL_C_SBIGINT: return sizeof(SQLBIGINT); case SQL_C_UBIGINT: return sizeof(SQLUBIGINT); case SQL_C_BINARY: return -1; /* SQL_C_BOOKMARK has same value as SQL_C_UBIGINT */ /* SQL_C_VARBOOKMARK has same value as SQL_C_BINARY */ case SQL_C_TYPE_DATE: return sizeof(DATE_STRUCT); case SQL_C_TYPE_TIME: return sizeof(TIME_STRUCT); case SQL_C_TYPE_TIMESTAMP: return sizeof(TIMESTAMP_STRUCT); case SQL_C_NUMERIC: return sizeof(SQL_NUMERIC_STRUCT); case SQL_C_GUID: return sizeof(SQLGUID); case SQL_C_INTERVAL_YEAR: case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_DAY: case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_YEAR_TO_MONTH: case SQL_C_INTERVAL_DAY_TO_HOUR: case SQL_C_INTERVAL_DAY_TO_MINUTE: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: return sizeof(SQL_INTERVAL_STRUCT); default: printf("unknown SQL C type: %u", sql_c_type); return -1; } } static char *resultbuf = NULL; void test_conversion(const char *pgtype, const char *pgvalue, int sqltype, const char *sqltypestr, int buflen, int use_time) { char sql[500]; SQLRETURN rc; SQLLEN len_or_ind; int fixed_len; printf("'%s' (%s) as %s: ", pgvalue, pgtype, sqltypestr); if (resultbuf == NULL) resultbuf = malloc(500); memset(resultbuf, 0xFF, 500); fixed_len = get_sql_type_size(sqltype); if (fixed_len != -1) buflen = fixed_len; if (buflen == -1) { printf("no buffer length given!"); exit(1); } /* * Use dollar-quotes to make the test case insensitive to * standards_conforming_strings. Some of the test values we use contain * backslashes. */ snprintf(sql, sizeof(sql), "SELECT $$%s$$::%s AS %s_col /* convert to %s */", pgvalue, pgtype, pgtype, sqltypestr); rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFetch(hstmt); CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt); rc = SQLGetData(hstmt, 1, sqltype, resultbuf, buflen, &len_or_ind); if (SQL_SUCCEEDED(rc)) { print_sql_type(sqltype, resultbuf, len_or_ind, use_time); if (rc == SQL_SUCCESS_WITH_INFO) { char sqlstate[10]; rc = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, sqlstate, NULL, NULL, 0, NULL); if (!SQL_SUCCEEDED(rc) && SQL_NO_DATA != rc) print_diag(" SQLGetDiagRec failed", SQL_HANDLE_STMT, hstmt); else { if (memcmp(sqlstate, "01004", 5) == 0) printf(" (truncated)"); else if (SQL_NO_DATA == rc && IsAnsi()) /* maybe */ printf(" (truncated)"); else print_diag("SQLGetData success with info", SQL_HANDLE_STMT, hstmt); } } /* just in order to fix ansi driver test on Windows */ else if (1 <= buflen && SQL_C_WCHAR == sqltype && 0 == len_or_ind && 0 == strcmp(pgtype, "text") && IsAnsi()) printf(" (truncated)"); printf("\n"); /* Check that the driver didn't write past the buffer */ if ((unsigned char) resultbuf[buflen] != 0xFF) printf("For %s Driver wrote byte %02X past result buffer of size %d!\n", sql, (unsigned char) resultbuf[buflen], buflen); } else { /* some of the conversions throw an error; that's OK */ print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); } rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); fflush(stdout); } /* A helper function to execute one command */ void exec_cmd(char *sql) { SQLRETURN rc; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); printf("Executed: %s\n", sql); } int main(int argc, char **argv) { SQLRETURN rc; int sqltype_i; int pgtype_i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* * The interval stuff requires intervalstyle=postgres at the momemnt. * Someone should fix the driver to understand other formats, * postgres_verbose in particular... */ exec_cmd("SET intervalstyle=postgres"); SQLExecDirect(hstmt, (SQLCHAR *) "SET timezone=-08", SQL_NTS); /* * Use octal escape bytea format in the tests. We will test the conversion * from the hex format separately later. */ exec_cmd("SET bytea_output=escape"); exec_cmd("SET lc_monetary='C'"); /* Test all combinations of PostgreSQL data types and SQL datatypes */ for (pgtype_i = 0; pgtypes[pgtype_i * 2] != NULL; pgtype_i++) { const char *value = pgtypes[pgtype_i * 2]; const char *pgtype = pgtypes[pgtype_i * 2 +1]; for (sqltype_i = 0; sqltypes[sqltype_i].str != NULL; sqltype_i++) { int sqltype = sqltypes[sqltype_i].sqltype; const char *sqltypestr = sqltypes[sqltype_i].str; test_conversion(pgtype, value, sqltype, sqltypestr, 100, 0); } } /* * Test a few things separately that were not part of the exhaustive test * above. */ /* Conversions from bytea, in the hex format */ /* * Use octal escape bytea format in the tests. We will test the conversion * from the hex format separately later. */ exec_cmd("SET bytea_output=hex"); test_conversion("bytea", "\\x464F4F", SQL_C_CHAR, "SQL_C_CHAR", 100, 0); test_conversion("bytea", "\\x464F4F", SQL_C_WCHAR, "SQL_C_WCHAR", 100, 0); /* Conversion to GUID throws error if the string is not of correct form */ test_conversion("text", "543c5e21-435a-440b-943c-64af1ad571f1", SQL_C_GUID, "SQL_C_GUID", -1, 0); /* Date/timestamp tests of non-date input depends on current date */ test_conversion("date", "2011-02-13", SQL_C_TYPE_DATE, "SQL_C_DATE", -1, 0); test_conversion("date", "2011-02-13", SQL_C_TYPE_TIMESTAMP, "SQL_C_TIMESTAMP", -1, 0); test_conversion("timestamp", "2011-02-15 15:49:18", SQL_C_TYPE_DATE, "SQL_C_DATE", -1, 0); test_conversion("timestamp", "2011-02-15 15:49:18", SQL_C_TYPE_TIMESTAMP, "SQL_C_TIMESTAMP", -1, 0); test_conversion("timestamptz", "2011-02-16 17:49:18+03", SQL_C_TYPE_DATE, "SQL_C_DATE", -1, 0); test_conversion("timestamptz", "2011-02-16 17:49:18+03", SQL_C_TYPE_TIMESTAMP, "SQL_C_TIMESTAMP", -1, 0); /* cast of empty text values using localtime() */ test_conversion("text", "", SQL_C_TYPE_DATE, "SQL_C_TYPE_DATE", -1, 1); test_conversion("text", "", SQL_C_TYPE_TIME, "SQL_C_TYPE_TIME", -1, 0); test_conversion("text", "", SQL_C_TYPE_TIMESTAMP, "SQL_C_TYPE_TIMESTAMP", -1, 1); /* * Test for truncations. */ test_conversion("text", "foobar", SQL_C_CHAR, "SQL_C_CHAR", 5, 0); test_conversion("text", "foobar", SQL_C_CHAR, "SQL_C_CHAR", 6, 0); test_conversion("text", "foobar", SQL_C_CHAR, "SQL_C_CHAR", 7, 0); test_conversion("text", "foobar", SQL_C_WCHAR, "SQL_C_WCHAR", 10, 0); test_conversion("text", "foobar", SQL_C_WCHAR, "SQL_C_WCHAR", 11, 0); test_conversion("text", "foobar", SQL_C_WCHAR, "SQL_C_WCHAR", 12, 0); test_conversion("text", "foobar", SQL_C_WCHAR, "SQL_C_WCHAR", 13, 0); test_conversion("text", "foobar", SQL_C_WCHAR, "SQL_C_WCHAR", 14, 0); test_conversion("text", "", SQL_C_CHAR, "SQL_C_CHAR", 1, 0); test_conversion("text", "", SQL_C_WCHAR, "SQL_C_WCHAR", 1, 0); test_conversion("timestamp", "2011-02-15 15:49:18", SQL_C_CHAR, "SQL_C_CHAR", 19, 0); /* * Test for a specific bug, where the driver used to overrun the output * buffer because it assumed that a timestamp value is always max 20 bytes * long (not true for BC values, or with years > 10000) */ test_conversion("timestamp", "2011-02-15 15:49:18 BC", SQL_C_CHAR, "SQL_C_CHAR", 20, 0); /* Test special float values */ test_conversion("float4", "NaN", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float4", "Infinity", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float4", "-Infinity", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float8", "NaN", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float8", "Infinity", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float8", "-Infinity", SQL_C_FLOAT, "SQL_C_FLOAT", 20, 0); test_conversion("float4", "NaN", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); test_conversion("float4", "Infinity", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); test_conversion("float4", "-Infinity", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); test_conversion("float8", "NaN", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); test_conversion("float8", "Infinity", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); test_conversion("float8", "-Infinity", SQL_C_DOUBLE, "SQL_C_DOUBLE", 20, 0); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/select-test.c000066400000000000000000000017631462406103600206530ustar00rootroot00000000000000#include #include #include #include "common.h" int main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char sql[100000]; char *sqlend; int i; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 1 UNION ALL SELECT 2", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Result set with 1600 cols */ strcpy(sql, "SELECT 1"); sqlend = &sql[strlen(sql)]; for (i = 2; i <= 1600; i++) { sprintf(sqlend, ",%d", i); sqlend += strlen(sqlend); } *sqlend = '\0'; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/stmthandles-test.c000066400000000000000000000056131462406103600217200ustar00rootroot00000000000000#include #include #include "common.h" /* * This test case tests that things still work when you have a lot of * statements open simultaneously. * * As of writing this, there's an internal limit of just below 2^15 stmt * handles. Also, unixodbc's method of checking if a handle is valid, by * scanning a linked list of statements, grinds to a halt as you have * a lot of statements. If you want to test those limits, increase * NUM_STMT_HANDLES value. */ #define NUM_STMT_HANDLES 100 #define MAX_QUERY_SIZE 100 int main(int argc, char **argv) { HSTMT hstmt[NUM_STMT_HANDLES]; SQLRETURN rc; int i, nhandles; char *sqlbufs[NUM_STMT_HANDLES]; test_connect(); /* Allocate a lot of stmt handles */ for (i = 0; i < NUM_STMT_HANDLES; i++) { rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt[i]); if (!SQL_SUCCEEDED(rc)) { printf("failed to allocate stmt handle %d\n", i + 1); print_diag(NULL, SQL_HANDLE_DBC, conn); break; } if ((i + 1) % (NUM_STMT_HANDLES / 10) == 0) { printf("%d statements allocated...\n", i + 1); fflush(stdout); } /* allocate some space to hold the query */ sqlbufs[i] = malloc(MAX_QUERY_SIZE); } nhandles = i; /* Execute a query using each of them to verify they all work */ for (i = 0; i < nhandles; i++) { sprintf(sqlbufs[i], "SELECT 'stmt no %d'", i + 1); rc = SQLExecDirect(hstmt[i], (SQLCHAR *) sqlbufs[i], SQL_NTS); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLExecDirect failed", SQL_HANDLE_STMT, hstmt); exit(1); } if ((i + 1) % (NUM_STMT_HANDLES / 10) == 0) { printf("%d statements executed...\n", i + 1); fflush(stdout); } } for (i = 0; i < nhandles; i += (NUM_STMT_HANDLES / 10)) { print_result(hstmt[i]); fflush(stdout); } for (i = 0; i < nhandles; i++) { rc = SQLFreeStmt(hstmt[i], SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt[i]); } /* Try SQLPrepare/SQLExecute on multiple statements. */ printf("\nTesting interleaving operations on multiple prepared statements\n"); for (i = 0; i < 5; i++) { SQLSMALLINT colcount; int j; char *sqlbuf = sqlbufs[i]; sprintf(sqlbuf, "SELECT 'stmt no %d'", i); for (j = 0; j < i; j++) { sprintf(&sqlbuf[strlen(sqlbuf)], ", 'col %d'", j); } strcat(sqlbuf, " FROM generate_series(1, 3)"); rc = SQLPrepare(hstmt[i], (SQLCHAR *) sqlbuf, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt[i]); /* Test SQLNumResultCols, called before SQLExecute() */ rc = SQLNumResultCols(hstmt[i], &colcount); CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); printf("# of result cols: %d\n", colcount); } for (i = 0; i < 5; i++) { rc = SQLExecute(hstmt[i]); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt[i]); print_result(hstmt[i]); } test_disconnect(); /* free the buffers, to keep Valgrind from complaining about the leaks */ for (i = 0; i < NUM_STMT_HANDLES; i++) free(sqlbufs[i]); return 0; } psqlodbc-REL-16_00_0005/test/src/update-test.c000066400000000000000000000054141462406103600206530ustar00rootroot00000000000000/* * Test DML (INSERT, UPDATE, DELETE) commands */ #include #include #include "common.h" int main(int argc, char **argv) { SQLRETURN rc; HSTMT hstmt = SQL_NULL_HSTMT; char param1[100]; SQLLEN cbParam1; SQLCHAR *sql; int i; SQLLEN rowcount; test_connect(); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } /* Prepare a test table */ sql = "CREATE TEMPORARY TABLE tmptable (i int4, t text)"; rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt); /* Insert some rows, using a prepared statement */ rc = SQLPrepare(hstmt, (SQLCHAR *) "INSERT INTO tmptable VALUES (?, 'foobar')", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt); for (i = 1; i <= 5; i++) { /* bind params */ snprintf(param1, sizeof(param1), "%d", i); cbParam1 = SQL_NTS; rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, /* value type */ SQL_CHAR, /* param type */ 20, /* column size */ 0, /* dec digits */ param1, /* param value ptr */ 0, /* buffer len */ &cbParam1 /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt); /* Execute */ rc = SQLExecute(hstmt); CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt); /* Test SQLRowCount() */ rc = SQLRowCount(hstmt, &rowcount); CHECK_STMT_RESULT(rc, "SQLRowCount failed", hstmt); printf("# of rows inserted: %d\n", (int) rowcount); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); } /* Update some rows */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "UPDATE tmptable SET t = 'updated ' || i WHERE i <= 3" , SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLRowCount(hstmt, &rowcount); CHECK_STMT_RESULT(rc, "SQLRowCount failed", hstmt); printf("# of rows updated: %d\n", (int) rowcount); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* and delete some rows */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "DELETE FROM tmptable WHERE i = 4 OR i = 2" , SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); rc = SQLRowCount(hstmt, &rowcount); CHECK_STMT_RESULT(rc, "SQLRowCount failed", hstmt); printf("# of rows deleted: %d\n", (int) rowcount); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* Print the contents of the table after all the updates to verify */ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM tmptable", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt); print_result(hstmt); /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/src/wchar-char-test-eucjp.c000066400000000000000000000040151462406103600225100ustar00rootroot00000000000000 static int eucjp_test(HSTMT hstmt) { int rc; SQLLEN ind, cbParam, cbParam2; SQLINTEGER cbQueryLen; unsigned char lovedt[100] = {0x95, 0x4e, 0x0a, 0x4e, 0x5a, 0x53, 0xf2, 0x53, 0x0, 0x0}; unsigned char lovedt2[100] = {0xf2, 0x53, 0x5a, 0x53, 0x0a, 0x4e, 0x95, 0x4e, 0x0, 0x0}; SQLWCHAR wchar[100]; SQLCHAR str[100]; SQLCHAR chardt[100]; SQLTCHAR query[200] = _T("select '' || ?::text || 'Ǥ' || ?::text || 'Ǥ͡'"); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, (SQLPOINTER) chardt, sizeof(chardt), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_CHAR failed", hstmt); // cbParam = SQL_NTS; cbParam = strlen(lovedt); strcat(lovedt, lovedt2); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, /* value type */ SQL_WCHAR, /* param type */ sizeof(lovedt) / sizeof(lovedt[0]), /* column size */ 0, /* dec digits */ lovedt, // param1, /* param value ptr */ sizeof(lovedt), /* buffer len */ &cbParam /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter 1 failed", hstmt); // cbParam2 = SQL_NTS; strncpy((char *) str, "ƣ", sizeof(str)); cbParam2 = strlen(str); strcat((char *) str, ""); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(str), 0, str, sizeof(str), &cbParam2); CHECK_STMT_RESULT(rc, "SQLBindParameter 2 failed", hstmt); cbQueryLen = (SQLINTEGER) strlen(query); strcat((char *) query, ""); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_CHAR", hstmt); while (SQL_SUCCEEDED(SQLFetch(hstmt))) printf("ANSI=%s\n", chardt); fflush(stdout); SQLFreeStmt(hstmt, SQL_CLOSE); rc = SQLBindCol(hstmt, 1, SQL_C_WCHAR, (SQLPOINTER) wchar, sizeof(wchar) / sizeof(wchar[0]), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_WCHAR failed", hstmt); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_WCHAR", hstmt); while (SQL_SUCCEEDED(rc = SQLFetch(hstmt))) { print_utf16_le(wchar); } return rc; } psqlodbc-REL-16_00_0005/test/src/wchar-char-test-sjis.c000066400000000000000000000040221462406103600223500ustar00rootroot00000000000000 static int sjis_test(HSTMT hstmt) { int rc; SQLLEN ind, cbParam, cbParam2; SQLINTEGER cbQueryLen; unsigned char lovedt[100] = {0x95, 0x4e, 0x0a, 0x4e, 0x5a, 0x53, 0xf2, 0x53, 0x0, 0x0}; unsigned char lovedt2[100] = {0xf2, 0x53, 0x5a, 0x53, 0x0a, 0x4e, 0x95, 0x4e, 0x0, 0x0}; SQLWCHAR wchar[100]; SQLCHAR str[100]; SQLCHAR chardt[100]; SQLTCHAR query[200] = _T("select '' || ?::text || 'łBM' || ?::text || 'łˁH'"); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, (SQLPOINTER) chardt, sizeof(chardt), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_CHAR failed", hstmt); // cbParam = SQL_NTS; cbParam = strlen(lovedt); strcat(lovedt, lovedt2); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, /* value type */ SQL_WCHAR, /* param type */ sizeof(lovedt) / sizeof(lovedt[0]), /* column size */ 0, /* dec digits */ lovedt, // param1, /* param value ptr */ sizeof(lovedt), /* buffer len */ &cbParam /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter 1 failed", hstmt); // cbParam2 = SQL_NTS; strncpy((char *) str, "ē_", sizeof(str)); cbParam2 = strlen(str); strcat((char *) str, "M"); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(str), 0, str, sizeof(str), &cbParam2); CHECK_STMT_RESULT(rc, "SQLBindParameter 2 failed", hstmt); cbQueryLen = (SQLINTEGER) strlen(query); strcat((char *) query, "["); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_CHAR", hstmt); while (SQL_SUCCEEDED(SQLFetch(hstmt))) printf("ANSI=%s\n", chardt); fflush(stdout); SQLFreeStmt(hstmt, SQL_CLOSE); rc = SQLBindCol(hstmt, 1, SQL_C_WCHAR, (SQLPOINTER) wchar, sizeof(wchar) / sizeof(wchar[0]), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_WCHAR failed", hstmt); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_WCHAR", hstmt); while (SQL_SUCCEEDED(rc = SQLFetch(hstmt))) { print_utf16_le(wchar); } return rc; } psqlodbc-REL-16_00_0005/test/src/wchar-char-test-utf8.c000066400000000000000000000051431462406103600222730ustar00rootroot00000000000000 static int utf8_test_one(HSTMT hstmt) { int rc; SQLLEN ind, cbParam, cbParam2; SQLINTEGER cbQueryLen; unsigned char lovedt[100] = {0x95, 0x4e, 0x0a, 0x4e, 0x5a, 0x53, 0xf2, 0x53, 0x0, 0x0}; unsigned char lovedt2[100] = {0xf2, 0x53, 0x5a, 0x53, 0x0a, 0x4e, 0x95, 0x4e, 0x0, 0x0}; SQLWCHAR wchar[100]; SQLCHAR str[100]; SQLCHAR chardt[100]; // SQLTCHAR query[] = _T("select '私は' || ?::text || 'です。貴方は' || ?::text || 'さんですね? 𠀋𡈽𡌛𡑮𡢽𪐷𪗱𪘂𪘚𪚲'"); SQLTCHAR query[512] = _T("select '私は' || ?::text || 'です。貴方は' || ?::text || 'さんですね? 𠀋𡈽𡌛𡑮𡢽𪐷𪗱𪘂'"); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, (SQLPOINTER) chardt, sizeof(chardt), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_CHAR failed", hstmt); // cbParam = SQL_NTS; cbParam = strlen(lovedt); strcat(lovedt, lovedt2); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, /* value type */ SQL_WCHAR, /* param type */ sizeof(lovedt) / sizeof(lovedt[0]), /* column size */ 0, /* dec digits */ lovedt, // param1, /* param value ptr */ sizeof(lovedt), /* buffer len */ &cbParam /* StrLen_or_IndPtr */); CHECK_STMT_RESULT(rc, "SQLBindParameter 1 failed", hstmt); // cbParam2 = SQL_NTS; strncpy((char *) str, "斉藤浩", sizeof(str)); cbParam2 = strlen(str); strcat((char *) str, "斉藤浩"); rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(str), 0, str, sizeof(str), &cbParam2); CHECK_STMT_RESULT(rc, "SQLBindParameter 2 failed", hstmt); cbQueryLen = (SQLINTEGER) strlen(query); strcat((char *) query, "斉藤浩"); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_CHAR", hstmt); while (SQL_SUCCEEDED(SQLFetch(hstmt))) printf("ANSI=%s\n", chardt); fflush(stdout); SQLFreeStmt(hstmt, SQL_CLOSE); rc = SQLBindCol(hstmt, 1, SQL_C_WCHAR, (SQLPOINTER) wchar, sizeof(wchar) / sizeof(wchar[0]), &ind); CHECK_STMT_RESULT(rc, "SQLBindCol to SQL_C_WCHAR failed", hstmt); rc = SQLExecDirect(hstmt, query, cbQueryLen); CHECK_STMT_RESULT(rc, "SQLExecDirect failed to return SQL_C_WCHAR", hstmt); while (SQL_SUCCEEDED(rc = SQLFetch(hstmt))) { print_utf16_le(wchar); } SQLFreeStmt(hstmt, SQL_CLOSE); return rc; } int static utf8_test(HSTMT hstmt) { int rc; rc = SQLSetConnectAttr(conn, 65548, (SQLPOINTER) 0, 0); printf("\t*** wcs_debug = 0 ***\n"); fflush(stdout); rc = utf8_test_one(hstmt); rc = SQLSetConnectAttr(conn, 65548, (SQLPOINTER) 1, 0); printf("\t*** wcs_debug = 1 ***\n"); fflush(stdout); rc = utf8_test_one(hstmt); return rc; } psqlodbc-REL-16_00_0005/test/src/wchar-char-test.c000066400000000000000000000044171462406103600214120ustar00rootroot00000000000000#include #include #include #include #include "common.h" // #define UNICODE #ifndef _T #ifdef UNICODE #define _T(t) L##t #else #define _T(t) t #endif /* UNICODE */ #endif /* _T */ #ifdef WIN32 #define stricmp _stricmp #else #define stricmp strcasecmp #endif static void print_utf16_le(const SQLWCHAR *wdt) { int i; unsigned char *ucdt; for (i = 0; wdt[i]; i++) { ucdt = (unsigned char *) &wdt[i]; printf("U+%02X%02X", ucdt[1], ucdt[0]); } printf("\n"); fflush(stdout); } #include "wchar-char-test-sjis.c" #include "wchar-char-test-utf8.c" #include "wchar-char-test-eucjp.c" enum { SJIS_TEST ,UTF8_TEST ,EUCJP_TEST }; int main(int argc, char **argv) { int rc, testsw = -1; HSTMT hstmt = SQL_NULL_HSTMT; const char *loc, *ptr; struct { const char *name; int id; } loctbl[] = { { "sjis", SJIS_TEST } ,{ "shiftjis", SJIS_TEST } ,{ "932", SJIS_TEST } ,{ "utf-8", UTF8_TEST } ,{ "utf8", UTF8_TEST } ,{ "eucjp", EUCJP_TEST } }; loc = setlocale(LC_ALL, ""); if (NULL != loc && NULL != (ptr = strchr(loc, '.'))) { int i; ptr++; for (i = 0; i < sizeof(loctbl) / sizeof(loctbl[0]); i++) { if (stricmp(ptr, loctbl[i].name) == 0) { testsw = loctbl[i].id; break; } } } if (testsw < 0) { printf("Unfortunately this program can't handle this locale\n"); printf("Or you are testing an ansi driver\n"); printf("Anyway bypass this program\n"); printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n"); printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n"); printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n"); exit(0); } test_connect_ext(""); rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt); if (!SQL_SUCCEEDED(rc)) { print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); exit(1); } switch (testsw) { case SJIS_TEST: printf("SJIS test\n"); fflush(stdout); rc = sjis_test(hstmt); break; case UTF8_TEST: printf("UTF8 test\n"); fflush(stdout); rc = utf8_test(hstmt); break; case EUCJP_TEST: printf("EUCJP test\n"); fflush(stdout); rc = eucjp_test(hstmt); break; } /* Clean up */ test_disconnect(); return 0; } psqlodbc-REL-16_00_0005/test/tests000066400000000000000000000031321462406103600165410ustar00rootroot00000000000000# List of regression test programs. # # This is in a separate file so that it can be included by both the Unix # Makefile, and Windows nmake file, win.mak. Note that the format of this # file must be acceptable to both, so don't add anything fancy here. That's # also why we list program names here, in format exe/-test, rather # than the base test names: nmake makes it difficult to add a prefix or suffix # to each name in a list, but it's easy to strip them away. TESTBINS = exe/connect-test \ exe/stmthandles-test \ exe/select-test \ exe/update-test \ exe/commands-test \ exe/multistmt-test \ exe/getresult-test \ exe/colattribute-test \ exe/result-conversions-test \ exe/prepare-test \ exe/premature-test \ exe/params-test \ exe/param-conversions-test \ exe/parse-test \ exe/identity-test \ exe/notice-test \ exe/arraybinding-test \ exe/insertreturning-test \ exe/dataatexecution-test \ exe/boolsaschar-test \ exe/cvtnulldate-test \ exe/alter-test \ exe/quotes-test \ exe/cursors-test \ exe/cursor-movement-test \ exe/cursor-commit-test \ exe/cursor-name-test \ exe/cursor-block-delete-test \ exe/bookmark-test \ exe/declare-fetch-commit-test \ exe/declare-fetch-block-test \ exe/positioned-update-test \ exe/bulkoperations-test \ exe/catalogfunctions-test \ exe/bindcol-test \ exe/lfconversion-test \ exe/cte-test \ exe/errors-test \ exe/error-rollback-test \ exe/diagnostic-test \ exe/numeric-test \ exe/large-object-test \ exe/large-object-data-at-exec-test \ exe/odbc-escapes-test \ exe/wchar-char-test \ exe/params-batch-exec-test \ exe/fetch-refcursors-test psqlodbc-REL-16_00_0005/test/win.mak000066400000000000000000000037611462406103600167530ustar00rootroot00000000000000# # File: win.mak # # Description: Makefile for regression tests on Windows # (can be built using platform SDK's buildfarm) # # Usage: NMAKE /f win.mak [ installcheck ] # # Comments: Created by Michael Paquier, 2014-05-21 # ORIGDIR=. # Include the list of tests !INCLUDE tests SRCDIR=$(ORIGDIR)\src OBJDIR=exe EXEDIR=exe # The 'tests' file contains names of the test programs, in form # exe/-test. Extract the base names of the tests, by stripping the # "exe/" prefix and "-test" suffix. (It would seem more straightforward to do # it the other way round, but it is surprisingly difficult to add a # prefix/suffix to a list in nmake. Removing them is much easier.) TESTS = $(TESTBINS:exe/=) TESTS = $(TESTS:-test=) # Now create names of the test .exe from the base names # exe\.exe TESTEXES = $(TESTBINS:-test=-test.exe) TESTEXES = $(TESTEXES:/=\) COMSRC = $(SRCDIR)\common.c COMOBJ = $(OBJDIR)\common.obj # Flags CLFLAGS=/W3 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE LINKFLAGS=/link odbc32.lib odbccp32.lib /MANIFEST:EMBED # Build an executable for each test. # {$(SRCDIR)\}.c{$(EXEDIR)\}.exe: $(CC) /Fe.\$(EXEDIR)\ /Fo.\$(OBJDIR)\ $< $(COMOBJ) $(CLFLAGS) $(LINKFLAGS) all: $(TESTEXES) runsuite.exe $(TESTEXES): $(OBJDIR) $(COMOBJ) $(COMOBJ): $(COMSRC) $(CC) $(CLFLAGS) /c $? /Fo$@ $(OBJDIR) : !IF !EXIST($(OBJDIR)) mkdir $(OBJDIR) !ENDIF !IF !EXIST($(EXEDIR)) && "$(EXEDIR)" != "$(OBJDIR)" mkdir "$(EXEDIR)" !ENDIF runsuite.exe: $(ORIGDIR)\runsuite.c $(CC) $** $(CLFLAGS) $(LINKFLAGS) reset-db.exe: $(ORIGDIR)\reset-db.c $(COMOBJ) $(CC) $** $(CLFLAGS) $(LINKFLAGS) # activate the above inference rule .SUFFIXES: .out # Run regression tests RESDIR=results installcheck: runsuite.exe $(TESTEXES) reset-db.exe del regression.diffs .\reset-db < $(ORIGDIR)\sampletables.sql !IF !EXIST($(RESDIR)) mkdir $(RESDIR) !ENDIF .\runsuite $(TESTS) --inputdir=$(ORIGDIR) clean: -del $(EXEDIR)\*.exe -del $(OBJDIR)\*.obj psqlodbc-REL-16_00_0005/tuple.c000066400000000000000000000026731462406103600160030ustar00rootroot00000000000000/*------- * Module: tuple.c * * Description: This module contains functions for setting the data * for individual fields (TupleField structure) of a * manual result set. * * Important Note: These functions are ONLY used in building manual * result sets for info functions (SQLTables, * SQLColumns, etc.) * * Classes: n/a * * API functions: none * * Comments: See "readme.txt" for copyright and license information. *------- */ #include "tuple.h" #include "misc.h" #include #include void set_tuplefield_null(TupleField *tuple_field) { tuple_field->len = 0; tuple_field->value = NULL; /* strdup(""); */ } void set_tuplefield_string(TupleField *tuple_field, const char *string) { if (string) { tuple_field->len = (Int4) strlen(string); /* PG restriction */ tuple_field->value = strdup(string); } if (!tuple_field->value) set_tuplefield_null(tuple_field); } void set_tuplefield_int2(TupleField *tuple_field, Int2 value) { char buffer[10]; ITOA_FIXED(buffer, value); tuple_field->len = (Int4) (strlen(buffer) + 1); /* +1 ... is this correct (better be on the save side-...) */ tuple_field->value = strdup(buffer); } void set_tuplefield_int4(TupleField *tuple_field, Int4 value) { char buffer[15]; ITOA_FIXED(buffer, value); tuple_field->len = (Int4) (strlen(buffer) + 1); /* +1 ... is this correct (better be on the save side-...) */ tuple_field->value = strdup(buffer); } psqlodbc-REL-16_00_0005/tuple.h000066400000000000000000000042611462406103600160030ustar00rootroot00000000000000/* File: tuple.h * * Description: See "tuple.c" * * Important NOTE: The TupleField structure is used both to hold backend data and manual result set data. The "set_" functions are only used for manual result sets by info routines. * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __TUPLE_H__ #define __TUPLE_H__ #include "psqlodbc.h" /* Used by backend data AND manual result sets */ struct TupleField_ { Int4 len; /* PG length of the current Tuple */ void *value; /* an array representing the value */ }; /* keyset(TID + OID) info */ struct KeySet_ { UWORD status; UInt2 offset; UInt4 blocknum; OID oid; }; /* Rollback(index + original TID) info */ struct Rollback_ { SQLLEN index; UInt4 blocknum; UInt2 offset; OID oid; UWORD option; }; #define KEYSET_INFO_PUBLIC 0x07 #define CURS_SELF_ADDING (1L << 3) #define CURS_SELF_DELETING (1L << 4) #define CURS_SELF_UPDATING (1L << 5) #define CURS_SELF_ADDED (1L << 6) #define CURS_SELF_DELETED (1L << 7) #define CURS_SELF_UPDATED (1L << 8) #define CURS_NEEDS_REREAD (1L << 9) #define CURS_IN_ROWSET (1L << 10) #define CURS_OTHER_DELETED (1L << 11) /* These macros are wrappers for the corresponding set_tuplefield functions but these handle automatic NULL determination and call set_tuplefield_null() if appropriate for the datatype (used by SQLGetTypeInfo). */ #define set_nullfield_string(FLD, VAL) ((VAL) ? set_tuplefield_string(FLD, (VAL)) : set_tuplefield_null(FLD)) #define set_nullfield_int2(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int2(FLD, (VAL)) : set_tuplefield_null(FLD)) #define set_nullfield_int4(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int4(FLD, (VAL)) : set_tuplefield_null(FLD)) void set_tuplefield_null(TupleField *tuple_field); void set_tuplefield_string(TupleField *tuple_field, const char *string); void set_tuplefield_int2(TupleField *tuple_field, Int2 value); void set_tuplefield_int4(TupleField *tuple_field, Int4 value); SQLLEN ClearCachedRows(TupleField *tuple, int num_fields, SQLLEN num_rows); SQLLEN ReplaceCachedRows(TupleField *otuple, const TupleField *ituple, int num_fields, SQLLEN num_rows); typedef struct _PG_BM_ { Int4 index; KeySet keys; } PG_BM; #endif psqlodbc-REL-16_00_0005/unicode_support.h000066400000000000000000000027461462406103600201020ustar00rootroot00000000000000/* File: psqlodbc.h * * Description: This file contains defines and declarations that are related to * the entire driver. * * Comments: See "readme.txt" for copyright and license information. */ #ifndef __UNICODE_SUPPORT_H__ #define __UNICODE_SUPPORT_H__ #include "psqlodbc.h" #ifdef UNICODE_SUPPORT #define WCLEN sizeof(SQLWCHAR) enum { CONVTYPE_UNKNOWN ,WCSTYPE_UTF16_LE ,WCSTYPE_UTF32_LE ,C16TYPE_UTF16_LE }; char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL tolower); SQLULEN utf8_to_ucs2_lf(const char * utf8str, SQLLEN ilen, BOOL lfconv, SQLWCHAR *ucs2str, SQLULEN buflen, BOOL errcheck); int get_convtype(void); #define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen, FALSE) SQLLEN bindcol_hybrid_estimate(const char *ldt, BOOL lf_conv, char **wcsbuf); SQLLEN bindcol_hybrid_exec(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv, char **wcsbuf); SQLLEN bindcol_localize_estimate(const char *utf8dt, BOOL lf_conv, char **wcsbuf); SQLLEN bindcol_localize_exec(char *ldt, size_t n, BOOL lf_conv, char **wcsbuf); SQLLEN bindpara_msg_to_utf8(const char *ldt, char **wcsbuf, SQLLEN used); SQLLEN bindpara_wchar_to_msg(const SQLWCHAR *utf16, char **wcsbuf, SQLLEN used); SQLLEN locale_to_sqlwchar(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv); SQLLEN utf8_to_locale(char *ldt, const char * utf8dt, size_t n, BOOL lf_conv); #endif /* UNICODE_SUPPORT */ #endif /* __UNICODE_SUPPORT_H__ */ psqlodbc-REL-16_00_0005/version.h000066400000000000000000000011261462406103600163340ustar00rootroot00000000000000/* File: version.h * * Description: This file defines the driver version. * * Comments: See "readme.txt" for copyright and license information. * */ #ifndef __VERSION_H__ #define __VERSION_H__ /* * BuildAll may pass POSTGRESDRIVERVERSION, POSTGRES_RESOURCE_VERSION * and PG_DRVFILE_VERSION via winbuild/psqlodbc.vcxproj. */ #ifndef POSTGRESDRIVERVERSION #define POSTGRESDRIVERVERSION "16.00.0005" #endif #ifndef POSTGRES_RESOURCE_VERSION #define POSTGRES_RESOURCE_VERSION POSTGRESDRIVERVERSION #endif #ifndef PG_DRVFILE_VERSION #define PG_DRVFILE_VERSION 16,0,00,00 #endif #endif psqlodbc-REL-16_00_0005/wbuild.sh000066400000000000000000000005401462406103600163170ustar00rootroot00000000000000#/bin/bash ## ## Build all dlls of psqlodbc project for Windows ## from WSL or cygwin ## cd $(dirname $0) pscript=winbuild/BuildAll.ps1 if [ $# -gt 0 ]; then if [ $1 = "/?" ]; then powershell.exe Get-Help $pscript -detailed exit 0 elif [ $1 = "-?" ]; then shift powershell.exe Get-Help $pscript $* exit 0 fi fi powershell.exe $pscript $* psqlodbc-REL-16_00_0005/wconfig.sh000066400000000000000000000002521462406103600164650ustar00rootroot00000000000000#/bin/bash ## ## Start editConfiguration with a mimimized console window ## cd $(dirname $0) Powershell.exe -Sta -WindowStyle Minimized winbuild/editConfiguration.ps1 $* psqlodbc-REL-16_00_0005/win64.mak000077500000000000000000000221001462406103600161350ustar00rootroot00000000000000# # File: win64.mak # # Description: psqlodbc35w Unicode 64bit version Makefile. # (can be built using platform SDK's buildfarm) # # Configurations: Debug, Release # Build Types: ALL, CLEAN # Usage: NMAKE /f win64.mak CFG=[Release | Debug] [ALL | CLEAN] # # Comments: Created by Hiroshi Inoue, 2006-10-31 # # Include default configuration options, followed by any local overrides !INCLUDE windows-defaults.mak !IF EXISTS(windows-local.mak) !INCLUDE windows-local.mak !ENDIF !IF "$(ANSI_VERSION)" == "yes" !MESSAGE Building the PostgreSQL ANSI 3.0 Driver for $(TARGET_CPU)... !ELSE !MESSAGE Building the PostgreSQL Unicode 3.5 Driver for $(TARGET_CPU)... !ENDIF !MESSAGE !IF "$(CFG)" == "" CFG=Release !MESSAGE No configuration specified. Defaulting to Release. !MESSAGE !ENDIF !IF "$(CFG)" != "Release" && "$(CFG)" != "Debug" !MESSAGE Invalid configuration "$(CFG)" specified. !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f win64.mak CFG=[Release | Debug] [ALL | CLEAN] !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "Release" ($(TARGET_CPU) Release DLL) !MESSAGE "Debug" ($(TARGET_CPU) Debug DLL) !MESSAGE !ERROR An invalid configuration was specified. !ENDIF # # Please replace the default options from the commandline if necessary # !IFNDEF CUSTOMCLOPT CUSTOMCLOPT=/nologo /W3 /wd4018 /EHsc !IF "$(CFG)" == "Release" CUSTOMCLOPT=$(CUSTOMCLOPT) /MD !ELSE CUSTOMCLOPT=$(CUSTOMCLOPT) /MDd !ENDIF !ELSE !MESSAGE CL option $(CUSTOMCLOPT) specified !ENDIF # # Please specify additional libraries to link from the command line. # For example specify # CUSTOMLINKLIBS=bufferoverflowu.lib # when bufferoverflowu.lib is needed in old VC environment. # CUSTOMLINKLIBS= # Print the paths that will be used in the build !MESSAGE Using PostgreSQL Include directory: $(PG_INC) !MESSAGE Using PostgreSQL Library directory: $(PG_LIB) !IF "$(ANSI_VERSION)" == "yes" DTCLIB = pgenlista !ELSE DTCLIB = pgenlist !ENDIF DTCDLL = $(DTCLIB).dll !IF "$(TARGET_CPU)" == "x64" ADD_DEFINES=$(ADD_DEFINES) /D _WIN64 !ENDIF !IF "$(MSDTC)" != "no" VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DelayLoad:$(DTCDLL) !ENDIF VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DELAY:UNLOAD ADD_DEFINES = $(ADD_DEFINES) /D "DYNAMIC_LOAD" !IF "$(MSDTC)" != "no" ADD_DEFINES = $(ADD_DEFINES) /D "_HANDLE_ENLIST_IN_DTC_" !ENDIF !IF "$(MEMORY_DEBUG)" == "yes" ADD_DEFINES = $(ADD_DEFINES) /D "_MEMORY_DEBUG_" /GS !ENDIF !IF "$(ANSI_VERSION)" == "yes" ADD_DEFINES = $(ADD_DEFINES) /D "DBMS_NAME=\"PostgreSQL ANSI($(TARGET_CPU))\"" !ELSE ADD_DEFINES = $(ADD_DEFINES) /D "DBMS_NAME=\"PostgreSQL Unicode($(TARGET_CPU))\"" /D "UNICODE_SUPPORT" RSC_DEFINES = $(RSC_DEFINES) /D "UNICODE_SUPPORT" !ENDIF !IF "$(PORT_CHECK)" == "yes" ADD_DEFINES = $(ADD_DEFINES) /Wp64 !ENDIF !IF "$(PG_INC)" != "" INC_OPT = $(INC_OPT) /I "$(PG_INC)" /I "$(PG_INC)\internal" !ENDIF !IF "$(ADD_INC)" != "" INC_OPT = $(INC_OPT) /I "$(ADD_INC)" !ENDIF !IF "$(ANSI_VERSION)" == "yes" MAINLIB = psqlodbc30a !ELSE MAINLIB = psqlodbc35w !ENDIF MAINDLL = $(MAINLIB).dll XALIB = pgxalib XADLL = $(XALIB).dll # Construct output directory name. The name consists of three parts, # target CPU, ANSI/Unicode, and Debug/Release. For example,the output # directory debug-enabled 32-bit ANSI-version is: # # .\x86_ANSI_Debug # OUTDIR=.\$(TARGET_CPU) !IF "$(ANSI_VERSION)" == "yes" OUTDIR=$(OUTDIR)_ANSI !ELSE OUTDIR=$(OUTDIR)_Unicode !ENDIF !IF "$(CFG)" == "Debug" OUTDIR=$(OUTDIR)_Debug !ELSE OUTDIR=$(OUTDIR)_Release !ENDIF # Location for intermediary build targets (e.g. *.obj files). INTDIR=$(OUTDIR) ALLDLL = "$(INTDIR)" !IF "$(OUTDIR)" != "$(INTDIR)" ALLDLL = $(ALLDLL) "$(INTDIR)" !ENDIF ALLDLL = $(ALLDLL) "$(OUTDIR)\$(MAINDLL)" !IF "$(MSDTC)" != "no" ALLDLL = $(ALLDLL) "$(OUTDIR)\$(XADLL)" "$(OUTDIR)\$(DTCDLL)" !ENDIF ALL : $(ALLDLL) CLEAN : -@erase "$(INTDIR)\*.obj" -@erase "$(INTDIR)\*.res" -@erase "$(OUTDIR)\*.lib" -@erase "$(OUTDIR)\*.exp" -@erase "$(INTDIR)\*.pch" -@erase "$(INTDIR)\*.dll" -@erase "$(INTDIR)\*.pdb" "$(INTDIR)" : !IF !EXISTS($(INTDIR)) mkdir "$(INTDIR)" !ENDIF !IF !EXISTS($(OUTDIR)) && "$(OUTDIR)" != "$(INTDIR)" mkdir "$(OUTDIR)" !ENDIF !IF "$(MSDTC)" != "no" "$(OUTDIR)\$(MAINDLL)": "$(OUTDIR)\$(DTCLIB).lib" !ENDIF CPP=cl.exe CPP_PROJ=$(CUSTOMCLOPT) $(INC_OPT) /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_DEPRECATE" /D "WIN_MULTITHREAD_SUPPORT" $(ADD_DEFINES) /Fp"$(INTDIR)\psqlodbc.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD !IF "$(CFG)" == "Release" CPP_PROJ=$(CPP_PROJ) /O2 !ELSEIF "$(CFG)" == "Debug" CPP_PROJ=$(CPP_PROJ) /Gm /ZI /Od /D "_DEBUG" /RTC1 !ENDIF .c{$(INTDIR)}.obj:: $(CPP) @<< $(CPP_PROJ) /c $< << .cpp{$(INTDIR)}.obj:: $(CPP) @<< $(CPP_PROJ) /c $< << .cxx{$(INTDIR)}.obj:: $(CPP) @<< $(CPP_PROJ) /c $< << RSC=rc.exe RSC_PROJ=/l 0x809 /fo"$(INTDIR)\psqlodbc.res" !IF "$(CFG)" == "Debug" RSC_PROJ=$(RSC_PROJ) /d "_DEBUG" !ENDIF LINK32=link.exe LIB32=lib.exe LINK32_FLAGS=libpq.lib kernel32.lib user32.lib gdi32.lib advapi32.lib odbc32.lib odbccp32.lib wsock32.lib ws2_32.lib secur32.lib XOleHlp.lib winmm.lib msvcrt.lib $(CUSTOMLINKLIBS) /nologo /dll /def:"$(DEF_FILE)" !IF "$(MSDTC)" != "no" LINK32_FLAGS=$(LINK32_FLAGS) "$(OUTDIR)\$(DTCLIB).lib" !ENDIF !IF "$(ANSI_VERSION)" == "yes" DEF_FILE= "psqlodbca.def" !ELSE DEF_FILE= "psqlodbc.def" !ENDIF !IF "$(CFG)" == "Release" LINK32_FLAGS=$(LINK32_FLAGS) !ELSE LINK32_FLAGS=$(LINK32_FLAGS) /debug /pdbtype:sept !ENDIF LINK32_FLAGS=$(LINK32_FLAGS) $(VC07_DELAY_LOAD) !IF "$(PG_LIB)" != "" LINK32_FLAGS=$(LINK32_FLAGS) /libpath:"$(PG_LIB)" !ENDIF LINK32_OBJS= \ "$(INTDIR)\bind.obj" \ "$(INTDIR)\columninfo.obj" \ "$(INTDIR)\connection.obj" \ "$(INTDIR)\convert.obj" \ "$(INTDIR)\dlg_specific.obj" \ "$(INTDIR)\dlg_wingui.obj" \ "$(INTDIR)\drvconn.obj" \ "$(INTDIR)\environ.obj" \ "$(INTDIR)\execute.obj" \ "$(INTDIR)\info.obj" \ "$(INTDIR)\lobj.obj" \ "$(INTDIR)\misc.obj" \ "$(INTDIR)\mylog.obj" \ "$(INTDIR)\pgapi30.obj" \ "$(INTDIR)\multibyte.obj" \ "$(INTDIR)\options.obj" \ "$(INTDIR)\parse.obj" \ "$(INTDIR)\pgtypes.obj" \ "$(INTDIR)\psqlodbc.obj" \ "$(INTDIR)\qresult.obj" \ "$(INTDIR)\results.obj" \ "$(INTDIR)\setup.obj" \ "$(INTDIR)\statement.obj" \ "$(INTDIR)\tuple.obj" \ "$(INTDIR)\odbcapi.obj" \ "$(INTDIR)\odbcapi30.obj" \ "$(INTDIR)\descriptor.obj" \ "$(INTDIR)\loadlib.obj" \ !IF "$(ANSI_VERSION)" != "yes" "$(INTDIR)\win_unicode.obj" \ "$(INTDIR)\odbcapiw.obj" \ "$(INTDIR)\odbcapi30w.obj" \ !ENDIF !IF "$(MSDTC)" != "no" "$(INTDIR)\xalibname.obj" \ !ENDIF !IF "$(MEMORY_DEBUG)" == "yes" "$(INTDIR)\inouealc.obj" \ !ENDIF "$(INTDIR)\psqlodbc.res" DTCDEF_FILE= "$(DTCLIB).def" LIB32_DTCLIBFLAGS=/nologo /def:"$(DTCDEF_FILE)" LINK32_DTCFLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib wsock32.lib XOleHlp.lib $(OUTDIR)\$(MAINLIB).lib $(CUSTOMLINKLIBS) Delayimp.lib /DelayLoad:XOLEHLP.DLL /nologo /dll LINK32_DTCOBJS= \ "$(INTDIR)\msdtc_enlist.obj" "$(INTDIR)\xalibname.obj" XADEF_FILE= "$(XALIB).def" LINK32_XAFLAGS=/nodefaultlib:libcmt.lib kernel32.lib user32.lib gdi32.lib advapi32.lib odbc32.lib odbccp32.lib wsock32.lib XOleHlp.lib winmm.lib msvcrt.lib $(CUSTOMLINKLIBS) /nologo /dll /def:"$(XADEF_FILE)" LINK32_XAOBJS= \ "$(INTDIR)\pgxalib.obj" "$(OUTDIR)\$(MAINDLL)" : $(DEF_FILE) $(LINK32_OBJS) $(LINK32) @<< $(LINK32_FLAGS) $(LINK32_OBJS) /pdb:$*.pdb /implib:$*.lib /out:$@ << "$(OUTDIR)\$(DTCLIB).lib" : $(DTCDEF_FILE) $(LINK32_DTCOBJS) $(LIB32) @<< $(LIB32_DTCLIBFLAGS) $(LINK32_DTCOBJS) /out:$@ << "$(OUTDIR)\$(DTCDLL)" : $(DTCDEF_FILE) $(LINK32_DTCOBJS) $(LINK32) @<< $(LINK32_DTCFLAGS) $(LINK32_DTCOBJS) $*.exp /pdb:$*.pdb /out:$@ << "$(OUTDIR)\$(XADLL)" : $(XADEF_FILE) $(LINK32_XAOBJS) $(LINK32) @<< $(LINK32_XAFLAGS) $(LINK32_XAOBJS) /pdb:$*.pdb /implib:$*.lib /out:$@ << SOURCE=psqlodbc.rc "$(INTDIR)\psqlodbc.res" : $(SOURCE) $(RSC) $(RSC_PROJ) $(RSC_DEFINES) $(SOURCE) #### # Umbrella targets, for building the driver in multiple configurations unicode-driver: $(MAKE) -f win64.mak ANSI_VERSION=no ansi-driver: $(MAKE) -f win64.mak ANSI_VERSION=yes installer: unicode-driver ansi-driver cd installer && $(MAKE) -f installer.mak CFG=$(CFG) # world target builds both 32-bit and 64-bit installers in one command. # # The "setenv" command, from Microsoft SDK, is used to switch the build # target. However, it only changes the environment for the current shell; # it is reset for the next command. So we cannot just call "setenv /x64" # here one one line and nmake one the next one. I also tried creating a .bat # file with the commands, but setenv contains a "EXIT /B" which stops the # script from executing. But we can launch a new cmd.exe and pass the # commands to it in stdin. world: cmd < << setenv /x64 $(MAKE) -f win64.mak installer CFG=$(CFG) setenv /x86 $(MAKE) -f win64.mak installer CFG=$(CFG) << clean-world: -rd /Q /S x64_ANSI_Release x64_ANSI_Debug -rd /Q /S x64_Unicode_Release x64_Unicode_Debug -rd /Q /S x86_ANSI_Release x86_ANSI_Debug -rd /Q /S x86_Unicode_Release x86_Unicode_Debug cd installer && $(MAKE) /f installer.mak CFG=$(CFG) clean psqlodbc-REL-16_00_0005/win_setup.h000066400000000000000000000015021462406103600166620ustar00rootroot00000000000000#ifndef _WIN_SETUP_H__ #define _WIN_SETUP_H__ #ifndef INTFUNC #define INTFUNC __stdcall #endif /* INTFUNC */ #define MAXDSNAME (32+1) /* Max data source name length */ /* Globals */ /* NOTE: All these are used by the dialog procedures */ typedef struct tagSETUPDLG { HWND hwndParent; /* Parent window handle */ LPCSTR lpszDrvr; /* Driver description */ ConnInfo ci; char szDSN[MAXDSNAME]; /* Original data source name */ BOOL fNewDSN; /* New data source flag */ BOOL fDefault; /* Default data source flag */ } SETUPDLG, * LPSETUPDLG; /* Prototypes */ LRESULT CALLBACK ConfigDlgProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); BOOL INTFUNC ChangeDriverName(HWND hwnd, LPSETUPDLG lpsetupdlg, LPCSTR driver_name); void test_connection(HANDLE hwnd, ConnInfo *ci, BOOL withDTC); #endif /* _WIN_SETUP_H__ */ psqlodbc-REL-16_00_0005/win_unicode.c000066400000000000000000000722171462406103600171560ustar00rootroot00000000000000/*------- * Module: win_unicode.c * * Description: This module contains utf8 <-> ucs2 conversion routines * under WIndows * *------- */ #ifdef UNICODE_SUPPORT #include "unicode_support.h" #include #include #include #ifdef WIN32 #define FORMAT_SIZE_T "%Iu" #else #define FORMAT_SIZE_T "%zu" #endif #if (defined(__STDC_ISO_10646__) && defined(HAVE_MBSTOWCS) && defined(HAVE_WCSTOMBS)) || defined(WIN32) #define __WCS_ISO10646__ static BOOL use_wcs = FALSE; #endif #if (defined(__STDC_UTF_16__) && defined(HAVE_UCHAR_H) && defined(HAVE_MBRTOC16) && defined(HAVE_C16RTOMB)) #define __CHAR16_UTF_16__ #include static BOOL use_c16 = FALSE; #endif static int convtype = -1; int get_convtype(void) { const UCHAR *cdt; #if defined(__WCS_ISO10646__) if (convtype < 0) { wchar_t *wdt = L"a"; int sizeof_w = sizeof(wchar_t); cdt = (UCHAR *) wdt; switch (sizeof_w) { case 2: if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3]) { MYLOG(0, " UTF-16LE detected\n"); convtype = WCSTYPE_UTF16_LE; use_wcs = TRUE; } break; case 4: if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3] && '\0' == cdt[4] && '\0' == cdt[5] && '\0' == cdt[6] && '\0' == cdt[7]) { MYLOG(0, " UTF32-LE detected\n"); convtype = WCSTYPE_UTF32_LE; use_wcs = TRUE; } break; } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (convtype < 0) { char16_t *c16dt = u"a"; cdt = (UCHAR *) c16dt; if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3]) { MYLOG(0, " C16_UTF-16LE detected\n"); convtype = C16TYPE_UTF16_LE; use_c16 = TRUE; } } #endif /* __CHAR16_UTF_16__ */ if (convtype < 0) convtype = CONVTYPE_UNKNOWN; /* unknown */ return convtype; } #define byte3check 0xfffff800 #define byte2_base 0x80c0 #define byte2_mask1 0x07c0 #define byte2_mask2 0x003f #define byte3_base 0x8080e0 #define byte3_mask1 0xf000 #define byte3_mask2 0x0fc0 #define byte3_mask3 0x003f #define surrog_check 0xfc00 #define surrog1_bits 0xd800 #define surrog2_bits 0xdc00 #define byte4_base 0x808080f0 #define byte4_sr1_mask1 0x0700 #define byte4_sr1_mask2 0x00fc #define byte4_sr1_mask3 0x0003 #define byte4_sr2_mask1 0x03c0 #define byte4_sr2_mask2 0x003f #define surrogate_adjust (0x10000 >> 10) static int little_endian = -1; SQLULEN ucs2strlen(const SQLWCHAR *ucs2str) { SQLULEN len; for (len = 0; ucs2str[len]; len++) ; return len; } char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { char * utf8str; int len = 0; MYLOG(0, "%p ilen=" FORMAT_LEN " ", ucs2str, ilen); if (!ucs2str) { if (olen) *olen = SQL_NULL_DATA; return NULL; } if (little_endian < 0) { int crt = 1; little_endian = (0 != ((char *) &crt)[0]); } if (ilen < 0) ilen = ucs2strlen(ucs2str); MYPRINTF(0, " newlen=" FORMAT_LEN, ilen); utf8str = (char *) malloc(ilen * 4 + 1); if (utf8str) { int i = 0; UInt2 byte2code; Int4 byte4code, surrd1, surrd2; const SQLWCHAR *wstr; for (i = 0, wstr = ucs2str; i < ilen; i++, wstr++) { if (!*wstr) break; else if (0 == (*wstr & 0xffffff80)) /* ASCII */ { if (lower_identifier) utf8str[len++] = (char) tolower(*wstr); else utf8str[len++] = (char) *wstr; } else if ((*wstr & byte3check) == 0) { byte2code = byte2_base | ((byte2_mask1 & *wstr) >> 6) | ((byte2_mask2 & *wstr) << 8); if (little_endian) memcpy(utf8str + len, (char *) &byte2code, sizeof(byte2code)); else { utf8str[len] = ((char *) &byte2code)[1]; utf8str[len + 1] = ((char *) &byte2code)[0]; } len += sizeof(byte2code); } /* surrogate pair check for non ucs-2 code */ else if (surrog1_bits == (*wstr & surrog_check)) { surrd1 = (*wstr & ~surrog_check) + surrogate_adjust; wstr++; i++; surrd2 = (*wstr & ~surrog_check); byte4code = byte4_base | ((byte4_sr1_mask1 & surrd1) >> 8) | ((byte4_sr1_mask2 & surrd1) << 6) | ((byte4_sr1_mask3 & surrd1) << 20) | ((byte4_sr2_mask1 & surrd2) << 10) | ((byte4_sr2_mask2 & surrd2) << 24); if (little_endian) memcpy(utf8str + len, (char *) &byte4code, sizeof(byte4code)); else { utf8str[len] = ((char *) &byte4code)[3]; utf8str[len + 1] = ((char *) &byte4code)[2]; utf8str[len + 2] = ((char *) &byte4code)[1]; utf8str[len + 3] = ((char *) &byte4code)[0]; } len += sizeof(byte4code); } else { byte4code = byte3_base | ((byte3_mask1 & *wstr) >> 12) | ((byte3_mask2 & *wstr) << 2) | ((byte3_mask3 & *wstr) << 16); if (little_endian) memcpy(utf8str + len, (char *) &byte4code, 3); else { utf8str[len] = ((char *) &byte4code)[3]; utf8str[len + 1] = ((char *) &byte4code)[2]; utf8str[len + 2] = ((char *) &byte4code)[1]; } len += 3; } } utf8str[len] = '\0'; if (olen) *olen = len; } MYPRINTF(0, " olen=%d utf8str=%s\n", len, utf8str ? utf8str : ""); return utf8str; } #define byte3_m1 0x0f #define byte3_m2 0x3f #define byte3_m3 0x3f #define byte2_m1 0x1f #define byte2_m2 0x3f #define byte4_m1 0x07 #define byte4_m2 0x3f #define byte4_m31 0x30 #define byte4_m32 0x0f #define byte4_m4 0x3f /* * Convert a string from UTF-8 encoding to UCS-2. * * utf8str - input string in UTF-8 * ilen - length of input string in bytes (or minus) * lfconv - TRUE if line feeds (LF) should be converted to CR + LF * ucs2str - output buffer * bufcount - size of output buffer * errcheck - if TRUE, check for invalidly encoded input characters * * Returns the number of SQLWCHARs copied to output buffer. If the output * buffer is too small, the output is truncated. The output string is * NULL-terminated, except when the output is truncated. */ SQLULEN utf8_to_ucs2_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, SQLWCHAR *ucs2str, SQLULEN bufcount, BOOL errcheck) { int i; SQLULEN rtn, ocount, wcode; const UCHAR *str; MYLOG(DETAIL_LOG_LEVEL, "ilen=" FORMAT_LEN " bufcount=" FORMAT_ULEN, ilen, bufcount); if (!utf8str) return 0; MYPRINTF(DETAIL_LOG_LEVEL, " string=%s", utf8str); if (!bufcount) ucs2str = NULL; else if (!ucs2str) bufcount = 0; if (ilen < 0) ilen = strlen(utf8str); for (i = 0, ocount = 0, str = (SQLCHAR *) utf8str; i < ilen && *str;) { if ((*str & 0x80) == 0) { if (lfconv && PG_LINEFEED == *str && (i == 0 || PG_CARRIAGE_RETURN != str[-1])) { if (ocount < bufcount) ucs2str[ocount] = PG_CARRIAGE_RETURN; ocount++; } if (ocount < bufcount) ucs2str[ocount] = *str; ocount++; i++; str++; } else if (0xf8 == (*str & 0xf8)) /* more than 5 byte code */ { ocount = (SQLULEN) -1; goto cleanup; } else if (0xf0 == (*str & 0xf8)) /* 4 byte code */ { if (errcheck) { if (i + 4 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80) || 0 == (str[3] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = (surrog1_bits | ((((UInt4) *str) & byte4_m1) << 8) | ((((UInt4) str[1]) & byte4_m2) << 2) | ((((UInt4) str[2]) & byte4_m31) >> 4)) - surrogate_adjust; ucs2str[ocount] = (SQLWCHAR) wcode; } ocount++; if (ocount < bufcount) { wcode = surrog2_bits | ((((UInt4) str[2]) & byte4_m32) << 6) | (((UInt4) str[3]) & byte4_m4); ucs2str[ocount] = (SQLWCHAR) wcode; } ocount++; i += 4; str += 4; } else if (0xe0 == (*str & 0xf0)) /* 3 byte code */ { if (errcheck) { if (i + 3 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4) *str) & byte3_m1) << 12) | ((((UInt4) str[1]) & byte3_m2) << 6) | (((UInt4) str[2]) & byte3_m3); ucs2str[ocount] = (SQLWCHAR) wcode; } ocount++; i += 3; str += 3; } else if (0xc0 == (*str & 0xe0)) /* 2 byte code */ { if (errcheck) { if (i + 2 > ilen || 0 == (str[1] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4) *str) & byte2_m1) << 6) | (((UInt4) str[1]) & byte2_m2); ucs2str[ocount] = (SQLWCHAR) wcode; } ocount++; i += 2; str += 2; } else { ocount = (SQLULEN) -1; goto cleanup; } } cleanup: rtn = ocount; if (ocount == (SQLULEN) -1) { if (!errcheck) rtn = 0; ocount = 0; } if (ocount < bufcount && ucs2str) ucs2str[ocount] = 0; MYPRINTF(DETAIL_LOG_LEVEL, " ocount=" FORMAT_ULEN "\n", ocount); return rtn; } #ifdef __WCS_ISO10646__ /* UCS4 => utf8 */ #define byte4check 0xffff0000 #define byte4_check 0x10000 #define byte4_mask1 0x1c0000 #define byte4_mask2 0x3f000 #define byte4_mask3 0x0fc0 #define byte4_mask4 0x003f #define byte4_m3 0x3f static SQLULEN ucs4strlen(const UInt4 *ucs4str) { SQLULEN len; for (len = 0; ucs4str[len]; len++) ; return len; } static char *ucs4_to_utf8(const UInt4 *ucs4str, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { char * utf8str; int len = 0; MYLOG(0, " %p ilen=" FORMAT_LEN "\n", ucs4str, ilen); if (!ucs4str) { if (olen) *olen = SQL_NULL_DATA; return NULL; } if (little_endian < 0) { int crt = 1; little_endian = (0 != ((char *) &crt)[0]); } if (ilen < 0) ilen = ucs4strlen(ucs4str); MYLOG(0, " newlen=" FORMAT_LEN "\n", ilen); utf8str = (char *) malloc(ilen * 4 + 1); if (utf8str) { int i; UInt2 byte2code; Int4 byte4code; const UInt4 *wstr; for (i = 0, wstr = ucs4str; i < ilen; i++, wstr++) { if (!*wstr) break; else if (0 == (*wstr & 0xffffff80)) /* ASCII */ { if (lower_identifier) utf8str[len++] = (char) tolower(*wstr); else utf8str[len++] = (char) *wstr; } else if ((*wstr & byte3check) == 0) { byte2code = byte2_base | ((byte2_mask1 & *wstr) >> 6) | ((byte2_mask2 & *wstr) << 8); if (little_endian) memcpy(utf8str + len, (char *) &byte2code, sizeof(byte2code)); else { utf8str[len] = ((char *) &byte2code)[1]; utf8str[len + 1] = ((char *) &byte2code)[0]; } len += sizeof(byte2code); } else if ((*wstr & byte4check) == 0) { byte4code = byte3_base | ((byte3_mask1 & *wstr) >> 12) | ((byte3_mask2 & *wstr) << 2) | ((byte3_mask3 & *wstr) << 16); if (little_endian) memcpy(utf8str + len, (char *) &byte4code, 3); else { utf8str[len] = ((char *) &byte4code)[3]; utf8str[len + 1] = ((char *) &byte4code)[2]; utf8str[len + 2] = ((char *) &byte4code)[1]; } len += 3; } else { byte4code = byte4_base | ((byte4_mask1 & *wstr) >> 18) | ((byte4_mask2 & *wstr) >> 4) | ((byte4_mask3 & *wstr) << 10) | ((byte4_mask4 & *wstr) << 24); /* MYLOG(0, " %08x->%08x\n", *wstr, byte4code); */ if (little_endian) memcpy(utf8str + len, (char *) &byte4code, sizeof(byte4code)); else { utf8str[len] = ((char *) &byte4code)[3]; utf8str[len + 1] = ((char *) &byte4code)[2]; utf8str[len + 2] = ((char *) &byte4code)[1]; utf8str[len + 3] = ((char *) &byte4code)[0]; } len += sizeof(byte4code); } } utf8str[len] = '\0'; if (olen) *olen = len; } MYLOG(0, " olen=%d %s\n", len, utf8str ? utf8str : ""); return utf8str; } /* * Convert a string from UTF-8 encoding to UTF-32. * * utf8str - input string in UTF-8 * ilen - length of input string in bytes (or minus) * lfconv - TRUE if line feeds (LF) should be converted to CR + LF * ucs4str - output buffer * bufcount - size of output buffer * errcheck - if TRUE, check for invalidly encoded input characters * * Returns the number of UInt4s copied to output buffer. If the output * buffer is too small, the output is truncated. The output string is * NULL-terminated, except when the output is truncated. */ static SQLULEN utf8_to_ucs4_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, UInt4 *ucs4str, SQLULEN bufcount, BOOL errcheck) { int i; SQLULEN rtn, ocount, wcode; const UCHAR *str; MYLOG(0, " ilen=" FORMAT_LEN " bufcount=" FORMAT_ULEN "\n", ilen, bufcount); if (!utf8str) return 0; MYLOG(99, " string=%s\n", utf8str); if (!bufcount) ucs4str = NULL; else if (!ucs4str) bufcount = 0; if (ilen < 0) ilen = strlen(utf8str); for (i = 0, ocount = 0, str = (SQLCHAR *) utf8str; i < ilen && *str;) { if ((*str & 0x80) == 0) { if (lfconv && PG_LINEFEED == *str && (i == 0 || PG_CARRIAGE_RETURN != str[-1])) { if (ocount < bufcount) ucs4str[ocount] = PG_CARRIAGE_RETURN; ocount++; } if (ocount < bufcount) ucs4str[ocount] = *str; ocount++; i++; str++; } else if (0xf8 == (*str & 0xf8)) /* more than 5 byte code */ { ocount = (SQLULEN) -1; goto cleanup; } else if (0xf0 == (*str & 0xf8)) /* 4 byte code */ { if (errcheck) { if (i + 4 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80) || 0 == (str[3] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = (((((UInt4) *str) & byte4_m1) << 18) | ((((UInt4) str[1]) & byte4_m2) << 12) | ((((UInt4) str[2]) & byte4_m3) << 6)) | (((UInt4) str[3]) & byte4_m4); ucs4str[ocount] = wcode; } ocount++; i += 4; str += 4; } else if (0xe0 == (*str & 0xf0)) /* 3 byte code */ { if (errcheck) { if (i + 3 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4) *str) & byte3_m1) << 12) | ((((UInt4) str[1]) & byte3_m2) << 6) | (((UInt4) str[2]) & byte3_m3); ucs4str[ocount] = wcode; } ocount++; i += 3; str += 3; } else if (0xc0 == (*str & 0xe0)) /* 2 byte code */ { if (errcheck) { if (i + 2 > ilen || 0 == (str[1] & 0x80)) { ocount = (SQLULEN) -1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4) *str) & byte2_m1) << 6) | (((UInt4) str[1]) & byte2_m2); ucs4str[ocount] = (SQLWCHAR) wcode; } ocount++; i += 2; str += 2; } else { ocount = (SQLULEN) -1; goto cleanup; } } cleanup: rtn = ocount; if (ocount == (SQLULEN) -1) { if (!errcheck) rtn = 0; ocount = 0; } if (ocount < bufcount && ucs4str) ucs4str[ocount] = 0; MYLOG(0, " ocount=" FORMAT_ULEN "\n", ocount); return rtn; } #define SURROGATE_CHECK 0xfc #define SURROG1_BYTE 0xd8 #define SURROG2_BYTE 0xdc static int ucs4_to_ucs2_lf(const unsigned int *ucs4str, SQLLEN ilen, SQLWCHAR *ucs2str, int bufcount, BOOL lfconv) { int outlen = 0, i; UCHAR *ucdt; SQLWCHAR *sqlwdt, dmy_wchar; UCHAR * const udt = (UCHAR *) &dmy_wchar; unsigned int uintdt; MYLOG(0, " ilen=" FORMAT_LEN " bufcount=%d\n", ilen, bufcount); if (ilen < 0) ilen = ucs4strlen(ucs4str); for (i = 0; i < ilen && (uintdt = ucs4str[i]); i++) { sqlwdt = (SQLWCHAR *)&uintdt; ucdt = (UCHAR *)&uintdt; if (0 == sqlwdt[1]) { if (lfconv && PG_LINEFEED == ucdt[0] && (i == 0 || PG_CARRIAGE_RETURN != *((UCHAR *)&ucs4str[i - 1])) ) { if (outlen < bufcount) { udt[0] = PG_CARRIAGE_RETURN; udt[1] = 0; ucs2str[outlen] = *((SQLWCHAR *) udt); } outlen++; } if (outlen < bufcount) ucs2str[outlen] = sqlwdt[0]; outlen++; continue; } sqlwdt[1]--; udt[0] = ((0xfc & ucdt[1]) >> 2) | ((0x3 & ucdt[2]) << 6); // printf("%02x", udt[0]); udt[1] = SURROG1_BYTE | ((0xc & ucdt[2]) >> 2); // printf("%02x", udt[1]); if (outlen < bufcount) ucs2str[outlen] = *((SQLWCHAR *)udt); outlen++; udt[0] = ucdt[0]; // printf("%02x", udt[0]); udt[1] = SURROG2_BYTE | (0x3 & ucdt[1]); // printf("%02x\n", udt[1]); if (outlen < bufcount) ucs2str[outlen] = *((SQLWCHAR *)udt); outlen++; } if (outlen < bufcount) ucs2str[outlen] = 0; return outlen; } static int ucs2_to_ucs4(const SQLWCHAR *ucs2str, SQLLEN ilen, unsigned int *ucs4str, int bufcount) { int outlen = 0, i; UCHAR *ucdt; SQLWCHAR sqlwdt; unsigned int dmy_uint; UCHAR * const udt = (UCHAR *) &dmy_uint; MYLOG(0, " ilen=" FORMAT_LEN " bufcount=%d\n", ilen, bufcount); if (ilen < 0) ilen = ucs2strlen(ucs2str); udt[3] = 0; /* always */ for (i = 0; i < ilen && (sqlwdt = ucs2str[i]); i++) { ucdt = (UCHAR *)(ucs2str + i); // printf("IN=%x\n", sqlwdt); if ((ucdt[1] & SURROGATE_CHECK) != SURROG1_BYTE) { // printf("SURROG1=%2x\n", ucdt[1] & SURROG1_BYTE); if (outlen < bufcount) { udt[0] = ucdt[0]; udt[1] = ucdt[1]; udt[2] = 0; ucs4str[outlen] = *((unsigned int *)udt); } outlen++; continue; } /* surrogate pair */ udt[0] = ucdt[2]; udt[1] = (ucdt[3] & 0x3) | ((ucdt[0] & 0x3f) << 2); udt[2] = (((ucdt[0] & 0xc0) >> 6) | ((ucdt[1] & 0x3) << 2)) + 1; // udt[3] = 0; needless if (outlen < bufcount) ucs4str[outlen] = *((unsigned int *)udt); outlen++; i++; } if (outlen < bufcount) ucs4str[outlen] = 0; return outlen; } #endif /* __WCS_ISO10646__ */ #if defined(__WCS_ISO10646__) static SQLULEN utf8_to_wcs_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, wchar_t *wcsstr, SQLULEN bufcount, BOOL errcheck) { switch (get_convtype()) { case WCSTYPE_UTF16_LE: return utf8_to_ucs2_lf(utf8str, ilen, lfconv, (SQLWCHAR *) wcsstr, bufcount, errcheck); case WCSTYPE_UTF32_LE: return utf8_to_ucs4_lf(utf8str, ilen, lfconv, (UInt4 *) wcsstr, bufcount, errcheck); } return -1; } static char *wcs_to_utf8(const wchar_t *wcsstr, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { switch (get_convtype()) { case WCSTYPE_UTF16_LE: return ucs2_to_utf8((const SQLWCHAR *) wcsstr, ilen, olen, lower_identifier); case WCSTYPE_UTF32_LE: return ucs4_to_utf8((const UInt4 *) wcsstr, ilen, olen, lower_identifier); } return NULL; } /* * Input strings must be NULL terminated. * Output wide character strings would be NULL terminated. The result * outmsg would be truncated when the buflen is small. * * The output NULL terminator is counted as buflen. * if outmsg is NULL or buflen is 0, only output length is returned. * As for return values, NULL terminators aren't counted. */ static int msgtowstr(const char *inmsg, wchar_t *outmsg, int buflen) { int outlen = -1; MYLOG(0, " inmsg=%p buflen=%d\n", inmsg, buflen); #ifdef WIN32 if (NULL == outmsg) buflen = 0; if ((outlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, inmsg, -1, outmsg, buflen)) > 0) outlen--; else if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) outlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, inmsg, -1, NULL, 0) - 1; else outlen = -1; #else if (0 == buflen) outmsg = NULL; outlen = mbstowcs((wchar_t *) outmsg, inmsg, buflen); #endif /* WIN32 */ if (outmsg && outlen >= buflen) { outmsg[buflen - 1] = 0; MYLOG(0, " out=%dchars truncated to %d\n", outlen, buflen - 1); } MYLOG(0, " buf=%dchars out=%dchars\n", buflen, outlen); return outlen; } /* * Input wide character strings must be NULL terminated. * Output strings would be NULL terminated. The result outmsg would be * truncated when the buflen is small. * * The output NULL terminator is counted as buflen. * if outmsg is NULL or buflen is 0, only output length is returned. * As for return values, NULL terminators aren't counted. */ static int wstrtomsg(const wchar_t *wstr, char *outmsg, int buflen) { int outlen = -1; MYLOG(0, " wstr=%p buflen=%d\n", wstr, buflen); #ifdef WIN32 if (NULL == outmsg) buflen = 0; if ((outlen = WideCharToMultiByte(CP_ACP, 0, wstr, -1, outmsg, buflen, NULL, NULL)) > 0) outlen--; else if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) outlen = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL) - 1; else outlen = -1; #else if (0 == buflen) outmsg = NULL; outlen = wcstombs(outmsg, wstr, buflen); #endif /* WIN32 */ if (outmsg && outlen >= buflen) { outmsg[buflen - 1] = 0; MYLOG(0, " out=%dbytes truncated to %d\n", outlen, buflen - 1); } MYLOG(0, " buf=%dbytes outlen=%dbytes\n", buflen, outlen); return outlen; } #endif /* __WCS_ISO10646__ */ #if defined(__CHAR16_UTF_16__) static mbstate_t initial_state; static SQLLEN mbstoc16_lf(char16_t *c16dt, const char *c8dt, size_t n, BOOL lf_conv) { int i; size_t brtn; const char *cdt; mbstate_t mbst = initial_state; MYLOG(0, " c16dt=%p size=" FORMAT_SIZE_T "\n", c16dt, n); for (i = 0, cdt = c8dt; i < n || (!c16dt); i++) { if (lf_conv && PG_LINEFEED == *cdt && i > 0 && PG_CARRIAGE_RETURN != cdt[-1]) { if (c16dt) c16dt[i] = PG_CARRIAGE_RETURN; i++; } brtn = mbrtoc16(c16dt ? c16dt + i : NULL, cdt, 4, &mbst); if (0 == brtn) break; if (brtn == (size_t) -1 || brtn == (size_t) -2) return -1; if (brtn == (size_t) -3) continue; cdt += brtn; } if (c16dt && i >= n) c16dt[n - 1] = 0; return i; } static SQLLEN c16tombs(char *c8dt, const char16_t *c16dt, size_t n) { int i; SQLLEN result = 0; size_t brtn; char *cdt, c4byte[4]; mbstate_t mbst = initial_state; MYLOG(0, " c8dt=%p size=" FORMAT_SIZE_T "u\n", c8dt, n); if (!c8dt) n = 0; for (i = 0, cdt = c8dt; c16dt[i] && (result < n || (!cdt)); i++) { if (NULL != cdt && result + 4 < n) brtn = c16rtomb(cdt, c16dt[i], &mbst); else { brtn = c16rtomb(c4byte, c16dt[i], &mbst); if (brtn < 5) { SQLLEN result_n = result + brtn; if (result_n < n) memcpy(cdt, c4byte, brtn); else { if (cdt && n > 0) { c8dt[result] = '\0'; /* truncate */ return result_n; } } } } /* printf("c16dt=%04X brtn=%lu result=%ld cdt=%02X%02X%02X%02X\n", c16dt[i], brtn, result, (UCHAR) cdt[0], (UCHAR) cdt[1], (UCHAR) cdt[2], (UCHAR) cdt[3]); */ if (brtn == (size_t) -1) { if (n > 0) c8dt[n - 1] = '\0'; return -1; } if (cdt) cdt += brtn; result += brtn; } if (cdt) *cdt = '\0'; return result; } #endif /* __CHAR16_UTF_16__ */ // // SQLBindParameter SQL_C_CHAR to UTF-8 case // the current locale => UTF-8 // SQLLEN bindpara_msg_to_utf8(const char *ldt, char **wcsbuf, SQLLEN used) { SQLLEN l = (-2); char *utf8 = NULL, *ldt_nts, *alloc_nts = NULL, ntsbuf[128]; int count; if (SQL_NTS == used) { count = strlen(ldt); ldt_nts = (char *) ldt; } else if (used < 0) { return -1; } else { count = used; if (used < sizeof(ntsbuf)) ldt_nts = ntsbuf; else { if (NULL == (alloc_nts = malloc(used + 1))) return l; ldt_nts = alloc_nts; } memcpy(ldt_nts, ldt, used); ldt_nts[used] = '\0'; } get_convtype(); MYLOG(0, " \n"); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsdt = (wchar_t *) malloc((count + 1) * sizeof(wchar_t)); if ((l = msgtowstr(ldt_nts, (wchar_t *) wcsdt, count + 1)) >= 0) utf8 = wcs_to_utf8(wcsdt, -1, &l, FALSE); free(wcsdt); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { SQLWCHAR *utf16 = (SQLWCHAR *) malloc((count + 1) * sizeof(SQLWCHAR)); if ((l = mbstoc16_lf((char16_t *) utf16, ldt_nts, count + 1, FALSE)) >= 0) utf8 = ucs2_to_utf8(utf16, -1, &l, FALSE); free(utf16); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != utf8) free(utf8); else *wcsbuf = (char *) utf8; if (NULL != alloc_nts) free(alloc_nts); return l; } // // SQLBindParameter hybrid case // SQLWCHAR(UTF-16) => the current locale // SQLLEN bindpara_wchar_to_msg(const SQLWCHAR *utf16, char **wcsbuf, SQLLEN used) { SQLLEN l = (-2); char *ldt = NULL; SQLWCHAR *utf16_nts, *alloc_nts = NULL, ntsbuf[128]; int count; if (SQL_NTS == used) { count = ucs2strlen(utf16); utf16_nts = (SQLWCHAR *) utf16; } else if (used < 0) return -1; else { count = used / WCLEN; if (used + WCLEN <= sizeof(ntsbuf)) utf16_nts = ntsbuf; else { if (NULL == (alloc_nts = (SQLWCHAR *) malloc(used + WCLEN))) return l; utf16_nts = alloc_nts; } memcpy(utf16_nts, utf16, used); utf16_nts[count] = 0; } get_convtype(); MYLOG(0, "\n"); #if defined(__WCS_ISO10646__) if (use_wcs) { if (sizeof(SQLWCHAR) == sizeof(wchar_t)) { ldt = (char *) malloc(2 * count + 1); l = wstrtomsg((wchar_t *) utf16_nts, ldt, 2 * count + 1); } else { unsigned int *utf32 = (unsigned int *) malloc((count + 1) * sizeof(unsigned int)); l = ucs2_to_ucs4(utf16_nts, -1, utf32, count + 1); if ((l = wstrtomsg((wchar_t *)utf32, NULL, 0)) >= 0) { ldt = (char *) malloc(l + 1); l = wstrtomsg((wchar_t *)utf32, ldt, l + 1); } free(utf32); } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { ldt = (char *) malloc(4 * count + 1); l = c16tombs(ldt, (const char16_t *) utf16_nts, 4 * count + 1); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != ldt) free(ldt); else *wcsbuf = ldt; if (NULL != alloc_nts) free(alloc_nts); return l; } size_t convert_linefeeds(const char *s, char *dst, size_t max, BOOL convlf, BOOL *changed); // // SQLBindCol hybrid case // the current locale => SQLWCHAR(UTF-16) // SQLLEN bindcol_hybrid_estimate(const char *ldt, BOOL lf_conv, char **wcsbuf) { SQLLEN l = (-2); get_convtype(); MYLOG(0, " lf_conv=%d\n", lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { unsigned int *utf32 = NULL; if (sizeof(SQLWCHAR) == sizeof(wchar_t)) { l = msgtowstr(ldt, (wchar_t *) NULL, 0); if (l >= 0 && lf_conv) { BOOL changed; size_t len; len = convert_linefeeds(ldt, NULL, 0, TRUE, &changed); if (changed) { l += (len - strlen(ldt)); *wcsbuf = (char *) malloc(len + 1); convert_linefeeds(ldt, *wcsbuf, len + 1, TRUE, NULL); } } } else { int count = strlen(ldt); utf32 = (unsigned int *) malloc((count + 1) * sizeof(unsigned int)); if ((l = msgtowstr(ldt, (wchar_t *) utf32, count + 1)) >= 0) { l = ucs4_to_ucs2_lf(utf32, -1, NULL, 0, lf_conv); *wcsbuf = (char *) utf32; } } if (l < 0 && NULL != utf32) free(utf32); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) l = mbstoc16_lf((char16_t *) NULL, ldt, 0, lf_conv); #endif /* __CHAR16_UTF_16__ */ return l; } SQLLEN bindcol_hybrid_exec(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv, char **wcsbuf) { SQLLEN l = (-2); get_convtype(); MYLOG(0, " size=" FORMAT_SIZE_T " lf_conv=%d\n", n, lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { unsigned int *utf32 = NULL; BOOL midbuf = (wcsbuf && *wcsbuf); if (sizeof(SQLWCHAR) == sizeof(wchar_t)) { if (midbuf) l = msgtowstr(*wcsbuf, (wchar_t *) utf16, n); else l = msgtowstr(ldt, (wchar_t *) utf16, n); } else if (midbuf) { utf32 = (unsigned int *) *wcsbuf; l = ucs4_to_ucs2_lf(utf32, -1, utf16, n, lf_conv); } else { int count = strlen(ldt); utf32 = (unsigned int *) malloc((count + 1) * sizeof(unsigned int)); if ((l = msgtowstr(ldt, (wchar_t *) utf32, count + 1)) >= 0) { l = ucs4_to_ucs2_lf(utf32, -1, utf16, n, lf_conv); } free(utf32); } if (midbuf) { free(*wcsbuf); *wcsbuf = NULL; } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { l = mbstoc16_lf((char16_t *) utf16, ldt, n, lf_conv); } #endif /* __CHAR16_UTF_16__ */ return l; } SQLLEN locale_to_sqlwchar(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv) { return bindcol_hybrid_exec(utf16, ldt, n, lf_conv, NULL); } // // SQLBindCol localize case // UTF-8 => the current locale // SQLLEN bindcol_localize_estimate(const char *utf8dt, BOOL lf_conv, char **wcsbuf) { SQLLEN l = (-2); char *convalc = NULL; get_convtype(); MYLOG(0, " lf_conv=%d\n", lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsalc = NULL; l = utf8_to_wcs_lf(utf8dt, -1, lf_conv, NULL, 0, FALSE); wcsalc = (wchar_t *) malloc(sizeof(wchar_t) * (l + 1)); convalc = (char *) wcsalc; l = utf8_to_wcs_lf(utf8dt, -1, lf_conv, wcsalc, l + 1, FALSE); l = wstrtomsg(wcsalc, NULL, 0); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { SQLWCHAR *wcsalc = NULL; l = utf8_to_ucs2_lf(utf8dt, -1, lf_conv, (SQLWCHAR *) NULL, 0, FALSE); wcsalc = (SQLWCHAR *) malloc(sizeof(SQLWCHAR) * (l + 1)); convalc = (char *) wcsalc; l = utf8_to_ucs2_lf(utf8dt, -1, lf_conv, wcsalc, l + 1, FALSE); l = c16tombs(NULL, (char16_t *) wcsalc, 0); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != convalc) free(convalc); else if (NULL != convalc) *wcsbuf = (char *) convalc; MYLOG(0, " return=" FORMAT_LEN "\n", l); return l; } SQLLEN bindcol_localize_exec(char *ldt, size_t n, BOOL lf_conv, char **wcsbuf) { SQLLEN l = (-2); get_convtype(); MYLOG(0, " size=" FORMAT_SIZE_T "\n", n); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsalc = (wchar_t *) *wcsbuf; l = wstrtomsg(wcsalc, ldt, n); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { char16_t *wcsalc = (char16_t *) *wcsbuf; l = c16tombs(ldt, (char16_t *) wcsalc, n); } #endif /* __CHAR16_UTF_16__ */ free(*wcsbuf); *wcsbuf = NULL; MYLOG(0, " return=" FORMAT_LEN "\n", l); return l; } SQLLEN utf8_to_locale(char *ldt, const char *utf8dt, size_t n, BOOL lf_conv) { SQLLEN l; char * tmpbuf; if ((l = bindcol_localize_estimate(utf8dt, lf_conv, &tmpbuf)) >= 0) l = bindcol_localize_exec(ldt, n, lf_conv, &tmpbuf); return l; } #endif /* UNICODE_SUPPORT */ psqlodbc-REL-16_00_0005/winbuild/000077500000000000000000000000001462406103600163135ustar00rootroot00000000000000psqlodbc-REL-16_00_0005/winbuild/.gitignore000066400000000000000000000000601462406103600202770ustar00rootroot00000000000000# generated_regress.vcxproj /test_x86 /test_x64 psqlodbc-REL-16_00_0005/winbuild/BuildAll.ps1000077500000000000000000000162571462406103600204460ustar00rootroot00000000000000<# .SYNOPSIS Build all dlls of psqlodbc project using MSbuild. .DESCRIPTION Build psqlodbc35w.dll, psqlodbc30a.dll, pgenlist.dll, pgenlista.dll and pgxalib.dll for both x86 and x64 platforms. .PARAMETER Target Specify the target of MSBuild. "Build"(default), "Rebuild" or "Clean" is available. .PARAMETER VCVersion Visual Studio version is determined automatically unless this option is specified. .PARAMETER Platform Specify build platforms, "both"(default), "Win32" or "x64" is available. .PARAMETER AlongWithInstallers Specify when you'd like to build installers after building drivers. .PARAMETER Toolset MSBuild PlatformToolset is determined automatically unless this option is specified. Currently "v90", "v100", "Windows7.1SDK", "v110", "v110_xp", "v120", "v120_xp", "v140" , "v140_xp", "v141", "v141_xp" or "v142" is available. .PARAMETER MSToolsVersion This option is deprecated. MSBuild ToolsVersion is detemrined automatically unless this option is specified. Currently "4.0", "12.0" or "14.0" is available. .PARAMETER Configuration Specify "Release"(default) or "Debug". .PARAMETER BuildConfigPath Specify the configuration xml file name if you want to use the configuration file other than standard one. The relative path is relative to the current directory. .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. .EXAMPLE > .\BuildAll Clean Clean all generated files. .EXAMPLE > .\BuildAll -V(CVersion) 11.0 Build using Visual Studio 11.0 environment. .EXAMPLE > .\BuildAll -P(latform) x64 Build only 64bit dlls. .EXAMPLE > .\BuildAll -A(longWithInstallers) Build installers as well after building drivers. .NOTES Author: Hiroshi Inoue Date: Febrary 1, 2014 #> # # build 32bit & 64bit dlls for VC10 or later # Param( [ValidateSet("Build", "Rebuild", "Clean", "info")] [string]$Target="Build", [string]$VCVersion, [ValidateSet("Win32", "x64", "both")] [string]$Platform="both", [string]$Toolset, [ValidateSet("", "4.0", "12.0", "14.0")] [string]$MSToolsVersion, [ValidateSet("Debug", "Release")] [String]$Configuration="Release", [string]$BuildConfigPath, [switch]$AlongWithInstallers, [switch]$UseMimalloc ) function buildPlatform([xml]$configInfo, [string]$Platform) { if ($Platform -ieq "x64") { $platinfo=$configInfo.Configuration.x64 } else { $platinfo=$configInfo.Configuration.x86 } $BUILD_MACROS=$platinfo.build_macros $PG_INC=getPGDir $configInfo $Platform "include" $PG_LIB=getPGDir $configInfo $Platform "lib" $PG_BIN=getPGDir $configInfo $Platform "bin" Write-Host "USE LIBPQ : ($PG_INC $PG_LIB $PG_BIN)" if (-not (Test-Path $PG_INC)) { throw("`n!!!! include directory $PG_INC does not exist`nplease specify the correct folder name using editConfiguration") } if (-not (Test-Path $PG_LIB)) { throw("`n!!!! lib directory $PG_LIB does not exist`nplease specify the correct folder name using editConfiguration") } if (-not (Test-Path $PG_BIN)) { throw("`n!!!! bin directory $PG_BIN does not exist`nplease specify the correct folder name using editConfiguration") } $useSplit=$true if ($useSplit) { $macroList = -split $BUILD_MACROS } else { $BUILD_MACROS = $BUILD_MACROS -replace ';', '`;' $BUILD_MACROS = $BUILD_MACROS -replace '"', '`"' $macroList = iex "write-output $BUILD_MACROS" } 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) Import-Module ${scriptPath}\Psqlodbc-config.psm1 $configInfo = LoadConfiguration $BuildConfigPath $scriptPath $DRIVERVERSION=$configInfo.Configuration.version pushd $scriptPath $path_save = ${env:PATH} Import-Module ${scriptPath}\MSProgram-Get.psm1 try { $rtnArray=Find-MSBuild ([ref]$VCVersion) ($MSToolsVersion) ([ref]$Toolset) $configInfo $msbuildexe=$rtnArray[0] $MSToolsV=$rtnArray[1] } catch [Exception] { if ("$_.Exception.Message" -ne "") { Write-Host $_.Exception.Message -ForegroundColor Red } else { echo $_.Exception | Format-List -Force } popd Remove-Module Psqlodbc-config return } finally { Remove-Module MSProgram-Get } $recordResult = $true if ($Target -ne "info") { $configInfo.Configuration.BuildResult.Date="" $configInfo.Configuration.BuildResult.VisualStudioVersion="" $configInfo.Configuration.BuildResult.PlatformToolset="" $configInfo.Configuration.BuildResult.ToolsVersion="" $configInfo.Configuration.BuildResult.Platform="" } try { # # build 32bit dlls # if ($Platform -ieq "Win32" -or $Platform -ieq "both") { buildPlatform $configInfo "Win32" if ($LastExitCode -ne 0) { $recordResult = $false } } # # build 64bit dlls # if ($recordResult -and ($Platform -ieq "x64" -or $Platform -ieq "both")) { buildPlatform $configInfo "x64" if ($LastExitCode -ne 0) { $recordResult = $false } } # # Write the result to configuration xml # $resultText="successful" if ($recordResult) { if ($Target -ne "Clean") { $configInfo.Configuration.BuildResult.Date=[string](Get-Date) $configInfo.Configuration.BuildResult.VisualStudioVersion=$VCVersion $configInfo.Configuration.BuildResult.PlatformToolset=$Toolset $configInfo.Configuration.BuildResult.ToolsVersion=$MSToolsV $configInfo.Configuration.BuildResult.Platform=$Platform } } else { $resultText="failed" } SaveConfiguration $configInfo Write-Host "VisualStudioVersion=$VCVersion(ToolsVersion=$MSToolsV) PlatformToolset=$Toolset Platform=$Platform $resultText`n" # # build installers as well # if ($AlongWithInstallers) { if (-not $recordResult) { throw("compilation failed") } $cpu = $Platform if ($Platform -eq "win32") { $cpu = "x86" } ..\installer\buildInstallers.ps1 -cpu $cpu -BuildConfigPath $BuildConfigPath if ($LASTEXITCODE -ne 0) { throw "Failed to build installers" } } } catch [Exception] { if ("$_.Exception.Message" -ne "") { Write-Host $_.Exception.Message -ForegroundColor Red } else { echo $_.Exception | Format-List -Force } } finally { $env:PATH = $path_save popd Remove-Module Psqlodbc-config } psqlodbc-REL-16_00_0005/winbuild/MSProgram-Get.psm1000066400000000000000000000266431462406103600215140ustar00rootroot00000000000000 function Find-MSBuild { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [ref]$VCVersion, [Parameter(Mandatory=$true)] $MSToolsVersion, [Parameter(Mandatory=$true)] [ref]$Toolset, [Parameter(Mandatory=$true)] [xml]$configInfo) $msbuildexe="" $VisualStudioVersion=$VCVersion.Value $Toolsetv=$Toolset.Value $WSDK71Set="Windows7.1SDK" Write-Debug "VCVersion=$VCVersionv $env:VisualStudioVersion" [int]$toolsnum=0 # # Determine VisualStudioVersion # if (("$VisualStudioVersion" -eq "") -And ($configInfo -ne $null)) { $VisualStudioVersion=$configInfo.Configuration.vcversion } if ("$VisualStudioVersion" -eq "") { $VisualStudioVersion = $env:VisualStudioVersion # VC11 or later version of C++ command prompt sets this variable } if ("$VisualStudioVersion" -eq "") { if ("${env:WindowsSDKVersionOverride}" -eq "v7.1") { # SDK7.1+ command prompt $VisualStudioVersion = "10.0" } elseif ("${env:VCInstallDir}" -ne "") { # C++ command prompt if ("${env:VCInstallDir}" -match "Visual Studio\s*(\S+)\\VC\\$") { $VisualStudioVersion = $matches[1] } } } $refnum="" # neither C++ nor SDK prompt if ("$VisualStudioVersion" -eq "") { if ((Find-VSDir 15) -ne "") { # VC15 is installed (current official) $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 $VisualStudioVersion = "12.0" } elseif ("${env:VS100COMNTOOLS}" -ne "") { # VC10 is installed $VisualStudioVersion = "10.0" } elseif ("${env:VS110COMNTOOLS}" -ne "") { # VC11 is installed $VisualStudioVersion = "11.0" } else { throw "Visual Studio >= 10.0 not found" } } if ([int]::TryParse($VisualStudioVersion, [ref]$refnum)) { $VisualStudioVersion="${refnum}.0" } # Check VisualStudioVersion and prepare for ToolsVersion switch ($VisualStudioVersion) { "10.0" { $toolsout = 4 } "11.0" { $toolsout = 4 } "12.0" { $toolsout = 12 } "14.0" { $toolsout = 14 } "15.0" { $toolsout = 15 } "16.0" { $toolsout = 16 } "17.0" { $toolsout = 17 } default { throw "Selected Visual Studio is Version ${VisualStudioVersion}. Please use VC10 or later"} } # # Determine ToolsVersion # [int]$toolsnum=$toolsout if ("$MSToolsVersion" -eq "") { $MSToolsVersion=$env:ToolsVersion } if ("$MSToolsVersion" -ne "") { if ([int]::TryParse($MSToolsVersion, [ref]$refnum)) { $toolsout=[int]$refnum } } if ($toolsnum -lt 12) { $toolsnum=$toolsout } # # Determine MSBuild executable # Write-Debug "ToolsVersion=$MSToolsVersion VisualStudioVersion=$VisualStudioVersion" try { $msbver = msbuild.exe /ver /nologo if ("$msbver" -match "^(\d+)\.(\d+)") { $major1 = [int] $matches[1] $minor1 = [int] $matches[2] if ($MSToolsVersion -match "^(\d+)\.(\d+)") { $bavail = $false $major2 = [int] $matches[1] $minor2 = [int] $matches[2] if ($major1 -gt $major2) { Write-Debug "$major1 > $major2" $bavail = $true } elseif ($major1 -eq $major2 -And $minor1 -ge $minor2) { Write-Debug "($major1, $minor1) >= ($major2, $minor2)" $bavail = $true } if ($bavail) { $msbuildexe = "MSBuild" } } } } catch {} if ("$msbuildexe" -eq "") { Write-Debug "tools version $toolsnum" if ($toolsnum -gt 14) { # VC15 ~ VC16 $msbuildexe = msbfind_15_xx $toolsnum } else { # VC10 ~ VC14 $msbuildexe = msbfind_10_14 "${toolsnum}.0" if ($toolsnum -eq 4) { if ((Find-VSDir $VisualStudioVersion) -eq "") { throw "MSBuild ${toolsnum}.0 found but VisualStudioVersion $VisualStudioVersion not Found" } } } if ("$msbuildexe" -eq "") { throw "MSBuild ToolsVersion ${toolsnum}.0 not Found" } } # # Determine PlatformToolset # if (("$Toolsetv" -eq "") -And ($configInfo -ne $null)) { $Toolsetv=$configInfo.Configuration.toolset } if ("$Toolsetv" -eq "") { $Toolsetv=$env:PlatformToolset } if ("$Toolsetv" -eq "") { switch ($VisualStudioVersion) { "10.0" { if (Test-path "HKLM:\Software\Microsoft\Microsoft SDKs\Windows\v7.1") { $Toolsetv=$WSDK71Set } else { $Toolsetv="v100" } } "11.0" {$Toolsetv="v110_xp"} "12.0" {$Toolsetv="v120_xp"} "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 if ($Toolsetv -eq $WSDK71Set) { $env:TARGET_CPU="" } # $VCVersion.value=$VisualStudioVersion $Toolset.value=$Toolsetv if ("$MSToolsVersion" -eq "") { if ([int]$toolsout -gt 15) { $MSToolsVersion="Current" } else { $MSToolsVersion="${toolsout}.0" } } return $msbuildexe, $MSToolsVersion } # find msbuild.exe for VC10 ~ VC14 function msbfind_10_14 { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$toolsver) $msbindir="" $regKey="HKLM:\Software\Wow6432Node\Microsoft\MSBuild\ToolsVersions\${toolsver}" if (Test-Path -path $regkey) { $msbitem=Get-ItemProperty $regKey if ($msbitem -ne $null) { $msbindir=$msbitem.MSBuildToolsPath } } else { $regKey="HKLM:\Software\Microsoft\MSBuild\ToolsVersions\${toolsver}" if (Test-Path -path $regkey) { $msbitem=Get-ItemProperty $regKey if ($msbitem -ne $null) { $msbindir=$msbitem.MSBuildToolsPath } } else { return "" } } return "${msbindir}msbuild" } # find msbuild.exe for VC15 ~ VC16 function msbfind_15_xx { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$toolsver) # via vssetup module $vsdir = find_vs_installation $toolsver # vssetup module is unavailable return find_default_msbuild_path $toolsver $vsdir } $dumpbinexe = "" $addPath="" function Find-Dumpbin { [CmdletBinding()] Param([int]$CurMaxVC = 16) if ("$dumpbinexe" -ne "") { if ("$addPath" -ne "") { if (${env:PATH}.indexof($addPath) -lt 0) { $env:PATH = "${addPath};" + $env:PATH } } return $dumpbinexe } $addPath="" $vsdir="" try { $dum = dumpbin.exe /NOLOGO $dumpbinexe="dumpbin" } catch [Exception] { # $dumpbinexe="$env:DUMPBINEXE" if ($dumpbinexe -eq "") { $searching = $true for ($i = $CurMaxVc; $searching -and ($i -ge 14); $i--) # VC15 ~ VC16 { $vsdir = Find-VSDir $i if ("$vsdir" -ne "") { $lslist = @(Get-ChildItem "${vsdir}VC\Tools\MSVC\*\bin\HostX86\x86\dumpbin.exe" -ErrorAction SilentlyContinue) if ($lslist.Count -gt 0) { $dumpbinexe=$lslist[0].FullName $searching = $false break } } } for (; $searching -and ($i -ge 10); $i--) # VC10 ~ VC14 { $vsdir = Find-VSDir $i if ("$vsdir" -ne "") { $dumpbinexe="${vsdir}VC\bin\dumpbin.exe" if (Test-Path -Path $dumpbinexe) { $searching = $false break } } } if ($searching) { throw "dumpbin doesn't exist" } elseif ($i -eq 10) { $addPath = "${vsdir}Common7\ide" } } } Set-Variable -Name dumpbinexe -Value $dumpbinexe -Scope 1 Set-Variable -Name addPath -Value $addPath -Scope 1 if ("$addPath" -ne "") { if (${env:PATH}.indexof($addPath) -lt 0) { $env:PATH = "${addPath};" + $env:PATH } } return $dumpbinexe } function dumpbinRecurs { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$dllname, [Parameter(Mandatory=$true)] [string]$dllfolder, [array]$instarray) $tmem=& ${dumpbinexe} /imports "$dllfolder\${dllname}" | select-string -pattern "^\s*(\S*\.dll)" | foreach-object {$_.Matches.Groups[1].Value} | where-object {test-path ("${dllfolder}\" + $_)} if ($LASTEXITCODE -ne 0) { throw "Failed to dumpbin ${dllfolder}\${dllname}" } if ($tmem -eq $Null) { return $instarray } if ($tmem.GetType().Name -eq "String") { [String []]$tarray = @($tmem) } else { $tarray = $tmem } $iarray=@() for ($i=0; $i -lt $tarray.length; $i++) { if (-not($instarray -contains $tarray[$i])) { $iarray += $tarray[$i] } } if ($iarray.length -eq 0) { return $instarray } $instarray += $iarray for ($i=0; $i -lt $iarray.length; $i++) { $instarray=dumpbinRecurs $iarray[$i] $dllfolder $instarray } return $instarray } function Get-RelatedDlls { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$dllname, [Parameter(Mandatory=$true)] [string]$dllfolder) Find-Dumpbin | Out-Null $libpqmem=@() $libpqmem=dumpbinRecurs $dllname $dllfolder $libpqmem return $libpqmem } function env_vcversion_no() { $viver = $env:VisualStudioVersion if ("$viver" -ne "") { if ("$viver" -match "(\d+)\.0") { return [int]$matches[1] } } return 0 } function Find-VSDir { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$vcversion) [int]$vcversion_no = [int]$vcversion if ("${vcversion}" -match "^(\d+)") { $vcversion_no = $matches[1] } if ((env_vcversion_no) -eq $vcversion_no) { return $env:VSINSTALLDIR } if ($vcversion_no -gt 14) { # VC15 ~ VC16 return find_vsdir_15_xx ${vcversion_no} } else { # VC10 ~ VC14 $comntools = [environment]::getenvironmentvariable("VS${vcversion_no}0COMNTOOLS") if ("$comntools" -eq "") { return "" } return (Split-Path (Split-Path $comntools -Parent) -Parent) + "\" } } [bool]$vssetup_available = $true $vssetup = $null # find vs installation path for VC15 ~ VC16 function find_vs_installation { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$toolsver) $vsdir = "" # vssetup module is available? if ($vssetup_available -and ($vsseup -eq $null)) { try { $vssetup = @(Get-VssetupInstance) } catch [Exception] { $vssetup_available = $false } } $toolsnum = [int]$toolsver if ($vssetup -ne $null) { $lslist = @($vssetup | where-object { $_.InstallationVersion.Major -eq $toolsnum } | foreach-object { $_.InstallationPath }) if ($lslist.Count -gt 0) { $vsdir = $lslist[0] } } return $vsdir } $vsarray = @{VC15 = "2017"; VC16 = "2019"; VC17 = "2022"} # find VS dir for VC15 ~ VC16 function find_default_msbuild_path { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$toolsver, [string]$vsdir) if ($vsdir -eq "") { $toolsnum = [int]$toolsver 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) } if ($lslist.Count -gt 0) { return $lslist[0].FullName } return "" } # find VS dir for VC15 ~ VC16 function find_vsdir_15_xx { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$toolsver) # via vssetup module $vsdir = find_vs_installation $toolsver if ($vsdir -ne "") { return $vsdir } # vssetup module is unavailable $msbpath = find_default_msbuild_path $toolsver $vsdir if ($msbpath -ne "") { return (Split-Path (Split-Path (Split-Path (Split-Path $msbpath -Parent) -Parent) -Parent) -Parent) + "\" } return "" } Export-ModuleMember -function Find-MSBuild, Find-Dumpbin, Get-RelatedDlls, Find-VSDir psqlodbc-REL-16_00_0005/winbuild/Psqlodbc-config.psm1000077500000000000000000000120731462406103600221350ustar00rootroot00000000000000$configurationXmlPath="" $configurationTemplatePath="" function InitConfiguration([string]$savePath) { $configInfo = [xml](Get-Content $configurationTemplatePath) if ($env:PROCESSOR_ARCHITECTURE -ieq "x86") { $x64info = $configInfo.Configuration.x64 $x64info.libpq.include = "" $x64info.libpq.lib = "" $x64info.libpq.bin = "" } $configInfo.save($savePath) return $configInfo } function GetConfiguration([string]$loadPath) { $configInfo = [xml] (Get-Content $loadPath) set-variable -name xmlFormatVersion -value "0.4" -option constant if ($configInfo.Configuration.formatVersion -ne $xmlFormatVersion) { $xmlDoc2 = [xml](Get-Content $configurationTemplatePath) $root2 = $XmlDoc2.get_DocumentElement() $root1 = $configInfo.get_DocumentElement() unifyNodes $root1 $root2 $root1.formatVersion = $xmlFormatVersion $configInfo.save($loadPath) } return $configInfo } function LoadConfiguration([string]$configPath, [string]$configDir) { Write-Debug "configPath=$configPath" set-variable -name configurationTemplatePath -scope 1 -value "$configDir\configuration_template.xml" if ("$configPath" -eq "") { if ("$env:PSQLODBC_WCONFIG" -eq "") { $configPath = "$configDir\configuration.xml" } else { $configPath = $env:PSQLODBC_WCONFIG } } set-variable -name configurationXmlPath -scope 1 -value $configPath if (!(Test-Path -path $configPath)) { return InitConFiguration $configPath } else { return GetConfiguration $configPath } } function SaveConfiguration([xml]$configInfo, [string]$savePath) { if ("$savePath" -eq "") { $savePath = $configurationXmlPath } $configInfo.save($savePath) } function unifyNodes($node1, $node2) { $attributes2 = $node2.get_Attributes() if ($attributes2.Count -gt 0) { $attributes1 = $node1.get_Attributes() foreach ($attrib in $attributes2) { $attribname = $attrib.name if (($attributes1.Count -eq 0) -or ($attributes1.GetNamedItem($attribname) -eq $null)) { Write-Debug " Adding attribute=$attribname" $addattr = $node1.OwnerDocument.ImportNode($attrib, $true) $added = $attributes1.Append($addattr) } } } if (!$node2.get_HasChildNodes()) { return } foreach ($child2 in $node2.get_ChildNodes()) { $nodename = $child2.get_Name() if ($nodename -eq "#text"){ continue } $matchnode = $node1.SelectSingleNode($nodename) if ($matchnode -eq $null) { Write-Debug "Adding node=$nodename" $addnode = $node1.OwnerDocument.ImportNode($child2, $true) $added = $node1.AppendChild($addnode) continue } unifyNodes $matchnode $child2 } } function getPGDir([xml]$configInfo, [string]$Platform, [string]$kind) { if ($Platform -ieq "x64") { $platinfo=$configInfo.Configuration.x64 } else { $platinfo=$configInfo.Configuration.x86 } $LIBPQVER=$platinfo.libpq.version if ($kind -eq "include") { $result=$platinfo.libpq.include } elseif ($kind -eq "lib") { $result=$platinfo.libpq.lib } else { $result=$platinfo.libpq.bin } if ($result -ne "default") { return $result } if ($Platform -ieq "x64") { if ($env:PROCESSOR_ARCHITECTURE -ieq "x86") { $pgmfs = $env:ProgramW6432 } else { $pgmfs = $env:ProgramFiles } } else { if ($env:PROCESSOR_ARCHITECTURE -ieq "x86") { $pgmfs = $env:ProgramFiles } else { $pgmfs = ${env:ProgramFiles(x86)} } } if ("$pgmfs" -eq "") { $result = $null } else { $lslist = $null $result = $null if (-not (Test-Path "$pgmfs\PostgreSQL")) { throw("default Postgres Directory not found`nPlease specify the directories other than default") } $lslist = @(Get-ChildItem "$pgmfs\PostgreSQL") if ($null -eq $lslist) { throw("default Postgres Directory not found") } else { [decimal]$vernum = 0 if ("$LIBPQVER" -eq "") { foreach ($l in $lslist) { $ver = [decimal]$l.Name if ($ver -gt $vernum) { $result = $l.FullName + "\$kind" $vernum = $ver } } } else { foreach ($l in $lslist) { if ($LIBPQVER -eq $l.Name) { $result = $l.FullName + "\$kind" break } } } } } return $result } function GetPackageVersion([xml]$configInfo, [string]$srcpath) { $version_no = $configInfo.Configuration.version if ("$version_no" -eq "") { pushd "$srcpath" $splitItem = Get-Content ".\version.h" | Where-Object {($_.IndexOf("#define") -ge 0) -and ($_.IndexOf("POSTGRESDRIVERVERSION") -ge 0) -and ($_.IndexOF("`"") -ge 0)} | ForEach-Object {$_.split("`"")} $version_no = $splitItem[1] popd } return $version_no } function GetObjbase([string] $stdDir, [string] $addPath = "") { if ("$env:PSQLODBC_OBJBASE" -eq "") { return $stdDir } else { if ("$addPath" -eq "") { return $env:PSQLODBC_OBJBASE } else { return $env:PSQLODBC_OBJBASE + "\" + $addPath } } } Export-ModuleMember -function LoadConfiguration, SaveConfiguration, unifyNodes, getPGDir, getPackageVersion, GetObjbase -variable LIBPQ_VERSION psqlodbc-REL-16_00_0005/winbuild/configuration_template.xml000077500000000000000000000015351462406103600236060ustar00rootroot00000000000000 default default default default default default psqlodbc-REL-16_00_0005/winbuild/editConfiguration.ps1000077500000000000000000000260251462406103600224250ustar00rootroot00000000000000# Powershell needs to run in STA mode to display WPF windows Param( [string]$configPath ) if ([Threading.Thread]::CurrentThread.GetApartmentState() -eq "MTA"){ PowerShell -Sta -File $MyInvocation.MyCommand.Path return } <# configuration XAML with WPF #> Add-Type -AssemblyName presentationframework [xml]$XAML = @'