Run clang-tidy modernize-use-nullptr check on all files and manually
change the remaining NULLs skipped by it to nullptr.
Also use nullptr in the documentation.
The recent 335b8e53 (Give context in error message when
define_and_bind() fails, 2026-01-14) accidentally used "context" string
instead of context variable, as intended.
It was not obvious that this member variable couldn't be used without
being initialized, so do initialize it to ensure that it always has a
valid value.
Also fix a typo in a related comment.
Make sure the macros are consistently defined.
Also define SOCI_SOURCE and SOCI_$BACKEND_SOURCE at CMake level to
make sure they are always defined.
Closes#1273.
Keep SOCI_NORETURN defined just in case somebody uses it in their own
code, but stop using it in SOCI and just use the standard C++11
attribute directly instead.
This is done mostly to avoid MSVC warnings about implicit __int64 to int
conversions, it should make no difference in practice as all sizes will
always be smaller than INT_MAX anyhow.
Since SQLite doesn't have a type system, we have to always be prepared
to select huge numbers, even if the "type" is e.g. int8.
To do that, we overwrite the exchange type (e.g. in row based APIs) to
always be (u)int64 for integers to avoid over-/underflows.
Update the documentation to explain this SQLite peculiarity and add a
test verifying that this behaves as expected.
Fixes#1190.
Closes#1217.
This requires backend cooperation, but it is now possible for a backend
to override get_row_to_dump() function to return the row whose values
would appear in the error message.
This commit is best viewed using Git --color-moved option.
It looks like this function must always be called after a (successful)
call to describe() and it is not called from anywhere else, so it seems
wrong to both require and allow calling it independently -- just call it
from describe() itself.
No real changes, this function has never been part of public API, so
hopefully nobody was using it.
Describe the statement once again after calling execute() if we had
failed to describe it before because SQLNumResultCols() returned 0, as
it may happen with some complex queries and SQL Server used via ODBC
backend.
Closes#1151.
See #1182.
Co-Authored-By: Vadim Zeitlin <vz-soci@zeitlins.org>
Handle wide-strings similarly to how normal strings are already handled.
For now support for them is only available in the ODBC backend.
Also add conversion functions between UTF-{8,16,32} and wchar_t and the
tests for them. Note that some of these functions are not used yet, but
provide the complete set as they probably will be in the future.
Co-Authored-By: Vadim Zeitlin <vz-soci@zeitlins.org>
It wasn't quite the same for all of them, notably MySQL and ODBC
disagreed about the mapping of db_uint32 and ODBC backend also mapped
db_uint64 to signed dt_long_long and not dt_unsigned_long_long as the
other backends, so make it possible to preserve its existing behaviour
by overriding to_data_type() in it.
There is still a minor incompatibility in MySQL backend: the type of
unsigned INT24 fields is now dt_long_long and not dt_integer as before,
but we can hopefully live with this.
This is unnecessary as it can be recovered from db_type: even if this is
not lossless, we don't really care about it if all we need is data_type,
so simplify the API and the implementation by only having one "type"
parameter instead of two.
No real changes.
Clear the `statement_impl::indicators_` vector instead of just appending
more and more elements to it when using values-based API.
Closes#1058.
See #1061.
This makes errors such as e.g. "Null value fetched and no indicator
defined." much more useful, as the error message now says which
parameter exactly was null.
Closes#631.
Fix warnings by changing the code whenever possible, in particular remove
firebird_rowid_backend class and src/backends/firebird/row-id.cpp file in
which it was defined entirely as it only resulted in "unreachable code"
warnings but was otherwise unused.
Also avoid implicit conversions by either using the correct types or by making
the casts explicit using static_cast<> in places where the casts are really
needed.
Add helpful SOCI_NOT_COPYABLE, SOCI_NOT_ASSIGNABLE and SOCI_UNUSED macros and
use them to suppress the corresponding warnings.
Finally, combine soci-config.h and soci-platform.h in a single file, always
include the latter as the first header and keep the former as a wrapper for
the latter just for compatibility.
Remove the MSVC "#pragma warning(disable: *)" as they are not needed any more.
Closes#355.
Improve the error messages by using the parameter names used in the query
itself, if any, when the query parameters were bound by position and not by
name.
This means that errors for a query like
sql << "insert into soci_test(name, age) values (:name, :age)",
use(name), use(age));
will now contain "with :name=... :age=..." even though the parameter names
were not passed to use().
* Warning: break compatibility with boost 1.35 released in 2008!
* when calling use() or into() with tuple or fusion objects, it stores
reference to each member of object instead of storing object reference
thanks to boost::fusion::foreach.
* Job is done by new use_type_vector and into_type_vector classes
Add soci_error::add_context() and use it in statement class to record the
information about the query which resulted in the exception and, if
applicable, this query parameters.
This results in much better end user experience as the error messages now
contain information allowing to diagnose which query exactly has failed
instead of just unhelpfully saying that an error occurred.
The leak has been confirmed usign memory debugger. Applied fix suggested
by Evgeny Barabanov to perform allocated statement clean up if exception
is thrown from prepare() method.
There is no need for a separate type for "unsigned long" as we don't have
special types neither for "unsigned int" nor for "long" and this type was not
handled correctly in the ODBC backend that mapped "unsigned int" to
SQL_BIGINT, even though the former is almost always 32 bits and the latter is
always 64 bits.
Simply remove these types to avoid the problem and simplify the code.
Signed-off-by: Vadim Zeitlin <vz-soci@zeitlins.org>