Commit Graph

229 Commits

Author SHA1 Message Date
John Gallagher
74b57ee47a Add test and fix for invalid cached column_count.
Issue raised in
https://github.com/jgallagher/rusqlite/pull/113#issuecomment-220122048.
2016-05-18 22:19:04 -05:00
John Gallagher
d5bbbbd763 Add query_map_named and query_and_then_named to Statement. 2016-05-18 22:01:08 -05:00
John Gallagher
703cf22b52 Separate Savepoint out from Transaction.
Replaces `set_commit` and `set_rollback` with `set_drop_behavior`.

Allows specification of savepoint names.

Savepoint::rollback() does not consume the savepoint;
Transaction::rollback() does consume the transaction.
2016-05-18 16:38:09 -05:00
John Gallagher
30733a3688 Modify Rows::next to tie its lifetime to the returned Row.
This means Rows no longer implements Iterator, but it is no longer
possible to misuse it by accessing a stale Row handle.
2016-05-18 11:41:22 -05:00
John Gallagher
437a06fca3 Merge branch 'master' into gwenn-stmt-cache 2016-05-17 20:52:52 -05:00
John Gallagher
92834951e3 Make the creation of transactions and savepoints take &mut self.
Transactions in SQLite are nested, but the previous API allowed rusqlite
transaction wrappers to be created as "siblings". This resulted in
unexpected (and usually wrong) behavior.
2016-05-17 19:53:53 -05:00
John Gallagher
d923d8c670 Use a real LruCache instead of a VecDeque. 2016-05-17 13:35:23 -05:00
John Gallagher
3c15eb0218 Add Connection::prepare_cached. 2016-05-17 13:34:54 -05:00
John Gallagher
ed72da92ef Remove cache feature 2016-05-17 12:01:55 -05:00
John Gallagher
0ab9421e6a Detach StatementCache from Connection so we can embed it (coming later) 2016-05-17 11:59:54 -05:00
John Gallagher
1978568d01 Make StatementCache hold RawStatements instead of Statements. 2016-05-17 11:55:10 -05:00
John Gallagher
f6aba80f4b Extract RawStatement wrapper around *mut sqlite3_stmt. 2016-05-17 11:27:29 -05:00
John Gallagher
b76196ae1a Merge branch 'master' into gwenn-stmt-cache 2016-05-17 08:54:47 -05:00
John Gallagher
63e5570ca9 Merge pull request #149 from jgallagher/gwenn-reset
Reset statements ASAP.
2016-05-16 15:19:03 -05:00
John Gallagher
1262d3bb17 Call sqlite3_reset on a statement ASAP inside Rows's Iterator impl. 2016-05-16 14:39:14 -05:00
John Gallagher
8e1ce5cf9c Fuse a Rows iterator once it fetches the final row. 2016-05-16 14:11:44 -05:00
John Gallagher
4a6c7b5329 Reset in Rows's drop impl instead of waiting for the next query 2016-05-16 14:02:39 -05:00
gwenn
3a52dd65f0 Rustfmt 2016-05-16 19:52:17 +02:00
John Gallagher
ba7b1ea45e Merge pull request #147 from jgallagher/update-to-latest-bitflags
Update to latest bitflags crate.
2016-05-16 12:20:26 -05:00
John Gallagher
f77ae8816d Update to latest bitflags crate.
Closes #139.
2016-05-16 11:36:48 -05:00
John Gallagher
504b16dc98 Merge branch 'master' into gwenn-convenient 2016-05-16 11:02:56 -05:00
gwenn
b20168fe9c Use String::from_utf8_lossy for error/trace.
Try to use the original message even if there are invalid
characters.
2016-05-07 12:08:57 +02:00
John Gallagher
41fe698cec Address additional clippy warnings 2016-03-29 14:18:56 -04:00
John Gallagher
2bd54578f5 Update clippy version and address new warnings 2016-03-29 11:54:02 -04:00
gwenn
aea2f876d5 Try to fix regression with Rust stable. 2016-02-14 16:24:35 +01:00
gwenn
0fe1990d34 Fix clippy warnings 2016-02-14 16:11:59 +01:00
gwenn
24d5093ab8 Merge remote-tracking branch 'jgallagher/master' into rustfmt 2016-02-02 19:15:35 +01:00
gwenn
f529d130b9 Rustfmt 2016-02-02 19:12:00 +01:00
gwenn
82f1467a9f Add declaration for convenient module 2016-02-02 18:57:25 +01:00
John Gallagher
9a4095365f Merge branch 'master' into gwenn-stmt-cache 2016-02-02 10:39:22 -05:00
John Gallagher
350fd11fed Add a handle() method to unsafely get the underlying SQLite connection.
Doc comments suggest opening issues on rusqlite for any uses of
`handle()`, as uses indicate areas where rusqlite insufficiently wraps
SQLite.
2016-02-01 15:21:03 -05:00
John Gallagher
a793f8c8c5 Remove scary lifetime-of-rows-may-panic from README.
Closes #119.
2016-02-01 14:30:51 -05:00
John Gallagher
a9a953e6b7 Merge branch 'stmt-cache' of https://github.com/gwenn/rusqlite into gwenn-stmt-cache 2016-01-07 11:19:59 -05:00
John Gallagher
f290c15d0d Merge branch 'dynamic' of https://github.com/gwenn/rusqlite into gwenn-dynamic 2016-01-07 11:12:05 -05:00
gwenn
12f26e78b3 Introduce RowIndex trait (like in rust-postgres) 2016-01-02 12:13:37 +01:00
gwenn
9db82e74db Make possible to execute dynamic queries.
Queries with dynamic column count/type.
2016-01-02 10:28:00 +01:00
Gwenael Treguier
86ffc24bb9 Merge branch 'master' of https://github.com/jgallagher/rusqlite into stmt-cache 2015-12-18 20:25:52 +01:00
Gwenael Treguier
109c26fea4 Replace LruCache by VecDeque. 2015-12-17 20:02:49 +01:00
John Gallagher
b241f98920 Add test and check for SQLite being in single-threaded mode 2015-12-16 23:56:21 -05:00
John Gallagher
7920dbc5ff Only check for SQLITE_CONSTRAINT_NOTNULL on new enough versions of SQLite. 2015-12-16 20:30:27 -05:00
John Gallagher
047861b928 Move Error into its own module (internal organization only - public API remains). 2015-12-16 20:30:27 -05:00
John Gallagher
aac4d59fcc Change Error from a struct to an enum (BREAKING CHANGE).
This allows us to separate out the underlying SQLite error codes from
errors that occur on the Rust side.
2015-12-16 20:30:27 -05:00
John Gallagher
bf859a8008 Attempt to enable extended result codes for all connections 2015-12-16 20:30:27 -05:00
Gwenael Treguier
880a78ae83 Partial fix following John suggestions. 2015-12-15 21:49:59 +01:00
Gwenael Treguier
108b6b6fcd Merge branch 'master' of https://github.com/jgallagher/rusqlite into stmt-cache 2015-12-15 21:03:31 +01:00
John Gallagher
5ac5f3e9b5 Make blob_open take a DatabaseName instead of a str. 2015-12-14 13:38:36 -05:00
John Gallagher
73611d45d5 Merge branch 'blob' of https://github.com/gwenn/rusqlite into gwenn-blob 2015-12-14 13:35:05 -05:00
John Gallagher
4b512212d2 Inline decode_result_with_errmsg to fix dead code warning 2015-12-13 14:59:47 -05:00
Gwenael Treguier
1c4ca000cf Simplify execute_batch implementation. 2015-12-13 14:15:56 +01:00
Gwenael Treguier
d5faf2fab3 Merge branch 'master' of https://github.com/jgallagher/rusqlite into stmt-cache 2015-12-13 11:23:54 +01:00
Gwenael Treguier
6f0f121d61 Merge remote-tracking branch 'remotes/jgallagher/master' into blob 2015-12-13 10:53:29 +01:00
John Gallagher
6bcc3edccd BREAKING CHANGE: Remove common prefix on TransactionBehavior case names. 2015-12-12 14:22:50 -05:00
John Gallagher
b1cde705be Rename SqliteLoadExtensionGuard -> LoadExtensionGuard. 2015-12-12 14:20:11 -05:00
John Gallagher
3d15a8a15c Rename SqliteTransaction* -> Transaction*. 2015-12-12 14:17:43 -05:00
John Gallagher
9cac56d6a2 Rename SqliteOpenFlags -> OpenFlags. 2015-12-12 14:13:29 -05:00
John Gallagher
ea5cb41bbf Rename SqliteRow -> Row. 2015-12-12 14:11:24 -05:00
John Gallagher
b932640181 Rename SqliteRows -> Rows. 2015-12-12 14:09:37 -05:00
John Gallagher
ec654352d9 Rename SqliteStatement -> Statement. 2015-12-12 14:08:04 -05:00
John Gallagher
eb60bb3111 Rename SqliteResult -> Result. 2015-12-12 14:06:03 -05:00
John Gallagher
f0b6bf9152 Rename SqliteError -> Error. 2015-12-12 13:53:58 -05:00
John Gallagher
4327a84edb Rename SqliteConnection -> Connection.
Leave old name in as a (deprecated) typealias.
2015-12-12 13:53:34 -05:00
John Gallagher
5039e57637 Merge branch 'master' into gwenn-functions
Conflicts:
	Changelog.md
2015-12-11 19:21:39 -05:00
John Gallagher
9f5f4ac385 Merge branch 'functions' of https://github.com/gwenn/rusqlite into gwenn-functions
Conflicts:
	Cargo.toml
	src/lib.rs
2015-12-11 11:31:25 -05:00
John Gallagher
0051ff47a6 Refactor: Extract match to get an expected row into its own method. 2015-12-10 20:48:38 -05:00
John Gallagher
53979407c5 Merge branch 'named-param' of https://github.com/gwenn/rusqlite into gwenn-named-param
Conflicts:
	Cargo.toml
	src/lib.rs
2015-12-10 16:53:43 -05:00
John Gallagher
a1f1480b18 Run rustfmt on all crate files 2015-12-10 16:48:09 -05:00
John Gallagher
8c2e0a0da7 Rename BackupName -> DatabaseName 2015-12-10 16:20:45 -05:00
John Gallagher
e2f8e73635 Initial implementation of the online backup API. 2015-12-09 00:19:59 -05:00
John Gallagher
51a542c0f7 Fix broken load_extension feature 2015-12-08 21:15:23 -05:00
Gwenael Treguier
fe6afe2a94 Merge branch 'master' of https://github.com/jgallagher/rusqlite into functions 2015-12-06 21:33:21 +01:00
Gwenael Treguier
5b86871d76 Merge branch 'master' of https://github.com/jgallagher/rusqlite into named-param 2015-12-05 12:32:16 +01:00
Gwenael Treguier
18ff9cf4ca Merge branch 'master' of https://github.com/jgallagher/rusqlite into stmt-cache 2015-12-05 11:58:06 +01:00
Gwenael Treguier
cef1d3285e Merge branch 'master' of https://github.com/jgallagher/rusqlite into blob 2015-12-05 11:11:23 +01:00
John Gallagher
ac08a18c43 Merge pull request #86 from jgallagher/gwenn-trace_extension
Add Rust interface to SQLite's logging, tracing, and profiling hooks
2015-12-01 13:19:43 -05:00
John Gallagher
3d654aeed1 Add more documentation for failure modes of functions that return s 2015-12-01 12:05:29 -05:00
John Gallagher
1af3fcd053 Fix error messages when failing to convert paths and strings to C-compatible versions 2015-12-01 11:47:55 -05:00
John Gallagher
49cb1efe62 Merge branch 'master' into gwenn-trace_extension 2015-12-01 11:13:23 -05:00
John Gallagher
635616842c Remove 'static requirement on output of closure given to query_map and query_and_then.
The 'static bound was there to prevent callers from being able to save
off the `SqliteRow` handles passed into the closure. This PR changes the
closure to take `&SqliteRow`s instead, which provides the same feature
without restricting the output of the closure.
2015-12-01 10:58:32 -05:00
John Gallagher
ace5b1ebdc Change trace() to take a Rust fn instead of an extern "C" fn. 2015-11-30 21:08:39 -05:00
John Gallagher
eaf080261b Merge branch 'trace_extension' of https://github.com/gwenn/rusqlite into gwenn-trace_extension 2015-11-30 13:13:43 -05:00
Gwenael Treguier
0729e195c3 Use debug_struct for formatting. 2015-11-30 12:16:09 -05:00
Gwenael Treguier
20c1213482 Remove feature duration. 2015-11-11 15:03:07 +01:00
Gwenael Treguier
a2327fb048 Revert "Remove usage of unstable library feature 'duration'"
This reverts commit 9c415f9c9e.
2015-11-11 15:00:39 +01:00
Gwenael Treguier
e052053a79 Merge remote-tracking branch 'jgallagher/master' into stmt-cache 2015-11-11 14:42:08 +01:00
Gwenael Treguier
db7345624f Merge remote-tracking branch 'jgallagher/master' into named-param 2015-11-11 14:39:15 +01:00
Gwenael Treguier
8bff40b6d6 Merge remote-tracking branch 'jgallagher/master' into trace_extension 2015-11-11 14:28:21 +01:00
John Gallagher
b1350c4c14 Merge branch 'master' into gwenn-reset_asap 2015-09-22 10:16:52 -07:00
John Gallagher
d23667870e Merge pull request #70 from jgallagher/pfernie-master
Replace get_opt with get_checked. Add query_and_then and query_row_and_then.
2015-09-21 10:38:07 -04:00
John Gallagher
7ee69fe103 Remove get_opt (superceded by get_checked). 2015-09-21 10:31:11 -04:00
John Gallagher
1918dc14d0 Add tests for query_row_and_then(). 2015-09-20 21:30:40 -04:00
John Gallagher
072a336b33 Refactor: Reduce duplication across query_and_then tests. 2015-09-20 21:28:50 -04:00
John Gallagher
0cbb2743e3 Merge branch 'master' of https://github.com/pfernie/rusqlite into pfernie-master 2015-09-20 21:07:39 -04:00
John Gallagher
59a3b0ddb5 Merge pull request #62 from gwenn/too-big
Check Rust str length before binding.
2015-09-20 20:57:28 -04:00
John Gallagher
d07c7ec8a6 Add basic unit test of statement debug including SQL 2015-09-20 20:44:51 -04:00
gwenn
05669082a3 Debug db path and stmt sql. 2015-09-20 20:41:13 -04:00
John Gallagher
43b0c1c98a Merge branch 'reset_asap' of https://github.com/gwenn/rusqlite into gwenn-reset_asap 2015-09-20 20:30:59 -04:00
John Gallagher
36f577aea6 Merge pull request #53 from gwenn/exec_check
Extra check in SqliteStatement.execute
2015-09-20 20:29:12 -04:00
Huon Wilson
b7efb37b35 Relax uses of P: AsRef<...> from &P to P.
This means that one can pass `AsRef` types directly, without having to
insert a `&`, e.g. `SqliteConnection::open("foo.db")` (new)
vs. `SqliteConnection::open(&"foo.db")` (old).

This should be backwards compatible, since there is an impl in the
standard library:

    impl<'a, T, U> AsRef<U> for &'a T where U: ?Sized, T: AsRef<U> + ?Sized

I.e. the old `&P` satisfies the new bound still. (Taking `P` directly is
what the standard library does with similar functions, like
`File::open`.)
2015-09-08 18:11:50 +10:00
Patrick Fernie
e4eda2041e Implement SqliteConnection::query_row_and_then() 2015-08-27 14:47:48 -04:00
Patrick Fernie
29072e585b Implement SqliteStatement::query_and_then()
Allows for more ergonomic unification of error types
2015-08-27 13:43:43 -04:00