Re: Numeric Type Precision Not Respected in Function or Procedure Arguments - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Numeric Type Precision Not Respected in Function or Procedure Arguments
Date
Msg-id 2973998.1758576667@sss.pgh.pa.us
Whole thread Raw
In response to Numeric Type Precision Not Respected in Function or Procedure Arguments  (Aaron Ackerman <aackerman@goodmorning.com>)
List pgsql-bugs
Aaron Ackerman <aackerman@goodmorning.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



pgsql-bugs by date:

Previous
From: Aaron Ackerman
Date:
Subject: Numeric Type Precision Not Respected in Function or Procedure Arguments
Next
From: "David G. Johnston"
Date:
Subject: Re: Numeric Type Precision Not Respected in Function or Procedure Arguments