Commit Graph

35 Commits

Author SHA1 Message Date
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
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
3bc032dec4 Add sqlite3_session_backend::libversion() and libversion_number()
Use these functions instead of directly using SQLite3 ones in the test.

This makes no real difference, but allows to provide the implementation
of these functions in SOCI SQLite3 backend itself and so works even when
SQLite3 library is linked statically into this backend and is not linked
into the test.
2025-04-11 01:52:33 +02:00
Vadim Zeitlin
fb04446e35 Convert most HTTP links to HTTPS
No real changes, but it's not very serious to use HTTP links in 2025.
2025-03-04 18:03:53 +01:00
Vadim Zeitlin
ff20d620c8 Add connection_parameters::is_true_value()
Extract this function from SQLite3 backend, as it will be useful in the
other ones too, and also change it to use case-insensitive comparison.
2024-11-09 22:37:13 +01:00
Vadim Zeitlin
ae2ca287a8 Reuse connection_parameters parsing in SQLite3 backend
Don't duplicate the code for parsing space-separated possibly quoted
words in SQLite3 backend but just use the common function for it too.

Also correct handling of some boolean parameters, where previously
specifying any value, even "0" or "false", would enable it and document
the exact values accepted for them.

Add tests checking that parsing connection string works as expected.
2024-11-09 22:37:13 +01:00
Vadim Zeitlin
e543e37690 Fix typo in execute_hardcoded() SQLite backend function name
Closes #1090.
2023-10-14 14:16:48 +02:00
Vadim Zeitlin
5a81866c2f Improve connection error reporting in SQLite3 backend
Include the path to the database file in the error message, as it wasn't
particularly helpful without it.

Generalize check_sqlite_err() to take an error callback, just as it was
done for execude_hardcoded() in the parent commit.
2022-11-28 23:59:59 +01:00
Vadim Zeitlin
5ce426e75f Make error reporting in SQLite3 backend more flexible
Allow passing a lambda instead of just a hard-coded error message to
execude_hardcoded() helper function, so that we could include additional
information in the error messages without necessarily constructing the
error message in advance -- which is useless if it's not used at all,
i.e. if the error doesn't happen.

No real changes yet, but this prepares ground for the next commit.
2022-11-28 23:58:37 +01:00
Vadim Zeitlin
196ec23418 Add "nocreate" connection option to SQLite3 backend
This allows to avoid creating the database file if it doesn't already
exist as it may sometimes (often?) be undesirable, e.g. when it's
supposed to have been already created and its schema initialized, as
creating an empty database is not really helpful in this case.
2022-11-28 23:35:43 +01:00
Cosmin Cremarenco
9507d084cd Improve get_last_insert_id() for SQLite
Return the ID used for the given table instead of the last ID inserted
in any database table, which could be very different.

This relies on using internal sqlite_sequence table that is used by
AUTOINCREMENT.

Co-authored-by: Vadim Zeitlin <vz-soci@zeitlins.org>

Closes #971.
2022-06-20 19:12:57 +02:00
Cosmin Cremarenco
ae3ff29216 Add support for enforcing foreign keys in SQLite backend
Allow enabling foreign key checking, which is disabled by default in the
current SQLite versions, for the applications that need it using the
appropriate SQLite pragma if the corresponding connection string
parameter is specified.

Closes #968.
2022-05-19 23:51:24 +02:00
Johan Pascal
c158d2c67b Support "vfs" flag in SQLite3 backend connection parameters
Allow passing a pre-registered sqlite3 vfs string identifier to the
database open function
2020-06-17 23:54:01 +02:00
Cavaler
d6edfe5868 Support "readonly" flag in SQLite3 backend connection parameters
Allow opening the database in read-only mode instead of the default
read-write one.

See #784.
2020-02-06 14:19:33 +01: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
Vadim Zeitlin
2f65f02e8f Define SOCI_SQLITE3_SOURCE in all SQLite3 backend sources
Not doing it in session.cpp resulted in link errors in MinGW build as
SOCI_SQLITE3_DECL wasn't defined correctly in this case and the DLL
tried to import sqlite3_soci_error class instead of exporting it.

See #528.
2017-07-19 13:29:55 +02:00
Miha Ravselj
23d3989946 sqlite3_close moved after sqlite3_errmsg is called. 2015-08-26 15:20:20 +02:00
Miha Ravselj
bf5dad9f40 Memory leak fix in sqlite3_session_backend. 2015-08-17 11:29:51 +02:00
Mateusz Łoskot
e4376edaec Merge branch 'master' into develop-3.2.3
wip: Merging SOCI 3.2.3 changes (current master) into develop.

Conflicts:
	.gitignore
	.travis.yml
	AUTHORS
	CHANGES
	cmake/SociBackend.cmake
	cmake/modules/FindODBC.cmake
	docs/installation.html
	include/soci/boost-fusion.h
	include/soci/boost-tuple.h
	include/soci/odbc/soci-odbc.h
	include/soci/prepare-temp-type.h
	include/soci/ref-counted-prepare-info.h
	include/soci/soci-platform.h
	include/soci/statement.h
	include/soci/use.h
	include/soci/version.h
	src/CMakeLists.txt
	src/backends/postgresql/test/test-postgresql.cpp
	src/backends/sqlite3/blob.cpp
	src/backends/sqlite3/test/test-sqlite3.cpp
	src/core/CMakeLists.txt
	src/core/test/common-tests.h
	tests/mysql/test-mysql.cpp
	www/index.html
2015-04-09 23:43:22 +02:00
Vadim Zeitlin
e8e5978138 No real changes, just remove trailing whitespace.
Insignificant trailing whitespace was annoying as it resulted in extra noise
in the diffs, just get rid of it everywhere at once.
2015-04-01 14:52:39 +02:00
Alex Volanis
5776dd46e7 Introduced sqlite3_soci_error exception as subclass of soci_error.
This new exception exposes the SQLite3 result code returned when any
failure happens. Using this method is preferable to scrubbing string
error messages in soci_error exceptions. Useful when there needs to be
a distinction between general errors and database constraint errors.
Unit test added to prove the funtionality does what is expected.
2014-04-22 12:52:10 -04:00
Vadim Zeitlin
417ef5cc4d Include all public headers using "soci/" prefix inside SOCI itself.
Harmonize the inclusion style of the headers from inside and outside the
library and always use the "soci/foo.h" form.
2014-03-25 15:53:32 +01:00
Dirk Grambow
ccd4c0d96f Add get_last_insert_id for sqlite3 and mysql backends
Update docs/beyond.html accordingly
2013-10-28 19:29:46 +01:00
soyer
c62521c182 code cosmetic 2013-09-11 00:33:13 +02:00
soyer
09dbfb2fdb support for shared_cache=true propery 2013-09-11 00:23:55 +02:00
Vadim Zeitlin
f2a575c387 Update all backends to take connection_parameters instead of connect string.
There are still no real changes as only the connect string part of the
connection parameters is currently used, but this will make it possible to use
other information stored in connection_parameters from the backend code in the
future.

Also replace session::lastFactory_ and lastConnectString_ with a single
lastConnectParameters_ making the code slightly shorter and simpler.
2013-03-09 13:12:59 +01:00
Howard Butler
aa8a467944 getline in on apple doesn't seem to like an inline-constructed string 2012-10-02 11:47:29 -05:00
Belobrov Andrey
392ae75c9d SQLite database path may contain spaces if enclosed in quotes. 2012-09-04 14:14:14 +04:00
Mateusz Loskot
4ff8df029d Fixed tautological condition comparing string::find >= 0 2011-10-06 22:47:21 +01:00
Mateusz Loskot
cd7a6a65c1 Patch from Daniel Lidström with support for synchronous=on|off property for SQLite3 session. 2010-12-19 22:42:45 +00:00
Mateusz Loskot
6f551ce943 Tidy up naming convention 2010-12-19 22:32:47 +00:00
Mateusz Loskot
2d8c87c0b7 backends/sqlite3: applied patch with timeout support. Thanks to Cory Bennett for contributing the patch. Testing welcome. 2009-08-05 22:56:52 +01:00
Maciej Sobczak
89676ff71a Moved CVS src module to its own directory. 2009-04-30 11:50:31 +02:00