psqlodbc.git
11 years agoGet rid of copy and paste code in installer/ and unify them.
Hiroshi Inoue [Tue, 12 Aug 2014 04:28:16 +0000 (13:28 +0900)]
Get rid of copy and paste code in installer/ and unify them.

The powershell scripts had lots of duplication. Make the unified
code instead.
Original patch was provided by Craig Ringer.

11 years agoAdd a check for NULL dereference pointed out by Pluto Cobain.
Hiroshi Inoue [Thu, 10 Jul 2014 03:51:50 +0000 (12:51 +0900)]
Add a check for NULL dereference pointed out by Pluto Cobain.
It's for safety though I don't think it would occur.

11 years agoRemove duplicated line in snprintf() which causes a crash introduced by
Hiroshi Inoue [Tue, 8 Jul 2014 05:22:17 +0000 (14:22 +0900)]
Remove duplicated line in snprintf() which causes a crash introduced by
the commit 1177281049e8bb3df5992da5dc1ca31ad892082e.

11 years agoRemove unsed dialog which was added by mistake.
Hiroshi Inoue [Mon, 7 Jul 2014 03:47:30 +0000 (12:47 +0900)]
Remove unsed dialog which was added by mistake.

11 years agoRevise descriptor stuff.
Hiroshi Inoue [Fri, 13 Jun 2014 12:47:24 +0000 (18:32 +0545)]
Revise descriptor stuff.
descriptor.c(h) was broken by the commit
2da1668f4c7d7871a7212db10af606a7e646abd6
and it now causes a crash bug.
Instead of reverting the change revising the stuff completely.

11 years agoFix a memory leak pointed out by pluto.cobain.
Hiroshi Inoue [Fri, 4 Jul 2014 03:52:49 +0000 (12:52 +0900)]
Fix a memory leak pointed out by pluto.cobain.

11 years agoRemove the duplicate winbuild readme
Craig Ringer [Thu, 3 Jul 2014 06:03:19 +0000 (14:03 +0800)]
Remove the duplicate winbuild readme

11 years agoRemove obsolete .bat installer creators
Craig Ringer [Thu, 3 Jul 2014 05:56:44 +0000 (13:56 +0800)]
Remove obsolete .bat installer creators

11 years agoDocument enabling MSDTC tracing
Craig Ringer [Thu, 3 Jul 2014 04:59:07 +0000 (12:59 +0800)]
Document enabling MSDTC tracing

11 years agoDocument build opts for SDK vs VS better
Craig Ringer [Thu, 3 Jul 2014 04:58:51 +0000 (12:58 +0800)]
Document build opts for SDK vs VS better

11 years agoAdd KeepaliveTime and KeepaliveInterval options to specify time or
Hiroshi Inoue [Sun, 1 Jun 2014 10:08:28 +0000 (19:08 +0900)]
Add KeepaliveTime and KeepaliveInterval options to specify time or
interval for keepalive.

11 years agoRemove PgDtc_set_property(.., prepareRequestded, 0) which causes a crash
Hiroshi Inoue [Mon, 30 Jun 2014 11:59:22 +0000 (20:59 +0900)]
Remove PgDtc_set_property(.., prepareRequestded, 0) which causes a crash
in case PREPARE TRANSACTION error. The property prepareRequested isn't set
anywhere.

11 years agoFix driver name mismatch between 32-bit ODBC app and 64-bit MSDTC host
Craig Ringer [Wed, 25 Jun 2014 07:17:00 +0000 (15:17 +0800)]
Fix driver name mismatch between 32-bit ODBC app and 64-bit MSDTC host

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 within
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".

To fix this, we detect if we're running under SysWow64 by examining the
PROCESSOR_ARCHITEW6432 environment variable and supply the 64-bit driver name
if so.

See mailing list thread:

  http://www.postgresql.org/message-id/53A45B59.70303@2ndquadrant.com

for details.

Craig Ringer

11 years agoFix bug with UseDeclareFetch=1 when a transaction is committed before fetch.
Heikki Linnakangas [Tue, 24 Jun 2014 13:38:00 +0000 (16:38 +0300)]
Fix bug with UseDeclareFetch=1 when a transaction is committed before fetch.

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.

11 years agoRemove unused function.
Heikki Linnakangas [Tue, 24 Jun 2014 07:27:46 +0000 (10:27 +0300)]
Remove unused function.

