Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions binlog_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (s *BinlogStreamer) createBinlogSyncer() error {
Password: s.DBConfig.Pass,
TLSConfig: tlsConfig,
UseDecimal: true,
UseFloatWithTrailingZero: true,
TimestampStringLocation: time.UTC,
}

Expand Down
2 changes: 1 addition & 1 deletion copydb/test/copydb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (t *CopydbTestSuite) TestCreateDatabasesAndTablesAlreadyExists() {
testhelpers.SeedInitialData(t.ferry.TargetDB, renamedSchemaName, renamedTableName, 1)

err = t.copydbFerry.CreateDatabasesAndTables()
t.Require().EqualError(err, "Error 1050: Table 'test_table_1_renamed' already exists")
t.Require().EqualError(err, "Error 1050 (42S01): Table 'test_table_1_renamed' already exists")
}

func (t *CopydbTestSuite) TestCreateDatabasesAndTablesAlreadyExistsAllowed() {
Expand Down
3 changes: 3 additions & 0 deletions dml_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ func appendEscapedValue(buffer []byte, value interface{}, column schema.TableCol

return appendEscapedString(buffer, v, rightPadLengthForBinaryColumn)
case []byte:
if column.Type == schema.TYPE_JSON {
return appendEscapedBuffer(buffer, v, true)
}
// schema type cannot be JSON at this point because all JSON results are strings
return appendEscapedBuffer(buffer, v, false)
case bool:
Expand Down
27 changes: 17 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,39 @@ go 1.24.1
require (
github.com/DataDog/datadog-go v4.8.2+incompatible
github.com/Masterminds/squirrel v0.0.0-20180620232226-b127ed9be034
github.com/go-mysql-org/go-mysql v1.4.1-0.20220112102103-b3f1a27311d8
github.com/go-sql-driver/mysql v1.5.0
github.com/go-mysql-org/go-mysql v1.12.1-0.20250611010020-447a516ce9c0
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.

Since this is not a released version, we'll need to bump again once the maintainers cut a new release, though I guess it will be picked up by dependabot.

github.com/go-sql-driver/mysql v1.7.1
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
github.com/gorilla/mux v1.6.1
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
github.com/shopspring/decimal v1.2.0
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.4.0
github.com/stretchr/testify v1.8.4
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/lann/builder v0.0.0-20180216234317-1b87b36280d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 // indirect
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3 // indirect
github.com/pingcap/errors v0.11.5-0.20250318082626-8f80e5cb09ec // indirect
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a // indirect
github.com/pingcap/tidb/pkg/parser v0.0.0-20250421232622-526b2c79173d // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect
golang.org/x/text v0.24.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
132 changes: 50 additions & 82 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions sharding/test/copy_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func (t *CopyFilterTestSuite) SetupTest() {
Columns: columns,
PKColumns: []int{0},
Indexes: []*schema.Index{
{Name: "unrelated_index", Columns: []string{"tenant_id", "data"}},
{Name: "less_good_sharding_index", Columns: []string{"tenant_id"}},
{Name: "good_sharding_index", Columns: []string{"tenant_id", "id"}},
{Name: "unrelated_index2", Columns: []string{"data"}},
{Name: "unrelated_index", Columns: []string{"tenant_id", "data"}, Visible: true},
{Name: "less_good_sharding_index", Columns: []string{"tenant_id"}, Visible: true},
{Name: "good_sharding_index", Columns: []string{"tenant_id", "id"}, Visible: true},
{Name: "unrelated_index2", Columns: []string{"data"}, Visible: true},
},
},
PaginationKeyColumn: &columns[0],
Expand All @@ -54,7 +54,7 @@ func (t *CopyFilterTestSuite) SetupTest() {
Columns: columns,
PKColumns: []int{0},
Indexes: []*schema.Index{
{Name: "good_sharding_index", Columns: []string{"tenant_id", "id"}},
{Name: "good_sharding_index", Columns: []string{"tenant_id", "id"}, Visible: true},
},
},
PaginationKeyColumn: &columns[0],
Expand Down
9 changes: 9 additions & 0 deletions table_schema_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ func LoadTables(db *sql.DB, tableFilter TableFilter, columnCompressionConfig Col
return tableSchemaCache, err
}

// Filter out invisible indexes
visibleIndexes := make([]*schema.Index, 0, len(tableSchema.Indexes))
for _, index := range tableSchema.Indexes {
if index.Visible {
visibleIndexes = append(visibleIndexes, index)
}
}
tableSchema.Indexes = visibleIndexes

tableSchemas = append(tableSchemas, &TableSchema{
Table: tableSchema,
CompressedColumnsForVerification: columnCompressionConfig.CompressedColumnsFor(dbname, table),
Expand Down
16 changes: 8 additions & 8 deletions test/go/dml_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ func (this *DMLEventsTestSuite) TestBinlogInsertEventGeneratesInsertQuery() {

q1, err := dmlEvents[0].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("INSERT IGNORE INTO `target_schema`.`target_table` (`col1`,`col2`,`col3`) VALUES (1000,_binary'val1',1)", q1)
this.Require().Equal("INSERT IGNORE INTO `target_schema`.`target_table` (`col1`,`col2`,`col3`) VALUES (1000,CAST('val1' AS JSON),1)", q1)

q2, err := dmlEvents[1].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("INSERT IGNORE INTO `target_schema`.`target_table` (`col1`,`col2`,`col3`) VALUES (1001,_binary'val2',0)", q2)
this.Require().Equal("INSERT IGNORE INTO `target_schema`.`target_table` (`col1`,`col2`,`col3`) VALUES (1001,CAST('val2' AS JSON),0)", q2)

q3, err := dmlEvents[2].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
Expand Down Expand Up @@ -133,11 +133,11 @@ func (this *DMLEventsTestSuite) TestBinlogUpdateEventGeneratesUpdateQuery() {

q1, err := dmlEvents[0].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1000,`col2`=_binary'val2',`col3`=0 WHERE `col1`=1000 AND `col2`=_binary'val1' AND `col3`=1", q1)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1000,`col2`=CAST('val2' AS JSON),`col3`=0 WHERE `col1`=1000 AND `col2`=CAST('val1' AS JSON) AND `col3`=1", q1)

q2, err := dmlEvents[1].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1001,`col2`=_binary'val4',`col3`=1 WHERE `col1`=1001 AND `col2`=_binary'val3' AND `col3`=0", q2)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1001,`col2`=CAST('val4' AS JSON),`col3`=1 WHERE `col1`=1001 AND `col2`=CAST('val3' AS JSON) AND `col3`=0", q2)

q3, err := dmlEvents[2].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
Expand Down Expand Up @@ -174,7 +174,7 @@ func (this *DMLEventsTestSuite) TestBinlogUpdateEventWithNull() {

q1, err := dmlEvents[0].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1000,`col2`=_binary'val2',`col3`=NULL WHERE `col1`=1000 AND `col2`=_binary'val1' AND `col3` IS NULL", q1)
this.Require().Equal("UPDATE `target_schema`.`target_table` SET `col1`=1000,`col2`=CAST('val2' AS JSON),`col3`=NULL WHERE `col1`=1000 AND `col2`=CAST('val1' AS JSON) AND `col3` IS NULL", q1)
}

func (this *DMLEventsTestSuite) TestBinlogUpdateEventMetadata() {
Expand Down Expand Up @@ -208,11 +208,11 @@ func (this *DMLEventsTestSuite) TestBinlogDeleteEventGeneratesDeleteQuery() {

q1, err := dmlEvents[0].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1000 AND `col2`=_binary'val1' AND `col3`=1", q1)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1000 AND `col2`=CAST('val1' AS JSON) AND `col3`=1", q1)

q2, err := dmlEvents[1].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1001 AND `col2`=_binary'val2' AND `col3`=0", q2)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1001 AND `col2`=CAST('val2' AS JSON) AND `col3`=0", q2)
}

func (this *DMLEventsTestSuite) TestBinlogDeleteEventWithNull() {
Expand All @@ -229,7 +229,7 @@ func (this *DMLEventsTestSuite) TestBinlogDeleteEventWithNull() {

q1, err := dmlEvents[0].AsSQLString(this.targetTable.Schema, this.targetTable.Name)
this.Require().Nil(err)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1000 AND `col2`=_binary'val1' AND `col3` IS NULL", q1)
this.Require().Equal("DELETE FROM `target_schema`.`target_table` WHERE `col1`=1000 AND `col2`=CAST('val1' AS JSON) AND `col3` IS NULL", q1)
}

func (this *DMLEventsTestSuite) TestBinlogDeleteEventWithWrongColumnsReturnsError() {
Expand Down
4 changes: 2 additions & 2 deletions test/go/lag_throttler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ func TestThrottlerRunErrors(t *testing.T) {

err = throttler.Run(ctx)
assert.NotNil(t, err)
expectedError := "Error 1146: Table 'meta.lag_table' doesn't exist"
expectedError := "Error 1146 (42S02): Table 'meta.lag_table' doesn't exist"

if os.Getenv("MYSQL_VERSION") == "8.0" || os.Getenv("MYSQL_VERSION") == "8.4" {
expectedError = "Error 1049: Unknown database 'meta'"
expectedError = "Error 1049 (42000): Unknown database 'meta'"
}

validError := (err.Error() == expectedError)
Expand Down
27 changes: 27 additions & 0 deletions vendor/filippo.io/edwards25519/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/filippo.io/edwards25519/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/filippo.io/edwards25519/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading