Is your feature request related to a problem? Please describe:
Describe the feature you'd like:
MySQL (at least since 5.6) has the @@div_precision_increment system variable which controls the precision of division result (default is 4). If we compute p/q where p and q are both exact, and p has type DECIMAL(m, d), then the result p/q has type DECIMAL(?, d + @@div_precision_increment).
Feature Request
Is your feature request related to a problem? Please describe:
Describe the feature you'd like:
MySQL (at least since 5.6) has the
@@div_precision_increment
system variable which controls the precision of division result (default is 4). If we computep/q
wherep
andq
are both exact, andp
has typeDECIMAL(m, d)
, then the resultp/q
has typeDECIMAL(?, d + @@div_precision_increment)
.TiDB currently knows the existence of a
@@div_precision_increment
sys var but changing it is no-op because the "4" is hard-coded inhttps://github.com/pingcap/tidb/blob/7e3074afa3f3db4555e44e720d7ed77d9797e501/expression/builtin_arithmetic.go#L58-L60
Describe alternatives you've considered:
Don't support it, it's a niche feature which can be worked around through
cast
or manually increasing the precision anyway.Teachability, Documentation, Adoption, Migration Strategy: