psqlodbc.git
10 years agoDisable LF <-> LF+CR conversion in the param-conversions test.
Heikki Linnakangas [Wed, 28 Jan 2015 11:21:54 +0000 (13:21 +0200)]
Disable LF <-> LF+CR conversion in the param-conversions test.

This silences a silly regression failure on Windows. There is a separate
test for LFConversion, so let's just rely on that.

10 years agoMake boolsaschar test case insensitive to whether text maps to CHAR or WCHAR.
Heikki Linnakangas [Tue, 27 Jan 2015 18:26:05 +0000 (20:26 +0200)]
Make boolsaschar test case insensitive to whether text maps to CHAR or WCHAR.

There's no need to print the type of the text column, it's not what
boolsaschar test case is testing.

This fixes regression failure on Windows with Unicode driver.

10 years agoUse a larger buffer for error message.
Heikki Linnakangas [Tue, 27 Jan 2015 17:57:11 +0000 (19:57 +0200)]
Use a larger buffer for error message.

This allows us to get a large NOTICE message. The driver limitation that the
comment in notice-test.c talks about has been lifted, remove comment.

10 years agoRemove unneeded tests from configure script.
Heikki Linnakangas [Tue, 27 Jan 2015 16:59:31 +0000 (18:59 +0200)]
Remove unneeded tests from configure script.

10 years agoTeach deprecated-test regression test about keyset-type cursors.
Heikki Linnakangas [Tue, 27 Jan 2015 16:40:55 +0000 (18:40 +0200)]
Teach deprecated-test regression test about keyset-type cursors.

Also use SQL_CURSOR_TYPE instead of SQL_ATTR_CURSOR_TYPE in the
SQLSetStmtOption calls. Although they both have the same value,
SQL_CURSOR_TYPE is what it used to be called back when SQLSetStmtOption
was not deprecated yet, so that's what a genuinely old application would
use.

10 years agoThe printf() output format of infinite/nan doubles varies across platforms.
Heikki Linnakangas [Tue, 27 Jan 2015 15:38:57 +0000 (17:38 +0200)]
The printf() output format of infinite/nan doubles varies across platforms.

Notably, it's different on Windows. Check for infinite/nan values explicitly
in the regression test, to avoid platform-dependent output.

10 years agoWindows _snprintf is not a drop-in replacement for POSIX snprintf()
Heikki Linnakangas [Tue, 27 Jan 2015 14:18:10 +0000 (16:18 +0200)]
Windows _snprintf is not a drop-in replacement for POSIX snprintf()

