Re: domain usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: domain usage
Date: 2002-07-14 18:58:14
Message-ID: 20235.1026673094@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> I have a question about the use of domains in 7.3.
> Will I be able to use them to catch mistakes in doing comparisons
> or value setting between objects with the same underlying type but
> in different domains (without doing an explicit type cast)?

No, I don't think so. It certainly doesn't work at the moment:

regression=# create domain d1 int4;
CREATE DOMAIN
regression=# create domain d2 int4;
CREATE DOMAIN
regression=# select '1'::d1 = '1'::d2;
?column?
----------
t
(1 row)

The reason it doesn't work is that d1 and d2 are treated as
binary-compatible with int4, so the int4 = operator is found and
applied.

If we did not have this binary-compatibility behavior, domains would be
near useless, because out-of-the-box they'd have no applicable functions
or operators at all. Do you want to have to issue a ton of CREATE
FUNCTION and CREATE OPERATOR commands for every domain you make?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2002-07-14 20:10:51 Re: domain usage
Previous Message Bruno Wolff III 2002-07-14 18:55:49 domain usage