Previous commit added a void return to a function with char * return value,
which generated a warning. On further inspection, the whole function is
used nowhere, so just remove it rather than try fixing the warning.

11 years agoThis patch fixes a NULL pointer dereference occurring when connecting
Hiroshi Inoue [Tue, 24 Jun 2014 03:22:15 +0000 (12:22 +0900)]
This patch fixes a NULL pointer dereference occurring when connecting
using SSPI authentication (without kerberos, a local Windows user trying
to connect to postgres instance on same host). Patch originally by
Nikhil R Deshpande, 1 line added for safety by me.

11 years agoFix compilation on Windows, broken by my previous commit.
Heikki Linnakangas [Mon, 23 Jun 2014 07:55:50 +0000 (10:55 +0300)]
Fix compilation on Windows, broken by my previous commit.

Michael Paquier

11 years agoRefactor SQLCancel() and add comments, for readability.
Heikki Linnakangas [Fri, 20 Jun 2014 16:43:20 +0000 (19:43 +0300)]
Refactor SQLCancel() and add comments, for readability.

11 years agoFix bug in SQLCancel().
Heikki Linnakangas [Fri, 20 Jun 2014 16:43:13 +0000 (19:43 +0300)]
Fix bug in SQLCancel().

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.

11 years agoFix broken buildX86-installer.ps1 due to the change to use psqlodbcm_cpu.wxs instead...
Hiroshi Inoue [Fri, 20 Jun 2014 02:09:19 +0000 (11:09 +0900)]
Fix broken buildX86-installer.ps1 due to the change to use psqlodbcm_cpu.wxs instead of psqlodbcm.wxs.

11 years agoDon't use PG_VERSION_xx() macros in original_CC_connect() because
Hiroshi Inoue [Fri, 20 Jun 2014 03:19:45 +0000 (12:19 +0900)]
Don't use PG_VERSION_xx() macros in original_CC_connect() because
it's not obtained from the server yet. This may fix another cause
of the problem Craig Ringer reported.

11 years agoMerge remote-tracking branch 'ringerc/fix-febe-protocol-desync-emptyquery'
Hiroshi Inoue [Fri, 20 Jun 2014 02:13:25 +0000 (11:13 +0900)]
Merge remote-tracking branch 'ringerc/fix-febe-protocol-desync-emptyquery'

11 years agoFix use of server-queried version before connection
Craig Ringer [Thu, 19 Jun 2014 05:56:57 +0000 (13:56 +0800)]
Fix use of server-queried version before connection

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.

11 years agoFix the problems using SQLFetch on prepared INSERT with RETURNING clause reported...
Hiroshi Inoue [Sun, 1 Jun 2014 05:42:21 +0000 (14:42 +0900)]
Fix the problems using SQLFetch on prepared INSERT with RETURNING clause reported by John Smith.

11 years agoClear errors for prepared statement for subsequent exections.
Hiroshi Inoue [Sun, 1 Jun 2014 09:35:50 +0000 (18:35 +0900)]
Clear errors for prepared statement for subsequent exections.

11 years agoIncrease digits used to convert from REAL/DOUBLEs to strings so that the reverse
Hiroshi Inoue [Thu, 19 Jun 2014 04:39:07 +0000 (10:24 +0545)]
Increase digits used to convert from REAL/DOUBLEs to strings so that the reverse
 conversions can recover original values. Patch originally by John Smith, slightly changed by me.

11 years agoSQL_NUMERIC_STRUCT was not available until ODBC 3.0
Heikki Linnakangas [Wed, 18 Jun 2014 18:08:07 +0000 (21:08 +0300)]
SQL_NUMERIC_STRUCT was not available until ODBC 3.0

Also add a prototype for ResolveNumericParam for readability.

11 years agoFix access to unallocated memory in IAsyncPG
Craig Ringer [Mon, 16 Jun 2014 13:16:31 +0000 (21:16 +0800)]
Fix access to unallocated memory in IAsyncPG

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)
complains about it:

Error #4: UNADDRESSABLE ACCESS: reading 0x00b1b2b0-0x00b1b2b4 4 byte(s)
# 0 pgenlista.dll!IAsyncPG::Release   [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:352]
# 1 pgenlista.dll!CloseCommitThread   [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
# 2 MSVCR120D.dll!_callthreadstart    [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
# 3 MSVCR120D.dll!_threadstart        [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
# 4 KERNEL32.dll!BaseThreadInitThunk +0x11     (0x7768338a <KERNEL32.dll+0x1338a>)
Note: @0:00:57.879 in thread 4516
Note: next higher malloc: 0x00b1b420-0x00b1b440
Note: 0x00b1b2b0-0x00b1b2b4 overlaps memory 0x00b1b2a0-0x00b1b390 that was freed here:
Note: # 0 replace_operator_delete                              [d:\drmemory_package\common\alloc_replace.c:2524]
Note: # 1 pgenlista.dll!IAsyncPG::`scalar deleting destructor'
Note: # 2 pgenlista.dll!IAsyncPG::Release                      [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:341]
Note: # 3 pgenlista.dll!CloseCommitThread                      [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
Note: # 4 MSVCR120D.dll!_callthreadstart                       [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
Note: # 5 MSVCR120D.dll!_threadstart                           [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
Note: # 6 KERNEL32.dll!BaseThreadInitThunk                    +0x11     (0x7768338a <KERNEL32.dll+0x1338a>)
Note: instruction: mov    0x10(%eax) -> %eax

This patch fixes the issue.

11 years agoctype_length() is missing the length for SQL_C_BIGINT and SQL_C_NUMERIC(patch by...
Hiroshi Inoue [Mon, 16 Jun 2014 11:42:09 +0000 (20:42 +0900)]
ctype_length() is missing the length for SQL_C_BIGINT and SQL_C_NUMERIC(patch by John Smith <nukemd@hotmail.com>).

11 years agoDiscuss issues with SDK support and installation
Craig Ringer [Mon, 16 Jun 2014 04:25:21 +0000 (12:25 +0800)]
Discuss issues with SDK support and installation

11 years agoDocument build outputs
Craig Ringer [Mon, 16 Jun 2014 04:20:44 +0000 (12:20 +0800)]
Document build outputs

The build didn't explain what went where, or what to do about dependencies.
Improve the docs to cover the topic.

11 years agoFix the warning MSB8028: The intermediate directory (..\x86_Unicode_Release\) contain...
Hiroshi Inoue [Sun, 15 Jun 2014 12:22:29 +0000 (21:22 +0900)]
Fix the warning MSB8028: The intermediate directory (..\x86_Unicode_Release\) contains files shared from another project (pgxalib.vcxproj).  This can lead to incorrect clean and rebuild behavior.

11 years agoIt's safe to add this change in addition to the previous commit.
U-Lenovo-PC\hiroshi [Sat, 14 Jun 2014 13:28:22 +0000 (22:28 +0900)]
It's safe to add this change in addition to the previous commit.
d0c993d3f6f0a4496a20486f2ec19b14591baba7
Author: U-Lenovo-PC\hiroshi <hiroshi@Lenovo-PC.(none)>
Date:   Sat Jun 14 21:53:57 2014 +0900

    Fix potentially uninitialized local pointer access which causes
    fatal compilation errors on vs2012/2013 reported by Craig Ringer.

11 years agoFix potentially uninitialized local pointer access which causes
U-Lenovo-PC\hiroshi [Sat, 14 Jun 2014 12:53:57 +0000 (21:53 +0900)]
Fix potentially uninitialized local pointer access which causes
fatal compilation errors on vs2012/2013 reported by Craig Ringer.

11 years agoAdd top-level Windows makefile targets for building installers.
Heikki Linnakangas [Fri, 13 Jun 2014 12:34:36 +0000 (15:34 +0300)]
Add top-level Windows makefile targets for building installers.

You can now do "nmake /f win64.mak world" to build both x86 and x64
versions of the installers in one command.

11 years agoMake sure that the psqlodbc ANSI driver is ODBC3.5.
Hiroshi Inoue [Sun, 1 Jun 2014 04:02:10 +0000 (13:02 +0900)]
Make sure that the psqlodbc ANSI driver is ODBC3.5.

11 years agoChanges by a patch and a request from Craig Ringer <craig@2ndquadrant.com>.
Hiroshi Inoue [Fri, 13 Jun 2014 02:51:40 +0000 (08:36 +0545)]
Changes by a patch and a request from Craig Ringer <craig@2ndquadrant.com>.
Applied a patch [ODBC] PATCH: WiX has moved.
Register 64bit XA DLL on installation per discussion with him.

11 years agoFix a PowerShell syntax error.
Hiroshi Inoue [Sun, 1 Jun 2014 04:31:07 +0000 (13:31 +0900)]
Fix a PowerShell syntax error.
Also handle the case when GSSBINDIR parameter is given as an empty string in psqodbcm_cpu.wxs.

11 years agoSupport running regression tests on Windows.
Heikki Linnakangas [Thu, 12 Jun 2014 18:55:03 +0000 (21:55 +0300)]
Support running regression tests on Windows.

Some tests fail, and numeric test crashes for me, but at least it's
relatively easy to run the suite on Windows now.

Michael Paquier and me

11 years agoFix ODBC function escape for SPACE function.
Heikki Linnakangas [Thu, 12 Jun 2014 14:02:18 +0000 (17:02 +0300)]
Fix ODBC function escape for SPACE function.

Also add a regression test case for SPACE and a few other ODBC function
escapes.

11 years agoSilence compiler warnings from regression tests.
Heikki Linnakangas [Wed, 11 Jun 2014 21:43:48 +0000 (00:43 +0300)]
Silence compiler warnings from regression tests.

Three categories of warnings:

1. Missing return at end of main() function
2. Unused variables (copy-pasted from another test)
3. Data type mismatch in printfs, e.g. passing SQLULEN param to %d

11 years agoOops, forgot to git add some last-minute changes to the new regression test.
Heikki Linnakangas [Wed, 11 Jun 2014 21:28:16 +0000 (00:28 +0300)]
Oops, forgot to git add some last-minute changes to the new regression test.

11 years agoRewrite the conversion functions between strings and SQL_NUMERIC_STRUCT.
Heikki Linnakangas [Tue, 10 Jun 2014 10:35:05 +0000 (13:35 +0300)]
Rewrite the conversion functions between strings and SQL_NUMERIC_STRUCT.

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.

11 years agoMinor code cleanup.
Heikki Linnakangas [Mon, 9 Jun 2014 18:29:42 +0000 (21:29 +0300)]
Minor code cleanup.

The main change is to move the responsibility of adding the "length" header
to the QueryBuild from ResolveOneParam to its caller, when constructing the
parameters to send over to the server in a Bind message. ResolveOneParam
is complicated enough without that, so it seems more clear this way.

The rest is just fixes to the macros to make them deal with a "&qb" argument,
by adding parens around the macro argument. And while at it, clean up the
whitespace in them.

11 years agoMisc whitespace and comment fixes. Remove dead, commented-out code.
Heikki Linnakangas [Sat, 7 Jun 2014 18:48:46 +0000 (21:48 +0300)]
Misc whitespace and comment fixes. Remove dead, commented-out code.

For sake of readability.

11 years agoFix crash if connection is closed while sending a query to the server.
Heikki Linnakangas [Wed, 4 Jun 2014 16:58:51 +0000 (19:58 +0300)]
Fix crash if connection is closed while sending a query to the server.

This is a similar bug that was fixed in commit 22b151eb. 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.

11 years agoRemove unused NDEBUG and PSQLODBC_EXPORTS defines from makefiles.
Heikki Linnakangas [Wed, 4 Jun 2014 07:42:16 +0000 (10:42 +0300)]
Remove unused NDEBUG and PSQLODBC_EXPORTS defines from makefiles.

11 years agoRemove more unused stuff from win64.mak
Heikki Linnakangas [Wed, 4 Jun 2014 07:24:22 +0000 (10:24 +0300)]
Remove more unused stuff from win64.mak

11 years agoSilence misc issues flagged up by Clang's static analyzer, scan-build
Heikki Linnakangas [Tue, 3 Jun 2014 16:37:21 +0000 (19:37 +0300)]
Silence misc issues flagged up by Clang's static analyzer, scan-build

11 years agoUsing tolower() requires ctype.h with some compilers.
Heikki Linnakangas [Tue, 3 Jun 2014 14:57:35 +0000 (17:57 +0300)]
Using tolower() requires ctype.h with some compilers.

gcc and MSVC were happy without it, but clang warns.

11 years agoMerge 32-bit and 64-bit .wxs files used to build the .MSM files on Windows
Heikki Linnakangas [Tue, 3 Jun 2014 14:52:49 +0000 (17:52 +0300)]
Merge 32-bit and 64-bit .wxs files used to build the .MSM files on Windows

11 years agoUnify the 32-bit and 64-bit installer build processes.
Heikki Linnakangas [Tue, 3 Jun 2014 13:56:03 +0000 (16:56 +0300)]
Unify the 32-bit and 64-bit installer build processes.

Use the same .wxs file for both builds. The MSM files is still generated
differently, but this is a step in the right direction.

11 years agoFix Debug-mode builds with win64.mak
Heikki Linnakangas [Tue, 3 Jun 2014 12:38:28 +0000 (15:38 +0300)]
Fix Debug-mode builds with win64.mak

It apparently hasn't worked for a very long time. Copy some tricks from
the already-deleted win32.mak to make it work: Use /MDd rather than /MD
when compiling in Debug mode, and replace /GZ with /RTC1, to silence a
deprecation warning from the compiler

11 years agoFix Windows build with MSDTC=no.
Heikki Linnakangas [Tue, 3 Jun 2014 09:35:49 +0000 (12:35 +0300)]
Fix Windows build with MSDTC=no.

11 years agoRename Windows output folders, for clarity.
Heikki Linnakangas [Tue, 3 Jun 2014 08:23:26 +0000 (11:23 +0300)]
Rename Windows output folders, for clarity.

11 years agoRemove obsolete Windows build files.
Heikki Linnakangas [Tue, 3 Jun 2014 07:38:28 +0000 (10:38 +0300)]
Remove obsolete Windows build files.

buildx86.ps1 and buildx64.ps1 were used to invoke the nmake makefiles, but
have been obsoleted by the scripts in winbuild/. win64.mak can be used to
build 32-bit and 64-bit binaries now, so win32.mak is no longer needed.

11 years agoSimplify win32.mak and win64.mak a little bit.
Heikki Linnakangas [Mon, 2 Jun 2014 19:23:26 +0000 (22:23 +0300)]
Simplify win32.mak and win64.mak a little bit.

Change the way we test whether a directory exists, so that we don't need
a version check for Windows NT. (although we probably don't need to support
compiling on NT anymore anyway)

11 years agoImprove Windows compilation instructions in the docs.
Heikki Linnakangas [Mon, 2 Jun 2014 17:48:47 +0000 (20:48 +0300)]
Improve Windows compilation instructions in the docs.

11 years agoRefactor win64.mak to allow passing options in local file.
Heikki Linnakangas [Mon, 2 Jun 2014 17:16:49 +0000 (20:16 +0300)]
Refactor win64.mak to allow passing options in local file.

Move all the default values for external library paths to
windows-defaults.mak. Add an include for file called windows-local.mak,
this allows you to put local config options in that file, which is much
easier than passing them on the command line every time.

11 years agoRemove /incremental option from linker call on Windows / nmake
Heikki Linnakangas [Mon, 2 Jun 2014 17:03:51 +0000 (20:03 +0300)]
Remove /incremental option from linker call on Windows / nmake

The linker defaults to what were passing, so should work fine without it.

Also remove an unused variable from win32.mak

11 years agoRemove special check for nmake version 6.00.9782.0
Heikki Linnakangas [Mon, 2 Jun 2014 16:19:10 +0000 (19:19 +0300)]
Remove special check for nmake version 6.00.9782.0

Surely we don't need to support that old versions anymore. Besides, it
was bizarre to check for that exact version, and not any older or newer
versions of that era.

11 years agoRemove unused cruft from Windows build files.
Heikki Linnakangas [Mon, 2 Jun 2014 16:13:47 +0000 (19:13 +0300)]
Remove unused cruft from Windows build files.

11 years agoAdd comments to modify_msi.vbs.
Heikki Linnakangas [Mon, 2 Jun 2014 15:51:37 +0000 (18:51 +0300)]
Add comments to modify_msi.vbs.

It took me quite a while to reverse-engineer what it does, and more
importantly, why. Add comment to save time for the next reader.

11 years agoClean up Windows makefiles
Heikki Linnakangas [Mon, 2 Jun 2014 10:33:46 +0000 (13:33 +0300)]
Clean up Windows makefiles

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)

