Re: DEFAULT of domain ignored in plpgsql (8.4.1)

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgresql-Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DEFAULT of domain ignored in plpgsql (8.4.1)
Date: 2009-11-21 21:30:41
Message-ID: 4B085C01.9040009@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gurjeet Singh wrote:
> On Sat, Nov 21, 2009 at 7:26 AM, Josh Berkus <josh(at)agliodbs(dot)com
> <mailto:josh(at)agliodbs(dot)com>> wrote: However, there are some other
> issues to be resolved:
>
> (1) what should be the interaction of DEFAULT parameters and domains
> with defaults?
>
> The function's DEFAULT parameter should take precedence over the
> default of the domain.

I think Josh was pondering whether

create domain myint as int default 0;
create function f(i myint) ...;

should behave like

create function f(i myint default 0) ...;

and hence call f(0) if you do "select f();", or instead
raise an error because no f with zero parameters is defined (as it does
now).

I'd say no, because "no default" should be treated the same as "default
null", so for consistency we'd then have to also support

create function g(i int) ...;
select g();

And of course throw an error if there was another function defined as
create function g() ...;

This way leads to madness...

If one really wanted to do that, there'd have to be an OPTIONAL clause
for function parameters that works like DEFAULT, but doesn't take a
default value and instead uses the type's default (NULL except for
domains with DEFAULT clause). But I wouldn't got that far, personally...

best regards,
Florian Pflug

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-11-21 22:49:42 Ignoring white space in regression tests really a good idea?
Previous Message Florian G. Pflug 2009-11-21 21:20:17 Re: DEFAULT of domain ignored in plpgsql (8.4.1)