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: DATEDIFF #4212

Merged
merged 4 commits into from Aug 24, 2017

Conversation

Projects
None yet
4 participants
@spongedu
Contributor

spongedu commented Aug 16, 2017

for #4080

@zz-jason zz-jason changed the title from expression: rewrite builtin datediff to expression: rewrite builtin function: DATEDIFF Aug 16, 2017

@zz-jason zz-jason referenced this pull request Aug 16, 2017

Closed

rewrite builtin functions #4080

150 of 150 tasks complete
Show outdated Hide outdated expression/builtin_time.go Outdated
func (b *builtinDateDiffSig) evalInt(row []types.Datum) (int64, bool, error) {
ctx := b.ctx.GetSessionVars().StmtCtx
t1, isNull, err := b.args[0].EvalTime(row, ctx)
if isNull || err != nil {

This comment has been minimized.

@zz-jason

zz-jason Aug 17, 2017

Member

in mysql:

MySQL > select datediff("2014-12-09", "aaaa");
Field   1:  `datediff("2014-12-09", "aaaa")`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     7
Max_length: 0
Decimals:   0
Flags:      BINARY NUM


+--------------------------------+
| datediff("2014-12-09", "aaaa") |
+--------------------------------+
|                           NULL |
+--------------------------------+
1 row in set, 1 warning (0.00 sec)

MySQL > show warnings;
Field   1:  `Level`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     21
Max_length: 7
Decimals:   31
Flags:      NOT_NULL

Field   2:  `Code`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONG
Collation:  binary (63)
Length:     4
Max_length: 4
Decimals:   0
Flags:      NOT_NULL UNSIGNED BINARY NUM

Field   3:  `Message`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     1536
Max_length: 32
Decimals:   31
Flags:      NOT_NULL


+---------+------+----------------------------------+
| Level   | Code | Message                          |
+---------+------+----------------------------------+
| Warning | 1292 | Incorrect datetime value: 'aaaa' |
+---------+------+----------------------------------+
1 row in set (0.00 sec)
@zz-jason

zz-jason Aug 17, 2017

Member

in mysql:

MySQL > select datediff("2014-12-09", "aaaa");
Field   1:  `datediff("2014-12-09", "aaaa")`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     7
Max_length: 0
Decimals:   0
Flags:      BINARY NUM


+--------------------------------+
| datediff("2014-12-09", "aaaa") |
+--------------------------------+
|                           NULL |
+--------------------------------+
1 row in set, 1 warning (0.00 sec)

MySQL > show warnings;
Field   1:  `Level`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     21
Max_length: 7
Decimals:   31
Flags:      NOT_NULL

Field   2:  `Code`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONG
Collation:  binary (63)
Length:     4
Max_length: 4
Decimals:   0
Flags:      NOT_NULL UNSIGNED BINARY NUM

Field   3:  `Message`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     1536
Max_length: 32
Decimals:   31
Flags:      NOT_NULL


+---------+------+----------------------------------+
| Level   | Code | Message                          |
+---------+------+----------------------------------+
| Warning | 1292 | Incorrect datetime value: 'aaaa' |
+---------+------+----------------------------------+
1 row in set (0.00 sec)
Show outdated Hide outdated expression/integration_test.go Outdated
Show outdated Hide outdated plan/typeinfer_test.go Outdated
Show outdated Hide outdated expression/integration_test.go Outdated
@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason

zz-jason Aug 22, 2017

Member

@spongedu plz resolve conflicts

Member

zz-jason commented Aug 22, 2017

@spongedu plz resolve conflicts

@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu
Contributor

XuHuaiyu commented Aug 23, 2017

@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason
Member

zz-jason commented Aug 23, 2017

@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason

zz-jason Aug 24, 2017

Member

@spongedu please resolve conflicts

Member

zz-jason commented Aug 24, 2017

@spongedu please resolve conflicts

Show outdated Hide outdated expression/integration_test.go Outdated
@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu

XuHuaiyu Aug 24, 2017

Contributor

Please merge the master, I've split tpTime into tpDatetime and tpTimestamp.

Contributor

XuHuaiyu commented Aug 24, 2017

Please merge the master, I've split tpTime into tpDatetime and tpTimestamp.

@spongedu

This comment has been minimized.

Show comment
Hide comment
@spongedu

spongedu Aug 24, 2017

Contributor

@XuHuaiyu Done

Contributor

spongedu commented Aug 24, 2017

@XuHuaiyu Done

@XuHuaiyu

This comment has been minimized.

Show comment
Hide comment
@XuHuaiyu

XuHuaiyu Aug 24, 2017

Contributor

please fix ci

Contributor

XuHuaiyu commented Aug 24, 2017

please fix ci

spongedu added some commits Aug 24, 2017

@spongedu

This comment has been minimized.

Show comment
Hide comment
@spongedu

spongedu Aug 24, 2017

Contributor

@XuHuaiyu Done. PTAL

Contributor

spongedu commented Aug 24, 2017

@XuHuaiyu Done. PTAL

@XuHuaiyu

LGTM

@XuHuaiyu XuHuaiyu merged commit ff57b06 into pingcap:master Aug 24, 2017

3 checks passed

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

@spongedu spongedu deleted the spongedu:rewrite_builtin_datediff branch Aug 24, 2017

dbjoa added a commit to cloud-pi/tidb that referenced this pull request Aug 30, 2017

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