mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:22:08 +00:00
LibSQL: Store a NonnullRefPtr to the table definition in SQL::Row
Also return a direct reference to the table from its getter.
This commit is contained in:
parent
5336f23c7e
commit
6d3f68cc11
3 changed files with 13 additions and 12 deletions
|
@ -199,25 +199,25 @@ ErrorOr<Vector<Row>> Database::match(TableDef const& table, Key const& key)
|
|||
|
||||
ErrorOr<void> Database::insert(Row& row)
|
||||
{
|
||||
VERIFY(m_table_cache.get(row.table()->key().hash()).has_value());
|
||||
VERIFY(m_table_cache.get(row.table().key().hash()).has_value());
|
||||
// TODO Check constraints
|
||||
|
||||
row.set_pointer(m_heap->new_record_pointer());
|
||||
row.set_next_pointer(row.table()->pointer());
|
||||
row.set_next_pointer(row.table().pointer());
|
||||
TRY(update(row));
|
||||
|
||||
// TODO update indexes defined on table.
|
||||
|
||||
auto table_key = row.table()->key();
|
||||
auto table_key = row.table().key();
|
||||
table_key.set_pointer(row.pointer());
|
||||
VERIFY(m_tables->update_key_pointer(table_key));
|
||||
row.table()->set_pointer(row.pointer());
|
||||
row.table().set_pointer(row.pointer());
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Database::update(Row& tuple)
|
||||
{
|
||||
VERIFY(m_table_cache.get(tuple.table()->key().hash()).has_value());
|
||||
VERIFY(m_table_cache.get(tuple.table().key().hash()).has_value());
|
||||
// TODO Check constraints
|
||||
m_serializer.reset();
|
||||
m_serializer.serialize_and_write<Tuple>(tuple);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue