Re: Type modifiers for DOMAIN
Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
From: Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Date: 2010-01-07T00:43:23Z
Lists: pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Because the domain is supposed to be opaque as to exactly what its
> underlying type is. In particular, you're supposed to do this:
>
> CREATE DOMAIN varchar2 AS pg_catalog.varchar(10);
>
> If you look in the SQL spec you will not find any suggestion that it
> should work the way you propose.
Hmmm, it means we need to create domains for each length of character types.
If we allowed domains with pass-through-modifiers, it could save codes
than CREATE (scalar) TYPE.
=# CREATE DOMAIN digit_varchar AS varchar ( <pass-through-modifiers> )
CHECK (VALUE ~ E'^\\d*$');
=# CREATE TABLE tbl (digit10 digit_varchar(10));
Regards,
---
Takahiro Itagaki
NTT Open Source Software Center