Re: User-defined typle similar to char(length) varchar(length) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: User-defined typle similar to char(length) varchar(length)
Date
Msg-id 26292.1154639087@sss.pgh.pa.us
Whole thread Raw
In response to Re: User-defined typle similar to char(length) varchar(length)  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: User-defined typle similar to char(length) varchar(length)
Re: User-defined typle similar to char(length) varchar(length)
Re: User-defined typle similar to char(length)
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Thu, Aug 03, 2006 at 04:18:53PM -0400, Tom Lane wrote:
>> I think we could legislate that the stored typmod is the same as what
>> the user sees (and can't be negative).  The fact that it's different
>> for some of the built-in types is a historical artifact that I'd love
>> to get rid of.

> But that makes NUMERIC(x,y) impossible to represent.

Well, we have to special-case INTERVAL anyway (because its cramming some
truly bizarre things into typmod), and it wouldn't bother me too much to
special-case NUMERIC as well.

Another option is to agree on some simple rule for cramming two values
into one typmod, like first one in the low half and second in the high
half, and then user types could have either one or two typmod values ---
but I can imagine some pretty bizarre behavior if the type is expecting
one value and you enter two or vice versa.  NUMERIC can finesse this
because the default for scale is zero, but in the general case that
wouldn't work so well.

Does anyone have examples of real user-defined types that would need two
fields?  If not it may not be worth spending time on.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: [PATCHES] tg_trigtuple/tg_newtuple settings in AFTER triggers
Next
From: Tom Lane
Date:
Subject: Re: O_NOATIME