Thread

  1. Re: Range Types

    Jeff Davis <pgsql@j-davis.com> — 2011-09-01T07:32:25Z

    Updated patch attached.
    
    Changes:
    
    1. Now supports new constructor scheme. If you define a range foorange,
    you get the following constructors:
     * foorange() -- produces empty foorange
     * foorange(S) -- produces singleton range [S]
     * foorange(L,B) -- produces range [L,B)
     * foorange(L,B,'(]') -- produces range (L,B]
    
    Actually, the two-argument form uses a special "default_flags" that can
    be specified at creation time, and that defaults to '[)'.
    
    The way I accomplish this is by generating 4 functions at definition
    time -- a little ugly, and I am open to suggestions. I ran into a
    problem using the default argument as Robert suggested because
    pg_node_tree doesn't have a working input function (intentionally so),
    so I couldn't get the built-in range types to work with initdb. The
    constructors all essentially point to the same C function, aside from
    some indirection that I did to avoid excessive complaining from the
    opr_sanity test. Again, suggestions welcome.
    
    2. Documentation has been updated.
    
    3. Now there's support for multiple range types over a single base type,
    e.g. two text ranges using different collations.
    
    TODO:
    
    There is still some cleanup to do, e.g. pg_dump. I'd like to get some
    feedback to stabilize the user-facing behavior before I put too much
    effort into the code cleanup (which shouldn't take long, but I just
    don't want to work toward a moving target).
    
    Regards,
    	Jeff Davis