X-Original-To: pgsql-hackers-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 505F89FB2DC for ; Thu, 3 Aug 2006 21:41:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 83373-05 for ; Thu, 3 Aug 2006 21:41:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from b.mail.sonic.net (b.mail.sonic.net [64.142.19.5]) by postgresql.org (Postfix) with ESMTP id 627009FB205 for ; Thu, 3 Aug 2006 21:41:49 -0300 (ADT) Received: from localhost.localdomain (64-142-36-103.dsl.static.sonic.net [64.142.36.103]) by b.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id k740flSs028105 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Thu, 3 Aug 2006 17:41:47 -0700 Received: from elein by localhost.localdomain with local (Exim 4.50) id 1G8ngn-0002eh-6h; Thu, 03 Aug 2006 17:37:21 -0700 Date: Thu, 3 Aug 2006 17:37:21 -0700 To: Tom Lane Cc: Martijn van Oosterhout , Teodor Sigaev , Pgsql Hackers Subject: Re: User-defined typle similar to char(length) varchar(length) Message-ID: <20060804003720.GF9697@varlena.com> Mail-Followup-To: Tom Lane , Martijn van Oosterhout , Teodor Sigaev , Pgsql Hackers References: <44CF56BF.9070003@sigaev.ru> <1748.1154438988@sss.pgh.pa.us> <44CF6983.5060605@sigaev.ru> <20060801145156.GH30427@svana.org> <29387.1154489219@sss.pgh.pa.us> <44D23F6B.3090801@sigaev.ru> <20060803193754.GD20080@svana.org> <25285.1154636333@sss.pgh.pa.us> <20060803204954.GF20080@svana.org> <26292.1154639087@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26292.1154639087@sss.pgh.pa.us> User-Agent: Mutt/1.5.9i From: elein X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/180 X-Sequence-Number: 87673 On Thu, Aug 03, 2006 at 05:04:47PM -0400, Tom Lane wrote: > Martijn van Oosterhout 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. I can think of histograms as a data type which may take more than one argument, maybe even an array for boundary information. I think the direction *in the long term* should be to allow multiple arguments (as a ROW type?) and other base or complex types as arguments. The value would be a type itself and the datatype must do the right thing regarding it. This may not be practical for short-term, but would open up initialization parameters for user-defined typed. --elein > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend >