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

expression: rewrite builtin function: INTERVAL #4421

Merged
merged 10 commits into from Sep 6, 2017

Conversation

Projects
None yet
3 participants
@XuHuaiyu
Contributor

XuHuaiyu commented Sep 4, 2017

@zz-jason zz-jason referenced this pull request Sep 4, 2017

Closed

rewrite builtin functions #4080

150 of 150 tasks complete
Show outdated Hide outdated expression/builtin_compare.go
Show outdated Hide outdated expression/builtin_compare.go
Show outdated Hide outdated expression/builtin_compare.go
Show outdated Hide outdated expression/builtin_compare.go
}
sc := b.ctx.GetSessionVars().StmtCtx
idx, err := b.binSearch(sc, args0, mysql.HasUnsignedFlag(b.args[0].GetType().Flag), b.args[1:], row)

This comment has been minimized.

@zz-jason

zz-jason Sep 5, 2017

Member

if err != nil, we should return NULL

@zz-jason

zz-jason Sep 5, 2017

Member

if err != nil, we should return NULL

Show outdated Hide outdated expression/builtin_compare.go
}
if d1.Kind() == types.KindUint64 && d1.Kind() == d2.Kind() {
return d1.GetUint64() < d2.GetUint64()
if isNull {

This comment has been minimized.

@zz-jason

zz-jason Sep 5, 2017

Member

if NULL is treated as 0, we can not use a binary search like this, since the query can be like select INTERVAL(-100, NULL, NULL, NULL, NULL, NULL, -100); and mysql will returns 6

we have to evaluate all the values first, record every non-NULL values and its position, then we can do a binary search.

@zz-jason

zz-jason Sep 5, 2017

Member

if NULL is treated as 0, we can not use a binary search like this, since the query can be like select INTERVAL(-100, NULL, NULL, NULL, NULL, NULL, -100); and mysql will returns 6

we have to evaluate all the values first, record every non-NULL values and its position, then we can do a binary search.

// for interval
result = tk.MustQuery(`select interval(null, 1, 2), interval(1, 2, 3), interval(2, 1, 3)`)
result.Check(testkit.Rows("-1 0 1"))
result = tk.MustQuery(`select interval(3, 1, 2), interval(0, "b", "1", "2"), interval("a", "b", "1", "2")`)

This comment has been minimized.

@zz-jason

zz-jason Sep 5, 2017

Member

add test cases like select INTERVAL(100, NULL, NULL, NULL, NULL, NULL, 100);

@zz-jason

zz-jason Sep 5, 2017

Member

add test cases like select INTERVAL(100, NULL, NULL, NULL, NULL, NULL, 100);

@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu

XuHuaiyu Sep 5, 2017

Contributor

/run-all-test

Contributor

XuHuaiyu commented Sep 5, 2017

/run-all-test

err = err1
break
}
if isNull {

This comment has been minimized.

@zz-jason

zz-jason Sep 5, 2017

Member
if isNull {
    i = mid + 1
} else if cmp := target < v; !cmp {
    ...
}
@zz-jason

zz-jason Sep 5, 2017

Member
if isNull {
    i = mid + 1
} else if cmp := target < v; !cmp {
    ...
}

XuHuaiyu and others added some commits Sep 6, 2017

@zz-jason zz-jason added the status/LGT1 label Sep 6, 2017

@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason
Member

zz-jason commented Sep 6, 2017

@zz-jason zz-jason changed the title from expression, plan: rewrite builtin function interval to expression: rewrite builtin function: INTERVAL Sep 6, 2017

@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu

XuHuaiyu Sep 6, 2017

Contributor

PTAL @jackysp

Contributor

XuHuaiyu commented Sep 6, 2017

PTAL @jackysp

@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu

XuHuaiyu Sep 6, 2017

Contributor

PTAL @coocood

Contributor

XuHuaiyu commented Sep 6, 2017

PTAL @coocood

@jackysp

jackysp approved these changes Sep 6, 2017

LGTM

@zz-jason zz-jason merged commit 9f040b8 into master Sep 6, 2017

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@zz-jason zz-jason deleted the xhy/interval branch Sep 6, 2017

mccxj added a commit to mccxj/tidb that referenced this pull request Sep 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment