Re: DEFAULT of domain ignored in plpgsql (8.4.1)

Поиск
Список
Период
Сортировка
От Florian G. Pflug
Тема Re: DEFAULT of domain ignored in plpgsql (8.4.1)
Дата
Msg-id 4B085C01.9040009@phlo.org
обсуждение исходный текст
Ответ на Re: DEFAULT of domain ignored in plpgsql (8.4.1)  (Gurjeet Singh <singh.gurjeet@gmail.com>)
Список pgsql-hackers
Gurjeet Singh wrote:
> On Sat, Nov 21, 2009 at 7:26 AM, Josh Berkus <josh@agliodbs.com 
> <mailto:josh@agliodbs.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Florian G. Pflug"
Дата:
Сообщение: Re: DEFAULT of domain ignored in plpgsql (8.4.1)
Следующее
От: Tom Lane
Дата:
Сообщение: Ignoring white space in regression tests really a good idea?