Skip to content

Commit

Permalink
post rebase nuclear fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
jussisaurio committed Dec 31, 2024
1 parent 9364dfe commit 49bbae9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions core/translate/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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)
}
Expand Down
35 changes: 22 additions & 13 deletions core/translate/planner.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -374,18 +376,20 @@ pub fn parse_where(
}
}

struct JoinParseResult {
source_operator: SourceOperator,
is_outer_join: bool,
using: Option<ast::DistinctNames>,
predicates: Option<Vec<ast::Expr>>,
}

fn parse_join(
schema: &Schema,
join: ast::JoinedSelectTable,
operator_id_counter: &mut OperatorIdCounter,
tables: &mut Vec<TableReference>,
table_index: usize,
) -> Result<(
SourceOperator,
bool,
Option<ast::DistinctNames>,
Option<Vec<ast::Expr>>,
)> {
) -> Result<JoinParseResult> {
let ast::JoinedSelectTable {
operator: join_operator,
table,
Expand Down Expand Up @@ -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<usize> {
Expand Down
2 changes: 1 addition & 1 deletion core/translate/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Plan> {
pub fn prepare_select_plan(schema: &Schema, select: ast::Select) -> Result<Plan> {
match select.body.select {
ast::OneSelect::Select {
columns,
Expand Down

0 comments on commit 49bbae9

Please sign in to comment.