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

infoschema: refine infoschema's MaxLength Precision value #7463

Merged
merged 2 commits into from
Aug 24, 2018
Merged

infoschema: refine infoschema's MaxLength Precision value #7463

merged 2 commits into from
Aug 24, 2018

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Aug 22, 2018

What problem does this PR solve?

fixes #7396

What is changed and how it works?

set value for CHARACTER_MAXIMUM_LENGTH,CHARACTER_OCTET_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE,DATETIME_PRECISION base on different column type.

see more example in new added TestCase

Tests

  • Unit test

Code changes

  • impl change

Side effects

  • no

Related changes

  • no

This change is Reviewable

@lysu
Copy link
Contributor Author

lysu commented Aug 22, 2018

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented Aug 22, 2018

/run-common-test tidb-test=pr/611
/run-integration-common-test tidb-test=pr/611

@@ -792,8 +792,12 @@ func dataForColumns(ctx sessionctx.Context, schemas []*model.DBInfo) [][]types.D
func dataForColumnsInTable(schema *model.DBInfo, tbl *model.TableInfo) [][]types.Datum {
var rows [][]types.Datum
for i, col := range tbl.Columns {
var charMaxLen, charOctLen, numericPrecision, numericScale, datetimePrecision interface{}
Copy link
Member

Choose a reason for hiding this comment

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

Why not use int instead of interface{}? Are there any benefits of using interface{} here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using interface{}, we can got NULL result~

Copy link
Member

Choose a reason for hiding this comment

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

interface is really slow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes~~we should void using interface{} as we can, but in this case is special, types.MakeDatums accept args ...interface{} as arguments.

cast to interface always happen, so direct using interface{} local variable is simple.

we also can use *int local varible instead of interface{}, but that will make us step into a well-known trap in go https://play.golang.org/p/qw6UJhvZcrR

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu lysu added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 23, 2018
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 24, 2018
@ngaut ngaut merged commit db873d6 into pingcap:master Aug 24, 2018
@lysu lysu deleted the fix-infoschema branch September 27, 2018 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INFORMATION_SCHEMA.COLUMNS's PRECISION value for different type
4 participants