Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJqtn-00051G-27 for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 21:57:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YJqtm-0002ys-Ho for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 21:57:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJqtl-0002yj-Fr for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 21:57:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJqtg-0000VU-VN for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 21:57:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t16Lv4qb004296; Fri, 6 Feb 2015 16:57:04 -0500 From: Tom Lane To: Mark Simonetti cc: pgsql-bugs@postgresql.org Subject: Re: Function parameter type precision modifiers ignored. In-reply-to: <54D39E4A.9030600@opalsoftware.co.uk> References: <54D39E4A.9030600@opalsoftware.co.uk> Comments: In-reply-to Mark Simonetti message dated "Thu, 05 Feb 2015 16:46:02 +0000" Date: Fri, 06 Feb 2015 16:57:04 -0500 Message-ID: <4295.1423259824@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Mark Simonetti writes: > I don't know if this is a bug as such, but the behaviour certainly > confused me for a while : - > Given the following PostgreSQL functions: > CREATE OR REPLACE FUNCTION fn_dtm ( > dtm timestamptz(0)) > RETURNS void AS $$ > BEGIN > RAISE NOTICE 'fn: %, %', dtm, dtm::timestamptz(0); > END; > $$ LANGUAGE plpgsql; > CREATE OR REPLACE FUNCTION fn_num ( > num numeric(5, 2)) > RETURNS void AS $$ > BEGIN > RAISE NOTICE 'num: %, %', num, num::numeric(5, 2); > END; > $$ LANGUAGE plpgsql; > Would you expect the output of these functions to show the result as per > the type declared in the function parameter? Attributes applied to function parameter types --- or result types for that matter --- are entirely ignored by Postgres; only the base type matters. This is documented. There's been some talk of rejecting syntax like the above, because we get bug reports like this once or twice a year, so obviously a lot of people are confused about what happens. The odds of actually enforcing such typmods anytime in the near future are not distinguishable from zero, but we could make CREATE FUNCTION throw an error. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs