-
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
expression, executor: rewrite built-in func makeDate using new expression evaluation architecture #3533
Conversation
expression/builtin_time.go
Outdated
@@ -2023,35 +2023,36 @@ type makeDateFunctionClass struct { | |||
} | |||
|
|||
func (c *makeDateFunctionClass) getFunction(args []Expression, ctx context.Context) (builtinFunc, error) { | |||
sig := &builtinMakeDateSig{newBaseBuiltinFunc(args, ctx)} | |||
tp := types.NewFieldType(mysql.TypeDate) | |||
tp.Flen = 10 |
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 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 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.
@XuHuaiyu
Thank you, I found it,and the MAX_DATE_WIDTH is 10.
refer https://github.com/mysql/mysql-server/blob/5.7/sql/sql_const.h#L59
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.
You may define MAX_DATE_WIDTH as a constant in mysql/const.go as MySQL does
6cf38ec
to
8078486
Compare
@hanfei1991 @XuHuaiyu , PTAL, thanks. |
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.
Rest LGTM
expression/builtin_time.go
Outdated
func (b *builtinMakeDateSig) evalTime(row []types.Datum) (d types.Time, isNull bool, err error) { | ||
args := b.getArgs() | ||
var year, dayOfYear int64 | ||
year, isNull, err = args[0].EvalInt(row, b.ctx.GetSessionVars().StmtCtx) |
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.
sc := b.ctx.GetSessionVars().StmtCtx
so we can use it at line 2050
c.Assert(err, IsNil) | ||
if t["Want"][0].Kind() == types.KindNull { | ||
c.Assert(got.Kind(), Equals, types.KindNull, Commentf("[%v] - args:%v", idx, t["Args"])) | ||
{[]interface{}{71, 1}, "1971-01-01", false, false}, |
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 test cases for float64 value
mysql/const.go
Outdated
@@ -193,6 +193,11 @@ const ( | |||
// AllPrivMask is the mask for PrivilegeType with all bits set to 1. | |||
const AllPrivMask = AllPriv - 1 | |||
|
|||
const ( |
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 comments for these const.
You can run |
@XuHuaiyu |
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.
Rest LGTM
mysql/const.go
Outdated
@@ -193,6 +193,12 @@ const ( | |||
// AllPrivMask is the mask for PrivilegeType with all bits set to 1. | |||
const AllPrivMask = AllPriv - 1 | |||
|
|||
// MYSQL type maximum length. |
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.
s/MYSQL/MySQL
expression/builtin_time.go
Outdated
var year, dayOfYear int64 | ||
year, isNull, err = args[0].EvalInt(row, sc) | ||
if isNull || err != nil { | ||
return d, isNull, errors.Trace(err) |
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, true is clearer
expression/builtin_time.go
Outdated
return d, errors.Trace(err) | ||
dayOfYear, isNull, err = args[1].EvalInt(row, sc) | ||
if isNull || err != nil { | ||
return d, isNull, errors.Trace(err) |
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.
ditto.
LGTM |
Rewrite built-in func
makeDate
using new expression evaluation architecture