GetTypmodFromNumericPrecisionAndScale takes Numeric type precision and scale and returns the type modifier value.
(precision, scale int32)
| 89 | |
| 90 | // GetTypmodFromNumericPrecisionAndScale takes Numeric type precision and scale and returns the type modifier value. |
| 91 | func GetTypmodFromNumericPrecisionAndScale(precision, scale int32) (int32, error) { |
| 92 | if precision < 1 || precision > 1000 { |
| 93 | return 0, errors.Errorf("NUMERIC precision %v must be between 1 and 1000", precision) |
| 94 | } |
| 95 | if scale < -1000 || scale > 1000 { |
| 96 | return 0, errors.Errorf("NUMERIC scale 20000 must be between -1000 and 1000") |
| 97 | } |
| 98 | return ((precision << 16) | scale) + 4, nil |
| 99 | } |
| 100 | |
| 101 | // GetPrecisionAndScaleFromTypmod takes Numeric type modifier and returns precision and scale values. |
| 102 | func GetPrecisionAndScaleFromTypmod(typmod int32) (int32, int32) { |
no test coverage detected