Skip to content

filter by prefix_between/prefix_in in Reader - #14893

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
aunjgr:prefix
Mar 13, 2024
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
aunjgr:prefix

Conversation

@aunjgr

@aunjgr aunjgr commented Mar 11, 2024 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue https://github.com/matrixorigin/MO-Cloud/issues/2574

What this PR does / why we need it:

to avoid copying entire block out of cache

@mergify mergify Bot added the kind/feature label Mar 11, 2024
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Mar 11, 2024
@mergify
mergify Bot merged commit 57a9f7a into matrixorigin:main Mar 13, 2024
@aunjgr
aunjgr deleted the prefix branch March 22, 2024 04:01
aunjgr added a commit to aunjgr/matrixone that referenced this pull request Apr 10, 2024
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
mergify Bot pushed a commit that referenced this pull request Oct 6, 2026
Persisted, sorted secondary-index filtering can receive reversed Prepared
BETWEEN bounds. `CollectOffsetsByPrefixBetweenFactory` searches the lower and
upper positions independently, but only rejects `start == end`. When the
upper position precedes the lower position, `make([]int64, end-start)` panics
and a valid SELECT returns Error 20101 instead of an empty result.

Reject `start >= end` before allocation. This is the same empty-selection
invariant already used by the neighboring prefix-range helper. Keep both
existing search comparisons unchanged: rejecting bytewise reversed bounds
before searching would incorrectly discard valid shorter-upper-prefix ranges.
Normal nonempty selections retain the same searches, allocation and offsets.
No planner, parameter conversion, index format, cache or distributed execution
change is included.

Extend the existing six-key unit fixture with forward/equal/short-upper-prefix,
reversed, missing and empty-vector cases, checking explicit expected offsets
and the existing linear helper. Add a self-contained 256-row persisted-index
BVT for reused and fresh SQL PREPARE handles, equal/overlapping/NULL bindings,
a mixed empty/nonempty OR, and literal/no-secondary-index controls.

This is a longstanding component boundary defect, not a proven recent
regression: the missing guard exists in #14893 (March 2024), and the actual
SQL panic also reproduces on the September 30, 2026 4.2 image `28f1f02`.
MOTR #215 added the reversed-bound probe on October 5. The earliest release
where this exact SQL plan became reachable has not been bisected.

Tested with:

- Fresh Main base `c65991043b10fb39988d45b72af1485560ac5433` plus this patch;
matching native artifacts built locally and on the isolated Linux test host.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run '^TestCollectOffsetsByPrefixBetweenFactory$' ./pkg/container/vector`:
the added reversed case panics without the production fix; all 13 subtests
pass with it, both on macOS arm64 and Linux amd64.
- Complete `./pkg/container/vector` tests pass on both platforms; complete
`./pkg/objectio` tests and `go vet ./pkg/container/vector ./pkg/objectio`
pass locally with matching CGo settings.
- The original real binary-protocol `int64` probe on a 32,768-row persisted
secondary-index fixture: all nine result checks match an independent
finite-domain oracle on the fixed Main binary. Includes forward, reversed,
NULL, out-of-INT32, rebind/recovery, SQL PREPARE, literal and no-index cases.
- Official mo-tester normal comparison (not result recording) on the isolated
host: the new BVT fails on exactly three queries on the incident Main image;
fixed Main passes **37/37 statements twice on the same instance**, with zero
ignored/abnormal statements and zero BVT database residue after each run.
- SQL remains usable after the protocol probe and first BVT. The owned test
container remained running without OOM and exited 0 after deliberate stop.
- Complete self-review and `git diff --check`: no unresolved blockers. Valid
ranges gain no additional scan, allocation, copy, synchronization or I/O.

This PR targets Main only. Unrelated Prepared performance/type-normalization
failures in #29606 are not claimed to be fixed.

Approved by: @XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants