Repository navigation
fix: count binary char length in bytes - #26488
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the complete diff at 2ee5ed1. The shared LENGTH_UTF8 overloads preserve UTF-8 character counting for text while defining BINARY/VARBINARY/BLOB as raw byte length, including empty, NULL, and invalid-UTF8 inputs. Focused tests passed repeatedly under -race, the full function package passed under -race, and the exact-head check run is green.
Merge Queue Status
This pull request spent 1 hour 7 minutes 58 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #26488 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks: HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25295 ## What this PR does / why we need it: `CHAR_LENGTH()` previously had overloads only for text string types. Binary arguments were therefore implicitly cast to text and counted as UTF-8 code points. For example, `CHAR_LENGTH(_binary '你好')` returned `2` instead of the MySQL-compatible byte length `6`. This change: - adds direct `BINARY`, `VARBINARY`, and `BLOB` overloads that count raw bytes; - keeps `CHAR`, `VARCHAR`, and `TEXT` on the existing UTF-8 character-counting path; - registers `CHARACTER_LENGTH()` as an alias of `CHAR_LENGTH()`; and - adds unit and BVT coverage for binary literals, binary columns, invalid UTF-8, empty values, and `NULL`. Validation: - focused function tests; - `TestLengthBinary` and `Test_GetFunctionByName` with `-race -count=100`; - full `pkg/sql/plan/function` race tests; - `make build`; - focused `go vet` and `golangci-lint` (`0 issues`); - `func_string_char_length.test` BVT (`83/83` passed); and - `git diff --check`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25295 ## What this PR does / why we need it: `CHAR_LENGTH()` previously had overloads only for text string types. Binary arguments were therefore implicitly cast to text and counted as UTF-8 code points. For example, `CHAR_LENGTH(_binary '你好')` returned `2` instead of the MySQL-compatible byte length `6`. This change: - adds direct `BINARY`, `VARBINARY`, and `BLOB` overloads that count raw bytes; - keeps `CHAR`, `VARCHAR`, and `TEXT` on the existing UTF-8 character-counting path; - registers `CHARACTER_LENGTH()` as an alias of `CHAR_LENGTH()`; and - adds unit and BVT coverage for binary literals, binary columns, invalid UTF-8, empty values, and `NULL`. Validation: - focused function tests; - `TestLengthBinary` and `Test_GetFunctionByName` with `-race -count=100`; - full `pkg/sql/plan/function` race tests; - `make build`; - focused `go vet` and `golangci-lint` (`0 issues`); - `func_string_char_length.test` BVT (`83/83` passed); and - `git diff --check`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25295 ## What this PR does / why we need it: `CHAR_LENGTH()` previously had overloads only for text string types. Binary arguments were therefore implicitly cast to text and counted as UTF-8 code points. For example, `CHAR_LENGTH(_binary '你好')` returned `2` instead of the MySQL-compatible byte length `6`. This change: - adds direct `BINARY`, `VARBINARY`, and `BLOB` overloads that count raw bytes; - keeps `CHAR`, `VARCHAR`, and `TEXT` on the existing UTF-8 character-counting path; - registers `CHARACTER_LENGTH()` as an alias of `CHAR_LENGTH()`; and - adds unit and BVT coverage for binary literals, binary columns, invalid UTF-8, empty values, and `NULL`. Validation: - focused function tests; - `TestLengthBinary` and `Test_GetFunctionByName` with `-race -count=100`; - full `pkg/sql/plan/function` race tests; - `make build`; - focused `go vet` and `golangci-lint` (`0 issues`); - `func_string_char_length.test` BVT (`83/83` passed); and - `git diff --check`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #25295
What this PR does / why we need it:
CHAR_LENGTH()previously had overloads only for text string types. Binaryarguments were therefore implicitly cast to text and counted as UTF-8 code
points. For example,
CHAR_LENGTH(_binary '你好')returned2instead of theMySQL-compatible byte length
6.This change:
BINARY,VARBINARY, andBLOBoverloads that count raw bytes;CHAR,VARCHAR, andTEXTon the existing UTF-8 character-countingpath;
CHARACTER_LENGTH()as an alias ofCHAR_LENGTH(); andempty values, and
NULL.Validation:
TestLengthBinaryandTest_GetFunctionByNamewith-race -count=100;pkg/sql/plan/functionrace tests;make build;go vetandgolangci-lint(0 issues);func_string_char_length.testBVT (83/83passed); andgit diff --check.