From e81b0b7149666f0ad0243b4d5700c907ed4bd7d5 Mon Sep 17 00:00:00 2001 From: walter Date: Sun, 28 Apr 2024 10:22:14 +0800 Subject: [PATCH] Fix drop table with keyword (#67) --- pkg/ccr/job.go | 2 +- .../suites/table-sync/test_keyword_name.groovy | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/ccr/job.go b/pkg/ccr/job.go index 20104b77..e857aa7b 100644 --- a/pkg/ccr/job.go +++ b/pkg/ccr/job.go @@ -1004,7 +1004,7 @@ func (j *Job) handleDropTable(binlog *festruct.TBinlog) error { tableName = srcTable.Name } - sql := fmt.Sprintf("DROP TABLE %s FORCE", tableName) + sql := fmt.Sprintf("DROP TABLE %s FORCE", utils.FormatKeywordName(tableName)) log.Infof("dropTableSql: %s", sql) if err = j.IDest.DbExec(sql); err != nil { return err diff --git a/regression-test/suites/table-sync/test_keyword_name.groovy b/regression-test/suites/table-sync/test_keyword_name.groovy index 193598c5..c1406ddc 100644 --- a/regression-test/suites/table-sync/test_keyword_name.groovy +++ b/regression-test/suites/table-sync/test_keyword_name.groovy @@ -167,4 +167,16 @@ suite("test_keyword_name") { SHOW CREATE TABLE `TEST_${context.dbName}`.`${tableName}` """, checkNewPartition, 30, "target")) + + logger.info("=== Test 3: Drop table ===") + sql "DROP TABLE `${tableName}`" + + def notExist = { res -> Boolean + return res.size() == 0 + } + + assertTrue(checkShowTimesOf(""" + SHOW CREATE TABLE `TEST_${context.dbName}`.`${tableName}` + """, + notExist, 30, "target")) } \ No newline at end of file