Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
backend/tidb: temporarily disable the strict-mode value check in tidb…
Browse files Browse the repository at this point in the history
… backend (#551)

* temporarily disable the strict-mode value check in tidb backend since it's buggy

* add link to related issue
  • Loading branch information
glorv authored Jan 18, 2021
1 parent 0c9788e commit deb5243
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
7 changes: 2 additions & 5 deletions lightning/backend/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"bytes"
"context"
"encoding/binary"
"fmt"
"github.com/pingcap/tidb-lightning/lightning/common"
"math"
"math/rand"
"os"
"path/filepath"
"sort"

"github.com/pingcap/tidb-lightning/lightning/common"

"github.com/cockroachdb/pebble"
. "github.com/pingcap/check"
"github.com/pingcap/tidb/kv"
Expand Down Expand Up @@ -378,16 +378,13 @@ func testLocalWriter(c *C, needSort bool, partitialSort bool) {
}

func (s *localSuite) TestLocalWriterWithSort(c *C) {
fmt.Println("TestLocalWriterWithSort")
testLocalWriter(c, false, false)
}

func (s *localSuite) TestLocalWriterWithIngest(c *C) {
fmt.Println("TestLocalWriterWithIngest")
testLocalWriter(c, true, false)
}

func (s *localSuite) TestLocalWriterWithIngestUnsort(c *C) {
fmt.Println("TestLocalWriterWithIngestUnsort")
testLocalWriter(c, true, true)
}
15 changes: 8 additions & 7 deletions lightning/backend/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ func (enc *tidbEncoder) appendSQL(sb *strings.Builder, datum *types.Datum, col *
value := strconv.AppendFloat(buffer[:0], datum.GetFloat64(), 'g', -1, 64)
sb.Write(value)
case types.KindString:
if enc.mode.HasStrictMode() {
d, err := table.CastValue(enc.se, *datum, col.ToInfo(), false, false)
if err != nil {
return errors.Trace(err)
}
datum = &d
}
// See: https://github.com/pingcap/tidb-lightning/issues/550
//if enc.mode.HasStrictMode() {
// d, err := table.CastValue(enc.se, *datum, col.ToInfo(), false, false)
// if err != nil {
// return errors.Trace(err)
// }
// datum = &d
//}

enc.appendSQLBytes(sb, datum.GetBytes())
case types.KindBytes:
Expand Down
3 changes: 2 additions & 1 deletion lightning/backend/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func (s *mysqlSuite) TestWriteRowsErrorOnDup(c *C) {
c.Assert(err, IsNil)
}

func (s *mysqlSuite) TestStrictMode(c *C) {
// TODO: temporarily disable this test before we fix strict mode
func (s *mysqlSuite) testStrictMode(c *C) {
ft := *types.NewFieldType(mysql.TypeVarchar)
ft.Charset = charset.CharsetUTF8MB4
col0 := &model.ColumnInfo{ID: 1, Name: model.NewCIStr("s0"), State: model.StatePublic, Offset: 0, FieldType: ft}
Expand Down

0 comments on commit deb5243

Please sign in to comment.