mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-10 02:34:20 +01:00
Add registers for offset and sum of limit and offset
This commit is contained in:
@@ -68,6 +68,10 @@ pub struct TranslateCtx<'a> {
|
||||
pub reg_result_cols_start: Option<usize>,
|
||||
// The register holding the limit value, if any.
|
||||
pub reg_limit: Option<usize>,
|
||||
// The register holding the offset value, if any.
|
||||
pub reg_offset: Option<usize>,
|
||||
// The register holding the limit+offset value, if any.
|
||||
pub reg_limit_offset_sum: Option<usize>,
|
||||
// metadata for the group by operator
|
||||
pub meta_group_by: Option<GroupByMetadata>,
|
||||
// metadata for the order by operator
|
||||
@@ -111,6 +115,8 @@ fn prologue<'a>(
|
||||
label_main_loop_end: None,
|
||||
reg_agg_start: None,
|
||||
reg_limit: None,
|
||||
reg_offset: None,
|
||||
reg_limit_offset_sum: None,
|
||||
reg_result_cols_start: None,
|
||||
meta_group_by: None,
|
||||
meta_left_joins: HashMap::new(),
|
||||
@@ -200,6 +206,14 @@ pub fn emit_query<'a>(
|
||||
t_ctx.reg_limit = plan.limit.map(|_| program.alloc_register());
|
||||
}
|
||||
|
||||
if t_ctx.reg_offset.is_none() {
|
||||
t_ctx.reg_offset = plan.offset.map(|_| program.alloc_register());
|
||||
}
|
||||
|
||||
if t_ctx.reg_limit_offset_sum.is_none() {
|
||||
t_ctx.reg_limit_offset_sum = plan.offset.map(|_| program.alloc_register());
|
||||
}
|
||||
|
||||
// No rows will be read from source table loops if there is a constant false condition eg. WHERE 0
|
||||
// however an aggregation might still happen,
|
||||
// e.g. SELECT COUNT(*) WHERE 0 returns a row with 0, not an empty result set
|
||||
|
||||
@@ -97,6 +97,8 @@ pub fn emit_subquery<'a>(
|
||||
result_column_indexes_in_orderby_sorter: HashMap::new(),
|
||||
result_columns_to_skip_in_orderby_sorter: None,
|
||||
reg_limit: plan.limit.map(|_| program.alloc_register()),
|
||||
reg_offset: plan.offset.map(|_| program.alloc_register()),
|
||||
reg_limit_offset_sum: plan.offset.map(|_| program.alloc_register()),
|
||||
resolver: Resolver::new(t_ctx.resolver.symbol_table),
|
||||
};
|
||||
let subquery_body_end_label = program.allocate_label();
|
||||
|
||||
Reference in New Issue
Block a user