Re: Restriction of windows functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Restriction of windows functions
Date
Msg-id 21487.1466176338@sss.pgh.pa.us
Whole thread Raw
In response to Re: Restriction of windows functions  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
List pgsql-hackers
Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes:
> On 17.06.2016 17:01, Tom Lane wrote:
>> IIRC, the sticking point was defining a reasonably datatype-independent
>> (i.e. extensible) notion of distance.

> Why it is not possible just to locate "-" or "+ operator for this type?

Because there's no guarantee that that operator has anything to do with
the sort ordering imposed by the type's btree opclass.  We must have a
distance operator that is consistent with the sort order, or the windowing
logic will get hopelessly confused.  For that matter, we support multiple
opclasses (sort orderings) per data type, and there's certainly no way
that a single "-" operator will be consistent with all of them.

At the time we discussed extending the definition of a btree opclass to
allow specification of related "+" and "-" operators, but the
infrastructure additions required seemed rather daunting.  Now that
we have pg_amop.amoppurpose, it might be easier to add such a concept;
they could be put in with a new "purpose" that shows that they are
not intended as index search operators.

Again, please see the archives.  I'm just speaking off the cuff here,
and probably don't remember all the details.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: Should phraseto_tsquery('simple', 'blue blue') @@ to_tsvector('simple', 'blue') be true ?
Next
From: Aleksey Demakov
Date:
Subject: Experimental dynamic memory allocation of postgresql shared memory