Skip to content

fix(optimizer): check IN casts and avoid nullability warning probes - #1393

Open
willlling wants to merge 17 commits into
oceanbase:masterfrom
willlling:fix/seek-593-in-predicate-types
Open

willlling wants to merge 17 commits into
oceanbase:masterfrom
willlling:fix/seek-593-in-predicate-types

Conversation

@willlling

@willlling willlling commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix two optimizer checks that evaluate the wrong thing:

  • IN predicate deduction checked a casted scalar against the IN-list container's null type and rejected valid queries with error 5083. Check each list element instead.
  • Nullability inference evaluated warning/error-capable constants while probing their properties. Keep nullability unknown for these expressions and preserve their execution-time evaluation.

A minimal IN trigger is:

CREATE TABLE t1(c DECIMAL(10));
CREATE TABLE t2(c DECIMAL(20));
SELECT t1.c, t2.c FROM t1, t2
WHERE t1.c = t2.c AND t2.c IN (10, 20);

CI follow-up and dependency

The completed CI run 34937566348 reached mysqltest after its earlier checkout failure. Its only failing case was sqlancer_optimizer_regressions: count 9 plus four X3 decimal-conversion warnings. Both the fixed baseline dc88204e5 and this PR's initial head reproduced that result with identical full rejects.

This branch now merges the pinned dependency #1392 at d80905ab86fc532ac60b15b4761c9adb4ed81931. That dependency is not yet merged into the base branch; its shared implementation is retained through the merge, not reimplemented here.

The dependency removes two speculative warnings. This PR's is_const_expr_not_null guard removes another speculative warning by keeping nullability unknown for warning/error-capable expressions. The remaining warning comes from actual filter execution (ObOperator::filter_batch_rows); the no-rewrite control also reports it. The resolved result-file conflict therefore retains exactly one X3 warning. Extra or missing diagnostics still fail.

Current combined commit: 55a69c3dcc1676b88fbbe2aae3c589417f5796f4. A fresh release configuration regenerated the embedded revision for that exact commit. The running process executable SHA256 matched the built binary. Local validation used the CI init.sql/init_user.sql and admin/test context, with an isolated instance.

Validation

  • Current combined release build: PASS.
  • Both original complete 5083 regression cases: PASS with unchanged expected output.
  • predicate_deduce_in_cast: PASS (decimal precision, binary/text, derived-table collation; EXPLAIN and SELECT).
  • sqlancer_optimizer_regressions: PASS, count 9 and exactly one required runtime warning.
  • git diff --check: PASS.
  • Current commit CI 35050028619: SUCCESS. Setup, all four mysqltest slices, collect, and all other PR checks passed.

Runtime failure stacks and a correction confined to the IN helper attribute the 5083 regression to #1379 (402f0e25b95006747f31477a78907e0a66147b83); no historical parent-binary bisect was performed. The additional CI warning failure predates this PR; its introducing commit has not been established.

Links

Fixed 2026-09-17 baseline verification

SEEK-609 verifies the net fixes from pinned #1392 d80905ab86fc532ac60b15b4761c9adb4ed81931 and this combined head 55a69c3dcc1676b88fbbe2aae3c589417f5796f4 on baseline 8a8d6f5a8dd48cdbf859305b3f7eb050149a5bd1. The isolated verification commit is c98a258c61c45934c932349784290bd2edda7862 (full revision and binary hash in the SEEK-609 evidence attachment). It excludes unrelated PR1394/bigtrans changes.

The internal test MR64 must require exactly one runtime X3 warning. Its old four-warning expectation matches the unfixed product (EXPLAIN 3, SELECT 4) and is not the corrected semantic oracle. Original SQL and warning checks remain unchanged.

Related: SEEK-604, SEEK-609.

Local validation on that fixed-baseline combination: 18/18 complete cases PASS, including all 12 original warning cases, both original IN/deduction cases, SQLancer (counts 9/5/5/1, exactly one X3 warning), predicate_deduce_in_cast, uuid_having_warning, and window_function.sqlancer_const_prop_cast. Original query and all-block NO_REWRITE phase probes both produced EXPLAIN 0 / SELECT 1 warning, count 9. Binary and running executable SHA256: d6144cd64fbadabf56feed14c8ab3c382a2fe5d1240b633ee0df38b3f993ab79. Initial -j80 build lost one geo compiler process (Killed); incremental -j8 build succeeded. No additional product fix was needed; this verification does not establish historical warning first-bad. MR64 is updated on its original branch to 74261325ea064c75597f8272c66cbba42800ac9a; no PR/MR was merged.

willlling and others added 4 commits September 15, 2026 14:34
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
@willlling willlling changed the title fix(optimizer): check IN deduction casts against list elements fix(optimizer): check IN casts and avoid nullability warning probes Sep 15, 2026
willlling and others added 10 commits September 15, 2026 16:45
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
This reverts commit e260f0c.

Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
This reverts commit 4ed5118.

Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
willlling and others added 3 commits September 15, 2026 20:20
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
Co-authored-by: antmultica-agent <agent@antmultica.alipay.com>
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