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

Support SQLITE_LIMIT_* Run-Time Limit #3522

Open
RinCat opened this issue Sep 25, 2024 · 2 comments
Open

Support SQLITE_LIMIT_* Run-Time Limit #3522

RinCat opened this issue Sep 25, 2024 · 2 comments
Labels
db:sqlite Related to SQLite enhancement New feature or request

Comments

@RinCat
Copy link

RinCat commented Sep 25, 2024

Is your feature request related to a problem? Please describe.
I try to change the Sqlite Run-Time Limit , but found no way to do it in sqlx.

Describe the solution you'd like
It should able to set in sqlite::SqliteConnectOptions or other place like .limit(SQLITE_LIMIT_ATTACHED, 0)

Describe alternatives you've considered
I don't think I can call sqlite3_limit() directly.

Additional context
N/A

@RinCat RinCat added the enhancement New feature or request label Sep 25, 2024
@abonander abonander added the db:sqlite Related to SQLite label Sep 25, 2024
@abonander
Copy link
Collaborator

abonander commented Sep 25, 2024

There are two ways you could do this right now:

You can pass the flags at compile time with an environment variable: https://github.com/rusqlite/rusqlite?tab=readme-ov-file#notes-on-building-rusqlite-and-libsqlite3-sys

export LIBSQLITE3_FLAGS="-DSQLITE_MAX_LENGTH=123456789 -DSQLITE_MAX_COLUMN=100"

cargo build

You can put this in a .cargo/config.toml file in your project so it's always added: https://doc.rust-lang.org/cargo/reference/config.html#env

[env]
LIBSQLITE3_FLAGS="-DSQLITE_MAX_LENGTH=123456789 -DSQLITE_MAX_COLUMN=100"

Or you can call .lock_handle().await? on the connection: https://docs.rs/sqlx/latest/sqlx/struct.SqliteConnection.html#method.lock_handle

Which gives you direct access to the sqlite3* pointer: https://docs.rs/sqlx/latest/sqlx/sqlite/struct.LockedSqliteHandle.html#method.as_raw_handle

And then import libsqlite3-sys and call sqlite3_limit() yourself. Note that the version needs to match that used by SQLx: https://docs.rs/sqlx/latest/sqlx/sqlite/index.html#note-linkage-is-semver-exempt


I could see putting a nicer API on this, but I'd need to think about what that should look like and where it should go. I would probably put it on SqliteConnectOptions.

@RinCat
Copy link
Author

RinCat commented Sep 25, 2024

Thanks, I will use the LIBSQLITE3_FLAGS for now. Looking forward to the APIs. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db:sqlite Related to SQLite enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants