Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plan: push a handle into schema if datasource's schema have no col. #5447

Merged
merged 3 commits into from Dec 19, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions plan/column_pruning.go
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/context"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/model"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -161,7 +162,6 @@ func (p *LogicalUnionScan) PruneColumns(parentUsedCols []*expression.Column) {
// PruneColumns implements LogicalPlan interface.
func (p *DataSource) PruneColumns(parentUsedCols []*expression.Column) {
used := getUsedList(parentUsedCols, p.schema)
firstCol, firstColInfo := p.schema.Columns[0], p.Columns[0]
for i := len(used) - 1; i >= 0; i-- {
if !used[i] {
p.schema.Columns = append(p.schema.Columns[:i], p.schema.Columns[i+1:]...)
Expand All @@ -177,8 +177,8 @@ func (p *DataSource) PruneColumns(parentUsedCols []*expression.Column) {
// For SQL like `select 1 from t`, tikv's response will be empty if no column is in schema.
// So we'll force to push one if schema doesn't have any column.
if p.schema.Len() == 0 {
p.schema.Append(firstCol)
p.Columns = append(p.Columns, firstColInfo)
p.Columns = append(p.Columns, model.NewExtraHandleColInfo())
p.schema.Append(p.newExtraHandleSchemaCol())
}
}

Expand Down