Add sorter utility functions and opcodes

This adds basic in-memory sorting utility functions, similar to SQLite's
src/vdbesort.c. We need to improve this later with external sorting so
to support large data sets.

This also adds sorting functionality to the VDBE. Note that none of this
is wired to SQL translation yet so it's unused for now.
This commit is contained in:
Pekka Enberg 2024-07-07 13:43:49 +03:00
parent dac8f4dcba
commit 30ec86a81e
9 changed files with 525 additions and 95 deletions

View file

@ -4,6 +4,7 @@ mod function;
mod io;
mod pager;
mod schema;
mod sorter;
mod sqlite3_ondisk;
mod storage;
mod translate;
@ -70,8 +71,8 @@ impl Database {
}
let root_page: i64 = row.get::<i64>(3)?;
let sql: String = row.get::<String>(4)?;
let table = schema::Table::from_sql(&sql, root_page as usize)?;
schema.add_table(table);
let table = schema::BTreeTable::from_sql(&sql, root_page as usize)?;
schema.add_table(Rc::new(table));
}
RowResult::IO => {
// TODO: How do we ensure that the I/O we submitted to