Skip to content

[4.2-dev] fix: support ENUM and YEAR in serial_extract - #33260

Merged
XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/33258-composite-enum-index-42
Nov 25, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/33258-composite-enum-index-42

Conversation

@XuPeng-SH

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 #33258

What this PR does / why we need it:

Backports the serial_extract ENUM/YEAR result dispatch from #26943 to 4.2-dev, using the exact named vector types types.Enum and types.MoYear. Composite secondary-index lookups no longer fail with 20101 internal error: not supported type ENUM/YEAR when extracting those key parts.

Regression coverage includes:

  • Constant-index and row-index extraction for both types.
  • Literal and binary-prepared equality/IN predicates.
  • Forced-index and no-index controls, plus NULL binds.
  • Both inline indexes and indexes backfilled with ALTER TABLE ... ADD KEY.

The backfilled ENUM path relies on the physical-key encoding from #33152, which is already merged into this PR's 4.2-dev base.

Validation:

  • go test ./pkg/sql/plan/function -run '^TestSerialExtractEnumAndYear$' -count=1: PASS.
  • Full go test ./pkg/sql/plan/function -count=1: PASS.
  • go test ./pkg/tests/issues -run '^TestIssue33258CompositeEnumAndYearIndexLookup$' -count=1 -v: PASS; inline and backfilled groups, including all 28 leaf cases.
  • go vet ./pkg/sql/plan/function ./pkg/tests/issues: PASS.
  • Independent code review found no implementation correctness issue; its prepared/backfill coverage finding was addressed in the final test.
  • Independent final QA built exact commit f5a4f4e0b26a085d9f1254cd557127c56e8b3674 (binary self-reported f5a4f4e0b2), confirmed all 31 focused-test PASS records, and passed separate ALTER ADD INDEX black-box probes for ENUM, YEAR, and an INT control.

Scope: no full repository suite or multi-CN run; validation used the controlled local darwin/arm64 CGo setup.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner November 25, 2026 15:12
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Nov 25, 2026
@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · superseded

Commit: f5a4f4e0b26a085d9f1254cd557127c56e8b3674

discussion changed before publication

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

追加正确性、鲁棒性、异常路径与性能验证

验证对象仍为最终 head f5a4f4e0b26a085d9f1254cd557127c56e8b3674;以下使用临时 QA 探针,未修改 PR 代码或提交。

正确性、鲁棒性与异常路径

  • 新增白盒 adversarial 探针:ENUM/YEAR × 常量索引/行索引,共 32 个叶子场景。
    • 正常值、NULL tuple、NULL index:结果及 NULL 语义正确。
    • 错误编码类型、空 tuple、截断 tuple、负索引、越界索引:均返回错误,未 panic。
  • go test -race -run '^(TestIssue33260AdversarialNamedExtraction|TestSerialExtractEnumAndYear)$' ./pkg/sql/plan/function:PASS,未报告 data race。
  • 使用精确 head 二进制,对回填的 (tag, enum, year, int) 复合索引进行并发验证:每阶段 16 workers × 200 iterations,即 3200 次 binary-prepared 等值查询、3200 次 NULL-safe 查询、64 次 literal 查询。
    • 重启前:PASS。
    • 重启后使用同一数据目录再次执行:PASS。
  • 资源路径审计:新增分支复用既有固定宽度提取函数;FunctionResult.Append 写入预分配结果缓冲区,不新增 goroutine、锁、等待或常驻容器。本轮未发现泄漏、double cleanup 或 hang。

性能

环境:Apple M4、darwin/arm64、Go 1.26.4;每批 1024 行,-benchmem -benchtime=1s -count=5,base c56af3c5f04c 与 PR head 使用同一临时 benchmark。

既有 INT64 路径 base 中位数 PR 中位数 中位数变化 内存/分配
常量索引 42.320 µs/batch 42.620 µs/batch +0.7% 均为 32880 B/op、2050 allocs/op
行索引 83.033 µs/batch 84.460 µs/batch +1.7% 均为 112784 B/op、4866 allocs/op

两次差值处于运行波动范围内,未观察到稳定性能回退。新增路径的 PR 中位数:ENUM 常量/行索引为 43.008/86.466 µs/batch,YEAR 为 49.481/92.410 µs/batch;这些路径在 base 上直接报错,因此没有可用的同功能性能基线。

边界:未做多 CN、OOM/分配失败或执行中取消故障注入;性能数据仅代表现有本地 darwin/arm64 微基准。

@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: f5a4f4e0b26a085d9f1254cd557127c56e8b3674

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: f5a4f4e0b26a085d9f1254cd557127c56e8b3674

Assessment: approve

The ENUM and YEAR dispatch reuses the existing tuple decoders and result types without changing stored encoding. The additional QA discussion raises no unresolved finding.

Model: gpt-6.1-terra / max

Session: 01a21136-dc54-7ba1-aace-4039c02570be · slot 2 · generation 3

Validation:

  • Current receipt 1795621215569566404-2.json verifies the frozen head, base, patch, policy files, discussion coverage, and prior native-input provenance.

  • Reused exact-head isolated test receipt 1795620864673901502-2.json and its retained log: tuple and extraction tests passed, as did all 28 embedded SQL cases.

  • Reused exact-head receipt 1795620920135159467-2.json and its retained log: the complete function package passed.

Limitations:

  • The additional adversarial, restart, race, and benchmark results in the new discussion were reported without raw artifacts and were not independently reproduced.

  • The public SQL check used one CN of an embedded cluster; no separate mo-tester or release-upgrade run was performed.

@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 20b7c18bdf9dca99262167b6c1f626fc4d2a2608

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 20b7c18bdf9dca99262167b6c1f626fc4d2a2608

Assessment: approve

The production fix correctly reuses the existing ENUM and YEAR tuple decoding paths. The new head adds test cleanup and error checks already performed by the test helper.

Model: gpt-6.1-terra / max

Session: 01a21136-dc54-7ba1-aace-4039c02570be · slot 2 · generation 3

Validation:

  • Receipt 1795624297179597671-2.json verifies the current head, clean checkout, four-line test-only delta, formatting, discussion coverage, and retained evidence provenance.

  • Reused prior isolated receipt 1795620864673901502-2.json: tuple and extraction tests and all 28 SQL cases passed.

  • Reused prior receipt 1795620920135159467-2.json: the complete function package passed.

Limitations:

  • The SQL test was not rerun at the new head; the earlier run was at f5a4f4e, before the four additional cleanup and error-check lines.

  • The separately reported adversarial, restart, race, and benchmark results were not independently reproduced.

@XuPeng-SH
XuPeng-SH merged commit 4d84605 into matrixorigin:4.2-dev Nov 25, 2026

This branch was previously deployed

1 inactive deployment
ci — 20b7c18b Deployed Nov 25, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants