pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Simonetti <marks@opalsoftware.co.uk>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Function parameter type precision modifiers ignored.
Date: Fri, 06 Feb 2015 16:57:04 -0500
Message-ID: <4295.1423259824@sss.pgh.pa.us> (raw)
In-Reply-To: <54D39E4A.9030600@opalsoftware.co.uk>
References: <54D39E4A.9030600@opalsoftware.co.uk>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Mark Simonetti <marks@opalsoftware.co.uk> 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



view thread (4+ messages)  latest in thread

Message-ID: <4295.1423259824@sss.pgh.pa.us>
Permalink:  ../4295.1423259824@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4295.1423259824@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 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: tgl@sss.pgh.pa.us, marks@opalsoftware.co.uk
  Subject: Re: Function parameter type precision modifiers ignored.
  In-Reply-To: <4295.1423259824@sss.pgh.pa.us>
  References: <54D39E4A.9030600@opalsoftware.co.uk> <4295.1423259824@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