Skip to content

MDEV-39433: Crash when recording context for a sequence query#5193

Merged
bsrikanth-mariadb merged 1 commit into
bb-12.3-MDEV-39368-test-replayfrom
13.1-MDEV-39433-Crash_when_sequence_is_used_in_a_query
Jun 9, 2026
Merged

MDEV-39433: Crash when recording context for a sequence query#5193
bsrikanth-mariadb merged 1 commit into
bb-12.3-MDEV-39368-test-replayfrom
13.1-MDEV-39433-Crash_when_sequence_is_used_in_a_query

Conversation

@bsrikanth-mariadb

@bsrikanth-mariadb bsrikanth-mariadb commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

With optimizer_record_context enabled, a simple query involving sequence such as:

create sequence s1;
Explain select * from s1;

is crashing in store_optimizer_costs(). There are no costs associated with sequence tables, and their fields, and hence when trying to access cost information for them, a crash occurs.

Solution

in store_optimizer_costs() return immediately if the costs is set to null

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request addresses MDEV-39433 by fixing a crash that occurs when selecting from a sequence with optimizer_record_context enabled. The fix updates the is_base_table function in sql/opt_context_store_replay.cc to ensure that sequences are not treated as base tables by checking !tbl->table->s->sequence. Corresponding test cases and results have also been added to verify the fix. No review comments were provided, so there is no additional feedback.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 13.1-MDEV-39433-Crash_when_sequence_is_used_in_a_query branch 6 times, most recently from 269210c to 52fe014 Compare June 8, 2026 23:31
With optimizer_record_context enabled, a simple query involving sequence
such as:

create sequence s1;
Explain select * from s1;

is crashing in store_optimizer_costs(). There are no costs associated
with sequence tables, and their fields, and hence when trying to access
cost information for them, a crash occurs.

Solution
========
Don't try to store stats or cost information for sequences
@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 13.1-MDEV-39433-Crash_when_sequence_is_used_in_a_query branch from 52fe014 to 5152905 Compare June 9, 2026 02:44
@bsrikanth-mariadb bsrikanth-mariadb merged commit 5152905 into bb-12.3-MDEV-39368-test-replay Jun 9, 2026
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants