mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +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
2 changed files with 7 additions and 12 deletions
|
@ -14,7 +14,12 @@ namespace SQL::AST {
|
||||||
ResultOr<ResultSet> Statement::execute(AK::NonnullRefPtr<Database> database) const
|
ResultOr<ResultSet> Statement::execute(AK::NonnullRefPtr<Database> database) const
|
||||||
{
|
{
|
||||||
ExecutionContext context { move(database), this, nullptr };
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::~Database()
|
Database::~Database() = default;
|
||||||
{
|
|
||||||
// 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Database::commit()
|
ErrorOr<void> Database::commit()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue