MDEV-31182 Check for blob too in create_key_parts_for_pseudo_indexes#5349
MDEV-31182 Check for blob too in create_key_parts_for_pseudo_indexes#5349mariadb-YuchenPei wants to merge 3 commits into
Conversation
|
|
8f5242e to
9e907f8
Compare
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182 by ensuring that MYSQL_TYPE_BLOB is treated similarly to MYSQL_TYPE_VARCHAR when calculating key part lengths for pseudo-indexes in sql/opt_range.cc. Specifically, it adds HA_KEY_BLOB_LENGTH to the store length when the field type is a BLOB. Additionally, a corresponding test case has been added to verify the fix and prevent ASAN errors. I have no feedback to provide as there are no review comments.
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.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182, fixing ASAN errors related to String_copier::well_formed_copy and calculate_cond_selectivity_for_table. The changes ensure that MYSQL_TYPE_BLOB is handled correctly when calculating key lengths for pseudo-indexes, and introduces an empty override for set_key_image in Field_geom to prevent incorrect key data parsing. Feedback suggests using the is_real_blob() abstraction in sql/opt_range.cc for better readability, and adding a Doxygen comment to explain the no-op override in Field_geom.
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.
da2fe4d to
269f807
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182 by adding test cases and fixing ASAN errors related to geometry and blob types. Key changes include making print_key_part_value virtual, handling MYSQL_TYPE_BLOB in pseudo-index key part creation, and implementing Field_geom::print_key_part_value while asserting on unsupported operations. The review feedback suggests simplifying the Field_geom::print_key_part_value implementation by removing an unnecessary temporary StringBuffer and charset check, as well as correcting minor typos in the newly added comments in sql/sql_type_geom.h.
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.
269f807 to
8f0aef9
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182 by fixing ASAN errors in String_copier::well_formed_copy and calculate_cond_selectivity_for_table. It makes print_key_part_value virtual, implements it for Field_geom, and updates pseudo-index key part creation to support MYSQL_TYPE_BLOB. The review feedback correctly points out that replacing the fallback behavior in Field_geom::print_key_value with only DBUG_ASSERT(0) leaves the function empty in release builds, which could lead to issues if called; retaining the fallback string append after the assertion is recommended.
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.
|
claude review comment on the gis commit: Code Review: MDEV-31182 —
|
8f0aef9 to
1527e98
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182, fixing ASAN errors related to geometry and blob fields during selectivity calculations. The changes include adding test cases, making print_key_part_value virtual, handling MYSQL_TYPE_BLOB in pseudo-index key part creation, and overriding key-related methods in Field_geom with assertions. The review feedback highlights potential compiler warnings in release builds where DBUG_ASSERT(0) is compiled out, leaving parameters unused in set_key_image, print_key_value, and print_key_part_value. It is recommended to comment out or omit these unused parameter names to prevent build warnings or errors.
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.
BLOB and VARCHAR has keys prefixed with length of the payload. This length data itself has length HA_KEY_BLOB_LENGTH which is 2, as demonstrated for example in Field_blob::set_key_image and Field_varstring::set_key_image. In this patch, when preparing key info for a range analysis, we account for this extra HA_KEY_BLOB_LENGTH in the total key length for BLOB. Previously it was only done for VARCHAR. This way, when doing the actual range analysis, LIKE (Item_func_like::get_mm_leaf) can correctly identify that it is dealing with a BLOB, thereby allowing the space of 2 for the length data. This avoids later Field_blob::set_key_image reading the payload as length data and causing reading the wrong memory segment for the payload.
1527e98 to
7365b7d
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182 by fixing ASAN errors related to geometry and blob types. Key changes include making Field::print_key_part_value virtual, implementing it for Field_geom, and updating pseudo-index key part creation to handle MYSQL_TYPE_BLOB. The review feedback suggests removing the print_key_value override in Field_geom that asserts 0, as the base class implementation already delegates to the newly virtual print_key_part_value, making the override redundant and potentially prone to debug crashes.
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.
In fact, it should not be called at all, as GIS indexes do not store the whole data. Remove the only known callsite covered by a testcase (added in this commit), in print_key_part_value
(this commit is split out for a targeted review that does not duplicate the review of its parent commit) The new testcase results in new coverage that exposes an MSAN uninitialised failure, where range->end_key.keypart_map is not assigned for GIS indexes in sel_arg_range_seq_next, so we accordingly do not use that keypart_map in the subsequent print_range call
7365b7d to
13c5c02
Compare
|
claude review of the msan fix below Code Review: MDEV-31182 — Fix MSAN uninitialized read in
|
This is a good point, but it is not clear what should be the correct value in that branch |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses MDEV-31182, resolving ASAN errors in String_copier::well_formed_copy and calculate_cond_selectivity_for_table. Key changes include making print_key_part_value virtual in Field, implementing it for Field_geom to handle unprintable geometry values, and updating create_key_parts_for_pseudo_indexes to correctly handle MYSQL_TYPE_BLOB. Additionally, the logic for dropping statistic fields during table alteration was refined in sql_table.cc to only trigger when the field's comparison type handler changes. Since there are no review comments, no further feedback is provided.
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.
|
claude review of the new commit on dropping column stats: Code Review: MDEV-31182 [wip] — Drop column stats on incompatible ALTER changesCommit: OverviewThe goal: The change:
I confirmed the plumbing is sound: Correctness
The two open questions in the commit message1. Is
Suggestion: consider 2. Do affected index stats need dropping too? — Yes, and there's now an asymmetry. The index-stat drop ( Code quality / style
Test coverage
Risks
VerdictRight direction, not yet mergeable (as the |
c12371b to
13c5c02
Compare
BLOB and VARCHAR has keys prefixed with length of the payload. This length data itself has length HA_KEY_BLOB_LENGTH which is 2, as demonstrated for example in Field_blob::set_key_image and Field_varstring::set_key_image.
In this patch, when preparing key info for a range analysis, we account for this extra HA_KEY_BLOB_LENGTH in the total key length for BLOB. Previously it was only done for VARCHAR. This way, when doing the actual range analysis, LIKE (Item_func_like::get_mm_leaf) can correctly identify that it is dealing with a BLOB, thereby allowing the space of 2 for the length data. This avoids later Field_blob::set_key_image reading the payload as length data and causing reading the wrong memory segment for the payload.