| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: polymorphic SQL functions has a problem with domains |
| Date: | 2014-04-02 15:19:12 |
| Message-ID: | 14886.1396451952@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> I was informed about impossibility to use a polymorphic functions together
> with domain types
> see
> create domain xx as numeric(15);
> create or replace function g(anyelement, anyelement)
> returns anyelement as
> $$ select $1 + $2 $$
> language sql immutable;
> postgres=# select g(1::xx, 2::xx);
> ERROR: return type mismatch in function declared to return xx
> DETAIL: Actual return type is numeric.
> CONTEXT: SQL function "g" during inlining
That example doesn't say you can't use polymorphic functions with domains.
It says that this particular polymorphic function definition is wrong:
it is not making sure its result is of the expected data type. I don't
recall right now whether SQL functions will apply an implicit cast on the
result for you, but even if they do, an upcast from numeric to some domain
over numeric wouldn't be implicit.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2014-04-02 15:23:22 | Re: polymorphic SQL functions has a problem with domains |
| Previous Message | Pavel Stehule | 2014-04-02 15:07:42 | polymorphic SQL functions has a problem with domains |