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
type: make decimal default precision visible in show create table
#7667
Conversation
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.
LGTM
/run-all-tests |
types/field_type.go
Outdated
} | ||
suffix += ")" | ||
} else { | ||
suffix = "(10,0)" |
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.
the default fsp for tidb seem be not 10
which is different to mysql
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.
ok
PTAL @lysu |
/run-all-tests |
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.
LGTM
types/field_type.go
Outdated
} | ||
suffix += ")" | ||
} else { | ||
suffix = fmt.Sprintf("(%d,0)", defaultFlen) | ||
} |
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.
how about
if isFlenNotDefault {
} else {
}
if isDecimalNotDefault {
} else {
}
types/field_type.go
Outdated
} | ||
suffix += ")" | ||
} else { | ||
suffix = fmt.Sprintf("(%d,0)", defaultFlen) |
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.
It would be simpler if calculate the displayFlen
and displayDecimal
first, then just Sprintf once.
suffix = fmt.Sprintf("(%d,%d)", displayFlen, displayDecimal)
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.
When the type is mysql.TypeNewDecimal, why still need to check isFlenNotDefault or isDecimalNotDefault? What about just using suffix = fmt.Sprintf("(%d,%d)", displayFlen, displayDecimal)
?
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.
@winkyao , have you checked it with MySQL?
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.
I think just use suffix = fmt.Sprintf("(%d,%d)", displayFlen, displayDecimal)
is okay.
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.
When it is a decimal type, mysql show decimal length in show create table anyway. @jackysp
types/field_type.go
Outdated
@@ -231,8 +231,12 @@ func (ft *FieldType) CompactStr() string { | |||
suffix = fmt.Sprintf("(%d", displayFlen) | |||
if isDecimalNotDefault { |
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.
how about:
if isFlenNotDefault {
prefix = xxx
break
}
if isDecimalNotDefault {
prefix = xxx
break
}
prefix = xx
/run-all-tests tidb-test=pr/622 |
1 similar comment
/run-all-tests tidb-test=pr/622 |
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.
LGTM
What problem does this PR solve?
Fix #7665 to make jdbc test happy.
What is changed and how it works?
Add code to make default decimal precision visible in
show create table
.See #7665 for detail.
Check List
Tests
Code changes
Side effects