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

Commit

Permalink
tests,restore: re-enable the exotic_filenames test (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm authored and lonng committed Apr 26, 2019
1 parent 9adb660 commit 9b895b6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
13 changes: 9 additions & 4 deletions lightning/restore/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/http"
"net/url"
"regexp"
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
Expand Down Expand Up @@ -79,13 +80,17 @@ func (timgr *TiDBManager) InitSchema(ctx context.Context, database string, table
Logger: log.With(zap.String("db", database)),
}

createDatabase := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s`", database)
err := sql.Exec(ctx, "create database", createDatabase)
var createDatabase strings.Builder
createDatabase.WriteString("CREATE DATABASE IF NOT EXISTS ")
common.WriteMySQLIdentifier(&createDatabase, database)
err := sql.Exec(ctx, "create database", createDatabase.String())
if err != nil {
return errors.Trace(err)
}
useDB := fmt.Sprintf("USE `%s`", database)
err = sql.Exec(ctx, "use database", useDB)
var useDB strings.Builder
useDB.WriteString("USE ")
common.WriteMySQLIdentifier(&useDB, database)
err = sql.Exec(ctx, "use database", useDB.String())
if err != nil {
return errors.Trace(err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create database `中文庫🥳`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table 中文表(a int primary key);
1 change: 1 addition & 0 deletions tests/exotic_filenames/data/中文庫🥳.中文表.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into 中文表 values (2345);
6 changes: 4 additions & 2 deletions tests/exotic_filenames/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
# Confirm the behavior for some exotic filenames
# Do not enable until https://github.com/pingcap/tidb/pull/8302 is merged.

exit 0

set -eu

run_sql 'DROP DATABASE IF EXISTS `x``f"n`;'
run_sql 'DROP DATABASE IF EXISTS `中文庫🥳`;'
run_lightning
echo 'Import finished'

Expand All @@ -33,3 +32,6 @@ check_contains 'b > 80000: 1'
run_sql 'SELECT _tidb_rowid > 80000, b > 80000 FROM `x``f"n`.`exotic``table````name` WHERE a = "gggggg"'
check_contains '_tidb_rowid > 80000: 1'
check_contains 'b > 80000: 1'

run_sql 'SELECT * FROM `中文庫🥳`.中文表'
check_contains 'a: 2345'

0 comments on commit 9b895b6

Please sign in to comment.