It handles truncation differently. Witnessed by failures in the
result-conversions regression test on Windows. Create a shim function that
uses _snprintf() to implement the POSIX truncation behavior (as long as you
don't run out of memory...)

10 years agoUse correct handle when getting error message in regression test.
Heikki Linnakangas [Tue, 27 Jan 2015 12:21:14 +0000 (14:21 +0200)]
Use correct handle when getting error message in regression test.

I hadn't noticed that the error message on procedure call didn't complain
about the invalid function. Also, on Windows, apparently the error message
isn't automatically copied from statement to connection handle, because
I got a diff.

10 years agoTeach SQLDriverConnect that Port is no longer required.
Heikki Linnakangas [Tue, 27 Jan 2015 12:17:27 +0000 (14:17 +0200)]
Teach SQLDriverConnect that Port is no longer required.

This caused SQLDriverConnect to unnecessarily fail or open a connection
options dialog if no Port was specified.

10 years agoRemove dead code.
Heikki Linnakangas [Mon, 26 Jan 2015 16:36:49 +0000 (18:36 +0200)]
Remove dead code.

Also move some stuff that's not used elsewhere into multibyte.c

10 years agoRemove dead NULL-check.
Heikki Linnakangas [Mon, 26 Jan 2015 16:30:59 +0000 (18:30 +0200)]
Remove dead NULL-check.

Per Coverity warning, res-keyset is accessed earlier, so can't be NULL.

10 years agoDon't crash on NULL result from CC_send_query
Heikki Linnakangas [Mon, 26 Jan 2015 16:25:39 +0000 (18:25 +0200)]
Don't crash on NULL result from CC_send_query

Per Coverity warning. There are probably dozens more cases like this that
it doesn't happen to warn aboute, but let's reduce the noise anyway.

10 years agoFix memory overrun bug with large keyset-driven result sets.
Heikki Linnakangas [Mon, 26 Jan 2015 16:20:43 +0000 (18:20 +0200)]
Fix memory overrun bug with large keyset-driven result sets.

The address passed to memset() was bogus, resulting in clobbering random
piece of memory.

Found by Coverity. Add a somewhat contrived test case for this too.

10 years agoRemove a few more unnecessary NULL-checks.
Heikki Linnakangas [Mon, 26 Jan 2015 15:53:12 +0000 (17:53 +0200)]
Remove a few more unnecessary NULL-checks.

The only caller to QR_next_tuple always passed non-NULL.

10 years agoRemove unnecessary null-check.
Heikki Linnakangas [Mon, 26 Jan 2015 15:49:09 +0000 (17:49 +0200)]
Remove unnecessary null-check.

Per Coverity warning.

10 years agoloadlib.c is only needed on Windows.
Heikki Linnakangas [Mon, 26 Jan 2015 07:49:00 +0000 (09:49 +0200)]
loadlib.c is only needed on Windows.

10 years agoRemove dead function.
Heikki Linnakangas [Mon, 26 Jan 2015 07:30:01 +0000 (09:30 +0200)]
Remove dead function.

10 years agoUse test -x rather than test -f to check the [i]odbc_config program.
Heikki Linnakangas [Mon, 26 Jan 2015 06:57:09 +0000 (08:57 +0200)]
Use test -x rather than test -f to check the [i]odbc_config program.

I copied the odbc_config_dummy version from the Debian system, but forgot
to make the script executable. Configure failed, but it didn't complain
about odbc_config, but it claimed that "libpq-fe.h" could not be found.
Turns out that it tried to execute odbc_config --include-prefix, which
failed, leaving the variable empty. In subsequent tests, it ran gcc like
"gcc -I -I/usr/include/postgresql". With this fix, you'll get an error
about odbc_config.

10 years agoFix miscellaneous little issues spotted by Coverity.
Heikki Linnakangas [Fri, 23 Jan 2015 19:27:57 +0000 (21:27 +0200)]
Fix miscellaneous little issues spotted by Coverity.

A few were real bugs, although highly unlikely ones. Others were false
positives like dead code, but let's be tidy.

10 years agoRemove unnecessary argument from schema_strcat1 and my_strcat1.
Heikki Linnakangas [Fri, 23 Jan 2015 18:01:01 +0000 (20:01 +0200)]
Remove unnecessary argument from schema_strcat1 and my_strcat1.

The length was always passed as SQL_NTS.

10 years agoFix test case to work with standards_conforming_strings=off.
Heikki Linnakangas [Fri, 23 Jan 2015 17:04:21 +0000 (19:04 +0200)]
Fix test case to work with standards_conforming_strings=off.

10 years agoWith standards_conforming_strings=off, one \ in LIKE pattern becomes four.
Heikki Linnakangas [Fri, 23 Jan 2015 16:54:31 +0000 (18:54 +0200)]
With standards_conforming_strings=off, one \ in LIKE pattern becomes four.

You could get a segfault if the pattern contained a lot of \ characters.
Add test case for the bug.

10 years agoCheck return values of a few function calls.
Heikki Linnakangas [Fri, 23 Jan 2015 15:40:34 +0000 (17:40 +0200)]
Check return values of a few function calls.

While we're at it, fix spelling of the error messages.

Clang static analyzer complained.

10 years agoSilence a few harmless warnings that clang static analyzer gave.
Heikki Linnakangas [Fri, 23 Jan 2015 14:41:15 +0000 (16:41 +0200)]
Silence a few harmless warnings that clang static analyzer gave.

10 years agoFix bug in detection of E'' literals.
Heikki Linnakangas [Fri, 23 Jan 2015 14:27:18 +0000 (16:27 +0200)]
Fix bug in detection of E'' literals.

The code assigned to escape_in_literal local variable when it saw a quote
characeter after E. And checked the local variable on subsequent iterations.
But the function is called separately for each processed characters, so the
local variable was reset between each call. Move the flag to the QueryParse
struct so that it survives across calls.

Expand the 'quotes' test case to cover this.

Clang Static Analyzer warned that the escape_in_literal variable was set
but not used, which lead me into looking at this more closely.

10 years agoCorrectly set returned value to an empty string in "cvt_null_date" mode.
Heikki Linnakangas [Fri, 23 Jan 2015 13:15:20 +0000 (15:15 +0200)]
Correctly set returned value to an empty string in "cvt_null_date" mode.

Spotted by clang compiler warning. Also add test case for this.

10 years agoRefactor and add comments for the modes ResolveOneParam can operate in.
Heikki Linnakangas [Fri, 23 Jan 2015 12:47:25 +0000 (14:47 +0200)]
Refactor and add comments for the modes ResolveOneParam can operate in.

ResolveOneParam can work in four different modes that are mutually
exclusive. Put the mode in an enum field in the QueryBuild struct,
separately from the additional flags that can be set. Add comments to
explain what each mode does.

Refactor the way CVT_SPECIAL_CHARS works with the query buffer along the
way. It was always a bit awkward, but with this refactoring it would've
become more so, as the mode would've needed to be another argument to it.

10 years agoMore miscellaneous cleanup.
Heikki Linnakangas [Thu, 22 Jan 2015 20:04:58 +0000 (22:04 +0200)]
More miscellaneous cleanup.

* Simplify the way the ignore-round-trip-time config option works. (No need
  for the caller of CC_send_query_append to pass it as argument,
  CC_send_query_append can look at the options in the connection object
  itself)
* remove unnecessary local variable used for "fetch" constant.
* remove unused FLGP_BUILDING_PREPARE_STATEMENT flag.
* remove unused parameter, and check for stmt==NULL, from QB_Initialize.
* inline process_statements function into its only caller.

10 years agoMiscellaneous cleanup.
Heikki Linnakangas [Thu, 22 Jan 2015 17:44:59 +0000 (19:44 +0200)]
Miscellaneous cleanup.

* Mark functions used only in same file as static.
* Remove unused 'encoding' argument from msgtowstr and wstrtoms (all
  callers passed NULL).
* Silence remaining compiler warnings on 64-bit Windows about assigning
  size_t to int without cast.
* Remove superfluous FORMAT_INT4/FORMAT_UINT4 defines.
* Remove useless dollar_quote argument from findTag (it was always '$'), and
  add comment.
* Turn OID_NAME into a #define, to avoid a useless sprintf.
* Turn the mapFuncs array into structs, for clarity, and add comment.

10 years agoRemove "Cancel as FreeStmt" from docs, too.
Heikki Linnakangas [Thu, 22 Jan 2015 17:37:20 +0000 (19:37 +0200)]
Remove "Cancel as FreeStmt" from docs, too.

10 years agoCheck for PQsetSingleRowMode function in configure test.
Heikki Linnakangas [Thu, 22 Jan 2015 17:26:27 +0000 (19:26 +0200)]
Check for PQsetSingleRowMode function in configure test.

We require libpq 9.2 (or newer), where PQsetSingleRowMode was added. Check
for that in configure, so that you get a nice error message if you try
build with anything older.

10 years agoAdd expected output for running on a database initialized with C locale.
Heikki Linnakangas [Thu, 22 Jan 2015 13:42:38 +0000 (15:42 +0200)]
Add expected output for running on a database initialized with C locale.

10 years agoRemove default for Port attribute.
Heikki Linnakangas [Thu, 22 Jan 2015 13:27:17 +0000 (15:27 +0200)]
Remove default for Port attribute.

The default is to use whatever the libpq's default is. Makes no difference
under normal circumstances, as 5432 is the libpq default too, but it can
be changed if you make a custom build of libpq.

While at it, fix a typo in error message.

10 years agoDon't put default Servername and Port in the odbc.ini file.
Heikki Linnakangas [Thu, 22 Jan 2015 11:51:11 +0000 (13:51 +0200)]
Don't put default Servername and Port in the odbc.ini file.

This way, the driver will pick up the defaults from the libpq environment
variables, which makes more sense as we rely on those for the 'sampletables'
test case anyway.

10 years agoExpand colattributes test case a bit.
Heikki Linnakangas [Thu, 22 Jan 2015 07:17:04 +0000 (09:17 +0200)]
Expand colattributes test case a bit.

Test SQL_DESC_TYPE_NAME. There was an old report in the pgfoundry bug
tracker that it didn't work correctly with interval types, (#1010745, from
Farid Zidan on 2009-12-30), but it seems to work now.

10 years agoImprove print_diag() regression test helper to print all diagnostic records.
Heikki Linnakangas [Wed, 21 Jan 2015 20:04:33 +0000 (22:04 +0200)]
Improve print_diag() regression test helper to print all diagnostic records.

Previously, it only printed the first record. This is academic at the
moment, as the driver never reports more than one record AFAICS, but let's
be prepared.

10 years agoSilence regression failure of diagnostic test.
Heikki Linnakangas [Wed, 21 Jan 2015 20:01:16 +0000 (22:01 +0200)]
Silence regression failure of diagnostic test.

Now that I fixed the bug in the error handler, we're not losing the libpq's
message about lost connect anymore. It overwrites the previous FATAL error,
which is unfortunate, but it's been long-standing behaviour that if multiple
errors are returned as result for a query, only the last one is kept.

10 years agoFix references to uninitialized memory.
Heikki Linnakangas [Wed, 21 Jan 2015 17:59:54 +0000 (19:59 +0200)]
Fix references to uninitialized memory.

Some variables that were supposed to be set by sscanf() were accessed before
checking the return value of sscanf().

Spotted by valgrind on the result-conversions regression test.

10 years agoFix uninitialized memory access.
Heikki Linnakangas [Wed, 21 Jan 2015 17:49:19 +0000 (19:49 +0200)]
Fix uninitialized memory access.

