Skip to content

Handle null and null-like characters sorting before spaces in pad-spaced columns - #38147

Draft
peterdukelarsen wants to merge 2 commits into
MaterializeInc:mainfrom
peterdukelarsen:pl/mysql-partition-padded-bounds-draft
Draft

Handle null and null-like characters sorting before spaces in pad-spaced columns#38147
peterdukelarsen wants to merge 2 commits into
MaterializeInc:mainfrom
peterdukelarsen:pl/mysql-partition-padded-bounds-draft

Conversation

@peterdukelarsen

Copy link
Copy Markdown
Contributor

Remove these sections if your commit already has a good description!

Motivation

Why does this change exist? Link to a GitHub issue, design doc, Slack
thread, or explain the problem in a sentence or two. A reviewer who has
no context should understand why after reading this section.

If this implements or addresses an existing issue, it's enough to link to that:
Closes
Fixes
etc.

Description

What does this PR actually do? Focus on the approach and any non-obvious
decisions. The diff shows the code --- use this space to explain what the
diff can't tell a reviewer.

Verification

How do you know this change is correct? Describe new or existing automated
tests, or manual steps you took.

Restores the broader live test suite on top of the probe interface PR:
case-insensitive traversal, LIKE wildcard and metacharacter data,
multibyte and emoji keys, ULID and UUID primary keys, collation
behavior, stale table statistics, and sargability via Handler_read
session counters.
Tests default to utf8mb4_bin, with utf8mb4_general_ci for the
case-insensitive cases, matching the collations snapshot splitting
accepts. New tests pin the edge cases that rule out other collations:
the Czech ch contraction silently drops prefixes, and NUL keys and
eszett expansions return prefixes that sort below the range they came
from.

Under PAD SPACE collations a key continuing with a character below space
sorts below its own prefix, so bare prefix bounds hide those keys. Range
bounds are now NUL-padded to sit at the infimum of the prefix extension
space, with the original prefix kept alongside to exclude the exact key.
A None lower bound means the start of the key space.
peterdukelarsen added a commit that referenced this pull request Aug 11, 2026
### Motivation
Split out some testing from
#38022 to keep that PR
manageable.

Part of: [SS-97](https://linear.app/materializeinc/issue/SS-97)

### Description
Adds testing for more diverse character types, collations, and for
asserting searches use the B-tree rather than scanning the full table.

### For Context
I've caught a couple of bugs in the later PR from discussion with Marty
and a review with Dennis:
#38093.
1. For PAD SPACE collations certain characters will sort before a
shorter string. Our algorithm still works cleanly for that case at a
high level, just throwing out the lower bounds which for utf8mb4_bin are
all things like null, carriage return, and tab. The one tricky spot we
needed to handle correctly was the upper bound, for which we're able to
append NUL characters to get behavior like what we would have expected
initially. I tried fixing this directly initially, but thought the fix
was more complex than the perf issue was worth (see
[here](#38147)).
2. Certain collations can't be supported with this approach because
multiple characters in a row can in fact sort differently from it's
prefix. There are tests here highlighting that and then most of the
tests have been moved to utf8mb4_bin to match the first collation we
intend to support.
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.

1 participant