Originally, the indicator passed by the user was copied into a stored-for-later
variable. This value could have been overwritten during conversion of the bound
parameter to its base type.
Signed-off-by: Innokentiy Alaytsev <alaitsev@gmail.com>
Provide soci_error constructors taking a format string and an argument
instead.
This is still unsafe, because we lose the compile-time check of the
format string, but is slightly less ugly than defining format() in our
own namespace.
Previously an overload of the soci::use function accepted a value of
type T and a vector of indicators. This function worked when T was
std::vector<U>, but would fail if T was any other type. Judging by the
comment, the original intent was to have an overload for std::vector<T>.
Closes#1334.
Closes#1336.
Signed-off-by: Innokentiy Alaytsev <alaitsev@gmail.com>
This was supposed to allow reading into char[N] but either was never
implemented or got broken a long time ago and doesn't seem really useful
compared to using std::string with into(), so simply remove this
overload.
Closes#1332.
See #1333.
It may be more convenient to work with this type than with "long long",
so provide an overload allowing to retrieve the ID as it too.
Closes#1232.
Closes#1325.
Instead of calling throw_oracle_soci_error(), add oracle_soci_error ctor
taking the parameters that were passed to this function and just throw
the object created using this ctor.
This is more explicit and simpler.
No real changes.
This also fixes compilation error due to not including <sstream> any
more after the changes of a7b02446 (Merge branch 'use-fmt', 2026-01-15).
See #1321.
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.
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.
This allows to specify the window to be used as parent for the dialog
that can be shown by the ODBC driver to ask for missing information,
which can be useful to ensure that this dialog stays in front of the
application window instead of being hidden beneath it.
Make sure no exceptions can escape from session class dtor as this would
result in an immediate application termination due to throwing from a
(implicitly) noexcept function.
Let exceptions escape from the backend session classes dtors for those
of them that throw from them: as these classes are private, this
shouldn't affect any existing code and allows these exceptions to still
be reported if they happen when session::close() is called.
Also document that close() may throw and should be called by the
application if handling errors during clean up is important for it.
Closes#1313.
SQLHENV and SQLHDBC handles stored in odbc_session_backend member
variables were never freed if the ctor threw an exception because the
dtor, freeing them, was not called in this case, resulting in memory and
resource leaks.
Fix this by wrapping these handles in a simple struct freeing them
automatically, as members dtors are always called if they had been
constructed successfully.
If connecting to the database fails, postgresql_session_backend dtor is
not executed and traceFile_ could be leaked.
Fix this by using a unique_ptr<> with a custom deleter to store the file
pointer: this ensures that it is closed in any case.
Also use soci_scoped_lock to ensure that the mutex is always unlocked.
This simplifies the code and fixes a couple of potential bugs where the
resources were not cleaned up properly if an exception happened.
Sometimes it is necessary just to check whether an option is given (e.g.
to avoid overwriting it in this case) and has_option() was inconvenient
to use in this case as it required defining a dummy string variable.
Make it possible to do this easily with has_option().
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.
Not only the compiler seems to give this warning for just a simple
unconditional "throw", but it also has started giving it in a previously
warning-free code, probably due to a micro version update on GitHub CI.
Fighting against is becoming really ridiculous, so just suppress the
warning globally and remove the local suppressions for it which are not
needed any more.
This was inconsistent with the other statement-like macros in SOCI
itself and globally unusual.
Add semicolons to a couple of places where they were not used (they
already were in a couple of other ones).
No real changes.
As we can't specialize exchange_traits<> for both int8_t and char when
they are the same type (which is the case under Solaris, see #1154),
specialize exchange_traits<> for some wrapper type in this case to avoid
compilation errors.
This is an alternative, and simpler, solution than that of #1170, so we
can now remove soci_are_types_same CMake function.
This should have been part of the parent 185feedb (Remove
SOCI_INT64_T_IS_LONG and the test for it in CMake, 2025-06-12) which
forgot to replace the types inside type_conversion<> specializations for
soci_l_or_ll_t and its unsigned equivalent with these types.
See #1277.
We can replace preprocessor checks for SOCI_INT64_T_IS_LONG with simpler
logic if we assume that int64_t is always either "long" or "long long",
which seems to be true in practice, so do it and remove duplicated
specializations for "long" and "long long" in several places.
This allows to use set_deallocate_prepared_statements(false)
temporarily, which makes it usable even in the long-running programs
which shouldn't let the resources accumulate on the server without ever
freeing them.
Using this parameter allows to enable tracing of all database calls,
which can be useful for diagnostic and profiling purposes.
Also add fopen() wrapper to avoid "deprecation" warnings from MSVC.
Use "_s" versions of the standard C functions if possible/simple to do
and disable deprecation warnings explicitly in a couple of places where
this could not be done instead of disabling them globally.
Also stop using strcpy() entirely and use strncpy() instead.
See #1268.
They were ugly and not really necessary when we can just avoid marking
the functions as deprecated when compiling SOCI itself to allow using
them from the implementation code.
Also simply remove deprecated attributes from the functions in
blob_backend which is not supposed to be used publicly at all.
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.
Switch to using the same "ub2" type as OCI uses for charset codes to
avoid warnings about implicitly truncating "int" to "ub2" when passing
charset parameters to various OCI functions.
Neither of these warnings (corresponding to copy ctor and assignment
operator not being synthesized by the compiler) are generated any
longer, so there is no need to suppress them.
We don't need to determine sizeof(long) at configure time when we can do
it directly during the build using std::conditional<>.
Also merge the identical specializations of various types for long in 32
and 64-bit cases.