Commit Graph

152 Commits

Author SHA1 Message Date
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
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
1a02665e21 Update version to 4.0.1
Prepare for v4.0.1 release.
2020-10-19 16:08:28 +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
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
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
William Blough
b208b22456 Ignore alignment warnings/errors in Firebird backend
Suppress gcc -Wcast-align which are harmless in this context.

Closes https://github.com/SOCI/soci/pull/824
2020-10-10 23:01:43 +02:00
Vadim Zeitlin
4e3d9e99c7 Extract and extend PostgreSQL string to int conversion helpers
Generalize the use of strtoll() instead of sscanf() for the conversion
to unsigned integer types too and extend the code doing it to a couple
of new simple reusable functions that can now be used in all backends.

Keep PostgreSQL idiosyncratic conversion of "f" and "t" to integers to
avoid changing the existing behaviour, even if it's not really clear
whether this is needed for all types.
2020-04-05 00:55:38 +02:00
Alexander Kulikov
b32d480e0a Fix using const std::vector<boost::optional<>> as query arguments
Remove apparently unused conversion_use_type::convert_from_base() which
prevents this class from being used with const references.

Closes https://github.com/SOCI/soci/pull/797
2020-04-04 23:23:14 +02:00
Ross Marwood
99a33e0f45 Changed Windows #ifdefs from _MSC_VER (VC++ specific) to _WIN32 (Windows API in general) 2020-03-22 18:43:33 +02:00
Ross Marwood
2041df3774 Changed issue 723 bugfix to use timegm(), reverted Oracle tests (which no longer need to be modified) and substituted NULL for nullptr in issue 723 test for earlier C++ compaticbility 2020-03-22 17:42:50 +02:00
Ross Marwood
0c91ff9aa0 Fix for soci issue 723 2020-03-20 15:50:36 +03:00
Vadim Zeitlin
ca7e0fcd41 Detect mismatching SOCI_HAVE_CXX11 at compile-time
This is better than debugging unexpected calls to terminate() at
run-time, see #795.
2020-03-09 15:58:22 +01:00
Mateusz Łoskot
02a5cae2c5 Rename SOCI_CXX_C11 to SOCI_CXX11 (#757)
This change was discussed and suggested in this thread of comments:
https://github.com/SOCI/soci/pull/755#discussion_r329550806
2019-09-30 20:58:57 +02:00
Mohan Sella
9d0caa13ca Use 64-bit integer for next sequence and last insert ID values (#720) 2019-06-07 15:00:07 +02:00
Andrei Lebedev
2660d5f938 Deduce reference in boost::fusion::for_each (#728)
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
2019-05-08 12:10:28 +02:00
myd7349
f8d036e719 No define snprintf for VS2015 and above (#717) 2019-03-11 12:00:20 +01:00
Vadim Zeitlin
a7ec4a618f Use SQL_LONGVARCHAR to really fix long strings in ODBC backend
Using SQL_SS_LENGTH_UNLIMITED for size seems to only work with SQL
Native Client ODBC drivers v11+, but not with the old, but still used,
SQL Server ODBC driver, while just using SQL_LONGVARCHAR works with both
of them and is even simpler.

Really closes #383.
2018-09-20 19:13:58 +02:00
Mateusz Łoskot
5c8b799496 Disable -Wstrict-aliasing diagnostic for GCC or clang only
Refines #663
2018-07-01 22:39:34 +02:00
Heiko Rabe
424d258438 Support DB2 driver not compliant to ODBC spec (#663)
* Add explicit option for generating ODBC DB2 tests
- can be activated by -DWITH_ODBC_TEST_DB2
- needs proper connect string via -DSOCI_ODBC_TEST_DB2_CONNSTR
* Add DB2 as database product for ODBC
* Add support for not ODBC spec compliant ODBC driver
IBM DB2 driver is not compliant to ODBC spec for indicators in 64bit
SQLLEN is still defined 32bit (int) but spec requires 64bit (long)
* Disable GCC warning as error for -Wstrict-aliasing
The casts are necessary to handle not compliant drivers in 64bit.
* Rename noncompliant helper methods
2018-06-27 14:48:27 +02:00
Mateusz Loskot
edb87abd8e Remove use of std::unary_function
Deprecated in C++11 and removed in C++17

Fixes #646
2018-06-08 00:06:56 +02:00
Alex Volanis
ba0fbf8690 Issue #617: CMAKE_BUILD_TYPE=RelWithDebInfo build fails with "may be used uninitialized" error
This simple change eliminates the problem and unit tests
continue to pass as before.
2018-05-14 15:17:14 -04:00
Mateusz Loskot
64607d7778 Merge branch 'master' into master 2018-05-07 22:51:35 +02:00
Mateusz Loskot
030f65b18a Merge branch 'master' into master 2018-02-27 22:43:27 +01:00
Adesmier
c05f9131ab Minor fix, in use_type last constructor, const was set to false instead of true
---
Cherry-pick from https://github.com/SOCI/soci/pull/215
2018-02-27 22:22:46 +01:00
Vadim Zeitlin
ace388bce7 Add logger class to allow customizing SOCI logging operations.
No big changes yet, but it is now possible to use a custom logger object which
may do something else than just write the query string passed to it to a
stream.

The old behaviour is preserved by using the standard SOCI logger by default
which does write the query to the stream.
2018-02-24 15:10:35 +01:00
Lemme
e935075bd5 Fixing uninitialized gotData_ in soci::statement #609 2018-01-04 12:02:36 +01:00
Mateusz Loskot
05ab0bcf6d Add SOCI_OVERRIDE macro as conditional C++11 override specifier
MSVC++ 1900+ always compile with C++11 mode enabled, so it should be
safe to selectively enable 'override'specifier for internal use.

It does not enable all C++11 features for SOCI and we still compile
with C++11 compilation mode SOCI_CXX_C11=OFF by default.

Refactoring performed with clang-tidy-4.0:

 cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSOCI_CXX_C11=ON ..
 run-clang-tidy.py -clang-tidy-binary -header-filter='.*' \
                   -checks='-*,modernize-use-modernize' -fix
2017-09-24 23:05:06 +02:00
Heiko Rabe
51d058f04c Repair VC8 compile of test applications (#593)
Fix compilation issues for Visual C++ 8.0 (VS2005)

* Add _WIN32_WINNT minimal required version to soci-platform.h to fix windows.h issue related to use of Add/RemoveVectoredExceptionHandler.
* Override SECTION macro since default macro parameter (3 required / 2 given or 2 required / 1 given) do not expand and lead to syntax error.
2017-09-23 12:57:38 +02:00
Vadim Zeitlin
11a8982d5b Add a helper function for copying strings in ODBC backend too
This will be reused for XML and CLOB types soon.
2017-09-15 01:44:34 +02:00
Vadim Zeitlin
556f5d3369 Add exchange_type_traits<> specializations for XML and CLOB
There is no reason to not have them and this allows to write slightly
shorter and safer code using exchange_type_cast<> instead of "raw"
static_cast<>.
2017-09-15 01:44:34 +02:00
Vadim Zeitlin
f1243acdfc Add helper function for copying string to PostgreSQL backend
This helper is trivial but it's still better not to repeat these 2 lines
4 times.
2017-09-15 01:44:34 +02:00
Vadim Zeitlin
9943459f40 Add support for XML type to Firebird backend too
There is no real XML support in Firebird, so handle it in the same way
as CLOB -- this is the best that can be done with this database anyhow
and is much better than not supporting it at all.
2017-09-13 15:09:35 +02:00
Vadim Zeitlin
059faf5d96 Add CLOB support to Firebird backend
Reuse the existing BLOB support, however we now need to allocate a BLOB
inside firebird_standard_use_type_backend objects as, unlike when using
soci::blob objects, we don't have any way to associate backend-specific
data with the parameter otherwise.

This difference between CLOB and BLOB support is not ideal, but there
doesn't seem to be any way to avoid it.
2017-09-13 15:09:35 +02:00
Vadim Zeitlin
4b451971a0 Avoid using overloaded virtual methods in vector type backends
This is mostly done in order to allow SOCI headers to compile cleanly
with -Woverloaded-virtual (or corresponding MSVC warning C4266) in
effect, but it also allows to turn the same warning on for building SOCI
itself, which can be useful.

Closes #573.
2017-09-03 21:53:02 +02:00
Alex Ott
23d2f2593d fix some of warnings from fresh Coverity report 2017-09-03 14:03:42 +02:00
Mateusz Loskot
25eb5bdb36 Initialize indISCHolder_ member in firebird_into/use_type_backend classes 2017-09-01 22:29:28 +02:00
Maciej Cencora
9d82ee8e7d Remove unnecessary namespace qualification 2017-08-22 15:16:31 +02:00
Maciej Cencora
e4ab099dff Fix undefined sanitizer warnings
Access to member that was not initialized yet is undefined behavior.
2017-08-22 13:24:16 +02:00
Maciej Sobczak
e7db59c74b Merge pull request #557 from msobczak/master
Lazy initialization of the temporary LOB objects for Oracle.
Due to no comments raised for this PR, I'm merging it as is.
2017-07-30 22:47:15 +02:00
Сергей Сергеевич Журавлев
43229ecfe5 Fix types for SQLite3 backend 2017-07-25 07:53:55 +03:00
Сергей Сергеевич Журавлев
ed25eea2cd Fix session::get_table_names() for sqlite backend 2017-07-25 07:53:14 +03:00
Vadim Zeitlin
a1e07e389c Avoid duplicate code for parsing dates in different backends
SQLite, MySQL and PostgreSQL backends used the same but slightly
different code for parsing the contents of a buffer into std::tm struct.

Replace all these different versions with a single version, copied from
the PostgreSQL variant, which seems like the most complete, in the
common code.

Update MySQL-specific test to not expect parsing a string containing
time without date to yield year 2000, this didn't make any sense at all
and PostgreSQL default of year 1900 makes at least slightly more sense.
2017-07-20 15:38:42 +02:00
Maciej Sobczak
638b89d1fd Merge remote-tracking branch 'upstream/master' 2017-07-20 00:53:53 +02:00
Maciej Sobczak
138b29e431 Lazy initialization of the temporary LOB objects for Oracle. 2017-07-20 00:47:59 +02:00
Vadim Zeitlin
d91c2228ce Add get_dummy_from_{table,clause}() methods
These functions are helpful to allow writing queries not using any
tables portably, i.e. they basically abstract the difference between
"select ... from dual" in Oracle and just "select ..." in almost all the
other backends.
2017-07-19 02:27:13 +02:00
Vadim Zeitlin
78bedc931f Consistently check for connection in the session object methods
This was done for most, but not all, of them.

Add missing checks to ensure consistent and safer (exception instead of
a null pointer dereference) behaviour in all cases.
2017-07-19 01:48:35 +02:00
Sergei Nikulov
b510e1a63d moved to latest Catch UT Framework (#544)
* Moved to latest Catch UT Framework
* Added -Wextra to gcc and clang
* Fixed discovered issues
2017-07-07 21:31:41 +03:00