Skip to content

Conversation

@paulfitz
Copy link
Member

@paulfitz paulfitz commented Mar 8, 2022

This extends db.configure to support the sqlite3_limit method.

Calling db.configure('limit', sqlite3.LIMIT_XXX, value) is now equivalent to calling sqlite3_limit(db, SQLITE_LIMIT_XXX, value). For example, to prohibit attaching extra databases on a given database connection, you'd call db.configure('limit', sqlite3.LIMIT_ATTACHED, 0). The list of possible limits is taken from https://www.sqlite.org/c3ref/c_limit_attached.html

This is useful for selectively reducing limits. It cannot increase limits set at compile-time.

Filed upstream at TryGhost#1548

paulfitz added 2 commits March 8, 2022 15:00
This extends `db.configure` to support the `sqlite3_limit` method.
Calling `db.configure('limit', sqlite3.LIMIT_XXX, value)` is equivalent to
calling `sqlite3_limit(db, SQLITE_LIMIT_XXX, value)`.

For example, to prohibit attaching extra databases on a given database
connection, you'd call `db.configure('limit', sqlite3.LIMIT_ATTACHED, 0)`.
}

void Database::SetLimit(Baton* b) {
std::unique_ptr<LimitBaton> baton(static_cast<LimitBaton*>(b));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, modern C++ (i.e. from 21st century)! Looks good to me, but I don't see it used elsewhere, so wouldn't be surprised if it gets frowned upon upstream in case they are trying to support some old C++ compilers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is actually me matching the latest style upstream, they've started putting this everywhere.

@paulfitz paulfitz merged commit dc6ec98 into grist-main Mar 9, 2022
@paulfitz paulfitz deleted the enable-sqlite3-limit branch March 9, 2022 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants