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,plan: fix some issues of ROUND func #2461

Merged
merged 9 commits into from
Jan 22, 2017

Conversation

zyguan
Copy link
Contributor

@zyguan zyguan commented Jan 14, 2017

I'm not very sure if I shall update the following codes also.

util/types/convert.go
303:            return strconv.FormatFloat(float64(v), 'f', -1, 32), nil
305:            return strconv.FormatFloat(float64(v), 'f', -1, 64), nil

util/types/mydecimal.go
951:    s := strconv.FormatFloat(f, 'g', -1, 64)

util/types/datum.go
747:            s = strconv.FormatFloat(d.GetFloat64(), 'f', -1, 32)
749:            s = strconv.FormatFloat(d.GetFloat64(), 'f', -1, 64)
1306:           return strconv.FormatFloat(float64(d.GetFloat32()), 'f', -1, 32), nil
1308:           return strconv.FormatFloat(float64(d.GetFloat64()), 'f', -1, 64), nil

case "round":
t := x.Args[0].GetType().Tp
switch t {
case mysql.TypeBit, mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLonglong:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should decimal be counted as Exact Value ? @coocood

@@ -325,9 +325,17 @@ func dumpTextValue(mysqlType uint8, value types.Datum) ([]byte, error) {
case types.KindUint64:
return strconv.AppendUint(nil, value.GetUint64(), 10), nil
case types.KindFloat32:
return strconv.AppendFloat(nil, value.GetFloat64(), 'f', -1, 32), nil
prec := -1
Copy link
Contributor

Choose a reason for hiding this comment

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

Any tests cover this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tiancaiamao I've added some tests, PTAL.

@tiancaiamao
Copy link
Contributor

LGTM
PTAL @coocood

@coocood
Copy link
Member

coocood commented Jan 17, 2017

@zyguan
mysql.NewDecimal should be handled too.
Rounding a decimal returns a decimal.

@coocood
Copy link
Member

coocood commented Jan 22, 2017

LGTM
Thank you!

@hanfei1991 hanfei1991 merged commit 5aec72c into pingcap:master Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants