Skip to content

Commit

Permalink
*: preparation for Go1.11 module cherry pick (pingcap#8388)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and zz-jason committed Nov 22, 2018
1 parent d39d382 commit fc4c93f
Show file tree
Hide file tree
Showing 1,311 changed files with 188,606 additions and 10,672 deletions.
243 changes: 40 additions & 203 deletions Gopkg.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ required = ["github.com/golang/protobuf/jsonpb"]
version = "1.1.0"
name = "github.com/golang/protobuf"

[[constraint]]
branch = "master"
name = "github.com/cznic/parser"

[[constraint]]
branch = "master"
name = "github.com/cznic/sortutil"
Expand Down Expand Up @@ -106,3 +102,7 @@ required = ["github.com/golang/protobuf/jsonpb"]
[[constraint]]
name = "github.com/pingcap/tidb-tools"
revision = "8dd71127bcf09130ae032ab6877dd22f32b53e14"

[[constraint]]
name = "github.com/pingcap/parser"
branch = "release-2.1"
45 changes: 12 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go" | grep -vE "vendor"
GOFAIL_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs gofail enable)
GOFAIL_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs gofail disable)

LDFLAGS += -X "github.com/pingcap/tidb/mysql.TiDBReleaseVersion=$(shell git describe --tags --dirty)"
LDFLAGS += -X "github.com/pingcap/parser/mysql.TiDBReleaseVersion=$(shell git describe --tags --dirty)"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
Expand All @@ -40,7 +40,7 @@ CHECK_LDFLAGS += $(LDFLAGS) ${TEST_LDFLAGS}

TARGET = ""

.PHONY: all build update parser clean todo test gotest interpreter server dev benchkv benchraw check parserlib checklist
.PHONY: all build update parser clean todo test gotest interpreter server dev benchkv benchraw check checklist parser

default: server buildsucc

Expand All @@ -51,35 +51,14 @@ buildsucc:

all: dev server benchkv

dev: checklist parserlib test check
parser:
@echo "remove this command later"

dev: checklist test check

build:
$(GOBUILD)

goyacc:
$(GOBUILD) -o bin/goyacc parser/goyacc/main.go

parser: goyacc
bin/goyacc -o /dev/null parser/parser.y
bin/goyacc -o parser/parser.go parser/parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; exit 1;}}'
rm -f y.output

@if [ $(ARCH) = $(LINUX) ]; \
then \
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser/parser.go; \
elif [ $(ARCH) = $(MAC) ]; \
then \
/usr/bin/sed -i "" 's|//line.*||' parser/parser.go; \
/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser/parser.go; \
fi

@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' parser/parser.go > tmp_parser.go && mv tmp_parser.go parser/parser.go;

parserlib: parser/parser.go

parser/parser.go: parser/parser.y
make parser

# The retool tools.json is setup from hack/retool-install.sh
check-setup:
@which retool >/dev/null 2>&1 || go get github.com/twitchtv/retool
Expand Down Expand Up @@ -135,7 +114,7 @@ test: checklist gotest explaintest
explaintest: server
@cd cmd/explaintest && ./run-tests.sh -s ../../bin/tidb-server

gotest: parserlib
gotest:
go get github.com/etcd-io/gofail
@$(GOFAIL_ENABLE)
ifeq ("$(TRAVIS_COVERAGE)", "1")
Expand All @@ -152,21 +131,21 @@ else
endif
@$(GOFAIL_DISABLE)

race: parserlib
race:
go get github.com/etcd-io/gofail
@$(GOFAIL_ENABLE)
@export log_level=debug; \
$(GOTEST) -timeout 20m -race $(PACKAGES) || { $(GOFAIL_DISABLE); exit 1; }
@$(GOFAIL_DISABLE)

leak: parserlib
leak:
go get github.com/etcd-io/gofail
@$(GOFAIL_ENABLE)
@export log_level=debug; \
$(GOTEST) -tags leak $(PACKAGES) || { $(GOFAIL_DISABLE); exit 1; }
@$(GOFAIL_DISABLE)

tikv_integration_test: parserlib
tikv_integration_test:
go get github.com/etcd-io/gofail
@$(GOFAIL_ENABLE)
$(GOTEST) ./store/tikv/. -with-tikv=true || { $(GOFAIL_DISABLE); exit 1; }
Expand All @@ -183,14 +162,14 @@ ifeq ("$(WITH_CHECK)", "1")
CHECK_FLAG = $(TEST_LDFLAGS)
endif

server: parserlib
server:
ifeq ($(TARGET), "")
$(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
else
$(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
endif

server_check: parserlib
server_check:
ifeq ($(TARGET), "")
$(GOBUILD) $(RACE_FLAG) -ldflags '$(CHECK_LDFLAGS)' -o bin/tidb-server tidb-server/main.go
else
Expand Down
61 changes: 2 additions & 59 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package ast
import (
"io"

"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"golang.org/x/net/context"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
)

// Node is the basic element of the AST.
Expand Down Expand Up @@ -64,14 +62,6 @@ type ExprNode interface {
SetType(tp *types.FieldType)
// GetType gets the evaluation type of the expression.
GetType() *types.FieldType
// SetValue sets value to the expression.
SetValue(val interface{})
// GetValue gets value of the expression.
GetValue() interface{}
// SetDatum sets datum to the expression.
SetDatum(datum types.Datum)
// GetDatum gets datum of the expression.
GetDatum() *types.Datum
// SetFlag sets flag to the expression.
// Flag indicates whether the expression contains
// parameter marker, reference, aggregate function...
Expand Down Expand Up @@ -138,31 +128,6 @@ type ResultField struct {
Referenced bool
}

// RecordSet is an abstract result set interface to help get data from Plan.
type RecordSet interface {
// Fields gets result fields.
Fields() []*ResultField

// Next reads records into chunk.
Next(ctx context.Context, chk *chunk.Chunk) error

// NewChunk creates a new chunk with initial capacity.
NewChunk() *chunk.Chunk

// Close closes the underlying iterator, call Next after Close will
// restart the iteration.
Close() error
}

// RowToDatums converts row to datum slice.
func RowToDatums(row chunk.Row, fields []*ResultField) []types.Datum {
datums := make([]types.Datum, len(fields))
for i, f := range fields {
datums[i] = row.GetDatum(i, &f.Column.FieldType)
}
return datums
}

// ResultSetNode interface has a ResultFields property, represents a Node that returns result set.
// Implementations include SelectStmt, SubqueryExpr, TableSource, TableName and Join.
type ResultSetNode interface {
Expand All @@ -176,28 +141,6 @@ type SensitiveStmtNode interface {
SecureText() string
}

// Statement is an interface for SQL execution.
// NOTE: all Statement implementations must be safe for
// concurrent using by multiple goroutines.
// If the Exec method requires any Execution domain local data,
// they must be held out of the implementing instance.
type Statement interface {
// OriginText gets the origin SQL text.
OriginText() string

// Exec executes SQL and gets a Recordset.
Exec(ctx context.Context) (RecordSet, error)

// IsPrepared returns whether this statement is prepared statement.
IsPrepared() bool

// IsReadOnly returns if the statement is read only. For example: SelectStmt without lock.
IsReadOnly() bool

// RebuildPlan rebuilds the plan of the statement.
RebuildPlan() (schemaVersion int64, err error)
}

// Visitor visits a Node.
type Visitor interface {
// Enter is called before children nodes are visited.
Expand Down
14 changes: 3 additions & 11 deletions ast/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package ast

import "github.com/pingcap/tidb/types"
import "github.com/pingcap/parser/types"

// node is the struct implements node interface except for Accept method.
// Node implementations should embed it in.
Expand Down Expand Up @@ -62,20 +62,12 @@ func (dn *dmlNode) dmlStatement() {}
// Expression implementations should embed it in.
type exprNode struct {
node
types.Datum
Type types.FieldType
flag uint64
}

// SetDatum implements ExprNode interface.
func (en *exprNode) SetDatum(datum types.Datum) {
en.Datum = datum
}

// GetDatum implements ExprNode interface.
func (en *exprNode) GetDatum() *types.Datum {
return &en.Datum
}
// TexprNode is exported for parser driver.
type TexprNode = exprNode

// SetType implements ExprNode interface.
func (en *exprNode) SetType(tp *types.FieldType) {
Expand Down
4 changes: 2 additions & 2 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package ast

import (
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/types"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion ast/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package ast_test

import (
. "github.com/pingcap/check"
. "github.com/pingcap/tidb/ast"
. "github.com/pingcap/parser/ast"
)

var _ = Suite(&testDDLSuite{})
Expand Down
6 changes: 3 additions & 3 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
package ast

import (
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/util/auth"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/mysql"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion ast/dml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package ast_test

import (
. "github.com/pingcap/check"
. "github.com/pingcap/tidb/ast"
. "github.com/pingcap/parser/ast"
)

var _ = Suite(&testDMLSuite{})
Expand Down
Loading

0 comments on commit fc4c93f

Please sign in to comment.