Skip to content

MDEV-28610 : Assertion `marked_for_read()' failed upon range select with virtual column in index#5122

Open
pranavktiwari wants to merge 1 commit into
10.11from
10.11-MDEV-28610
Open

MDEV-28610 : Assertion `marked_for_read()' failed upon range select with virtual column in index#5122
pranavktiwari wants to merge 1 commit into
10.11from
10.11-MDEV-28610

Conversation

@pranavktiwari
Copy link
Copy Markdown

@pranavktiwari pranavktiwari commented May 25, 2026

fixes MDEV-28610

Problem:

Executing a range select using an index that includes virtual/generated columns
(e.g. SELECT ... WHERE c BETWEEN ... ORDER BY d) could trigger:

Assertion 'marked_for_read()' failed in Field access during execution.

Cause:

The keyread initialization path was populating table->read_set using
mark_index_columns(), which follows the non-recursive index marking path.
This only marks direct index fields and does not resolve dependencies of
virtual/generated columns.

As a result, when an index contained virtual columns, their dependent base
columns were not included in read_set, leading to invalid access during
later evaluation of virtual columns.

Fix:

Replace mark_index_columns() with mark_index_columns_for_read() in the
keyread initialization path. This ensures the recursive read-marking logic is
used, so virtual/generated column dependencies are correctly propagated into
read_set before execution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

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 modifies the do_mark_index_columns function in sql/table.cc to ensure that virtual columns are registered in the read map even when the read flag is false. A review comment identifies a potential issue where this change causes the code to skip marking the write set for virtual columns, which could lead to missing updates in the storage engine. The reviewer suggested refactoring the logic to ensure virtual columns are registered in the read map without bypassing the write set marking.

Comment thread sql/table.cc Outdated
…h virtual column in index.

Fix read_set propagation for virtual columns during keyread
The keyread initialization path was populating  using , which internally uses the non-recursive index marking path. This only marks direct index fields and does not resolve dependencies of virtual/generated columns.
As a result, when a covering index contained a virtual column, its dependent base columns could be missing from , leading to  assertions during virtual column evaluation.
Replace the call with , which uses the recursive read-marking path and correctly propagates virtual/generated column dependencies into  during keyread setup.
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