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

backend: fix issue 282 #283

Merged
merged 6 commits into from
Mar 16, 2020
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lightning/backend/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`''`)
Expand Down
2 changes: 1 addition & 1 deletion lightning/backend/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion lightning/mydump/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func unescape(
case 't':
return "\t"
case 'Z':
return "\x26"
return "\x1a"
default:
return substr[1:]
}
Expand Down
2 changes: 1 addition & 1 deletion lightning/mydump/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))`,
Expand Down
1 change: 1 addition & 0 deletions tests/check_requirements/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/checkpoint_chunks/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added tests/issue_282/config.toml
Empty file.
1 change: 1 addition & 0 deletions tests/issue_282/data/issue282-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE `issue282` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
4 changes: 4 additions & 0 deletions tests/issue_282/data/issue282.t_access3-schema.sql
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions tests/issue_282/data/issue282.t_access3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*!40103 SET TIME_ZONE='+00:00' */;
INSERT INTO `t_access3` VALUES
('@P&FLASHSHA');
INSERT INTO `t_access3` VALUES
('\Z');
25 changes: 25 additions & 0 deletions tests/issue_282/run.sh
Original file line number Diff line number Diff line change
@@ -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