From 7ea78e772e1b097b231e331d7da22c6a5883602b Mon Sep 17 00:00:00 2001 From: tangenta Date: Fri, 12 Mar 2021 08:02:54 +0800 Subject: [PATCH] types: fix clustered keyword regexp (#23264) --- sessionctx/binloginfo/binloginfo_test.go | 4 ++++ types/parser_driver/special_cmt_ctrl.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sessionctx/binloginfo/binloginfo_test.go b/sessionctx/binloginfo/binloginfo_test.go index 89622fe6c226c..a64d2684aec26 100644 --- a/sessionctx/binloginfo/binloginfo_test.go +++ b/sessionctx/binloginfo/binloginfo_test.go @@ -650,6 +650,10 @@ func (s *testBinlogSuite) TestAddSpecialComment(c *C) { "create table clustered (id int)", "create table clustered (id int)", }, + { + "create table t1 (id int, a varchar(255) key clustered);", + "create table t1 (id int, a varchar(255) key /*T![clustered_index] clustered */ );", + }, } for _, ca := range testCase { re := binloginfo.AddSpecialComment(ca.input) diff --git a/types/parser_driver/special_cmt_ctrl.go b/types/parser_driver/special_cmt_ctrl.go index ffa26636981c5..6fa7ebf67d6cd 100644 --- a/types/parser_driver/special_cmt_ctrl.go +++ b/types/parser_driver/special_cmt_ctrl.go @@ -68,5 +68,5 @@ var FeatureIDPatterns = map[featureID]*regexp.Regexp{ FeatureIDAutoRandom: regexp.MustCompile(`(?P(?i)AUTO_RANDOM\b\s*(\s*\(\s*\d+\s*\)\s*)?)`), FeatureIDAutoIDCache: regexp.MustCompile(`(?P(?i)AUTO_ID_CACHE\s*=?\s*\d+\s*)`), FeatureIDAutoRandomBase: regexp.MustCompile(`(?P(?i)AUTO_RANDOM_BASE\s*=?\s*\d+\s*)`), - FeatureClusteredIndex: regexp.MustCompile(`(?i)PRIMARY\s+KEY(\s*\(.*\))?\s+(?P(NON)?CLUSTERED\b)`), + FeatureClusteredIndex: regexp.MustCompile(`(?i)(PRIMARY)?\s+KEY(\s*\(.*\))?\s+(?P(NON)?CLUSTERED\b)`), }