Skip to content

Assertion marked_for_read() failed in virtual my_time_t Field_timesta…#5201

Open
pranavktiwari wants to merge 1 commit into
11.4from
11.4-MDEV-34992
Open

Assertion marked_for_read() failed in virtual my_time_t Field_timesta…#5201
pranavktiwari wants to merge 1 commit into
11.4from
11.4-MDEV-34992

Conversation

@pranavktiwari

@pranavktiwari pranavktiwari commented Jun 9, 2026

Copy link
Copy Markdown

fixes MDEV-34992

Problem:

SELECT on a table with a TIMESTAMP column and a virtual column
expression containing a field reference crashes with assertion
marked_for_read() in Field_timestamp0::get_timestamp.

Cause:

convert_item_for_comparison() physically evaluates the subject item
via Datetime dt(thd, subject, ...) to attempt a TIMESTAMP vs DATETIME
optimization. During vcol_fix_expr() at open_table() time,
used_tables_cache is not yet propagated up the item tree, causing
const_item() to return true incorrectly for a non-constant expression
containing a field reference. The evaluation then reads Field_timestamp0
before read bitmaps are initialized, violating marked_for_read().

Fix:

Add find_field_processor() to the Item base class, overridden in
Item_field to return true. Guard convert_item_for_comparison() with
a walk() check to skip physical evaluation if the subject subtree
contains any field reference.

@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 introduces a new processor check_field_ref_processor to check for field references in Item and Item_field classes, and updates Type_handler_datetime_common::convert_item_for_comparison to utilize it. The review feedback suggests breaking down a long, complex conditional statement in sql/sql_type.cc into multiple lines to improve readability.

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.

Comment thread sql/sql_type.cc Outdated
…Field_timestamp0::get_timestamp(const uchar*, ulong*) const.

add find_field_processor() to Item, overridden in Item_field to return true, and guard convert_item_for_comparison() with a walk() check to skip evaluation if the subject contains any field reference.
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