core: Move Select struct at the top of select.rs

It's the main data structure of the file so let's make it the first one.
This commit is contained in:
Pekka Enberg
2024-07-25 17:27:45 +03:00
parent fcc087b85c
commit b2f47746a9

View File

@@ -19,6 +19,26 @@ use crate::{function::Func, schema::Table, vdbe::BranchOffset};
use super::SortInfo;
pub struct Select<'a> {
pub columns: &'a Vec<ast::ResultColumn>,
pub column_info: Vec<ColumnInfo<'a>>,
pub src_tables: Vec<SrcTable<'a>>, // Tables we use to get data from. This includes "from" and "joins"
pub limit: &'a Option<ast::Limit>,
pub order_by: &'a Option<Vec<ast::SortedColumn>>,
pub exist_aggregation: bool,
pub where_clause: &'a Option<ast::Expr>,
/// Ordered list of opened read table loops
/// Used for generating a loop that looks like this:
/// cursor 0 = open table 0
/// for each row in cursor 0
/// cursor 1 = open table 1
/// for each row in cursor 1
/// ...
/// end cursor 1
/// end cursor 0
pub loops: Vec<LoopInfo>,
}
#[derive(Debug)]
pub struct SrcTable<'a> {
pub table: Table,
@@ -91,26 +111,6 @@ pub struct LoopInfo {
pub open_cursor: usize,
}
pub struct Select<'a> {
pub columns: &'a Vec<ast::ResultColumn>,
pub column_info: Vec<ColumnInfo<'a>>,
pub src_tables: Vec<SrcTable<'a>>, // Tables we use to get data from. This includes "from" and "joins"
pub limit: &'a Option<ast::Limit>,
pub order_by: &'a Option<Vec<ast::SortedColumn>>,
pub exist_aggregation: bool,
pub where_clause: &'a Option<ast::Expr>,
/// Ordered list of opened read table loops
/// Used for generating a loop that looks like this:
/// cursor 0 = open table 0
/// for each row in cursor 0
/// cursor 1 = open table 1
/// for each row in cursor 1
/// ...
/// end cursor 1
/// end cursor 0
pub loops: Vec<LoopInfo>,
}
pub fn build_select<'a>(schema: &Schema, select: &'a ast::Select) -> Result<Select<'a>> {
match &select.body.select {
ast::OneSelect::Select {