11 years agoRip out broken retry/timeout logic in SOCK_wait_for_ready.
Heikki Linnakangas [Tue, 27 May 2014 14:10:53 +0000 (17:10 +0300)]
Rip out broken retry/timeout logic in SOCK_wait_for_ready.

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.

11 years agoFix broken expected output of catalogfunctions regression test.
Heikki Linnakangas [Tue, 27 May 2014 13:18:23 +0000 (16:18 +0300)]
Fix broken expected output of catalogfunctions regression test.

11 years agoAdd Windows build directories to .gitignore
Heikki Linnakangas [Mon, 19 May 2014 11:27:27 +0000 (14:27 +0300)]
Add Windows build directories to .gitignore

Michael Paquier

11 years agocorresponds to notice the message level change. REL-09_03_0300
Hiroshi Saito [Thu, 15 May 2014 13:32:20 +0000 (22:32 +0900)]
corresponds to notice the message level change.

11 years agoFixed test/expected.
Hiroshi Saito [Wed, 14 May 2014 14:37:48 +0000 (23:37 +0900)]
Fixed test/expected.

11 years agoPrep release ver 09.03.0300
Hiroshi Saito [Tue, 13 May 2014 15:24:27 +0000 (00:24 +0900)]
Prep release ver 09.03.0300

