mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-22 17:34:27 +01:00
fix compound select
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::schema::{Index, IndexColumn, Schema};
|
||||
use crate::translate::emitter::{emit_query, LimitCtx, Resolver, TranslateCtx};
|
||||
use crate::translate::emitter::{emit_query, init_limit, LimitCtx, Resolver, TranslateCtx};
|
||||
use crate::translate::expr::translate_expr;
|
||||
use crate::translate::plan::{Plan, QueryDestination, SelectPlan};
|
||||
use crate::translate::result_row::try_fold_expr_to_i64;
|
||||
@@ -133,6 +133,14 @@ fn emit_compound_select(
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
let compound_select_end = program.allocate_label();
|
||||
if let Some(limit_ctx) = &limit_ctx {
|
||||
program.emit_insn(Insn::IfNot {
|
||||
reg: limit_ctx.reg_limit,
|
||||
target_pc: compound_select_end,
|
||||
jump_if_null: false,
|
||||
});
|
||||
}
|
||||
let mut right_most_ctx = TranslateCtx::new(
|
||||
program,
|
||||
schema,
|
||||
@@ -359,6 +367,8 @@ fn emit_compound_select(
|
||||
}
|
||||
}
|
||||
|
||||
program.preassign_label_to_next_insn(compound_select_end);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1726,7 +1726,7 @@ pub fn emit_cdc_insns(
|
||||
/// Initialize the limit/offset counters and registers.
|
||||
/// In case of compound SELECTs, the limit counter is initialized only once,
|
||||
/// hence [LimitCtx::initialize_counter] being false in those cases.
|
||||
fn init_limit(
|
||||
pub fn init_limit(
|
||||
program: &mut ProgramBuilder,
|
||||
t_ctx: &mut TranslateCtx,
|
||||
limit: &Option<Box<Expr>>,
|
||||
|
||||
Reference in New Issue
Block a user