Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv committed Dec 25, 2020
1 parent 76b2023 commit 588e5b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lightning/backend/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,8 @@ func (*tidbEncoder) Close() {}
func getColumnByIndex(cols []*table.Column, index int) *table.Column {
if index == len(cols) {
return extraHandleTableColumn
} else {
return cols[index]
}
return cols[index]
}

func (enc *tidbEncoder) Encode(logger log.Logger, row []types.Datum, _ int64, columnPermutation []int) (Row, error) {
Expand All @@ -267,7 +266,7 @@ func (enc *tidbEncoder) Encode(logger log.Logger, row []types.Datum, _ int64, co
// See: tests/generated_columns/data/gencol.various_types.0.sql this sql has no columns, so encodeLoop will fill the
// column permutation with default, thus enc.columnCnt > len(row).
if len(row) > enc.columnCnt {
log.L().Error("column count mismatch", zap.Ints("column_permutation", columnPermutation),
logger.Error("column count mismatch", zap.Ints("column_permutation", columnPermutation),
zap.Array("data", rowArrayMarshaler(row)))
return nil, errors.Errorf("column count mismatch, expected %d, got %d", enc.columnCnt, len(row))
}
Expand Down
4 changes: 2 additions & 2 deletions lightning/restore/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ var (
"default_week_format": "0",
"block_encryption_mode": "aes-128-ecb",
"group_concat_max_len": "1024",
// allow use _tidb_rowid in sql statement
"tidb_opt_write_row_id": "1",
}
)

Expand Down Expand Up @@ -100,6 +98,8 @@ func DBFromConfig(dsn config.DBStore) (*sql.DB, error) {
// after https://github.com/pingcap/tidb/pull/17102 merge,
// we need set session to true for insert auto_random value in TiDB Backend
"allow_auto_random_explicit_insert": "1",
// allow use _tidb_rowid in sql statement
"tidb_opt_write_row_id": "1",
},
}
db, err := param.Connect()
Expand Down
4 changes: 4 additions & 0 deletions tests/tidb_rowid/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
set -eu

for BACKEND in local importer tidb; do
if [ "$BACKEND" = 'local' ]; then
check_cluster_version 4 0 0 'local backend' || continue
fi

run_sql 'DROP DATABASE IF EXISTS rowid;'
run_lightning -backend $BACKEND
echo 'Import finished'
Expand Down

0 comments on commit 588e5b6

Please sign in to comment.