Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow binding of text/blobs without SQLITE_TRANSIENT? #164

Open
jgallagher opened this issue May 26, 2016 · 4 comments
Open

Allow binding of text/blobs without SQLITE_TRANSIENT? #164

jgallagher opened this issue May 26, 2016 · 4 comments

Comments

@jgallagher
Copy link
Contributor

jgallagher commented May 26, 2016

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.)

@jgallagher
Copy link
Contributor Author

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.

@obsgolem
Copy link

obsgolem commented Dec 8, 2022

Note that ToSqlOutput::Owned Strings and Boxs 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.

@gwenn
Copy link
Collaborator

gwenn commented Dec 8, 2022

Vec::into_boxed_slice / String::into_boxed_str + Box::into_raw / drop(Box::from_raw)

@gwenn
Copy link
Collaborator

gwenn commented Dec 9, 2022

To be fixed here:

rusqlite/src/statement.rs

Lines 730 to 732 in 51a69b1

ToSqlOutput::Borrowed(v) => v,
ToSqlOutput::Owned(ref v) => ValueRef::from(v),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants