Skip to content

*: remove mysql.TypeDecimal - #18787

Merged
AilinKid merged 13 commits into
pingcap:masterfrom
wangggong:TypeDecimal
Jul 29, 2020
Merged

AilinKid merged 13 commits into
pingcap:masterfrom
wangggong:TypeDecimal

Conversation

@wangggong

Copy link
Copy Markdown
Contributor

Signed-off-by: Wang Ruichao wangruichao2014@xiaochuankeji.cn

What problem does this PR solve?

close pingcap/parser#767
cc #15328

Problem Summary:

What is changed and how it works?

What's Changed:

Remove mysql.TypeDecimal, instead mysql.TypeNewDecimal / mysql.TypeUnspecified is used.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM
  • Breaking backward compatibility

Release note

Nope. Please tell me if there's any test to add or code to modify. Thanks.

Signed-off-by: Wang Ruichao <wangruichao2014@xiaochuankeji.cn>
@wangggong
wangggong requested a review from a team as a code owner July 25, 2020 18:59
@wangggong
wangggong requested review from SunRunAway and removed request for a team July 25, 2020 18:59
@ti-srebot ti-srebot added the contribution This PR is from a community contributor. label Jul 25, 2020
Signed-off-by: Wang Ruichao <wangruichao2014@xiaochuankeji.cn>
@codecov

codecov Bot commented Jul 25, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #18787 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #18787   +/-   ##
===========================================
  Coverage   79.4066%   79.4066%           
===========================================
  Files           545        545           
  Lines        148922     148922           
===========================================
  Hits         118254     118254           
  Misses        21246      21246           
  Partials       9422       9422           

Signed-off-by: Wang Ruichao <wangruichao2014@xiaochuankeji.cn>
@wangggong

Copy link
Copy Markdown
Contributor Author

Note that in my opinion some mysql.TypeDecimal can be replaced into mysql.TypeNewDecimal instead of mysql.TypeUnspecified, while some test with the real TiKV cannot pass. To make CI happy, I commit another commit. I'm curious whether the 1st commit is reasonable. If so, I'll try to debug & fix the test with TiKV.

@eurekaka eurekaka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ti-srebot

Copy link
Copy Markdown
Contributor

@eurekaka,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: ddl(slack),execution(slack).

Comment thread cmd/importer/db.go

data = append(data, '\'')
return string(data), nil
case mysql.TypeNewDecimal, mysql.TypeDecimal:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should remove the TypeDecimal here, it's misuse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

revert done, thx~

ditto.

