Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJr2B-0005Oj-TW for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 22:05:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YJr2B-0005Lb-C4 for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Feb 2015 22:05:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJr2A-0005Jk-68 for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 22:05:54 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJr26-0000qk-5O for pgsql-bugs@postgresql.org; Fri, 06 Feb 2015 22:05:53 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id ABF1B1316A44 for ; Fri, 6 Feb 2015 14:05:49 -0800 (PST) Date: Fri, 6 Feb 2015 15:05:48 -0700 (MST) From: David G Johnston To: pgsql-bugs@postgresql.org Message-ID: <1423260348880-5837000.post@n5.nabble.com> In-Reply-To: <4295.1423259824@sss.pgh.pa.us> References: <54D39E4A.9030600@opalsoftware.co.uk> <4295.1423259824@sss.pgh.pa.us> Subject: Re: Function parameter type precision modifiers ignored. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) 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 Tom Lane-2 wrote > Mark Simonetti < > marks@.co > > 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. http://www.postgresql.org/docs/9.4/interactive/sql-createfunction.html @ Notes First Paragraph Maybe it would be more obvious in the section detailing "argtype"...but its not like its buried deep in the documentation. The bigger problem is understanding exactly what that notes means in reality. Often that means getting bit by the behavior first and then reading about what just bit you. Happens to all of us. I'm for the idea of issuing a syntax error upon seeing "type()" in general but not strongly since perfectly valid code (often back-stopped by table constraints) currently works and would otherwise have no reason to change other than to conform to this decision. David J. -- View this message in context: http://postgresql.nabble.com/Function-parameter-type-precision-modifiers-ignored-tp5836988p5837000.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs