Re: Domains and function arguments - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Domains and function arguments
Date
Msg-id 6362.1055793955@sss.pgh.pa.us
Whole thread Raw
In response to Domains and function arguments  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Domains and function arguments
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> The SQL standard does not allow functions to have domains as arguments.
> Semantically, they have a point.

I don't think they do.  Declaring a domain as the input type seems a
very natural way of asserting that the function only works over a subset
of the base input type.  For example, log() might usefully be declared
to take arguments from a "positivereal" domain.

Admittedly, we have trouble resolving the type to use when a function is
overloaded with both a domain and a base type, but that's hardly
surprising.

The present algorithm for ambiguous-function resolution is probably
excessively unfriendly to functions with domain inputs: it will match
them *only* when they are an exact match (ie, the input argument is
already declared or coerced to the domain type).  I think that's bowing
quite far enough in the direction of the standard; I'd like to loosen
it someday, but don't have time to think about it more right now.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Errors compiling hba.c in current CVS
Next
From: "Yurgis Baykshtis"
Date:
Subject: Re: PostgreSQL and Windows