diff --git a/lightning/backend/tidb.go b/lightning/backend/tidb.go index 76725a890..70358cfe4 100644 --- a/lightning/backend/tidb.go +++ b/lightning/backend/tidb.go @@ -117,7 +117,7 @@ func (enc tidbEncoder) appendSQLBytes(sb *strings.Builder, value []byte) { sb.WriteString(`\r`) case '\t': sb.WriteString(`\t`) - case 0x26: + case 26: sb.WriteString(`\Z`) case '\'': sb.WriteString(`''`) diff --git a/lightning/backend/tidb_test.go b/lightning/backend/tidb_test.go index 6648eefaf..46b3c4016 100644 --- a/lightning/backend/tidb_test.go +++ b/lightning/backend/tidb_test.go @@ -75,7 +75,7 @@ func (s *mysqlSuite) TestWriteRowsReplaceOnDup(c *C) { types.NewFloat64Datum(5e-324), types.NewFloat64Datum(1.7976931348623157e+308), types.NewFloat64Datum(-0.0), - types.NewStringDatum("甲乙丙\r\n\x00\x26'\"\\`"), + types.NewStringDatum("甲乙丙\r\n\x00\x1a'\"\\`"), types.NewBinaryLiteralDatum(types.NewBinaryLiteralFromUint(0xabcdef, 6)), types.NewMysqlBitDatum(types.NewBinaryLiteralFromUint(0x98765432, 4)), types.NewDecimalDatum(types.NewDecFromFloatForTest(12.5)), diff --git a/lightning/mydump/parser.go b/lightning/mydump/parser.go index 7749245bd..78f719774 100644 --- a/lightning/mydump/parser.go +++ b/lightning/mydump/parser.go @@ -270,7 +270,7 @@ func unescape( case 't': return "\t" case 'Z': - return "\x26" + return "\x1a" default: return substr[1:] } diff --git a/lightning/mydump/parser_test.go b/lightning/mydump/parser_test.go index 6268e5dc8..43236ceca 100644 --- a/lightning/mydump/parser_test.go +++ b/lightning/mydump/parser_test.go @@ -340,7 +340,7 @@ func (s *testMydumpParserSuite) TestVariousSyntax(c *C) { }, { input: `('\0\b\n\r\t\Z\'\a')`, - expected: [][]types.Datum{{types.NewStringDatum("\x00\b\n\r\t\x26'a")}}, + expected: [][]types.Datum{{types.NewStringDatum("\x00\b\n\r\t\x1a'a")}}, }, { input: `(CONVERT("[1,2,3]" USING UTF8MB4))`, diff --git a/tests/check_requirements/run.sh b/tests/check_requirements/run.sh index 3a9c68638..26d614024 100755 --- a/tests/check_requirements/run.sh +++ b/tests/check_requirements/run.sh @@ -31,6 +31,7 @@ reset_cluster_version() { trap reset_cluster_version EXIT curl_cluster_version '{"cluster-version":"2.0.0-fake.and.error.expected"}' +sleep 1 run_sql 'DROP DATABASE IF EXISTS checkreq' set +e diff --git a/tests/checkpoint_chunks/run.sh b/tests/checkpoint_chunks/run.sh index 0c6468bae..8917b7933 100755 --- a/tests/checkpoint_chunks/run.sh +++ b/tests/checkpoint_chunks/run.sh @@ -86,9 +86,10 @@ set +e i=0 wait_max_time=20 while [ $i -lt $wait_max_time ]; do - lightning_proc=$(ps -ef|grep '[b]in/tidb-lightning.test') + lightning_proc=$(ps -ef|grep "[b]in/tidb-lightning\\.test.*$TEST_NAME") ret="$?" if [ "$ret" -eq 0 ]; then + echo "lightning is still running: $lightning_proc" sleep 1 else break diff --git a/tests/issue_282/config.toml b/tests/issue_282/config.toml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/issue_282/data/issue282-schema-create.sql b/tests/issue_282/data/issue282-schema-create.sql new file mode 100644 index 000000000..4cdf51448 --- /dev/null +++ b/tests/issue_282/data/issue282-schema-create.sql @@ -0,0 +1 @@ +CREATE DATABASE `issue282` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; diff --git a/tests/issue_282/data/issue282.t_access3-schema.sql b/tests/issue_282/data/issue282.t_access3-schema.sql new file mode 100644 index 000000000..4c955d457 --- /dev/null +++ b/tests/issue_282/data/issue282.t_access3-schema.sql @@ -0,0 +1,4 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +CREATE TABLE `t_access3` ( + `accessKey` varchar(100) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/tests/issue_282/data/issue282.t_access3.sql b/tests/issue_282/data/issue282.t_access3.sql new file mode 100644 index 000000000..2c3e038ea --- /dev/null +++ b/tests/issue_282/data/issue282.t_access3.sql @@ -0,0 +1,5 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +INSERT INTO `t_access3` VALUES +('@P&FLASHSHA'); +INSERT INTO `t_access3` VALUES +('\Z'); diff --git a/tests/issue_282/run.sh b/tests/issue_282/run.sh new file mode 100644 index 000000000..ce2a0f9e6 --- /dev/null +++ b/tests/issue_282/run.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright 2020 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +for backend in tidb importer; do + run_sql 'DROP DATABASE IF EXISTS issue282;' + run_lightning --backend $backend + + run_sql "SELECT hex(accessKey) FROM issue282.t_access3" + check_contains 'hex(accessKey): 405026464C415348534841' + check_contains 'hex(accessKey): 1A' +done