Fix accumulator reset when arguments outnumber aggregates

Previously, while resetting accumulator registers, we would also
reset subsequent registers. This happened because the number of registers
to reset was computed as the sum of arguments rather than the number of
aggregate functions.
This commit is contained in:
Piotr Rzysko
2025-09-06 05:36:03 +02:00
parent 6224cdbbd3
commit 110ffba2a1
2 changed files with 19 additions and 1 deletions

View File

@@ -308,3 +308,21 @@ shirt
shorts
sweater
sweatshirt}
# There was a bug where, while resetting accumulator registers, subsequent registers were also reset.
# This happened when there were more arguments than aggregate functions — the number of registers to reset
# was calculated as the sum of the arguments, not the number of aggregates.
# The issue affected cases where rows were pre-sorted, hence the 'GROUP BY id' test.
do_execsql_test more_args_than_aggregates {
SELECT group_concat(name, ','), group_concat(name, ';'), group_concat(name, '.') FROM products GROUP BY id;
} {hat|hat|hat
cap|cap|cap
shirt|shirt|shirt
sweater|sweater|sweater
sweatshirt|sweatshirt|sweatshirt
shorts|shorts|shorts
jeans|jeans|jeans
sneakers|sneakers|sneakers
boots|boots|boots
coat|coat|coat
accessories|accessories|accessories}