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

Add SqliteDatabase::executeWithRegulator #2054

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

justin-mp
Copy link
Contributor

There are sqlite3 API functions that may prepare and execute their own internal statements. We need to call those functions with a regulator or we’ll summarily reject them. Adding a method to do this seemed like a clean way of handling these cases.

@justin-mp justin-mp requested review from a team as code owners April 24, 2024 14:54
There are `sqlite3` API functions that may prepare and execute their
own internal statements.  We need to call those functions with a
regulator or we’ll summarily reject them.  Adding a method to do this
seemed like a clean way of handling these cases.
@justin-mp justin-mp force-pushed the jmp/sqlite-executeWithRegulator branch from 1942089 to 5ff0c59 Compare April 25, 2024 10:42
@justin-mp
Copy link
Contributor Author

@justin-mp justin-mp requested a review from smerritt April 25, 2024 19:33
@@ -94,6 +94,9 @@ class SqliteDatabase {
// that was not processed. This is used for streaming SQL ingestion.
kj::StringPtr ingestSql(Regulator& regulator, kj::StringPtr sqlCode);

// Execute a function with the given regulator.
void executeWithRegulator(Regulator& regulator, kj::FunctionParam<void()> func);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good, but I've got one brain cell that won't quit screaming about something like

template <typename Ret, typename... Params>
Ret executeWithRegulator(Regulator& regulator, kj::FunctionParam<Ret(Params...)> func, Params... params) {
// ...
return func(kj::fwd<Params>(params)...);

Let's ignore that brain cell, though, since we can go back and generalize this later if we need to. YAGNI, blah blah blah.

@justin-mp justin-mp merged commit c150442 into main Apr 26, 2024
10 checks passed
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