Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v0o7y-000p4D-7V for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Sep 2025 21:31:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v0o7w-002HnV-PV for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Sep 2025 21:31:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v0o7w-002Hl6-G4 for pgsql-bugs@lists.postgresql.org; Mon, 22 Sep 2025 21:31:16 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v0o7r-001pTh-00 for pgsql-bugs@lists.postgresql.org; Mon, 22 Sep 2025 21:31:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 58MLV7YV2973999; Mon, 22 Sep 2025 17:31:07 -0400 From: Tom Lane To: Aaron Ackerman cc: pgsql-bugs@lists.postgresql.org Subject: Re: Numeric Type Precision Not Respected in Function or Procedure Arguments In-reply-to: References: Comments: In-reply-to Aaron Ackerman message dated "Mon, 22 Sep 2025 13:39:38 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2973997.1758576667.1@sss.pgh.pa.us> Date: Mon, 22 Sep 2025 17:31:07 -0400 Message-ID: <2973998.1758576667@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Aaron Ackerman 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