Commit Graph

2633 Commits

Author SHA1 Message Date
Vadim Zeitlin
d28d6827a9 Fix a number of variable shadowing warnings from MSVS
Don't redefine the same variables in a couple of tests.

In other places, use artificially different names to avoid clashes with
the existing variables in outer scope.

No real changes.
2021-03-12 02:18:02 +01:00
Vadim Zeitlin
182bc6b6fb Fix harmless warning about size_t to int cast
The begin_ value here is never going to be out of int range, so just
cast it explicitly to avoid a warning about doing it implicitly.
2021-03-12 02:17:35 +01:00
Vadim Zeitlin
ae5d5c4460 Fix harmless unused variable warning in PostgreSQL test
Just don't name the exception variable.
2021-03-12 02:16:45 +01:00
George Rhoten
6b6a2b437b Fix Catch build for macOS on ARM
Cherry picked from upstream bad3c930493d08dd7cca2af57cf355d9b7cddb21

Closes #852.
2021-02-23 12:47:22 +01:00
nobodyxu
d867b0c631 Use ELF visibility
Only make symbols that are part of the public API visible.

Closes #848.
2021-01-15 13:46:27 +01:00
Vadim Zeitlin
6c3f1f7f5d Merge branch 'travis-allow-oracle-fail'
Give up and just ignore spurious errors in Oracle Travis CI builds, it
doesn't seem possible to actually fix them.

See #847.
2020-12-27 13:51:30 +01:00
Vadim Zeitlin
931b8fc728 Document SOCI_ASAN and SOCI_LTO build options
Try to keep all CMake options documented.
2020-12-27 13:51:02 +01:00
Vadim Zeitlin
0c4b568ef7 Merge branch 'EnableLTO' of https://github.com/NobodyXu/soci
Add SOCI_LTO CMake build option to enable LTO: this results in
noticeable library size reduction if nothing else.

See #846.
2020-12-27 13:46:55 +01:00
Vadim Zeitlin
7bf5edf91a Ignore failures in Travis CI Oracle build
Spurious ORA-12520 errors happen all the time in this build.

See #801.
2020-12-27 13:30:32 +01:00
Vadim Zeitlin
25fee967cb Fix harmless warnings in Travis CI config file
Don't use "sudo:" key which is ignored now, but do use "os: linux" which
is implicit, but better made explicit.

Also use "jobs" instead of the deprecated "matrix" key name.

No real changes.
2020-12-27 13:29:30 +01:00
nobodyxu
4f6bf85f64 Restore global cmake version; Add separate version check for LTO 2020-12-27 22:58:11 +11:00
NobodyXu
9a1e994e63 Fix grammer of the status message
Co-authored-by: VZ <vz-github@zeitlins.org>
2020-12-27 22:47:51 +11:00
nobodyxu
d7e8629120 Set cmake option SOCI_LTO to off by default
so that LTO won't be used in debug build
2020-12-27 22:46:00 +11:00
nobodyxu
cab510f2e4 Fix confusing status msg when lto is not supported 2020-12-27 21:26:02 +11:00
nobodyxu
d4452345ae Add cmake config for check and enable lto support
It also checks for clang and lld. In case both are present,
'-fuse-ld=lld' is appended to linker flags.
2020-12-27 20:57:25 +11:00
nobodyxu
a88341ef96 Bump minimal cmake version to 3.9 for CheckIPOSupported 2020-12-27 20:39:24 +11:00
Mariana Meireles
0e69973d64 Use fully qualified type for session in PostgreSQL test
This is similar to 88e7249f (Fix PostgreSQL tests build under macOS,
2020-10-30).

Closes #841.
2020-12-08 15:59:24 +01:00
Christian Kröhnert
7ee01afc4c Fix use of quoted identifiers with colons in PostgreSQL queries
This was broken by 99d26063 (Fix handling of identifiers with colons in
PostgreSQL backend, 2020-01-27), see #782.

Fix this and add a test checking for the use of such identifiers.

Closes #840.
2020-12-03 16:15:57 +01:00
Vadim Zeitlin
4fc02b8427 Merge branch 'psql-odbc-leaks'
Fix spurious failures of ODBC PostgreSQL tests on Travis CI.

See #838.
2020-11-29 15:23:34 +01:00
Vadim Zeitlin
422fa050e3 Install debug symbols for libc6 and odbc-postgresql
This should help with more informative stack traces in case of problems
such as ASAN reports.
2020-11-29 15:16:58 +01:00
Vadim Zeitlin
277be5ffb9 Use Xenial version of odbc-postgresql package
Travis hosts use PostgreSQL PPA which is problematic for a few reasons:

1. We don't actually test in the same environment as most SOCI users,
   who would just use the standard Ubuntu repositories and not this PPA.
2. The environment is not even stable, e.g. recently the version of
   psqlodbc has changed from 12 to 13 in Travis builds, breaking them
   due to new leak reports from ASAN.
3. We don't have debug symbols for these packages as the PPA doesn't
   provide them and the ones from Ubuntu repositories don't match. This
   prevents us from even creating precise suppressions for ASAN.

Solve all these problems at once by just sticking to the stock Xenial
version, which doesn't even trigger any leak reports, so there is
nothing to suppress any more and the changes of 457ec97e (Suppress
reports about memory leaks in PostgreSQL ODBC test, 2020-03-29) can be
reverted.
2020-11-29 15:16:58 +01:00
Vadim Zeitlin
072baaf345 Remove hard TAB in a Travis CI script
No real changes.
2020-11-29 15:16:57 +01:00
Vadim Zeitlin
ce6f74c906 Only install Valgrind on Travis for the build which needs it
It seems useless to always download and install Valgrind for all builds
when we only need it for a single one of them.
2020-11-29 15:16:57 +01:00
Vadim Zeitlin
d4d50d6500 Don't show interactive ODBC dialogs when reconnecting
Such dialogs can be unexpected and confusing, as reconnection can happen
automatically, and not in a response to a user action.

Implement this by adding a new "reconnect" option and add is_option_on()
helper to connection_parameters to facilitate using it.
2020-11-04 01:30:05 +01:00
Vadim Zeitlin
96c7ec18b4 Don't force CR LF normalization in .gitattributes
Nowadays all systems can deal with LF-only files (perhaps with some rare
exceptions, not affecting SOCI) and there is no need to force
normalization in the repository itself -- people who need it can always
enable it in their global Git config.
2020-11-04 01:27:52 +01:00
Vadim Zeitlin
fc29f3b504 Fix version of Markdown linter used on Circle CI
The latest version seems to have problems and reports

/usr/local/lib/node_modules/markdownlint-cli/markdownlint.js:52
    } catch {
            ^
SyntaxError: Unexpected token {

when installing it, so revert to the last known working one.

Co-authored-by: Mateusz Loskot <mateusz@loskot.net>
2020-11-01 01:27:46 +01:00
Noah Shutty
88e7249f4c Fix PostgreSQL tests build under macOS
Use fully qualified "soci::session" type name to avoid conflicts with
"session" struct declared in sys/proc.h under macOS.

This is a recurrent problem (see #605 for a previous example of it)
which should probably be solved by removing "using namespace soci" from
the test to prevent it from happening again.

Closes #832.
2020-10-31 13:36:53 +01:00
Vadim Zeitlin
988493ac76 Use v4.0.1 tag in the README badges instead of 4.0.0 v4.0.1 2020-10-19 16:58:52 +02:00
Vadim Zeitlin
17238d86c1 Add change log for v4.0.1 release 2020-10-19 16:08:42 +02:00
Vadim Zeitlin
1a02665e21 Update version to 4.0.1
Prepare for v4.0.1 release.
2020-10-19 16:08:28 +02:00
Vadim Zeitlin
c6aa3306c6 Add contributors since 4.0.0 to the AUTHORS file
Also add a "maintainer" section.
2020-10-19 16:04:36 +02:00
Vadim Zeitlin
0ccbd9224c Add myself (Vadim Zeitlin) as maintainer to the README 2020-10-19 15:58:18 +02:00
Vadim Zeitlin
ef5e1227e1 Always initialize leave postgresql_session_backend::conn_
This wasn't done before in case of connection failure in connect(), so
PQfinish() could be called with a dangling pointer from clean_up(),
called from the dtor, later.

Just initialize conn_ in ctor to fix this.

Closes #822.
2020-10-19 15:33:01 +02:00
Vadim Zeitlin
81c7a391e2 Merge branch 'conn-keep-alive'
Make it easier to implement trivial connection keep alive mechanism.

See #828.
2020-10-19 15:23:46 +02:00
XiaoGuang Zeng
8f6e56bc58 Define search_paths() in dynamic_backends namespace
The function search_paths() was accidentally defined in the global
namespace instead of "dynamic_backends" one, as it was supposed to,
meaning that dynamic_backends::search_paths() was not defined at all and
attempts to use it resulted in link errors.

Closes #829.
2020-10-13 13:27:27 +02:00
Vadim Zeitlin
0d6ab166a1 Skip category check for unknown ODBC errors in "Reconnect" test
At least PostgreSQL ODBC driver just returns "HY000", i.e. "General
error" in case of connection loss, which clearly can't be always mapped
to soci_error::connection_error, so we need to take into account that
get_error_category() doesn't always return the expected value, at least
with the ODBC backend.
2020-10-13 01:45:24 +02:00
Vadim Zeitlin
0d014a9e7b Recognize some well-known SQLSTATE values in ODBC error class
Try to return something meaningful from get_error_category() for a few
SQLSTATE values that seem to be reasonable standard and map well to the
existing error_category enum values.

This is far from being exhaustive, but is still better than nothing and
allows "Reconnect" unit test to pass when using MS SQL ODBC driver.
2020-10-13 01:39:13 +02:00
Vadim Zeitlin
43c133be13 Add session::is_connected() function
This function can be used to check if the connection to the server is
still available (and then, perhaps, call reconnect(), if it isn't).

Implement it for all backends using native API (except for SQLite for
which it always returns true).
2020-10-13 01:05:51 +02:00
Vadim Zeitlin
515a6505c0 Recognize more Oracle errors as corresponding to connection loss
Set error category to connection_error for ORA-03113 which occurs if the
server is not running any longer, ORA-03114 which happens in case of a
network problem and also for ORA-12541 which seems similar to ORA-12162,
which was already mapped to connection_error.

This allow the manual "Reconnect" test to pass with Oracle backend.
2020-10-13 01:02:30 +02:00
Vadim Zeitlin
498bcedfa5 Add test for using failover callback
This test is disabled by default, but can be run explicitly to check
that we can automatically recover from connection loss when using a
backend supporting this (currently only Oracle and PostgreSQL, and only
tested with the latter).
2020-10-12 23:26:39 +02:00
Vadim Zeitlin
605db30f6c Reuse correct connection parameters for PostgreSQL failover
If the failover callback doesn't provide the connection string to use,
default to the originally used one instead of using empty connection
string which is almost certainly not what we want.

Note that this requires storing the original connection parameters in
postgresql_session_backend, as we don't have access to the ones stored
in the session object and it seems wrong to add backlinks from the
backend to the session object.

Closes #793.
2020-10-12 23:26:39 +02:00
Vadim Zeitlin
339a5a3a1d Add test of manually reconnecting after connection loss
This can't be tested automatically, as we don't really have any way to
break the connection programmatically, but we can still have a test for
this relying on breaking (and then restoring) the connection manually.
2020-10-12 23:26:39 +02:00
Vadim Zeitlin
a6259e917b Return more precise error on connection loss with PostgreSQL
Use SQL state which is mapped to "connection_error" category when the
connection is lost.
2020-10-12 23:26:39 +02:00
Vadim Zeitlin
276a54d4d1 Add private auto_statement RAII helper
When working directly with concrete statement_backend classes, their
alloc() and clean_up() methods must be called directly, which suffers
from all the usual problems, especially in presence of exceptions.

Avoid them by using the new auto_statement class which takes care of
calling these methods in its ctor/dtor instead.

An alternative could be to make the concrete classes themselves use
RAII, but this would be more error prone (e.g. there would be a risk of
alloc() being called twice) and require many more changes, so, at least
for now, use this more lightweight solution.

No real changes.
2020-10-12 23:25:43 +02:00
Vadim Zeitlin
63bb4f5a6f Define SOCI_NOEXCEPT and use it instead of deprecated "throw()"
Add another C++11-like macro (similar to SOCI_OVERRIDE) which can also
be used in C++98 code.

The main advantage is that new code can now use SOCI_NOEXCEPT instead of
the old "throw()" and it will be possible to simply replace it with
"noexcept" after dropping C++98 support.
2020-10-12 22:03:56 +02:00
Vadim Zeitlin
2b1aea601e Merge branch 'disable-werror-by-default'
Don't use -Werror when building SOCI by default (but still use it in the
CI builds).

See #825.
2020-10-11 01:03:51 +02:00
Vadim Zeitlin
372e919a45 Debug expect script used for Firebird configuration
Try to understand why setting the SYSDBA password suddenly doesn't work
any longer.
2020-10-11 00:44:12 +02:00
Vadim Zeitlin
53a1a18ccc Enable -Werror for Travis CI builds too
This needs to be done explicitly now, since the changes of c6ed5f70
(Don't use -Werror unconditionally when building SOCI, 2020-06-05).
2020-10-10 23:36:44 +02:00
Vadim Zeitlin
84fed32d0b Refactor Travis CI build scripts to reuse common options
Define SOCI_DEFAULT_CMAKE_OPTIONS once and use it in almost all builds
instead of repeating the same options many times everywhere.

For the remaining build (Valgrind) still reuse a couple of options which
it has in common with the other ones.
2020-10-10 23:36:40 +02:00
Vadim Zeitlin
f14c97fecf Enable -Werror for AppVeyor builds
This needs to be done explicit since the changes of c6ed5f70 (Don't use
-Werror unconditionally when building SOCI, 2020-06-05).
2020-10-10 23:25:07 +02:00