Skip to content

vitessdriver: send string for binary result values#19542

Merged
derekperkins merged 3 commits into
vitessio:mainfrom
derekperkins:vitessdriver-string
Apr 11, 2026
Merged

vitessdriver: send string for binary result values#19542
derekperkins merged 3 commits into
vitessio:mainfrom
derekperkins:vitessdriver-string

Conversation

@derekperkins
Copy link
Copy Markdown
Member

@derekperkins derekperkins commented Mar 3, 2026

Description

Apologies, my prior PR in #19527 did the string conversion the wrong direction, coming out of Vitess vs going into Vitess. This reverts that change and does a similar conversion before building the bind variable.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

AI Disclosure

None

@github-actions github-actions Bot added this to the v24.0.0 milestone Mar 3, 2026
@derekperkins derekperkins added the Backport to: release-23.0 Needs to be backport to release-23.0 label Mar 3, 2026
@vitess-bot vitess-bot Bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Mar 3, 2026
@vitess-bot
Copy link
Copy Markdown
Contributor

vitess-bot Bot commented Mar 3, 2026

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@derekperkins derekperkins added Type: Regression Component: Driver and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Mar 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.26%. Comparing base (70c7a72) to head (594b11c).
⚠️ Report is 168 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #19542       +/-   ##
===========================================
+ Coverage   69.67%   78.26%    +8.58%     
===========================================
  Files        1614        5     -1609     
  Lines      216793      483   -216310     
===========================================
- Hits       151044      378   -150666     
+ Misses      65749      105    -65644     
Flag Coverage Δ
partial 78.26% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@promptless
Copy link
Copy Markdown
Contributor

promptless Bot commented Mar 3, 2026

📝 Documentation updates detected!

Updated existing suggestion: Remove changelog entry for vitessdriver binary-to-string change (reverted)


Tip: Whenever you leave a comment tagged @Promptless on a Promptless PR, Promptless will remember it for future suggestions 🧠

Copy link
Copy Markdown
Member

@arthurschreiber arthurschreiber left a comment

Choose a reason for hiding this comment

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

Can you add a test case for this? Maybe a unit test and an integration level test would be good.

Copy link
Copy Markdown
Member

@dbussink dbussink left a comment

Choose a reason for hiding this comment

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

You'll also will need to fix the DCO here.

Comment on lines +60 to +63
case []byte:
if t == nil {
return sqltypes.NullBindVariable, nil
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't quite sure what the right behavior here was. There are three outcomes:

  • NullBindVariable: what is happening here, which is an untyped null
  • Typed NULL as VARBINARY: this is the only one I'm fairly confident that we don't want, as it is likely to trigger a similar error for json values
  • Typed NULL as VARCHAR: this maintains the spirit of the string conversion here, but may be unnecessary

Is there any reason to choose a typed null over what is currently happening? This has to happen before the string conversion because string isn't nullable natively

@derekperkins
Copy link
Copy Markdown
Member Author

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a9fb0f8c6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread go/vt/vitessdriver/convert.go
@mattlord mattlord modified the milestones: v24.0.0, v25.0.0 Apr 10, 2026
@derekperkins derekperkins modified the milestones: v25.0.0, v24.0.0 Apr 11, 2026
Comment thread go/vt/vitessdriver/convert_test.go Outdated
Comment on lines +249 to +251
if !reflect.DeepEqual(bv, tcase.out) {
t.Fatalf("BuildBindVariable(%v) = %#v, want %#v", tcase.in, bv, tcase.out)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit, but we should use require in new tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed and I added a commit migrating the rest of the vitessdriver tests to require

@mattlord mattlord added the Backport to: release-24.0 Needs to be backport to release-24.0 label Apr 11, 2026
…o#19527)"

Signed-off-by: Derek Perkins <derek@nozzle.io>
This reverts commit 2deac14.
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Derek Perkins <derek@nozzle.io>
Copilot AI review requested due to automatic review settings April 11, 2026 13:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates vitessdriver parameter binding to avoid sending []byte inputs as VARBINARY (which can trigger MySQL JSON charset errors), while reverting the earlier behavior change that affected how binary-typed result values are returned to Go callers.

Changes:

  • Revert ToNative behavior so binary result values remain []byte (undoing the prior “return string for binary results” approach).
  • Update BuildBindVariable to convert []byte inputs into VARCHAR bind variables (and nil []byte into NULL) before sending to Vitess.
  • Refactor several vitessdriver tests to use testify/require assertions and add targeted tests for BuildBindVariable.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
go/vt/vitessdriver/convert.go Moves the “bytes->string” conversion to bind-var construction (inputs), and removes the binary special-case from result conversion (outputs).
go/vt/vitessdriver/convert_test.go Updates ToNative expectations for binary types and adds new coverage for BuildBindVariable.
go/vt/vitessdriver/driver_test.go Converts many assertions to require and improves subtest isolation with t.Run.
go/vt/vitessdriver/rows_test.go Converts comparisons to require and removes now-unneeded mismatch logging helper.
go/vt/vitessdriver/streaming_rows_test.go Converts comparisons/error checks to require and removes unused imports.

Comment thread go/vt/vitessdriver/convert_test.go
@derekperkins derekperkins merged commit cbcdc53 into vitessio:main Apr 11, 2026
114 of 115 checks passed
@derekperkins derekperkins deleted the vitessdriver-string branch April 11, 2026 17:05
vitess-bot Bot added a commit that referenced this pull request Apr 11, 2026
Signed-off-by: Derek Perkins <derek@nozzle.io>
mattlord pushed a commit that referenced this pull request Apr 11, 2026
…9542) (#19842)

Signed-off-by: Derek Perkins <derek@nozzle.io>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
timvaillancourt pushed a commit to timvaillancourt/vitess that referenced this pull request Apr 17, 2026
Signed-off-by: Derek Perkins <derek@nozzle.io>
timvaillancourt pushed a commit to timvaillancourt/vitess that referenced this pull request May 12, 2026
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport to: release-23.0 Needs to be backport to release-23.0 Backport to: release-24.0 Needs to be backport to release-24.0 Component: Driver Type: Regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v23 regression: inserting JSON values throws an error

5 participants