mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-27 11:54:30 +01:00
Handle limit zero case in query plan emitter
This commit is contained in:
@@ -180,12 +180,13 @@ fn emit_program_for_select(
|
||||
if let Some(limit) = plan.limit {
|
||||
if limit == 0 {
|
||||
epilogue(program, init_label, start_offset)?;
|
||||
program.result_columns = plan.result_columns;
|
||||
program.table_references = plan.table_references;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
// Emit main parts of query
|
||||
emit_query(program, &mut plan, &mut t_ctx)?;
|
||||
|
||||
// Finalize program
|
||||
epilogue(program, init_label, start_offset)?;
|
||||
program.result_columns = plan.result_columns;
|
||||
@@ -302,6 +303,14 @@ fn emit_program_for_delete(
|
||||
plan.result_columns.len(),
|
||||
)?;
|
||||
|
||||
// exit early if LIMIT 0
|
||||
if let Some(0) = plan.limit {
|
||||
epilogue(program, init_label, start_offset)?;
|
||||
program.result_columns = plan.result_columns;
|
||||
program.table_references = plan.table_references;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// No rows will be read from source table loops if there is a constant false condition eg. WHERE 0
|
||||
let after_main_loop_label = program.allocate_label();
|
||||
t_ctx.label_main_loop_end = Some(after_main_loop_label);
|
||||
|
||||
Reference in New Issue
Block a user