Skip to content

Commit

Permalink
Merge branch 'master' into selectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Jan 11, 2019
2 parents cefba96 + 73655f6 commit 8a7bb77
Show file tree
Hide file tree
Showing 135 changed files with 4,834 additions and 1,261 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ language: go
go_import_path: github.com/pingcap/tidb

go:
- "1.11.2"
- "1.11.3"

env:
- TRAVIS_COVERAGE=0
- TRAVIS_COVERAGE=1

# Run coverage tests.
matrix:
fast_finish: true
allow_failures:
- go: "1.11.3"
env: TRAVIS_COVERAGE=1

before_install:
# create /logs/unit-test for unit test.
Expand All @@ -15,4 +23,4 @@ before_install:
# See https://github.com/golang/go/issues/12933
- bash gitcookie.sh
script:
- make dev
- make dev upload-coverage
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A Contributor refers to the person who contributes to the following projects:

## How to become a TiDB Contributor?

If a PR (Pull Request) submitted to the TiDB / TiKV / TiSpark / PD / DocsDocs-cn projects by you is approved and merged, then you become a TiDB Contributor.
If a PR (Pull Request) submitted to the TiDB/TiKV/TiSpark/PD/Docs/Docs-cn projects by you is approved and merged, then you become a TiDB Contributor.

You are also encouraged to participate in the projects in the following ways:
- Actively answer technical questions asked by community users.
Expand Down
59 changes: 28 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export PATH := $(path_to_add):$(PATH)
GO := GO111MODULE=on go
GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := CGO_ENABLED=1 $(GO) test -p 3
OVERALLS := CGO_ENABLED=1 overalls
GOVERALLS := goveralls
OVERALLS := CGO_ENABLED=1 GO111MODULE=on overalls

ARCH := "`uname -s`"
LINUX := "Linux"
Expand All @@ -25,8 +24,8 @@ PACKAGES := $$($(PACKAGE_LIST))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/$(PROJECT)/||'
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")

GOFAIL_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs gofail enable)
GOFAIL_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs gofail disable)
GOFAIL_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs tools/bin/gofail enable)
GOFAIL_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs tools/bin/gofail disable)

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')"
Expand Down Expand Up @@ -117,42 +116,37 @@ test: checklist checkdep gotest explaintest
explaintest: server
@cd cmd/explaintest && ./run-tests.sh -s ../../bin/tidb-server

gotest:
@rm -rf $GOPATH/bin/gofail
$(GO) get github.com/pingcap/gofail
@which gofail
@$(GOFAIL_ENABLE)
upload-coverage: SHELL:=/bin/bash
upload-coverage:
ifeq ("$(TRAVIS_COVERAGE)", "1")
mv overalls.coverprofile coverage.txt
bash <(curl -s https://codecov.io/bash)
endif

gotest: gofail-enable
ifeq ("$(TRAVIS_COVERAGE)", "1")
@echo "Running in TRAVIS_COVERAGE mode."
@export log_level=error; \
go get github.com/go-playground/overalls
go get github.com/mattn/goveralls
$(OVERALLS) -project=github.com/pingcap/tidb -covermode=count -ignore='.git,vendor,cmd,docs,LICENSES' || { $(GOFAIL_DISABLE); exit 1; }
$(GOVERALLS) -service=travis-ci -coverprofile=overalls.coverprofile || { $(GOFAIL_DISABLE); exit 1; }
$(GO) get github.com/go-playground/overalls
$(OVERALLS) -project=github.com/pingcap/tidb -covermode=count -ignore='.git,vendor,cmd,docs,LICENSES' -concurrency=1 || { $(GOFAIL_DISABLE); exit 1; }
else
@echo "Running in native mode."
@export log_level=error; \
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover $(PACKAGES) || { $(GOFAIL_DISABLE); exit 1; }
endif
@$(GOFAIL_DISABLE)

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

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

tikv_integration_test:
$(GO) get github.com/pingcap/gofail
@$(GOFAIL_ENABLE)
tikv_integration_test: gofail-enable
$(GOTEST) ./store/tikv/. -with-tikv=true || { $(GOFAIL_DISABLE); exit 1; }
@$(GOFAIL_DISABLE)

Expand Down Expand Up @@ -196,37 +190,40 @@ importer:
checklist:
cat checklist.md

gofail-enable:
gofail-enable: tools/bin/gofail
# Converting gofail failpoints...
@$(GOFAIL_ENABLE)

gofail-disable:
gofail-disable: tools/bin/gofail
# Restoring gofail failpoints...
@$(GOFAIL_DISABLE)

checkdep:
$(GO) list -f '{{ join .Imports "\n" }}' github.com/pingcap/tidb/store/tikv | grep ^github.com/pingcap/parser$$ || exit 0; exit 1

tools/bin/megacheck:
tools/bin/megacheck: tools/check/go.mod
cd tools/check; \
$go build -o ../bin/megacheck honnef.co/go/tools/cmd/megacheck
$(GO) build -o ../bin/megacheck honnef.co/go/tools/cmd/megacheck

tools/bin/revive:
tools/bin/revive: tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/revive github.com/mgechev/revive

tools/bin/goword:
tools/bin/goword: tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/goword github.com/chzchzchz/goword

tools/bin/gometalinter:
tools/bin/gometalinter: tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/gometalinter gopkg.in/alecthomas/gometalinter.v2

tools/bin/gosec:
tools/bin/gosec: tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/gosec github.com/securego/gosec/cmd/gosec

tools/bin/errcheck:
tools/bin/errcheck: tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/errcheck github.com/kisielk/errcheck

tools/bin/gofail: go.mod
$(GO) build -o $@ github.com/pingcap/gofail
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![Build Status](https://travis-ci.org/pingcap/tidb.svg?branch=master)](https://travis-ci.org/pingcap/tidb)
[![Go Report Card](https://goreportcard.com/badge/github.com/pingcap/tidb)](https://goreportcard.com/report/github.com/pingcap/tidb)
![GitHub release](https://img.shields.io/github/release/pingcap/tidb.svg)
![GitHub release](https://img.shields.io/github/tag/pingcap/tidb.svg?label=release)
[![CircleCI Status](https://circleci.com/gh/pingcap/tidb.svg?style=shield)](https://circleci.com/gh/pingcap/tidb)
[![Coverage Status](https://coveralls.io/repos/github/pingcap/tidb/badge.svg?branch=master)](https://coveralls.io/github/pingcap/tidb?branch=master)
[![Coverage Status](https://codecov.io/gh/pingcap/tidb/branch/master/graph/badge.svg)](https://codecov.io/gh/pingcap/tidb)

## What is TiDB?

Expand Down
44 changes: 24 additions & 20 deletions cmd/explaintest/r/explain_complex.result
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,27 @@ CREATE TABLE `tbl_008` (`a` int, `b` int);
CREATE TABLE `tbl_009` (`a` int, `b` int);
explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b;
id count task operator info
HashAgg_34 72000.00 root group by:x.b, funcs:sum(x.a)
└─Union_35 90000.00 root
├─TableReader_38 10000.00 root data:TableScan_37
│ └─TableScan_37 10000.00 cop table:tbl_001, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_41 10000.00 root data:TableScan_40
│ └─TableScan_40 10000.00 cop table:tbl_002, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_44 10000.00 root data:TableScan_43
│ └─TableScan_43 10000.00 cop table:tbl_003, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_47 10000.00 root data:TableScan_46
│ └─TableScan_46 10000.00 cop table:tbl_004, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_50 10000.00 root data:TableScan_49
│ └─TableScan_49 10000.00 cop table:tbl_005, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_53 10000.00 root data:TableScan_52
│ └─TableScan_52 10000.00 cop table:tbl_006, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_56 10000.00 root data:TableScan_55
│ └─TableScan_55 10000.00 cop table:tbl_007, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_59 10000.00 root data:TableScan_58
│ └─TableScan_58 10000.00 cop table:tbl_008, range:[-inf,+inf], keep order:false, stats:pseudo
└─TableReader_62 10000.00 root data:TableScan_61
└─TableScan_61 10000.00 cop table:tbl_009, range:[-inf,+inf], keep order:false, stats:pseudo
HashAgg_34 72000.00 root group by:col_1, funcs:sum(col_0)
└─Projection_63 90000.00 root cast(x.a), x.b
└─Union_35 90000.00 root
├─TableReader_38 10000.00 root data:TableScan_37
│ └─TableScan_37 10000.00 cop table:tbl_001, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_41 10000.00 root data:TableScan_40
│ └─TableScan_40 10000.00 cop table:tbl_002, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_44 10000.00 root data:TableScan_43
│ └─TableScan_43 10000.00 cop table:tbl_003, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_47 10000.00 root data:TableScan_46
│ └─TableScan_46 10000.00 cop table:tbl_004, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_50 10000.00 root data:TableScan_49
│ └─TableScan_49 10000.00 cop table:tbl_005, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_53 10000.00 root data:TableScan_52
│ └─TableScan_52 10000.00 cop table:tbl_006, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_56 10000.00 root data:TableScan_55
│ └─TableScan_55 10000.00 cop table:tbl_007, range:[-inf,+inf], keep order:false, stats:pseudo
├─TableReader_59 10000.00 root data:TableScan_58
│ └─TableScan_58 10000.00 cop table:tbl_008, range:[-inf,+inf], keep order:false, stats:pseudo
└─TableReader_62 10000.00 root data:TableScan_61
└─TableScan_61 10000.00 cop table:tbl_009, range:[-inf,+inf], keep order:false, stats:pseudo



44 changes: 24 additions & 20 deletions cmd/explaintest/r/explain_complex_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,27 @@ CREATE TABLE tbl_009 (a int, b int);
load stats 's/explain_complex_stats_tbl_009.json';
explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b;
id count task operator info
HashAgg_34 18000.00 root group by:x.b, funcs:sum(x.a)
└─Union_35 18000.00 root
├─TableReader_38 2000.00 root data:TableScan_37
│ └─TableScan_37 2000.00 cop table:tbl_001, range:[-inf,+inf], keep order:false
├─TableReader_41 2000.00 root data:TableScan_40
│ └─TableScan_40 2000.00 cop table:tbl_002, range:[-inf,+inf], keep order:false
├─TableReader_44 2000.00 root data:TableScan_43
│ └─TableScan_43 2000.00 cop table:tbl_003, range:[-inf,+inf], keep order:false
├─TableReader_47 2000.00 root data:TableScan_46
│ └─TableScan_46 2000.00 cop table:tbl_004, range:[-inf,+inf], keep order:false
├─TableReader_50 2000.00 root data:TableScan_49
│ └─TableScan_49 2000.00 cop table:tbl_005, range:[-inf,+inf], keep order:false
├─TableReader_53 2000.00 root data:TableScan_52
│ └─TableScan_52 2000.00 cop table:tbl_006, range:[-inf,+inf], keep order:false
├─TableReader_56 2000.00 root data:TableScan_55
│ └─TableScan_55 2000.00 cop table:tbl_007, range:[-inf,+inf], keep order:false
├─TableReader_59 2000.00 root data:TableScan_58
│ └─TableScan_58 2000.00 cop table:tbl_008, range:[-inf,+inf], keep order:false
└─TableReader_62 2000.00 root data:TableScan_61
└─TableScan_61 2000.00 cop table:tbl_009, range:[-inf,+inf], keep order:false
HashAgg_34 18000.00 root group by:col_1, funcs:sum(col_0)
└─Projection_63 18000.00 root cast(x.a), x.b
└─Union_35 18000.00 root
├─TableReader_38 2000.00 root data:TableScan_37
│ └─TableScan_37 2000.00 cop table:tbl_001, range:[-inf,+inf], keep order:false
├─TableReader_41 2000.00 root data:TableScan_40
│ └─TableScan_40 2000.00 cop table:tbl_002, range:[-inf,+inf], keep order:false
├─TableReader_44 2000.00 root data:TableScan_43
│ └─TableScan_43 2000.00 cop table:tbl_003, range:[-inf,+inf], keep order:false
├─TableReader_47 2000.00 root data:TableScan_46
│ └─TableScan_46 2000.00 cop table:tbl_004, range:[-inf,+inf], keep order:false
├─TableReader_50 2000.00 root data:TableScan_49
│ └─TableScan_49 2000.00 cop table:tbl_005, range:[-inf,+inf], keep order:false
├─TableReader_53 2000.00 root data:TableScan_52
│ └─TableScan_52 2000.00 cop table:tbl_006, range:[-inf,+inf], keep order:false
├─TableReader_56 2000.00 root data:TableScan_55
│ └─TableScan_55 2000.00 cop table:tbl_007, range:[-inf,+inf], keep order:false
├─TableReader_59 2000.00 root data:TableScan_58
│ └─TableScan_58 2000.00 cop table:tbl_008, range:[-inf,+inf], keep order:false
└─TableReader_62 2000.00 root data:TableScan_61
└─TableScan_61 2000.00 cop table:tbl_009, range:[-inf,+inf], keep order:false



44 changes: 24 additions & 20 deletions cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ TableReader_7 0.33 root data:Selection_6
└─TableScan_5 1.00 cop table:t1, range:[1,1], keep order:false, stats:pseudo
explain select sum(t1.c1 in (select c1 from t2)) from t1;
id count task operator info
StreamAgg_12 1.00 root funcs:sum(5_aux_0)
└─MergeJoin_28 10000.00 root left outer semi join, left key:test.t1.c1, right key:test.t2.c1
├─TableReader_19 10000.00 root data:TableScan_18
│ └─TableScan_18 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─IndexReader_23 10000.00 root index:IndexScan_22
└─IndexScan_22 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:true, stats:pseudo
StreamAgg_12 1.00 root funcs:sum(col_0)
└─Projection_35 10000.00 root cast(5_aux_0)
└─MergeJoin_28 10000.00 root left outer semi join, left key:test.t1.c1, right key:test.t2.c1
├─TableReader_19 10000.00 root data:TableScan_18
│ └─TableScan_18 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─IndexReader_23 10000.00 root index:IndexScan_22
└─IndexScan_22 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:true, stats:pseudo
explain select c1 from t1 where c1 in (select c2 from t2);
id count task operator info
Projection_9 10000.00 root test.t1.c1
Expand Down Expand Up @@ -190,12 +191,13 @@ HashAgg_18 24000.00 root group by:c1, funcs:firstrow(join_agg_0)
set @@session.tidb_opt_insubq_to_join_and_agg=0;
explain select sum(t1.c1 in (select c1 from t2)) from t1;
id count task operator info
StreamAgg_12 1.00 root funcs:sum(5_aux_0)
└─MergeJoin_28 10000.00 root left outer semi join, left key:test.t1.c1, right key:test.t2.c1
├─TableReader_19 10000.00 root data:TableScan_18
│ └─TableScan_18 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─IndexReader_23 10000.00 root index:IndexScan_22
└─IndexScan_22 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:true, stats:pseudo
StreamAgg_12 1.00 root funcs:sum(col_0)
└─Projection_35 10000.00 root cast(5_aux_0)
└─MergeJoin_28 10000.00 root left outer semi join, left key:test.t1.c1, right key:test.t2.c1
├─TableReader_19 10000.00 root data:TableScan_18
│ └─TableScan_18 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─IndexReader_23 10000.00 root index:IndexScan_22
└─IndexScan_22 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:true, stats:pseudo
explain select 1 in (select c2 from t2) from t1;
id count task operator info
Projection_6 10000.00 root 5_aux_0
Expand All @@ -207,13 +209,14 @@ Projection_6 10000.00 root 5_aux_0
└─TableScan_10 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(6 in (select c2 from t2)) from t1;
id count task operator info
StreamAgg_12 1.00 root funcs:sum(5_aux_0)
└─HashLeftJoin_19 10000.00 root left outer semi join, inner:TableReader_18
├─TableReader_21 10000.00 root data:TableScan_20
│ └─TableScan_20 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─TableReader_18 10.00 root data:Selection_17
└─Selection_17 10.00 cop eq(6, test.t2.c2)
└─TableScan_16 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
StreamAgg_12 1.00 root funcs:sum(col_0)
└─Projection_22 10000.00 root cast(5_aux_0)
└─HashLeftJoin_19 10000.00 root left outer semi join, inner:TableReader_18
├─TableReader_21 10000.00 root data:TableScan_20
│ └─TableScan_20 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─TableReader_18 10.00 root data:Selection_17
└─Selection_17 10.00 cop eq(6, test.t2.c2)
└─TableScan_16 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain format="dot" select sum(t1.c1 in (select c1 from t2)) from t1;
dot contents

Expand All @@ -222,7 +225,8 @@ subgraph cluster12{
node [style=filled, color=lightgrey]
color=black
label = "root"
"StreamAgg_12" -> "MergeJoin_28"
"StreamAgg_12" -> "Projection_35"
"Projection_35" -> "MergeJoin_28"
"MergeJoin_28" -> "TableReader_19"
"MergeJoin_28" -> "IndexReader_23"
}
Expand Down
Loading

0 comments on commit 8a7bb77

Please sign in to comment.