Commit Graph

968 Commits

Author SHA1 Message Date
Thom Chiovoloni
2461ebf62f Update documentation 2020-11-03 19:09:19 -08:00
Thom Chiovoloni
032aea73b8 Overhaul query API, removing the need for the _named variants of all functions, and rusqlite::NO_PARAMS 2020-11-03 19:09:19 -08:00
Thom Chiovoloni
c45446ba73 Seal the RowIndex trait (technically breaking, but unlikely to break anybody) 2020-11-03 19:09:19 -08:00
gwenn
b9ccb252ef
Merge pull request #824 from gwenn/progress_handler
Expose query progress information
2020-11-03 18:14:36 +01:00
Thom Chiovoloni
1aeea123dd Silence clippy's complaint about unelided lifetime in session.rs 2020-11-02 19:34:09 -08:00
gwenn
1103febb1e Test Batch iterator 2020-10-31 11:11:12 +01:00
gwenn
f3c2b63836 Get rid of fallible iterator trait 2020-10-31 10:47:44 +01:00
gwenn
73323b6b92 Remove Iterator implementation for Batch
If Batch implements both `Iterator` and `FaillibleIterator`, `next`
method is ambiguous and must be qualified...
2020-10-29 20:06:47 +01:00
gwenn
b73ca079a8 Implement Iterator for Batch 2020-10-29 20:01:46 +01:00
gwenn
5f5943435e Remove lazy_static block where possible 2020-10-29 19:51:51 +01:00
Nick Hynes
749266cae9 Reduce required lifetime in create_scalar_function 2020-10-28 23:33:00 -07:00
gwenn
d1ec46182f Fix Clippy warning 2020-10-28 21:26:36 +01:00
gwenn
b448d95510 Merge remote-tracking branch 'upstream/master' into progress_handler 2020-10-28 21:21:19 +01:00
gwenn
76ad2bf19c Rustfmt 2020-10-28 21:12:29 +01:00
gwenn
5ce81024c8 Introduce Batch fallible iterator 2020-10-28 21:10:13 +01:00
gwenn
e1072b7f75 Reduce required lifetime
Revert lifetime change on table_filter
2020-10-28 20:16:53 +01:00
gwenn
926977846f Reduce required lifetime
Extends #825 to
 - create_collation
 - commit_hook
 - rollback_hook
 - update_hook
 - table_filter
2020-10-28 19:20:05 +01:00
Tim Hutt
b0ade73f43 Add ToSql implementations for u64 and usize 2020-10-26 23:28:25 -07:00
gwenn
9c954b8cb5 Rustfmt 2020-10-25 12:28:03 +01:00
gwenn
49325296a9 Expose query progress information
Add unit tests
2020-10-25 12:20:15 +01:00
gwenn
f5c83af863 Expose query progress information 2020-10-25 11:58:47 +01:00
Tim Hutt
8841187717 Silence clippy 2020-10-24 09:52:05 -07:00
Tim Hutt
f264873999 Cargo format 2020-10-24 09:52:05 -07:00
Tim Hutt
ebcec59969 Implement From/ToSql for more types
This implements `FromSql` for `u64`, `usize` and `f32`, and `ToSql` for `f32`.

I also updated the documentation to describe how it currently works, and changed the implementation to use `try_from` for integral casts rather rather than custom code.

Test added.
2020-10-24 09:52:05 -07:00
gwenn
6ae9802fa3 Feature ptr_offset_from #41079 available in 1.47 2020-10-08 21:12:46 +02:00
Thom Chiovoloni
084d1f535d Replace lru-cache with hashlink 2020-10-06 00:10:22 -07:00
Thom Chiovoloni
587fdeb185 Add write_all_at for compatibility with FileExt, improve docs a little 2020-10-04 15:48:10 -07:00
Thom Chiovoloni
d61fe36237 Improve pos io test coverage 2020-10-04 15:48:10 -07:00
Thom Chiovoloni
67ee5a0586 Add test coverage for positional blob io 2020-10-04 15:48:10 -07:00
Thom Chiovoloni
7cd909fc14 Add positional blob i/o and adjust blob i/o example docs 2020-10-04 15:48:10 -07:00
gwenn
799b5d3f7b Rustfmt 2020-10-04 07:39:35 +02:00
gwenn
d2dcc2d987 Fix clippy warning 2020-10-04 07:38:52 +02:00
Michael Sproul
d7e0536b41
Add must_use attribute to iterators 2020-09-02 16:15:25 +10:00
gwenn
2a7b11320f Fix clippy warnings 2020-08-17 20:07:56 +02:00
gwenn
a4691db6d0 pragma_update fails with ExecuteReturnedResults
Ideally, while executing a batch, we should fail if it contains a SELECT
statement. But currently there is no way to make the distinction between
a SELECT and a PRAGMA which both updates and returns a row.
So we fail only when `extra_check` feature is activated.
2020-08-17 19:30:24 +02:00
Nikhil Benesch
b83d22e2b7 Upgrade to time v0.2 and put it behind a feature flag
This also removes the usage of time in the crate's top-level
documentation example, as was done for the README in #625.

Fix #653.
2020-07-24 11:28:19 -07:00
Tim
83c038107d Fix order of parameters in InvalidParameterCount message
This prints a message like `Error: Wrong number of parameters passed to query. Got 7, needed 8`, but the numbers were the wrong way around - i.e. it should have printed `Got 8, needed 7` in this case.
2020-07-01 08:38:50 -07:00
Thom Chiovoloni
f79a9ca3ef Publically expose Map 2020-06-29 09:36:13 -07:00
gwenn
024e2e6bf0
Merge pull request #773 from gwenn/execute_batch
Implement our own sqlite3_exec
2020-06-28 06:18:56 +02:00
gwenn
dd886578d2 Implement our own sqlite3_exec
Should fix issue related to unlock notify: #767
Caveat: many CString allocated.
2020-06-26 19:35:14 +02:00
gwenn
4114c94585 Clippy 2020-06-26 19:22:20 +02:00
gwenn
57db338537 Rustfmt 2020-06-25 09:45:49 -07:00
gwenn
f37519ad51 Replace execute_batch usages by execute
Because execute_batch does not support unlock_notify
2020-06-25 09:45:49 -07:00
Thom Chiovoloni
1c9e381a21 Clippy fixes 2020-06-07 19:18:46 -07:00
Thom Chiovoloni
f7a573e44a Don't implement Into<RawStatement> for Statement 2020-06-07 19:18:46 -07:00
gwenn
7b08dc9ad5 Try to explain why we need a map function
To tranform the fallible streaming iterator.
2020-06-02 19:05:09 +02:00
gwenn
c577a9d801 Lifetime elision 2020-06-01 18:44:02 +02:00
gwenn
52a80f95f7
Merge pull request #754 from gwenn/phantom_data
Fix some PhantomData declarations
2020-06-01 11:48:02 +02:00
gwenn
265020e589 Fix some PhantomData declarations
Specify the expected type instead of () even if only the lifetime
matters
2020-06-01 10:11:34 +02:00
gwenn
2af75d1f13 VTabCursor lifetime should be bound to VTab lifetime
```c
struct sqlite3_vtab_cursor {
  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
```
It seems that we need to introduce a lifetime on `VTab` trait
to express such constraint:
https://users.rust-lang.org/t/associated-type-with-lifetime-bound/7256
But there may be another/new way to do it.
2020-06-01 09:48:49 +02:00
Evgeniy A. Dushistov
d16748ac9f adding ability to work with sqlite compiled with -DSQLITE_OMIT_DECLTYPE
fix #751
2020-06-01 06:31:27 +03:00
gwenn
8cb5b2e585 Document Rows::map and FallibleStreamingIterator impl
See
https://www.reddit.com/r/rust/comments/gov817/rusqlite_only_getting_ok_entries_from_query_map/
```
let mut stmt = self
    .db
    .prepare("SELECT tag FROM tags WHERE tags.entry_id = ?1")?;

let tags = stmt.query(params![id])?;

tags
    .map(|res| res.get(0))
    .collect()
```
2020-05-24 20:53:52 +02:00
gwenn
e664f82630 Add still missing docs in session module 2020-05-21 00:48:06 -07:00
gwenn
5ebba26a7e Add missing docs in session module 2020-05-21 00:48:06 -07:00
gwenn
76fc22c653 Fix missing docs 2020-05-21 00:48:06 -07:00
Martin Habovstiak
8a08dff115 Clippy reports redundant closures even in cases in which removing the
closure is impossible. See
https://github.com/rust-lang/rust-clippy/issues/5594

Allow this lint until the issue is resolved in clippy or the compiler.
2020-05-21 00:47:52 -07:00
Martin Habovstiak
c5b2efc099 impl TryFrom<&Row<'_>> for (...)
This change implements `TryFrom<&Row>` for tuples up to 16 fields. This
is a convenience function that can be used to map rows more easily.

The change includes tests for 1-tuple, 2-tuple and 16-tuple.
2020-05-21 00:47:52 -07:00
gwenn
5565ae5629
Merge pull request #735 from gwenn/extended_result_codes
Activate extended result codes asap
2020-05-17 09:53:25 +02:00
gwenn
0060ff8a44 Activate extended result codes asap 2020-05-16 11:01:30 +02:00
gwenn
ceb9f11de8 Replace pub(crate) by pub(super) visibilty 2020-05-16 10:18:25 +02:00
Thom Chiovoloni
12cb228c9c Fix SqliteMallocString::from_str on arm32 2020-04-23 13:58:50 -07:00
Thom Chiovoloni
d88fe1c1b1 Remove parameter count caching -- should be cheap (if statically linked at least...) 2020-04-16 12:05:56 -07:00
Thom Chiovoloni
a776f460e8 Cache param count and make statement cache more effective 2020-04-16 12:05:56 -07:00
Thom Chiovoloni
6485b324d7 Name fields of RawStatement 2020-04-16 12:05:56 -07:00
Thom Chiovoloni
1207a7cc06 Make clippy behave slightly more reasonably 2020-04-16 08:21:43 -07:00
Thom Chiovoloni
418ef10af2 Add a wrapper for strings allocated on sqlite heap 2020-04-16 08:21:43 -07:00
Thom Chiovoloni
9322b0e881 Update links & copyright statement 2020-04-15 21:37:39 -07:00
Thom Chiovoloni
45fd77ee43 UnlockNotification should hold mutex when calling condvar 2020-04-15 13:52:19 -07:00
Thom Chiovoloni
c9ef5bd63c Make VTab / VTabCursor unsafe trait as implmenting them on the wrong type is unsound 2020-04-15 10:33:04 -07:00
Thom Chiovoloni
3c6b57fe1b Fix vtab::Module lifetime 2020-04-15 10:33:04 -07:00
Thom Chiovoloni
2327d3b774 Fix format string error in rusqlite::trace::log 2020-04-14 12:23:15 -07:00
Thom Chiovoloni
abbab7216a Better docs and cleaner SmallCString 2020-04-14 10:26:41 -07:00
Thom Chiovoloni
ac30e169ae Use SmallCString in most places 2020-04-14 10:26:41 -07:00
Thom Chiovoloni
552416039e Optimize named params via caching and use of smallvec 2020-04-14 10:26:41 -07:00
Thom Chiovoloni
cf9b6e9ae2 Avoid relying on sqlite to justify str::from_utf8_unchecked 2020-04-14 09:31:29 -07:00
Thom Chiovoloni
1b27ce0541 Docs for new aux api 2020-04-14 08:06:37 -07:00
Thom Chiovoloni
2ef3628dac Actually fix auxdata api... 2020-04-14 08:06:37 -07:00
Thom Chiovoloni
71b2f5187b Ensure type use for auxdata is repr(C) 2020-04-14 08:06:37 -07:00
Thom Chiovoloni
38aea89809 Remove implementations of std::error::Error::description 2020-04-12 12:06:53 -07:00
Thom Chiovoloni
5a8108bd86 Implement source and not cause for FromSqlError 2020-04-12 12:06:53 -07:00
gwenn
611c8e8b02 Rustfmt 2020-04-11 22:18:22 -07:00
gwenn
4dbfdc85fe Fix ValueRef::from_value
Handle text with internal nuls (#657)
2020-04-11 22:18:22 -07:00
Thom Chiovoloni
e04426176f
Merge pull request #693 from thomcc/unchecked-transaction
Allow opting out of compile-time transaction checking
2020-04-10 10:06:37 -07:00
Thom Chiovoloni
d408e3bcd2 Allow opting out of compile-time transaction checking 2020-04-09 12:39:40 -07:00
Konrad Borowski
c8078dfd1f Allow non-Unicode file names on Unix-like platforms 2020-04-09 10:35:38 +02:00
Thom Chiovoloni
ca13698273 Revert "Merge pull request #499 from xfix/unix-invalid-unicode"
This reverts commit 061748e1f5, reversing
changes made to cf3cdecf12.
2020-04-08 10:38:32 -07:00
Thom Chiovoloni
061748e1f5
Merge pull request #499 from xfix/unix-invalid-unicode
Allow non-Unicode file names on Unix-like platforms
2020-04-08 10:30:50 -07:00
Thom Chiovoloni
cf3cdecf12
Merge pull request #684 from thomcc/internal-unsafe
Clean up internal unsafe code
2020-04-08 10:15:03 -07:00
Thom Chiovoloni
f5c20abaa1 Remove unused vtab_v3 feature while I'm here 2020-04-07 14:28:03 -07:00
Thom Chiovoloni
8f7fc7d976 Avoid using MaybeUninit for pointers 2020-04-07 10:04:18 -07:00
Thom Chiovoloni
53c99f940e Fix up conventions around unsafe in internal functions 2020-04-07 10:04:18 -07:00
Thom Chiovoloni
c0df911946
Avoid rust-analyzer bug in InnerConnection::new (#686)
This is a workaround for a false error rust-analyzer gives in
InnerConnection::new. I'm guessing it's because it does some weird
feature stuff. It doesn't change any semantics, but makes working in
`rusqlite` much nicer when using rust-analyzer.
2020-04-07 08:58:41 -07:00
Thom Chiovoloni
5ef73f6c8c
Implement std::error::Error::source instead of cause (#683) 2020-04-06 18:12:22 -07:00
Thom Chiovoloni
76336369ed
Fix regression with <Cow<'_, _> as ToSql> (#681) 2020-04-06 17:00:15 -07:00
Thom Chiovoloni
d35dd0e99f
Allow optionally passing an Error parameter to rusqlite::Result (#678) 2020-04-06 14:43:06 -07:00
Thom Chiovoloni
9b040da029
Add Rows::{mapped,and_then} to get an Iterator out of a Rows i… (#676) 2020-04-06 13:01:39 -07:00
Thom Chiovoloni
0394e114d0
Return an error instead of panicing when parameter count is wron… (#675)
Fixes #671
2020-04-06 12:47:35 -07:00
Thom Chiovoloni
6f6f7ffd9f
Add #[non_exhaustive] to enums that might get new variants. (#673)
This just using them in patterns without a catchall. I left things alone
that seem very unlikely to change (`Value`, `ValueRef`, `DatabaseName`,
etc...). This might help reduce the number of breaking changes we need
(rusqlite is still pre-1.0 so it doesn't really matter that much, but
breaking changes complicate the story around when we can cut releases).
2020-04-06 12:01:39 -07:00
Thom Chiovoloni
3196989f0d
Clarify that the submodules of rusqlite::vtab are ports (#672) 2020-04-06 11:04:45 -07:00
Thom Chiovoloni
0c0d45f714
Add APIs allowing separate parameter binding and statement execu… (#668) 2020-04-06 10:44:00 -07:00