11 years agoFix typo in error message.
Heikki Linnakangas [Mon, 12 May 2014 07:09:39 +0000 (10:09 +0300)]
Fix typo in error message.

11 years agoFix crash if connection is closed during CC_send_query_append function.
Heikki Linnakangas [Mon, 5 May 2014 07:26:36 +0000 (10:26 +0300)]
Fix crash if connection is closed during CC_send_query_append function.

Malcolm MacLeod

11 years agoFix two UseDeclareFetch bugs.
Heikki Linnakangas [Fri, 11 Apr 2014 12:14:26 +0000 (15:14 +0300)]
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.

11 years agoFix typo in test case
Heikki Linnakangas [Fri, 11 Apr 2014 06:31:39 +0000 (09:31 +0300)]
Fix typo in test case

11 years agoDon't clear error number when SQLGetDiagRec is called.
Heikki Linnakangas [Thu, 10 Apr 2014 19:00:58 +0000 (22:00 +0300)]
Don't clear error number when SQLGetDiagRec is called.

Calls to SQLGetDiagRec are supposed to be nondestructive, per ODBC spec.
Also add a test case for that.

11 years agoPrint a better error message in regression tests on an invalid handle.
Heikki Linnakangas [Thu, 10 Apr 2014 18:59:39 +0000 (21:59 +0300)]
Print a better error message in regression tests on an invalid handle.

Has no effect at the moment, but I've seen it happen during development
of new regression tests, when I've passed an invalid handle to print_diag
by accident.

11 years agoAdd test case for error-rollback behavior.
Heikki Linnakangas [Tue, 25 Mar 2014 11:33:50 +0000 (13:33 +0200)]
Add test case for error-rollback behavior.

The rollback behavior is specified in the Protocol setting.

Michael Paquier

11 years agoAvoid deprecated SQLAllocStmt/SQLFreeStmt in regression tests.
Heikki Linnakangas [Mon, 24 Mar 2014 06:49:26 +0000 (08:49 +0200)]
Avoid deprecated SQLAllocStmt/SQLFreeStmt in regression tests.

The deprecated functions have a test case of their own.

Michael Paquier

11 years agoAdd test case for SQLGetConnectOption
Heikki Linnakangas [Mon, 24 Mar 2014 06:45:24 +0000 (08:45 +0200)]
Add test case for SQLGetConnectOption

Michael Paquier

11 years agoAdd a new test case to test ODBC functions deprecated in ODBC 3.0
Heikki Linnakangas [Thu, 20 Mar 2014 08:19:27 +0000 (09:19 +0100)]
Add a new test case to test ODBC functions deprecated in ODBC 3.0

Michael Paquier

11 years agoAdd more test cases for ODBC catalog functions.
Heikki Linnakangas [Tue, 18 Mar 2014 19:35:29 +0000 (21:35 +0200)]
Add more test cases for ODBC catalog functions.

Michael Paquier

11 years agoAdd test/Makefile to .gitignore.
Heikki Linnakangas [Tue, 18 Mar 2014 07:03:38 +0000 (09:03 +0200)]
Add test/Makefile to .gitignore.

It's generated from test/Makefile.in now.

11 years agoUse the PG_CONFIG setting from ./configure cmd line in regression tests.
Heikki Linnakangas [Mon, 17 Mar 2014 13:50:11 +0000 (15:50 +0200)]
Use the PG_CONFIG setting from ./configure cmd line in regression tests.

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.

11 years agoReplace NOT_USE_LIBPQ with USE_LIBPQ #define.
Heikki Linnakangas [Mon, 17 Mar 2014 13:38:15 +0000 (15:38 +0200)]
Replace NOT_USE_LIBPQ with USE_LIBPQ #define.

This avoids the cumbersome double-negatives, "#ifndef NOT_USE_LIBPQ",
making the code easier to read.

11 years agoUse the same CFLAGS/LDFLAGS to build regression tests as used to build driver.
Heikki Linnakangas [Mon, 17 Mar 2014 08:31:02 +0000 (10:31 +0200)]
Use the same CFLAGS/LDFLAGS to build regression tests as used to build driver.

11 years agoAdd missing function declarations.
Heikki Linnakangas [Wed, 12 Mar 2014 07:40:21 +0000 (09:40 +0200)]
Add missing function declarations.

These are not actually used outside of pgtypes.c, but let's be consistent
and declare them in pgtypes.h anyway.

Michael Paquier

11 years agoUse "function(void)" instead of "function()" to declare 0-arg functions.
Heikki Linnakangas [Wed, 12 Mar 2014 07:24:14 +0000 (09:24 +0200)]
Use "function(void)" instead of "function()" to declare 0-arg functions.

"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.

Michael Paquier and me.

11 years agoRemove a couple of unused functions, and fix a typeo.
Heikki Linnakangas [Tue, 11 Mar 2014 11:28:14 +0000 (13:28 +0200)]
Remove a couple of unused functions, and fix a typeo.

11 years agoMore whitespace cleanup.
Heikki Linnakangas [Tue, 11 Mar 2014 11:15:55 +0000 (13:15 +0200)]
More whitespace cleanup.

Make whitespace and indentation more consistent in SQL_API function
declarations.

11 years agoWhitespace and indentation fixes.
Heikki Linnakangas [Tue, 11 Mar 2014 08:47:05 +0000 (10:47 +0200)]
Whitespace and indentation fixes.

This also changed the file permissions stored in git for a couple of header
files, removing the executable bit. Didn't realize they were different from
all the others, but apparently my editor decided to change them. Now
they're the same as all the other files, which seems good.

Michael Paquier and me.

11 years agoPass the argument to isalpha/isspace etc. routines as unsigned char.
Heikki Linnakangas [Mon, 10 Mar 2014 17:44:34 +0000 (19:44 +0200)]
Pass the argument to isalpha/isspace etc. routines as unsigned char.

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.

11 years agoFix implicit casts between SQLCHAR and char. Don't rely on -Wno-pointer-sign.
Heikki Linnakangas [Mon, 10 Mar 2014 17:44:30 +0000 (19:44 +0200)]
Fix implicit casts between SQLCHAR and char. Don't rely on -Wno-pointer-sign.

11 years agoPrep release 09.03.0210. REL-09_03_0210
Hiroshi Saito [Thu, 6 Mar 2014 14:06:54 +0000 (23:06 +0900)]
Prep release 09.03.0210.

11 years agoAdd a .gitignore file to ignore test/results dir.
Heikki Linnakangas [Thu, 6 Mar 2014 11:45:24 +0000 (13:45 +0200)]
Add a .gitignore file to ignore test/results dir.

Michael Paquier

11 years agoUse "exit(1);" instead of "return;" to exit from main().
Heikki Linnakangas [Thu, 6 Mar 2014 11:45:21 +0000 (13:45 +0200)]
Use "exit(1);" instead of "return;" to exit from main().

Per Michael Paquier, at least some compiler on OS X didn't like it.

11 years agoRemove some dead code.
Heikki Linnakangas [Thu, 6 Mar 2014 11:45:17 +0000 (13:45 +0200)]
Remove some dead code.

11 years agoPass the content of POSTGRES_RESOURCE_VERSION variable to the resource
Hiroshi Inoue [Wed, 5 Mar 2014 08:00:45 +0000 (17:00 +0900)]
Pass the content of POSTGRES_RESOURCE_VERSION variable to the resource
compiler correctly so that FileVersion and ProductVersion are properly set.

11 years agoSilence another compiler warning.
Heikki Linnakangas [Mon, 3 Mar 2014 19:43:54 +0000 (21:43 +0200)]
Silence another compiler warning.

conn_settings cannot be NULL here.

11 years agoSilence compiler warning.
Heikki Linnakangas [Mon, 3 Mar 2014 19:23:06 +0000 (21:23 +0200)]
Silence compiler warning.

Michael Paquier

11 years agoRecord the result of Build in configuration.xml.
Hiroshi Inoue [Fri, 28 Feb 2014 14:01:37 +0000 (23:01 +0900)]
Record the result of Build in configuration.xml.