pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G Johnston <david.g.johnston@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Re: Function parameter type precision modifiers ignored.
Date: Fri, 6 Feb 2015 15:05:48 -0700 (MST)
Message-ID: <1423260348880-5837000.post@n5.nabble.com> (raw)
In-Reply-To: <4295.1423259824@sss.pgh.pa.us>
References: <54D39E4A.9030600@opalsoftware.co.uk>
	<4295.1423259824@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Tom Lane-2 wrote
> Mark Simonetti &lt;

> marks@.co

> &gt; 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.h...
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



view thread (4+ messages)  latest in thread

Message-ID: <1423260348880-5837000.post@n5.nabble.com>
Permalink:  ../1423260348880-5837000.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1423260348880-5837000.post@n5.nabble.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: Function parameter type precision modifiers ignored.
  In-Reply-To: <1423260348880-5837000.post@n5.nabble.com>
  References: <54D39E4A.9030600@opalsoftware.co.uk> <4295.1423259824@sss.pgh.pa.us> <1423260348880-5837000.post@n5.nabble.com>

* 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