mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-24 18:34:34 +01:00
core: fix initialization of sum vdbe
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
This commit is contained in:
16
core/vdbe.rs
16
core/vdbe.rs
@@ -369,10 +369,15 @@ impl Program {
|
||||
},
|
||||
Insn::AggStep { acc_reg, col, func } => {
|
||||
if let OwnedValue::Null = &state.registers[*acc_reg] {
|
||||
state.registers[*acc_reg] = OwnedValue::Agg(Box::new(AggContext::Avg(
|
||||
OwnedValue::Float(0.0),
|
||||
OwnedValue::Integer(0),
|
||||
)));
|
||||
state.registers[*acc_reg] = match func {
|
||||
AggFunc::Avg => OwnedValue::Agg(Box::new(AggContext::Avg(
|
||||
OwnedValue::Float(0.0),
|
||||
OwnedValue::Integer(0),
|
||||
))),
|
||||
AggFunc::Sum => {
|
||||
OwnedValue::Agg(Box::new(AggContext::Sum(OwnedValue::Float(0.0))))
|
||||
}
|
||||
};
|
||||
}
|
||||
match func {
|
||||
AggFunc::Avg => {
|
||||
@@ -393,11 +398,10 @@ impl Program {
|
||||
else {
|
||||
unreachable!();
|
||||
};
|
||||
let AggContext::Avg(acc, count) = agg.borrow_mut() else {
|
||||
let AggContext::Sum(acc) = agg.borrow_mut() else {
|
||||
unreachable!();
|
||||
};
|
||||
*acc += col;
|
||||
*count += 1;
|
||||
}
|
||||
};
|
||||
state.pc += 1;
|
||||
|
||||
Reference in New Issue
Block a user