Introduced by the big libpq patch. Before that, the keyset array was
allocated - and zeroed - in another function.

Spotted by Valgrind.

10 years agoFix reference to free'd plan name.
Heikki Linnakangas [Wed, 21 Jan 2015 17:00:10 +0000 (19:00 +0200)]
Fix reference to free'd plan name.

libpq_bind_and_exec fetched a pointer to the statement's plan name to a
local variable, but then called prepareParameters which free'd it, and
allocated a new plan name. The already-free'd name was then passed to
PQexecParams().

Spotted by valgrind

10 years agoFix read-after-free bug in error handler.
Heikki Linnakangas [Wed, 21 Jan 2015 16:44:52 +0000 (18:44 +0200)]
Fix read-after-free bug in error handler.

If a connection dies, CC_on_abort() calls PQfinish() which frees the error
message. handle_pgres_error better deal with the error message before
calling CC_on_abort().

Spotted by valgrind, on the "diagnostic" regression test.

10 years agoFix bug in determining the datatypes when binding.
Heikki Linnakangas [Wed, 21 Jan 2015 16:43:09 +0000 (18:43 +0200)]
Fix bug in determining the datatypes when binding.

In the big libpq patch, I accidentally removed the line where
current_exec_param was reset to 0. It's still required (which is a very
fiddly way to pass that value to ParseAndDescribeWithLibpq, but let's live
with it for now..)

10 years agoMinor cleanup.
Heikki Linnakangas [Wed, 21 Jan 2015 15:36:30 +0000 (17:36 +0200)]
Minor cleanup.

Remove local variable that was never used for anything real (just passed as
NULL to mylog/qlog). Replace with real query in the logs, and add some extra
logging.

10 years agoRemove unused arguments.
Heikki Linnakangas [Tue, 20 Jan 2015 22:00:49 +0000 (00:00 +0200)]
Remove unused arguments.

10 years agoMark functions that are not used outside convert.c as static. Remove dead code.
Heikki Linnakangas [Tue, 20 Jan 2015 21:05:25 +0000 (23:05 +0200)]
Mark functions that are not used outside convert.c as static. Remove dead code.

10 years agoAdd test cases for conversions from string to date/time/timestamps.
Heikki Linnakangas [Tue, 20 Jan 2015 20:57:39 +0000 (22:57 +0200)]
Add test cases for conversions from string to date/time/timestamps.

Also improve a comment.

10 years agoAdd a few tests for conversions between binary and text.
Heikki Linnakangas [Tue, 20 Jan 2015 11:18:20 +0000 (13:18 +0200)]
Add a few tests for conversions between binary and text.

Just noticed that it was not tested.

10 years agoRemove long-since obsolete FAR/NEAR decorations from pointers.
Heikki Linnakangas [Mon, 19 Jan 2015 21:29:59 +0000 (23:29 +0200)]
Remove long-since obsolete FAR/NEAR decorations from pointers.

We haven't supported a segmented memory model for ages, probably never.

10 years agoMisc cleanup, mostly dead code removal.
Heikki Linnakangas [Mon, 19 Jan 2015 20:54:00 +0000 (22:54 +0200)]
Misc cleanup, mostly dead code removal.

10 years agoDon't insist that Server, Username and Database options are set.
Heikki Linnakangas [Mon, 19 Jan 2015 20:42:01 +0000 (22:42 +0200)]
Don't insist that Server, Username and Database options are set.

Libpq will use sensible defaults if they are not set. In particular, it's
very useful that if you don't specify a Server, on Unix systems we will now
try to connect to a local installation via Unix domain sockets. That was
difficult to configure otherwise.

10 years agoRemove obsolete CancelAsFreeStmt option.
Heikki Linnakangas [Sun, 18 Jan 2015 20:13:02 +0000 (22:13 +0200)]
Remove obsolete CancelAsFreeStmt option.

It became obsolete when support for ODBC versions < 3.51 was removed, as
it never did anything in 3.51 version.

10 years agoChange URL to FAQ to point to new domain, odbc.postgresql.org.
Heikki Linnakangas [Sun, 18 Jan 2015 17:41:02 +0000 (19:41 +0200)]
Change URL to FAQ to point to new domain, odbc.postgresql.org.

10 years agoThe project's website was moved to odbc.postgresql.org.
Heikki Linnakangas [Fri, 16 Jan 2015 21:25:48 +0000 (23:25 +0200)]
The project's website was moved to odbc.postgresql.org.

Change links in the readmes accordingly.

10 years agoSend proper datatypes to the server when binding parameters.
Heikki Linnakangas [Fri, 16 Jan 2015 21:18:47 +0000 (23:18 +0200)]
Send proper datatypes to the server when binding parameters.

We used to always send 0 as the parameter type, which means that the server
should deduce the datatype from the context. That usually works well, but
we can do better. Sometimes there is ambiguity, like in "SELECT '555' > ?".
If the parameter is bound as a string, '6' would return true, but if it's
bound as an integer, it returns false.

When the application calls SQLBindParameter, it specifies the datatype, so
we should make use of that.

Add a test case for the "SELECT '555' > ?" case.

10 years agoMore fixes to building query with SQL_INTEGER and SQL_SMALLINT params.
Heikki Linnakangas [Fri, 16 Jan 2015 21:12:53 +0000 (23:12 +0200)]
More fixes to building query with SQL_INTEGER and SQL_SMALLINT params.

Jeremy Faith pointed out that the code still incorrectly accepted '-' as
a valid integer. But a bigger issue with negative numbers is that even a
valid negative integer can lead to bogus queries. Consider "SELECT 0-?",
where the parameter is -123. It was expanded to "SELECT 0--123".

To fix, don't accept '-' as a valid integer, forcing it to be quoted. And
if the value is negative, put parens around it, so that the previous
example becomes "SELECT 0-(-123)".

Add test cases for these issues. While we're at it, improve the output of
the param-conversions-test to be more readable.

10 years agoFix passing username to the server.
Heikki Linnakangas [Thu, 15 Jan 2015 16:41:01 +0000 (18:41 +0200)]
Fix passing username to the server.

In commit e85fbb2, as part of removing non-libpq code, I removed the code
that determined the username of the currently logged-in user, and send it
to the server during authentication. However, I accidentally also removed
the code that passed any explicitly-given username to the server. Oops.

10 years agoSilence compiler warnings on 64-bit Windows build.
Heikki Linnakangas [Thu, 15 Jan 2015 09:04:33 +0000 (11:04 +0200)]
Silence compiler warnings on 64-bit Windows build.

Be more careful about using size_t with variables that count offsets or
lengths of strings. In theory, a string longer than 2^31 could overflow an
int. I'm not sure if such a string can occur in practice, but let's be
tidy.

10 years agoFix Windows build.
Heikki Linnakangas [Thu, 15 Jan 2015 08:59:39 +0000 (10:59 +0200)]
Fix Windows build.

In the previous commit, I missed a reference to the autocommit_public
field that was inside an #ifdef _HANDLE_ENLIST_IN_DTC_ section.

10 years agoDon't reset autocommit attribute at SQLDriverConnect.
Heikki Linnakangas [Thu, 15 Jan 2015 08:30:52 +0000 (10:30 +0200)]
Don't reset autocommit attribute at SQLDriverConnect.

It should be possible to call SQLSetConnectAttr to disable autocommit
before establishing a connection. It was incorrectly reset when the
per-datasource options were read. To fix, move autocommit_public flag from
ConnInfo struct to Connection, like we've always done with login_timeout.

Also add a test case.

Reported by Ivan Zhang

10 years agoSilence compiler warnings about variables being used uninitialized.
Heikki Linnakangas [Wed, 14 Jan 2015 16:19:11 +0000 (18:19 +0200)]
Silence compiler warnings about variables being used uninitialized.

10 years agoFix various quoting issues in sending query parameters to server.
Heikki Linnakangas [Tue, 13 Jan 2015 21:29:48 +0000 (23:29 +0200)]
Fix various quoting issues in sending query parameters to server.

The code used to just assume that if the parameter's SQL type is SQL_INTEGER
or SQL_SMALLINT, it doesn't need quoting. While that's true for valid
integers values, there were no safeguards that the bound string is actually
valid input. The server will just throw an error on invalid input, but we
need to quote it correctly to send it to the server in the first place.
For example, if the string "123, 'inject'" is bound to an SQL_INTEGER param,
we need to quote it or the server will interpret it as part of the query.

Also add a test case for this.

Reported by Jeremy Faith.

10 years agoMinor cleanup of the way binary parameter format is chosen.
Heikki Linnakangas [Tue, 13 Jan 2015 19:48:29 +0000 (21:48 +0200)]
Minor cleanup of the way binary parameter format is chosen.

Rather than have the caller guess whether ResolveOneParam chooses to use
the binary format, add an explicit return value for it.

10 years agoFix building with MSDTC=no.
Heikki Linnakangas [Tue, 6 Jan 2015 09:36:57 +0000 (11:36 +0200)]
Fix building with MSDTC=no.

10 years agoSilence compiler warning about unused variable.
Heikki Linnakangas [Tue, 6 Jan 2015 08:55:27 +0000 (10:55 +0200)]
Silence compiler warning about unused variable.

10 years agoUse libpq for everything.
Heikki Linnakangas [Wed, 31 Dec 2014 12:49:20 +0000 (14:49 +0200)]
Use libpq for everything.

Instead of speaking the frontend/backend protocol directly, use libpq's
functions for executing queries. This makes it libpq a hard dependency, but
removes direct dependencies to SSL and SSPI, and a lot of related code.

10 years agoAdd a test case for error handling.
Heikki Linnakangas [Mon, 22 Dec 2014 18:19:45 +0000 (20:19 +0200)]
Add a test case for error handling.

The current behavior isn't actually quite correct with some configurations,
but seems better to add the regression test now anyway, even though the
errors_2.out basically memorizes the bogus behavior. It should be removed
when the bug is fixed.

10 years agoRemove spurious semicolon from the end of default ExtraSysTablePrefixes.
Heikki Linnakangas [Mon, 22 Dec 2014 16:47:25 +0000 (18:47 +0200)]
Remove spurious semicolon from the end of default ExtraSysTablePrefixes.

The code that forms a new connection string from current settings doesn't
escape it correctly, so that the connection string looks like
"...;C2=dd_;;CX=...". Of course, the code that forms the connection string
should be fixed, but that's a much bigger job.

10 years agoOn second thoughts, treat a bookmark as a 32-bit integer, not SQLULEN.
Heikki Linnakangas [Fri, 5 Dec 2014 22:52:37 +0000 (00:52 +0200)]
On second thoughts, treat a bookmark as a 32-bit integer, not SQLULEN.

This seems more reliable.

Add a test case for SQLBulkOperations(SQL_FETCH_BY_BOOKMARK), although it's
disabled because it doesn't seem to work correctly (fetches wrong rows).
I don't have the energy to actually fix that now.

10 years agoFix confusion on whether a bookmark is 4 or 8 bytes long.
Heikki Linnakangas [Fri, 5 Dec 2014 21:16:03 +0000 (23:16 +0200)]
Fix confusion on whether a bookmark is 4 or 8 bytes long.

In some places, we used SQLULEN to refer to a bookmark, and in others,
UInt4. But SQLULEN is 8 bytes long on some platforms, which caused all
kinds of strange issues.

Also add a test case for SQLBulkOperations. This revealed the bug.

10 years agoAdd test for fetching deleted/updated rows in an updateable cursor.
Heikki Linnakangas [Fri, 5 Dec 2014 19:17:21 +0000 (21:17 +0200)]
Add test for fetching deleted/updated rows in an updateable cursor.

10 years agoAdd test case for SQLSetCursorName and SQLGetCursorName.
Heikki Linnakangas [Fri, 5 Dec 2014 18:45:36 +0000 (20:45 +0200)]
Add test case for SQLSetCursorName and SQLGetCursorName.

The test case also contains tests for UPDATE ... WHERE CURRENT OF, but
it's disabled because the driver doesn't actually support it. I wrote the
test before I realized that, and didn't want to throw it away, in case we
ever want to add support for it.

It also contains an #ifdef'd out test for cursor names that contain quotes.
The driver doesn't handle that correctly, but I didn't want to fix it right
now. No sane application does that anyway.

10 years agoEnhance the error-rollback test case.
Heikki Linnakangas [Fri, 5 Dec 2014 17:50:19 +0000 (19:50 +0200)]
Enhance the error-rollback test case.

This covers some cases that I found to contain bugs in a patch that I'm
working on. Current master is correct, but extra coverage is good.

10 years agoModify test case to call SQLPutData twice.
Heikki Linnakangas [Tue, 2 Dec 2014 16:55:45 +0000 (18:55 +0200)]
Modify test case to call SQLPutData twice.

For increased test coverage.

10 years agoFix SQL_DESC_OCTET_LENGTH for 'unknown' type columns.
Heikki Linnakangas [Tue, 2 Dec 2014 14:03:36 +0000 (16:03 +0200)]
Fix SQL_DESC_OCTET_LENGTH for 'unknown' type columns.

This makes 'unknown' to behave the same as 'varchar' without typmod.

Also add a regression test for it.

This addresses the bug reported originally on the pgsql-bugs mailing list as
bug #11767, by Keyur Govande.

10 years agoAdd test cases for:
Heikki Linnakangas [Tue, 2 Dec 2014 11:15:57 +0000 (13:15 +0200)]
Add test cases for:

* getting a bookmark with SQLBindCol,
* unbinding columns with SQLBindCol and SQLFreeStmt(SQL_UNBIND), and
* the procedure call "{ CALL ... }", and date, time, and timestamp escape
  syntaxes.

10 years agoMisc cleanup.
Heikki Linnakangas [Tue, 2 Dec 2014 11:00:28 +0000 (13:00 +0200)]
Misc cleanup.

Fix some misc issues pointed out by clang's static analyzer, scan-build.
Mostly dead assignments.

10 years agoAdd tests for Nan, Infinity, -Infinity float values.
Heikki Linnakangas [Fri, 28 Nov 2014 14:18:54 +0000 (16:18 +0200)]
Add tests for Nan, Infinity, -Infinity float values.

10 years agoSilence compiler warning about unused variable.
Heikki Linnakangas [Fri, 28 Nov 2014 13:41:54 +0000 (15:41 +0200)]
Silence compiler warning about unused variable.

10 years agoodbc.ini and odbcinst.ini are now generated, add them to .gitignore
Heikki Linnakangas [Fri, 28 Nov 2014 06:32:51 +0000 (08:32 +0200)]
odbc.ini and odbcinst.ini are now generated, add them to .gitignore

Michael Paquier

10 years agoAdd a Makefile target to run the tests with different config options.
Heikki Linnakangas [Thu, 27 Nov 2014 13:38:51 +0000 (15:38 +0200)]
Add a Makefile target to run the tests with different config options.

10 years agoMake the regression test output independent of some settings.
Heikki Linnakangas [Thu, 27 Nov 2014 13:32:09 +0000 (15:32 +0200)]
Make the regression test output independent of some settings.

Namely, UseServerSidePrepare, UseDeclareFetch and Protocol.

10 years agoRun the odbc[inst].ini generation script in a more Makefile fashion.
Heikki Linnakangas [Thu, 27 Nov 2014 12:32:32 +0000 (14:32 +0200)]
Run the odbc[inst].ini generation script in a more Makefile fashion.

The expected output didn't match what I got on my laptop. Not sure why,
or if it worked for anyone, but in any case it's more straightforward to
let make run the script directly, rather than through pg_regress.

In the passing, allow passing extra command line options to odbcini-gen.sh,
which will be appended to the generated odbc.ini. This makes it handy to
run the regressions with extra non-default options.

10 years agoAdd more test cases.
Heikki Linnakangas [Wed, 26 Nov 2014 12:50:45 +0000 (14:50 +0200)]
Add more test cases.

This adds coverage for SQLConnect, SQLRowCount, and moving a cursor with
SQLFetchScroll, and for bookmarks.

10 years agoRemove some remnants of old protocol support
Heikki Linnakangas [Wed, 26 Nov 2014 11:04:12 +0000 (13:04 +0200)]
Remove some remnants of old protocol support

10 years agoAnother round of -Wformat fixes.
Heikki Linnakangas [Thu, 13 Nov 2014 21:47:37 +0000 (23:47 +0200)]
Another round of -Wformat fixes.

10 years agoFix test case for big-endian systems.
Heikki Linnakangas [Thu, 13 Nov 2014 20:29:12 +0000 (22:29 +0200)]
Fix test case for big-endian systems.

10 years agoSilence more compiler warnings in -Wformat mode, in regression test.
Heikki Linnakangas [Thu, 13 Nov 2014 19:44:27 +0000 (21:44 +0200)]
Silence more compiler warnings in -Wformat mode, in regression test.

10 years agoSilence compiler warnings in -Wformat mode.
Heikki Linnakangas [Thu, 13 Nov 2014 18:46:38 +0000 (20:46 +0200)]
Silence compiler warnings in -Wformat mode.

Passing SQLINTEGER/SQLUINTEGER sprintf "%d", "%ld" modifiers gave a warning
on some systems (at least on my 32-bit Debian system) .

10 years agoAllow building test suite in a different place other than the source code is.
Hiroshi Inoue [Tue, 21 Oct 2014 07:57:28 +0000 (16:57 +0900)]
Allow building test suite in a different place other than the source code is.
Change the test suite so that it works not only with unixODBC but also with iodbc.

10 years agoAvoid buffer overrun by makeKeepaliveConnectString().
Hiroshi Inoue [Thu, 13 Nov 2014 07:43:09 +0000 (16:43 +0900)]
Avoid buffer overrun by makeKeepaliveConnectString().

10 years agoFix Windows compilation with libpq enabled, but without SSPI
Heikki Linnakangas [Mon, 3 Nov 2014 16:25:48 +0000 (18:25 +0200)]
Fix Windows compilation with libpq enabled, but without SSPI

GetUserNameEx function requires secur32.dll. It is now referenced in the
code, regardless of SSPI, so we need to link with secur32.dll.

10 years agoAdd test case for large objects.
Heikki Linnakangas [Mon, 3 Nov 2014 13:06:25 +0000 (15:06 +0200)]
Add test case for large objects.

10 years agoAdd test case.
Heikki Linnakangas [Mon, 3 Nov 2014 09:05:01 +0000 (11:05 +0200)]
Add test case.

This tests a codepath in QR_next_tuple that had no coverage before.

10 years agoAvoid conflicts of external symbols other than ODBC APis.
Hiroshi Inoue [Thu, 30 Oct 2014 03:40:13 +0000 (12:40 +0900)]
Avoid conflicts of external symbols other than ODBC APis.

10 years agoChange *ANSI* in the title of 32-bit Unicode driver setup dialog to *Unicode*.
Hiroshi Inoue [Sun, 2 Nov 2014 05:00:27 +0000 (14:00 +0900)]
Change *ANSI* in the title of 32-bit Unicode driver setup dialog to *Unicode*.

10 years agoRemove dead code
Heikki Linnakangas [Fri, 31 Oct 2014 17:53:24 +0000 (19:53 +0200)]
Remove dead code

10 years agoRemove option to disable geqo.
Heikki Linnakangas [Wed, 29 Oct 2014 18:00:59 +0000 (20:00 +0200)]
Remove option to disable geqo.

You can use the generic ConnSettings option for that.

10 years agoMinor code simplification.
Heikki Linnakangas [Thu, 30 Oct 2014 07:27:54 +0000 (09:27 +0200)]
Minor code simplification.

Any compiler worth its salt will turn "strlen(constant)" into a constant,
so let's get rid of the fancy logic to precalculate those.

10 years agoFix max identifier length stuff.
Heikki Linnakangas [Thu, 30 Oct 2014 20:43:56 +0000 (22:43 +0200)]
Fix max identifier length stuff.

CC_get_max_idlen function didn't work correctly. It sent the "show
identifier_length" query to the backend, but assumed that the value comes
back in the command tag. It doesnt; the command tag is always "SHOW".

We fell back to the compiled in NAMEDATALEN_V73 default. But that's
off-by-one; the actual max identifier length is NAMEDATALEN - 1.

10 years agoRemove support for receiving 'P' or 'B' responses from server.
Heikki Linnakangas [Wed, 29 Oct 2014 20:39:34 +0000 (22:39 +0200)]
Remove support for receiving 'P' or 'B' responses from server.

Server versions >= 7.4 don't send these anymore.