Repository navigation
fix(frontend): support native bit pick keys - #26611
Conversation
|
The unrelated Ubuntu/x86 UT blocker tracked by #26643 is resolved for this PR: the single permitted failed-job rerun completed successfully. There are no unresolved unrelated CI blockers. Successful rerun: https://github.com/matrixorigin/matrixone/actions/runs/30802660355/job/91661483282 |
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? |
|
Addressed both P1 findings from XuPeng-SH's review in The findings were valid and in scope:
Executable proof on the updated head:
There is no inline review thread to resolve, so I am re-requesting review on |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head c07af6a. The BIT literal conversion preserves unsigned width/range checks, unary signs, and transparent parentheses; focused frontend conversion tests passed, and the SQL regression covers public PICK behavior and atomic failure. No blocking issue found.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26074 ## What this PR does / why we need it: ### Root cause Current `main` accepts BOOL literals and decimal BIT keys, but a native BIT literal is represented by the MySQL parser as a `tree.P_bit` `NumVal` whose canonical string is `0b...`. The literal-key path sent that string to the generic BIT coercion function, which parses already-normalized decimal values in base 10. It therefore rejected the binary prefix before key materialization, while typed subquery values already arrived as normalized decimal strings. The same mismatch affected transparent AST wrappers. Unary `+b'1'` became `+0b1`, but exact integer normalization was limited to Go integer target OIDs and `types.T_bit.IsInteger()` is false. Parentheses then introduced `tree.ParenExpr` nodes that the literal classifier did not peel, so equivalent forms such as `+(b'1')`, `(+b'1')`, and a parenthesized BIT component in a composite key were rejected based only on AST shape. Finally, the scanner intentionally accepts the empty native BIT literal `b''` and canonicalizes it to `0b`, matching the normal typed SQL meaning of zero. The native-literal decoder required at least one binary digit after the prefix, so PICK incorrectly classified this valid parser output as malformed. ### Changes - Use one shared predicate for numeric AST forms that require exact integer normalization, preserving existing hexadecimal/fractional-number behavior and adding `tree.P_bit` only for BIT primary keys. - Decode native BIT literals as exact base-2 integers at the AST boundary, then feed their normalized decimal value into the existing BIT width/range check and vector append path. - Normalize the parser's canonical empty `P_bit` value to zero while retaining rejection of malformed programmatic `P_bit` AST strings. - Peel all transparent `tree.ParenExpr` layers before classifying the literal and again before classifying a unary operand. Arbitrary non-literal expressions remain unsupported. - Apply the same conversion to direct and unary-wrapped BIT literals: unary plus preserves the value, while unary minus remains invalid through the existing unsigned BIT range check. - Extend parser-to-vector unit and public BVT coverage across direct, unary, parenthesized, empty, composite, boundary, malformed, overflow, negative, and failure-atomicity cases. ### Issue-to-test proof | Issue behavior | Executable proof | | --- | --- | | BOOL literal and numeric keys | BVT covers `false`, `true`, `0`, and `1`, including update, delete, and conflict modes. | | Decimal BIT literal vs typed subquery | BVT applies key `1`, then applies the other BIT key through a typed subquery and verifies identical row semantics. | | Native `b'...'` / `B'...'` BIT literals | Unit tests parse full `DATA BRANCH PICK ... KEYS(...)` statements; BVT verifies single and composite PK application. | | Empty native BIT literal | Unit/BVT verify `KEYS(b'')` selects only the BIT zero key. | | Unary and transparent-parenthesis forms | Unit/BVT verify `+b'1'`, `+(b'1')`, `(+b'1')`, nested parentheses, and parenthesized BIT components in composite keys. | | BIT boundaries | Unit/BVT cover BIT(1), BIT(8) zero/max, BIT(64) zero/signed boundary/uint64 max, including unary-plus BIT(8) max. | | Invalid values and atomicity | Unit tests verify negative, overflow, non-literal, and malformed programmatic `P_bit` inputs fail without vector mutation; BVT puts a rejected key after a valid key and verifies the destination remains unchanged. | ### Tests run - Pre-fix focused parser-to-vector regression reproduced the empty/parenthesized failures. - `make build` - `go vet -mod=readonly ./pkg/frontend` with the repository CGo environment - Focused parser-to-vector tests for direct, unary, parenthesized, empty, malformed, boundary, and sign cases: pass - Focused test selection explicitly listed all four intended tests - Focused parser-to-vector race run: `-race -count=3` pass - Focused coverage profile: `unwrapPickKeyParens` 100% - Full controlled CGo package test: `./pkg/frontend` pass - Focused public BVT against the locally built server: 89/89 strict comparisons pass; every added expected row set was manually checked for selection semantics and failure atomicity ### CI follow-up The first Coverage job failed because only 4/6 changed production-code blocks were exercised (66.67%, below the required >75%). Commit `c5ff0283af` added malformed-AST tests for the defensive error branches. A later Ubuntu/x86 UT failure was unrelated (`TestDeleterConcurrentDelete`, tracked by matrixorigin#26643); the single permitted failed-job rerun completed successfully. ### Residual risks The change adds an O(parenthesis depth), allocation-free AST walk plus one short-lived `big.Int` parse per native BIT literal. Parsed statement size bounds both costs. It does not alter APIs, storage, wire formats, concurrency, or generic string/subquery coercion, and non-BIT targets retain their prior behavior. No known functional residual remains for matrixorigin#26074. --------- Co-authored-by: XuPeng-SH <[email protected]>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26074 ## What this PR does / why we need it: ### Root cause Current `main` accepts BOOL literals and decimal BIT keys, but a native BIT literal is represented by the MySQL parser as a `tree.P_bit` `NumVal` whose canonical string is `0b...`. The literal-key path sent that string to the generic BIT coercion function, which parses already-normalized decimal values in base 10. It therefore rejected the binary prefix before key materialization, while typed subquery values already arrived as normalized decimal strings. The same mismatch affected transparent AST wrappers. Unary `+b'1'` became `+0b1`, but exact integer normalization was limited to Go integer target OIDs and `types.T_bit.IsInteger()` is false. Parentheses then introduced `tree.ParenExpr` nodes that the literal classifier did not peel, so equivalent forms such as `+(b'1')`, `(+b'1')`, and a parenthesized BIT component in a composite key were rejected based only on AST shape. Finally, the scanner intentionally accepts the empty native BIT literal `b''` and canonicalizes it to `0b`, matching the normal typed SQL meaning of zero. The native-literal decoder required at least one binary digit after the prefix, so PICK incorrectly classified this valid parser output as malformed. ### Changes - Use one shared predicate for numeric AST forms that require exact integer normalization, preserving existing hexadecimal/fractional-number behavior and adding `tree.P_bit` only for BIT primary keys. - Decode native BIT literals as exact base-2 integers at the AST boundary, then feed their normalized decimal value into the existing BIT width/range check and vector append path. - Normalize the parser's canonical empty `P_bit` value to zero while retaining rejection of malformed programmatic `P_bit` AST strings. - Peel all transparent `tree.ParenExpr` layers before classifying the literal and again before classifying a unary operand. Arbitrary non-literal expressions remain unsupported. - Apply the same conversion to direct and unary-wrapped BIT literals: unary plus preserves the value, while unary minus remains invalid through the existing unsigned BIT range check. - Extend parser-to-vector unit and public BVT coverage across direct, unary, parenthesized, empty, composite, boundary, malformed, overflow, negative, and failure-atomicity cases. ### Issue-to-test proof | Issue behavior | Executable proof | | --- | --- | | BOOL literal and numeric keys | BVT covers `false`, `true`, `0`, and `1`, including update, delete, and conflict modes. | | Decimal BIT literal vs typed subquery | BVT applies key `1`, then applies the other BIT key through a typed subquery and verifies identical row semantics. | | Native `b'...'` / `B'...'` BIT literals | Unit tests parse full `DATA BRANCH PICK ... KEYS(...)` statements; BVT verifies single and composite PK application. | | Empty native BIT literal | Unit/BVT verify `KEYS(b'')` selects only the BIT zero key. | | Unary and transparent-parenthesis forms | Unit/BVT verify `+b'1'`, `+(b'1')`, `(+b'1')`, nested parentheses, and parenthesized BIT components in composite keys. | | BIT boundaries | Unit/BVT cover BIT(1), BIT(8) zero/max, BIT(64) zero/signed boundary/uint64 max, including unary-plus BIT(8) max. | | Invalid values and atomicity | Unit tests verify negative, overflow, non-literal, and malformed programmatic `P_bit` inputs fail without vector mutation; BVT puts a rejected key after a valid key and verifies the destination remains unchanged. | ### Tests run - Pre-fix focused parser-to-vector regression reproduced the empty/parenthesized failures. - `make build` - `go vet -mod=readonly ./pkg/frontend` with the repository CGo environment - Focused parser-to-vector tests for direct, unary, parenthesized, empty, malformed, boundary, and sign cases: pass - Focused test selection explicitly listed all four intended tests - Focused parser-to-vector race run: `-race -count=3` pass - Focused coverage profile: `unwrapPickKeyParens` 100% - Full controlled CGo package test: `./pkg/frontend` pass - Focused public BVT against the locally built server: 89/89 strict comparisons pass; every added expected row set was manually checked for selection semantics and failure atomicity ### CI follow-up The first Coverage job failed because only 4/6 changed production-code blocks were exercised (66.67%, below the required >75%). Commit `c5ff0283af` added malformed-AST tests for the defensive error branches. A later Ubuntu/x86 UT failure was unrelated (`TestDeleterConcurrentDelete`, tracked by matrixorigin#26643); the single permitted failed-job rerun completed successfully. ### Residual risks The change adds an O(parenthesis depth), allocation-free AST walk plus one short-lived `big.Int` parse per native BIT literal. Parsed statement size bounds both costs. It does not alter APIs, storage, wire formats, concurrency, or generic string/subquery coercion, and non-BIT targets retain their prior behavior. No known functional residual remains for matrixorigin#26074. --------- Co-authored-by: XuPeng-SH <[email protected]>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26074 ## What this PR does / why we need it: ### Root cause Current `main` accepts BOOL literals and decimal BIT keys, but a native BIT literal is represented by the MySQL parser as a `tree.P_bit` `NumVal` whose canonical string is `0b...`. The literal-key path sent that string to the generic BIT coercion function, which parses already-normalized decimal values in base 10. It therefore rejected the binary prefix before key materialization, while typed subquery values already arrived as normalized decimal strings. The same mismatch affected transparent AST wrappers. Unary `+b'1'` became `+0b1`, but exact integer normalization was limited to Go integer target OIDs and `types.T_bit.IsInteger()` is false. Parentheses then introduced `tree.ParenExpr` nodes that the literal classifier did not peel, so equivalent forms such as `+(b'1')`, `(+b'1')`, and a parenthesized BIT component in a composite key were rejected based only on AST shape. Finally, the scanner intentionally accepts the empty native BIT literal `b''` and canonicalizes it to `0b`, matching the normal typed SQL meaning of zero. The native-literal decoder required at least one binary digit after the prefix, so PICK incorrectly classified this valid parser output as malformed. ### Changes - Use one shared predicate for numeric AST forms that require exact integer normalization, preserving existing hexadecimal/fractional-number behavior and adding `tree.P_bit` only for BIT primary keys. - Decode native BIT literals as exact base-2 integers at the AST boundary, then feed their normalized decimal value into the existing BIT width/range check and vector append path. - Normalize the parser's canonical empty `P_bit` value to zero while retaining rejection of malformed programmatic `P_bit` AST strings. - Peel all transparent `tree.ParenExpr` layers before classifying the literal and again before classifying a unary operand. Arbitrary non-literal expressions remain unsupported. - Apply the same conversion to direct and unary-wrapped BIT literals: unary plus preserves the value, while unary minus remains invalid through the existing unsigned BIT range check. - Extend parser-to-vector unit and public BVT coverage across direct, unary, parenthesized, empty, composite, boundary, malformed, overflow, negative, and failure-atomicity cases. ### Issue-to-test proof | Issue behavior | Executable proof | | --- | --- | | BOOL literal and numeric keys | BVT covers `false`, `true`, `0`, and `1`, including update, delete, and conflict modes. | | Decimal BIT literal vs typed subquery | BVT applies key `1`, then applies the other BIT key through a typed subquery and verifies identical row semantics. | | Native `b'...'` / `B'...'` BIT literals | Unit tests parse full `DATA BRANCH PICK ... KEYS(...)` statements; BVT verifies single and composite PK application. | | Empty native BIT literal | Unit/BVT verify `KEYS(b'')` selects only the BIT zero key. | | Unary and transparent-parenthesis forms | Unit/BVT verify `+b'1'`, `+(b'1')`, `(+b'1')`, nested parentheses, and parenthesized BIT components in composite keys. | | BIT boundaries | Unit/BVT cover BIT(1), BIT(8) zero/max, BIT(64) zero/signed boundary/uint64 max, including unary-plus BIT(8) max. | | Invalid values and atomicity | Unit tests verify negative, overflow, non-literal, and malformed programmatic `P_bit` inputs fail without vector mutation; BVT puts a rejected key after a valid key and verifies the destination remains unchanged. | ### Tests run - Pre-fix focused parser-to-vector regression reproduced the empty/parenthesized failures. - `make build` - `go vet -mod=readonly ./pkg/frontend` with the repository CGo environment - Focused parser-to-vector tests for direct, unary, parenthesized, empty, malformed, boundary, and sign cases: pass - Focused test selection explicitly listed all four intended tests - Focused parser-to-vector race run: `-race -count=3` pass - Focused coverage profile: `unwrapPickKeyParens` 100% - Full controlled CGo package test: `./pkg/frontend` pass - Focused public BVT against the locally built server: 89/89 strict comparisons pass; every added expected row set was manually checked for selection semantics and failure atomicity ### CI follow-up The first Coverage job failed because only 4/6 changed production-code blocks were exercised (66.67%, below the required >75%). Commit `c5ff0283af` added malformed-AST tests for the defensive error branches. A later Ubuntu/x86 UT failure was unrelated (`TestDeleterConcurrentDelete`, tracked by matrixorigin#26643); the single permitted failed-job rerun completed successfully. ### Residual risks The change adds an O(parenthesis depth), allocation-free AST walk plus one short-lived `big.Int` parse per native BIT literal. Parsed statement size bounds both costs. It does not alter APIs, storage, wire formats, concurrency, or generic string/subquery coercion, and non-BIT targets retain their prior behavior. No known functional residual remains for matrixorigin#26074. --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26074
What this PR does / why we need it:
Root cause
Current
mainaccepts BOOL literals and decimal BIT keys, but a native BIT literal is represented by the MySQL parser as atree.P_bitNumValwhose canonical string is0b.... The literal-key path sent that string to the generic BIT coercion function, which parses already-normalized decimal values in base 10. It therefore rejected the binary prefix before key materialization, while typed subquery values already arrived as normalized decimal strings.The same mismatch affected transparent AST wrappers. Unary
+b'1'became+0b1, but exact integer normalization was limited to Go integer target OIDs andtypes.T_bit.IsInteger()is false. Parentheses then introducedtree.ParenExprnodes that the literal classifier did not peel, so equivalent forms such as+(b'1'),(+b'1'), and a parenthesized BIT component in a composite key were rejected based only on AST shape.Finally, the scanner intentionally accepts the empty native BIT literal
b''and canonicalizes it to0b, matching the normal typed SQL meaning of zero. The native-literal decoder required at least one binary digit after the prefix, so PICK incorrectly classified this valid parser output as malformed.Changes
tree.P_bitonly for BIT primary keys.P_bitvalue to zero while retaining rejection of malformed programmaticP_bitAST strings.tree.ParenExprlayers before classifying the literal and again before classifying a unary operand. Arbitrary non-literal expressions remain unsupported.Issue-to-test proof
false,true,0, and1, including update, delete, and conflict modes.1, then applies the other BIT key through a typed subquery and verifies identical row semantics.b'...'/B'...'BIT literalsDATA BRANCH PICK ... KEYS(...)statements; BVT verifies single and composite PK application.KEYS(b'')selects only the BIT zero key.+b'1',+(b'1'),(+b'1'), nested parentheses, and parenthesized BIT components in composite keys.P_bitinputs fail without vector mutation; BVT puts a rejected key after a valid key and verifies the destination remains unchanged.Tests run
make buildgo vet -mod=readonly ./pkg/frontendwith the repository CGo environment-race -count=3passunwrapPickKeyParens100%./pkg/frontendpassCI follow-up
The first Coverage job failed because only 4/6 changed production-code blocks were exercised (66.67%, below the required >75%). Commit
c5ff0283afadded malformed-AST tests for the defensive error branches. A later Ubuntu/x86 UT failure was unrelated (TestDeleterConcurrentDelete, tracked by #26643); the single permitted failed-job rerun completed successfully.Residual risks
The change adds an O(parenthesis depth), allocation-free AST walk plus one short-lived
big.Intparse per native BIT literal. Parsed statement size bounds both costs. It does not alter APIs, storage, wire formats, concurrency, or generic string/subquery coercion, and non-BIT targets retain their prior behavior. No known functional residual remains for #26074.