MDEV-40779 Evaluate HAVING on completed groups before DISTINCT #5776
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.34) × (1 − Review Confidence (0.92)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.34 · 50 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.96 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.235
Real PR Conversation Timeline
5 items
Is all of the above relevant to the test case? The original bug report had no charset or SQL modes etc.
Also, do you really need to create a database?
I'd suggest sticking to the minimal test case.
Thank you for your contribution! This is a preliminary review.
Very close, but I'd like to see a clearer test case before I approve it.
Changes Requested
Requested changes.
Approved
LGTM. Thanks. Please stand by for the final review.
gkodinov
DerZc
HAVING can read stale aggregate and field values when grouped rows are
copied into a second temporary table for DISTINCT. Rechecking the condition
during duplicate removal can discard qualifying rows.
Bind HAVING to the stored values of the completed groups. Evaluate it while
writing the DISTINCT table, and avoid attaching or evaluating it again
against that table.
Bug report: https://jira.mariadb.org/browse/MDEV-40779
Regression coverage
Reduce the addition to
main.func_groupfrom 67 lines to five: an issueheader, table creation, three input rows, one query and cleanup. Two groups
satisfy HAVING and produce the same output; a third group fails HAVING. The
expected DISTINCT result is one row,
(2, 2).Remove the extra InnoDB include, session settings, separate database,
sorting directives, equivalent query variants and manual prepared statements.
The original source fix and existing test contents are preserved.
Validation
On current
11.4atf49e838d367f2154b3edb43effa99ff9eb0d8602:main.func_grouponly because thenew query returns no rows instead of
(2, 2).main.func_group,main.group_by,main.having,main.select,main.distinctandmain.view.main.func_grouppasses with the view protocol.with the prepared-statement protocol, including its automatic repeated
SELECT execution. The existing full
main.func_grouptest disables thatprotocol at its start.