-
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 length using new expression evaluation architecture #3519
Conversation
…on evaluation architecture
expression/builtin_string.go
Outdated
args, err := b.evalArgs(row) | ||
func (b *builtinLengthSig) evalInt(row []types.Datum) (int64, bool, error) { | ||
ctx, sc := b.ctx, b.ctx.GetSessionVars().StmtCtx | ||
arg0, err := WrapWithCastAsString(b.args[0], ctx) |
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.
We should not add cast here.
expression/builtin_string.go
Outdated
@@ -132,32 +132,29 @@ type lengthFunctionClass struct { | |||
} | |||
|
|||
func (c *lengthFunctionClass) getFunction(args []Expression, ctx context.Context) (builtinFunc, error) { | |||
sig := &builtinLengthSig{newBaseBuiltinFunc(args, ctx)} | |||
tp := types.NewFieldType(mysql.TypeLonglong) | |||
types.SetBinChsClnFlag(tp) |
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.
Consider field length?
expression/builtin_string.go
Outdated
@@ -133,6 +133,7 @@ type lengthFunctionClass struct { | |||
|
|||
func (c *lengthFunctionClass) getFunction(args []Expression, ctx context.Context) (builtinFunc, error) { | |||
tp := types.NewFieldType(mysql.TypeLonglong) | |||
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.
Conflicts: expression/builtin.go �:q!
PTAL @hanfei1991 |
PTAL @zimulala |
LGTM |
expression/builtin_string.go
Outdated
return sig.setSelf(sig), errors.Trace(c.verifyArgs(args)) | ||
} | ||
|
||
type builtinLengthSig struct { | ||
baseBuiltinFunc | ||
baseIntBuiltinFunc | ||
} | ||
|
||
// eval evals a builtinLengthSig. |
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.
Update this comments.
LGTM |
rewrite built-in func
length
using new expression evaluation architecturePTAL @hanfei1991 @shenli @hicqu