From 961ac6d70d43a0b0210fd1265d6bfe50887e83f2 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 7 Nov 2018 14:11:05 +0800 Subject: [PATCH 01/19] update README.md, fix `make test`, add circle.yml --- .gitignore | 2 + Makefile | 4 + README.md | 50 +++++++ circle.yml | 12 ++ go.mod => go.mod1 | 2 +- go.sum => go.sum1 | 4 + mysql/const_test.go | 321 -------------------------------------------- 7 files changed, 73 insertions(+), 322 deletions(-) create mode 100644 circle.yml rename go.mod => go.mod1 (91%) rename go.sum => go.sum1 (98%) delete mode 100644 mysql/const_test.go diff --git a/.gitignore b/.gitignore index f1028630d..d35a30cb6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ bin/ y.go *.output .idea/ +go.mod +go.sum \ No newline at end of file diff --git a/Makefile b/Makefile index 169820b9a..881d06b0e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,11 @@ LINUX:="Linux" all: parser.go test: parser.go + mv go.mod1 go.mod + mv go.sum1 go.sum GO111MODULE=on go test ./... + mv go.mod go.mod1 + mv go.sum go.sum1 parser.go: parser.y make parser diff --git a/README.md b/README.md index 495e286f8..faf639c4f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,52 @@ # parser + TiDB SQL Parser + +## How to update parser for TiDB + +Suppose you want to pull a request to TiDB, and the PR needs to change the parser, here is how to do it. + +### Step 1, make changes in your parser repository + +Fork this repository to your own account, commit the changes to your repository. + +* Don't forget to run `make test` before you commit! +* Make sure the `parser.go` is updated. + +Suppose the forked repository is `https://github.com/your-repo/parser`. + +### Step 2, let TiDB use your parser changes and run CI + +In your TiDB repository, modify the `go.mod` file, remove `github.com/pingcap/parser` from the `require` instruction, add a new line at the end of file like this: + +``` +replace github.com/pingcap/parser => github.com/your-repo/parser v0.0.0-20181102150703-4acd198f5092 +``` + +This change tells TiDB to use the modified parser from your repository. + +You can get correct version information by running this command in your TiDB directory: + +``` +GO111MODULE=on go get -u github.com/your-repo/parser@master +``` + +If you get some error output, never mind. You can still edit the `go.mod` file manually. + +Pull a request to TiDB. + +### Step 3, merge the parser to this repository + +Pull a request to this repository. **Link the related PR in TiDB in your PR description or comment**. + +The PR will be reviewed, if everything goes well, it will be merged. + +### Step 4, update TiDB to use the latest parser + +In your TiDB pull request, modify the `go.mod` file manually or use this command: + +``` +GO111MODULE=on go get -u github.com/pingcap/parser@master +``` + +Make sure the `replace` instruction is changed back to the `require` instruction and the version is latest. diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..118a417f3 --- /dev/null +++ b/circle.yml @@ -0,0 +1,12 @@ +version: 2 + +jobs: + build: + docker: + - image: golang:1.11 + working_directory: /go/src/github.com/pingcap/parser + steps: + - checkout + - run: + name: "Build & Test" + command: make test diff --git a/go.mod b/go.mod1 similarity index 91% rename from go.mod rename to go.mod1 index 621567678..964020e71 100644 --- a/go.mod +++ b/go.mod1 @@ -8,7 +8,7 @@ require ( github.com/cznic/y v0.0.0-20170802143616-045f81c6662a github.com/pingcap/check v0.0.0-20171206051426-1c287c953996 github.com/pingcap/errors v0.11.0 - github.com/pingcap/tidb v0.0.0-20181105182855-379ee5b1915a + github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70 github.com/pingcap/tipb v0.0.0-20181012112600-11e33c750323 github.com/sirupsen/logrus v1.2.0 golang.org/x/net v0.0.0-20181029044818-c44066c5c816 diff --git a/go.sum b/go.sum1 similarity index 98% rename from go.sum rename to go.sum1 index 619f276a4..6f3974c27 100644 --- a/go.sum +++ b/go.sum1 @@ -139,6 +139,10 @@ github.com/pingcap/pd v2.1.0-rc.4+incompatible h1:/buwGk04aHO5odk/+O8ZOXGs4qkUjY github.com/pingcap/pd v2.1.0-rc.4+incompatible/go.mod h1:nD3+EoYes4+aNNODO99ES59V83MZSI+dFbhyr667a0E= github.com/pingcap/tidb v0.0.0-20181105182855-379ee5b1915a h1:Qd8qbDnsmAIXxefGBgFrWh4y0GDO6froUNFqZYmC568= github.com/pingcap/tidb v0.0.0-20181105182855-379ee5b1915a/go.mod h1:tq1TVnaDUrh46KbB+oJA34Ob3eMbinTopWVzhX5Rj94= +github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70 h1:a71Zzbf3hautypbfreDgnT+NWtTTJATGGcssArxl/WQ= +github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70/go.mod h1:tq1TVnaDUrh46KbB+oJA34Ob3eMbinTopWVzhX5Rj94= +github.com/pingcap/tidb v2.0.8+incompatible h1:4G85C71eFTQRJ0Icwul/z3gJfR0u0aWXq1t/f4O8R40= +github.com/pingcap/tidb v2.0.8+incompatible/go.mod h1:I8C6jrPINP2rrVunTRd7C9fRRhQrtR43S1/CL5ix/yQ= github.com/pingcap/tidb-tools v0.0.0-20181101090416-cfac1096162e h1:LKGiK9RwOntq4kniQdGM9q1Cg4AGeIyHBeiFc2OIlpo= github.com/pingcap/tidb-tools v0.0.0-20181101090416-cfac1096162e/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= github.com/pingcap/tipb v0.0.0-20181012112600-11e33c750323 h1:mRKKzRjDNaUNPnAkPAHnRqpNmwNWBX1iA+hxlmvQ93I= diff --git a/mysql/const_test.go b/mysql/const_test.go deleted file mode 100644 index 11c61157b..000000000 --- a/mysql/const_test.go +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright 2017 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. - -package mysql_test - -import ( - "flag" - "testing" - - . "github.com/pingcap/check" - "github.com/pingcap/parser" - "github.com/pingcap/parser/mysql" - "github.com/pingcap/tidb/domain" - "github.com/pingcap/tidb/kv" - "github.com/pingcap/tidb/session" - "github.com/pingcap/tidb/store/mockstore" - "github.com/pingcap/tidb/store/mockstore/mocktikv" - "github.com/pingcap/tidb/util/testkit" - "github.com/pingcap/tidb/util/testleak" - "golang.org/x/net/context" -) - -func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) -} - -var _ = Suite(&testMySQLConstSuite{}) - -type testMySQLConstSuite struct { - cluster *mocktikv.Cluster - mvccStore mocktikv.MVCCStore - store kv.Storage - dom *domain.Domain - *parser.Parser -} - -var mockTikv = flag.Bool("mockTikv", true, "use mock tikv store in executor test") - -func (s *testMySQLConstSuite) SetUpSuite(c *C) { - s.Parser = parser.New() - flag.Lookup("mockTikv") - useMockTikv := *mockTikv - if useMockTikv { - s.cluster = mocktikv.NewCluster() - mocktikv.BootstrapWithSingleStore(s.cluster) - s.mvccStore = mocktikv.MustNewMVCCStore() - store, err := mockstore.NewMockTikvStore( - mockstore.WithCluster(s.cluster), - mockstore.WithMVCCStore(s.mvccStore), - ) - c.Assert(err, IsNil) - s.store = store - session.SetSchemaLease(0) - session.SetStatsLease(0) - } - var err error - s.dom, err = session.BootstrapSession(s.store) - c.Assert(err, IsNil) -} - -func (s *testMySQLConstSuite) TearDownSuite(c *C) { - s.dom.Close() - s.store.Close() - testleak.AfterTest(c)() -} - -func (s *testMySQLConstSuite) TestGetSQLMode(c *C) { - positiveCases := []struct { - arg string - }{ - {"NO_ZERO_DATE"}, - {",,NO_ZERO_DATE"}, - {"NO_ZERO_DATE,NO_ZERO_IN_DATE"}, - {""}, - {", "}, - {","}, - } - - for _, t := range positiveCases { - _, err := mysql.GetSQLMode(mysql.FormatSQLModeStr(t.arg)) - c.Assert(err, IsNil) - } - - negativeCases := []struct { - arg string - }{ - {"NO_ZERO_DATE, NO_ZERO_IN_DATE"}, - {"NO_ZERO_DATE,adfadsdfasdfads"}, - {", ,NO_ZERO_DATE"}, - {" ,"}, - } - - for _, t := range negativeCases { - _, err := mysql.GetSQLMode(mysql.FormatSQLModeStr(t.arg)) - c.Assert(err, NotNil) - } -} - -func (s *testMySQLConstSuite) TestSQLMode(c *C) { - tests := []struct { - arg string - hasNoZeroDateMode bool - hasNoZeroInDateMode bool - hasErrorForDivisionByZeroMode bool - }{ - {"NO_ZERO_DATE", true, false, false}, - {"NO_ZERO_IN_DATE", false, true, false}, - {"ERROR_FOR_DIVISION_BY_ZERO", false, false, true}, - {"NO_ZERO_IN_DATE,NO_ZERO_DATE", true, true, false}, - {"NO_ZERO_DATE,NO_ZERO_IN_DATE", true, true, false}, - {"NO_ZERO_DATE,NO_ZERO_IN_DATE", true, true, false}, - {"NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO", true, true, true}, - {"NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO", false, true, true}, - {"", false, false, false}, - } - - for _, t := range tests { - sqlMode, _ := mysql.GetSQLMode(t.arg) - c.Assert(sqlMode.HasNoZeroDateMode(), Equals, t.hasNoZeroDateMode) - c.Assert(sqlMode.HasNoZeroInDateMode(), Equals, t.hasNoZeroInDateMode) - c.Assert(sqlMode.HasErrorForDivisionByZeroMode(), Equals, t.hasErrorForDivisionByZeroMode) - } -} - -func (s *testMySQLConstSuite) TestRealAsFloatMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("drop table if exists t;") - tk.MustExec("create table t (a real);") - result := tk.MustQuery("desc t") - c.Check(result.Rows(), HasLen, 1) - row := result.Rows()[0] - c.Assert(row[1], Equals, "double") - - tk.MustExec("drop table if exists t;") - tk.MustExec("set sql_mode='REAL_AS_FLOAT'") - tk.MustExec("create table t (a real)") - result = tk.MustQuery("desc t") - c.Check(result.Rows(), HasLen, 1) - row = result.Rows()[0] - c.Assert(row[1], Equals, "float") -} - -func (s *testMySQLConstSuite) TestPipesAsConcatMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("SET sql_mode='PIPES_AS_CONCAT';") - r := tk.MustQuery(`SELECT 'hello' || 'world';`) - r.Check(testkit.Rows("helloworld")) -} - -func (s *testMySQLConstSuite) TestNoUnsignedSubtractionMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - ctx := context.Background() - tk.MustExec("set sql_mode='NO_UNSIGNED_SUBTRACTION'") - r := tk.MustQuery("SELECT CAST(0 as UNSIGNED) - 1;") - r.Check(testkit.Rows("-1")) - rs, _ := tk.Exec("SELECT CAST(18446744073709551615 as UNSIGNED) - 1;") - _, err := session.GetRows4Test(ctx, tk.Se, rs) - c.Assert(err, NotNil) - c.Assert(rs.Close(), IsNil) - rs, _ = tk.Exec("SELECT 1 - CAST(18446744073709551615 as UNSIGNED);") - _, err = session.GetRows4Test(ctx, tk.Se, rs) - c.Assert(err, NotNil) - c.Assert(rs.Close(), IsNil) - rs, _ = tk.Exec("SELECT CAST(-1 as UNSIGNED) - 1") - _, err = session.GetRows4Test(ctx, tk.Se, rs) - c.Assert(err, NotNil) - c.Assert(rs.Close(), IsNil) - rs, _ = tk.Exec("SELECT CAST(9223372036854775808 as UNSIGNED) - 1") - _, err = session.GetRows4Test(ctx, tk.Se, rs) - c.Assert(err, NotNil) - c.Assert(rs.Close(), IsNil) -} - -func (s *testMySQLConstSuite) TestHighNotPrecedenceMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("drop table if exists t1") - tk.MustExec("create table t1 (a int);") - tk.MustExec("insert into t1 values (0),(1),(NULL);") - r := tk.MustQuery(`SELECT * FROM t1 WHERE NOT a BETWEEN 2 AND 3;`) - r.Check(testkit.Rows("0", "1")) - r = tk.MustQuery(`SELECT NOT 1 BETWEEN -5 AND 5;`) - r.Check(testkit.Rows("0")) - tk.MustExec("set sql_mode='high_not_precedence';") - r = tk.MustQuery(`SELECT * FROM t1 WHERE NOT a BETWEEN 2 AND 3;`) - r.Check(testkit.Rows()) - r = tk.MustQuery(`SELECT NOT 1 BETWEEN -5 AND 5;`) - r.Check(testkit.Rows("1")) -} - -func (s *testMySQLConstSuite) TestIgnoreSpaceMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("set sql_mode=''") - tk.MustExec("CREATE TABLE COUNT (a bigint);") - tk.MustExec("DROP TABLE COUNT;") - tk.MustExec("CREATE TABLE `COUNT` (a bigint);") - tk.MustExec("DROP TABLE COUNT;") - _, err := tk.Exec("CREATE TABLE COUNT(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.COUNT(a bigint);") - tk.MustExec("DROP TABLE COUNT;") - - tk.MustExec("CREATE TABLE BIT_AND (a bigint);") - tk.MustExec("DROP TABLE BIT_AND;") - tk.MustExec("CREATE TABLE `BIT_AND` (a bigint);") - tk.MustExec("DROP TABLE BIT_AND;") - _, err = tk.Exec("CREATE TABLE BIT_AND(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.BIT_AND(a bigint);") - tk.MustExec("DROP TABLE BIT_AND;") - - tk.MustExec("CREATE TABLE NOW (a bigint);") - tk.MustExec("DROP TABLE NOW;") - tk.MustExec("CREATE TABLE `NOW` (a bigint);") - tk.MustExec("DROP TABLE NOW;") - _, err = tk.Exec("CREATE TABLE NOW(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.NOW(a bigint);") - tk.MustExec("DROP TABLE NOW;") - - tk.MustExec("set sql_mode='IGNORE_SPACE'") - _, err = tk.Exec("CREATE TABLE COUNT (a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE `COUNT` (a bigint);") - tk.MustExec("DROP TABLE COUNT;") - _, err = tk.Exec("CREATE TABLE COUNT(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.COUNT(a bigint);") - tk.MustExec("DROP TABLE COUNT;") - - _, err = tk.Exec("CREATE TABLE BIT_AND (a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE `BIT_AND` (a bigint);") - tk.MustExec("DROP TABLE BIT_AND;") - _, err = tk.Exec("CREATE TABLE BIT_AND(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.BIT_AND(a bigint);") - tk.MustExec("DROP TABLE BIT_AND;") - - _, err = tk.Exec("CREATE TABLE NOW (a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE `NOW` (a bigint);") - tk.MustExec("DROP TABLE NOW;") - _, err = tk.Exec("CREATE TABLE NOW(a bigint);") - c.Assert(err, NotNil) - tk.MustExec("CREATE TABLE test.NOW(a bigint);") - tk.MustExec("DROP TABLE NOW;") - -} - -func (s *testMySQLConstSuite) TestPadCharToFullLengthMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - // test type `CHAR(n)` - tk.MustExec("drop table if exists t1") - tk.MustExec("create table t1 (a char(10));") - tk.MustExec("insert into t1 values ('xy');") - tk.MustExec("set sql_mode='';") - r := tk.MustQuery(`SELECT a='xy ', char_length(a) FROM t1;`) - r.Check(testkit.Rows("0 2")) - r = tk.MustQuery(`SELECT count(*) FROM t1 WHERE a='xy ';`) - r.Check(testkit.Rows("0")) - tk.MustExec("set sql_mode='PAD_CHAR_TO_FULL_LENGTH';") - r = tk.MustQuery(`SELECT a='xy ', char_length(a) FROM t1;`) - r.Check(testkit.Rows("1 10")) - r = tk.MustQuery(`SELECT count(*) FROM t1 WHERE a='xy ';`) - r.Check(testkit.Rows("1")) - - // test type `VARCHAR(n)` - tk.MustExec("drop table if exists t1") - tk.MustExec("create table t1 (a varchar(10));") - tk.MustExec("insert into t1 values ('xy');") - tk.MustExec("set sql_mode='';") - r = tk.MustQuery(`SELECT a='xy ', char_length(a) FROM t1;`) - r.Check(testkit.Rows("0 2")) - r = tk.MustQuery(`SELECT count(*) FROM t1 WHERE a='xy ';`) - r.Check(testkit.Rows("0")) - tk.MustExec("set sql_mode='PAD_CHAR_TO_FULL_LENGTH';") - r = tk.MustQuery(`SELECT a='xy ', char_length(a) FROM t1;`) - r.Check(testkit.Rows("0 2")) -} - -func (s *testMySQLConstSuite) TestNoBackslashEscapesMode(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("set sql_mode=''") - r := tk.MustQuery("SELECT '\\\\'") - r.Check(testkit.Rows("\\")) - tk.MustExec("set sql_mode='NO_BACKSLASH_ESCAPES'") - r = tk.MustQuery("SELECT '\\\\'") - r.Check(testkit.Rows("\\\\")) -} - -func (s *testMySQLConstSuite) TestServerStatus(c *C) { - tests := []struct { - arg uint16 - IsCursorExists bool - }{ - {0, false}, - {mysql.ServerStatusInTrans | mysql.ServerStatusNoBackslashEscaped, false}, - {mysql.ServerStatusCursorExists, true}, - {mysql.ServerStatusCursorExists | mysql.ServerStatusLastRowSend, true}, - } - - for _, t := range tests { - ret := mysql.HasCursorExistsFlag(t.arg) - c.Assert(ret, Equals, t.IsCursorExists) - } -} From 396005b7232ffb836a6e95f8974e23ca6631af48 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 8 Nov 2018 15:07:43 +0800 Subject: [PATCH 02/19] address comment --- Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 881d06b0e..b9f2598f4 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,7 @@ LINUX:="Linux" all: parser.go test: parser.go - mv go.mod1 go.mod - mv go.sum1 go.sum - GO111MODULE=on go test ./... - mv go.mod go.mod1 - mv go.sum go.sum1 + ./build.sh parser.go: parser.y make parser @@ -38,3 +34,4 @@ bin/goyacc: goyacc/main.go clean: go clean -i ./... rm -rf *.out + rm parser.go From aa84a573cd5d1136e3c4cd8640cca25b3d21eb9e Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 8 Nov 2018 15:10:33 +0800 Subject: [PATCH 03/19] add build.sh --- build.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 000000000..8fdc231ce --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +{ + mv go.mod1 go.mod + mv go.sum1 go.sum + GO111MODULE=on go test ./... +} || { + mv go.mod go.mod1 + mv go.sum go.sum1 +} + +mv go.mod go.mod1 +mv go.sum go.sum1 From f48f2e5160f2aeb78210e46e6238f735d70e1a44 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 8 Nov 2018 16:09:05 +0800 Subject: [PATCH 04/19] address comment --- Makefile | 2 +- build.sh => test.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) rename build.sh => test.sh (92%) diff --git a/Makefile b/Makefile index b9f2598f4..4ae44861c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LINUX:="Linux" all: parser.go test: parser.go - ./build.sh + sh test.sh parser.go: parser.y make parser diff --git a/build.sh b/test.sh similarity index 92% rename from build.sh rename to test.sh index 8fdc231ce..37733f4c4 100644 --- a/build.sh +++ b/test.sh @@ -1,5 +1,3 @@ -#!/bin/bash - { mv go.mod1 go.mod mv go.sum1 go.sum From 736d72195b10b394a5a7116e88aadbee68ef6c54 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:29:25 +0800 Subject: [PATCH 05/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index faf639c4f..f4ed577a1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Suppose you want to pull a request to TiDB, and the PR needs to change the parse ### Step 1, make changes in your parser repository -Fork this repository to your own account, commit the changes to your repository. +Fork this repository to your own account and commit the changes to your repository. * Don't forget to run `make test` before you commit! * Make sure the `parser.go` is updated. From 06a2520d8ab08489ba96544db3d0a21e1c2aa11d Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:30:47 +0800 Subject: [PATCH 06/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4ed577a1..fe2e67a62 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ TiDB SQL Parser ## How to update parser for TiDB -Suppose you want to pull a request to TiDB, and the PR needs to change the parser, here is how to do it. +Assuming that you want to file a PR (pull request) to TiDB, and your PR includes a change in the parser, implement the following steps to update the parser in TiDB. ### Step 1, make changes in your parser repository From 84d0b1759f7fb38dec3d215a25aec70546059eea Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:31:29 +0800 Subject: [PATCH 07/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe2e67a62..c9c99c44a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Fork this repository to your own account and commit the changes to your reposito Suppose the forked repository is `https://github.com/your-repo/parser`. -### Step 2, let TiDB use your parser changes and run CI +### Step 2: Make your parser changes take effect in TiDB and run CI In your TiDB repository, modify the `go.mod` file, remove `github.com/pingcap/parser` from the `require` instruction, add a new line at the end of file like this: From 4f4a54f8e6a1625ace9404e39a7e58a7173ea3b6 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:31:33 +0800 Subject: [PATCH 08/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9c99c44a..1ace565d0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ TiDB SQL Parser Assuming that you want to file a PR (pull request) to TiDB, and your PR includes a change in the parser, implement the following steps to update the parser in TiDB. -### Step 1, make changes in your parser repository +### Step 1: Make changes in your parser repository Fork this repository to your own account and commit the changes to your repository. From 3ecf2757e461b283a4193603c45aa102384fa715 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:31:50 +0800 Subject: [PATCH 09/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ace565d0..9c8460ba4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,10 @@ Assuming that you want to file a PR (pull request) to TiDB, and your PR includes ### Step 1: Make changes in your parser repository Fork this repository to your own account and commit the changes to your repository. - +> **Note:** +> +> - Don't forget to run `make test` before you commit! +> - Make sure `parser.go` is updated. * Don't forget to run `make test` before you commit! * Make sure the `parser.go` is updated. From 9f505fdc300b788f738bf5bddce76305a0152504 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:32:22 +0800 Subject: [PATCH 10/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c8460ba4..c9b4d7b0e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Suppose the forked repository is `https://github.com/your-repo/parser`. ### Step 2: Make your parser changes take effect in TiDB and run CI -In your TiDB repository, modify the `go.mod` file, remove `github.com/pingcap/parser` from the `require` instruction, add a new line at the end of file like this: +1. In your TiDB repository, modify the `go.mod` file, remove `github.com/pingcap/parser` from the `require` instruction, and add a new line at the end of the file like this: ``` replace github.com/pingcap/parser => github.com/your-repo/parser v0.0.0-20181102150703-4acd198f5092 From 07f3221818fd9e35d130685916c56f2f54a3f4fb Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:32:42 +0800 Subject: [PATCH 11/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9b4d7b0e..efb7fce2a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ You can get correct version information by running this command in your TiDB dir GO111MODULE=on go get -u github.com/your-repo/parser@master ``` -If you get some error output, never mind. You can still edit the `go.mod` file manually. +If some error is reported, you can ignore it and still edit the `go.mod` file manually. Pull a request to TiDB. From 19b5238ebbf699abed7ff9a1bdb2e9634adc045f Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:33:36 +0800 Subject: [PATCH 12/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efb7fce2a..4f2a007a9 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ replace github.com/pingcap/parser => github.com/your-repo/parser v0.0.0-20181102 This change tells TiDB to use the modified parser from your repository. -You can get correct version information by running this command in your TiDB directory: +2. You can get correct version information by running this command in your TiDB directory: ``` GO111MODULE=on go get -u github.com/your-repo/parser@master From 77d8be8f34cd026fd7dad90bf3bf45c33f169df5 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:33:38 +0800 Subject: [PATCH 13/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f2a007a9..f98aab986 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ GO111MODULE=on go get -u github.com/your-repo/parser@master If some error is reported, you can ignore it and still edit the `go.mod` file manually. -Pull a request to TiDB. +3. File a PR to TiDB. ### Step 3, merge the parser to this repository From 3b88e24ef4b33c14c33c2157503370b7235a6374 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:33:58 +0800 Subject: [PATCH 14/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f98aab986..5d0df2353 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ If some error is reported, you can ignore it and still edit the `go.mod` file ma 3. File a PR to TiDB. -### Step 3, merge the parser to this repository +### Step 3: Merge the PR about the parser to this repository Pull a request to this repository. **Link the related PR in TiDB in your PR description or comment**. From 312c9f0bfd1320f11fe8fc0fd06f2a1ab1cdc8f3 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:34:10 +0800 Subject: [PATCH 15/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d0df2353..30fa9fa3a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ If some error is reported, you can ignore it and still edit the `go.mod` file ma ### Step 3: Merge the PR about the parser to this repository -Pull a request to this repository. **Link the related PR in TiDB in your PR description or comment**. +File a PR to this repository. **Link the related PR in TiDB in your PR description or comment.** The PR will be reviewed, if everything goes well, it will be merged. From 3e33dcba311aaca1a7151d40700e960da760c9d3 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:34:23 +0800 Subject: [PATCH 16/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30fa9fa3a..702b40bdf 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ If some error is reported, you can ignore it and still edit the `go.mod` file ma File a PR to this repository. **Link the related PR in TiDB in your PR description or comment.** -The PR will be reviewed, if everything goes well, it will be merged. +This PR will be reviewed, and if everything goes well, it will be merged. ### Step 4, update TiDB to use the latest parser From 8f6e31db9d0499d3623cda6a8983050a37934cd1 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:34:28 +0800 Subject: [PATCH 17/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 702b40bdf..5dbadc045 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ File a PR to this repository. **Link the related PR in TiDB in your PR descripti This PR will be reviewed, and if everything goes well, it will be merged. -### Step 4, update TiDB to use the latest parser +### Step 4: Update TiDB to use the latest parser In your TiDB pull request, modify the `go.mod` file manually or use this command: From 74ea786dcf3da16634869e8c555846c27a7b34b1 Mon Sep 17 00:00:00 2001 From: Caitin <34535727+CaitinChen@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:34:38 +0800 Subject: [PATCH 18/19] Update README.md Co-Authored-By: tiancaiamao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dbadc045..e4a430047 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,4 @@ In your TiDB pull request, modify the `go.mod` file manually or use this command GO111MODULE=on go get -u github.com/pingcap/parser@master ``` -Make sure the `replace` instruction is changed back to the `require` instruction and the version is latest. +Make sure the `replace` instruction is changed back to the `require` instruction and the version is the latest. From 77784dd1dcc99a0d699c51a85849cccc6dbde454 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 8 Nov 2018 16:40:55 +0800 Subject: [PATCH 19/19] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index e4a430047..badb3c6f7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ TiDB SQL Parser ## How to update parser for TiDB -Assuming that you want to file a PR (pull request) to TiDB, and your PR includes a change in the parser, implement the following steps to update the parser in TiDB. +Assuming that you want to file a PR (pull request) to TiDB, and your PR includes a change in the parser, follow these steps to update the parser in TiDB. ### Step 1: Make changes in your parser repository @@ -13,8 +13,6 @@ Fork this repository to your own account and commit the changes to your reposito > > - Don't forget to run `make test` before you commit! > - Make sure `parser.go` is updated. -* Don't forget to run `make test` before you commit! -* Make sure the `parser.go` is updated. Suppose the forked repository is `https://github.com/your-repo/parser`.