Skip to content

Add SqliteDatabase::executeWithRegulator - #2054

Merged
justin-mp merged 1 commit into
mainfrom
jmp/sqlite-executeWithRegulator
Apr 26, 2024
Merged

Add SqliteDatabase::executeWithRegulator#2054
justin-mp merged 1 commit into
mainfrom
jmp/sqlite-executeWithRegulator

Conversation

@justin-mp

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

@justin-mp
justin-mp requested a review from smerritt April 25, 2024 19:33
Comment thread src/workerd/util/sqlite.h
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
Copy Markdown
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
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