Comment thread ddl/index.go
return mysql.DefaultLengthOfMysqlTypes[mysql.TypeFloat], nil
}
return mysql.DefaultLengthOfMysqlTypes[mysql.TypeDouble], nil
case mysql.TypeDecimal, mysql.TypeNewDecimal:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should remove the TypeDecimal here, it's misuse

}
isFloat := false
switch args[0].GetType().Tp {
case mysql.TypeFloat, mysql.TypeDouble, mysql.TypeDecimal:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to change this TypeDecimal to TypeNewDecimal

{Value: types.NewFloat64Datum(0.2), RetType: types.NewFieldType(mysql.TypeFloat)},
{{- end }}
{{- if eq .Input.ETName "Decimal" }}
{Value: types.NewDecimalDatum(types.NewDecFromInt(10)), RetType: types.NewFieldType(mysql.TypeDecimal)},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be changed to TypeNewDecimal

{{- end }}
{{- if eq .Input.ETName "Decimal" }}
{Value: types.NewDecimalDatum(types.NewDecFromInt(10)), RetType: types.NewFieldType(mysql.TypeDecimal)},
{Value: types.NewDecimalDatum(types.NewDecFromInt(20)), RetType: types.NewFieldType(mysql.TypeDecimal)},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be changed to TypeNewDecimal

Comment thread types/etc.go
func IsTypeNumeric(tp byte) bool {
switch tp {
case mysql.TypeBit, mysql.TypeTiny, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeNewDecimal,
mysql.TypeDecimal, mysql.TypeFloat, mysql.TypeDouble, mysql.TypeShort:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should change this to TypeNewDecimal

Comment thread types/etc_test.go
res = IsTypeNumeric(mysql.TypeNewDecimal)
c.Assert(res, Equals, true)

res = IsTypeNumeric(mysql.TypeDecimal)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should change this to TypeNewDecimal

Comment thread types/field_type.go Outdated
@@ -763,7 +763,7 @@ var fieldTypeMergeRules = [fieldTypeNum][fieldTypeNum]byte{
/* mysql.TypeYear -> */
{
//mysql.TypeDecimal mysql.TypeTiny

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment also need to be changed


// cast(bad_string as decimal)
for _, s := range []string{"hello", ""} {
f = BuildCastFunction(ctx, &Constant{Value: types.NewDatum(s), RetType: types.NewFieldType(mysql.TypeDecimal)}, tp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs to be changed to TypeNewDecimal

Signed-off-by: Wang Ruichao <wangruichao2014@xiaochuankeji.cn>
colExprs = append(colExprs, dg.genColumn(mysql.TypeEnum, 3))
colExprs = append(colExprs, dg.genColumn(mysql.TypeGeometry, 4))
colExprs = append(colExprs, dg.genColumn(mysql.TypeUnspecified, 5))
colExprs = append(colExprs, dg.genColumn(mysql.TypeDecimal, 6))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since if mysql.TypeDecimal is replaced into mysql.TypeUnspecified, the test will duplicate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can change this TypeDecimal to TypeNewDecimal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Emmmm... The test for mysql.TypeNewDecimal has been added in the following code. Add it will also duplicate.

@XuHuaiyu XuHuaiyu changed the title fix: remove mysql.TypeDecimal *: remove mysql.TypeDecimal Jul 28, 2020
XuHuaiyu
XuHuaiyu previously approved these changes Jul 28, 2020

@XuHuaiyu XuHuaiyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 28, 2020
tangenta
tangenta previously approved these changes Jul 28, 2020

@tangenta tangenta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 28, 2020
ti-srebot
ti-srebot previously approved these changes Jul 28, 2020
@tangenta

Copy link
Copy Markdown
Contributor

@wangggong We should update the parser dependency through

go get -v github.com/pingcap/parser@1259bef
go mod tidy

@wangggong

Copy link
Copy Markdown
Contributor Author

@wangggong We should update the parser dependency through

go get -v github.com/pingcap/parser@1259bef
go mod tidy

done, thx~ However there're some structs deleted in parser repo and still be used in tidb repo, making compile cannot be completed. I will try to fix it.

@AilinKid

Copy link
Copy Markdown
Contributor

/run-all-tests

@wangggong
wangggong dismissed stale reviews from ti-srebot, tangenta, and XuHuaiyu via 72be457 July 28, 2020 15:54
@wangggong

Copy link
Copy Markdown
Contributor Author

@wangggong We should update the parser dependency through

go get -v github.com/pingcap/parser@1259bef
go mod tidy

done. @tangenta @XuHuaiyu @AilinKid PTAL

@AilinKid

Copy link
Copy Markdown
Contributor

/run-all-tests

@AilinKid

Copy link
Copy Markdown
Contributor

/run-integration-compatibility-test

@AilinKid

Copy link
Copy Markdown
Contributor

/run-check_dev

@AilinKid

Copy link
Copy Markdown
Contributor

there is some max display length problem in TiDB-Test repo, I've added a parser variable to control the behavior. Focusing on pingcap/parser#949, update your parser again when it merged. Thanks

@AilinKid

AilinKid commented Jul 29, 2020 •

Copy link
Copy Markdown
Contributor

go get -v github.com/pingcap/parser@5fe0b0fdf629026232c91b80ea50e734315bf9e3
go mod tidy

Hi~ pls update the parser to pass the failed tests.

@AilinKid

Copy link
Copy Markdown
Contributor

/run-all-tests

Wang Ruichao added 2 commits July 29, 2020 14:55
@wangggong

Copy link
Copy Markdown
Contributor Author

there is some max display length problem in TiDB-Test repo, I've added a parser variable to control the behavior. Focusing on pingcap/parser#949, update your parser again when it merged. Thanks

OK, done~

@AilinKid

Copy link
Copy Markdown
Contributor

/run-all-tests

@AilinKid

Copy link
Copy Markdown
Contributor

/run-integration-compatibility-test

@AilinKid

Copy link
Copy Markdown
Contributor

/run-integration-copr-test

@AilinKid

Copy link
Copy Markdown
Contributor

/run-integration-compatibility-test

@AilinKid

Copy link
Copy Markdown
Contributor

/run-integration-common-test

@AilinKid

Copy link
Copy Markdown
Contributor

/rebuild

@AilinKid

Copy link
Copy Markdown
Contributor

/run-all-tests

@AilinKid

Copy link
Copy Markdown
Contributor

/run-unit-test

@AilinKid

Copy link
Copy Markdown
Contributor

The CI failure seems nothing to do with this PR.
This PR has blocked some pr with newer parser ( make dev will fail), that's why we merge it fristly here.

@AilinKid
AilinKid merged commit 4170007 into pingcap:master Jul 29, 2020
@wangggong
wangggong deleted the TypeDecimal branch July 29, 2020 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/expression contribution This PR is from a community contributor. sig/sql-infra SIG: SQL Infra status/LGT3 The PR has already had 3 LGTM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove mysql/type.go: TypeDecimal

6 participants