Re: WIP: RangeTypes - Mailing list pgsql-hackers
From | David Fetter |
---|---|
Subject | Re: WIP: RangeTypes |
Date | |
Msg-id | 20110111191334.GB11603@fetter.org Whole thread Raw |
In response to | WIP: RangeTypes (Jeff Davis <pgsql@j-davis.com>) |
Responses |
Re: WIP: RangeTypes
|
List | pgsql-hackers |
On Tue, Jan 11, 2011 at 01:16:47AM -0800, Jeff Davis wrote: > Ok, I have made some progress. This is still a proof-of-concept patch, > but the important pieces are working together. > > Synopsis: > > CREATE TYPE numrange AS RANGE (SUBTYPE=numeric, > SUBTYPE_CMP=numeric_cmp); > > SELECT range_eq('[1,2.2)'::numrange,'[1,2.2]'); > SELECT range_lbound('(3.7,9]'::numrange); > SELECT range(6.7); > SELECT '-'::numrange; -- empty > SELECT '[1, NULL]'::numrange; -- ] will become ) > SELECT '(INF, 3)'::numrange; > > I haven't completed many of the other generic functions, because I'd > like to make sure I'm on the right track first. The important thing > about the functions above is that they show ANYRANGE working in > conjunction with ANYELEMENT in various combinations, which was a > significant part of this patch. > > Here are the open items: > > 1. Generic functions -- most of which are fairly obvious. However, I > want to make sure I'm on the right track first. > > 2. GiST -- I'll need a mechanism to implement the "penalty" function, > and perhaps I'll also need additional support for the picksplit > function. For the "penalty" function, I think I'll need to require a > function to convert the subtype into a float, and I can use that to find > a distance (which can be the penalty). That should also satisfy anything > that picksplit might need. > > 3. Typmod -- There is still one annoyance about typmod remaining. I need > to treat it like an array in find_typmod_coercion_function(), and then > create a coercion expression. Is it worth it? Would typmod on a range be > confusing, or should I just finish this item up? Probably not worth it for the first round. > 4. Docs Happy to help evenings this week :) > 5. Tests Same. What do you have so far? > 6. pg_dump -- should be pretty easy; I just want to settle some of the > other stuff first. > > 7. Right now the parse function is quite dumb. Is there some example > code I should follow to make sure I get this right? KISS is a fine principle. Do you really need it smart on the first round? :) > 8. In order to properly support the various combinations of ANYRANGE and > ANYELEMENT in a function definition (which are all important), we need > to be able to determine the range type given a subtype. That means that > each subtype can only have one associated range, which sounds somewhat > limiting, but it can be worked around by using domains. I don't think > this is a major limitation. Comments? As we get a more nuanced type system, this is one of the things that will need to get reworked, so I'd say it's better not to put too much effort into things that a refactor of the type system <http://wiki.postgresql.org/wiki/Refactor_Type_System> would make much better, at least right now. > Also related to representation: > > * Right now I always align the subtypes within the range according to > typalign. I could avoid that by packing the bytes tightly, and then > copying them around later. Suggestions? And what should the overall > alignment of the range type be? For the first cut, the simplest possible. > * If it's a fixed-length type, we can save the varlena header byte on > the overall range; but we lose the ability to save space when one of the > boundaries of the range is missing (NULL or INF), and it would > complicate the code a little. Thoughts? Probably not worth complicating the code at this stage. KISS again :) Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
pgsql-hackers by date: