Make possible to pass your own pointers#1626
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1626 +/- ##
==========================================
+ Coverage 87.96% 88.02% +0.06%
==========================================
Files 58 58
Lines 10648 10733 +85
==========================================
+ Hits 9366 9448 +82
- Misses 1282 1285 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Does SQLite need to take ownership of the pointer (i.e. can this be made to use a slice ref instead of an owning vec/box)? That would remove the need to deallocate altogether. Alternatively, a vector of tuples of |
|
Currently, you cannot retrieve the |
| &self, | ||
| idx: usize, | ||
| ptr_type: &'static CStr, | ||
| ) -> Option<&T> { |
There was a problem hiding this comment.
@gwenn : I think here you need to return Option<Rc<T>> not Option<&T> (compare to https://github.com/rusqlite/rusqlite/pull/1799/changes#diff-dff5ca49e95ff5abfe972cd64b09632f0d9c9116db60599f2f9f0af44985e1a0R948).
Overall I think my implementation has trended closer towards yours (e.g. my ValuePointer type is equivalent to your anonymous tuple here.
One thing I ended up with in my branch was a nicer type that custom modules should use, PointerType. Ultimately this just converts to the lower-level representation. But the high-level type is used as part of the API for get_pointer see here.
You may also be interested in the example custom module I implemented here.
I think we can probably consolidate the work in the two branches, or / consolidate into your PR.
There was a problem hiding this comment.
I think here you need to return
Option<Rc<T>>notOption<&T>
We don't: see c9b7637#diff-dff5ca49e95ff5abfe972cd64b09632f0d9c9116db60599f2f9f0af44985e1a0R930
There was a problem hiding this comment.
One thing I ended up with in my branch was a nicer type that custom modules should use, PointerType.
See TypeId
There was a problem hiding this comment.
This is neat! I was unaware of sqlite_ext. Given that exists, why not use that directly or directly borrow that API?
There was a problem hiding this comment.
This is neat! I was unaware of sqlite_ext. Given that exists, why not use that directly or directly borrow that API?
You should be able to port PassedRef (which uses a Box instead of Rc) based on this PR.
See
https://github.com/CGamesPlay/sqlite3_ext/blob/7e5b44dbe959fe05e5dd11f5d0901bb68bfe3b74/src/query/params.rs#L259
https://github.com/CGamesPlay/sqlite3_ext/blob/7e5b44dbe959fe05e5dd11f5d0901bb68bfe3b74/src/function/context.rs#L331
There was a problem hiding this comment.
There seems to be no safe way to serialize a TypeId as a CStr (ptr_type).
See #1602, #1475, #1497
Box/Rc/Arc