mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibSQL: Immediately commit database modifications (for now)
This ensures tables survive the database connection quitting. LibSQL does not have transactional sessions yet, and probably won't for a while, so let's just commit each modification as it comes.
This commit is contained in:
parent
8f3c22718e
commit
17988bab75
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/17988bab75 Pull-request: https://github.com/SerenityOS/serenity/pull/16239 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/linusg
|
@ -14,7 +14,12 @@ namespace SQL::AST {
|
|||
ResultOr<ResultSet> Statement::execute(AK::NonnullRefPtr<Database> database) const
|
||||
{
|
||||
ExecutionContext context { move(database), this, nullptr };
|
||||
return execute(context);
|
||||
auto result = TRY(execute(context));
|
||||
|
||||
// FIXME: When transactional sessions are supported, don't auto-commit modifications.
|
||||
TRY(context.database->commit());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,17 +66,7 @@ ErrorOr<void> Database::open()
|
|||
return {};
|
||||
}
|
||||
|
||||
Database::~Database()
|
||||
{
|
||||
// This crashes if the database can't commit. It's recommended to commit
|
||||
// before the Database goes out of scope so the application can handle
|
||||
// errors.
|
||||
// Maybe we should enforce that by having a VERIFY here that there are no
|
||||
// pending writes. But that's a new API on Heap so let's not do that right
|
||||
// now.
|
||||
if (is_open())
|
||||
MUST(commit());
|
||||
}
|
||||
Database::~Database() = default;
|
||||
|
||||
ErrorOr<void> Database::commit()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue