From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: range_agg |
Date: | 2020-01-20 04:49:38 |
Message-ID: | CAFj8pRA+bBBE_4toavfzjXAOT7JssDj8uiHLjdZtFpfUQzRyMA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
po 20. 1. 2020 v 1:38 odesílatel Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> napsal:
> Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> writes:
> > On Sun, Jan 19, 2020 at 12:10 AM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
> >> Now, I think so name "anymultirange" is not good. Maybe better name is
> just "multirange"
>
> > Are you sure? This function exists to be a cast to an anymultirange,
> > and I thought the convention was to name cast functions after their
> > destination type.
>
> True for casts involving concrete types, mainly because we'd like
> the identity "value::typename == typename(value)" to hold without
> too much worry about whether the latter is a plain function call
> or a special case. Not sure whether it makes as much sense for
> polymorphics, since casting to a polymorphic type is pretty silly:
> we do seem to allow you to do that, but it's a no-op.
>
> I'm a little troubled by the notion that what you're talking about
> here is not a no-op (if it were, you wouldn't need a function).
> That seems like there's something fundamentally not quite right
> either with the design or with how you're thinking about it.
>
I thinking about completeness of operations
I can to write
CREATE OR REPLACE FUNCTION fx(anyarray, anyelement)
RETURNS anyarray AS $$
SELECT $1 || ARRAY[$2]
$$ LANGUAGE sql;
I need to some functionality for moving a value to different category (it
is more generic than casting to specific type (that can hold category)
CREATE OR REPLACE FUNCTION fx(anymultirange, anyrange)
RETURNS anyrage AS $$
SELECT $1 + multirange($1)
$$ LANGUAGE sql;
is just a analogy.
Regards
Pavel
> As a comparison point, we sometimes describe subscripting as
> being a polymorphic operation like
>
> subscript(anyarray, integer) returns anyelement
>
> It would be completely unhelpful to call that anyelement().
> I feel like you might be making a similar mistake here.
>
> Alternatively, consider this: a cast from some concrete multirange type
> to anymultirange is a no-op, while any other sort of cast probably ought
> to be casting to some particular concrete multirange type. That would
> line up with the existing operations for plain ranges.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | 김대호 | 2020-01-20 05:11:05 | Add limit option to copy function |
Previous Message | Prabhu R | 2020-01-20 04:35:58 | Master Master replication |