From 49bbae9455b6f3b408f4f6cfd3603da43497a2b6 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Tue, 31 Dec 2024 12:42:48 +0200 Subject: [PATCH] post rebase nuclear fallout --- core/lib.rs | 2 +- core/translate/emitter.rs | 6 ++---- core/translate/planner.rs | 35 ++++++++++++++++++++++------------- core/translate/select.rs | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/core/lib.rs b/core/lib.rs index 54609d6dc..d2461cc07 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -270,7 +270,7 @@ impl Connection { Cmd::ExplainQueryPlan(stmt) => { match stmt { ast::Stmt::Select(select) => { - let mut plan = prepare_select_plan(&*self.schema.borrow(), select)?; + let mut plan = prepare_select_plan(&self.schema.borrow(), select)?; optimize_plan(&mut plan)?; println!("{}", plan); } diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index 42e3915b0..60fbf5a96 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -311,7 +311,7 @@ fn emit_subquery(program: &mut ProgramBuilder, plan: &mut SelectPlan) -> Result< let subquery_body_end_label = program.allocate_label(); program.emit_insn_with_label_dependency( Insn::InitCoroutine { - yield_reg: yield_reg, + yield_reg, jump_on_definition: subquery_body_end_label, start_offset: coroutine_implementation_start_offset, }, @@ -328,9 +328,7 @@ fn emit_subquery(program: &mut ProgramBuilder, plan: &mut SelectPlan) -> Result< } let result_column_start_reg = emit_query(program, plan, &mut metadata)?; program.resolve_label(end_coroutine_label, program.offset()); - program.emit_insn(Insn::EndCoroutine { - yield_reg: yield_reg, - }); + program.emit_insn(Insn::EndCoroutine { yield_reg }); program.resolve_label(subquery_body_end_label, program.offset()); Ok(result_column_start_reg) } diff --git a/core/translate/planner.rs b/core/translate/planner.rs index 8e28fc414..73728354d 100644 --- a/core/translate/planner.rs +++ b/core/translate/planner.rs @@ -1,7 +1,5 @@ use super::{ - plan::{ - Aggregate, Plan, SelectQueryType, SourceOperator, TableReference, TableReferenceType, - }, + plan::{Aggregate, Plan, SelectQueryType, SourceOperator, TableReference, TableReferenceType}, select::prepare_select_plan, }; use crate::{ @@ -310,7 +308,7 @@ fn parse_from_clause_table( table_reference.clone(), SourceOperator::Subquery { id: operator_id_counter.get_next_id(), - table_reference: table_reference, + table_reference, plan: Box::new(subplan), predicates: None, }, @@ -342,8 +340,12 @@ pub fn parse_from( table_index += 1; for join in joins_owned.into_iter() { - let (right, outer, using, predicates) = - parse_join(schema, join, operator_id_counter, &mut tables, table_index)?; + let JoinParseResult { + source_operator: right, + is_outer_join: outer, + using, + predicates, + } = parse_join(schema, join, operator_id_counter, &mut tables, table_index)?; operator = SourceOperator::Join { left: Box::new(operator), right: Box::new(right), @@ -374,18 +376,20 @@ pub fn parse_where( } } +struct JoinParseResult { + source_operator: SourceOperator, + is_outer_join: bool, + using: Option, + predicates: Option>, +} + fn parse_join( schema: &Schema, join: ast::JoinedSelectTable, operator_id_counter: &mut OperatorIdCounter, tables: &mut Vec, table_index: usize, -) -> Result<( - SourceOperator, - bool, - Option, - Option>, -)> { +) -> Result { let ast::JoinedSelectTable { operator: join_operator, table, @@ -524,7 +528,12 @@ fn parse_join( } } - Ok((source_operator, outer, using, predicates)) + Ok(JoinParseResult { + source_operator, + is_outer_join: outer, + using, + predicates, + }) } pub fn parse_limit(limit: Limit) -> Option { diff --git a/core/translate/select.rs b/core/translate/select.rs index 326371d1a..cdd3ea8d9 100644 --- a/core/translate/select.rs +++ b/core/translate/select.rs @@ -29,7 +29,7 @@ pub fn translate_select( emit_program(database_header, select_plan, connection) } -pub fn prepare_select_plan<'a>(schema: &Schema, select: ast::Select) -> Result { +pub fn prepare_select_plan(schema: &Schema, select: ast::Select) -> Result { match select.body.select { ast::OneSelect::Select { columns,