pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aaron Ackerman <aackerman@goodmorning.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Numeric Type Precision Not Respected in Function or Procedure Arguments
Date: Mon, 22 Sep 2025 17:31:07 -0400
Message-ID: <2973998.1758576667@sss.pgh.pa.us> (raw)
In-Reply-To: <CAF6BKgE2hiOXHjR2E1bLJz1YMrfn6o4+=5gdNUTgsq=Q+MiCFw@mail.gmail.com>
References: <CAF6BKgE2hiOXHjR2E1bLJz1YMrfn6o4+=5gdNUTgsq=Q+MiCFw@mail.gmail.com>

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





view thread (3+ messages)  latest in thread

Message-ID: <2973998.1758576667@sss.pgh.pa.us>
Permalink:  ../2973998.1758576667@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2973998.1758576667@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, aackerman@goodmorning.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Numeric Type Precision Not Respected in Function or Procedure Arguments
  In-Reply-To: <2973998.1758576667@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox