Repository navigation
fix(readutil): preserve nested PK OR branches - #27521
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aptend
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 1882501, including the source issue and the complete 4.2 fix/review history. The container guard now runs before both atomic connector paths: OR falls back to the complete flattened disjunction, while AND retains only a necessary conjunct and preserves the selected atomic filter OID, so residual evaluation remains authoritative without false-negative pruning. Current-main merge simulation is clean. Exact-head list/build/vet/full readutil tests passed, focused race passed 20 iterations, and a temporary small-domain enumeration of atomic/container AND/OR combinations passed 20 iterations without dropping any true row; the temporary test was removed. No blocking issues found.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 188250109c313f4cd4853822545acca1007c6c2c. No blocking issue found.
The fix restores the necessary pruning invariant: a BasePKFilter carrying Disjuncts is treated as a container before either atomic merge switch. OR therefore falls back to the complete flattened leaf set instead of interpreting the container zero-value Op as EQUAL; AND conservatively retains one necessary conjunct and leaves the full expression to residual evaluation. Both operand orders are safe, two disjunctions retain a necessary disjunction, and the selected fallback keeps its own OID/resource ownership. Unsupported/non-PK OR remains fail-open. The change does not distribute AND over OR, so expression/memory growth remains linear rather than exponential.
Fresh validation passed: full readutil tests; the focused nested-boolean regression under race for 10 repetitions; build; vet; and diff checks. I also rechecked NULL/unsupported branches, IN-vector ownership, composite-PK OID override, and sorted/unsorted block-search consumers. No correctness, leak, or material performance regression remains.
Merge Queue Status
This pull request spent 12 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
1882501 to
3e3fb96
Compare
Merge Queue Status
This pull request spent 35 seconds in the queue, including 5 seconds running CI. Required conditions to merge
|
## Summary - replace the duplicated information_schema fixture called out in review #5013529566 - exercise a genuinely distinct reachable axis on a normal VARCHAR primary key - cover server PREPARE reuse with `a <= ? AND (a IN (?,?,?) OR a > ?)` across two bindings ## Why this is distinct - the case reaches the nested disjunction/container merge through a prepared `IN` plus a range arm - it does not depend on the information_schema cast path from #26627 - it is different from the existing equality/range operand-order cases in #27521 ## Validation - `go test ./pkg/vm/engine/readutil -run ^TestConstructBasePKFilterWithOr$ -count=1` - `go test ./pkg/sql/plan -run TestDoMergeFiltersOnCompositeKey -count=1` - `go test ./pkg/sql/plan -run TestInRHSValues -count=1` - SQL/result statement and expected-row alignment checked - `git diff --check` passed The shared local MatrixOne listener was not used because mo-tester performs destructive global cleanup; the updated fixture is ready for the repository BVT/CI environment. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: issue #27912 ## What this PR does / why we need it: Adds canonical regression coverage for the `information_schema.COLUMNS` query shape reported in #27912. The test compares three SQL `PREPARE`/`EXECUTE` paths over the same six-column table: - a fully literal predicate; - bound `TABLE_SCHEMA` and `TABLE_NAME` without `COLUMN_NAME IN`; - bound schema/table predicates combined with the six-value literal `COLUMN_NAME IN` clause that returned only 2 of 6 rows on v4.2.0. All paths assert the complete six-row result in deterministic ordinal order. This is test-only coverage for behavior already fixed by #27502 on release-4.2 and #27521 on main; it does not change production code or SQL semantics. - QA required: yes. Keep #27912 open for formal release/current-version verification after this regression is merged. - BVT: added to `test/distributed/cases/optimizer/pk_filter_nested_boolean.sql`. - Historical behavior: v4.2.0 returned 2/6 rows for the mixed bind/literal path. - CI repair: normalized six continuation-line indentations in the generated `.result` command record after exact-head BVT rejected the indented record before executing the new case. - Exact base: `ffc8d9f0625c76e87ba967984ce19db2d082b0ba`. - Exact PR head: `fb45e2d063bdb67b5403a8932b53158d7ee56963`. - Local exact-main SQL validation: PASS, 6/6 rows for literal, bind-only, and mixed paths through the MySQL wire protocol. - Local exact-format validation: PASS; the paired multiline command blocks match after whitespace normalization, and only the six result-file indentation characters changed. - Full mo-tester BVT: pending on the new PR head. - `git diff --check`: PASS. - Semantic preflight: PASS for exact head and diff. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This ports the root fix from matrixorigin#27502 to `main`. `main` contains the composite-PK block-pruning path introduced by matrixorigin#25596, but it does not contain either nested-disjunction guard from the 4.2 fix. A `BasePKFilter` with `Disjuncts` is a container, not an atomic predicate. Its zero-value `Op` is `function.EQUAL`; allowing it into the atomic merge switch can compare empty bounds and drop an OR branch, producing a false-negative pruning filter. The change rejects container merges before either AND or OR enters the atomic path. OR then flattens all disjuncts, while AND retains one safe atomic conjunct and leaves full predicate evaluation to the residual filter. The AND fallback now also preserves the selected atomic filter's OID. Regression coverage adds nested OR and both AND operand orders to the `readutil` unit test, plus the prepared SQL BVT `pk_filter_nested_boolean`. The BVT result was generated against `main`; its three metadata-width entries differ from 4.2 while all SQL values remain identical. Rebased onto `upstream/main` at `6a8e7ecc530539948663a35a52259224ee1d128a`. Validation on that base plus this branch: - `make build` - `go test ./pkg/vm/engine/readutil -count=1` - `go test -race ./pkg/vm/engine/readutil -run '^TestConstructBasePKFilterWithOr$' -count=10` - `go vet ./pkg/vm/engine/readutil` - `mo-tester` BVT `pk_filter_nested_boolean`: 29/29 statements, 100% Approved by: @aptend, @XuPeng-SH
## Summary - replace the duplicated information_schema fixture called out in review #5013529566 - exercise a genuinely distinct reachable axis on a normal VARCHAR primary key - cover server PREPARE reuse with `a <= ? AND (a IN (?,?,?) OR a > ?)` across two bindings ## Why this is distinct - the case reaches the nested disjunction/container merge through a prepared `IN` plus a range arm - it does not depend on the information_schema cast path from matrixorigin#26627 - it is different from the existing equality/range operand-order cases in matrixorigin#27521 ## Validation - `go test ./pkg/vm/engine/readutil -run ^TestConstructBasePKFilterWithOr$ -count=1` - `go test ./pkg/sql/plan -run TestDoMergeFiltersOnCompositeKey -count=1` - `go test ./pkg/sql/plan -run TestInRHSValues -count=1` - SQL/result statement and expected-row alignment checked - `git diff --check` passed The shared local MatrixOne listener was not used because mo-tester performs destructive global cleanup; the updated fixture is ready for the repository BVT/CI environment. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#28082) ## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: issue matrixorigin#27912 ## What this PR does / why we need it: Adds canonical regression coverage for the `information_schema.COLUMNS` query shape reported in matrixorigin#27912. The test compares three SQL `PREPARE`/`EXECUTE` paths over the same six-column table: - a fully literal predicate; - bound `TABLE_SCHEMA` and `TABLE_NAME` without `COLUMN_NAME IN`; - bound schema/table predicates combined with the six-value literal `COLUMN_NAME IN` clause that returned only 2 of 6 rows on v4.2.0. All paths assert the complete six-row result in deterministic ordinal order. This is test-only coverage for behavior already fixed by matrixorigin#27502 on release-4.2 and matrixorigin#27521 on main; it does not change production code or SQL semantics. - QA required: yes. Keep matrixorigin#27912 open for formal release/current-version verification after this regression is merged. - BVT: added to `test/distributed/cases/optimizer/pk_filter_nested_boolean.sql`. - Historical behavior: v4.2.0 returned 2/6 rows for the mixed bind/literal path. - CI repair: normalized six continuation-line indentations in the generated `.result` command record after exact-head BVT rejected the indented record before executing the new case. - Exact base: `ffc8d9f0625c76e87ba967984ce19db2d082b0ba`. - Exact PR head: `fb45e2d063bdb67b5403a8932b53158d7ee56963`. - Local exact-main SQL validation: PASS, 6/6 rows for literal, bind-only, and mixed paths through the MySQL wire protocol. - Local exact-format validation: PASS; the paired multiline command blocks match after whitespace normalization, and only the six result-file indentation characters changed. - Full mo-tester BVT: pending on the new PR head. - `git diff --check`: PASS. - Semantic preflight: PASS for exact head and diff. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This ports the root fix from matrixorigin#27502 to `main`. `main` contains the composite-PK block-pruning path introduced by matrixorigin#25596, but it does not contain either nested-disjunction guard from the 4.2 fix. A `BasePKFilter` with `Disjuncts` is a container, not an atomic predicate. Its zero-value `Op` is `function.EQUAL`; allowing it into the atomic merge switch can compare empty bounds and drop an OR branch, producing a false-negative pruning filter. The change rejects container merges before either AND or OR enters the atomic path. OR then flattens all disjuncts, while AND retains one safe atomic conjunct and leaves full predicate evaluation to the residual filter. The AND fallback now also preserves the selected atomic filter's OID. Regression coverage adds nested OR and both AND operand orders to the `readutil` unit test, plus the prepared SQL BVT `pk_filter_nested_boolean`. The BVT result was generated against `main`; its three metadata-width entries differ from 4.2 while all SQL values remain identical. Rebased onto `upstream/main` at `6a8e7ecc530539948663a35a52259224ee1d128a`. Validation on that base plus this branch: - `make build` - `go test ./pkg/vm/engine/readutil -count=1` - `go test -race ./pkg/vm/engine/readutil -run '^TestConstructBasePKFilterWithOr$' -count=10` - `go vet ./pkg/vm/engine/readutil` - `mo-tester` BVT `pk_filter_nested_boolean`: 29/29 statements, 100% Approved by: @aptend, @XuPeng-SH
## Summary - replace the duplicated information_schema fixture called out in review #5013529566 - exercise a genuinely distinct reachable axis on a normal VARCHAR primary key - cover server PREPARE reuse with `a <= ? AND (a IN (?,?,?) OR a > ?)` across two bindings ## Why this is distinct - the case reaches the nested disjunction/container merge through a prepared `IN` plus a range arm - it does not depend on the information_schema cast path from matrixorigin#26627 - it is different from the existing equality/range operand-order cases in matrixorigin#27521 ## Validation - `go test ./pkg/vm/engine/readutil -run ^TestConstructBasePKFilterWithOr$ -count=1` - `go test ./pkg/sql/plan -run TestDoMergeFiltersOnCompositeKey -count=1` - `go test ./pkg/sql/plan -run TestInRHSValues -count=1` - SQL/result statement and expected-row alignment checked - `git diff --check` passed The shared local MatrixOne listener was not used because mo-tester performs destructive global cleanup; the updated fixture is ready for the repository BVT/CI environment. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#28082) ## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: issue matrixorigin#27912 ## What this PR does / why we need it: Adds canonical regression coverage for the `information_schema.COLUMNS` query shape reported in matrixorigin#27912. The test compares three SQL `PREPARE`/`EXECUTE` paths over the same six-column table: - a fully literal predicate; - bound `TABLE_SCHEMA` and `TABLE_NAME` without `COLUMN_NAME IN`; - bound schema/table predicates combined with the six-value literal `COLUMN_NAME IN` clause that returned only 2 of 6 rows on v4.2.0. All paths assert the complete six-row result in deterministic ordinal order. This is test-only coverage for behavior already fixed by matrixorigin#27502 on release-4.2 and matrixorigin#27521 on main; it does not change production code or SQL semantics. - QA required: yes. Keep matrixorigin#27912 open for formal release/current-version verification after this regression is merged. - BVT: added to `test/distributed/cases/optimizer/pk_filter_nested_boolean.sql`. - Historical behavior: v4.2.0 returned 2/6 rows for the mixed bind/literal path. - CI repair: normalized six continuation-line indentations in the generated `.result` command record after exact-head BVT rejected the indented record before executing the new case. - Exact base: `ffc8d9f0625c76e87ba967984ce19db2d082b0ba`. - Exact PR head: `fb45e2d063bdb67b5403a8932b53158d7ee56963`. - Local exact-main SQL validation: PASS, 6/6 rows for literal, bind-only, and mixed paths through the MySQL wire protocol. - Local exact-format validation: PASS; the paired multiline command blocks match after whitespace normalization, and only the six result-file indentation characters changed. - Full mo-tester BVT: pending on the new PR head. - `git diff --check`: PASS. - Semantic preflight: PASS for exact head and diff. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This ports the root fix from matrixorigin#27502 to `main`. `main` contains the composite-PK block-pruning path introduced by matrixorigin#25596, but it does not contain either nested-disjunction guard from the 4.2 fix. A `BasePKFilter` with `Disjuncts` is a container, not an atomic predicate. Its zero-value `Op` is `function.EQUAL`; allowing it into the atomic merge switch can compare empty bounds and drop an OR branch, producing a false-negative pruning filter. The change rejects container merges before either AND or OR enters the atomic path. OR then flattens all disjuncts, while AND retains one safe atomic conjunct and leaves full predicate evaluation to the residual filter. The AND fallback now also preserves the selected atomic filter's OID. Regression coverage adds nested OR and both AND operand orders to the `readutil` unit test, plus the prepared SQL BVT `pk_filter_nested_boolean`. The BVT result was generated against `main`; its three metadata-width entries differ from 4.2 while all SQL values remain identical. Rebased onto `upstream/main` at `6a8e7ecc530539948663a35a52259224ee1d128a`. Validation on that base plus this branch: - `make build` - `go test ./pkg/vm/engine/readutil -count=1` - `go test -race ./pkg/vm/engine/readutil -run '^TestConstructBasePKFilterWithOr$' -count=10` - `go vet ./pkg/vm/engine/readutil` - `mo-tester` BVT `pk_filter_nested_boolean`: 29/29 statements, 100% Approved by: @aptend, @XuPeng-SH
## Summary - replace the duplicated information_schema fixture called out in review #5013529566 - exercise a genuinely distinct reachable axis on a normal VARCHAR primary key - cover server PREPARE reuse with `a <= ? AND (a IN (?,?,?) OR a > ?)` across two bindings ## Why this is distinct - the case reaches the nested disjunction/container merge through a prepared `IN` plus a range arm - it does not depend on the information_schema cast path from matrixorigin#26627 - it is different from the existing equality/range operand-order cases in matrixorigin#27521 ## Validation - `go test ./pkg/vm/engine/readutil -run ^TestConstructBasePKFilterWithOr$ -count=1` - `go test ./pkg/sql/plan -run TestDoMergeFiltersOnCompositeKey -count=1` - `go test ./pkg/sql/plan -run TestInRHSValues -count=1` - SQL/result statement and expected-row alignment checked - `git diff --check` passed The shared local MatrixOne listener was not used because mo-tester performs destructive global cleanup; the updated fixture is ready for the repository BVT/CI environment. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#28082) ## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: issue matrixorigin#27912 ## What this PR does / why we need it: Adds canonical regression coverage for the `information_schema.COLUMNS` query shape reported in matrixorigin#27912. The test compares three SQL `PREPARE`/`EXECUTE` paths over the same six-column table: - a fully literal predicate; - bound `TABLE_SCHEMA` and `TABLE_NAME` without `COLUMN_NAME IN`; - bound schema/table predicates combined with the six-value literal `COLUMN_NAME IN` clause that returned only 2 of 6 rows on v4.2.0. All paths assert the complete six-row result in deterministic ordinal order. This is test-only coverage for behavior already fixed by matrixorigin#27502 on release-4.2 and matrixorigin#27521 on main; it does not change production code or SQL semantics. - QA required: yes. Keep matrixorigin#27912 open for formal release/current-version verification after this regression is merged. - BVT: added to `test/distributed/cases/optimizer/pk_filter_nested_boolean.sql`. - Historical behavior: v4.2.0 returned 2/6 rows for the mixed bind/literal path. - CI repair: normalized six continuation-line indentations in the generated `.result` command record after exact-head BVT rejected the indented record before executing the new case. - Exact base: `ffc8d9f0625c76e87ba967984ce19db2d082b0ba`. - Exact PR head: `fb45e2d063bdb67b5403a8932b53158d7ee56963`. - Local exact-main SQL validation: PASS, 6/6 rows for literal, bind-only, and mixed paths through the MySQL wire protocol. - Local exact-format validation: PASS; the paired multiline command blocks match after whitespace normalization, and only the six result-file indentation characters changed. - Full mo-tester BVT: pending on the new PR head. - `git diff --check`: PASS. - Semantic preflight: PASS for exact head and diff. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27503
What this PR does / why we need it:
This ports the root fix from #27502 to
main.maincontains the composite-PK block-pruning path introduced by #25596, but it does not contain either nested-disjunction guard from the 4.2 fix.A
BasePKFilterwithDisjunctsis a container, not an atomic predicate. Its zero-valueOpisfunction.EQUAL; allowing it into the atomic merge switch can compare empty bounds and drop an OR branch, producing a false-negative pruning filter.The change rejects container merges before either AND or OR enters the atomic path. OR then flattens all disjuncts, while AND retains one safe atomic conjunct and leaves full predicate evaluation to the residual filter. The AND fallback now also preserves the selected atomic filter's OID.
Regression coverage adds nested OR and both AND operand orders to the
readutilunit test, plus the prepared SQL BVTpk_filter_nested_boolean. The BVT result was generated againstmain; its three metadata-width entries differ from 4.2 while all SQL values remain identical.Rebased onto
upstream/mainat6a8e7ecc530539948663a35a52259224ee1d128a.Validation on that base plus this branch:
make buildgo test ./pkg/vm/engine/readutil -count=1go test -race ./pkg/vm/engine/readutil -run '^TestConstructBasePKFilterWithOr$' -count=10go vet ./pkg/vm/engine/readutilmo-testerBVTpk_filter_nested_boolean: 29/29 statements, 100%