fix-sweight-v2.patch
application/octet-stream
Filename: fix-sweight-v2.patch
Type: application/octet-stream
Part: 1
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/utils/adt/numeric.c | 4 | 1 |
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 898c52099b..a42a6ceb18 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -3694,7 +3694,10 @@ numeric_sqrt(PG_FUNCTION_ARGS) init_var(&result); /* Assume the input was normalized, so arg.weight is accurate */ - sweight = (arg.weight + 1) * DEC_DIGITS / 2 - 1; + if (arg.weight < 0) + sweight = (arg.weight + 1) * DEC_DIGITS / 2 - 1; + else + sweight = arg.weight * DEC_DIGITS / 2 + 1; rscale = NUMERIC_MIN_SIG_DIGITS - sweight; rscale = Max(rscale, arg.dscale);