-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: add builtin function UNIX_TIMESTAMP #2369
Conversation
@@ -745,3 +745,43 @@ func parseDayInterval(sc *variable.StatementContext, value types.Datum) (int64, | |||
} | |||
return value.ToInt64(sc) | |||
} | |||
|
|||
func builtinUnixTimestamp(args []types.Datum, ctx context.Context) (d types.Datum, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add reference.
return | ||
} | ||
if e != nil { | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return d, errors.Trace(e)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find mysql default behavior is return 0, when input data is wrong...
@@ -278,6 +278,7 @@ import ( | |||
trim "TRIM" | |||
rtrim "RTRIM" | |||
ucase "UCASE" | |||
unixTimestamp "UNIX_TIMESTAMP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is UNIX_TIMESTAMP a keyword or non-keyword-token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a keyword or non-keyword.
https://dev.mysql.com/doc/refman/5.7/en/keywords.html
@tiancaiamao Please fix CI. |
PTAL |
@tiancaiamao Fix the conflict. |
Conflicts: expression/builtin_time_test.go
LGTM |
var ( | ||
t types.Time | ||
t1 time.Time | ||
e error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There exists an err so you needn't to declare an error e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but if I use if err != nil { return }
, this function would return error, which is not the same as mysql behavior.
Ping @tiancaiamao |
Conflicts: plan/typeinferer_test.go
LGTM |
For invalid input, |
For issue #236