From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Aaron Ackerman <aackerman(at)goodmorning(dot)com> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Numeric Type Precision Not Respected in Function or Procedure Arguments |
Date: | 2025-09-22 21:31:07 |
Message-ID: | 2973998.1758576667@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Aaron Ackerman <aackerman(at)goodmorning(dot)com> writes:
> When a NUMERIC type is used as a function or procedure argument, the
> value does not actually follow the user-defined precision, such as
> NUMERIC(10,4). It does not round off the value to the specified scale
> or check for an overflow error. Return type of function also does not
> respect precision.
This is documented. See for example in [1]:
The full SQL type syntax is allowed for declaring a function's
arguments and return value. However, parenthesized type modifiers
(e.g., the precision field for type numeric) are discarded by
CREATE FUNCTION. Thus for example CREATE FUNCTION foo
(varchar(10)) ... is exactly the same as CREATE FUNCTION foo
(varchar) ....
Perhaps we should reject type modifiers in CREATE FUNCTION,
since people do get confused about this. (The alternative of
actually doing something with them is in aint-gonna-happen
territory, I think.)
regards, tom lane
[1] https://www.postgresql.org/docs/current/sql-createfunction.html
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2025-09-22 21:33:45 | Re: Numeric Type Precision Not Respected in Function or Procedure Arguments |
Previous Message | Aaron Ackerman | 2025-09-22 19:39:38 | Numeric Type Precision Not Respected in Function or Procedure Arguments |