Skip to content

Bug#120641: Preserve FLOAT string formatting through ANY_VALUE - #791

Closed
DerZc wants to merge 1 commit into
mysql:trunkfrom
DerZc:fix-bug-120641
Closed

DerZc wants to merge 1 commit into
mysql:trunkfrom
DerZc:fix-bug-120641

Conversation

@DerZc

@DerZc DerZc commented Sep 28, 2026

Copy link
Copy Markdown

What does this change do?

Condition pushdown replaces a materialized FLOAT field with its expression. Return the argument's FLOAT string representation from ANY_VALUE so this replacement preserves string-comparison results and NULL state.

Bug report: https://bugs.mysql.com/bug.php?id=120641

Why is it needed?

The affected execution path returns a different query result from the equivalent reference. The change preserves the expression or access-path semantics described above.

How was it tested?

On trunk at a1ef44f1d327b940a763b25eee2c6e146a0ebdb0:

  • The unmodified server fails the new regression with a result mismatch.

  • The patched server builds successfully.

  • 16 query-result checks pass against separately established expected results, including repeated prepared statements.

  • Native MTR passes: main.bug_120641, main.select_count, main.type_float, main.group_by.

  • The regression passes with the prepared-statement protocol.

  • The full database regression suite was not run.

  • Added MTR coverage under mysql-test/.

  • Ran scripts/ci/mtr.sh with its default selection; the explicit native and related tests above were run instead.

  • Ran the full database regression suite.

Contributor checklist

  • Changed C++ files are formatted with the repository .clang-format.
  • One focused commit with a descriptive message.

AI assistance

  • I did not use AI assistance for this contribution.
  • I used AI assistance for this contribution.

OpenAI Codex assisted with implementation, regression test generation and review. The submitted change was checked with compilation, execution against independently established expected results, a failing unpatched regression, and the MTR tests listed above. No human review is claimed by these automated checks.

Areas touched

mysql-test, sql

Condition pushdown replaces a materialized FLOAT field with its
expression. Return the argument's FLOAT string representation from
ANY_VALUE so this replacement preserves string-comparison results and
NULL state.

Add native regressions for the reported query, equivalent controls, and
repeated prepared-statement execution. Preserve observable results
across the affected execution paths.

Bug report: https://bugs.mysql.com/bug.php?id=120641
@DerZc
DerZc requested a review from a team September 28, 2026 06:50
@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Sep 28, 2026
@github-actions github-actions Bot added the Tests Changes touching test code or test data label Sep 28, 2026
@ogrovlen ogrovlen added the Optimizer Changes touching optimizer code label Sep 28, 2026
@github-actions github-actions Bot added the Build Passed PR build passed label Sep 28, 2026
@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement Bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Sep 28, 2026
@github-actions github-actions Bot added the Review Requested Review requested from code owners label Sep 28, 2026
@RidhaOracle

Copy link
Copy Markdown
Member

/codex

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Codex PR Review completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Codex PR Review for #791

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one correctness regression: the new FLOAT string delegation inherits ZEROFILL padding that materialization drops, making query results depend on condition pushdown. The inline comment includes a regression case and suggested correction.

Reviewed all four changed files and the relevant formatting, temporary-field, and pushdown paths. Static review only; no PR code or tests were executed.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Codex PR Review for #791 · codex · gpt60 · 124.8 AIC · ⌖ 24 AIC · ⊞ 14K
Comment /codex to run again

Comment thread sql/item_cmpfunc.cc
// table. Keep that representation when a condition is pushed down and its
// field reference is replaced by this expression.
null_value = false;
String *res = eval_string_arg(collation.collation, args[0], str);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the temporary FLOAT field's unpadded representation

Delegating to the argument's val_str() also inherits ZEROFILL padding. For a FLOAT(10,2) ZEROFILL column containing 1, this returns 0000001.00, whereas create_tmp_field_from_item() constructs the materialized ANY_VALUE result with zerofill=false, so it returns 1.00. Consequently, with derived_merge=off, the following predicate matches with derived_condition_pushdown=on and does not match with it off:

CREATE TABLE t (c FLOAT(10,2) ZEROFILL);
INSERT INTO t VALUES (1);
SELECT c
FROM (SELECT ANY_VALUE(c) AS c FROM t) AS d
WHERE c LIKE '000%';

Before this change, the inherited numeric conversion was unpadded in both paths. Please format the numeric result with FLOAT precision and the expression's decimals without inheriting source-field padding, and add coverage comparing pushdown on/off for this case.

@github-actions github-actions Bot added the MTR Failed MTR suite failed label Sep 28, 2026
@ogrovlen
ogrovlen requested a review from roylyseng September 29, 2026 11:06
@roylyseng

Copy link
Copy Markdown
Member

Thank you for your contribution.
However, on further inspection, we concluded this is not a bug.
Combing FLOAT values and conversions to and from strings are inherently vulnerable and deviations may be expected due to internal handling precision issues.
In fact, it seems the result claimed to be correct in the bug report is actually incorrect.

@DerZc

DerZc commented Oct 8, 2026

Copy link
Copy Markdown
Author

Hi @roylyseng I got it! Thanks for your work!

@DerZc DerZc closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build Passed PR build passed MTR Failed MTR suite failed OCA Verified All contributors have signed the Oracle Contributor Agreement. Optimizer Changes touching optimizer code Review Requested Review requested from code owners Tests Changes touching test code or test data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants