Skip to content

Conversation

meiji163
Copy link

@meiji163 meiji163 commented Jul 23, 2025

Description

Backport vitessio#16255 to our release-19.0-github branch. This is necessary because the quote escaping can cause incorrect marshaling of json column in MarshalSQLTo.

For example {"field": "[{\"k1":\"v1\"},{\"k2\":\"v2\"}]" should be marshaled as JSON_OBJECT(_utf8mb4'field', _utf8mb4'[{"k1":"v1"},{":k2":"v2"}]'). Instead it was marshaled as JSON_OBJECT(_utf8mb4'field', _utf8mb4'[{\\\"k1\\\":\\\"v1\\\"},{\\\":k2\\\":\\\"v2\\\"}]')

We encountered this in a MoveTables operation, where the VDiff found a mismatching row with extra escaped quotes in the json field.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 15:43
Copy link

@Copilot 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

This pull request removes unnecessary double escaping of quotation marks in SQL string literals across Vitess test files and related code. The changes simplify the representation of SQL strings in tests by ensuring proper single-layer escaping is used.

  • Updates SQL test expectations to use properly escaped quotes (removing \" in favor of " for double quotes)
  • Modifies sqlparser test data to reflect correct string literal formatting
  • Removes redundant escape processing in value encoding logic

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
go/vt/wrangler/traffic_switcher_test.go Updated SQL regex patterns to use proper quote escaping
go/vt/wrangler/resharder_test.go Fixed vreplication query patterns with simplified quote escaping
go/vt/wrangler/materializer_test.go Cleaned up SQL string escaping in test expectations
go/vt/vttablet/tabletmanager/vreplication/vcopier_test.go Simplified quote escaping in copy state regex patterns
go/vt/vttablet/tabletmanager/vreplication/journal_test.go Updated vreplication insert patterns
go/vt/vttablet/tabletmanager/vreplication/insert_generator_test.go Fixed keyspace string formatting
go/vt/vttablet/tabletmanager/vdiff/engine_test.go Updated JSON report string escaping
go/vt/vttablet/tabletmanager/vdiff/action_test.go Simplified JSON string formatting
go/vt/vttablet/tabletmanager/rpc_vreplication_test.go Fixed vreplication source string formatting
go/vt/vtgate/planbuilder/testdata/select_cases.json Updated JSON function test expectations
go/vt/sqlparser/testdata/select_cases.txt Fixed string literal escaping in parser test data
go/vt/sqlparser/parse_test.go Updated string parsing test expectations
go/vt/sqlparser/ast_format.go Added null check for index option formatting
go/vt/binlog/binlogplayer/binlog_player_test.go Fixed binlog source string escaping
go/sqltypes/value_test.go Updated string encoding test expectations
go/sqltypes/value.go Simplified SQL encoding character mapping

Signed-off-by: Dirkjan Bussink <[email protected]>
Signed-off-by: meiji163 <[email protected]>
@meiji163 meiji163 merged commit 408d1e6 into release-19.0-github Jul 23, 2025
194 of 199 checks passed
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.

3 participants