Skip to content

MDEV-40821 SIGSEGV in Window_funcs_sort::setup - #5728

Open
midenok wants to merge 1 commit into
11.8from
11.8-midenok-MDEV-40821
Open

midenok wants to merge 1 commit into
11.8from
11.8-midenok-MDEV-40821

Conversation

@midenok

@midenok midenok commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Window_funcs_sort failed accessing win_func->window_spec as window spec was not defined in the query. Usually this is checked by fixing item win_func, but it was not done by setup_conds.

Actually, earlier check by vers_setup_conds() must fail on DELETE HISTORY from non-versioned table, but TABLE_LIST for t1 has no versioning conditions.

The cause was the parser assigning versioning conditions to wrong table pointed by last_table() which was already switched to another table from SYSTEM_TIME expression (cs1).

The fix assigns versioning conditions to the correct table stored to correspondent_table by delete_single_table branch of the parser.

Copilot AI lite review requested due to automatic review settings September 21, 2026 16:35

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 review overview

🔵 Needs a closer look

Add coverage for the analogous FOR PORTION OF path and address the two style nits.

Review effort: Lite
Findings: None

What changed in this PR

Fixes MDEV-40821 by attaching versioning conditions to the intended DELETE target, preventing a SIGSEGV when expressions introduce another table.

Changes:

  • Uses correspondent_table for condition assignment.
  • Adds regression coverage for sequence and window-function expressions.
  • Updates expected results.
File Summary
sql/​sql_yacc.yy Corrects DELETE condition association. A moderate regression case remains missing for FOR PORTION OF with setval(), along with two line-length nits.
mysql-test/​suite/​versioning/​t/​delete_history.test Adds MDEV-40821 regression cases.
mysql-test/​suite/​versioning/​r/​delete_history.result Records expected test results.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Window_funcs_sort failed accessing win_func->window_spec as window
spec was not defined in the query. Usually this is checked by fixing
item win_func, but it was not done by setup_conds.

Actually, earlier check by vers_setup_conds() must fail on DELETE
HISTORY from non-versioned table, but TABLE_LIST for t1 has no
versioning conditions.

The cause was the parser assigning versioning conditions to wrong
table pointed by last_table() which was already switched to another
table from SYSTEM_TIME expression (cs1).

The fix assigns versioning conditions to the correct table stored to
correspondent_table by delete_single_table branch of the parser.

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 review overview

🟢 Approval recommended

The fix and regression coverage are acceptable; the remaining formatting nit is non-blocking.

Review effort: Lite
Findings: 1 Low severity

Open (1)

Comment thread sql/sql_yacc.yy
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants