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, executor: no longer treat dml as logical/physical plan. #5230

Merged
merged 9 commits into from Nov 30, 2017

Conversation

hanfei1991
Copy link
Member

No description provided.

@shenli
Copy link
Member

shenli commented Nov 27, 2017

Why should we do this?

@coocood
Copy link
Member

coocood commented Nov 27, 2017

@hanfei1991
Does it solve the expensive query log issue?

@hanfei1991
Copy link
Member Author

@shenli make code cleaner, better and stronger.

@hanfei1991
Copy link
Member Author

@coocood I don't understand what you mean.

@hanfei1991
Copy link
Member Author

/run-all-tests

tblID2table[id], _ = b.is.TableByID(id)
}
return &DeleteExec{
baseExecutor: newBaseExecutor(nil, b.ctx),
SelectExec: b.build(v.Children()[0]),
SelectExec: b.build(v.SelectPlan),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

tblID2table[id], _ = b.is.TableByID(id)
}
return &UpdateExec{
baseExecutor: newBaseExecutor(nil, b.ctx),
SelectExec: b.build(v.Children()[0]),
SelectExec: b.build(v.SelectPlan),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after building, we should check b.err:

selectExec := b.build(v.SelectPlan)
if b.err != nil {
    b.err = errors.Trace(b.err)
    return nil
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if b.err is not nil, it's ok to return any executor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to discover error as soon as possible so that we can avoid useless executor building.

@hanfei1991
Copy link
Member Author

/run-common-test tidb-test=pr/410

@hanfei1991
Copy link
Member Author

/run-common-test tidb-test=pr/410

@shenli
Copy link
Member

shenli commented Nov 28, 2017

@hanfei1991 Please fix the conflicts.

updt.SetSchema(p.Schema())
updt.SelectPlan, b.err = doOptimize(b.optFlag, p, b.ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check b.err

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If b.err is not nil, we can also return. It's no need to check this.

@@ -52,6 +52,9 @@ type Plan interface {
// findColumn finds the column in basePlan's schema.
// If the column is not in the schema, returns error.
findColumn(*ast.ColumnName) (*expression.Column, int, error)

// ResolveIndices resolves the indices for columns. After doing this, the columns can evaluate the rows by their indices.
ResolveIndices()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert/Delete/Update also needs resolveIndices

for _, cols := range p.schema.TblID2Handle {
for _, col := range cols {
col.ResolveIndices(p.schema)
if p.schema != nil {
Copy link
Contributor

@XuHuaiyu XuHuaiyu Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment for when this check will be false.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't know when it would fail. It's strange and I will refactor the schema setting in the future.

@hanfei1991
Copy link
Member Author

@zz-jason @XuHuaiyu PTAL

if len(v.Children()) > 0 {
ivs.SelectExec = b.build(v.Children()[0])
ivs.SelectExec = b.build(v.SelectPlan)
if b.err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b.err = errors.Trace(b.err)

tblID2table[id], _ = b.is.TableByID(id)
}
selExec := b.build(v.SelectPlan)
if b.err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hanfei1991 hanfei1991 added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 29, 2017
@hanfei1991
Copy link
Member Author

@XuHuaiyu PTAL

@@ -612,19 +612,19 @@ func (s *testPlanSuite) TestPlanBuilder(c *C) {
},
{
sql: "update t set t.a = t.a * 1.5 where t.a >= 1000 order by t.a desc limit 10",
plan: "DataScan(t)->Sel([ge(test.t.a, 1000)])->Sort->Limit->*plan.Update",
plan: "TableReader(Table(t)->Limit)->Limit->Update",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why DataScan is replaced with TableReader?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We build update's SelectPlan at one time.

@shenli
Copy link
Member

shenli commented Nov 30, 2017

Should you consider the Replace statement in this PR?

@hanfei1991
Copy link
Member Author

@shenli replace is a kind of insert

@XuHuaiyu
Copy link
Contributor

/run-all-tests

@shenli
Copy link
Member

shenli commented Nov 30, 2017

@hanfei1991 CI fail.

@hanfei1991
Copy link
Member Author

/run-common-test tidb-test=pr/414

@hanfei1991
Copy link
Member Author

/run-common-tests tidb-test=pr/414

@hanfei1991
Copy link
Member Author

/run-common-test tidb-test=pr/414

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XuHuaiyu XuHuaiyu merged commit 01f77b0 into pingcap:master Nov 30, 2017
@hanfei1991 hanfei1991 deleted the dml branch December 4, 2017 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants