Re: Implementing SQL ASSERTION - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: Implementing SQL ASSERTION
Date
Msg-id 87pnwvewny.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: Implementing SQL ASSERTION  (Joe Wildish <joe-postgresql.org@elusive.cx>)
Responses Re: Implementing SQL ASSERTION
List pgsql-hackers
>>>>> "Joe" == Joe Wildish <joe-postgresql.org@elusive.cx> writes:

 >> I haven't looked at the background of this, but if what you want to
 >> know is whether the aggregate function has the semantics of min() or
 >> max() (and if so, which) then the place to look is
 >> pg_aggregate.aggsortop.

 Joe> Thanks for the pointer. I've had a quick look at pg_aggregate, and
 Joe> back at my code, but I think there is more to it than just the
 Joe> sorting property. Specifically we need to know about the aggregate
 Joe> function when combined with connectors <, <=, < ANY, <= ANY, < ALL
 Joe> and <= ALL (and their equivalents with ">" and ">=").

The presence of an aggsortop means "this aggregate function is
interchangeable with (select x from ... order by x using OP limit 1)",
with all of the semantic consequences that implies. Since OP must be the
"<" or ">" member of a btree index opclass, the semantics of its
relationships with other members of the same opfamily can be deduced
from that.

 Joe> Also, it looks like COUNT and SUM don't have a sortop

Right, because those currently have no semantics that PG needs to know
about or describe.

-- 
Andrew (irc:RhodiumToad)


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Cygwin linking rules
Next
From: Andrew Gierth
Date:
Subject: Re: Odd 9.4, 9.3 buildfarm failure on s390x