Skip to content

fix: encode BIT dump values as hexadecimal SQL literals - #54

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
ck89119:issue-30557-main
Oct 22, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
ck89119:issue-30557-main

Conversation

@ck89119

@ck89119 ck89119 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes matrixorigin/matrixone#30557.
Related to #50 (closed after migration to the MatrixOne issue tracker).

Encode non-NULL BIT values as hexadecimal SQL literals instead of partially escaped _binary '...' strings. Previously, a quote byte (0x27) produced invalid SQL and a backslash byte (0x5C) could change the literal's interpretation, despite a successful export.

  • Preserve byte order, leading zero bytes, and NULL values.
  • Handle a non-NULL empty byte slice without emitting an invalid bare 0x literal.
  • Leave CSV output and other column types unchanged.

Regression coverage

  • Exact output checks for special bytes, zero, NULL, empty input, multi-byte values, the 64-bit maximum, and case-insensitive BIT type names.
  • Exhaustive round-trip decoding of all 256 single-byte values.
  • A sqlmock-backed test of the complete INSERT output.
  • The new tests fail against the original implementation and pass with this fix. All changed production statements are covered (100%).

Validation

On macOS arm64, using Go 1.23.0 as declared by this repository's go.mod, with the worktree's own CGo artifacts:

  • PASS: go test -mod=readonly -v -count=1 -timeout=120s -run '^(TestConvertValueBit|TestShowInsertBit)$' ./cmd/mo-dump
  • PASS after merging main (8d78f7e): go test -mod=readonly -v -count=1 -timeout=120s -coverprofile=coverage.out ./cmd/mo-dump (complete owning package, including CSV tests).
  • PASS: go vet -mod=readonly ./cmd/mo-dump
  • PASS: make build
  • PASS: gofmt, git diff --check, and incremental golangci-lint v1.61.0 (built with Go 1.23.0).
  • PASS: real CLI export and restore through both the ordinary mysql client and --binary-mode=1. All 11 rows, primary keys, NULLs, and HEX() results matched for BIT(1), BIT(8), BIT(16), and BIT(64), including quote/backslash/control bytes and the 64-bit maximum. The test database and test-owned service were cleaned up.

Known validation limitations

The previous CSV baseline failures were resolved upstream by #63. Main has been merged without reverting those fixes; the complete package now passes. The BIT implementation and SQL restore path are unchanged by the merge, so the real-client round-trip evidence above remains applicable.

The real-service compatibility check used an existing MatrixOne binary built from clean revision 9dfe5c1be92e6ecc2cd32d1ee2deeb54233381c3; it is not a rebuild or validation of the latest MatrixOne main revision.

@ck89119
ck89119 marked this pull request as ready for review October 19, 2026 07:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T07:23:05.365621Z a17e7bc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

APPROVE at a17e7bc (base 324c33d).

Read the complete production and test delta and traced convertValue -> showInsert -> restore. The existing value encoder remains the owner; hexadecimal literals remove the quoting ambiguity without adding a second encoding path. NULL, leading zeros, empty-byte handling, mixed-case type names and all 256 one-byte values have independent output/decode oracles. No compatibility path or unnecessary abstraction was added.

Independent validation: owning-package tests have 29 passing test/subtest events, with only the two unchanged, independently base-confirmed CSV assertion failures; standalone build, vet, gofmt and diff checks pass. Real CLI export/restore preserved BIT(8)/BIT(64), quote/backslash bytes, NULL and the 64-bit maximum exactly. No unresolved actionable review comments found. No subagents used.

This approval is scoped to the reviewed change; it does not claim a green baseline package, latest-main server validation, or final combined-PR validation.

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.

[Bug]: mo-dump SQL export emits invalid literal for BIT value containing quote byte

2 participants