Skip to content

PS-10481 [9.x]: Bug#118009, Bug#118486, Bug#119770, Bug#119867: Fix r…#5837

Open
percona-mhansson wants to merge 1 commit intopercona:trunkfrom
percona-mhansson:ps-10481-trunk
Open

PS-10481 [9.x]: Bug#118009, Bug#118486, Bug#119770, Bug#119867: Fix r…#5837
percona-mhansson wants to merge 1 commit intopercona:trunkfrom
percona-mhansson:ps-10481-trunk

Conversation

@percona-mhansson
Copy link
Contributor

…ange optimizer falling back to full table scan for oversized string values

The range optimizer returns nullptr ("always true") when a string value exceeds the column's character capacity on strnxfrm collations (Bug#35169384). This nullptr then poisons valid ranges via tree_or(valid, nullptr) -> nullptr, causing a full table scan when the optimizer should use an index.

Three fixes:

  1. IN() list (Bug#118009, Bug#118486): When get_mm_parts() returns
    nullptr for an IN() value, check if the value's character count
    exceeds the field's char_length(). If so, skip it -- no row can
    match. The check uses the table field's char_length(), not the
    key_part's prefix clone, so values fitting the column but
    exceeding a prefix are not incorrectly skipped.

  2. Prefix index (Bug#119770): For EQ_FUNC on a prefix key
    (HA_PART_KEY_SEG), the truncated value is a valid prefix lookup
    key -- the prefix index stores truncated values by design. Fall
    through with inexact=true so the WHERE filter rechecks full
    equality, instead of bailing out.

  3. OR branches (Bug#119867): When an OR branch returns nullptr for
    a MULT_EQUAL predicate (produced by constant propagation from
    simple col = const), check whether the value exceeds the column's
    character capacity. If so, skip the branch. This check runs
    before the first-branch assignment to prevent an oversized first
    branch from poisoning all subsequent valid branches.

UCA contractions (e.g. 'ae' = U+00E6 'æ') can make an N-char value match an M-char stored value where N > M. When such a value is skipped, the contraction match is missed, but this matches the existing MySQL 8.0 behavior where the truncated sort key also fails to match the contraction character.

…ange optimizer falling back to full table scan for oversized string values

The range optimizer returns nullptr ("always true") when a string value
exceeds the column's character capacity on strnxfrm collations
(Bug#35169384). This nullptr then poisons valid ranges via
tree_or(valid, nullptr) -> nullptr, causing a full table scan when
the optimizer should use an index.

Three fixes:

1) IN() list (Bug#118009, Bug#118486): When get_mm_parts() returns
   nullptr for an IN() value, check if the value's character count
   exceeds the field's char_length(). If so, skip it -- no row can
   match. The check uses the table field's char_length(), not the
   key_part's prefix clone, so values fitting the column but
   exceeding a prefix are not incorrectly skipped.

2) Prefix index (Bug#119770): For EQ_FUNC on a prefix key
   (HA_PART_KEY_SEG), the truncated value is a valid prefix lookup
   key -- the prefix index stores truncated values by design. Fall
   through with inexact=true so the WHERE filter rechecks full
   equality, instead of bailing out.

3) OR branches (Bug#119867): When an OR branch returns nullptr for
   a MULT_EQUAL predicate (produced by constant propagation from
   simple col = const), check whether the value exceeds the column's
   character capacity. If so, skip the branch. This check runs
   before the first-branch assignment to prevent an oversized first
   branch from poisoning all subsequent valid branches.

UCA contractions (e.g. 'ae' = U+00E6 'æ') can make an N-char value
match an M-char stored value where N > M. When such a value is
skipped, the contraction match is missed, but this matches the
existing MySQL 8.0 behavior where the truncated sort key also fails
to match the contraction character.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants