Commit Graph

3542 Commits

Author SHA1 Message Date
Vadim Zeitlin
fcd5af3e39 Add a test checking that wide strings work with rowset API too
Verify that we can use row-based API for accessing NVARCHAR() columns.
2025-05-23 17:11:33 +02:00
Vadim Zeitlin
851b8e51ad Don't throw when to_data_type(db_wstring) is called
While there is no exact equivalent to this new database type among the
old dt_xxx constants, we still shouldn't throw from this function as
it's called from statement_impl::describe(), notably used by rowset API,
and throwing an exception from there prevented rowset from being used at
all with the NVARCHAR() columns mapped to db_wstring.
2025-05-23 17:09:27 +02:00
Vadim Zeitlin
c2f2685346 Update versions in master after 4.1.2 release
Change the version in this branch to 4.2.0.
2025-05-17 15:33:22 +02:00
Vadim Zeitlin
4ad4333fd8 Merge branch 'win32-libname-abiver'
Restore ABI version use in Windows DLL names.

See #1252.
2025-05-17 15:05:05 +02:00
Vadim Zeitlin
20325f57c9 Add unit test to check loading backends dynamically
Ensure that loading backend dynamically, i.e. using their name, works.

This required adding a way to get this name from the test context.

See #1250.
2025-05-17 00:33:31 +02:00
Vadim Zeitlin
ec00b69a71 Amendments to the parent commit, changing SQLite timeout setting
This should have been part of the parent commit but got accidentally
left out.

See #1254.
2025-05-17 00:23:00 +02:00
Matheus Gabriel Werny
515096dc9b SQLite: Ensure timeout is set first
The timeout must be set first for SQLite as applying other settings
might fail with a locked database without timeout.

Closes #1253.

Closes #1254.
2025-05-17 00:18:29 +02:00
Vadim Zeitlin
ad27c2ffc2 Restore ABI version use in Windows DLL names
This was lost during CMake rewrite, but it makes sense to keep doing it,
as it's a common convention under Windows due to the absence of
SOVERSION equivalent, and it broke dynamic backend loading by name.

Fix this by moving ABI_VERSION definition to the main CMakefile and also
defining ABI_SUFFIX there, if necessary, which is appended to the names
of all libraries, if it is defined.

See #1248.
2025-05-15 20:59:00 +02:00
Robert Silén
d3cbaa738a Add MariaDB to README.md
Mention that it is supported by MySQL backend too.

See #1249.

Closes #1150.
2025-05-13 18:32:38 +02:00
Vadim Zeitlin
0befeabdc5 Update for 4.1.1 release
There have been too many changes since 4.1.0-rc1 to keep the same
release version, so increment it.
2025-04-25 17:46:59 +02:00
Vadim Zeitlin
f8677c576e Remove extraneous blank line in installation documentation
This triggers markdownlint MD012 warning.
2025-04-25 17:40:09 +02:00
Vadim Zeitlin
85dea95da9 Fix typo in tar call syntax
This should have been part of d385619e (Include submodules in the
release, 2025-04-25).
2025-04-25 17:39:35 +02:00
Vadim Zeitlin
45f9ca39d8 Merge branch 'cxx20-fixes'
C++20 build fixes.

See #1245.
2025-04-25 17:34:11 +02:00
Vadim Zeitlin
bf612a40c0 Merge branch 'bundled-sqlite'
Improve using bundled SQLite.

See #1243.
2025-04-25 17:33:46 +02:00
Vadim Zeitlin
d385619ed2 Include submodules in the release
Use "git submodule foreach" to include all submodules, even if we
currently have just a single one.
2025-04-25 17:33:40 +02:00
Vadim Zeitlin
561f004076 Build SQLite3 as part of soci_sqlite3 itself if necessary
Get rid of a separate soci_sqlite3_builtin target as it didn't work
correctly when using static libraries.

Instead, just compile the amalgamated SQLite3 source as part of
soci_sqlite3 itself, which works after the changes of the parent commit
as we don't get tons of warnings for this C file any longer.
2025-04-25 15:49:17 +02:00
Vadim Zeitlin
ef9828ef3b Define SQLITE3_DIRECTORY and SQLITE3_SOURCE_FILE variables
No real changes, just use variables defined only once instead of
repeating paths.
2025-04-25 15:48:38 +02:00
Vadim Zeitlin
43caf0c3c2 Don't use GLOB for the header files
This results in an extra "GLOB verification" step when building and just
doesn't seem worth it, especially as we already list all the source
files and backend-specific headers explicitly.

This also fixes an annoying "GLOB mismatch" error which happened when
using Vim as its swap files (".foo.h.swp") were wrongly matched by the
GLOB wildcard and so switching to another file in Vim changed the GLOB
expansion.
2025-04-25 15:07:30 +02:00
Vadim Zeitlin
044826b95c Stop using u8 literals in the Unicode test
This doesn't work when using C++20 as they produce values of "char8_t*"
type which is different from the expected "char*".

Just assume UTF-8 encoding is always used, we already use /utf-8 flag
for MSVC and all Unix compilers should use it too anyhow.
2025-04-25 14:44:25 +02:00
Vadim Zeitlin
5cb654da7e Avoid clashes between soci::ssize() and std::ssize()
Simply use std function if it's available, i.e. if we're using C++20.

Closes #1244.
2025-04-25 14:39:01 +02:00
Vadim Zeitlin
5c39137ded Set compiler warning options for C++ sources only
Also make the use of generator expressions less horrible by defining a
variable with a readable name containing the condition checked.
2025-04-25 01:06:43 +02:00
Vadim Zeitlin
9371f32fa1 Add SOCI_SQLITE3_BUILTIN CMake variable
This can be used either to disable using the built-in SQLite version or,
on the contrary, force using it even if the system version is available.
2025-04-25 00:25:15 +02:00
Vadim Zeitlin
eb61a4e5bc Merge branch 'firebird-errors'
Improve Firebird errors generation too.

See #1242.
2025-04-24 20:58:10 +02:00
Vadim Zeitlin
ac622e4184 Implement get_error_category() for Firebird errors
Recognize permission and constraint violation errors as well as a few
other ones that haven't been actually observed but seem to match well
the existing error categories.
2025-04-24 20:23:29 +02:00
Vadim Zeitlin
8400532838 Fix retrieving the native error code for Firebird backend
Really return Firebird/InterBase error code instead of returning the
first element of the status vector (which is typically 1 for all
errors).
2025-04-24 20:23:29 +02:00
Vadim Zeitlin
62b74b101b Increase SOCI_FIREBIRD_ERRMSG size
512 characters might, conceivably, be too small for the error messages
including several database object names if they are long enough, so
increase it to 4096 which should really be enough.
2025-04-24 20:23:29 +02:00
Vadim Zeitlin
befb6cd4bc Don't make SOCI_FIREBIRD_ERRMSG constant public unnecessarily
It's only used in a single function, so define it just there.
2025-04-24 20:23:29 +02:00
Vadim Zeitlin
8dd1fd426a Don't define our own constants, just use ISC_STATUS_LENGTH
It's not clear why did we need to define our own "stat_size" when
ISC_STATUS_LENGTH exists.

Just use it.
2025-04-24 20:23:29 +02:00
Vadim Zeitlin
d2cd77b1e3 Remove unnecessary firebird_soci_error dtor
No real changes, just don't define this dtor unnecessarily.
2025-04-24 19:47:56 +02:00
Vadim Zeitlin
93ddffb05f Add functions returning native error description to soci_error
Allow handling backend-specific errors without including
backend-specific headers.
2025-04-23 01:33:23 +02:00
Vadim Zeitlin
a1b8d7de59 Merge branches 'mysql-errors' and 'oracle-errors'
Minor improvements to error handling in MySQL and Oracle backends to
make them more consistent with the other ones.

See #1238, #1239.
2025-04-23 00:11:24 +02:00
Vadim Zeitlin
9583f2411f Remove mysql_soci_error::cat_ member variable
Don't bother precomputing it in the ctor, do it in get_error_category()
as in the other backends and for the same reasons.
2025-04-22 23:59:13 +02:00
Vadim Zeitlin
9907b954bd Move mysql_soci_error ctor out of line
Create a separate implementation file, as in the other backends.

No real changes.
2025-04-22 23:58:09 +02:00
Vadim Zeitlin
60d4568f50 Recognize Oracle "insufficient privileges" error
Return the correct category for it.
2025-04-22 23:54:00 +02:00
Vadim Zeitlin
b79f6faf99 Remove unnecessarily "else" keywords in oracle_soci_error
No real changes, just make the code a bit more readable.
2025-04-22 23:50:58 +02:00
Vadim Zeitlin
82df4f0fba Remove oracle_soci_error::cat_
This is similar to 025d21ce (Remove postgresql_soci_error::cat_ field,
2025-04-22) but for Oracle backend.
2025-04-22 20:48:23 +02:00
Vadim Zeitlin
a77c689003 Merge branches 'sqlite-errors', 'postgresql-errors' and 'odbc-errors'
Improve error reporting for ODBC, PostgreSQL and SQLite backends, in
particular, provide, or improve, get_error_category() in the exception
classes of all these backends.

See #1235, #1236, #1237.
2025-04-22 20:06:32 +02:00
Vadim Zeitlin
fe29161c2c Add a simple pseudo-test for interactive SQL execution
This can be used to check that an SQL statement results in the expected
error.
2025-04-22 18:55:45 +02:00
Vadim Zeitlin
5144f45a32 Recognize more SQLSTATEs in odbc_soci_error::get_error_category()
In particular, detect error codes corresponding to "no_privilege", as
they may need to be handled differently from the other errors at the
application level.
2025-04-22 18:54:51 +02:00
Vadim Zeitlin
fcf635c144 Use strncmp() instead of comparing character by character
No real changes, just make the comparison slightly more readable.
2025-04-22 18:41:02 +02:00
Vadim Zeitlin
397da6b6f5 Move odbc_soci_error implementation in a separate source file
No real changes, just make this backend more consistent with the other
ones, which already have their own error.cpp files, and reduce physical
dependencies.
2025-04-22 18:01:37 +02:00
Vadim Zeitlin
025d21cea6 Remove postgresql_soci_error::cat_ field
Don't precompute it in the ctor, it seems better to do it only when it's
really needed: the code doing it can't throw, so it's safe, and we might
not need to run it at all.

No real changes.
2025-04-22 17:08:16 +02:00
Vadim Zeitlin
cf3e73ed3c Add get_error_category() test to PostgreSQL tests
Use this function in at least one of the tests to check that it's not
totally broken.
2025-04-22 17:05:29 +02:00
Vadim Zeitlin
cbb28ed046 Use CHECK_THAT() in PostgreSQL unit tests
This is simpler than manually using strncmp() or string::find().

Omit one negative test, it's not clear what was it actually testing for.
2025-04-22 17:02:01 +02:00
Vadim Zeitlin
53f5e9c340 Implement get_error_category() in sqlite3_soci_error
Try to classify all the possible SQLite result codes using SOCI
error_category enum.

In particular, this allows to detect connection and permission errors.

Update the unit test to test the error category too.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
62001b2365 Add sqlite3_soci_error::extended_result()
Allow to get the extended error code from SQLite too.

Add a unit test checking that the new function returns the expected
result.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
2a121b57c4 Rewrite SQLite unit test to use explicit try/catch
Don't use CHECK_THROWS_WITH(), it's convenient but not very flexible,
while an explicit try/catch will allow us to add more checks on the
exception object in the upcoming commits.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
51a5715164 Simplify and centralize SQLite3 backend error generation
Call sqlite3_errmsg() directly in sqlite3_soci_error ctor instead of
doing it in multiple places in the backend code.

Throw soci_error when there is no SQLite3-specific information
associated with the error.

Update the documentation to make it more clear that both
sqlite3_soci_error and soci_error must be caught.
2025-04-22 16:14:12 +02:00
Vadim Zeitlin
9b9e63d51b Use unique_ptr<> instead of calling sqlite3_free() manually
Prefer to use automatic resource management.

Also fix a typo in a comment.

No real changes.
2025-04-22 16:14:12 +02:00
Vadim Zeitlin
54ae45758b Improve wording of SQLite3 backend error messages
Don't use internal function names in them, they shouldn't be shown to
the users and don't mean much anyhow, so either rephrase the error or
just omit the extra noise from it, as in the most common case when
executing a statement failed.
2025-04-22 13:59:57 +02:00