8000 fix(mysql): widen table integers beside a nested rollup by colinhacks · Pull Request #234 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

fix(mysql): widen table integers beside a nested rollup - #234

Merged
colinhacks merged 2 commits into
mainfrom
fix/mysql-rollup-int8
Nov 11, 2026
Merged

colinhacks merged 2 commits into
mainfrom
fix/mysql-rollup-int8

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

MySQL 8.4.13 sends a table's INT column as a BIGINT through a temporary table (SQL_BUFFER_RESULT, or a plan that needs one) when a subquery grouped WITH ROLLUP reads it, even though the prepare names the table. The engine kept such a column at its declared type, so it was typed int and came back as int8:

select u.id, (select json_object('t', p.title, 'k', u.id, 'c', count(*)) from posts p where p.user_id = u.id group by p.title with rollup order by p.title limit 1) as o
from users u group by u.id

On 8.4.13 the outer u.id widens only when every piece is present: the subquery rolls up, holds an aggregate and reads u.id in its select list, and the outer query groups by u.id. A subquery that selects the outer column directly, (select u.id from posts p … with rollup limit 1), widens too. 8.4.11 keeps the first one an INT.

  • When a GROUP BY inside parentheses rolls up (a subquery's, a derived table's or a WITH query's), a table's own integer column is now typed as either width, int | bigint. The check reads the statement's text outside strings, names and comments.
  • The rule is wider than what was measured, so a few statements that 8.4.13 answers with INT are also typed int | bigint. Each variant is in the new case.
  • New oracle case mysql_correlated_rollup: the statement above, plus variants that each leave out one part of the trigger.

Refs #230

MySQL 8.4.13 answers an INT column as a BIGINT through a temporary table when a subquery grouped WITH ROLLUP reads it, though the prepare names its table.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:05
@vercel
vercel Bot commented Nov 11, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
reylo Ignored Ignored Preview Nov 11, 2026 5:14am UTC

Request Review

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues. One suggestion inline: the rule is broader than the behavior it's meant to cover.

Reviewed changes

I reviewed the MySQL engine's new rollup-in-parentheses rule in settle and the new oracle case for it.

  • rolls_up_within: scans the text outside strings, names and comments for the word rollup at a parenthesis depth above zero.
  • settle: when that word is found, no column counts as a table's own column, so a table's INT column is now typed int | bigint.
  • Unit test: a_rollup_in_parentheses_widens_a_tables_own_integer covers a nested rollup, a rollup split across a newline, the query's own top-level rollup, and the word inside a string, a quoted name, a comment and a longer identifier.
  • Oracle case mysql_correlated_rollup: the measured trigger, plus variants that each leave out one part of it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread engine/mysql/src/mysql.rs Resolved
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found. The earlier concern about the placeholder exemption is fixed.

Reviewed changes

I reviewed 74105e0, which narrows the nested-rollup rule in settle so that it only adds the other integer width.

  • settle: own no longer depends on rolled. A table's own column now returns its type unioned with other_width(c) only under a nested rollup, so it still keeps its type whatever is bound, and a BIGINT, DATE or VARCHAR table column is not widened.
  • Doc comment: now says a table's own integer column may also be of the other width but is still of its type whatever is bound.
  • Unit test: added a derived table that holds count(*) + ? beside a rollup. It checks that an INT table column becomes int | bigint and that BIGINT and VARCHAR table columns are not widened.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@colinhacks
colinhacks merged commit 6767faa into main Nov 11, 2026
12 checks passed
@colinhacks
colinhacks deleted the fix/mysql-rollup-int8 branch November 11, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0