Lists: | pgsql-hackers |
---|
From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | domain casting? |
Date: | 2007-08-10 17:21:10 |
Message-ID: | 162867790708101021i4b70ecc0r766f79448b8a0a40@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
I try casting function for domains. I can do it, but it doesn't work.
betal=# create domain mydomain text;
CREATE DOMAIN
betal=#
betal=# create or replace function mydomain_todate(mydomain)
betal-# returns date as $$
betal$# select to_date($1, 'YYYYMMDD');
betal$# $$ language sql;
CREATE FUNCTION
betal=#
betal=# create cast (mydomain as date)
betal-# with function mydomain_todate(mydomain);
CREATE CAST
betal=#
betal=# select mydomain_todate('20070715777'::mydomain);
mydomain_todate
-----------------
2007-07-15
(1 row)
betal=#
betal=# select '20070715777'::mydomain::date;
ERROR: invalid input syntax for type date: "20070715777"
betal=#
Is possible casting domain?
Regards
Pavel Stehule
betal=# select version();
version
-------------------------------------------------------------------------------------------------------
PostgreSQL 8.3devel on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
4.1.2 20070502 (Red Hat 4.1.2-12)
(1 row)
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: domain casting? |
Date: | 2007-08-10 18:08:21 |
Message-ID: | 11007.1186769301@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
"Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> Is possible casting domain?
No, because find_coercion_pathway() expects that only base types are
listed in pg_cast, so it starts by stripping domains. Function lookup
tends to do that too, so it's hard even to declare a function as taking
a domain.
Elein was going to look into devising a more domain-friendly set of
type coercion rules, but I dunno if she's made any progress.
regards, tom lane