Skip to content

Backport to 2.28.x: #10209: Fix potential incorrect stddev(float8/4) in columnar pipeline - #10269

Merged
timescale-automation merged 1 commit into
2.28.xfrom
backport/2.28.x/10209
Jul 16, 2026
Merged

Backport to 2.28.x: #10209: Fix potential incorrect stddev(float8/4) in columnar pipeline#10269
timescale-automation merged 1 commit into
2.28.xfrom
backport/2.28.x/10209

Conversation

@timescale-automation

Copy link
Copy Markdown
Member

This is an automated backport of #10209: Fix potential incorrect stddev(float8/4) in columnar pipeline.
The original issue is #10203.
This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.

For more details, please see the documentation

Original description

Fix potential incorrect stddev(float8/4) in columnar pipeline

Postgres uses the same float8_accum transition function for both avg() and stddev() for these types. TimescaleDB used to use a simplified implementation for avg(), because it doesn't require tracking sum of squares. However, Postgres uses a shared transition state for aggregates sharing a transition functions, as given by AggRef.aggtransno. This leads to potentially wrong result when both avg() and stddev() of same variable are computed in one query.

Change the aggregation states in columnar aggregation to follow aggtransno. Remove the "float8 accum with no squares" implementation because it cannot be safely used in general case, and checking for special cases is complicated.

Fixes #10203

Postgres uses the same float8_accum transition function for both avg()
and stddev() for these types. TimescaleDB used to use a simplified
implementation for avg(), because it doesn't require tracking sum of
squares. However, Postgres uses a shared transition state for aggregates
sharing a transition functions, as given by AggRef.aggtransno. This
leads to potentially wrong result when both avg() and stddev() of same
variable are computed in one query.

Change the aggregation states in columnar aggregation to follow
aggtransno. Remove the "float8 accum with no squares" implementation
because it cannot be safely used in general case, and checking for
special cases is complicated.

(cherry picked from commit 58e9840)
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/nodes/vector_agg/function/float48_accum_single.c 66.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@timescale-automation
timescale-automation merged commit 7cfc9bb into 2.28.x Jul 16, 2026
69 of 72 checks passed
@timescale-automation
timescale-automation deleted the backport/2.28.x/10209 branch July 16, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

is-auto-backport PR created by backport automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants