Skip to content
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

Merged
merged 18 commits into from
Jun 22, 2017

Conversation

XuHuaiyu
Copy link
Contributor

rewrite built-in func length using new expression evaluation architecture
PTAL @hanfei1991 @shenli @hicqu

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)
Copy link
Member

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.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider field length?

@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XuHuaiyu
Copy link
Contributor Author

PTAL @hanfei1991

@XuHuaiyu
Copy link
Contributor Author

PTAL @zimulala

@hanfei1991
Copy link
Member

LGTM

@hanfei1991 hanfei1991 added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 22, 2017
return sig.setSelf(sig), errors.Trace(c.verifyArgs(args))
}

type builtinLengthSig struct {
baseBuiltinFunc
baseIntBuiltinFunc
}

// eval evals a builtinLengthSig.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this comments.

@zimulala
Copy link
Contributor

LGTM

@XuHuaiyu XuHuaiyu merged commit f331160 into master Jun 22, 2017
@XuHuaiyu XuHuaiyu deleted the xhy/length branch June 22, 2017 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants