rusqlite
rusqlite copied to clipboard
Allow binding of text/blobs without SQLITE_TRANSIENT?
Currently, we always pass the SQLITE_TRANSIENT
flag when binding a text or blob parameter, instructing SQLite to make its own copy of the data. It would be nice to be able to avoid that copy if we can come up with a safe interface that allows it. (Initially discussed on #162.)
If we merge #163, we'll know from the ToSqlOutput
case if SQLITE_TRANSIENT
is definitely required (if we get a ToSqlOutput::Owned
, the value will be dropped immediately after it's bound). If we get a ToSqlOutput::Borrowed
, it's conceivably safe to use SQLITE_STATIC
if we can structure the API in such a way as to know the parameter(s) will still be alive when the query is executed.
Note that ToSqlOutput::Owned
String
s and Box
s could conceivably be handled by passing in a deleter function pointer to Sqlite, thus allowing us to avoid a copy in the owned case as well.
Vec::into_boxed_slice
/ String::into_boxed_str
+ Box::into_raw
/ drop(Box::from_raw)
To be fixed here: https://github.com/rusqlite/rusqlite/blob/51a69b1b7487aa41786570ed95abc2699ac02c1e/src/statement.rs#L730-L732